Class URL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionEncode this URL to the percent-encoding format using the UTF-8 charset, and the replace ampersand characters with the&
HTML character entity.Deprecated.Convert this URL in its string representation with proper percent encoding using the UTF-8 charset.asString()
Convert this URL in its string representation without percent encoding.Encode the complete URL to the percent-encoding format using the UTF-8 charset.asUrlEncodedString
(String p_strCharset) Deprecated.UseasUrlEncodedString()
instead.void
Remove all querystring parameters.cloneUrl()
Get the authority.Get the URL's fragment.Get a querystring parameter.Get all query parameters.getPath()
Get the path.Convert this URL's query to its string representation with proper percent encoding using the UTF-8 charset.Get the scheme.boolean
Check if this URL has an authority.boolean
Determine if this URL has a fragment.boolean
Test if the URL has the specified querystring parameter.boolean
Check if this URL has a parameters.boolean
hasPath()
Check if this URL has a path component.boolean
Check if this URL has a scheme.boolean
Check if this URL is absolute, i.e.void
Make this URL relative by discarding its scheme and authority part.void
Set a querystring parameter.void
Remove the URL's fragment.boolean
removeParam
(String p_strParam) Remove the specified querystring parameter.void
Remove the scheme from this URL.void
setAuthority
(String p_strAuthority) Set the authority.void
setFragment
(String p_strFragment) Set the URL#s fragment.void
Set the querystring parameters that are contained in the given map.void
Set the path.void
Set the scheme, e.g.void
writeEntityEncodedTo
(Writer p_out) Write the URL to the specifiedjava.io.Writer
, e.g.void
Write the string representation of this URL without percent encoding to the specifiedjava.io.Writer
, e.g.
-
Constructor Details
-
URL
- Throws:
MalformedURLException
-
-
Method Details
-
cloneUrl
-
hasScheme
public boolean hasScheme()Check if this URL has a scheme.- Returns:
true
if this URL has a scheme, orfalse
otherwise.
-
getScheme
Get the scheme.- Returns:
- The scheme.
-
setScheme
Set the scheme, e.g.https
.- Parameters:
p_strScheme
- The scheme.- Throws:
IllegalArgumentException
- If the given scheme isnull
, or does not conform to the syntax specified in RFC 3986, 3.1.- See Also:
-
removeScheme
public void removeScheme()Remove the scheme from this URL.This can be usefull to create schema-less URLs.
-
hasAuthority
public boolean hasAuthority()Check if this URL has an authority.- Returns:
true
if this URL has an authority, orfalse
otherwise.
-
getAuthority
Get the authority.- Returns:
- The authority.
-
setAuthority
Set the authority.- Parameters:
p_strAuthority
- The authority.- Throws:
IllegalArgumentException
- If the given authority isnull
.- See Also:
-
hasPath
public boolean hasPath()Check if this URL has a path component.- Returns:
true
if this URL has a path component, orfalse
otherwise.
-
getPath
Get the path.- Returns:
- The path.
-
setPath
Set the path.- Parameters:
p_strPath
- The path.
-
isAbsolute
public boolean isAbsolute()Check if this URL is absolute, i.e. if it has both a scheme and an authority.This method does not check for the presence of a fragment identifier. Also note that a schema-less URL is considered to be a relative URL.
- Returns:
true
if this URL is absolute, orfalse
otherwise.
-
makeRelative
public void makeRelative()Make this URL relative by discarding its scheme and authority part. -
hasParams
public boolean hasParams()Check if this URL has a parameters.- Returns:
true
if this URL has one or more parameters, orfalse
otherwise.
-
putParam
Set a querystring parameter.Parameters that start with
rq_
will be hex-encoded unless they are in the list of unencoded querystring parameters. All other parameters are not hex-encoded.- Parameters:
p_strParam
- The name of the querystring parameter.p_value
- The value of the querystring parameter.
-
getParam
Get a querystring parameter.- Parameters:
p_strParam
- The name of the querystring parameter.- Returns:
- The value of the given querystring parameter,
or
null
if it does not exist.
-
getParams
Get all query parameters.- Returns:
- The query parameters.
-
hasParam
Test if the URL has the specified querystring parameter.- Parameters:
p_strParam
- The querystring parameter.- Returns:
true
if the URL has the specified, querystring parameter, orfalse
otherwise.
-
removeParam
Remove the specified querystring parameter.- Parameters:
p_strParam
- The The querystring parameter.- Returns:
true
if the specified querystring parameter was was removed, orfalse
if the URL did not contain the specified querystring parameter.
-
setParams
Set the querystring parameters that are contained in the given map.- Parameters:
p_params
- The querystring parameters to set.
-
clearParams
public void clearParams()Remove all querystring parameters. -
hasFragment
public boolean hasFragment()Determine if this URL has a fragment.- Returns:
true
if the URL has a fragment, orfalse
otherwise.
-
getFragment
Get the URL's fragment.- Returns:
- The URL's fragment, not including the leading sharp sign,
or
null
if the URL has no fragment.
-
setFragment
Set the URL#s fragment.- Parameters:
p_strFragment
- The URL#s fragment.
-
removeFragment
public void removeFragment()Remove the URL's fragment. -
writeTo
Write the string representation of this URL without percent encoding to the specifiedjava.io.Writer
, e.g.$Response
.This method is mainly used to display human-readable URLs.
- Parameters:
p_out
- The output stream.- Throws:
IOException
- If an I/O error occurred or the character encoding could not be determined.- See Also:
-
asString
Convert this URL in its string representation without percent encoding.This method is mainly used to display human-readable URLs.
- Returns:
- The URL as a string.
-
asPercentEncodedString
Convert this URL in its string representation with proper percent encoding using the UTF-8 charset.The resulting string will contain ASCII characters only.
- Returns:
- The percent-encoded URL.
-
asParamsEncodedString
Deprecated.UseasPercentEncodedString()
instead.Same asasPercentEncodedString()
.- See Also:
-
writeEntityEncodedTo
Write the URL to the specifiedjava.io.Writer
, e.g.$Response
.- Parameters:
p_out
- The output stream.- Throws:
IOException
- If an I/O error occurred or the character encoding could not be determined.- See Also:
-
asEntityEncodedString
Encode this URL to the percent-encoding format using the UTF-8 charset, and the replace ampersand characters with the&
HTML character entity.- Returns:
- The percent- and entity-encoded URL.
-
asUrlEncodedString
Encode the complete URL to the percent-encoding format using the UTF-8 charset.- Returns:
- The URL-encoded string.
-
asUrlEncodedString
Deprecated.UseasUrlEncodedString()
instead.Encode the complete URL to the percent-encoding format using the UTF-8 charset.Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilites. So we ignore the charset parameter.
- Parameters:
p_strCharset
- Unused.- Returns:
- The URL-encoded string.
-
getQueryAsPercentEncodedString
Convert this URL's query to its string representation with proper percent encoding using the UTF-8 charset.The returned string does not start with the question mark delimiter.
The resulting string will contain ASCII characters only.
- Returns:
- The percent-encoded query string.
-
asPercentEncodedString()
instead.