Package com.yahoo.text
Class StringUtilities
java.lang.Object
com.yahoo.text.StringUtilities
Escapes strings into and out of a format where they only contain printable characters.
Need to duplicate escape / unescape of strings as we have in C++ for java version of system states.
- Author:
- Haakon Humberset
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
static String
Escapes strings into a format with only printable ASCII characters.static String
Returns the given array flattened to string, with the given separator stringstatic String
implodeMultiline
(List<String> lines) Returns the given list flattened to one with newline betweenstatic String
Adds single quotes around object.toString Example: '12'Splits a string on both space and commastatic String
stripSuffix
(String string, String suffix) static String
truncateSequencesIfNecessary
(String text, int maxConsecutiveLength) This will truncate sequences in a string of the same character that exceed the maximum allowed length.static String
-
Constructor Details
-
StringUtilities
public StringUtilities()
-
-
Method Details
-
escape
-
escape
Escapes strings into a format with only printable ASCII characters.- Parameters:
source
- The string to escapedelimiter
- Escape this character too, even if it is printable.- Returns:
- The escaped string
-
unescape
-
implode
Returns the given array flattened to string, with the given separator string- Parameters:
array
- the arraysepString
- or null- Returns:
- imploded array
-
implodeMultiline
Returns the given list flattened to one with newline between- Returns:
- flattened string
-
truncateSequencesIfNecessary
This will truncate sequences in a string of the same character that exceed the maximum allowed length.- Returns:
- The same string or a new one if truncation is done.
-
stripSuffix
-
quote
Adds single quotes around object.toString Example: '12' -
split
Splits a string on both space and comma
-