org.apache.clerezza.triaxrs.util.uri
Class UriEncoder

java.lang.Object
  extended by org.apache.clerezza.triaxrs.util.uri.UriEncoder

public final class UriEncoder
extends Object

URI Encoding and Decoding


Field Summary
static boolean[] fragmentChars
           
static boolean[] matrixChars
           
static boolean[] pathChars
           
static boolean[] queryChars
           
static boolean[] queryParamChars
           
static boolean[] segmentChars
           
static boolean[] unreservedChars
          Unreserved characters according to RFC 3986.
static boolean[] uriChars
           
static boolean[] uriTemplateChars
           
static boolean[] userInfoChars
           
 
Method Summary
static javax.ws.rs.core.MultivaluedMap<String,String> decodeMultivaluedMap(javax.ws.rs.core.MultivaluedMap<String,String> map, boolean decodeKeys)
           
static javax.ws.rs.core.MultivaluedMap<String,String> decodeMultivaluedMapValues(javax.ws.rs.core.MultivaluedMap<String,String> map)
           
static String decodeQuery(String string)
          Decode US-ASCII uri according to RFC 3986 and replaces all occurrences of the '+' sign with spaces.
static String decodeString(String string)
          Decode US-ASCII uri according to RFC 3986.
static String encodeFragment(String fragment, boolean relax)
          Encode a fragment string according to RFC 3986.
static String encodeMatrix(String matrix, boolean relax)
          Encode a matrix parameter (name or value) according to RFC 3986.
static String encodePath(String path, boolean relax)
          Encode a complete path string according to RFC 3986.
static String encodePathSegment(String segment, boolean relax)
          Encode a path segment (without matrix parameters) according to RFC 3986.
static String encodeQuery(String query, boolean relax)
          Encode a complete query string according to RFC 3986.
static String encodeQueryParam(String queryParam, boolean relax)
          Encode a query parameter (name or value) according to RFC 3986.
static String encodeString(String string)
          Encode all characters other than unreserved according to RFC 3986.
static String encodeUri(String uri, boolean relax)
          Encode a uri according to RFC 3986, escaping all reserved characters.
static String encodeUriTemplate(String uriTemplate, boolean relax)
          Encode a uri template according to RFC 3986, escaping all reserved characters, except for '{' and '}'.
static String encodeUserInfo(String userInfo, boolean relax)
          Encode user info according to RFC 3986.
static String normalize(String string)
          Decodes only the unreserved chars, according to RFC 3986 section 6.2.2.2
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

unreservedChars

public static final boolean[] unreservedChars
Unreserved characters according to RFC 3986. Each character below ASCII 128 has single array item with true if it is unreserved and false if it is reserved.


userInfoChars

public static final boolean[] userInfoChars

segmentChars

public static final boolean[] segmentChars

matrixChars

public static final boolean[] matrixChars

pathChars

public static final boolean[] pathChars

queryChars

public static final boolean[] queryChars

queryParamChars

public static final boolean[] queryParamChars

fragmentChars

public static final boolean[] fragmentChars

uriChars

public static final boolean[] uriChars

uriTemplateChars

public static final boolean[] uriTemplateChars
Method Detail

encodeString

public static String encodeString(String string)
Encode all characters other than unreserved according to RFC 3986.

Parameters:
string - string to encode
Returns:
encoded US-ASCII string

encodeUserInfo

public static String encodeUserInfo(String userInfo,
                                    boolean relax)
Encode user info according to RFC 3986.

Parameters:
userInfo - the user info to encode
relax - if true, then any sequence of chars in the input string that have the form '%XX', where XX are two HEX digits, will not be encoded
Returns:
encoded user info string

encodePathSegment

public static String encodePathSegment(String segment,
                                       boolean relax)
Encode a path segment (without matrix parameters) according to RFC 3986.

Parameters:
segment - the segment (without matrix parameters) to encode
relax - if true, then any sequence of chars in the input string that have the form '%XX', where XX are two HEX digits, will not be encoded
Returns:
encoded segment string

encodeMatrix

public static String encodeMatrix(String matrix,
                                  boolean relax)
Encode a matrix parameter (name or value) according to RFC 3986.

Parameters:
matrix - the matrix parameter (name or value) to encode
relax - if true, then any sequence of chars in the input string that have the form '%XX', where XX are two HEX digits, will not be encoded
Returns:
encoded matrix string

encodePath

public static String encodePath(String path,
                                boolean relax)
Encode a complete path string according to RFC 3986.

Parameters:
path - the path string to encode
relax - if true, then any sequence of chars in the input string that have the form '%XX', where XX are two HEX digits, will not be encoded
Returns:
encoded path string

encodeQueryParam

public static String encodeQueryParam(String queryParam,
                                      boolean relax)
Encode a query parameter (name or value) according to RFC 3986.

Parameters:
queryParam - the query parameter string to encode
relax - if true, then any sequence of chars in the input string that have the form '%XX', where XX are two HEX digits, will not be encoded
Returns:
encoded query parameter string

encodeQuery

public static String encodeQuery(String query,
                                 boolean relax)
Encode a complete query string according to RFC 3986.

Parameters:
query - the query string to encode
relax - if true, then any sequence of chars in the input string that have the form '%XX', where XX are two HEX digits, will not be encoded
Returns:
encoded query string

encodeFragment

public static String encodeFragment(String fragment,
                                    boolean relax)
Encode a fragment string according to RFC 3986.

Parameters:
fragment - the fragment string to encode
relax - if true, then any sequence of chars in the input string that have the form '%XX', where XX are two HEX digits, will not be encoded
Returns:
encoded fragment string

encodeUri

public static String encodeUri(String uri,
                               boolean relax)
Encode a uri according to RFC 3986, escaping all reserved characters.

Parameters:
uri - string to encode
relax - if true, then any sequence of chars in the input of the form '%XX', where XX are two HEX digits, will not be encoded.
Returns:
encoded US-ASCII string

encodeUriTemplate

public static String encodeUriTemplate(String uriTemplate,
                                       boolean relax)
Encode a uri template according to RFC 3986, escaping all reserved characters, except for '{' and '}'.

Parameters:
uriTemplate - template to encode
relax - if true, then any sequence of chars in the input of the form '%XX', where XX are two HEX digits, will not be encoded.
Returns:
encoded US-ASCII string

decodeQuery

public static String decodeQuery(String string)
Decode US-ASCII uri according to RFC 3986 and replaces all occurrences of the '+' sign with spaces.

Parameters:
string - query string to decode
Returns:
decoded query

decodeString

public static String decodeString(String string)
Decode US-ASCII uri according to RFC 3986.

Parameters:
string - US-ASCII uri to decode
Returns:
decoded uri

normalize

public static String normalize(String string)
Decodes only the unreserved chars, according to RFC 3986 section 6.2.2.2

Parameters:
string - US-ASCII uri to decode
Returns:
decoded uri

decodeMultivaluedMapValues

public static javax.ws.rs.core.MultivaluedMap<String,String> decodeMultivaluedMapValues(javax.ws.rs.core.MultivaluedMap<String,String> map)

decodeMultivaluedMap

public static javax.ws.rs.core.MultivaluedMap<String,String> decodeMultivaluedMap(javax.ws.rs.core.MultivaluedMap<String,String> map,
                                                                                  boolean decodeKeys)


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.