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
FieldsModifier and TypeFieldDescriptionstatic final CharsetThe default encoding isper B.2.1 Non-ASCII characters in URI attribute values.StandardCharsets.UTF_8 -
Constructor Summary
Constructors -
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 ':').booleanIs 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 isper 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:
toASCIIStringin classAnyURI
-
appendScheme
Description copied from class:AnyURIAppends the scheme (not including the ':').- Overrides:
appendSchemein classAnyURI- Returns:
this- Throws:
IOException
-
appendScheme
Description copied from class:AnyURIAppends the scheme (not including the ':').- Overrides:
appendSchemein classAnyURI- Returns:
this- Throws:
IOException
-
appendHierPart
Description copied from class:AnyURIAppends the part of the URI after the scheme and up to the first '?' or '#' (exclusive), or the full URI when neither found.- Overrides:
appendHierPartin classAnyURI- Returns:
this- Throws:
IOException
-
appendHierPart
Description copied from class:AnyURIAppends the part of the URI after the scheme and up to the first '?' or '#' (exclusive), or the full URI when neither found.- Overrides:
appendHierPartin classAnyURI- Returns:
this- Throws:
IOException
-
appendQueryString
Description copied from class:AnyURIAppends the query string (not including the '?').- Overrides:
appendQueryStringin classAnyURI- Returns:
this- Throws:
IOException
-
appendQueryString
Description copied from class:AnyURIAppends the query string (not including the '?').- Overrides:
appendQueryStringin classAnyURI- Returns:
this- Throws:
IOException
-
appendFragment
Description copied from class:AnyURIAppends the fragment (not including the '#').- Overrides:
appendFragmentin classAnyURI- Returns:
this- Throws:
IOException
-
appendFragment
Description copied from class:AnyURIAppends the fragment (not including the '#').- Overrides:
appendFragmentin 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:
isEncodingNormalizedin classAnyURI- Returns:
true-IRIare 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:AnyURIReplaces the hier-part.- Overrides:
setHierPartin classAnyURI- Parameters:
hierPart- The hier-part may not contain the query marker '?' or fragment marker '#'- Returns:
- The new
AnyURIorthiswhen unmodified.
-
setQueryString
Description copied from class:AnyURIReplaces the query string.- Overrides:
setQueryStringin 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
AnyURIorthiswhen unmodified.
-
addQueryString
Description copied from class:AnyURIAdds a query string.- Overrides:
addQueryStringin 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
AnyURIorthiswhen unmodified.
-
addEncodedParameter
Description copied from class:AnyURIAdds an already-encoded parameter.- Overrides:
addEncodedParameterin 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 benullwhennameisnull. The value may not contain the fragment marker '#'- Returns:
- The new
AnyURIorthiswhen unmodified.
-
addParameter
Description copied from class:AnyURIEncodes and adds a parameter.- Overrides:
addParameterin 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 benullwhennameisnull.- Returns:
- The new
AnyURIorthiswhen unmodified. - See Also:
-
addParameters
Description copied from class:AnyURIAdds all of the parameters.- Overrides:
addParametersin classAnyURI- Parameters:
params- The parameters to add. Nothing is added whennullor empty.- Returns:
- The new
AnyURIorthiswhen unmodified. - See Also:
-
setEncodedFragment
Description copied from class:AnyURIReplaces the fragment.- Overrides:
setEncodedFragmentin classAnyURI- Parameters:
encodedFragment- The fragment (not including the '#') - it is added without additional encoding. Removes fragment whennull.- Returns:
- The new
AnyURIorthiswhen unmodified.
-
setFragment
Description copied from class:AnyURIReplaces the fragment in the default encodingENCODING.TODO: Implement specification of fragment-escape.
- Overrides:
setFragmentin classAnyURI- Parameters:
fragment- The fragment (not including the '#') ornullfor no fragment.- Returns:
- The new
AnyURIorthiswhen unmodified.
-
