Java Code Examples for java.net.URI#isAbsolute()

The following examples show how to use java.net.URI#isAbsolute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: J2SEProjectProperties.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void validateURL(final URL url, final File file) {
    try {
        final URI uri = url.toURI();
        if (!uri.isAbsolute()) {
            throw new IllegalArgumentException("URI is not absolute: " + uri.toString() + " File: " + file.getAbsolutePath());   //NOI18N
        }
        if (uri.isOpaque()) {
            throw new IllegalArgumentException("URI is not hierarchical: " + uri.toString() + " File: " + file.getAbsolutePath());   //NOI18N
        }
        if (!"file".equals(uri.getScheme())) {
            throw new IllegalArgumentException("URI scheme is not \"file\": " + uri.toString() + " File: " + file.getAbsolutePath());   //NOI18N
        }
    } catch (URISyntaxException use) {
        throw new IllegalArgumentException(use);
    }
}
 
Example 2
Source File: AutoUpdateCatalogParser.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static URL getDistribution (String distribution, URI base) {
    URL retval = null;
    if (distribution != null && distribution.length () > 0) {
        try {
            URI distributionURI = new URI (distribution);
            if (! distributionURI.isAbsolute ()) {
                if (base != null) {
                    distributionURI = base.resolve (distributionURI);
                }
            }
            retval = distributionURI.toURL ();
        } catch (MalformedURLException | URISyntaxException ex) {
            ERR.log (Level.INFO, null, ex);
        }
    }
    return retval;
}
 
Example 3
Source File: ConfigDescription.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates a new instance of this class with the specified parameters.
 *
 * @param uri the URI of this description within the {@link ConfigDescriptionRegistry} (must neither be null nor
 *            empty)
 * @param parameters the list of configuration parameters that belong to the given URI
 *            (could be null or empty)
 * @param groups the list of groups associated with the parameters
 * @throws IllegalArgumentException if the URI is null or invalid
 */
public ConfigDescription(URI uri, List<ConfigDescriptionParameter> parameters,
        List<ConfigDescriptionParameterGroup> groups) {
    if (uri == null) {
        throw new IllegalArgumentException("The URI must not be null!");
    }
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("The scheme is missing!");
    }
    if (!uri.isOpaque()) {
        throw new IllegalArgumentException("The scheme specific part (token) must not start with a slash ('/')!");
    }

    this.uri = uri;

    if (parameters != null) {
        this.parameters = Collections.unmodifiableList(parameters);
    } else {
        this.parameters = Collections.unmodifiableList(new ArrayList<ConfigDescriptionParameter>(0));
    }

    if (groups != null) {
        this.parameterGroups = Collections.unmodifiableList(groups);
    } else {
        this.parameterGroups = Collections.unmodifiableList(new ArrayList<ConfigDescriptionParameterGroup>(0));
    }
}
 
Example 4
Source File: JavacFileManager.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Enforces the specification of a "relative" name as used in
 * {@linkplain #getFileForInput(Location, String, String)
 * getFileForInput}.  This method must follow the rules defined in
 * that method, do not make any changes without consulting the
 * specification.
 */
protected static boolean isRelativeUri(URI uri) {
    if (uri.isAbsolute())
        return false;
    String path = uri.normalize().getPath();
    if (path.length() == 0 /* isEmpty() is mustang API */)
        return false;
    if (!path.equals(uri.getPath())) // implicitly checks for embedded . and ..
        return false;
    return !path.startsWith("/") && !path.startsWith("./") && !path.startsWith("../");
}
 
Example 5
Source File: URIUtils.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
/**
 * Build URI starting from the given base and href.
 * <br/>
 * If href is absolute or base is null then base will be ignored.
 *
 * @param base URI prefix.
 * @param href URI suffix.
 * @return built URI.
 */
public static URI getURI(final URI base, final String href) {
  if (href == null) {
    throw new IllegalArgumentException("Null link provided");
  }

  URI uri = URI.create(href);

  if (!uri.isAbsolute() && base != null) {
    uri = URI.create(base.toASCIIString() + "/" + href);
  }

  return uri.normalize();
}
 
Example 6
Source File: Registration.java    From spring-boot-admin with Apache License 2.0 5 votes vote down vote up
/**
 * Checks the syntax of the given URL.
 * @param url the URL.
 * @return true, if valid.
 */
private boolean checkUrl(String url) {
	try {
		URI uri = new URI(url);
		return uri.isAbsolute();
	}
	catch (URISyntaxException ex) {
		return false;
	}
}
 
Example 7
Source File: AuthenticationEndpointTenantActivityListener.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize listener
 */
private synchronized void init() {
    try {
        tenantDataReceiveURLs = ConfigurationFacade.getInstance().getTenantDataEndpointURLs();

        if (!tenantDataReceiveURLs.isEmpty()) {

            serverURL = IdentityUtil.getServerURL("", true, true);
            int index = 0;

            for (String tenantDataReceiveUrl : tenantDataReceiveURLs) {
                URI tenantDataReceiveURI = new URI(tenantDataReceiveUrl);

                if (log.isDebugEnabled()) {
                    log.debug("Tenant list receiving url added : " + tenantDataReceiveUrl);
                }

                if (!tenantDataReceiveURI.isAbsolute()) {
                    // Set the absolute URL for tenant list receiving endpoint
                    tenantDataReceiveURLs.set(index, serverURL + tenantDataReceiveUrl);
                }
                index++;
            }

            initialized = true;
        } else {
            if (log.isDebugEnabled()) {
                log.debug("TenantDataListenerURLs are not set in configuration");
            }
        }
    } catch (URISyntaxException e) {
        log.error("Error while getting TenantDataListenerURLs", e);
    }
}
 
Example 8
Source File: ResourceCheckSteps.java    From vividus with Apache License 2.0 5 votes vote down vote up
private URI createUri(String uri)
{
    URI uriToCheck = URI.create(uri);
    if (uri.charAt(0) != '/' || uriToCheck.isAbsolute())
    {
        return uriToCheck;
    }
    return UriUtils.buildNewUrl(mainApplicationPageURI, uriToCheck.getPath());
}
 
Example 9
Source File: RuntimeConfiguration.java    From BUbiNG with Apache License 2.0 5 votes vote down vote up
private static URI handleSeedURL(final MutableString s) {
	final URI url = BURL.parse(s);
	if (url != null) {
		if (url.isAbsolute()) return url;
		else LOGGER.error("The seed URL " + s + " is relative");
	}
	else LOGGER.error("The seed URL " + s + " is malformed");
	return null;
}
 
Example 10
Source File: StoreAwareHandlerMapping.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@Override
	public void afterPropertiesSet() {

		URI baseUri = configuration.getBaseUri();

		if (baseUri.isAbsolute()) {
//			HttpServletRequest request = new BasePathAwareHandlerMapping.UriAwareHttpServletRequest(getServletContext(), baseUri);
//			this.prefix = URL_PATH_HELPER.getPathWithinApplication(request);
			throw new UnsupportedOperationException(format("absolute base URIs not supported %s", baseUri));
		} else {
			this.prefix = baseUri.toString();
		}

		super.afterPropertiesSet();
	}
 
Example 11
Source File: ClassPath.java    From kite with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the absolute uri of the Class-Path entry value as specified in
 * <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#Main%20Attributes">
 * JAR File Specification</a>. Even though the specification only talks about relative urls,
 * absolute urls are actually supported too (for example, in Maven surefire plugin).
 */
@VisibleForTesting static URI getClassPathEntry(File jarFile, String path)
    throws URISyntaxException {
  URI uri = new URI(path);
  if (uri.isAbsolute()) {
    return uri;
  } else {
    return new File(jarFile.getParentFile(), path.replace('/', File.separatorChar)).toURI();
  }
}
 
Example 12
Source File: LocalFile.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public LocalFile( URI uri )
{
	this.file = uri.isAbsolute( ) ? new File( uri )
			: new File( uri.toString( ) );
}
 
Example 13
Source File: WindowsUriSupport.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Converts given URI to a Path
 */
static WindowsPath fromUri(WindowsFileSystem fs, URI uri) {
    if (!uri.isAbsolute())
        throw new IllegalArgumentException("URI is not absolute");
    if (uri.isOpaque())
        throw new IllegalArgumentException("URI is not hierarchical");
    String scheme = uri.getScheme();
    if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
        throw new IllegalArgumentException("URI scheme is not \"file\"");
    if (uri.getFragment() != null)
        throw new IllegalArgumentException("URI has a fragment component");
    if (uri.getQuery() != null)
        throw new IllegalArgumentException("URI has a query component");
    String path = uri.getPath();
    if (path.equals(""))
        throw new IllegalArgumentException("URI path component is empty");

    // UNC
    String auth = uri.getAuthority();
    if (auth != null && !auth.equals("")) {
        String host = uri.getHost();
        if (host == null)
            throw new IllegalArgumentException("URI authority component has undefined host");
        if (uri.getUserInfo() != null)
            throw new IllegalArgumentException("URI authority component has user-info");
        if (uri.getPort() != -1)
            throw new IllegalArgumentException("URI authority component has port number");

        // IPv6 literal
        // 1. drop enclosing brackets
        // 2. replace ":" with "-"
        // 3. replace "%" with "s" (zone/scopeID delimiter)
        // 4. Append .ivp6-literal.net
        if (host.startsWith("[")) {
            host = host.substring(1, host.length()-1)
                       .replace(':', '-')
                       .replace('%', 's');
            host += IPV6_LITERAL_SUFFIX;
        }

        // reconstitute the UNC
        path = "\\\\" + host + path;
    } else {
        if ((path.length() > 2) && (path.charAt(2) == ':')) {
            // "/c:/foo" --> "c:/foo"
            path = path.substring(1);
        }
    }
    return WindowsPath.parse(fs, path);
}
 
Example 14
Source File: WindowsUriSupport.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Converts given URI to a Path
 */
static WindowsPath fromUri(WindowsFileSystem fs, URI uri) {
    if (!uri.isAbsolute())
        throw new IllegalArgumentException("URI is not absolute");
    if (uri.isOpaque())
        throw new IllegalArgumentException("URI is not hierarchical");
    String scheme = uri.getScheme();
    if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
        throw new IllegalArgumentException("URI scheme is not \"file\"");
    if (uri.getFragment() != null)
        throw new IllegalArgumentException("URI has a fragment component");
    if (uri.getQuery() != null)
        throw new IllegalArgumentException("URI has a query component");
    String path = uri.getPath();
    if (path.equals(""))
        throw new IllegalArgumentException("URI path component is empty");

    // UNC
    String auth = uri.getAuthority();
    if (auth != null && !auth.equals("")) {
        String host = uri.getHost();
        if (host == null)
            throw new IllegalArgumentException("URI authority component has undefined host");
        if (uri.getUserInfo() != null)
            throw new IllegalArgumentException("URI authority component has user-info");
        if (uri.getPort() != -1)
            throw new IllegalArgumentException("URI authority component has port number");

        // IPv6 literal
        // 1. drop enclosing brackets
        // 2. replace ":" with "-"
        // 3. replace "%" with "s" (zone/scopeID delimiter)
        // 4. Append .ivp6-literal.net
        if (host.startsWith("[")) {
            host = host.substring(1, host.length()-1)
                       .replace(':', '-')
                       .replace('%', 's');
            host += IPV6_LITERAL_SUFFIX;
        }

        // reconstitute the UNC
        path = "\\\\" + host + path;
    } else {
        if ((path.length() > 2) && (path.charAt(2) == ':')) {
            // "/c:/foo" --> "c:/foo"
            path = path.substring(1);
        }
    }
    return WindowsPath.parse(fs, path);
}
 
Example 15
Source File: AbstractClient.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected Message createMessage(Object body,
                                String httpMethod,
                                MultivaluedMap<String, String> headers,
                                URI currentURI,
                                Exchange exchange,
                                Map<String, Object> invocationContext,
                                boolean proxy) {
    checkClosed();
    Message m = cfg.getConduitSelector().getEndpoint().getBinding().createMessage();
    m.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
    m.put(Message.INBOUND_MESSAGE, Boolean.FALSE);

    setRequestMethod(m, httpMethod);
    m.put(Message.PROTOCOL_HEADERS, headers);
    if (currentURI.isAbsolute() && currentURI.getScheme().startsWith(HTTP_SCHEME)) {
        m.put(Message.ENDPOINT_ADDRESS, currentURI.toString());
    } else {
        m.put(Message.ENDPOINT_ADDRESS, state.getBaseURI().toString());
    }

    Object requestURIProperty = cfg.getRequestContext().get(Message.REQUEST_URI);
    if (requestURIProperty == null) {
        m.put(Message.REQUEST_URI, currentURI.toString());
    } else {
        m.put(Message.REQUEST_URI, requestURIProperty.toString());
    }

    String ct = headers.getFirst(HttpHeaders.CONTENT_TYPE);
    m.put(Message.CONTENT_TYPE, ct);

    body = checkIfBodyEmpty(body, ct);
    setEmptyRequestPropertyIfNeeded(m, body);

    m.setContent(List.class, getContentsList(body));

    m.put(URITemplate.TEMPLATE_PARAMETERS, getState().getTemplates());

    PhaseInterceptorChain chain = setupOutInterceptorChain(cfg);
    chain.setFaultObserver(setupInFaultObserver(cfg));
    m.setInterceptorChain(chain);

    exchange = createExchange(m, exchange);
    exchange.put(Message.REST_MESSAGE, Boolean.TRUE);
    exchange.setOneWay("true".equals(headers.getFirst(Message.ONE_WAY_REQUEST)));
    exchange.put(Retryable.class, new RetryableImpl());

    // context
    setContexts(m, exchange, invocationContext, proxy);

    //setup conduit selector
    prepareConduitSelector(m, currentURI, proxy);

    return m;
}
 
Example 16
Source File: LoadFunc.java    From spork with Apache License 2.0 4 votes vote down vote up
/**
 * Construct the absolute path from the file location and the current
 * directory. The current directory is either of the form 
 * {code}hdfs://<nodename>:<nodeport>/<directory>{code} in Hadoop 
 * MapReduce mode, or of the form 
 * {code}file:///<directory>{code} in Hadoop local mode.
 * 
 * @param location the location string specified in the load statement
 * @param curDir the current file system directory
 * @return the absolute path of file in the file system
 * @throws FrontendException if the scheme of the location is incompatible
 *         with the scheme of the file system
 */
public static String getAbsolutePath(String location, Path curDir) 
        throws FrontendException {
    
    if (location == null || curDir == null) {
        throw new FrontendException(
                "location: " + location + " curDir: " + curDir);
    }

    URI fsUri = curDir.toUri();
    String fsScheme = fsUri.getScheme();
    if (fsScheme == null) {
        throw new FrontendException("curDir: " + curDir);           
    }
    
    fsScheme = fsScheme.toLowerCase();
    String authority = fsUri.getAuthority();
    if(authority == null) {
        authority = "";
    }
    Path rootDir = new Path(fsScheme, authority, "/");
    
    ArrayList<String> pathStrings = new ArrayList<String>();
    
    String[] fnames = getPathStrings(location);
    for (String fname: fnames) {
        // remove leading/trailing whitespace(s)
        fname = fname.trim();
        Path p = new Path(fname);
        URI uri = p.toUri();
        // if the supplied location has a scheme (i.e. uri is absolute) or 
        // an absolute path, just use it.
        if(! (uri.isAbsolute() || p.isAbsolute())) {
            String scheme = uri.getScheme();
            if (scheme != null) {
                scheme = scheme.toLowerCase();
            }
            
            if (scheme != null && !scheme.equals(fsScheme)) {
                throw new FrontendException("Incompatible file URI scheme: "
                        + scheme + " : " + fsScheme);               
            }            
            String path = uri.getPath();
        
            fname = (p.isAbsolute()) ? 
                        new Path(rootDir, path).toString() : 
                            new Path(curDir, path).toString();
        }
        fname = fname.replaceFirst("^file:/([^/])", "file:///$1");
        // remove the trailing /
        fname = fname.replaceFirst("/$", "");
        pathStrings.add(fname);
    }

    return join(pathStrings, ",");
}
 
Example 17
Source File: NumberedFileInputSplit.java    From DataVec with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canWriteToLocation(URI location) {
    return location.isAbsolute();
}
 
Example 18
Source File: File.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a new <tt>File</tt> instance by converting the given
 * <tt>file:</tt> URI into an abstract pathname.
 *
 * <p> The exact form of a <tt>file:</tt> URI is system-dependent, hence
 * the transformation performed by this constructor is also
 * system-dependent.
 *
 * <p> For a given abstract pathname <i>f</i> it is guaranteed that
 *
 * <blockquote><tt>
 * new File(</tt><i>&nbsp;f</i><tt>.{@link #toURI() toURI}()).equals(</tt><i>&nbsp;f</i><tt>.{@link #getAbsoluteFile() getAbsoluteFile}())
 * </tt></blockquote>
 *
 * so long as the original abstract pathname, the URI, and the new abstract
 * pathname are all created in (possibly different invocations of) the same
 * Java virtual machine.  This relationship typically does not hold,
 * however, when a <tt>file:</tt> URI that is created in a virtual machine
 * on one operating system is converted into an abstract pathname in a
 * virtual machine on a different operating system.
 *
 * @param  uri
 *         An absolute, hierarchical URI with a scheme equal to
 *         <tt>"file"</tt>, a non-empty path component, and undefined
 *         authority, query, and fragment components
 *
 * @throws  NullPointerException
 *          If <tt>uri</tt> is <tt>null</tt>
 *
 * @throws  IllegalArgumentException
 *          If the preconditions on the parameter do not hold
 *
 * @see #toURI()
 * @see java.net.URI
 * @since 1.4
 */
public File(URI uri) {

    // Check our many preconditions
    if (!uri.isAbsolute())
        throw new IllegalArgumentException("URI is not absolute");
    if (uri.isOpaque())
        throw new IllegalArgumentException("URI is not hierarchical");
    String scheme = uri.getScheme();
    if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
        throw new IllegalArgumentException("URI scheme is not \"file\"");
    if (uri.getAuthority() != null)
        throw new IllegalArgumentException("URI has an authority component");
    if (uri.getFragment() != null)
        throw new IllegalArgumentException("URI has a fragment component");
    if (uri.getQuery() != null)
        throw new IllegalArgumentException("URI has a query component");
    String p = uri.getPath();
    if (p.equals(""))
        throw new IllegalArgumentException("URI path component is empty");

    // Okay, now initialize
    p = fs.fromURIPath(p);
    if (File.separatorChar != '/')
        p = p.replace('/', File.separatorChar);
    this.path = fs.normalize(p);
    this.prefixLength = fs.prefixLength(this.path);
}
 
Example 19
Source File: File.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a new <tt>File</tt> instance by converting the given
 * <tt>file:</tt> URI into an abstract pathname.
 *
 * <p> The exact form of a <tt>file:</tt> URI is system-dependent, hence
 * the transformation performed by this constructor is also
 * system-dependent.
 *
 * <p> For a given abstract pathname <i>f</i> it is guaranteed that
 *
 * <blockquote><tt>
 * new File(</tt><i>&nbsp;f</i><tt>.{@link #toURI() toURI}()).equals(</tt><i>&nbsp;f</i><tt>.{@link #getAbsoluteFile() getAbsoluteFile}())
 * </tt></blockquote>
 *
 * so long as the original abstract pathname, the URI, and the new abstract
 * pathname are all created in (possibly different invocations of) the same
 * Java virtual machine.  This relationship typically does not hold,
 * however, when a <tt>file:</tt> URI that is created in a virtual machine
 * on one operating system is converted into an abstract pathname in a
 * virtual machine on a different operating system.
 *
 * @param  uri
 *         An absolute, hierarchical URI with a scheme equal to
 *         <tt>"file"</tt>, a non-empty path component, and undefined
 *         authority, query, and fragment components
 *
 * @throws  NullPointerException
 *          If <tt>uri</tt> is <tt>null</tt>
 *
 * @throws  IllegalArgumentException
 *          If the preconditions on the parameter do not hold
 *
 * @see #toURI()
 * @see java.net.URI
 * @since 1.4
 */
public File(URI uri) {

    // Check our many preconditions
    if (!uri.isAbsolute())
        throw new IllegalArgumentException("URI is not absolute");
    if (uri.isOpaque())
        throw new IllegalArgumentException("URI is not hierarchical");
    String scheme = uri.getScheme();
    if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
        throw new IllegalArgumentException("URI scheme is not \"file\"");
    if (uri.getAuthority() != null)
        throw new IllegalArgumentException("URI has an authority component");
    if (uri.getFragment() != null)
        throw new IllegalArgumentException("URI has a fragment component");
    if (uri.getQuery() != null)
        throw new IllegalArgumentException("URI has a query component");
    String p = uri.getPath();
    if (p.equals(""))
        throw new IllegalArgumentException("URI path component is empty");

    // Okay, now initialize
    p = fs.fromURIPath(p);
    if (File.separatorChar != '/')
        p = p.replace('/', File.separatorChar);
    this.path = fs.normalize(p);
    this.prefixLength = fs.prefixLength(this.path);
}
 
Example 20
Source File: File.java    From Java8CN with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a new <tt>File</tt> instance by converting the given
 * <tt>file:</tt> URI into an abstract pathname.
 *
 * <p> The exact form of a <tt>file:</tt> URI is system-dependent, hence
 * the transformation performed by this constructor is also
 * system-dependent.
 *
 * <p> For a given abstract pathname <i>f</i> it is guaranteed that
 *
 * <blockquote><tt>
 * new File(</tt><i>&nbsp;f</i><tt>.{@link #toURI() toURI}()).equals(</tt><i>&nbsp;f</i><tt>.{@link #getAbsoluteFile() getAbsoluteFile}())
 * </tt></blockquote>
 *
 * so long as the original abstract pathname, the URI, and the new abstract
 * pathname are all created in (possibly different invocations of) the same
 * Java virtual machine.  This relationship typically does not hold,
 * however, when a <tt>file:</tt> URI that is created in a virtual machine
 * on one operating system is converted into an abstract pathname in a
 * virtual machine on a different operating system.
 *
 * @param  uri
 *         An absolute, hierarchical URI with a scheme equal to
 *         <tt>"file"</tt>, a non-empty path component, and undefined
 *         authority, query, and fragment components
 *
 * @throws  NullPointerException
 *          If <tt>uri</tt> is <tt>null</tt>
 *
 * @throws  IllegalArgumentException
 *          If the preconditions on the parameter do not hold
 *
 * @see #toURI()
 * @see java.net.URI
 * @since 1.4
 */
public File(URI uri) {

    // Check our many preconditions
    if (!uri.isAbsolute())
        throw new IllegalArgumentException("URI is not absolute");
    if (uri.isOpaque())
        throw new IllegalArgumentException("URI is not hierarchical");
    String scheme = uri.getScheme();
    if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
        throw new IllegalArgumentException("URI scheme is not \"file\"");
    if (uri.getAuthority() != null)
        throw new IllegalArgumentException("URI has an authority component");
    if (uri.getFragment() != null)
        throw new IllegalArgumentException("URI has a fragment component");
    if (uri.getQuery() != null)
        throw new IllegalArgumentException("URI has a query component");
    String p = uri.getPath();
    if (p.equals(""))
        throw new IllegalArgumentException("URI path component is empty");

    // Okay, now initialize
    p = fs.fromURIPath(p);
    if (File.separatorChar != '/')
        p = p.replace('/', File.separatorChar);
    this.path = fs.normalize(p);
    this.prefixLength = fs.prefixLength(this.path);
}