public final class Utils extends Object
It provides static functions to escape unescape, trim or removing leading?trailing quotes out of String.
It also provide additional utility functions, handy to make them unit tested.
Modifier and Type | Method and Description |
---|---|
static String |
escape(String aText)
Escapes characters for text appearing as data in the
Javascript Object Notation
(JSON) data interchange format.
|
static String |
escapeAndReplace(boolean debug,
String input,
char[] quoteDelims,
char escapeChar,
List<String> opaque)
Given an input String like this : hello,"world,you",moon
it may be necessary before splitting it into "hello" and "world,you" and "moon",
to make everything between (sqy) quotes be opacified.
|
static String |
removeTrailingDoubleOrSingleQuote(String value)
remove from the string the leading and trailing quote and double quote.
|
static String |
restore(String value,
List<String> opaque) |
static String |
unescape(String aText) |
public static String escape(String aText)
>The following commonly used control characters are escaped :
Character | Escaped As |
---|---|
" | \" |
\ | \\ |
/ | \/ |
back space | \b |
form feed | \f |
line feed | \n |
carriage return | \r |
tab | \t |
See RFC 4627 for more information.
aText
- your input textpublic static String escapeAndReplace(boolean debug, String input, char[] quoteDelims, char escapeChar, List<String> opaque)
With that string you can safely split it, then at the end replace back in turn each \@PUNCH\@ by its original content.
debug
- true to stdout important steps. Do not use in productioninput
- the input StringquoteDelims
- the quoteDelims to use for opacifying inner contentescapeChar
- the escapeChar to use for escaping quote delimitersopaque
- a list of String that will be filled with the substring replaced by \@PUNCH\@Copyright © 2023. All rights reserved.