org.tuckey.web.filters.urlrewrite.utils
Class URLEncoder

java.lang.Object
  extended by org.tuckey.web.filters.urlrewrite.utils.URLEncoder

public class URLEncoder
extends Object

URL-encoding utility for each URL part according to the RFC specs see the rfc at http://www.ietf.org/rfc/rfc2396.txt

Author:
stephane

Field Summary
static BitSet ALPHA
          alpha = lowalpha | upalpha
static BitSet ALPHANUM
          alphanum = alpha | digit
static BitSet DIGIT
          digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
static 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"
static BitSet MARK
          mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
static BitSet PCHAR
          pchar = unreserved | escaped | ":" | "@" | "&" | "=" | "+" | "$" | ","

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

static BitSet UNRESERVED
          unreserved = alphanum | mark
static 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"
 
Constructor Summary
URLEncoder()
           
 
Method Summary
static String encodePathParam(String pathParam, String charset)
          Encodes a string to be a valid path parameter URL, which means it can contain PCHAR* only (do not put the leading ";" or it will be escaped.
static String encodePathSegment(String pathSegment, String charset)
          Encodes a string to be a valid path segment URL, which means it can contain PCHAR* only (do not put path parameters or they will be escaped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MARK

public static final BitSet MARK
mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"


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 = alphanum | mark


PCHAR

public static final BitSet PCHAR
pchar = unreserved | escaped | ":" | "@" | "&" | "=" | "+" | "$" | ","

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

Constructor Detail

URLEncoder

public URLEncoder()
Method Detail

encodePathParam

public static String encodePathParam(String pathParam,
                                     String charset)
                              throws UnsupportedEncodingException
Encodes a string to be a valid path parameter URL, which means it can contain PCHAR* only (do not put the leading ";" or it will be escaped.

Throws:
UnsupportedEncodingException

encodePathSegment

public static String encodePathSegment(String pathSegment,
                                       String charset)
                                throws UnsupportedEncodingException
Encodes a string to be a valid path segment URL, which means it can contain PCHAR* only (do not put path parameters or they will be escaped.

Throws:
UnsupportedEncodingException


Copyright © 2001-2012 Paul Tuckey. All Rights Reserved.