Package com.github.javaparser.utils
Class StringEscapeUtils
java.lang.Object
com.github.javaparser.utils.StringEscapeUtils
Adapted from apache commons-lang3 project.
Unescapes escaped chars in strings.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classAdapted from apache commons-lang3 project.private static classAdapted from apache commons-lang3 project.private static classAdapted from apache commons-lang3 project.private static classAdapted from apache commons-lang3 project.private static classAdapted from apache commons-lang3 project. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringEscapeUtils.CharSequenceTranslatorprivate static final StringEscapeUtils.LookupTranslatorprivate static final StringEscapeUtils.LookupTranslatorprivate static final StringEscapeUtils.CharSequenceTranslatorprivate static final StringEscapeUtils.CharSequenceTranslator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringescapeJava(String input) Escapes the characters in aStringusing Java String rules.static StringunescapeJava(String input) Unescapes any Java literals found in theString.static StringunescapeJavaTextBlock(String input)
-
Field Details
-
JAVA_CTRL_CHARS_UNESCAPE
-
JAVA_CTRL_CHARS_ESCAPE
-
ESCAPE_JAVA
-
UNESCAPE_JAVA
-
UNESCAPE_JAVA_TEXT_BLOCK
-
-
Constructor Details
-
StringEscapeUtils
private StringEscapeUtils()
-
-
Method Details
-
escapeJava
Escapes the characters in a
Stringusing Java String rules.Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.)
So a tab becomes the characters
'\\'and't'.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!\"
- Parameters:
input- String to escape values in, may be null- Returns:
- String with escaped values,
nullif null string input
-
unescapeJava
Unescapes any Java literals found in the
String. For example, it will turn a sequence of'\'and'n'into a newline character, unless the'\'is preceded by another'\'.This can be replaced by String::translateEscapes in JDK 13
- Parameters:
input- theStringto unescape, may be null- Returns:
- a new unescaped
String,nullif null string input
-
unescapeJavaTextBlock
-