Interface Address
-
- All Known Implementing Classes:
AddressParser
public interface Address
TheAddress
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
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.URI = [scheme "://"] host [ ":" port ] [ path [ "?" query ]]
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.
- Author:
- Niall Gallagher
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method 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 aString
object.
-
-
-
Method Detail
-
getScheme
java.lang.String getScheme()
This allows the scheme of the URL given to be returned. If the URI does not contain a scheme then this will return null. The scheme of the URI is the part that specifies the type of protocol that the URI is used for, an examplehttp://domain/path
is a URI that is intended for the http protocol. The scheme is the stringhttp
.- Returns:
- the scheme tag for the address if available
-
getDomain
java.lang.String getDomain()
This is used to retrieve the domain of this URI. The domain part in the URI is an optional part, an examplehttp://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.- Returns:
- the domain part of the address if available
-
getPort
int getPort()
This is used to retrieve the port of the uniform resource identifier. The port part in this is an optional part, an examplehttp://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.- Returns:
- this returns the port part if it is available
-
getPath
Path getPath()
This is used to retrieve the path of this URI. The path part is the most fundamental part of the URI. This will return the value of the path. If there is no path part then this will return a Path implementation that represents the root path represented by/
.- Returns:
- the path part of the uniform resource identifier
-
getQuery
Query getQuery()
This is used to retrieve the query of this URI. The query part in the URI is an optional part. This will return the value of the query part. If there is no query part then this will return an emptyQuery
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 containsquery
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. TheQuery
object is a read-only interface to the query parameters, and so will not affect the URI.- Returns:
- a
Query
object for the query part
-
getParameters
KeyMap<java.lang.String> getParameters()
This extracts the parameter values from the uniform resource identifier represented by this object. The parameters that a uniform resource identifier contains are embedded in the path part of the URI. If the path contains no parameters then this will return an emptyMap
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 namedx
would bez
.- Returns:
- this will return the parameter names found in the URI
-
toString
java.lang.String toString()
This is used to convert this URI object into aString
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 likescheme://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
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the URI address with the optional parts if available
-
-