Unescapes escaped chars in strings.
| Modifier and Type | Class and Description |
|---|---|
| private static class | StringEscapeUtils.
Adapted from apache commons-lang3 project. |
| private abstract static class | StringEscapeUtils.
Adapted from apache commons-lang3 project. |
| private static class | StringEscapeUtils.
Adapted from apache commons-lang3 project. |
| private static class | StringEscapeUtils.
Adapted from apache commons-lang3 project. |
| private static class | StringEscapeUtils.
Adapted from apache commons-lang3 project. |
| Modifier and Type | Field and Description |
|---|---|
| private static final StringEscapeUtils. | |
| private static final String[][] | |
| private static final String[][] | |
| private static final StringEscapeUtils. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static String | Returns: String with escaped values,null if null string inputString to escape values in, may be null input)Escapes the characters in a |
| public static String | Returns: a new unescapedString, null if null string inputthe input)String to unescape, may be nullUnescapes any Java literals found in the |
| ESCAPE_JAVA | back to summary |
|---|---|
| private static final StringEscapeUtils. | |
| JAVA_CTRL_CHARS_ESCAPE | back to summary |
|---|---|
| private static final String[][] JAVA_CTRL_CHARS_ESCAPE | |
| JAVA_CTRL_CHARS_UNESCAPE | back to summary |
|---|---|
| private static final String[][] JAVA_CTRL_CHARS_UNESCAPE | |
| UNESCAPE_JAVA | back to summary |
|---|---|
| private static final StringEscapeUtils. | |
| StringEscapeUtils | back to summary |
|---|---|
| private StringEscapeUtils() | |
| escapeJava | back to summary |
|---|---|
| public static String escapeJava(final String input) Escapes the characters in a
Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.)
So a tab becomes the characters
The only difference between Java strings and JavaScript strings is that in JavaScript, a single quote and forward-slash (/) are escaped.
Example: input string: He didn't say, "Stop!" output string: He didn't say, \"Stop!\" | |
| unescapeJava | back to summary |
|---|---|
| public static String unescapeJava(final String input) Unescapes any Java literals found in the | |
Executes a sequence of translators one after the other. Execution ends whenever the first translator consumes codepoints from the input.
| Modifier and Type | Field and Description |
|---|---|
| private final StringEscapeUtils. |
| Access | Constructor and Description |
|---|---|
| public | AggregateTranslator(final StringEscapeUtils.
CharSequenceTranslator array to aggregate translatorsSpecify the translators to be used at creation time. |
| Modifier and Type | Method and Description |
|---|---|
| public int | translate(final CharSequence
CharSequence that is being translated input, final int int representing the current point of translation index, final Writer Writer to translate the text to out)Implements abstract com. |
| translators | back to summary |
|---|---|
| private final StringEscapeUtils. | |
| AggregateTranslator | back to summary |
|---|---|
| public AggregateTranslator(final StringEscapeUtils. Specify the translators to be used at creation time.
| |
| translate | back to summary |
|---|---|
| public int translate(final CharSequence input, final int index, final Writer out) throws IOException Implements abstract com. Doc from com. The first translator to consume codepoints from the input is the 'winner'. Execution stops with the number of consumed codepoints being returned. Translate a set of codepoints, represented by an int index into a CharSequence, into another set of codepoints. The number of codepoints consumed must be returned, and the only IOExceptions thrown must be from interacting with the Writer so that the top level API may reliably ignore StringWriter IOExceptions.
| |
An API for translating text. Its core use is to escape and unescape text. Because escaping and unescaping is completely contextual, the API does not present two separate signatures.
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public abstract int | Returns: int count of codepoints consumedCharSequence that is being translated input, int int representing the current point of translation index, Writer Writer to translate the text to out)Translate a set of codepoints, represented by an int index into a CharSequence, into another set of codepoints. |
| public final String | Returns: String output of translationCharSequence to be translated input)Helper for non-Writer usage. |
| public final void | translate(final CharSequence
CharSequence that is being translated input, final Writer Writer to translate the text to out)Translate an input onto a Writer. |
| public final StringEscapeUtils. | Returns: CharSequenceTranslator merging this translator with the othersCharSequenceTranslator array of translators to merge with this one translatorsHelper method to create a merger of this translator with another set of translators. |
| CharSequenceTranslator | back to summary |
|---|---|
| private CharSequenceTranslator() | |
| translate | back to summary |
|---|---|
| public abstract int translate(CharSequence input, int index, Writer out) throws IOException Translate a set of codepoints, represented by an int index into a CharSequence, into another set of codepoints. The number of codepoints consumed must be returned, and the only IOExceptions thrown must be from interacting with the Writer so that the top level API may reliably ignore StringWriter IOExceptions.
| |
| translate | back to summary |
|---|---|
| public final String translate(final CharSequence input) Helper for non-Writer usage.
| |
| translate | back to summary |
|---|---|
| public final void translate(final CharSequence input, final Writer out) throws IOException Translate an input onto a Writer. This is intentionally final as its algorithm is tightly coupled with the abstract method of this class.
| |
| with | back to summary |
|---|---|
| public final StringEscapeUtils. Helper method to create a merger of this translator with another set of translators. Useful in customizing the standard functionality.
| |
Translates a value using a lookup table.
| Modifier and Type | Field and Description |
|---|---|
| private final int | |
| private final HashMap | |
| private final HashSet | |
| private final int |
| Access | Constructor and Description |
|---|---|
| public | LookupTranslator(final CharSequence[]...
CharSequence[][] table of size [*][2] lookup)Define the lookup table to be used in translation Note that, as of Lang 3.1, the key to the lookup table is converted to a java.lang.String. |
| Modifier and Type | Method and Description |
|---|---|
| public int | translate(final CharSequence
CharSequence that is being translated input, final int int representing the current point of translation index, final Writer Writer to translate the text to out)Implements abstract com. |
| longest | back to summary |
|---|---|
| private final int longest | |
| lookupMap | back to summary |
|---|---|
| private final HashMap<String, String> lookupMap | |
| prefixSet | back to summary |
|---|---|
| private final HashSet<Character> prefixSet | |
| shortest | back to summary |
|---|---|
| private final int shortest | |
| LookupTranslator | back to summary |
|---|---|
| public LookupTranslator(final CharSequence[]... lookup) Define the lookup table to be used in translation Note that, as of Lang 3.1, the key to the lookup table is converted to a java.lang.String. This is because we need the key to support hashCode and equals(Object), allowing it to be the key for a HashMap. See LANG-882.
| |
| translate | back to summary |
|---|---|
| public int translate(final CharSequence input, final int index, final Writer out) throws IOException Implements abstract com. Doc from com. Translate a set of codepoints, represented by an int index into a CharSequence, into another set of codepoints. The number of codepoints consumed must be returned, and the only IOExceptions thrown must be from interacting with the Writer so that the top level API may reliably ignore StringWriter IOExceptions.
| |
Translate escaped octal Strings back to their octal values.
For example, "\45" should go back to being the specific value (a %).
Note that this currently only supports the viable range of octal for Java; namely 1 to 377. This is because parsing Java is the main use case.
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private boolean | Returns: true if the given char is the character representation of one of the digits from 0 to 7the char to check ch)Checks if the given char is an octal digit. |
| private boolean | Returns: true if the given char is the character representation of one of the digits from 0 to 3the char to check ch)Checks if the given char is the character representation of one of the digit from 0 to 3. |
| public int | translate(final CharSequence
CharSequence that is being translated input, final int int representing the current point of translation index, final Writer Writer to translate the text to out)Implements abstract com. |
| OctalUnescaper | back to summary |
|---|---|
| private OctalUnescaper() | |
| isOctalDigit | back to summary |
|---|---|
| private boolean isOctalDigit(final char ch) Checks if the given char is an octal digit. Octal digits are the character representations of the digits 0 to 7.
| |
| isZeroToThree | back to summary |
|---|---|
| private boolean isZeroToThree(final char ch) Checks if the given char is the character representation of one of the digit from 0 to 3.
| |
| translate | back to summary |
|---|---|
| public int translate(final CharSequence input, final int index, final Writer out) throws IOException Implements abstract com. Doc from com. Translate a set of codepoints, represented by an int index into a CharSequence, into another set of codepoints. The number of codepoints consumed must be returned, and the only IOExceptions thrown must be from interacting with the Writer so that the top level API may reliably ignore StringWriter IOExceptions.
| |
Translates escaped Unicode values of the form \\u+\d\d\d\d back to Unicode. It supports multiple 'u' characters and will work with or without the +.
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public int | translate(final CharSequence
CharSequence that is being translated input, final int int representing the current point of translation index, final Writer Writer to translate the text to out)Implements abstract com. |
| UnicodeUnescaper | back to summary |
|---|---|
| private UnicodeUnescaper() | |
| translate | back to summary |
|---|---|
| public int translate(final CharSequence input, final int index, final Writer out) throws IOException Implements abstract com. Doc from com. Translate a set of codepoints, represented by an int index into a CharSequence, into another set of codepoints. The number of codepoints consumed must be returned, and the only IOExceptions thrown must be from interacting with the Writer so that the top level API may reliably ignore StringWriter IOExceptions.
| |