java.lang.Object | |
↳ | com.sun.jndi.toolkit.url.Uri |
![]() |
A Uri object represents an absolute Uniform Resource Identifier (URI) as defined by RFC 2396 and updated by RFC 2373 and RFC 2732. The most commonly used form of URI is the Uniform Resource Locator (URL).
The java.net.URL class cannot be used to parse URIs since it requires the installation of URL stream handlers that may not be available. The hack of getting around this by temporarily replacing the scheme part of a URI is not appropriate here: JNDI service providers must work on older Java platforms, and we want new features and bug fixes that are not available in old versions of the URL class.
It may be appropriate to drop this code in favor of the java.net.URI class. The changes would need to be written so as to still run on pre-1.4 platforms not containing that class.
The format of an absolute URI (see the RFCs mentioned above) is:
absoluteURI = scheme ":" ( hier_part | opaque_part ) scheme = alpha *( alpha | digit | "+" | "-" | "." ) hier_part = ( net_path | abs_path ) [ "?" query ] opaque_part = uric_no_slash *uric net_path = "//" authority [ abs_path ] abs_path = "/" path_segments authority = server | reg_name reg_name = 1*( unreserved | escaped | "$" | "," | ";" | ":" | "@" | "&" | "=" | "+" ) server = [ [ userinfo "@" ] hostport ] userinfo = *( unreserved | escaped | ";" | ":" | "&" | "=" | "+" | "$" | "," ) hostport = host [ ":" port ] host = hostname | IPv4address | IPv6reference port = *digit IPv6reference = "[" IPv6address "]" IPv6address = hexpart [ ":" IPv4address ] IPv4address = 1*3digit "." 1*3digit "." 1*3digit "." 1*3digit hexpart = hexseq | hexseq "::" [ hexseq ] | "::" [ hexseq ] hexseq = hex4 *( ":" hex4) hex4 = 1*4hex path = [ abs_path | opaque_part ] path_segments = segment *( "/" segment ) segment = *pchar *( ";" param ) param = *pchar pchar = unreserved | escaped | ":" | "@" | "&" | "=" | "+" | "$" | "," query = *uric uric = reserved | unreserved | escaped uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," | "[" | "]" unreserved = alphanum | mark mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")" escaped = "%" hex hex unwise = "{" | "}" | "|" | "\" | "^" | "`"
Currently URIs containing userinfo or reg_name are not supported. The opaque_part of a non-hierarchical URI is treated as if if were a path without a leading slash.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
hasAuthority | |||||||||||
host | |||||||||||
path | |||||||||||
port | |||||||||||
query | |||||||||||
scheme | |||||||||||
uri |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a Uri object given a URI string.
|
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates an uninitialized Uri object.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the host from the URI's authority part, or null
if no host is provided.
| |||||||||||
Returns the URI's path.
| |||||||||||
Returns the port from the URI's authority part, or -1 if
no port is provided.
| |||||||||||
Returns the URI's query part, or null if no query is provided.
| |||||||||||
Returns the URI's scheme.
| |||||||||||
Returns the URI as a string.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Initializes a Uri object given a URI string.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Creates an uninitialized Uri object. The init() method must be called before any other Uri methods.
Returns the host from the URI's authority part, or null
if no host is provided. If the host is an IPv6 literal, the
delimiting brackets are part of the returned value (see
getHost()
).
Returns the URI's path. The path is never null. Note that a slash following the authority part (or the scheme if there is no authority part) is part of the path. For example, the path of "http://host/a/b" is "/a/b".
Returns the port from the URI's authority part, or -1 if no port is provided.
Returns the URI's query part, or null if no query is provided. Note that a query always begins with a leading "?".
Returns the URI as a string.
Initializes a Uri object given a URI string. This method must be called exactly once, and before any other Uri methods.
MalformedURLException |
---|