public abstract class UriComponents extends Object implements Serializable
URI
, but with more powerful encoding options and support for
URI template variables.UriComponentsBuilder
,
Serialized FormModifier and Type | Class and Description |
---|---|
static interface |
UriComponents.UriTemplateVariables
Defines the contract for URI Template variables.
|
Modifier | Constructor and Description |
---|---|
protected |
UriComponents(String scheme,
String fragment) |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
copyToUriComponentsBuilder(UriComponentsBuilder builder)
Set all components of the given UriComponentsBuilder.
|
UriComponents |
encode()
Invoke this after expanding URI variables to encode the
resulting URI component values.
|
abstract UriComponents |
encode(Charset charset)
A variant of
encode() with a charset other than "UTF-8". |
UriComponents |
expand(Map<String,?> uriVariables)
Replace all URI template variables with the values from a given map.
|
UriComponents |
expand(Object... uriVariableValues)
Replace all URI template variables with the values from a given array.
|
UriComponents |
expand(UriComponents.UriTemplateVariables uriVariables)
Replace all URI template variables with the values from the given
UriComponents.UriTemplateVariables . |
String |
getFragment()
Return the fragment.
|
abstract String |
getHost()
Return the host.
|
abstract String |
getPath()
Return the path.
|
abstract List<String> |
getPathSegments()
Return the list of path segments.
|
abstract int |
getPort()
Return the port.
|
abstract String |
getQuery()
Return the query.
|
abstract MultiValueMap<String,String> |
getQueryParams()
Return the map of query parameters.
|
String |
getScheme()
Return the scheme.
|
abstract String |
getSchemeSpecificPart()
Return the scheme specific part.
|
abstract String |
getUserInfo()
Return the user info.
|
abstract UriComponents |
normalize()
Normalize the path removing sequences like "path/..".
|
String |
toString()
A simple pass-through to
toUriString() . |
abstract URI |
toUri()
Create a
URI from this instance as follows: |
abstract String |
toUriString()
Concatenate all URI components to return the fully formed URI String.
|
@Nullable public abstract String getSchemeSpecificPart()
null
.public abstract int getPort()
-1
if no port has been set.public abstract List<String> getPathSegments()
public abstract MultiValueMap<String,String> getQueryParams()
public final UriComponents encode()
In comparison to UriComponentsBuilder.encode()
, this method
only replaces non-ASCII and illegal (within a given URI
component type) characters, but not characters with reserved meaning.
For most cases, UriComponentsBuilder.encode()
is more likely
to give the expected result.
UriComponentsBuilder.encode()
public abstract UriComponents encode(Charset charset)
encode()
with a charset other than "UTF-8".charset
- the charset to use for encodingUriComponentsBuilder.encode(Charset)
public final UriComponents expand(Map<String,?> uriVariables)
The given map keys represent variable names; the corresponding values represent variable values. The order of variables is not significant.
uriVariables
- the map of URI variablespublic final UriComponents expand(Object... uriVariableValues)
The given array represents variable values. The order of variables is significant.
uriVariableValues
- the URI variable valuespublic final UriComponents expand(UriComponents.UriTemplateVariables uriVariables)
UriComponents.UriTemplateVariables
.uriVariables
- the URI template valuespublic abstract UriComponents normalize()
StringUtils.cleanPath(String)
public abstract String toUriString()
This method amounts to simple String concatenation of the current
URI component values and as such the result may contain illegal URI
characters, for example if URI variables have not been expanded or if
encoding has not been applied via UriComponentsBuilder.encode()
or encode()
.
public abstract URI toUri()
URI
from this instance as follows:
If the current instance is encoded
, form the full
URI String via 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.
public final String toString()
toUriString()
.protected abstract void copyToUriComponentsBuilder(UriComponentsBuilder builder)