类 UriComponents

java.lang.Object
cn.taketoday.web.util.UriComponents
所有已实现的接口:
Serializable
直接已知子类:
HierarchicalUriComponents, OpaqueUriComponents

public abstract class UriComponents extends Object implements 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.
从以下版本开始:
4.0
作者:
Arjen Poutsma, Juergen Hoeller, Rossen Stoyanchev
另请参阅:
  • 字段详细资料

    • NAMES_PATTERN

      private static final Pattern NAMES_PATTERN
      Captures URI template variable names.
    • scheme

      @Nullable private final String scheme
    • fragment

      @Nullable private final String fragment
  • 构造器详细资料

    • UriComponents

      protected UriComponents(@Nullable String scheme, @Nullable String fragment)
  • 方法详细资料

    • getScheme

      @Nullable public final String getScheme()
      Return the scheme. Can be null.
    • getFragment

      @Nullable public final String getFragment()
      Return the fragment. Can be null.
    • getSchemeSpecificPart

      @Nullable public abstract String getSchemeSpecificPart()
      Return the scheme specific part. Can be null.
    • getUserInfo

      @Nullable public abstract String getUserInfo()
      Return the user info. Can be null.
    • getHost

      @Nullable public abstract String getHost()
      Return the host. Can be null.
    • getPort

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

      @Nullable public abstract String getPath()
      Return the path. Can be null.
    • getPathSegments

      public abstract List<String> getPathSegments()
      Return the list of path segments. Empty if no path has been set.
    • getQuery

      @Nullable public abstract String getQuery()
      Return the query. Can be null.
    • getQueryParams

      public abstract cn.taketoday.util.MultiValueMap<String,String> getQueryParams()
      Return the map of query parameters. Empty if no query has been set.
    • encode

      public final UriComponents encode()
      Invoke 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.

      另请参阅:
    • encode

      public abstract UriComponents encode(Charset charset)
      A variant of encode() with a charset other than "UTF-8".
      参数:
      charset - the charset to use for encoding
      另请参阅:
    • expand

      public final UriComponents expand(Map<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.

      参数:
      uriVariables - the map of URI variables
      返回:
      the expanded URI components
    • expand

      public final UriComponents expand(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.

      参数:
      uriVariableValues - the URI variable values
      返回:
      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.
      参数:
      uriVariables - the URI template values
      返回:
      the expanded URI components
    • expandInternal

      abstract UriComponents expandInternal(UriComponents.UriTemplateVariables uriVariables)
      Replace all URI template variables with the values from the given UriComponents.UriTemplateVariables.
      参数:
      uriVariables - the URI template values
      返回:
      the expanded URI components
    • normalize

      public abstract UriComponents normalize()
      Normalize the path removing sequences like "path/..". Note that normalization is applied to the full path, and not to individual path segments.
      另请参阅:
      • StringUtils.cleanPath(String)
    • toUriString

      public abstract String toUriString()
      Concatenate 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() or encode().

    • toUri

      public abstract URI toUri()
      Create a 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.

    • toString

      public final String toString()
      A simple pass-through to toUriString().
      覆盖:
      toString 在类中 Object
    • copyToUriComponentsBuilder

      protected abstract void copyToUriComponentsBuilder(UriComponentsBuilder builder)
      Set all components of the given UriComponentsBuilder.
    • expandUriComponent

      @Nullable static String expandUriComponent(@Nullable String source, UriComponents.UriTemplateVariables uriVariables)
    • expandUriComponent

      @Nullable static String expandUriComponent(@Nullable String source, UriComponents.UriTemplateVariables uriVariables, @Nullable UnaryOperator<String> encoder)
    • sanitizeSource

      private static String sanitizeSource(String source)
      Remove nested "{}" such as in URI vars with regular expressions.
    • getVariableName

      private static String getVariableName(String match)
    • getVariableValueAsString

      private static String getVariableValueAsString(@Nullable Object variableValue)