Class UriComponents
- All Implemented Interfaces:
- Serializable
URI, but with more powerful encoding options and support for
 URI template variables.- Since:
- 3.1
- Author:
- Arjen Poutsma, Juergen Hoeller, Rossen Stoyanchev
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceDefines the contract for URI Template variables.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract voidSet all components of the given UriComponentsBuilder.final UriComponentsencode()Invoke this after expanding URI variables to encode the resulting URI component values.abstract UriComponentsA variant ofencode()with a charset other than "UTF-8".final UriComponentsReplace all URI template variables with the values from a given array.final UriComponentsReplace all URI template variables with the values from a given map.final UriComponentsexpand(UriComponents.UriTemplateVariables uriVariables) Replace all URI template variables with the values from the givenUriComponents.UriTemplateVariables.final StringReturn the fragment.abstract StringgetHost()Return the host.abstract StringgetPath()Return the path.Return the list of path segments.abstract intgetPort()Return the port.abstract StringgetQuery()Return the query.abstract MultiValueMap<String,String> Return the map of query parameters.final StringReturn the scheme.abstract StringReturn the scheme specific part.abstract StringReturn the user info.abstract UriComponentsNormalize the path removing sequences like "path/..".final StringtoString()A simple pass-through totoUriString().abstract URItoUri()Create aURIfrom this instance as follows:abstract StringConcatenate all URI components to return the fully formed URI String.
- 
Constructor Details- 
UriComponents
 
- 
- 
Method Details- 
getSchemeReturn the scheme. Can benull.
- 
getFragmentReturn the fragment. Can benull.
- 
getSchemeSpecificPartReturn the scheme specific part. Can benull.
- 
getUserInfoReturn the user info. Can benull.
- 
getHostReturn the host. Can benull.
- 
getPortpublic abstract int getPort()Return the port.-1if no port has been set.
- 
getPathReturn the path. Can benull.
- 
getPathSegmentsReturn the list of path segments. Empty if no path has been set.
- 
getQueryReturn the query. Can benull.
- 
getQueryParamsReturn the map of query parameters. Empty if no query has been set.
- 
encodeInvoke this after expanding URI variables to encode the resulting URI component values.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.- See Also:
 
- 
encodeA variant ofencode()with a charset other than "UTF-8".- Parameters:
- charset- the charset to use for encoding
- See Also:
 
- 
expandReplace all URI template variables with the values from a given map.The given map keys represent variable names; the corresponding values represent variable values. The order of variables is not significant. - Parameters:
- uriVariables- the map of URI variables
- Returns:
- the expanded URI components
 
- 
expandReplace all URI template variables with the values from a given array.The given array represents variable values. The order of variables is significant. - Parameters:
- uriVariableValues- the URI variable values
- Returns:
- the expanded URI components
 
- 
expandReplace all URI template variables with the values from the givenUriComponents.UriTemplateVariables.- Parameters:
- uriVariables- the URI template values
- Returns:
- the expanded URI components
 
- 
normalizeNormalize the path removing sequences like "path/..". Note that normalization is applied to the full path, and not to individual path segments.- See Also:
 
- 
toUriStringConcatenate all URI components to return the fully formed URI String.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()orencode().
- 
toUriCreate aURIfrom this instance as follows:If the current instance is encoded, form the full URI String viatoUriString(), and then pass it to the single argumentURIconstructor which preserves percent encoding.If not yet encoded, pass individual URI component values to the multi-argument URIconstructor which quotes illegal characters that cannot appear in their respective URI component.
- 
toStringA simple pass-through totoUriString().
- 
copyToUriComponentsBuilderSet all components of the given UriComponentsBuilder.- Since:
- 4.2
 
 
-