@Beta @GwtCompatible public final class Escapers extends java.lang.Object
Escaper instances.| Modifier and Type | Class and Description |
|---|---|
static class |
Escapers.Builder
A builder for simple, fast escapers.
|
| Modifier and Type | Field and Description |
|---|---|
private static Escaper |
NULL_ESCAPER |
| Modifier | Constructor and Description |
|---|---|
private |
Escapers() |
| Modifier and Type | Method and Description |
|---|---|
(package private) static UnicodeEscaper |
asUnicodeEscaper(Escaper escaper)
Returns a
UnicodeEscaper equivalent to the given escaper instance. |
static Escapers.Builder |
builder()
Returns a builder for creating simple, fast escapers.
|
static java.lang.String |
computeReplacement(CharEscaper escaper,
char c)
Returns a string that would replace the given character in the specified escaper, or
null if no replacement should be made. |
static java.lang.String |
computeReplacement(UnicodeEscaper escaper,
int cp)
Returns a string that would replace the given character in the specified escaper, or
null if no replacement should be made. |
static Escaper |
nullEscaper()
Returns an
Escaper that does no escaping, passing all character data through unchanged. |
private static java.lang.String |
stringOrNull(char[] in) |
private static UnicodeEscaper |
wrap(CharEscaper escaper)
Private helper to wrap a CharEscaper as a UnicodeEscaper.
|
private static final Escaper NULL_ESCAPER
public static Escaper nullEscaper()
Escaper that does no escaping, passing all character data through unchanged.public static Escapers.Builder builder()
The initial state of the builder is such that:
safeMin == Character.MIN_VALUE
safeMax == Character.MAX_VALUE
unsafeReplacement == null
For performance reasons escapers created by this builder are not Unicode aware and will not validate the well-formedness of their input.
static UnicodeEscaper asUnicodeEscaper(Escaper escaper)
UnicodeEscaper equivalent to the given escaper instance. If the escaper is
already a UnicodeEscaper then it is simply returned, otherwise it is wrapped in a
UnicodeEscaper.
When a CharEscaper escaper is wrapped by this method it acquires extra behavior with
respect to the well-formedness of Unicode character sequences and will throw
IllegalArgumentException when given bad input.
escaper - the instance to be wrappedjava.lang.NullPointerException - if escaper is nulljava.lang.IllegalArgumentException - if escaper is not a UnicodeEscaper or a CharEscaperpublic static java.lang.String computeReplacement(CharEscaper escaper, char c)
null if no replacement should be made. This method is intended for use in tests through
the EscaperAsserts class; production users of CharEscaper should limit
themselves to its public interface.c - the character to escape if necessarynull if no escaping was neededpublic static java.lang.String computeReplacement(UnicodeEscaper escaper, int cp)
null if no replacement should be made. This method is intended for use in tests through
the EscaperAsserts class; production users of UnicodeEscaper should limit
themselves to its public interface.cp - the Unicode code point to escape if necessarynull if no escaping was neededprivate static java.lang.String stringOrNull(char[] in)
private static UnicodeEscaper wrap(CharEscaper escaper)