uri.java
来自「Mac OS X 10.4.9 for x86 Source Code gcc」· Java 代码 · 共 835 行 · 第 1/2 页
JAVA
835 行
this.string = str; parseURI(str); } /** * Create an URI from the given components * * @param scheme The scheme name * @param userInfo The username and authorization info * @param host The hostname * @param port The port number * @param path The path * @param query The query * @param fragment The fragment * * @exception URISyntaxException If the given string violates RFC 2396 */ public URI(String scheme, String userInfo, String host, int port, String path, String query, String fragment) throws URISyntaxException { this((scheme == null ? "" : scheme + ":") + (userInfo == null && host == null && port == -1 ? "" : "//") + (userInfo == null ? "" : quoteUserInfo(userInfo) + "@") + (host == null ? "" : quoteHost(host)) + (port == -1 ? "" : ":" + String.valueOf(port)) + (path == null ? "" : quotePath(path)) + (query == null ? "" : "?" + quote(query)) + (fragment == null ? "" : "#" + quote(fragment))); parseServerAuthority(); } /** * Create an URI from the given components * * @param scheme The scheme name * @param authority The authority * @param path The apth * @param query The query * @param fragment The fragment * * @exception URISyntaxException If the given string violates RFC 2396 */ public URI(String scheme, String authority, String path, String query, String fragment) throws URISyntaxException { this((scheme == null ? "" : scheme + ":") + (authority == null ? "" : "//" + quoteAuthority(authority)) + (path == null ? "" : quotePath(path)) + (query == null ? "" : "?" + quote(query)) + (fragment == null ? "" : "#" + quote(fragment))); } /** * Create an URI from the given components * * @param scheme The scheme name * @param host The hostname * @param path The path * @param fragment The fragment * * @exception URISyntaxException If the given string violates RFC 2396 */ public URI(String scheme, String host, String path, String fragment) throws URISyntaxException { this(scheme, null, host, -1, path, null, fragment); } /** * Create an URI from the given components * * @param scheme The scheme name * @param ssp The scheme specific part * @param fragment The fragment * * @exception URISyntaxException If the given string violates RFC 2396 */ public URI(String scheme, String ssp, String fragment) throws URISyntaxException { this((scheme == null ? "" : scheme + ":") + (ssp == null ? "" : quote(ssp)) + (fragment == null ? "" : "#" + quote(fragment))); } /** * Create an URI from the given string * * @param str The string to create the URI from * * @exception IllegalArgumentException If the given string violates RFC 2396 * @exception NullPointerException If str is null */ public static URI create(String str) { try { return new URI(str); } catch (URISyntaxException e) { throw (IllegalArgumentException) new IllegalArgumentException() .initCause(e); } } /** * Attempts to parse this URI's authority component, if defined, * into user-information, host, and port components * * @exception URISyntaxException If the given string violates RFC 2396 */ public URI parseServerAuthority() throws URISyntaxException { return null; } /** * Returns a normalizes versions of the URI */ public URI normalize() { return null; } /** * Resolves the given URI against this URI * * @param uri The URI to resolve against this URI * * @return The resulting URI, or null when it couldn't be resolved * for some reason. * * @exception NullPointerException If uri is null */ public URI resolve(URI uri) { if (uri.isAbsolute()) return uri; if (uri.isOpaque()) return uri; String scheme = uri.getScheme(); String schemeSpecificPart = uri.getSchemeSpecificPart(); String authority = uri.getAuthority(); String path = uri.getPath(); String query = uri.getQuery(); String fragment = uri.getFragment(); try { if (fragment != null && path != null && path.equals("") && scheme == null && authority == null && query == null) return new URI(this.scheme, this.schemeSpecificPart, fragment); if (authority == null) { authority = this.authority; if (path == null) path = ""; if (! (path.startsWith("/"))) { StringBuffer basepath = new StringBuffer(this.path); int i = this.path.lastIndexOf('/'); if (i >= 0) basepath.delete(i + 1, basepath.length()); basepath.append(path); path = basepath.toString(); // FIXME We must normalize the path here. // Normalization process omitted. } } return new URI(this.scheme, authority, path, query, fragment); } catch (URISyntaxException e) { return null; } } /** * Resolves the given URI string against this URI * * @param str The URI as string to resolve against this URI * * @return The resulting URI * * @exception IllegalArgumentException If the given URI string * violates RFC 2396 * @exception NullPointerException If uri is null */ public URI resolve(String str) throws IllegalArgumentException { return resolve(create(str)); } /** * Relativizes the given URI against this URI * * @param uri The URI to relativize this URI * * @return The resulting URI * * @exception NullPointerException If uri is null */ public URI relativize(URI uri) { return null; } /** * Creates an URL from an URI * * @exception MalformedURLException If a protocol handler for the URL could * not be found, or if some other error occurred while constructing the URL * @exception IllegalArgumentException If the URI is not absolute */ public URL toURL() throws IllegalArgumentException, MalformedURLException { if (isAbsolute()) return new URL(this.toString()); throw new IllegalArgumentException("not absolute"); } /** * Returns the scheme of the URI */ public String getScheme() { return scheme; } /** * Tells whether this URI is absolute or not */ public boolean isAbsolute() { return scheme != null; } /** * Tell whether this URI is opaque or not */ public boolean isOpaque() { return ((scheme != null) && ! (schemeSpecificPart.startsWith("/"))); } /** * Returns the raw scheme specific part of this URI. * The scheme-specific part is never undefined, though it may be empty */ public String getRawSchemeSpecificPart() { return rawSchemeSpecificPart; } /** * Returns the decoded scheme specific part of this URI. */ public String getSchemeSpecificPart() { return schemeSpecificPart; } /** * Returns the rae authority part of this URI */ public String getRawAuthority() { return rawAuthority; } /** * Returns the decoded authority part of this URI */ public String getAuthority() { return authority; } /** * Returns the raw user info part of this URI */ public String getRawUserInfo() { return rawUserInfo; } /** * Returns the decoded user info part of this URI */ public String getUserInfo() { return userInfo; } /** * Returns the hostname of the URI */ public String getHost() { return host; } /** * Returns the port number of the URI */ public int getPort() { return port; } /** * Returns the raw path part of this URI */ public String getRawPath() { return rawPath; } /** * Returns the path of the URI */ public String getPath() { return path; } /** * Returns the raw query part of this URI */ public String getRawQuery() { return rawQuery; } /** * Returns the query of the URI */ public String getQuery() { return query; } /** * Return the raw fragment part of this URI */ public String getRawFragment() { return rawFragment; } /** * Returns the fragment of the URI */ public String getFragment() { return fragment; } /** * Compares the URI with a given object * * @param obj The obj to compare the URI with */ public boolean equals(Object obj) { return false; } /** * Computes the hascode of the URI */ public int hashCode() { return 0; } /** * Compare the URI with another object that must be an URI too * * @param obj This object to compare this URI with * * @exception ClassCastException If given object ist not an URI */ public int compareTo(Object obj) throws ClassCastException { return 0; } /** * Returns the URI as string */ public String toString() { return (getScheme() == null ? "" : getScheme() + ":") + (getRawAuthority() == null ? "" : "//" + getRawAuthority()) + (getRawPath() == null ? "" : getRawPath()) + (getRawQuery() == null ? "" : "?" + getRawQuery()) + (getRawFragment() == null ? "" : "#" + getRawFragment()); } /** * Returns the URI as US-ASCII string */ public String toASCIIString() { return ""; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?