Escaper instances.
| Modifier and Type | Class and Description |
|---|---|
| public static class | Escapers.
A builder for simple, fast escapers. |
| Modifier and Type | Field and Description |
|---|---|
| private static final Escaper |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static UnicodeEscaper | Returns: a UnicodeEscaper with the same behavior as the given instancethe instance to be wrapped escaper)Returns a |
| public static Escapers. | |
| public static String | Returns: the replacement string, ornull if no escaping was neededthe character to escape if necessary c)Returns a string that would replace the given character in the specified escaper, or |
| public static String | Returns: the replacement string, ornull if no escaping was neededthe Unicode code point to escape if necessary cp)Returns a string that would replace the given character in the specified escaper, or |
| public static Escaper | nullEscaper()
Returns an |
| private static String | |
| private static UnicodeEscaper |
| NULL_ESCAPER | back to summary |
|---|---|
| private static final Escaper NULL_ESCAPER | |
| Escapers | back to summary |
|---|---|
| private Escapers() | |
| asUnicodeEscaper | back to summary |
|---|---|
| pack-priv static UnicodeEscaper asUnicodeEscaper(Escaper escaper) Returns a When a
| |
| builder | back to summary |
|---|---|
| public static Escapers. Returns a builder for creating simple, fast escapers. A builder instance can be reused and each escaper that is created will be a snapshot of the current builder state. Builders are not thread safe. The initial state of the builder is such that:
For performance reasons escapers created by this builder are not Unicode aware and will not validate the well-formedness of their input. | |
| computeReplacement | back to summary |
|---|---|
| public static String computeReplacement(CharEscaper escaper, char c) Returns a string that would replace the given character in the specified escaper, or
| |
| computeReplacement | back to summary |
|---|---|
| public static String computeReplacement(UnicodeEscaper escaper, int cp) Returns a string that would replace the given character in the specified escaper, or
| |
| nullEscaper | back to summary |
|---|---|
| public static Escaper nullEscaper() Returns an | |
| stringOrNull | back to summary |
|---|---|
private static String stringOrNull(char[] in)
| |
| wrap | back to summary |
|---|---|
| private static UnicodeEscaper wrap(CharEscaper escaper) Private helper to wrap a CharEscaper as a UnicodeEscaper. | |
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 | Field and Description |
|---|---|
| private final Map | |
| private char | |
| private char | |
| private String |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Escapers. | |
| public Escaper | |
| public Escapers. | Returns: the builder instancethe lowest 'safe' character safeMin, char the highest 'safe' character safeMax)Sets the safe range of characters for the escaper. |
| public Escapers. | Returns: the builder instancethe string to replace unsafe characters unsafeReplacement)Sets the replacement string for any characters outside the 'safe' range that have no explicit replacement. |
| replacementMap | back to summary |
|---|---|
| private final Map<Character, String> replacementMap | |
| safeMax | back to summary |
|---|---|
| private char safeMax | |
| safeMin | back to summary |
|---|---|
| private char safeMin | |
| unsafeReplacement | back to summary |
|---|---|
| private String unsafeReplacement
| |
| Builder | back to summary |
|---|---|
| private Builder() | |
| addEscape | back to summary |
|---|---|
| public Escapers. Adds a replacement string for the given input character. The specified character will be replaced by the given string whenever it occurs in the input, irrespective of whether it lies inside or outside the 'safe' range.
| |
| build | back to summary |
|---|---|
| public Escaper build() Returns a new escaper based on the current state of the builder. | |
| setSafeRange | back to summary |
|---|---|
| public Escapers. Sets the safe range of characters for the escaper. Characters in this range that have no
explicit replacement are considered 'safe' and remain unescaped in the output. If | |
| setUnsafeReplacement | back to summary |
|---|---|
| public Escapers. Sets the replacement string for any characters outside the 'safe' range that have no explicit
replacement. If | |