AnyURI
that prefers RFC 3987 IRI.
This has consistently formatted percent encodings.
Furthermore, this assumes UTF-8 encoding for the query parameters.
If the query parameters include any arbitrary encoded data, use
AnyURI
or URI
instead.
When a strict ASCII-only representation of a RFC 3986 URI
is required, use URI
. When a Unicode representation of a RFC 3987 IRI
is preferred, use IRI
. Otherwise, to support both, use AnyURI
, which should also perform
the best since it performs fewer conversions.
- Author:
- AO Industries, Inc.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Charset
The default encoding is
per B.2.1 Non-ASCII characters in URI attribute values.StandardCharsets.UTF_8
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddEncodedParameter
(String encodedName, String encodedValue) Adds an already-encoded parameter.addParameter
(String name, String value) Encodes and adds a parameter.addParameters
(URIParameters params) Adds all of the parameters.addQueryString
(String query) Adds a query string.appendFragment
(Encoder encoder, Appendable out) Appends the fragment (not including the '#').appendFragment
(Appendable out) Appends the fragment (not including the '#').appendHierPart
(Encoder encoder, Appendable out) Appends the part of the URI after the scheme and up to the first '?'appendHierPart
(Appendable out) Appends the part of the URI after the scheme and up to the first '?'appendQueryString
(Encoder encoder, Appendable out) Appends the query string (not including the '?').Appends the query string (not including the '?').appendScheme
(Encoder encoder, Appendable out) Appends the scheme (not including the ':').appendScheme
(Appendable out) Appends the scheme (not including the ':').boolean
Is this URI percent-encoding normalized?setEncodedFragment
(String encodedFragment) Replaces the fragment.setFragment
(String fragment) Replaces the fragment in the default encodingENCODING
.setHierPart
(String hierPart) Replaces the hier-part.setQueryString
(String query) Replaces the query string.Gets the full URI in RFC 3986 URI US-ASCII format.toIRI()
Gets this URI encoded in RFC 3987 IRI Unicode format.toString()
Gets the full IRI in RFC 3987 IRI Unicode format.toURI()
Gets this URI encoded in RFC 3986 URI US-ASCII format.Methods inherited from class com.aoapps.net.AnyURI
appendFragment, appendFragment, appendHierPart, appendHierPart, appendQueryString, appendQueryString, appendScheme, appendScheme, equals, getFragment, getFragmentIndex, getHierPart, getPathEnd, getQueryIndex, getQueryString, getScheme, getSchemeLength, hasFragment, hashCode, hasQuery, hasScheme, isScheme, pathEndsWith, pathEndsWithIgnoreCase, writeFragment, writeFragment, writeHierPart, writeHierPart, writeQueryString, writeQueryString, writeScheme, writeScheme
-
Field Details
-
ENCODING
The default encoding is
per B.2.1 Non-ASCII characters in URI attribute values.StandardCharsets.UTF_8
-
-
Constructor Details
-
IRI
-
-
Method Details
-
toString
Gets the full IRI in RFC 3987 IRI Unicode format.This will be percent-encoding normalized and contain consistently formatted percent encodings.
-
toASCIIString
Gets the full URI in RFC 3986 URI US-ASCII format.This will be percent-encoding normalized and contain consistently formatted percent encodings.
- Overrides:
toASCIIString
in classAnyURI
-
appendScheme
Description copied from class:AnyURI
Appends the scheme (not including the ':').- Overrides:
appendScheme
in classAnyURI
- Returns:
this
- Throws:
IOException
-
appendScheme
Description copied from class:AnyURI
Appends the scheme (not including the ':').- Overrides:
appendScheme
in classAnyURI
- Returns:
this
- Throws:
IOException
-
appendHierPart
Description copied from class:AnyURI
Appends the part of the URI after the scheme and up to the first '?' or '#' (exclusive), or the full URI when neither found.- Overrides:
appendHierPart
in classAnyURI
- Returns:
this
- Throws:
IOException
-
appendHierPart
Description copied from class:AnyURI
Appends the part of the URI after the scheme and up to the first '?' or '#' (exclusive), or the full URI when neither found.- Overrides:
appendHierPart
in classAnyURI
- Returns:
this
- Throws:
IOException
-
appendQueryString
Description copied from class:AnyURI
Appends the query string (not including the '?').- Overrides:
appendQueryString
in classAnyURI
- Returns:
this
- Throws:
IOException
-
appendQueryString
Description copied from class:AnyURI
Appends the query string (not including the '?').- Overrides:
appendQueryString
in classAnyURI
- Returns:
this
- Throws:
IOException
-
appendFragment
Description copied from class:AnyURI
Appends the fragment (not including the '#').- Overrides:
appendFragment
in classAnyURI
- Returns:
this
- Throws:
IOException
-
appendFragment
Description copied from class:AnyURI
Appends the fragment (not including the '#').- Overrides:
appendFragment
in classAnyURI
- Returns:
this
- Throws:
IOException
-
isEncodingNormalized
public boolean isEncodingNormalized()Is this URI percent-encoding normalized? Normalized percent encoding means it will have only the required percent encodings, and the encodings are capitalized hexadecimal.Note: This only refers to the percent encodings. This is not related to full URI normalization.
- Overrides:
isEncodingNormalized
in classAnyURI
- Returns:
true
-IRI
are always encoding normalized.
-
toURI
Gets this URI encoded in RFC 3986 URI US-ASCII format.This will be percent-encoding normalized and contain consistently formatted percent encodings.
-
toIRI
Gets this URI encoded in RFC 3987 IRI Unicode format. -
setHierPart
Description copied from class:AnyURI
Replaces the hier-part.- Overrides:
setHierPart
in classAnyURI
- Parameters:
hierPart
- The hier-part may not contain the query marker '?' or fragment marker '#'- Returns:
- The new
AnyURI
orthis
when unmodified.
-
setQueryString
Description copied from class:AnyURI
Replaces the query string.- Overrides:
setQueryString
in classAnyURI
- Parameters:
query
- The query (not including the first '?') - it is added without additional encoding. The query is removed when the query isnull
. The query may not contain the fragment marker '#'- Returns:
- The new
AnyURI
orthis
when unmodified.
-
addQueryString
Description copied from class:AnyURI
Adds a query string.- Overrides:
addQueryString
in classAnyURI
- Parameters:
query
- The query (not including the first '?' / '&') - it is added without additional encoding. Nothing is added when the query isnull
. The query may not contain the fragment marker '#'- Returns:
- The new
AnyURI
orthis
when unmodified.
-
addEncodedParameter
Description copied from class:AnyURI
Adds an already-encoded parameter.- Overrides:
addEncodedParameter
in classAnyURI
- Parameters:
encodedName
- The parameter name - it is added without additional encoding. Nothing is added when the name isnull
. The name may not contain the fragment marker '#'encodedValue
- The parameter value - it is added without additional encoding. Whennull
, the parameter is added without any '='. Must benull
whenname
isnull
. The value may not contain the fragment marker '#'- Returns:
- The new
AnyURI
orthis
when unmodified.
-
addParameter
Description copied from class:AnyURI
Encodes and adds a parameter.- Overrides:
addParameter
in classAnyURI
- Parameters:
name
- The parameter name. Nothing is added when the name isnull
.value
- The parameter value. Whennull
, the parameter is added without any '='. Must benull
whenname
isnull
.- Returns:
- The new
AnyURI
orthis
when unmodified. - See Also:
-
addParameters
Description copied from class:AnyURI
Adds all of the parameters.- Overrides:
addParameters
in classAnyURI
- Parameters:
params
- The parameters to add. Nothing is added whennull
or empty.- Returns:
- The new
AnyURI
orthis
when unmodified. - See Also:
-
setEncodedFragment
Description copied from class:AnyURI
Replaces the fragment.- Overrides:
setEncodedFragment
in classAnyURI
- Parameters:
encodedFragment
- The fragment (not including the '#') - it is added without additional encoding. Removes fragment whennull
.- Returns:
- The new
AnyURI
orthis
when unmodified.
-
setFragment
Description copied from class:AnyURI
Replaces the fragment in the default encodingENCODING
.TODO: Implement specification of fragment-escape.
- Overrides:
setFragment
in classAnyURI
- Parameters:
fragment
- The fragment (not including the '#') ornull
for no fragment.- Returns:
- The new
AnyURI
orthis
when unmodified.
-