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
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 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:AnyURIGets 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:
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:
truewhen this was derived from anIRI, which are always encoding normalized.falseotherwise, 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: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 encodingIRI.ENCODING.TODO: Implement specification of fragment-escape.
- Overrides:
setFragmentin classAnyURI- Parameters:
fragment- The fragment (not including the '#') ornullfor no fragment.- Returns:
- The new
AnyURIorthiswhen unmodified.
-
