public interface Address
Address
interface is used to represent a generic
uniform resource identifier. This interface allows each section
of the uniform resource identifier to be represented. A generic
uniform resource identifier syntax is represented in RFC 2616
section 3.2.2 for the HTTP protocol, this allows similar URI's
for example ftp, http, https, tftp. The syntax is
URI = [scheme "://"] host [ ":" port ] [ path [ "?" query ]]
This interface represents the host, port, path and query part
of the uniform resource identifier. The parameters are also
represented by the URI. The parameters in a URI consist of name
and value pairs in the path segment of the URI.
This will normalize the path part of the uniform resource identifier. A normalized path is one that contains no back references like "./" and "../". The normalized path will not contain the path parameters.
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDomain()
This is used to retrieve the domain of this URI.
|
KeyMap<java.lang.String> |
getParameters()
This extracts the parameter values from the uniform resource
identifier represented by this object.
|
Path |
getPath()
This is used to retrieve the path of this URI.
|
int |
getPort()
This is used to retrieve the port of the uniform resource
identifier.
|
Query |
getQuery()
This is used to retrieve the query of this URI.
|
java.lang.String |
getScheme()
This allows the scheme of the URL given to be returned.
|
java.lang.String |
toString()
This is used to convert this URI object into a
String
object. |
java.lang.String getScheme()
http://domain/path
is
a URI that is intended for the http protocol. The
scheme is the string http
.java.lang.String getDomain()
http://domain/path?querypart
. This will
return the value of the domain part. If there is no
domain part then this will return null otherwise the
domain value found in the uniform resource identifier.int getPort()
http://host:port/path?querypart
. This
will return the value of the port. If there is no port then
this will return -1
because this represents
an impossible uniform resource identifier port. The port
is an optional part.Path getPath()
/
.Query getQuery()
Query
object. The query is
an optional member of a URI and comes after the path part, it
is preceded by a question mark, ?
character.
For example the following URI contains query
for
its query part, http://host:port/path?query
.
This returns a org.simpleframework.http.Query
object that can be used to interact directly with the query
values. The Query
object is a read-only interface
to the query parameters, and so will not affect the URI.
Query
object for the query partKeyMap<java.lang.String> getParameters()
Map
instance.
This will produce unique name and value parameters. Thus if the
URI contains several path segments with similar parameter names
this will return the deepest parameter. For example if the URI
represented was http://domain/path1;x=y/path2;x=z
the value for the parameter named x
would be
z
.
java.lang.String toString()
String
object. This will only convert the parts of the URI that exist, so
the URI may not contain the domain or the query part and it will
not contain the path parameters. If the URI contains all these
parts then it will return something like
scheme://host:port/path/path?querypart
It can return /path/path?querypart
style relative
URI's. If any of the parts are set to null then that part will be
missing, for example if only the path is available then this will
omit the domain, port and scheme. Showing a relative address.
scheme://host:port/?querypart
toString
in class java.lang.Object