|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.exolab.jms.net.uri.URI
A class to represent a Uniform Resource Identifier (URI). This class is designed to handle the parsing of URIs and provide access to the various components (scheme, host, port, userinfo, path, query string and fragment) that may constitute a URI.
Parsing of a URI specification is done according to the URI
syntax described in RFC 2396
For URIs that do not follow the "generic URI" syntax (e.g. mailto), the entire scheme-specific part is treated as the "path" portion of the URI.
Note that, unlike the java.net.URL class, this class does not provide any built-in network access functionality nor does it provide any scheme-specific functionality (for example, it does not know a default port for a specific scheme). Rather, it only knows the grammar and basic set of operations that can be applied to a URI.
Inner Class Summary | |
static class |
URI.MalformedURIException
MalformedURIExceptions are thrown in the process of building a URI or setting fields on a URI when an operation would result in an invalid URI specification. |
Constructor Summary | |
URI()
Construct a new and uninitialized URI. |
|
URI(java.lang.String uriSpec)
Construct a new URI from a URI specification string. |
|
URI(java.lang.String scheme,
java.lang.String schemeSpecificPart)
Construct a new URI that does not follow the generic URI syntax. |
|
URI(java.lang.String scheme,
java.lang.String userinfo,
java.lang.String host,
int port,
java.lang.String path,
java.lang.String queryString,
java.lang.String fragment)
Construct a new URI that follows the generic URI syntax from its component parts. |
|
URI(java.lang.String scheme,
java.lang.String host,
java.lang.String path,
java.lang.String queryString,
java.lang.String fragment)
Construct a new URI that follows the generic URI syntax from its component parts. |
|
URI(URI other)
Construct a new URI from another URI. |
|
URI(URI base,
java.lang.String uriSpec)
Construct a new URI from a base URI and a URI specification string. |
Method Summary | |
void |
appendPath(java.lang.String addToPath)
Append to the end of the path of this URI. |
boolean |
equals(java.lang.Object test)
Determines if the passed-in Object is equivalent to this URI. |
java.lang.String |
getFragment()
Get the fragment for this URI. |
java.lang.String |
getHost()
Get the host for this URI. |
java.lang.String |
getPath()
Get the path for this URI. |
java.lang.String |
getPath(boolean includeQueryString,
boolean includeFragment)
Get the path for this URI (optionally with the query string and fragment). |
int |
getPort()
Get the port for this URI. |
java.lang.String |
getQueryString()
Get the query string for this URI. |
java.lang.String |
getScheme()
Get the scheme for this URI. |
java.lang.String |
getSchemeSpecificPart()
Get the scheme-specific part for this URI (everything following the scheme and the first colon). |
java.lang.String |
getUserinfo()
Get the userinfo for this URI. |
int |
hashCode()
Returns the hash code of this URI |
static boolean |
isConformantSchemeName(java.lang.String scheme)
Determine whether a scheme conforms to the rules for a scheme name. |
boolean |
isGenericURI()
Get the indicator as to whether this URI uses the "generic URI" syntax. |
static boolean |
isWellFormedAddress(java.lang.String address)
Determine whether a string is syntactically capable of representing a valid IPv4 address or the domain name of a network host. |
void |
setFragment(java.lang.String fragment)
Set the fragment for this URI. |
void |
setHost(java.lang.String host)
Set the host for this URI. |
void |
setPath(java.lang.String path)
Set the path for this URI. |
void |
setPort(int port)
Set the port for this URI. |
void |
setQueryString(java.lang.String queryString)
Set the query string for this URI. |
void |
setScheme(java.lang.String scheme)
Set the scheme for this URI. |
void |
setUserinfo(java.lang.String userinfo)
Set the userinfo for this URI. |
java.lang.String |
toString()
Get the URI as a string specification. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public URI()
public URI(URI other)
other
- the URI to copy (cannot be null)public URI(java.lang.String uriSpec) throws URI.MalformedURIException
uriSpec
- the URI specification string (cannot be null or empty)URI.MalformedURIException
- uriSpec violates any syntax rulespublic URI(URI base, java.lang.String uriSpec) throws URI.MalformedURIException
base
- the base URI (cannot be null if uriSpec is null or empty)uriSpec
- the URI specification string (cannot be null or empty
if base is null)URI.MalformedURIException
- uriSpec violates any syntax rulespublic URI(java.lang.String scheme, java.lang.String schemeSpecificPart) throws URI.MalformedURIException
scheme
- the URI scheme (cannot be null or empty)schemeSpecificPart
- the scheme-specific part (cannot be
null or empty)URI.MalformedURIException
- scheme violates any syntax rulespublic URI(java.lang.String scheme, java.lang.String host, java.lang.String path, java.lang.String queryString, java.lang.String fragment) throws URI.MalformedURIException
scheme
- the URI scheme (cannot be null or empty)host
- the hostname or IPv4 address for the URIpath
- the URI path - if the path contains '?' or '#',
then the query string and/or fragment will be set from the path;
however, if the query and fragment are specified both in the path
and as separate parameters, an exception is thrownqueryString
- the URI query string (cannot be specified
if path is null)fragment
- the URI fragment (cannot be specified if path is null)URI.MalformedURIException
- Any of the parameters violates
syntax rules or semantic rulespublic URI(java.lang.String scheme, java.lang.String userinfo, java.lang.String host, int port, java.lang.String path, java.lang.String queryString, java.lang.String fragment) throws URI.MalformedURIException
scheme
- the URI scheme (cannot be null or empty)userinfo
- the URI userinfo (cannot be specified if host is null)host
- the hostname or IPv4 address for the URIport
- the URI port (may be -1 for "unspecified"; cannot
be specified if host is null)path
- the URI path - if the path contains '?' or '#',
then the query string and/or fragment will be set from the path;
however, if the query and fragment are specified both in the path
and as separate parameters, an exception is thrownqueryString
- the URI query string (cannot be specified
if path is null)fragment
- the URI fragment (cannot be specified if path is null)URI.MalformedURIException
- Any of the parameters violates
syntax rules or semantic rulesMethod Detail |
public java.lang.String getScheme()
public java.lang.String getSchemeSpecificPart()
public java.lang.String getUserinfo()
public java.lang.String getHost()
public int getPort()
public java.lang.String getPath(boolean includeQueryString, boolean includeFragment)
includeQueryString
- if true (and query string is not null),
then a "?" followed by the query string will be appendedincludeFragment
- if true (and fragment is not null),
then a "#" followed by the fragment will be appendedpublic java.lang.String getPath()
public java.lang.String getQueryString()
public java.lang.String getFragment()
public void setScheme(java.lang.String scheme) throws URI.MalformedURIException
scheme
- the scheme for this URI (cannot be null)URI.MalformedURIException
- scheme is not a conformant scheme namepublic void setUserinfo(java.lang.String userinfo) throws URI.MalformedURIException
userinfo
- the userinfo for this URIURI.MalformedURIException
- userinfo contains invalid characterspublic void setHost(java.lang.String host) throws URI.MalformedURIException
host
- the host for this URIURI.MalformedURIException
- host is not a valid IP address or DNS hostname.public void setPort(int port) throws URI.MalformedURIException
port
- the port number for this URIURI.MalformedURIException
- port is not -1 and not a valid port numberpublic void setPath(java.lang.String path) throws URI.MalformedURIException
path
- the path for this URI (may be null)URI.MalformedURIException
- path contains invalid characterspublic void appendPath(java.lang.String addToPath) throws URI.MalformedURIException
addToPath
- the new segment to be added to the current pathURI.MalformedURIException
- addToPath contains syntax errorspublic void setQueryString(java.lang.String queryString) throws URI.MalformedURIException
queryString
- the query string for this URIURI.MalformedURIException
- queryString is not null and this
URI does not conform to the generic URI syntax or if the path is nullpublic void setFragment(java.lang.String fragment) throws URI.MalformedURIException
fragment
- the fragment for this URIURI.MalformedURIException
- fragment is not null and this
URI does not conform to the generic URI syntax or if the path is nullpublic boolean equals(java.lang.Object test)
equals
in class java.lang.Object
test
- the Object to test for equality.public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean isGenericURI()
public static boolean isConformantSchemeName(java.lang.String scheme)
scheme
- The sheme name to checkpublic static boolean isWellFormedAddress(java.lang.String address)
address
- The address string to check
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |