@Beta public static final class Escapers.Builder extends Object
Typically an escaper needs to deal with the escaping of high valued characters or code
points. In these cases it is necessary to extend either ArrayBasedCharEscaper
or
ArrayBasedUnicodeEscaper
to provide the desired behavior. However this builder is
suitable for creating escapers that replace a relative small set of characters.
Modifier and Type | Method and Description |
---|---|
Escapers.Builder |
addEscape(char c,
String replacement)
Adds a replacement string for the given input character.
|
Escaper |
build()
Returns a new escaper based on the current state of the builder.
|
Escapers.Builder |
setSafeRange(char safeMin,
char safeMax)
Sets the safe range of characters for the escaper.
|
Escapers.Builder |
setUnsafeReplacement(String unsafeReplacement)
Sets the replacement string for any characters outside the 'safe' range that have no explicit
replacement.
|
public Escapers.Builder setSafeRange(char safeMin, char safeMax)
safeMax < safeMin
then the safe range is empty.safeMin
- the lowest 'safe' charactersafeMax
- the highest 'safe' characterpublic Escapers.Builder setUnsafeReplacement(@Nullable String unsafeReplacement)
unsafeReplacement
is null
then no replacement will occur, if
it is ""
then the unsafe characters are removed from the output.unsafeReplacement
- the string to replace unsafe chracterspublic Escapers.Builder addEscape(char c, String replacement)
c
- the character to be replacedreplacement
- the string to replace the given characterNullPointerException
- if replacement
is nullCopyright © 2010-2016. All Rights Reserved.