Java Reference
In-Depth Information
public boolean isAbsolute ()
The details of the scheme-specific part vary depending on the type of the scheme. For
example, in a tel URL, the scheme-specific part has the syntax of a telephone number.
However, in many useful URIs, including the very common file and http URLs, the
scheme-specific part has a particular hierarchical format divided into an authority, a
path, and a query string. The authority is further divided into user info, host, and port.
The isOpaque() method returns false if the URI is hierarchical, true if it's not hier‐
archical—that is, if it's opaque:
public boolean isOpaque ()
If the URI is opaque, all you can get is the scheme, scheme-specific part, and fragment
identifier. However, if the URI is hierarchical, there are getter methods for all the dif‐
ferent parts of a hierarchical URI:
public String getAuthority ()
public String getFragment ()
public String getHost ()
public String getPath ()
public String getPort ()
public String getQuery ()
public String getUserInfo ()
These methods all return the decoded parts; in other words, percent escapes, such as
%3C, are changed into the characters they represent, such as <. If you want the raw,
encoded parts of the URI, there are five parallel getRaw_Foo_() methods:
public String getRawAuthority ()
public String getRawFragment ()
public String getRawPath ()
public String getRawQuery ()
public String getRawUserInfo ()
Remember the URI class differs from the URI specification in that non-ASCII characters
such as é and ü are never percent escaped in the first place, and thus will still be present
in the strings returned by the getRawFoo() methods unless the strings originally used
to construct the URI object were encoded.
There are no getRawPort() and getRawHost() methods because these
components are always guaranteed to be made up of ASCII characters.
In the event that the specific URI does not contain this information—for instance, the
URI http://www.example.com has no user info, path, port, or query string—the relevant
methods return null. getPort() is the single exception. Since it's declared to return an
int , it can't return null . Instead, it returns -1 to indicate an omitted port.
Search WWH ::




Custom Search