| java.lang.Object | |
| ↳ | com.google.gdata.util.common.base.CharEscapers |
Utility functions for dealing with CharEscapers, and some commonly
used CharEscaper instances.
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| ASCII_HTML_ESCAPER | Escapes special characters from a string so it can safely be included in an HTML document in either element content or attribute values. | ||||||||||
| CPP_URI_ESCAPER | |||||||||||
| HEX_DIGITS | |||||||||||
| JAVASCRIPT_ESCAPER | CharEscaper to escape javascript strings. |
||||||||||
| JAVA_CHAR_ESCAPER | Escapes special characters from a string so it can safely be included in a Java char literal or string literal. | ||||||||||
| JAVA_STRING_ESCAPER | Escapes special characters from a string so it can safely be included in a Java string literal. | ||||||||||
| JAVA_STRING_UNICODE_ESCAPER | Escapes each non-ASCII character in with its Unicode escape sequence
\\uxxxx where xxxx is a hex number. |
||||||||||
| NULL_ESCAPER | Performs no escaping. | ||||||||||
| PYTHON_ESCAPER | Escapes special characters in a string so it can safely be included in a Python string literal. | ||||||||||
| URI_ESCAPER | |||||||||||
| URI_ESCAPER_NO_PLUS | |||||||||||
| URI_PATH_ESCAPER | |||||||||||
| URI_QUERY_STRING_ESCAPER | |||||||||||
| XML_CONTENT_ESCAPER | Escapes special characters from a string so it can safely be included in an XML document in element content. | ||||||||||
| XML_ESCAPER | Escapes special characters from a string so it can safely be included in an XML document in either element content or attribute values. | ||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Returns a
CharEscaper instance that escapes special characters in a
string so it can safely be included in an HTML document in either element
content or attribute values. | |||||||||||
Returns a
Escaper instance that escapes Java characters in a manner
compatible with the C++ webutil/url URL class (the kGoogle1Escape
set). | |||||||||||
Returns a composite
CharEscaper instance that tries to escape
characters using a primary CharEscaper first and falls back to a
secondary one if there is no escaping. | |||||||||||
Returns a
CharEscaper instance that escapes special characters in a
string so it can safely be included in an HTML document in either element
content or attribute values. | |||||||||||
Returns a
CharEscaper instance that escapes special characters in a
string so it can safely be included in a Java char or string literal. | |||||||||||
Returns a
CharEscaper instance that escapes special characters in a
string so it can safely be included in a Java string literal. | |||||||||||
Returns a
CharEscaper instance that replaces non-ASCII characters
in a string with their Unicode escape sequences (\\uxxxx where
xxxx is a hex number). | |||||||||||
Returns a
CharEscaper instance that escapes non-ASCII characters in
a string so it can safely be included in a Javascript string literal. | |||||||||||
Returns a
CharEscaper that does no escaping. | |||||||||||
Returns a
CharEscaper instance that escapes special characters from
a string so it can safely be included in a Python string literal. | |||||||||||
Returns a
Escaper instance that escapes Java characters so they can
be safely included in URIs. | |||||||||||
Returns an
Escaper instance that escapes Java chars so they can be
safely included in URIs. | |||||||||||
Returns an
Escaper instance that escapes Java chars so they can be
safely included in URI path segments. | |||||||||||
Returns an
Escaper instance that escapes Java chars so they can be
safely included in URI query string segments. | |||||||||||
Returns a
CharEscaper instance that escapes special characters in a
string so it can safely be included in an XML document in element content. | |||||||||||
Returns a
CharEscaper instance that escapes special characters in a
string so it can safely be included in an XML document in either element
content or attribute values. | |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Escapes special characters from a string so it can safely be included in an HTML document in either element content or attribute values. Does not alter non-ASCII characters or control characters.
CharEscaper to escape javascript strings. Turns all non-ASCII
characters into ASCII javascript escape sequences (e.g., \\uhhhh or \xhh).
Escapes special characters from a string so it can safely be included in a Java char literal or string literal.
Note that non-ASCII characters will be octal or Unicode escaped.
This is the same as JAVA_STRING_ESCAPER, except that it escapes single quotes.
Escapes special characters from a string so it can safely be included in a Java string literal. Does not escape single-quotes, so use JAVA_CHAR_ESCAPE if you are generating char literals, or if you are unsure.
Note that non-ASCII characters will be octal or Unicode escaped.
Escapes each non-ASCII character in with its Unicode escape sequence
\\uxxxx where xxxx is a hex number. Existing escape
sequences won't be affected.
Escapes special characters in a string so it can safely be included in a Python string literal. Does not have any special handling for non-ASCII characters.
Escapes special characters from a string so it can safely be included in an XML document in element content. Note that quotes are not escaped, so this is not safe for use in attribute values. Use XML_ESCAPER for attribute values, or if you are unsure. Also removes non-whitespace control characters, as there is no way to represent them in XML.
Escapes special characters from a string so it can safely be included in an XML document in either element content or attribute values. Also removes null-characters and control characters, as there is no way to represent them in XML.
Returns a CharEscaper instance that escapes special characters in a
string so it can safely be included in an HTML document in either element
content or attribute values.
Note
: does not alter non-ASCII and control characters.Returns a Escaper instance that escapes Java characters in a manner
compatible with the C++ webutil/url URL class (the kGoogle1Escape
set).
When encoding a String, the following rules apply:
Note: Unlike other escapers, URI escapers produce uppercase
hexidecimal sequences. From
RFC 3986:
"URI producers and normalizers should use uppercase hexadecimal digits
for all percent-encodings."
Note: This escaper is a special case and is not
compliant with
RFC 2396. Specifically it will not escape "/", ":" and ",". This is
only provided for certain limited use cases and you should favor using
uriEscaper() whenever possible.
Returns a composite CharEscaper instance that tries to escape
characters using a primary CharEscaper first and falls back to a
secondary one if there is no escaping.
The returned escaper will attempt to escape each character using the primary escaper, and if the primary escaper has no escaping for that character, it will use the secondary escaper. If the secondary escaper has no escaping for a character either, the original character will be used. If the primary escaper has an escape for a character, the secondary escaper will not be used at all for that character; the escaped output of the primary is not run through the secondary. For a case where you would like to first escape with one escaper, and then with another, it is recommended that you call each escaper in order.
| primary | The primary CharEscaper to use |
|---|---|
| secondary | The secondary CharEscaper to use if the first one
has no escaping rule for a character |
| NullPointerException | if any of the arguments is null |
|---|
Returns a CharEscaper instance that escapes special characters in a
string so it can safely be included in an HTML document in either element
content or attribute values.
Note
: alters non-ASCII and control characters. The entity list was taken from: hereReturns a CharEscaper instance that escapes special characters in a
string so it can safely be included in a Java char or string literal. The
behavior of this escaper is the same as that of the
javaStringEscaper(), except it also escapes single quotes.
Returns a CharEscaper instance that escapes special characters in a
string so it can safely be included in a Java string literal.
Note
: does not escape single quotes, so use the escaper returned byjavaCharEscaper() if you are generating char
literals or if you are unsure.
Returns a CharEscaper instance that replaces non-ASCII characters
in a string with their Unicode escape sequences (\\uxxxx where
xxxx is a hex number). Existing escape sequences won't be affected.
Returns a CharEscaper instance that escapes non-ASCII characters in
a string so it can safely be included in a Javascript string literal.
Non-ASCII characters are replaced with their ASCII javascript escape
sequences (e.g., \\uhhhh or \xhh).
Returns a CharEscaper instance that escapes special characters from
a string so it can safely be included in a Python string literal. Does not
have any special handling for non-ASCII characters.
Returns a Escaper instance that escapes Java characters so they 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:
plusForSpace was specified, the space character " " is
converted into a plus sign "+". Otherwise it is converted into "%20".
Note: Unlike other escapers, URI escapers produce uppercase
hexidecimal sequences. From
RFC 3986:
"URI producers and normalizers should use uppercase hexadecimal digits
for all percent-encodings."
| plusForSpace | If true space is escaped to + otherwise
it is escaped to %20. Although common, the escaping of
spaces as plus signs has a very ambiguous status in the relevant
specifications. You should prefer %20 unless you are doing
exact character-by-character comparisons of URLs and backwards
compatibility requires you to use plus signs. |
|---|
Returns an Escaper instance that escapes Java chars so they 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
hexidecimal 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):
encode(String)
encode(String, String)
with the encoding name "UTF-8"
encode(String)
encode(String, java.nio.charset.Charset)
with the UTF_8 Charset
encode(String, String)
with the encoding name "UTF-8"
This method is equivalent to uriEscaper(true).
Returns an Escaper instance that escapes Java chars so they 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
hexidecimal sequences. From
RFC 3986:
"URI producers and normalizers should use uppercase hexadecimal digits
for all percent-encodings."
Returns an Escaper instance that escapes Java chars so they 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
hexidecimal sequences. From
RFC 3986:
"URI producers and normalizers should use uppercase hexadecimal digits
for all percent-encodings."
Returns a CharEscaper instance that escapes special characters in a
string so it can safely be included in an XML document in element content.
Note
: double and single quotes are not escaped, so it is not safe to use this escaper to escape attribute values. Use thexmlEscaper() escaper to escape attribute values or if you are
unsure. Also silently removes non-whitespace control characters, as there
is no way to represent them in XML.
Returns a CharEscaper instance that escapes special characters in a
string so it can safely be included in an XML document in either element
content or attribute values.
Note
: silently removes null-characters and control characters, as there is no way to represent them in XML.