Class UriComponent

java.lang.Object
org.exoplatform.services.rest.impl.uri.UriComponent

public final class UriComponent extends Object
Version:
$Id: $
Author:
Andrey Parfonov
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Fragment.
    static final int
    Host URI component.
    static final int
    Path URI components, consists of path-segments.
    static final int
    Path segment URI sub-component, it can't contains '/'.
    static final int
    Port URI component.
    static final int
    Query string.
    static final int
    Scheme URI component.
    static final int
    Scheme-specific part.
    static final int
    UserInfo URI component.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Check does two next characters after '%' represent percent-encoded character.
    static String
    decode(String str, int component)
    Decode percent encoded URI string.
    static String
    encode(String str, int component, boolean containsUriParams)
    Encode given URI string.
    static List<javax.ws.rs.core.PathSegment>
    parsePathSegments(String path, boolean decode)
    Parse path segments.
    static javax.ws.rs.core.MultivaluedMap<String,String>
    parseQueryString(String rawQuery, boolean decode)
    Parse encoded query string.
    static String
    recognizeEncode(String str, int component, boolean containsUriParams)
    Check string and if it does not contains any '%' characters validate it for contains only valid characters.
    static String
    validate(String str, int component, boolean containsUriParams)
    Validate content of percent-encoding string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • encode

      public static String encode(String str, int component, boolean containsUriParams)
      Encode given URI string.
      Parameters:
      str - the URI string
      component - component of URI, scheme, host, port, etc
      containsUriParams - true if the source string contains URI parameters
      Returns:
      encoded string
    • validate

      public static String validate(String str, int component, boolean containsUriParams)
      Validate content of percent-encoding string.
      Parameters:
      str - the string which must be validate
      component - component of URI, scheme, host, port, etc
      containsUriParams - true if the source string contains URI parameters
      Returns:
      the source string
    • recognizeEncode

      public static String recognizeEncode(String str, int component, boolean containsUriParams)
      Check string and if it does not contains any '%' characters validate it for contains only valid characters. If it contains '%' then check does following two character is valid hex numbers, if not then encode '%' to '%25' otherwise keep characters without change, there is no double encoding.
      Parameters:
      str - source string
      component - part of URI, e. g. schema, host, path
      containsUriParams - does string may contains URI templates
      Returns:
      valid string
    • decode

      public static String decode(String str, int component)
      Decode percent encoded URI string.
      Parameters:
      str - the source percent encoded string
      component - component of URI, scheme, host, port, etc. NOTE type of component is not used currently but will be used for decoding IPv6 addresses
      Returns:
      decoded string
    • checkHexCharacters

      public static boolean checkHexCharacters(String s, int p)
      Check does two next characters after '%' represent percent-encoded character.
      Parameters:
      s - source string
      p - position of character in string
      Returns:
      true is two characters after '%' represent percent-encoded character false otherwise
    • parsePathSegments

      public static List<javax.ws.rs.core.PathSegment> parsePathSegments(String path, boolean decode)
      Parse path segments.
      Parameters:
      path - the relative path
      decode - true if character must be decoded false otherwise
      Returns:
      List of PathSegment
    • parseQueryString

      public static javax.ws.rs.core.MultivaluedMap<String,String> parseQueryString(String rawQuery, boolean decode)
      Parse encoded query string.
      Parameters:
      rawQuery - source query string
      decode - if true then query parameters will be decoded
      Returns:
      MultivaluedMap with query parameters