|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.could.util.location.Location
An utility class representing an HTTP-like URL.
This class can be used to represent any URL that roughly uses the HTTP
format. Compared to the standard URL
class, the scheme part
of the a Location
is never checked, and it's up to the application
to verify its correctness, while compared to the URI
class,
its parsing mechanism is a lot more relaxed (be liberal in what you accept,
be strict in what you send).
For a bigger picture on how this class works, this is an easy-to-read
representation of what the different parts of a Location
are:
One important difference between this implementation and the description
of URLs and
URIs is that parameter
paths are represented only at the end of the entire path structure
rather than for each path element. This over-simplification allows easy
relativization of Location
s when used with servlet containers, which
normally use path parameters to encode the session id.
Nested Class Summary | |
static class |
Location.Authority
The Authority class represents the autority
and user information for a Location . |
static class |
Location.Schemes
The Schemes class represents an unmodifiable
ordered collection of String schemes for a Location . |
Field Summary |
Fields inherited from interface it.could.util.encoding.EncodingAware |
DEFAULT_ENCODING, PLATFORM_ENCODING |
Constructor Summary | |
Location(Location.Schemes schemes,
Location.Authority authority,
Path path,
Parameters parameters,
String fragment)
Create a new Location instance. |
Method Summary | |
boolean |
equals(Object object)
Check if the specified Object is equal to this instance. |
static int |
findPort(List schemes,
String encoding)
Return the port number associated with the specified schemes. |
Location.Authority |
getAuthority()
Return the Authority part for this
Location or null. |
String |
getFragment()
Return the fragment of this Location unencoded. |
Parameters |
getParameters()
Return an unmodifiable list of all parameters
parsed from this Location 's query string or null. |
Path |
getPath()
Return the non-null Path structure
associated with this Location instance. |
Location.Schemes |
getSchemes()
Return an unmodifiable list of all schemes for this
Location instance or null. |
int |
hashCode()
Return the hash code value for this Location instance. |
boolean |
isAbsolute()
Checks whether this Location is absolute or not. |
boolean |
isAuthoritative(Location location)
|
boolean |
isRelative()
|
static Location |
parse(String url)
|
static Location |
parse(String url,
String encoding)
|
Location |
relativize(Location location)
|
Location |
relativize(String url)
|
Location |
relativize(String url,
String encoding)
|
Location |
resolve(Location location)
|
Location |
resolve(String url)
|
Location |
resolve(String url,
String encoding)
|
String |
toString()
Return the String representation of this Location
instance. |
String |
toString(String encoding)
Return the String representation of this Location
instance using the specified character encoding. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Location(Location.Schemes schemes, Location.Authority authority, Path path, Parameters parameters, String fragment) throws MalformedURLException
Create a new Location
instance.
Method Detail |
public static Location parse(String url) throws MalformedURLException
MalformedURLException
public static Location parse(String url, String encoding) throws MalformedURLException, UnsupportedEncodingException
MalformedURLException
UnsupportedEncodingException
public Location.Schemes getSchemes()
Return an unmodifiable list of all schemes
for this
Location
instance or null.
public Location.Authority getAuthority()
public Path getPath()
public Parameters getParameters()
Return an unmodifiable list of all parameters
parsed from this Location
's query string or null.
public String getFragment()
Return the fragment of this Location
unencoded.
public boolean equals(Object object)
Check if the specified Object
is equal to this instance.
The specified Object
must be a non-null
Location
instance whose string value
equals
this one's.
public int hashCode()
Return the hash code value for this Location
instance.
public String toString()
Return the String
representation of this Location
instance.
toString
in interface Encodable
public String toString(String encoding) throws UnsupportedEncodingException
Return the String
representation of this Location
instance using the specified character encoding.
toString
in interface Encodable
UnsupportedEncodingException
- if the specified encoding is not
supported by the platform.public boolean isAbsolute()
Checks whether this Location
is absolute or not.
This method must not be confused with the similarly named
Path.isAbsolute()
method.
This method will check whether the full Location
is absolute (it
has a scheme), while the one exposed by the Path
class will check if the path is absolute.
public boolean isRelative()
public boolean isAuthoritative(Location location)
public Location resolve(String url) throws MalformedURLException
MalformedURLException
public Location resolve(String url, String encoding) throws MalformedURLException, UnsupportedEncodingException
MalformedURLException
UnsupportedEncodingException
public Location resolve(Location location)
public Location relativize(String url) throws MalformedURLException
MalformedURLException
public Location relativize(String url, String encoding) throws MalformedURLException, UnsupportedEncodingException
MalformedURLException
UnsupportedEncodingException
public Location relativize(Location location)
public static int findPort(List schemes, String encoding) throws UnsupportedEncodingException
Return the port number associated with the specified schemes.
UnsupportedEncodingException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |