📄 uri.java
字号:
* @exception IllegalArgumentException If the given string violates RFC 2396 * @exception NullPointerException If str is null */ public static URI create (String str) throws IllegalArgumentException { 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 * * @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(); // 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 schemeSpecificPart; } /** * Returns the decoded scheme specific part of this URI. */ public String getSchemeSpecificPart () { // FIXME: unimplemented. return schemeSpecificPart; } /** * Returns the rae authority part of this URI */ public String getRawAuthority () { return authority; } /** * Returns the decoded authority part of this URI */ public String getAuthority () { // FIXME: unimplemented. return authority; } /** * Returns the raw user info part of this URI */ public String getRawUserInfo () { return userInfo; } /** * Returns the decoded user info part of this URI */ public String getUserInfo () { // FIXME: unimplemented. 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 path; } /** * Returns the path of the URI */ public String getPath () { // FIXME: unimplemented. return path; } /** * Returns the raw query part of this URI */ public String getRawQuery () { return query; } /** * Returns the query of the URI */ public String getQuery () { // FIXME: unimplemented. return query; } /** * Return the raw fragment part of this URI */ public String getRawFragment () { return fragment; } /** * Returns the fragment of the URI */ public String getFragment () { // FIXME: unimplemented. 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -