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
private static class CharEscaperBuilder.CharArrayDecorator extends CharEscaper
Simple decorator that turns an array of replacement char[]s into a CharEscaper, this results in a very fast escape method.
-
-
Field Summary
Fields Modifier and Type Field Description private int
replaceLength
private char[][]
replacements
-
Constructor Summary
Constructors Constructor Description CharArrayDecorator(char[][] replacements)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected char[]
escape(char c)
Returns the escaped form of the given character, ornull
if this character does not need to be escaped.java.lang.String
escape(java.lang.String s)
Returns the escaped form of a given literal string.-
Methods inherited from class com.google.common.escape.CharEscaper
escapeSlow
-
Methods inherited from class com.google.common.escape.Escaper
asFunction
-
-
-
-
Method Detail
-
escape
public java.lang.String escape(java.lang.String s)
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
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
-
-