public class ParseURL
extends java.lang.Object
Constructor and Description |
---|
ParseURL(java.lang.String url)
Create a new instance and parse the URL.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
decodeValue(java.lang.String encodedValue)
Convert a percent-encoded/URL-encoded value to a plain value by applying the UTF-8 charset.
|
static java.lang.String |
encodeValue(java.lang.String plainText)
Convert a plain value to a percent-encoded/URL-encoded value by applying the UTF-8 charset.
|
static java.lang.String |
escapedTextToPlainText(java.lang.String escapedText)
Convert an escaped text of a URL query string name or value parameter to plain text.
|
java.lang.String |
getFragmentIdentifier()
Get the fragment identifier (the text after the '#' anchor).
|
java.lang.String |
getHost()
Get the host.
|
java.lang.String |
getPath()
Get the path, without (optional) CGI parameters, and without the (optional) fragment identifier.
|
int |
getPort()
Get the IP port, or - if the URL contains no IP port - get the default IP port of the protocol.
|
java.lang.String |
getProtocol()
Get the protocol.
|
java.lang.String |
getRawCGIParams()
Get the raw CGI parameters.
|
java.lang.String |
getRawPath()
Get the raw path, inclusive (optional) CGI parameters, but without the (optional) fragment identifier.
|
int |
getRawPort()
Get the raw IP port of the URL.
|
static java.lang.String |
getUrlQueryString(java.lang.String url)
Get the query string of an URL.
|
static java.util.ArrayList<KeyValuePair<java.lang.String,java.lang.String>> |
getUrlQueryStringNameValuePairs(java.lang.String queryString)
Get an array list of name/value pairs from an URL query string.
|
boolean |
hasNoPath()
Get if the URL has no path.
|
static java.lang.String |
plainTextToEscapedText(java.lang.String plainText)
Convert a plain text of a URL query string name or value parameter to escaped text.
|
public ParseURL(java.lang.String url) throws java.net.MalformedURLException
url
- the URL to parsejava.net.MalformedURLException
- if parsing failspublic java.lang.String getProtocol()
public java.lang.String getHost()
public int getRawPort()
public int getPort()
public boolean hasNoPath()
public java.lang.String getRawPath()
public java.lang.String getPath()
public java.lang.String getRawCGIParams()
public java.lang.String getFragmentIdentifier()
public static java.lang.String getUrlQueryString(java.lang.String url)
url
- the URL, or the full path of an URLpublic static java.util.ArrayList<KeyValuePair<java.lang.String,java.lang.String>> getUrlQueryStringNameValuePairs(java.lang.String queryString)
queryString
- the URL query stringpublic static java.lang.String escapedTextToPlainText(java.lang.String escapedText)
escapedText
- the escaped textpublic static java.lang.String plainTextToEscapedText(java.lang.String plainText)
plainText
- the plain textpublic static java.lang.String encodeValue(java.lang.String plainText) throws java.io.UnsupportedEncodingException
plainText
- the plain textjava.io.UnsupportedEncodingException
- if the encoding failspublic static java.lang.String decodeValue(java.lang.String encodedValue) throws java.io.UnsupportedEncodingException
encodedValue
- the percent-encoded/URL-encoded valuejava.io.UnsupportedEncodingException
- if decoding encoding fails