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 java.net.URI;
010    import java.net.URISyntaxException;
011    
012    /**
013     * Resolver that uses java's URI library.
014     * The IRI resolver is strongly recommended over this.
015     *
016     * @author pldms
017     */
018    public class URIResolver implements Resolver {
019    
020        public URIResolver() { }
021    
022        public String resolve(String first, String second) {
023            try {
024                URI uri = new URI(first);
025                return uri.resolve(second).toString();
026            } catch (URISyntaxException ex) {
027                throw new RuntimeException("Problem resolving URI: " +
028                        first + " " + second, ex);
029            }
030        }
031    
032    }
033    
034    /*
035     * (c) Copyright 2009 University of Bristol
036     * All rights reserved.
037     *
038     * Redistribution and use in source and binary forms, with or without
039     * modification, are permitted provided that the following conditions
040     * are met:
041     * 1. Redistributions of source code must retain the above copyright
042     *    notice, this list of conditions and the following disclaimer.
043     * 2. Redistributions in binary form must reproduce the above copyright
044     *    notice, this list of conditions and the following disclaimer in the
045     *    documentation and/or other materials provided with the distribution.
046     * 3. The name of the author may not be used to endorse or promote products
047     *    derived from this software without specific prior written permission.
048     *
049     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
050     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
051     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
052     * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
053     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
054     * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
055     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
056     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
057     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
058     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
059     */