|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object issrg.utils.ParsedURL
public class ParsedURL
This class provides methods for splitting a URL into an array of strings. There is also a method for checking that particular strings conform to the standard - i.e. contain only valid characters.
It handles only HTTP-like URLs:
protocol : // [[username [: password] @] host [:port]] [/ [ path ] [# anchor] [? query]]
Note that host is also an optional part of the URL, so file: URLs are also acceptable (but getHost() will return null).
There are corresponding methods to get these values; they can be null, if the value is missing (only path is not null, and has 0 elements, if missing; paths ending with '/' have an empty String "" at the end of the array).
Constructor Summary | |
---|---|
protected |
ParsedURL()
|
protected |
ParsedURL(java.lang.String url,
java.lang.String protocol,
java.lang.String userName,
java.lang.String password,
java.lang.String host,
java.lang.String port,
java.lang.String[] path,
java.lang.String anchor,
java.lang.String query)
This constructor builds a ParsedURL given the original URL and parts of it. |
Method Summary | |
---|---|
java.lang.String |
getAnchor()
|
java.lang.String |
getHost()
|
java.lang.String |
getNormalizedURL()
This method returns a normalised URL (i.e. the path is without '.' and '..' elements, etc.) |
java.lang.String[] |
getOriginalPath()
This method returns the path as it is in the URL ("." and ".." are possible). |
java.lang.String |
getPassword()
|
java.lang.String[] |
getPath()
This method returns normalised path (excessive "." and ".." are removed) |
java.lang.String |
getPathString()
This method returns the normalised path as a String. |
java.lang.String |
getPort()
|
java.lang.String |
getProtocol()
|
java.lang.String |
getQuery()
|
java.lang.String |
getURL()
|
java.lang.String |
getUserName()
|
static ParsedURL |
parseURL(java.lang.String url)
This method parses a URL string, and returns a ParsedURL object, if succeded. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected ParsedURL()
protected ParsedURL(java.lang.String url, java.lang.String protocol, java.lang.String userName, java.lang.String password, java.lang.String host, java.lang.String port, java.lang.String[] path, java.lang.String anchor, java.lang.String query)
url
- - the original URL from which the parts were obtainedprotocol
- - the protocol extracted from the original URLuserName
- - the user name as it appears in the URLpassword
- - the password as it appears in the URLhost
- - the host name as it appears in the URLport
- - the port specification String; may be an integer, but
sometimes it is more than that (e.g. a range of ports)path
- - the array of path elements; cannot be null, but can be emptyanchor
- - the anchor String (everything after "#" and before the
query String)query
- - the query String (everything after "?")Method Detail |
---|
public java.lang.String getProtocol()
public java.lang.String getURL()
public java.lang.String getUserName()
public java.lang.String getPassword()
public java.lang.String getHost()
public java.lang.String getPort()
public java.lang.String[] getPath()
public java.lang.String[] getOriginalPath()
public java.lang.String getPathString()
public java.lang.String getAnchor()
public java.lang.String getQuery()
public java.lang.String getNormalizedURL()
public static ParsedURL parseURL(java.lang.String url)
Valid URLs correspond to the following syntax:
[url:]protocol : // [username [: password]@] host [: port] [/ [path] [# [anchor]]] [? [query]]
url
- is a string encoding of the URL; no character transformation is
done, e.g. %20 remains itself, and is not substituted by a space
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |