Class URLUtils

java.lang.Object
org.jboss.resteasy.util.URLUtils

public class URLUtils extends Object
URL-encoding utility for each URL part according to the RFC specs
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BitSet
    alpha = lowalpha | upalpha
    static final BitSet
    alphanum = alpha | digit
    static final BitSet
    digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
    static final BitSet
    fragment = pchar / "/" / "?"
    static final BitSet
    gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
    static final BitSet
    lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
    static final BitSet
    path_param_name = pchar ";" | "="
    static final BitSet
    path_param_value = pchar ";"
    static final BitSet
    path_segment = pchar ";"
    static final BitSet
    pchar = unreserved | escaped | sub-delims | ":" | "@"
    static final BitSet
    query = pchar / "/" / "?"
    static final BitSet
    reserved = gen-delims | sub-delims
    static final BitSet
    sub-delims = "!" / "$" / "invalid input: '&'" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
    static final BitSet
    unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
    static final BitSet
    upalpha = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    encodePart(String part, String charset, BitSet allowed)
    Encodes a string to be a valid URI part, with the given characters allowed.
    static String
    encodePathParamName(String pathParamName)
    Encodes a string to be a valid path parameter name, which means it can contain PCHAR* without "=" or ";".
    static String
    encodePathParamValue(String pathParamValue)
    Encodes a string to be a valid path parameter value, which means it can contain PCHAR* without ";".
    static String
    Encodes a string to be a valid path segment, which means it can contain PCHAR* only (do not put path parameters or they will be escaped.
    static String
    encodeQueryNameOrValue(String queryNameOrValue)
    Encodes a string to be a valid query, which means it can contain PCHAR* | "?" | "/" without "=" | "invalid input: '&'" | "+".
    static String
    encodeQueryNameOrValueNoParen(String queryNameOrValueNoParen)
    Encodes a string to be a valid query with no parenthesis, which means it can contain PCHAR* | "?" | "/" without "=" | "invalid input: '&'" | "+" | "(" | ")".

    Methods inherited from class java.lang.Object

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

    • GEN_DELIMS

      public static final BitSet GEN_DELIMS
      gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
    • SUB_DELIMS

      public static final BitSet SUB_DELIMS
      sub-delims = "!" / "$" / "invalid input: '&'" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
    • RESERVED

      public static final BitSet RESERVED
      reserved = gen-delims | sub-delims
    • LOW_ALPHA

      public static final BitSet LOW_ALPHA
      lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
    • UP_ALPHA

      public static final BitSet UP_ALPHA
      upalpha = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
    • ALPHA

      public static final BitSet ALPHA
      alpha = lowalpha | upalpha
    • DIGIT

      public static final BitSet DIGIT
      digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
    • ALPHANUM

      public static final BitSet ALPHANUM
      alphanum = alpha | digit
    • UNRESERVED

      public static final BitSet UNRESERVED
      unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
    • PCHAR

      public static final BitSet PCHAR
      pchar = unreserved | escaped | sub-delims | ":" | "@"

      Note: we don't allow escaped here since we will escape it ourselves, so we don't want to allow them in the unescaped sequences

    • PATH_SEGMENT

      public static final BitSet PATH_SEGMENT
      path_segment = pchar ";"
    • PATH_PARAM_NAME

      public static final BitSet PATH_PARAM_NAME
      path_param_name = pchar ";" | "="
    • PATH_PARAM_VALUE

      public static final BitSet PATH_PARAM_VALUE
      path_param_value = pchar ";"
    • QUERY

      public static final BitSet QUERY
      query = pchar / "/" / "?"
    • FRAGMENT

      public static final BitSet FRAGMENT
      fragment = pchar / "/" / "?"
  • Constructor Details

    • URLUtils

      public URLUtils()
  • Method Details

    • encodePathParamName

      public static String encodePathParamName(String pathParamName)
      Encodes a string to be a valid path parameter name, which means it can contain PCHAR* without "=" or ";". Uses UTF-8.
    • encodePathParamValue

      public static String encodePathParamValue(String pathParamValue)
      Encodes a string to be a valid path parameter value, which means it can contain PCHAR* without ";". Uses UTF-8.
    • encodeQueryNameOrValue

      public static String encodeQueryNameOrValue(String queryNameOrValue)
      Encodes a string to be a valid query, which means it can contain PCHAR* | "?" | "/" without "=" | "invalid input: '&'" | "+". Uses UTF-8.
    • encodeQueryNameOrValueNoParen

      public static String encodeQueryNameOrValueNoParen(String queryNameOrValueNoParen)
      Encodes a string to be a valid query with no parenthesis, which means it can contain PCHAR* | "?" | "/" without "=" | "invalid input: '&'" | "+" | "(" | ")". It strips parenthesis. Uses UTF-8.
    • encodePathSegment

      public static String encodePathSegment(String pathSegment)
      Encodes a string to be a valid path segment, which means it can contain PCHAR* only (do not put path parameters or they will be escaped. Uses UTF-8.
    • encodePart

      public static String encodePart(String part, String charset, BitSet allowed) throws UnsupportedEncodingException
      Encodes a string to be a valid URI part, with the given characters allowed. The rest will be encoded.
      Throws:
      UnsupportedEncodingException