Modifier and Type | Field and Description |
---|---|
static String |
CDATA_PREFIX |
static String |
CDATA_SUFFIX |
static String |
COLON |
static String |
COMMA |
static String |
CR |
static String |
DOT |
static char |
DOUBLE_QUOTE |
static String[] |
EMPTY_ARRAY |
static String |
EMPTY_STRING |
static String |
FORWARD_SLASH |
static String |
LF |
static String |
SPACE |
static String |
UTF8 |
Constructor and Description |
---|
Str() |
Modifier and Type | Method and Description |
---|---|
static String |
cdata(String s)
Turn the string into CDATA - http://en.wikipedia.org/wiki/CDATA
|
static String |
conceal(String text)
A trivial way to conceal
text . |
static boolean |
contains(List<String> tokens,
String value,
boolean caseSensitive) |
static boolean |
equals(String s1,
String s2,
boolean caseSensitive) |
static String |
flatten(String s)
Replace carriage returns and linefeeds with a space
|
static String |
flatten(String s,
String cr,
String lf)
Replace carriage returns with
cr and linefeeds with lf . |
static byte[] |
getAsciiBytes(String s) |
static String |
getAsciiString(byte[] bytes) |
static byte[] |
getBytes(String s,
String encoding) |
static String |
getId(String... tokens)
Convert the tokens into a string delimited by the colon "
: " character |
static String |
getPath(String s)
Convert dots to forward slashes and trim.
|
static String |
getString(byte[] bytes,
String encoding) |
static byte[] |
getUTF8Bytes(String s) |
static String |
getUTF8String(byte[] bytes) |
static String |
inflate(String s,
String cr,
String lf)
Replace
cr with carriage return and lf with linefeed. |
static boolean |
isConcealed(String text)
Return true if
text is concealed |
static boolean |
matches(String s,
String prefix,
String suffix)
Return true if
s starts with prefix and ends with suffix |
static String |
quote(String s)
Surround the string with double quotes.
|
static String |
remove(String s,
String prefix,
String suffix) |
static String |
removePrefix(String s,
String prefix)
If
s starts with prefix , remove it |
static String |
removeSuffix(String s,
String suffix)
If
s ends with suffix , remove it |
static String |
reveal(String text)
Reveal the original contents of a string concealed by the
conceal method. |
static String[] |
split(String s,
String separatorChars,
boolean trim)
Split the string into tokens using the indicated separator chars, optionally trimming the tokens.
|
static String[] |
splitAndTrim(String s,
String separatorChars)
Split the string into tokens using the indicated separator, trimming as we go.
|
static String[] |
splitAndTrimCSV(String csv)
Split comma separated values into tokens, trimming as we go.
|
static String[] |
splitCSV(String csv,
boolean trim)
Split comma separated values into tokens, optionally trimming the tokens.
|
static String |
toEmpty(String s)
If s is null return "" otherwise return s
|
static String[] |
toEmptyArray(String[] strings)
If
strings are null return EMPTY_ARRAY , otherwise return strings . |
static String |
toString(String[] tokens)
Combine
tokens into a String |
public static final String EMPTY_STRING
public static final String UTF8
public static final String COMMA
public static final String SPACE
public static final String CR
public static final String LF
public static final String DOT
public static final String COLON
public static final String FORWARD_SLASH
public static final char DOUBLE_QUOTE
public static final String CDATA_PREFIX
public static final String CDATA_SUFFIX
public static final String[] EMPTY_ARRAY
public Str()
public static final String conceal(String text)
A trivial way to conceal text
. Can be reversed using reveal()
. Do NOT use this method in an attempt to obscure sensitive data. The algorithm
is completely trivial and exceedingly simple to reverse engineer. Not to mention, the reveal()
method can reproduce the original string without requiring any
secret knowledge.
The use case here is to help prevent someone with otherwise mostly good intentions from altering a piece of information in a way they should not. This is NOT intended to defeat any serious attempt at discovering the original text.
Think a hungry sales or marketing rep who stumbles across a config file with the entry vending.machine.refill.day=wed
in it and tries to change that to
mon
in order to beat a case of the munchies. :)
If the entry says vending.machine.refill.day=cnc--jrq
instead of vending.machine.refill.day=wed
they are far more likely to ask around before they
change it OR just give up and head out to lunch instead.
reveal
public static final String reveal(String text)
conceal
method.conceal
public static final boolean isConcealed(String text)
text
is concealedpublic static final String[] toEmptyArray(String[] strings)
strings
are null
return EMPTY_ARRAY
, otherwise return strings
.public static final String getId(String... tokens)
:
" character
"foo","bar" ,"baz" -> foo:bar:baz "foo", null ,"baz" -> foo::baz "foo", "" ,"baz" -> foo::baz "foo", null , null -> foo:: null,"bar" , null -> :bar:
public static final String cdata(String s)
public static final String removeSuffix(String s, String suffix)
s
ends with suffix
, remove itpublic static final String removePrefix(String s, String prefix)
s
starts with prefix
, remove itpublic static final boolean matches(String s, String prefix, String suffix)
s
starts with prefix
and ends with suffix
public static final String getAsciiString(byte[] bytes)
public static final String getUTF8String(byte[] bytes)
public static final byte[] getAsciiBytes(String s)
public static final byte[] getUTF8Bytes(String s)
public static final boolean contains(List<String> tokens, String value, boolean caseSensitive)
public static final String[] splitCSV(String csv, boolean trim)
public static final String[] splitAndTrimCSV(String csv)
public static final String[] splitAndTrim(String s, String separatorChars)
public static final String[] split(String s, String separatorChars, boolean trim)
public static final String flatten(String s)
public static final String flatten(String s, String cr, String lf)
cr
and linefeeds with lf
.Copyright © 2010–2014 The Kuali Foundation. All rights reserved.