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 intreplaceLengthprivate 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, ornullif this character does not need to be escaped.java.lang.Stringescape(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:CharEscaperReturns the escaped form of a given literal string.- Overrides:
escapein 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:CharEscaperReturns the escaped form of the given character, ornullif 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
charvalue, so this method should not throw any exceptions.- Specified by:
escapein classCharEscaper- Parameters:
c- the character to escape if necessary- Returns:
- the replacement characters, or
nullif no escaping was needed
-
-