java.net
Class URI

java.lang.Object
  |
  +--java.net.URI
All Implemented Interfaces:
Comparable, Serializable

public final class URI
extends Object
implements Comparable, Serializable

Untamed:

See Also:
Serialized Form

Field Summary
private  String authority
           
private  String decodedAuthority
           
private  String decodedFragment
           
private  String decodedPath
           
private  String decodedQuery
           
private  String decodedSchemeSpecificPart
           
private  String decodedUserInfo
           
private  String fragment
           
private static long H_ALPHA
           
private static long H_ALPHANUM
           
private static long H_DASH
           
private static long H_DIGIT
           
private static long H_DOT
           
private static long H_ESCAPED
           
private static long H_HEX
           
private static long H_LOWALPHA
           
private static long H_MARK
           
private static long H_PATH
           
private static long H_PCHAR
           
private static long H_REG_NAME
           
private static long H_RESERVED
           
private static long H_SCHEME
           
private static long H_SERVER
           
private static long H_UNRESERVED
           
private static long H_UPALPHA
           
private static long H_URIC
           
private static long H_URIC_NO_SLASH
           
private static long H_USERINFO
           
private  int hash
           
private static char[] hexDigits
           
private  String host
           
private static long L_ALPHA
           
private static long L_ALPHANUM
           
private static long L_DASH
           
private static long L_DIGIT
           
private static long L_DOT
           
private static long L_ESCAPED
           
private static long L_HEX
           
private static long L_LOWALPHA
           
private static long L_MARK
           
private static long L_PATH
           
private static long L_PCHAR
           
private static long L_REG_NAME
           
private static long L_RESERVED
           
private static long L_SCHEME
           
private static long L_SERVER
           
private static long L_UNRESERVED
           
private static long L_UPALPHA
           
private static long L_URIC
           
private static long L_URIC_NO_SLASH
           
private static long L_USERINFO
           
private  String path
           
private  int port
           
private  String query
           
private  String scheme
           
private  String schemeSpecificPart
           
(package private) static long serialVersionUID
           
private  String string
          The string form of this URI.
private  String userInfo
           
 
Constructor Summary
private URI()
           
  URI(String str)
          Enabled: Constructs a URI by parsing the given string.
  URI(String scheme, String ssp, String fragment)
          Enabled: Constructs a URI from the given components.
  URI(String scheme, String userInfo, String host, int port, String path, String query, String fragment)
          Enabled: Constructs a hierarchical URI from the given components.
  URI(String scheme, String host, String path, String fragment)
          Enabled: Constructs a hierarchical URI from the given components.
  URI(String scheme, String authority, String path, String query, String fragment)
          Enabled: Constructs a hierarchical URI from the given components.
 
Method Summary
private  void appendAuthority(StringBuffer sb, String authority, String userInfo, String host, int port)
           
private static void appendEncoded(StringBuffer sb, char c)
           
private static void appendEscape(StringBuffer sb, byte b)
           
private  void appendFragment(StringBuffer sb, String fragment)
           
private  void appendSchemeSpecificPart(StringBuffer sb, String opaquePart, String authority, String userInfo, String host, int port, String path, String query)
           
private static void checkPath(String s, String scheme, String path)
           
private static int compare(String s, String t)
           
private static int compareIgnoringCase(String s, String t)
           
 int compareTo(Object ob)
          Enabled: Compares this URI to another object, which must be a URI.
static URI create(String str)
          Enabled: Creates a URI by parsing the given string.
private static int decode(char c)
           
private static byte decode(char c1, char c2)
           
private static String decode(String s)
           
private  void defineSchemeSpecificPart()
           
private  void defineString()
           
private static String encode(String s)
           
private static boolean equal(String s, String t)
           
private static boolean equalIgnoringCase(String s, String t)
           
 boolean equals(Object ob)
          Suppressed: Tests this URI for equality with another object.
 String getAuthority()
          Enabled: Returns the decoded authority component of this URI.
 String getFragment()
          Enabled: Returns the decoded fragment component of this URI.
 String getHost()
          Enabled: Returns the host component of this URI.
 String getPath()
          Enabled: Returns the decoded path component of this URI.
 int getPort()
          Enabled: Returns the port number of this URI.
 String getQuery()
          Enabled: Returns the decoded query component of this URI.
 String getRawAuthority()
          Enabled: Returns the raw authority component of this URI.
 String getRawFragment()
          Enabled: Returns the raw fragment component of this URI.
 String getRawPath()
          Enabled: Returns the raw path component of this URI.
 String getRawQuery()
          Enabled: Returns the raw query component of this URI.
 String getRawSchemeSpecificPart()
          Enabled: Returns the raw scheme-specific part of this URI.
 String getRawUserInfo()
          Enabled: Returns the raw user-information component of this URI.
 String getScheme()
          Enabled: Returns the scheme component of this URI.
 String getSchemeSpecificPart()
          Enabled: Returns the decoded scheme-specific part of this URI.
 String getUserInfo()
          Enabled: Returns the decoded user-information component of this URI.
private static int hash(int hash, String s)
           
 int hashCode()
          Suppressed: Returns a hash-code value for this URI.
private static int hashIgnoringCase(int hash, String s)
           
private static long highMask(char first, char last)
           
private static long highMask(String chars)
           
 boolean isAbsolute()
          Enabled: Tells whether or not this URI is absolute.
 boolean isOpaque()
          Enabled: Tells whether or not this URI is opaque.
private static int join(char[] path, int[] segs)
           
private static long lowMask(char first, char last)
           
private static long lowMask(String chars)
           
private static boolean match(char c, long lowMask, long highMask)
           
private static void maybeAddLeadingDot(char[] path, int[] segs)
           
private static int needsNormalization(String path)
           
 URI normalize()
          Enabled: Normalizes this URI's path.
private static String normalize(String ps)
           
private static URI normalize(URI u)
           
 URI parseServerAuthority()
          Enabled: Attempts to parse this URI's authority component, if defined, into user-information, host, and port components.
private static String quote(String s, long lowMask, long highMask)
           
private  void readObject(ObjectInputStream is)
          Reconstitutes a URI from the given serial stream.
 URI relativize(URI uri)
          Enabled: Relativizes the given URI against this URI.
private static URI relativize(URI base, URI child)
           
private static void removeDots(char[] path, int[] segs)
           
 URI resolve(String str)
          Enabled: Constructs a new URI by parsing the given string and then resolving it against this URI.
 URI resolve(URI uri)
          Enabled: Resolves the given URI against this URI.
private static URI resolve(URI base, URI child)
           
private static String resolvePath(String base, String child, boolean absolute)
           
private static void split(char[] path, int[] segs)
           
 String toASCIIString()
          Enabled: Returns the content of this URI as a US-ASCII string.
private static int toLower(char c)
           
 String toString()
          Suppressed: Returns the content of this URI as a string.
private  String toString(String scheme, String opaquePart, String authority, String userInfo, String host, int port, String path, String query, String fragment)
           
 URL toURL()
          Enabled: Constructs a URL from this URI.
private  void writeObject(ObjectOutputStream os)
          Saves the content of this URI to the given serial stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID

scheme

private transient String scheme

fragment

private transient String fragment

authority

private transient String authority

userInfo

private transient String userInfo

host

private transient String host

port

private transient int port

path

private transient String path

query

private transient String query

schemeSpecificPart

private transient volatile String schemeSpecificPart

hash

private transient volatile int hash

decodedUserInfo

private transient volatile String decodedUserInfo

decodedAuthority

private transient volatile String decodedAuthority

decodedPath

private transient volatile String decodedPath

decodedQuery

private transient volatile String decodedQuery

decodedFragment

private transient volatile String decodedFragment

decodedSchemeSpecificPart

private transient volatile String decodedSchemeSpecificPart

string

private volatile String string
The string form of this URI.


L_DIGIT

private static final long L_DIGIT

H_DIGIT

private static final long H_DIGIT

L_UPALPHA

private static final long L_UPALPHA

H_UPALPHA

private static final long H_UPALPHA

L_LOWALPHA

private static final long L_LOWALPHA

H_LOWALPHA

private static final long H_LOWALPHA

L_ALPHA

private static final long L_ALPHA

H_ALPHA

private static final long H_ALPHA

L_ALPHANUM

private static final long L_ALPHANUM

H_ALPHANUM

private static final long H_ALPHANUM

L_HEX

private static final long L_HEX

H_HEX

private static final long H_HEX

L_MARK

private static final long L_MARK

H_MARK

private static final long H_MARK

L_UNRESERVED

private static final long L_UNRESERVED

H_UNRESERVED

private static final long H_UNRESERVED

L_RESERVED

private static final long L_RESERVED

H_RESERVED

private static final long H_RESERVED

L_ESCAPED

private static final long L_ESCAPED

H_ESCAPED

private static final long H_ESCAPED

L_URIC

private static final long L_URIC

H_URIC

private static final long H_URIC

L_PCHAR

private static final long L_PCHAR

H_PCHAR

private static final long H_PCHAR

L_PATH

private static final long L_PATH

H_PATH

private static final long H_PATH

L_DASH

private static final long L_DASH

H_DASH

private static final long H_DASH

L_DOT

private static final long L_DOT

H_DOT

private static final long H_DOT

L_USERINFO

private static final long L_USERINFO

H_USERINFO

private static final long H_USERINFO

L_REG_NAME

private static final long L_REG_NAME

H_REG_NAME

private static final long H_REG_NAME

L_SERVER

private static final long L_SERVER

H_SERVER

private static final long H_SERVER

L_SCHEME

private static final long L_SCHEME

H_SCHEME

private static final long H_SCHEME

L_URIC_NO_SLASH

private static final long L_URIC_NO_SLASH

H_URIC_NO_SLASH

private static final long H_URIC_NO_SLASH

hexDigits

private static final char[] hexDigits
Constructor Detail

URI

private URI()

URI

public URI(String str)
    throws URISyntaxException
Enabled: Constructs a URI by parsing the given string.

This constructor parses the given string exactly as specified by the grammar in RFC 2396, Appendix A, except for the following deviations:

Parameters:
str - The string to be parsed into a URI
Throws:
NullPointerException - If str is null
URISyntaxException - If the given string violates RFC 2396, as augmented by the above deviations

URI

public URI(String scheme,
           String userInfo,
           String host,
           int port,
           String path,
           String query,
           String fragment)
    throws URISyntaxException
Enabled: Constructs a hierarchical URI from the given components.

If a scheme is given then the path, if also given, must either be empty or begin with a slash character ('/'). Otherwise a component of the new URI may be left undefined by passing null for the corresponding parameter or, in the case of the port parameter, by passing -1.

This constructor first builds a URI string from the given components according to the rules specified in RFC 2396, section 5.2, step 7:

  1. Initially, the result string is empty.

  2. If a scheme is given then it is appended to the result, followed by a colon character (':').

  3. If user information, a host, or a port are given then the string "//" is appended.

  4. If user information is given then it is appended, followed by a commercial-at character ('@'). Any character not in the unreserved, punct, escaped, or other categories is quoted.

  5. If a host is given then it is appended. If the host is a literal IPv6 address but is not enclosed in square brackets ('[' and ']') then the square brackets are added.

  6. If a port number is given then a colon character (':') is appended, followed by the port number in decimal.

  7. If a path is given then it is appended. Any character not in the unreserved, punct, escaped, or other categories, and not equal to the slash character ('/') or the commercial-at character ('@'), is quoted.

  8. If a query is given then a question-mark character ('?') is appended, followed by the query. Any character that is not a legal URI character is quoted.

  9. Finally, if a fragment is given then a hash character ('#') is appended, followed by the fragment. Any character that is not a legal URI character is quoted.

The resulting URI string is then parsed as if by invoking the URI(String) constructor and then invoking the parseServerAuthority() method upon the result; this may cause a URISyntaxException to be thrown.

Parameters:
scheme - Scheme name
userInfo - User name and authorization information
host - Host name
port - Port number
path - Path
query - Query
fragment - Fragment
Throws:
URISyntaxException - If both a scheme and a path are given but the path is relative, if the URI string constructed from the given components violates RFC 2396, or if the authority component of the string is present but cannot be parsed as a server-based authority

URI

public URI(String scheme,
           String authority,
           String path,
           String query,
           String fragment)
    throws URISyntaxException
Enabled: Constructs a hierarchical URI from the given components.

If a scheme is given then the path, if also given, must either be empty or begin with a slash character ('/'). Otherwise a component of the new URI may be left undefined by passing null for the corresponding parameter.

This constructor first builds a URI string from the given components according to the rules specified in RFC 2396, section 5.2, step 7:

  1. Initially, the result string is empty.

  2. If a scheme is given then it is appended to the result, followed by a colon character (':').

  3. If an authority is given then the string "//" is appended, followed by the authority. If the authority contains a literal IPv6 address then the address must be enclosed in square brackets ('[' and ']'). Any character not in the unreserved, punct, escaped, or other categories, and not equal to the commercial-at character ('@'), is quoted.

  4. If a path is given then it is appended. Any character not in the unreserved, punct, escaped, or other categories, and not equal to the slash character ('/') or the commercial-at character ('@'), is quoted.

  5. If a query is given then a question-mark character ('?') is appended, followed by the query. Any character that is not a legal URI character is quoted.

  6. Finally, if a fragment is given then a hash character ('#') is appended, followed by the fragment. Any character that is not a legal URI character is quoted.

The resulting URI string is then parsed as if by invoking the URI(String) constructor and then invoking the parseServerAuthority() method upon the result; this may cause a URISyntaxException to be thrown.

Parameters:
scheme - Scheme name
authority - Authority
path - Path
query - Query
fragment - Fragment
Throws:
URISyntaxException - If both a scheme and a path are given but the path is relative, if the URI string constructed from the given components violates RFC 2396, or if the authority component of the string is present but cannot be parsed as a server-based authority

URI

public URI(String scheme,
           String host,
           String path,
           String fragment)
    throws URISyntaxException
Enabled: Constructs a hierarchical URI from the given components.

A component may be left undefined by passing null.

This convenience constructor works as if by invoking the seven-argument constructor as follows:

new URI(scheme, null, host, -1, path, null, fragment);

Parameters:
scheme - Scheme name
host - Host name
path - Path
fragment - Fragment
Throws:
URISyntaxException - If the URI string constructed from the given components violates RFC 2396

URI

public URI(String scheme,
           String ssp,
           String fragment)
    throws URISyntaxException
Enabled: Constructs a URI from the given components.

A component may be left undefined by passing null.

This constructor first builds a URI in string form using the given components as follows:

  1. Initially, the result string is empty.

  2. If a scheme is given then it is appended to the result, followed by a colon character (':').

  3. If a scheme-specific part is given then it is appended. Any character that is not a legal URI character is quoted.

  4. Finally, if a fragment is given then a hash character ('#') is appended to the string, followed by the fragment. Any character that is not a legal URI character is quoted.

The resulting URI string is then parsed in order to create the new URI instance as if by invoking the URI(String) constructor; this may cause a URISyntaxException to be thrown.

Parameters:
scheme - Scheme name
ssp - Scheme-specific part
fragment - Fragment
Throws:
URISyntaxException - If the URI string constructed from the given components violates RFC 2396
Method Detail

create

public static URI create(String str)
Enabled: Creates a URI by parsing the given string.

This convenience factory method works as if by invoking the URI(String) constructor; any URISyntaxException thrown by the constructor is caught and wrapped in a new IllegalArgumentException object, which is then thrown.

This method is provided for use in situations where it is known that the given string is a legal URI, for example for URI constants declared within in a program, and so it would be considered a programming error for the string not to parse as such. The constructors, which throw URISyntaxException directly, should be used situations where a URI is being constructed from user input or from some other source that may be prone to errors.

Parameters:
str - The string to be parsed into a URI
Returns:
The new URI
Throws:
NullPointerException - If str is null
IllegalArgumentException - If the given string violates RFC 2396

parseServerAuthority

public URI parseServerAuthority()
                         throws URISyntaxException
Enabled: Attempts to parse this URI's authority component, if defined, into user-information, host, and port components.

If this URI's authority component has already been recognized as being server-based then it will already have been parsed into user-information, host, and port components. In this case, or if this URI has no authority component, this method simply returns this URI.

Otherwise this method attempts once more to parse the authority component into user-information, host, and port components, and throws an exception describing why the authority component could not be parsed in that way.

This method is provided because the generic URI syntax specified in RFC 2396 cannot always distinguish a malformed server-based authority from a legitimate registry-based authority. It must therefore treat some instances of the former as instances of the latter. The authority component in the URI string "//foo:bar", for example, is not a legal server-based authority but it is legal as a registry-based authority.

In many common situations, for example when working URIs that are known to be either URNs or URLs, the hierarchical URIs being used will always be server-based. They therefore must either be parsed as such or treated as an error. In these cases a statement such as

URI u = new URI(str).parseServerAuthority();

can be used to ensure that u always refers to a URI that, if it has an authority component, has a server-based authority with proper user-information, host, and port components. Invoking this method also ensures that if the authority could not be parsed in that way then an appropriate diagnostic message can be issued based upon the exception that is thrown.

Returns:
A URI whose authority field has been parsed as a server-based authority
Throws:
URISyntaxException - If the authority component of this URI is defined but cannot be parsed as a server-based authority according to RFC 2396

normalize

public URI normalize()
Enabled: Normalizes this URI's path.

If this URI is opaque, or if its path is already in normal form, then this URI is returned. Otherwise a new URI is constructed that is identical to this URI except that its path is computed by normalizing this URI's path in a manner consistent with RFC 2396, section 5.2, step 6, sub-steps c through f; that is:

  1. All "." segments are removed.

  2. If a ".." segment is preceded by a non-".." segment then both of these segments are removed. This step is repeated until it is no longer applicable.

  3. If the path is relative, and if its first segment contains a colon character (':'), then a "." segment is prepended. This prevents a relative URI with a path such as "a:b/c/d" from later being re-parsed as an opaque URI with a scheme of "a" and a scheme-specific part of "b/c/d". (Deviation from RFC 2396)

A normalized path will begin with one or more ".." segments if there were insufficient non-".." segments preceding them to allow their removal. A normalized path will begin with a "." segment if one was inserted by step 3 above. Otherwise, a normalized path will not contain any "." or ".." segments.

Returns:
A URI equivalent to this URI, but whose path is in normal form

resolve

public URI resolve(URI uri)
Enabled: Resolves the given URI against this URI.

If the given URI is already absolute, or if this URI is opaque, then the given URI is returned.

If the given URI's fragment component is defined, its path component is empty, and its scheme, authority, and query components are undefined, then a URI with the given fragment but with all other components equal to those of this URI is returned. This allows a URI representing a standalone fragment reference, such as "#foo", to be usefully resolved against a base URI.

Otherwise this method constructs a new hierarchical URI in a manner consistent with RFC 2396, section 5.2; that is:

  1. A new URI is constructed with this URI's scheme and the given URI's query and fragment components.

  2. If the given URI has an authority component then the new URI's authority and path are taken from the given URI.

  3. Otherwise the new URI's authority component is copied from this URI, and its path is computed as follows:

    1. If the given URI's path is absolute then the new URI's path is taken from the given URI.

    2. Otherwise the given URI's path is relative, and so the new URI's path is computed by resolving the path of the given URI against the path of this URI. This is done by concatenating all but the last segment of this URI's path, if any, with the given URI's path and then normalizing the result as if by invoking the normalize method.

The result of this method is absolute if, and only if, either this URI is absolute or the given URI is absolute.

Parameters:
uri - The URI to be resolved against this URI
Returns:
The resulting URI
Throws:
NullPointerException - If uri is null

resolve

public URI resolve(String str)
Enabled: Constructs a new URI by parsing the given string and then resolving it against this URI.

This convenience method works as if invoking it were equivalent to evaluating the expression resolve(URI.create(str)).

Parameters:
str - The string to be parsed into a URI
Returns:
The resulting URI
Throws:
NullPointerException - If str is null
IllegalArgumentException - If the given string violates RFC 2396

relativize

public URI relativize(URI uri)
Enabled: Relativizes the given URI against this URI.

The relativization of the given URI against this URI is computed as follows:

  1. If either this URI or the given URI are opaque, or if the scheme and authority components of the two URIs are not identical, or if the path of this URI is not a prefix of the path of the given URI, then the given URI is returned.

  2. Otherwise a new relative hierarchical URI is constructed with query and fragment components taken from the given URI and with a path component computed by removing this URI's path from the beginning of the given URI's path.

Parameters:
uri - The URI to be relativized against this URI
Returns:
The resulting URI
Throws:
NullPointerException - If uri is null

toURL

public URL toURL()
          throws MalformedURLException
Enabled: Constructs a URL from this URI.

This convenience method works as if invoking it were equivalent to evaluating the expression new URL(this.toString()) after first checking that this URI is absolute.

Returns:
A URL constructed from this URI
Throws:
IllegalArgumentException - If this URL is not absolute
MalformedURLException - If a protocol handler for the URL could not be found, or if some other error occurred while constructing the URL

getScheme

public String getScheme()
Enabled: Returns the scheme component of this URI.

The scheme component of a URI, if defined, only contains characters in the alphanum category and in the string "-.+". A scheme always starts with an alpha character.

The scheme component of a URI cannot contain escaped octets, hence this method does not perform any decoding.

Returns:
The scheme component of this URI, or null if the scheme is undefined

isAbsolute

public boolean isAbsolute()
Enabled: Tells whether or not this URI is absolute.

A URI is absolute if, and only if, it has a scheme component.

Returns:
true if, and only if, this URI is absolute

isOpaque

public boolean isOpaque()
Enabled: Tells whether or not this URI is opaque.

An opaque URI is not parsed beyond the scheme component. The remainder of an opaque URI may be retrieved via the getSchemeSpecificPart method; all other components are undefined.

Returns:
true if, and only if, this URI is opaque

getRawSchemeSpecificPart

public String getRawSchemeSpecificPart()
Enabled: Returns the raw scheme-specific part of this URI. The scheme-specific part is never undefined, though it may be empty.

The scheme-specific part of a URI only contains legal URI characters.

Returns:
The raw scheme-specific part of this URI (never null)

getSchemeSpecificPart

public String getSchemeSpecificPart()
Enabled: Returns the decoded scheme-specific part of this URI.

The string returned by this method is equal to that returned by the getRawSchemeSpecificPart method except that all sequences of escaped octets are decoded.

Returns:
The decoded scheme-specific part of this URI (never null)

getRawAuthority

public String getRawAuthority()
Enabled: Returns the raw authority component of this URI.

The authority component of a URI, if defined, only contains the commercial-at character ('@') and characters in the unreserved, punct, escaped, and other categories. If the authority is server-based then it is further constrained to have valid user-information, host, and port components.

Returns:
The raw authority component of this URI, or null if the authority is undefined

getAuthority

public String getAuthority()
Enabled: Returns the decoded authority component of this URI.

The string returned by this method is equal to that returned by the getRawAuthority method except that all sequences of escaped octets are decoded.

Returns:
The decoded authority component of this URI, or null if the authority is undefined

getRawUserInfo

public String getRawUserInfo()
Enabled: Returns the raw user-information component of this URI.

The user-information component of a URI, if defined, only contains characters in the unreserved, punct, escaped, and other categories.

Returns:
The raw user-information component of this URI, or null if the user information is undefined

getUserInfo

public String getUserInfo()
Enabled: Returns the decoded user-information component of this URI.

The string returned by this method is equal to that returned by the getRawUserInfo method except that all sequences of escaped octets are decoded.

Returns:
The decoded user-information component of this URI, or null if the user information is undefined

getHost

public String getHost()
Enabled: Returns the host component of this URI.

The host component of a URI, if defined, will have one of the following forms:

The host component of a URI cannot contain escaped octets, hence this method does not perform any decoding.

Returns:
The host component of this URI, or null if the host is undefined

getPort

public int getPort()
Enabled: Returns the port number of this URI.

The port component of a URI, if defined, is a non-negative integer.

Returns:
The port component of this URI, or -1 if the port is undefined

getRawPath

public String getRawPath()
Enabled: Returns the raw path component of this URI.

The path component of a URI, if defined, only contains the slash character ('/'), the commercial-at character ('@'), and characters in the unreserved, punct, escaped, and other categories.

Returns:
The path component of this URI, or null if the path is undefined

getPath

public String getPath()
Enabled: Returns the decoded path component of this URI.

The string returned by this method is equal to that returned by the getRawPath method except that all sequences of escaped octets are decoded.

Returns:
The decoded path component of this URI, or null if the path is undefined

getRawQuery

public String getRawQuery()
Enabled: Returns the raw query component of this URI.

The query component of a URI, if defined, only contains legal URI characters.

Returns:
The raw query component of this URI, or null if the query is undefined

getQuery

public String getQuery()
Enabled: Returns the decoded query component of this URI.

The string returned by this method is equal to that returned by the getRawQuery method except that all sequences of escaped octets are decoded.

Returns:
The decoded query component of this URI, or null if the query is undefined

getRawFragment

public String getRawFragment()
Enabled: Returns the raw fragment component of this URI.

The fragment component of a URI, if defined, only contains legal URI characters.

Returns:
The raw fragment component of this URI, or null if the fragment is undefined

getFragment

public String getFragment()
Enabled: Returns the decoded fragment component of this URI.

The string returned by this method is equal to that returned by the getRawFragment method except that all sequences of escaped octets are decoded.

Returns:
The decoded fragment component of this URI, or null if the fragment is undefined

equals

public boolean equals(Object ob)
Suppressed: Tests this URI for equality with another object.

If the given object is not a URI then this method immediately returns false.

For two URIs to be considered equal requires that either both are opaque or both are hierarchical. Their schemes must either both be undefined or else be equal without regard to case, and similarly for their fragments.

For two opaque URIs to be considered equal, their scheme-specific parts must be equal.

For two hierarchical URIs to be considered equal, their paths must be equal and their queries must either both be undefined or else be equal. Their authorities must either both be undefined, or both be registry-based, or both be server-based. If their authorities are defined and are registry-based, then they must be equal. If their authorities are defined and are server-based, then their hosts must be equal without regard to case, their port numbers must be equal, and their user-information components must be equal.

When testing the user-information, path, query, fragment, authority, or scheme-specific parts of two URIs for equality, the raw forms rather than the encoded forms of these components are compared and the hexadecimal digits of escaped octets are compared without regard to case.

This method satisfies the general contract of the Object.equals method.

Overrides:
equals in class Object
Parameters:
ob - The object to which this object is to be compared
Returns:
true if, and only if, the given object is a URI that is identical to this URI
See Also:
Object.hashCode(), java.util.Hashtable

hashCode

public int hashCode()
Suppressed: Returns a hash-code value for this URI. The hash code is based upon all of the URI's components, and satisfies the general contract of the Object.hashCode method.

Overrides:
hashCode in class Object
Returns:
A hash-code value for this URI
See Also:
java.lang.Object#equals(java.lang.Object), java.util.Hashtable

compareTo

public int compareTo(Object ob)
Enabled: Compares this URI to another object, which must be a URI.

When comparing corresponding components of two URIs, if one component is undefined but the other is defined then the first is considered to be less than the second. Unless otherwise noted, string components are ordered according to their natural, case-sensitive ordering as defined by the String.compareTo method. String components that are subject to encoding are compared by comparing their raw forms rather than their encoded forms.

The ordering of URIs is defined as follows:

This method satisfies the general contract of the Comparable.compareTo method.

Specified by:
compareTo in interface Comparable
Parameters:
ob - The object to which this URI is to be compared
Returns:
A negative integer, zero, or a positive integer as this URI is less than, equal to, or greater than the given URI
Throws:
ClassCastException - If the given object is not a URI

toString

public String toString()
Suppressed: Returns the content of this URI as a string.

If this URI was created by invoking one of the constructors in this class then a string equivalent to the original input string, or to the string computed from the originally-given components, as appropriate, is returned. Otherwise this URI was created by normalization, resolution, or relativization, and so a string is constructed from this URI's components according to the rules specified in RFC 2396, section 5.2, step 7.

Overrides:
toString in class Object
Returns:
The string form of this URI

toASCIIString

public String toASCIIString()
Enabled: Returns the content of this URI as a US-ASCII string.

If this URI does not contain any characters in the other category then an invocation of this method will return the same value as an invocation of the toString method. Otherwise this method works as if by invoking that method and then encoding the result.

Returns:
The string form of this URI, encoded as needed so that it only contains characters in the US-ASCII charset

writeObject

private void writeObject(ObjectOutputStream os)
                  throws IOException
Saves the content of this URI to the given serial stream.

The only serializable field of a URI instance is its string field. That field is given a value, if it does not have one already, and then the java.io.ObjectOutputStream#defaultWriteObject() method of the given object-output stream is invoked.

Parameters:
os - The object-output stream to which this object is to be written
IOException

readObject

private void readObject(ObjectInputStream is)
                 throws ClassNotFoundException,
                        IOException
Reconstitutes a URI from the given serial stream.

The java.io.ObjectInputStream#defaultReadObject() method is invoked to read the value of the string field. The result is then parsed in the usual way.

Parameters:
is - The object-input stream from which this object is being read
ClassNotFoundException
IOException

toLower

private static int toLower(char c)

equal

private static boolean equal(String s,
                             String t)

equalIgnoringCase

private static boolean equalIgnoringCase(String s,
                                         String t)

hash

private static int hash(int hash,
                        String s)

hashIgnoringCase

private static int hashIgnoringCase(int hash,
                                    String s)

compare

private static int compare(String s,
                           String t)

compareIgnoringCase

private static int compareIgnoringCase(String s,
                                       String t)

checkPath

private static void checkPath(String s,
                              String scheme,
                              String path)
                       throws URISyntaxException
URISyntaxException

appendAuthority

private void appendAuthority(StringBuffer sb,
                             String authority,
                             String userInfo,
                             String host,
                             int port)

appendSchemeSpecificPart

private void appendSchemeSpecificPart(StringBuffer sb,
                                      String opaquePart,
                                      String authority,
                                      String userInfo,
                                      String host,
                                      int port,
                                      String path,
                                      String query)

appendFragment

private void appendFragment(StringBuffer sb,
                            String fragment)

toString

private String toString(String scheme,
                        String opaquePart,
                        String authority,
                        String userInfo,
                        String host,
                        int port,
                        String path,
                        String query,
                        String fragment)

defineSchemeSpecificPart

private void defineSchemeSpecificPart()

defineString

private void defineString()

resolvePath

private static String resolvePath(String base,
                                  String child,
                                  boolean absolute)

resolve

private static URI resolve(URI base,
                           URI child)

normalize

private static URI normalize(URI u)

relativize

private static URI relativize(URI base,
                              URI child)

needsNormalization

private static int needsNormalization(String path)

split

private static void split(char[] path,
                          int[] segs)

join

private static int join(char[] path,
                        int[] segs)

removeDots

private static void removeDots(char[] path,
                               int[] segs)

maybeAddLeadingDot

private static void maybeAddLeadingDot(char[] path,
                                       int[] segs)

normalize

private static String normalize(String ps)

lowMask

private static long lowMask(String chars)

highMask

private static long highMask(String chars)

lowMask

private static long lowMask(char first,
                            char last)

highMask

private static long highMask(char first,
                             char last)

match

private static boolean match(char c,
                             long lowMask,
                             long highMask)

appendEscape

private static void appendEscape(StringBuffer sb,
                                 byte b)

appendEncoded

private static void appendEncoded(StringBuffer sb,
                                  char c)

quote

private static String quote(String s,
                            long lowMask,
                            long highMask)

encode

private static String encode(String s)

decode

private static int decode(char c)

decode

private static byte decode(char c1,
                           char c2)

decode

private static String decode(String s)


comments?