public static class StringEscapes.JavaStringEscapes
extends java.lang.Object
Constructor and Description |
---|
StringEscapes.JavaStringEscapes() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
escapeJavaString(java.lang.String value)
converts normal string to java escaped for double-quotes (but not wrapped in double quotes)
|
static void |
escapeJavaString(java.lang.String value,
java.lang.Appendable out)
converts normal string to java escaped for double-quotes (but not wrapped in double quotes)
|
static java.lang.String |
unwrapJavaString(java.lang.String s)
given a string in java syntax, e.g.
|
static java.lang.String |
unwrapJavaStringIfWrapped(java.lang.String s)
as
unwrapJavaString(String) if the given string is wrapped in double quotes;
otherwise just returns the given string |
static java.util.List<java.lang.String> |
unwrapJsonishListIfPossible(java.lang.String input)
converts a comma separated list in a single string to a list of strings,
doing what would be expected if given java or json style string as input,
and falling back to returning the input.
|
static java.util.List<java.lang.String> |
unwrapOptionallyQuotedJavaStringList(java.lang.String input)
as
unwrapJsonishListIfPossible(String) but throwing errors
if something which looks like a string or set of brackets is not well-formed
(this does the work for that method) |
static java.util.List<java.lang.String> |
unwrapQuotedJavaStringList(java.lang.String s,
java.lang.String separator)
Unwraps a sequence of quoted java strings, that are each separated by the given separator.
|
static java.lang.String |
wrapJavaString(java.lang.String value)
converts normal string to java escaped for double-quotes and wrapped in those double quotes
|
static void |
wrapJavaString(java.lang.String value,
java.lang.Appendable out)
converts normal string to java escaped for double-quotes and wrapped in those double quotes
|
public static java.lang.String escapeJavaString(java.lang.String value)
public static java.lang.String wrapJavaString(java.lang.String value)
public static java.lang.String unwrapJavaStringIfWrapped(java.lang.String s)
unwrapJavaString(String)
if the given string is wrapped in double quotes;
otherwise just returns the given stringpublic static void wrapJavaString(java.lang.String value, java.lang.Appendable out) throws java.io.IOException
java.io.IOException
public static void escapeJavaString(java.lang.String value, java.lang.Appendable out) throws java.io.IOException
java.io.IOException
public static java.lang.String unwrapJavaString(java.lang.String s)
public static java.util.List<java.lang.String> unwrapQuotedJavaStringList(java.lang.String s, java.lang.String separator)
trimmedArg
- public static java.util.List<java.lang.String> unwrapJsonishListIfPossible(java.lang.String input)
this method does not throw exceptions on invalid input, but just returns that input
specifically, uses the following rules (executed once in sequence:
[ X ]
(in brackets after trim),
then removes brackets and applies following rules to X (for any X including quoted or with commas)
"X"
(in double quotes after trim,
where X contains no internal double quotes unless escaped with backslash)
then returns list containing X unescaped (\x replaced by x)
X
or X, Y, ...
(where X, Y, ... each satisfy the constraint given in 2, or have no double quotes or commas in them)
then returns the concatenation of rule 2 applied to non-empty X, Y, ...
(if you want an empty string in a list, you must double quote it)
public static java.util.List<java.lang.String> unwrapOptionallyQuotedJavaStringList(java.lang.String input)
unwrapJsonishListIfPossible(String)
but throwing errors
if something which looks like a string or set of brackets is not well-formed
(this does the work for that method)java.lang.IllegalArgumentException
- if looks to have quoted list or surrounding brackets but they are not syntactically valid