Spring for Android

org.springframework.web.util
Class UriComponents

java.lang.Object
  extended by org.springframework.web.util.UriComponents
All Implemented Interfaces:
java.io.Serializable

public abstract class UriComponents
extends java.lang.Object
implements java.io.Serializable

Represents an immutable collection of URI components, mapping component type to String values. Contains convenience getters for all components. Effectively similar to URI, but with more powerful encoding options and support for URI template variables.

Since:
1.0
Author:
Arjen Poutsma
See Also:
UriComponentsBuilder, Serialized Form

Nested Class Summary
static interface UriComponents.UriTemplateVariables
          Defines the contract for URI Template variables
 
Constructor Summary
protected UriComponents(java.lang.String scheme, java.lang.String fragment)
           
 
Method Summary
 UriComponents encode()
          Encode all URI components using their specific encoding rules, and returns the result as a new UriComponents instance.
abstract  UriComponents encode(java.lang.String encoding)
          Encode all URI components using their specific encoding rules, and returns the result as a new UriComponents instance.
 UriComponents expand(java.util.Map<java.lang.String,?> uriVariables)
          Replace all URI template variables with the values from a given map.
 UriComponents expand(java.lang.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.
 java.lang.String getFragment()
          Returns the fragment.
abstract  java.lang.String getHost()
          Returns the host.
abstract  java.lang.String getPath()
          Returns the path.
abstract  java.util.List<java.lang.String> getPathSegments()
          Returns the list of path segments.
abstract  int getPort()
          Returns the port.
abstract  java.lang.String getQuery()
          Returns the query.
abstract  MultiValueMap<java.lang.String,java.lang.String> getQueryParams()
          Returns the map of query parameters.
 java.lang.String getScheme()
          Returns the scheme.
abstract  java.lang.String getSchemeSpecificPart()
          Returns the scheme specific part.
abstract  java.lang.String getUserInfo()
          Returns the user info.
abstract  UriComponents normalize()
          Normalize the path removing sequences like "path/..".
 java.lang.String toString()
           
abstract  java.net.URI toUri()
          Return a URI from this UriComponents instance.
abstract  java.lang.String toUriString()
          Return a URI string from this UriComponents instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UriComponents

protected UriComponents(java.lang.String scheme,
                        java.lang.String fragment)
Method Detail

getScheme

public final java.lang.String getScheme()
Returns the scheme. Can be null.


getSchemeSpecificPart

public abstract java.lang.String getSchemeSpecificPart()
Returns the scheme specific part. Can be null.


getUserInfo

public abstract java.lang.String getUserInfo()
Returns the user info. Can be null.


getHost

public abstract java.lang.String getHost()
Returns the host. Can be null.


getPort

public abstract int getPort()
Returns the port. Returns -1 if no port has been set.


getPath

public abstract java.lang.String getPath()
Returns the path. Can be null.


getPathSegments

public abstract java.util.List<java.lang.String> getPathSegments()
Returns the list of path segments. Empty if no path has been set.


getQuery

public abstract java.lang.String getQuery()
Returns the query. Can be null.


getQueryParams

public abstract MultiValueMap<java.lang.String,java.lang.String> getQueryParams()
Returns the map of query parameters. Empty if no query has been set.


getFragment

public final java.lang.String getFragment()
Returns the fragment. Can be null.


encode

public final UriComponents encode()
Encode all URI components using their specific encoding rules, and returns the result as a new UriComponents instance. This method uses UTF-8 to encode.

Returns:
the encoded URI components

encode

public abstract UriComponents encode(java.lang.String encoding)
                              throws java.io.UnsupportedEncodingException
Encode all URI components using their specific encoding rules, and returns the result as a new UriComponents instance.

Parameters:
encoding - the encoding of the values contained in this map
Returns:
the encoded URI components
Throws:
java.io.UnsupportedEncodingException - if the given encoding is not supported

expand

public final UriComponents expand(java.util.Map<java.lang.String,?> uriVariables)
Replace 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

expand

public final UriComponents expand(java.lang.Object... uriVariableValues)
Replace 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

expand

public final UriComponents expand(UriComponents.UriTemplateVariables uriVariables)
Replace all URI template variables with the values from the given UriComponents.UriTemplateVariables.

Parameters:
uriVariables - the URI template values
Returns:
the expanded URI components

normalize

public abstract UriComponents normalize()
Normalize the path removing sequences like "path/..".

See Also:
StringUtils.cleanPath(String)

toUriString

public abstract java.lang.String toUriString()
Return a URI string from this UriComponents instance.


toUri

public abstract java.net.URI toUri()
Return a URI from this UriComponents instance.


toString

public final java.lang.String toString()
Overrides:
toString in class java.lang.Object

Spring for Android