com.google.api.client.util.escape
Class CharEscapers

java.lang.Object
  extended by com.google.api.client.util.escape.CharEscapers

public final class CharEscapers
extends Object

Utility functions for dealing with CharEscapers, and some commonly used CharEscaper instances.

Since:
1.0

Method Summary
static String decodeUri(String uri)
          Percent-decodes a US-ASCII string into a Unicode string.
static String escapeUri(String value)
          Escapes the string value so it can be safely included in URIs.
static String escapeUriPath(String value)
          Escapes the string value so it can be safely included in URI path segments.
static String escapeUriQuery(String value)
          Escapes the string value so it can be safely included in URI query string segments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

escapeUri

public static String escapeUri(String value)
Escapes the string value so it can be safely included in URIs. For details on escaping URIs, see section 2.4 of RFC 2396.

When encoding a String, the following rules apply:

Note: Unlike other escapers, URI escapers produce uppercase hexadecimal sequences. From RFC 3986:
"URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings."

This escaper has identical behavior to (but is potentially much faster than):


decodeUri

public static String decodeUri(String uri)
Percent-decodes a US-ASCII string into a Unicode string. UTF-8 encoding is used to determine what characters are represented by any consecutive sequences of the form "%XX".

This replaces each occurrence of '+' with a space, ' '. So this method should not be used for non application/x-www-form-urlencoded strings such as host and path.

Parameters:
uri - a percent-encoded US-ASCII string
Returns:
a Unicode string

escapeUriPath

public static String escapeUriPath(String value)
Escapes the string value so it can be safely included in URI path segments. For details on escaping URIs, see section 2.4 of RFC 3986.

When encoding a String, the following rules apply:

Note: Unlike other escapers, URI escapers produce uppercase hexadecimal sequences. From RFC 3986:
"URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings."


escapeUriQuery

public static String escapeUriQuery(String value)
Escapes the string value so it can be safely included in URI query string segments. When the query string consists of a sequence of name=value pairs separated by &, the names and values should be individually encoded. If you escape an entire query string in one pass with this escaper, then the "=" and "&" characters used as separators will also be escaped.

This escaper is also suitable for escaping fragment identifiers.

For details on escaping URIs, see section 2.4 of RFC 3986.

When encoding a String, the following rules apply:

Note: Unlike other escapers, URI escapers produce uppercase hexadecimal sequences. From RFC 3986:
"URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings."



Copyright © 2011-2012 Google. All Rights Reserved.