AnyStrings instead@Deprecated public final class Strings extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
ensureEndsWith(String string,
String suffix)
Deprecated.
Ensure that
string ends with suffix by appending it to
string if and only if it is not already the last sequence of
characters in the string. |
static String |
ensureStartsWith(String string,
String prefix)
Deprecated.
Ensure that
string starts with prefix by prepending it to
string if and only if it is not already the first sequence of
characters in the string. |
static String |
ensureWithinQuotes(String string)
Deprecated.
Ensure that
string is surrounded by quotes. |
static String |
ensureWithinQuotesIfNeeded(String string,
char delimiter)
Deprecated.
Wrap
string within quotes if it is necessary to do so. |
static String |
escapeInner(String string,
char... characters)
Deprecated.
Efficiently escape inner occurrences of each of the
characters
within the string, if necessary. |
static String |
format(String pattern,
Object... params)
Deprecated.
Perform string substitution and formatting in a manner that is similar to
the SLF4J library.
|
static Set<String> |
getAllSubStrings(String string)
Deprecated.
Return a set that contains every possible substring of
string
excluding pure whitespace strings. |
static boolean |
isSubString(String needle,
String haystack)
Deprecated.
|
static boolean |
isValidJson(String json)
Deprecated.
in version 0.9.6; use
com.cinchapi.concourse.util.DataServices#jsonParser()#parse() |
static boolean |
isWithinQuotes(String string)
Deprecated.
Return
true if string both starts and ends with single or
double quotes. |
static String |
join(char separator,
Object... args)
Deprecated.
Concatenates the
string representation of all the
args, separated by the separator char in an efficient
manner. |
static String |
join(String separator,
Object... args)
Deprecated.
Concatenates the
string representation of all the
args, separated by the separator string in an efficient
manner. |
static String |
joinSimple(Object... args)
Deprecated.
Concatenates the toString values of all the
args in an efficient
manner. |
static String |
joinWithSpace(Object... args)
Deprecated.
Concatenates the toString values of all the
args, separated by
whitespace in an efficient manner. |
static String |
replaceUnicodeConfusables(String string)
Deprecated.
Replace all instances of "confusable" unicode characters with a
canoncial/normalized character.
|
static String[] |
splitButRespectQuotes(String string)
Deprecated.
in version 0.5.0, use
QuoteAwareStringSplitter
instead. |
static List<String> |
splitCamelCase(String string)
Deprecated.
Split a camel case
string into tokens that represent the distinct
words. |
static String[] |
splitStringByDelimiterButRespectQuotes(String string,
String delimiter)
Deprecated.
Split a string on a delimiter as long as that delimiter is not wrapped in
double or single quotes.
|
static Boolean |
tryParseBoolean(String value)
Deprecated.
This method efficiently tries to parse
value into a
Boolean object if possible. |
static Number |
tryParseNumber(String value)
Deprecated.
This method efficiently tries to parse
value into a
Number object if possible. |
static Number |
tryParseNumberStrict(String value)
Deprecated.
A stricter version of
tryParseNumber(String) that does not parse
strings that masquerade as numbers (i.e. |
static String |
valueOfCached(char c)
Deprecated.
Similar to the
String.valueOf(char) method, but this one will
return a cached copy of the string for frequently used characters. |
public static String ensureEndsWith(String string, String suffix)
string ends with suffix by appending it to
string if and only if it is not already the last sequence of
characters in the string.public static String ensureStartsWith(String string, String prefix)
string starts with prefix by prepending it to
string if and only if it is not already the first sequence of
characters in the string.public static String ensureWithinQuotes(String string)
string is surrounded by quotes. If that is not the
case, alter the string so that it is and return the altered form.
Calling isWithinQuotes(String) on the result of this
method will always return true.
string - the string that must be quotedstring or string surrounded by quotes if it is
not alreadypublic static String ensureWithinQuotesIfNeeded(String string, char delimiter)
string within quotes if it is necessary to do so. Otherwise,
return the original string.
The original string will be wrapped in quotes and returned as
such if:
within
quotes, anddelimiter appears at least oncestring - the string to potentially quotedelimiter - the delimiter that determines whether quoting should
happenstring or a properly quoted alternativepublic static String escapeInner(String string, char... characters)
characters
within the string, if necessary.
Escaped characters are prepended with the backslash ('\') character.
An "inner occurrence" for a character is one that is not at the head or tail of the string.
string - the string to escapecharacters - the characters to escape within the stringstringpublic static String replaceUnicodeConfusables(String string)
See http://www.unicode.org/Public/security/revision-03/confusablesSummary. txt for a list of characters that are considered to be confusable.
public static String format(String pattern, Object... params)
Strings#format("Bob is very {} because he has no {}", "brave", "fear") = "Bob is very brave because he has no fear"
NOTE: This method is less efficient than using a
StringBuilder and manually appending variable arguments for
interpolation. This is provided for convenience, but don't use it for
anything that is performance critical.
pattern - the message pattern which will be parsed and formattedparams - an array of arguments to be substituted in place of
formatting anchorspublic static Set<String> getAllSubStrings(String string)
string
excluding pure whitespace strings.string - the string to divide into substringspublic static boolean isSubString(String needle, String haystack)
needle - the substring for which to searchhaystack - the string in which to search for the substringtrue if needle is a substring@Deprecated public static boolean isValidJson(String json)
com.cinchapi.concourse.util.DataServices#jsonParser()#parse()true if the json string is valid, otherwise return
false.json - a json formatted stringtrue if the json is validpublic static boolean isWithinQuotes(String string)
true if string both starts and ends with single or
double quotes.string - true if the string is between quotespublic static String join(char separator, Object... args)
string representation of all the
args, separated by the separator char in an efficient
manner.separator - the separator to place between each of the argsargs - the args to joinpublic static String join(String separator, Object... args)
string representation of all the
args, separated by the separator string in an efficient
manner.separator - the separator to place between each of the argsargs - the args to joinpublic static String joinSimple(Object... args)
args in an efficient
manner.args - public static String joinWithSpace(Object... args)
args, separated by
whitespace in an efficient manner.args - @Deprecated public static String[] splitButRespectQuotes(String string)
QuoteAwareStringSplitter
instead.string - public static List<String> splitCamelCase(String string)
string into tokens that represent the distinct
words.
string - public static String[] splitStringByDelimiterButRespectQuotes(String string, String delimiter)
If delimiter is a single character string, it is more efficient
to use a StringSplitter as opposed to this method.
string - the string to splitdelimiter - the delimiting string/regex on which the input
string is splitpublic static Boolean tryParseBoolean(String value)
value into a
Boolean object if possible. If the string is not a boolean, then
the method returns null as quickly as possible.value - null if it
is not possible to parse the string into a boolean@Nullable public static Number tryParseNumber(String value)
value into a
Number object if possible. If the string is not a number, then
the method returns null as quickly as possible.value - null if it
is not possible to parse the string into a number@Nullable public static Number tryParseNumberStrict(String value)
tryParseNumber(String) that does not parse
strings that masquerade as numbers (i.e. 3.124D). Instead this method
will only parse the string into a Number if it contains characters that
are either a decimal digit, a decimal separator or a negative sign.value - null if it
is not possible to parse the string into a numberpublic static String valueOfCached(char c)
String.valueOf(char) method, but this one will
return a cached copy of the string for frequently used characters.c - the character to convert