| java.lang.Object HTTPClient.URI
URI | public class URI (Code) | | This class represents a generic URI, as defined in RFC-2396.
This is similar to java.net.URL, with the following enhancements:
- it doesn't require a URLStreamhandler to exist for the scheme; this
allows this class to be used to hold any URI, construct absolute
URIs from relative ones, etc.
- it handles escapes correctly
- equals() works correctly
- relative URIs are correctly constructed
- it has methods for accessing various fields such as userinfo,
fragment, params, etc.
- it handles less common forms of resources such as the "*" used in
http URLs.
Ideally, java.net.URL should subclass URI.
See Also: rfc-2396 version: 0.3-2 18/06/1999 author: Ronald Tschalär since: V0.3-1 |
Constructor Summary | |
public | URI(String uri) Constructs a URI from the given string representation. | public | URI(URI base, String rel_uri) Constructs a URI from the given string representation, relative to
the given base URI. | public | URI(URL url) Construct a URI from the given URL. | public | URI(String scheme, String host, String path) Constructs a URI from the given parts, using the default port for
this scheme (if known). | public | URI(String scheme, String host, int port, String path) Constructs a URI from the given parts. | public | URI(String scheme, String userinfo, String host, int port, String path, String query, String fragment) Constructs a URI from the given parts. | public | URI(String scheme, String opaque) Constructs an opaque URI from the given parts. |
is_generic | protected boolean is_generic(Code) | | |
URI | public URI(String uri) throws ParseException(Code) | | Constructs a URI from the given string representation. The string
must be an absolute URI.
Parameters: uri - a String containing an absolute URI exception: ParseException - if no scheme can be found or a specifiedport cannot be parsed as a number |
URI | public URI(URI base, String rel_uri) throws ParseException(Code) | | Constructs a URI from the given string representation, relative to
the given base URI.
Parameters: base - the base URI, relative to which rel_uriis to be parsed Parameters: rel_uri - a String containing a relative or absolute URI exception: ParseException - if base is null andrel_uri is not an absolute URI, orif base is not null and the schemeis not known to use the generic syntax, orif a given port cannot be parsed as a number |
URI | public URI(URL url) throws ParseException(Code) | | Construct a URI from the given URL.
Parameters: url - the URL exception: ParseException - if url.toExternalForm() generatesan invalid string representation |
URI | public URI(String scheme, String host, String path) throws ParseException(Code) | | Constructs a URI from the given parts, using the default port for
this scheme (if known).
Parameters: scheme - the scheme (sometimes known as protocol) Parameters: host - the host Parameters: path - the path part exception: ParseException - if scheme is null |
URI | public URI(String scheme, String host, int port, String path) throws ParseException(Code) | | Constructs a URI from the given parts.
Parameters: scheme - the scheme (sometimes known as protocol) Parameters: host - the host Parameters: port - the port Parameters: path - the path part exception: ParseException - if scheme is null |
URI | public URI(String scheme, String userinfo, String host, int port, String path, String query, String fragment) throws ParseException(Code) | | Constructs a URI from the given parts. Any part except for the
the scheme may be null.
Parameters: scheme - the scheme (sometimes known as protocol) Parameters: userinfo - the userinfo Parameters: host - the host Parameters: port - the port Parameters: path - the path part Parameters: query - the query string Parameters: fragment - the fragment identifier exception: ParseException - if scheme is null |
URI | public URI(String scheme, String opaque) throws ParseException(Code) | | Constructs an opaque URI from the given parts.
Parameters: scheme - the scheme (sometimes known as protocol) Parameters: opaque - the opaque part exception: ParseException - if scheme is null |
defaultPort | final public static int defaultPort(String protocol)(Code) | | Return the default port used by a given protocol.
Parameters: protocol - the protocol the port number, or 0 if unknown |
equals | public boolean equals(Object other)(Code) | | true if other is either a URI or URL and itmatches the current URI |
getOpaque | public String getOpaque()(Code) | | the opaque part, or null if this URI is generic |
getPath | public String getPath()(Code) | | the path; this includes the query string |
getPort | public int getPort()(Code) | | the port, or -1 if it's the default port |
getQueryString | public String getQueryString()(Code) | | the query string |
getScheme | public String getScheme()(Code) | | the scheme (often also referred to as protocol) |
isGenericURI | public boolean isGenericURI()(Code) | | Does the scheme specific part of this URI use the generic-URI syntax?
In general URI are split into two categories: opaque-URI and
generic-URI. The generic-URI syntax is the syntax most are familiar
with from URLs such as ftp- and http-URLs, which is roughly:
generic-URI = scheme ":" [ "//" server ] [ "/" ] [ path_segments ] [ "?" query ]
(see draft-fielding-uri-syntax-03 for exact syntax). Only URLs
using the generic-URI syntax can be used to create and resolve
relative URIs.
Whether a given scheme is parsed according to the generic-URI
syntax or wether it is treated as opaque is determined by an internal
table of URI schemes.
See Also: rfc-2396 |
toExternalForm | public String toExternalForm()(Code) | | a string representation of this URI suitable for use inlinks, headers, etc. |
unescape | final static String unescape(String str) throws ParseException(Code) | | Unescape escaped characters (i.e. %xx).
Parameters: str - the string to unescape the unescaped string exception: ParseException - if the two digits following a `%' arenot a valid hex number |
usesGenericSyntax | public static boolean usesGenericSyntax(String scheme)(Code) | | true if the scheme should be parsed according to thegeneric-URI syntax |
|
|