001    /*
002     * (c) Copyright 2009 University of Bristol
003     * All rights reserved.
004     * [See end of file]
005     */
006    
007    package net.rootdev.javardfa;
008    
009    import com.hp.hpl.jena.iri.IRI;
010    import com.hp.hpl.jena.iri.IRIFactory;
011    
012    /**
013     * Resolver that uses the IRI library.
014     * This is the recommended resolver.
015     *
016     * @author pldms
017     */
018    public class IRIResolver implements Resolver {
019        private final IRIFactory iriFactory;
020    
021        /**
022         * Create a semantic web version
023         */
024        public IRIResolver() {
025            this(IRIFactory.semanticWebImplementation());
026        }
027    
028        public IRIResolver(IRIFactory iriFactory) {
029            this.iriFactory = iriFactory;
030        }
031    
032        public String resolve(String first, String second) {
033            if (first == null) throw new RuntimeException("Base is null.");
034            IRI iri = iriFactory.construct(first);
035            IRI resolved = iri.resolve(second);
036            return resolved.toString();
037        }
038    
039    }
040    
041    /*
042     * (c) Copyright 2009 University of Bristol
043     * All rights reserved.
044     *
045     * Redistribution and use in source and binary forms, with or without
046     * modification, are permitted provided that the following conditions
047     * are met:
048     * 1. Redistributions of source code must retain the above copyright
049     *    notice, this list of conditions and the following disclaimer.
050     * 2. Redistributions in binary form must reproduce the above copyright
051     *    notice, this list of conditions and the following disclaimer in the
052     *    documentation and/or other materials provided with the distribution.
053     * 3. The name of the author may not be used to endorse or promote products
054     *    derived from this software without specific prior written permission.
055     *
056     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
057     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
058     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
059     * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
060     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
061     * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
062     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
063     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
064     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
065     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
066     */