Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.web.util
Class UriComponents

    java.lang.Object
      org.springframework.web.util.UriComponents

    public final class UriComponents

extends java.lang.Object

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:
  3.1
Author:
  Arjen Poutsma
See Also:
  `UriComponentsBuilder`

Method Summary
`UriComponents` | `encode()` Encodes all URI components using their specific encoding rules, and returns the result as a new `UriComponents` instance.
`UriComponents` | `encode(java.lang.String encoding)` Encodes all URI components using their specific encoding rules, and returns the result as a new `UriComponents` instance.
`boolean` | `equals(java.lang.Object o)`
`UriComponents` | `expand(java.util.Map<java.lang.String,?> uriVariables)` Replaces all URI template variables with the values from a given map.
`UriComponents` | `expand(java.lang.Object... uriVariableValues)` Replaces all URI template variables with the values from a given array.
`java.lang.String` | `getFragment()` Returns the fragment.
`java.lang.String` | `getHost()` Returns the host.
`java.lang.String` | `getPath()` Returns the path.
`java.util.List<java.lang.String>` | `getPathSegments()` Returns the list of path segments.
`int` | `getPort()` Returns the port.
`java.lang.String` | `getQuery()` Returns the query.
`MultiValueMap<java.lang.String,java.lang.String>` | `getQueryParams()` Returns the map of query parameters.
`java.lang.String` | `getScheme()` Returns the scheme.
`java.lang.String` | `getUserInfo()` Returns the user info.
`int` | `hashCode()`
`UriComponents` | `normalize()` Normalize the path removing sequences like "path/..".
`java.lang.String` | `toString()`
`java.net.URI` | `toUri()` Returns a `URI` from this `UriComponents` instance.
`java.lang.String` | `toUriString()` Returns a URI string from this `UriComponents` instance.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Method Detail

### getScheme

    public java.lang.String getScheme()

  Returns the scheme.

  Returns:
    the scheme. Can be `null`.

### getUserInfo

    public java.lang.String getUserInfo()

  Returns the user info.

  Returns:
    the user info. Can be `null`.

### getHost

    public java.lang.String getHost()

  Returns the host.

  Returns:
    the host. Can be `null`.

### getPort

    public int getPort()

  Returns the port. Returns `-1` if no port has been set.

  Returns:
    the port

### getPath

    public java.lang.String getPath()

  Returns the path.

  Returns:
    the path. Can be `null`.

### getPathSegments

    public java.util.List<java.lang.String> getPathSegments()

  Returns the list of path segments.

  Returns:
    the path segments. Empty if no path has been set.

### getQuery

    public java.lang.String getQuery()

  Returns the query.

  Returns:
    the query. Can be `null`.

### getQueryParams

    public MultiValueMap<java.lang.String,java.lang.String> getQueryParams()

  Returns the map of query parameters.

  Returns:
    the query parameters. Empty if no query has been set.

### getFragment

    public java.lang.String getFragment()

  Returns the fragment.

  Returns:
    the fragment. Can be `null`.

### encode

    public UriComponents encode()

  Encodes 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 UriComponents encode(java.lang.String encoding)
                         throws java.io.UnsupportedEncodingException

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

  Replaces all URI template variables with the values from a given map. The map keys represent variable names; the values variable values. The order of variables is not significant.

  Parameters:
    `uriVariables` - the map of URI variables
  Returns:
    the expanded uri components

### expand

    public UriComponents expand(java.lang.Object... uriVariableValues)

  Replaces all URI template variables with the values from a given array. The array represent variable values. The order of variables is significant.

  Parameters:
    `uriVariableValues` - URI variable values
  Returns:
    the expanded uri components

### normalize

    public UriComponents normalize()

  Normalize the path removing sequences like "path/..".

  See Also:
    `StringUtils.cleanPath(String)`

### toUriString

    public java.lang.String toUriString()

  Returns a URI string from this `UriComponents` instance.

  Returns:
    the URI string

### toUri

    public java.net.URI toUri()

  Returns a `URI` from this `UriComponents` instance.

  Returns:
    the URI

### equals

    public boolean equals(java.lang.Object o)

  Overrides:
    `equals` in class `java.lang.Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `java.lang.Object`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD