final class HierarchicalUriComponents extends UriComponents
UriComponents
for hierarchical URIs.Modifier and Type | Class and Description |
---|---|
private static class |
HierarchicalUriComponents.EncodeState |
(package private) static class |
HierarchicalUriComponents.FullPathComponent
Represents a path backed by a String.
|
(package private) static interface |
HierarchicalUriComponents.PathComponent
Defines the contract for path (segments).
|
(package private) static class |
HierarchicalUriComponents.PathComponentComposite
Represents a collection of PathComponents.
|
(package private) static class |
HierarchicalUriComponents.PathSegmentComponent
Represents a path backed by a String list (i.e.
|
private static class |
HierarchicalUriComponents.QueryUriTemplateVariables |
(package private) static class |
HierarchicalUriComponents.Type
Enumeration used to identify the allowed characters per URI component.
|
private static class |
HierarchicalUriComponents.UriTemplateEncoder |
UriComponents.UriTemplateVariables
Modifier and Type | Field and Description |
---|---|
private static MultiValueMap<java.lang.String,java.lang.String> |
EMPTY_QUERY_PARAMS |
private HierarchicalUriComponents.EncodeState |
encodeState |
private java.lang.String |
host |
(package private) static HierarchicalUriComponents.PathComponent |
NULL_PATH_COMPONENT
Represents an empty path.
|
private HierarchicalUriComponents.PathComponent |
path |
private static char |
PATH_DELIMITER |
private static java.lang.String |
PATH_DELIMITER_STRING |
private java.lang.String |
port |
private MultiValueMap<java.lang.String,java.lang.String> |
queryParams |
private java.lang.String |
userInfo |
private java.util.function.UnaryOperator<java.lang.String> |
variableEncoder |
Modifier | Constructor and Description |
---|---|
(package private) |
HierarchicalUriComponents(java.lang.String scheme,
java.lang.String fragment,
java.lang.String userInfo,
java.lang.String host,
java.lang.String port,
HierarchicalUriComponents.PathComponent path,
MultiValueMap<java.lang.String,java.lang.String> query,
boolean encoded)
Package-private constructor.
|
private |
HierarchicalUriComponents(java.lang.String scheme,
java.lang.String fragment,
java.lang.String userInfo,
java.lang.String host,
java.lang.String port,
HierarchicalUriComponents.PathComponent path,
MultiValueMap<java.lang.String,java.lang.String> queryParams,
HierarchicalUriComponents.EncodeState encodeState,
java.util.function.UnaryOperator<java.lang.String> variableEncoder) |
Modifier and Type | Method and Description |
---|---|
protected void |
copyToUriComponentsBuilder(UriComponentsBuilder builder)
Set all components of the given UriComponentsBuilder.
|
HierarchicalUriComponents |
encode(java.nio.charset.Charset charset)
A variant of
UriComponents.encode() with a charset other than "UTF-8". |
private MultiValueMap<java.lang.String,java.lang.String> |
encodeQueryParams(java.util.function.BiFunction<java.lang.String,HierarchicalUriComponents.Type,java.lang.String> encoder) |
(package private) HierarchicalUriComponents |
encodeTemplate(java.nio.charset.Charset charset)
Identical to
UriComponents.encode() but skipping over URI variable placeholders. |
(package private) static java.lang.String |
encodeUriComponent(java.lang.String source,
java.nio.charset.Charset charset,
HierarchicalUriComponents.Type type)
Encode the given source into an encoded String using the rules specified
by the given component and with the given options.
|
(package private) static java.lang.String |
encodeUriComponent(java.lang.String source,
java.lang.String encoding,
HierarchicalUriComponents.Type type)
Encode the given source into an encoded String using the rules specified
by the given component and with the given options.
|
boolean |
equals(java.lang.Object other) |
protected HierarchicalUriComponents |
expandInternal(UriComponents.UriTemplateVariables uriVariables)
Replace all URI template variables with the values from the given
UriComponents.UriTemplateVariables . |
private MultiValueMap<java.lang.String,java.lang.String> |
expandQueryParams(UriComponents.UriTemplateVariables variables) |
java.lang.String |
getHost()
Return the host.
|
private HierarchicalUriComponents.Type |
getHostType() |
java.lang.String |
getPath()
Return the path.
|
java.util.List<java.lang.String> |
getPathSegments()
Return the list of path segments.
|
int |
getPort()
Return the port.
|
java.lang.String |
getQuery()
Return the query.
|
MultiValueMap<java.lang.String,java.lang.String> |
getQueryParams()
Return the map of query parameters.
|
java.lang.String |
getSchemeSpecificPart()
Return the scheme specific part.
|
java.lang.String |
getUserInfo()
Return the user info.
|
int |
hashCode() |
UriComponents |
normalize()
Normalize the path removing sequences like "path/..".
|
java.net.URI |
toUri()
Create a
URI from this instance as follows: |
java.lang.String |
toUriString()
Concatenate all URI components to return the fully formed URI String.
|
private void |
verify()
Check if any of the URI components contain any illegal characters.
|
private static void |
verifyUriComponent(java.lang.String source,
HierarchicalUriComponents.Type type) |
encode, expand, expand, expand, expandUriComponent, expandUriComponent, getFragment, getScheme, toString
private static final char PATH_DELIMITER
private static final java.lang.String PATH_DELIMITER_STRING
private static final MultiValueMap<java.lang.String,java.lang.String> EMPTY_QUERY_PARAMS
static final HierarchicalUriComponents.PathComponent NULL_PATH_COMPONENT
@Nullable private final java.lang.String userInfo
@Nullable private final java.lang.String host
@Nullable private final java.lang.String port
private final HierarchicalUriComponents.PathComponent path
private final MultiValueMap<java.lang.String,java.lang.String> queryParams
private final HierarchicalUriComponents.EncodeState encodeState
@Nullable private java.util.function.UnaryOperator<java.lang.String> variableEncoder
HierarchicalUriComponents(@Nullable java.lang.String scheme, @Nullable java.lang.String fragment, @Nullable java.lang.String userInfo, @Nullable java.lang.String host, @Nullable java.lang.String port, @Nullable HierarchicalUriComponents.PathComponent path, @Nullable MultiValueMap<java.lang.String,java.lang.String> query, boolean encoded)
null
.scheme
- the schemeuserInfo
- the user infohost
- the hostport
- the portpath
- the pathquery
- the query parametersfragment
- the fragmentencoded
- whether the components are already encodedprivate HierarchicalUriComponents(@Nullable java.lang.String scheme, @Nullable java.lang.String fragment, @Nullable java.lang.String userInfo, @Nullable java.lang.String host, @Nullable java.lang.String port, HierarchicalUriComponents.PathComponent path, MultiValueMap<java.lang.String,java.lang.String> queryParams, HierarchicalUriComponents.EncodeState encodeState, @Nullable java.util.function.UnaryOperator<java.lang.String> variableEncoder)
@Nullable public java.lang.String getSchemeSpecificPart()
UriComponents
null
.getSchemeSpecificPart
in class UriComponents
@Nullable public java.lang.String getUserInfo()
UriComponents
null
.getUserInfo
in class UriComponents
@Nullable public java.lang.String getHost()
UriComponents
null
.getHost
in class UriComponents
public int getPort()
UriComponents
-1
if no port has been set.getPort
in class UriComponents
@NonNull public java.lang.String getPath()
UriComponents
null
.getPath
in class UriComponents
public java.util.List<java.lang.String> getPathSegments()
UriComponents
getPathSegments
in class UriComponents
@Nullable public java.lang.String getQuery()
UriComponents
null
.getQuery
in class UriComponents
public MultiValueMap<java.lang.String,java.lang.String> getQueryParams()
getQueryParams
in class UriComponents
HierarchicalUriComponents encodeTemplate(java.nio.charset.Charset charset)
UriComponents.encode()
but skipping over URI variable placeholders.
Also variableEncoder
is initialized with the given charset for
use later when URI variables are expanded.public HierarchicalUriComponents encode(java.nio.charset.Charset charset)
UriComponents
UriComponents.encode()
with a charset other than "UTF-8".encode
in class UriComponents
charset
- the charset to use for encodingUriComponentsBuilder.encode(Charset)
private MultiValueMap<java.lang.String,java.lang.String> encodeQueryParams(java.util.function.BiFunction<java.lang.String,HierarchicalUriComponents.Type,java.lang.String> encoder)
static java.lang.String encodeUriComponent(java.lang.String source, java.lang.String encoding, HierarchicalUriComponents.Type type)
source
- the source Stringencoding
- the encoding of the source Stringtype
- the URI component for the sourcejava.lang.IllegalArgumentException
- when the given value is not a valid URI componentstatic java.lang.String encodeUriComponent(java.lang.String source, java.nio.charset.Charset charset, HierarchicalUriComponents.Type type)
source
- the source Stringcharset
- the encoding of the source Stringtype
- the URI component for the sourcejava.lang.IllegalArgumentException
- when the given value is not a valid URI componentprivate HierarchicalUriComponents.Type getHostType()
private void verify()
java.lang.IllegalArgumentException
- if any component has illegal charactersprivate static void verifyUriComponent(@Nullable java.lang.String source, HierarchicalUriComponents.Type type)
protected HierarchicalUriComponents expandInternal(UriComponents.UriTemplateVariables uriVariables)
UriComponents
UriComponents.UriTemplateVariables
.expandInternal
in class UriComponents
uriVariables
- the URI template valuesprivate MultiValueMap<java.lang.String,java.lang.String> expandQueryParams(UriComponents.UriTemplateVariables variables)
public UriComponents normalize()
UriComponents
normalize
in class UriComponents
StringUtils.cleanPath(String)
public java.lang.String toUriString()
UriComponents
This method does nothing more than a simple concatenation based on
current values. That means it could produce different results if invoked
before vs after methods that can change individual values such as
encode
, expand
, or normalize
.
toUriString
in class UriComponents
public java.net.URI toUri()
UriComponents
URI
from this instance as follows:
If the current instance is encoded
, form the full
URI String via UriComponents.toUriString()
, and then pass it to the single
argument URI
constructor which preserves percent encoding.
If not yet encoded, pass individual URI component values to the
multi-argument URI
constructor which quotes illegal characters
that cannot appear in their respective URI component.
toUri
in class UriComponents
protected void copyToUriComponentsBuilder(UriComponentsBuilder builder)
UriComponents
copyToUriComponentsBuilder
in class UriComponents
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object