Class URL
-
Constructor Summary
Constructors -
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.voidRemove 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.booleanCheck if this URL has an authority.booleanDetermine if this URL has a fragment.booleanTest if the URL has the specified querystring parameter.booleanCheck if this URL has a parameters.booleanhasPath()Check if this URL has a path component.booleanCheck if this URL has a scheme.booleanCheck if this URL is absolute, i.e. if it has both a scheme and an authority.voidMake this URL relative by discarding its scheme and authority part.voidSet a querystring parameter.voidRemove the URL's fragment.booleanremoveParam(String p_strParam) Remove the specified querystring parameter.voidRemove the scheme from this URL.voidsetAuthority(String p_strAuthority) Set the authority.voidsetFragment(String p_strFragment) Set the URL#s fragment.voidSet the querystring parameters that are contained in the given map.voidSet the path.voidSet the scheme, e.g.voidwriteEntityEncodedTo(Writer p_out) Write the URL to the specifiedjava.io.Writer, e.g.voidWrite 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:
trueif this URL has a scheme, orfalseotherwise.
-
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:
trueif this URL has an authority, orfalseotherwise.
-
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:
trueif this URL has a path component, orfalseotherwise.
-
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:
trueif this URL is absolute, orfalseotherwise.
-
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:
trueif this URL has one or more parameters, orfalseotherwise.
-
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
nullif 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:
trueif the URL has the specified, querystring parameter, orfalseotherwise.
-
removeParam
Remove the specified querystring parameter.- Parameters:
p_strParam- The The querystring parameter.- Returns:
trueif the specified querystring parameter was was removed, orfalseif 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:
trueif the URL has a fragment, orfalseotherwise.
-
getFragment
Get the URL's fragment.- Returns:
- The URL's fragment, not including the leading sharp sign,
or
nullif 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.