-
public final class PercentEscaperNote: This class is based on code from guava. It is comprised of code from three classes:
- com.google.common.escape.Escaper
- com.google.common.escape.UnicodeEscaper
- com.google.common.net.PercentEscaper
Escapes some set of Java characters using a UTF-8 based percent encoding scheme. The set of safe characters (those which remain unescaped) can be specified on construction.
This class is primarily used for creating URI escapers in
{@code UrlEscapers}but can be used directly if required. While URI escapers impose specific semantics on which characters are considered 'safe', this class has a minimal set of restrictions.When escaping a String, the following rules apply:
- All specified safe characters remain unchanged.
- If
{@code plusForSpace}was specified, the space character " " is converted into a plus sign{@code "+"}. - All other characters are converted into one or more bytes using UTF-8 encoding and each byte is then represented by the 3-character string "%XX", where "XX" is the two-digit, uppercase, hexadecimal representation of the byte value.
For performance reasons the only currently supported character encoding of this class is UTF-8.
Note: This escaper produces uppercase hexadecimal sequences.
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classPercentEscaper.Escaped
-
Method Summary
Modifier and Type Method Description static PercentEscapercreate()The default PercentEscaper which will *not* replace spaces with plus signs. PercentEscaper.EscapedescapeKey(String s)PercentEscaper.EscapedescapeValue(String s)booleankeyNeedsEncoding(String key)booleanvalNeedsEncoding(String val)PercentEscaper.Escapedescape(String s, Array<boolean> unsafeOctets)Escape the provided String, using percent-style URL Encoding. -
-
Method Detail
-
create
static PercentEscaper create()
The default PercentEscaper which will *not* replace spaces with plus signs.
-
escapeKey
PercentEscaper.Escaped escapeKey(String s)
-
escapeValue
PercentEscaper.Escaped escapeValue(String s)
-
keyNeedsEncoding
boolean keyNeedsEncoding(String key)
-
valNeedsEncoding
boolean valNeedsEncoding(String val)
-
escape
PercentEscaper.Escaped escape(String s, Array<boolean> unsafeOctets)
Escape the provided String, using percent-style URL Encoding.
-
-
-
-