public class URI
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
authority_
The authority component of an URI.
|
protected static java.lang.String |
AUTHORITY_CHARS_
Contains all characters which are allowed for the authority component of an URI.
|
protected java.lang.String |
path_
The path component of an URI.
|
protected static java.lang.String |
PATH_CHARS_
Contains all characters which are allowed for the path component of an URI.
|
protected java.lang.String |
query_
The query component of an URI.
|
protected static java.lang.String |
QUERY_CHARS_
Contains all characters which are allowed for the query component of an URI.
|
protected java.lang.String |
reference_
The reference component of an URI.
|
protected static java.lang.String |
REFERENCE_CHARS_
Contains all characters which are allowed for the reference component of an URI.S_
|
protected static java.lang.String |
RESERVED_
Contains all reserved characters which can be used for an URI.
|
protected java.lang.String |
scheme_
The scheme component of an URI.
|
protected static java.lang.String |
SCHEME_CHARS_
Contains all characters which are allowed for the scheme component of an URI.
|
protected static java.lang.String |
UNRESERVED_
Contains all unreserved characters which can be used for an URI.
|
| Constructor and Description |
|---|
URI(java.lang.String uri)
Parses the given URI string and extracts its five components.
|
URI(java.lang.String scheme,
java.lang.String authority,
java.lang.String path,
java.lang.String query,
java.lang.String reference)
Constructs a URI from its five components.
|
| Modifier and Type | Method and Description |
|---|---|
static URI |
absolutizeURI(URI base,
URI candidate)
Absolutizes a specified candidate URI using a specified base URI according to
RFC 2396, section 5.2.
|
protected java.lang.String |
escape(java.lang.String original,
java.lang.String allowedChars)
Escapes all non-ASCII characters and all forbidden ASCII characters in the specified string.
|
java.lang.String |
getAuthority()
Gets the authority component of the URI.
|
java.lang.String |
getAuthorityUnescaped()
Gets the authority component of the URI in its unescaped (unicode) version.
|
java.lang.String |
getPath()
Gets the path component of the URI.
|
java.lang.String |
getPathUnescaped()
Gets the path component of the URI in its unescaped (unicode) version.
|
java.lang.String |
getQuery()
Gets the query component of the URI.
|
java.lang.String |
getQueryUnescaped()
Gets the query component of the URI in its unescaped (unicode) version.
|
java.lang.String |
getReference()
Gets the reference component of the URI.
|
java.lang.String |
getReferenceUnescaped()
Gets the reference component of the URI in its unescaped (unicode) version.
|
java.lang.String |
getScheme()
Gets the scheme component of the URI.
|
java.lang.String |
getSchemeUnescaped()
Gets the scheme component of the URI in its unescaped (unicode) version.
|
java.lang.String |
getURIWithoutReference()
Provides the string representation of the URI, excluding the reference part.
|
boolean |
isAbsolute()
Tests if the URI is absolute.
|
boolean |
isEmpty()
Checks if the URI is empty.
|
boolean |
isReference()
Checks if the URI is reference-only.
|
protected java.lang.String |
parseComponent(java.lang.String uri,
int fromIndex,
java.lang.String allowedChars)
Gets the longest possible substring, containing only the specified allowed characters, and starting
at the specified position of the candidate string.
|
java.lang.String |
toString()
Provides the sString representation of the URI.
|
protected java.lang.String |
unescape(java.lang.String escaped)
Unescapes the provided string.
|
protected static final java.lang.String UNRESERVED_
protected static final java.lang.String RESERVED_
protected static final java.lang.String SCHEME_CHARS_
protected static final java.lang.String AUTHORITY_CHARS_
protected static final java.lang.String PATH_CHARS_
protected static final java.lang.String QUERY_CHARS_
protected static final java.lang.String REFERENCE_CHARS_
protected java.lang.String scheme_
protected java.lang.String authority_
protected java.lang.String path_
protected java.lang.String query_
protected java.lang.String reference_
public URI(java.lang.String scheme, java.lang.String authority, java.lang.String path, java.lang.String query, java.lang.String reference)
To construct a empty URI, all components must equal null, except path, which must be an
empty String.
To construct a reference-only URI, all components must equal null, except path, which must
be an empty String, and reference, which must at least be an empty String.
Please note, that all parameters are considered to contain no escape sequences (%XX). For
example, an invocation (new URI("file", null, "a%20filename.txt", null, null)).toString()
would result in a string value of file:a%2520filename.txt.
scheme - The URI scheme component.authority - The URI authority component.path - The URI path component.query - The URI query component.reference - The URI reference component.public URI(java.lang.String uri)
throws URIException
uri - A string representing an URI according to
RFC 2396. Must not be null.URIException - if a parsing error occurs.public static URI absolutizeURI(URI base, URI candidate) throws URIException
base - The base URI. Must not be null.candidate - The candidate URI. Must not be null.URIException - if the candidate URI cannot be absolutized with the specified base URI.public java.lang.String getURIWithoutReference()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean isEmpty()
true if the URI is empty, false otherwise.public boolean isReference()
#aRef is reference-only, but
http://anywhere.com/aDocument.html#aRef is not reference-only, but it has a reference.true if the URI is reference-only, false otherwise.public java.lang.String getScheme()
public java.lang.String getSchemeUnescaped()
public java.lang.String getAuthority()
public java.lang.String getAuthorityUnescaped()
public java.lang.String getPath()
public java.lang.String getPathUnescaped()
public java.lang.String getQuery()
public java.lang.String getQueryUnescaped()
public java.lang.String getReference()
public java.lang.String getReferenceUnescaped()
public boolean isAbsolute()
true, if the URI is absolute, false otherwise.protected java.lang.String escape(java.lang.String original,
java.lang.String allowedChars)
ä is transformed into the byte sequence
0xC3 0xA4. Therefore the corresponding representation as escaped URI characters is
%c3%a4.original - The string which characters are perhaps to be escaped. Must not be null.allowedChars - String containing all allowed ASCII characters which should not be escaped. Must
not be null.protected java.lang.String unescape(java.lang.String escaped)
(%xy)* are replaced with its
corresponding unicode characters. For instance, %C3%B6 is replaced with unicode character
0xF6 (character ö).escaped - The string to be escaped.protected java.lang.String parseComponent(java.lang.String uri,
int fromIndex,
java.lang.String allowedChars)
uri - The string containing the requested substring. Must not be null.fromIndex - The start position of the substring. Must match the interval
[0, candidate.length()].allowedChars - A string containing all allowed characters for the substring. Must not be
null.