AnyURI
that is restricted to RFC 3986 URI only.
This may have additional, unnecessary percent encodings, if they were present
in the anyUri
provided to the constructor. If consistent formatting
is required, use IRI
.toURI()
. See isEncodingNormalized()
.
Furthermore, there is no assumption about the query parameter encodings, and the query could, in theory, contain any arbitrary encoded data. Existing encoded query data is maintained, as-is.
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.
-
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 encodingIRI.ENCODING
.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 URI in RFC 3986 URI US-ASCII 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
-
Constructor Details
-
URI
-
-
Method Details
-
toString
Gets the full URI in RFC 3986 URI US-ASCII format.This might not be percent-encoding normalized. Use
toIRI()
.toString()
ortoIRI()
.toURI()
.toString()
if consistent formatting is required. -
toASCIIString
Description copied from class:AnyURI
Gets the full URI in RFC 3986 URI US-ASCII format.This might not be percent-encoding normalized. Use
AnyURI.toIRI()
.toASCIIString()
if consistent formatting is required.- 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
when this was derived from anIRI
, which are always encoding normalized.false
otherwise, since the percent-encoding normalization status is unknown.
-
toURI
Gets this URI encoded in RFC 3986 URI US-ASCII format.This might not be percent-encoding normalized. Use
AnyURI.toIRI()
.toURI()
if consistent formatting is required. -
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 encodingIRI.ENCODING
.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.
-