Package com.github.javaparser.utils
Class StringEscapeUtils.CharSequenceTranslator
java.lang.Object
com.github.javaparser.utils.StringEscapeUtils.CharSequenceTranslator
- Direct Known Subclasses:
StringEscapeUtils.AggregateTranslator
,StringEscapeUtils.LookupTranslator
,StringEscapeUtils.OctalUnescaper
,StringEscapeUtils.UnicodeUnescaper
- Enclosing class:
StringEscapeUtils
Adapted from apache commons-lang3 project.
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.
- Since:
- 3.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate String
translate
(CharSequence input) Helper for non-Writer usage.protected abstract int
translate
(CharSequence input, int index, Writer out) Translate a set of codepoints, represented by an int index into a CharSequence, into another set of codepoints.private void
translate
(CharSequence input, Writer out) Translate an input onto a Writer.
-
Constructor Details
-
CharSequenceTranslator
private CharSequenceTranslator()
-
-
Method Details
-
translate
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.- Parameters:
input
- CharSequence that is being translatedindex
- int representing the current point of translationout
- Writer to translate the text to- Returns:
- int count of codepoints consumed
- Throws:
IOException
- if and only if the Writer produces an IOException
-
translate
Helper for non-Writer usage.- Parameters:
input
- CharSequence to be translated- Returns:
- String output of translation
-
translate
Translate an input onto a Writer. This is intentionally final as its algorithm is tightly coupled with the abstract method of this class.- Parameters:
input
- CharSequence that is being translatedout
- Writer to translate the text to- Throws:
IOException
- if and only if the Writer produces an IOException
-