Package com.google.common.escape
Class CharEscaperBuilder.CharArrayDecorator
java.lang.Object
com.google.common.escape.Escaper
com.google.common.escape.CharEscaper
com.google.common.escape.CharEscaperBuilder.CharArrayDecorator
- Enclosing class:
CharEscaperBuilder
Simple decorator that turns an array of replacement char[]s into a CharEscaper, this results in
a very fast escape method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
private final char[][]
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.google.common.escape.CharEscaper
escapeSlow
Methods inherited from class com.google.common.escape.Escaper
asFunction
-
Field Details
-
replacements
private final char[][] replacements -
replaceLength
private final int replaceLength
-
-
Constructor Details
-
CharArrayDecorator
CharArrayDecorator(char[][] replacements)
-
-
Method Details
-
escape
Description copied from class:CharEscaper
Returns the escaped form of a given literal string.- Overrides:
escape
in classCharEscaper
- Parameters:
s
- the literal string to be escaped- Returns:
- the escaped form of
string
-
escape
@CheckForNull protected char[] escape(char c) Description copied from class:CharEscaper
Returns the escaped form of the given character, ornull
if this character does not need to be escaped. If an empty array is returned, this effectively strips the input character from the resulting text.If the character does not need to be escaped, this method should return
null
, rather than a one-character array containing the character itself. This enables the escaping algorithm to perform more efficiently.An escaper is expected to be able to deal with any
char
value, so this method should not throw any exceptions.- Specified by:
escape
in classCharEscaper
- Parameters:
c
- the character to escape if necessary- Returns:
- the replacement characters, or
null
if no escaping was needed
-