java.lang.Object
com.pervasive.datarush.util.StringUtil
Utility methods for operating on strings.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringescapeAndQuote(String str) Escapes the input string and surrounds it with single quotes.static StringescapeFieldName(String name) Escapes a field name, for use in the expression language.static StringformatFieldName(String name) Formats a field name for printing to the console or GUI.static StringgetTypeName(String packageStyleType) Gets the unqualified type name from a fully qualified type name.static StringConcatenates string values together using a comma followed by a space.static StringConcatenates string values together using a comma followed by a space.static StringConcatenates string values together using a separator.static StringConcatenates string values together using a separator.static String[]Parses a comma-separated list into an array of strings.static final String[]Splits incoming String data into an array of substrings based on a character delimiter.static StringtoCSV(Collection<String> values) Create a csv from a list of stringsstatic StringunescapeAndQuote(String str) Removes a single layer of matched leading and trailing quotes, and also unescapes JavaScript style escape sequences.
-
Constructor Details
-
StringUtil
public StringUtil()
-
-
Method Details
-
escapeAndQuote
Escapes the input string and surrounds it with single quotes.This method should not be used for field names; instead, use
formatFieldName(String).- Parameters:
str- the string to escape and quote- Returns:
- the escaped and quoted string
-
unescapeAndQuote
Removes a single layer of matched leading and trailing quotes, and also unescapes JavaScript style escape sequences.- Parameters:
str- the string to unquote and unescape- Returns:
- the unquoted and unescaped string
-
formatFieldName
Formats a field name for printing to the console or GUI. The field name is surrounded with backticks, as it would be formatted in the expression language.- Parameters:
name- the field name to format- Returns:
- the formatted field name
-
escapeFieldName
Escapes a field name, for use in the expression language. Control characters and backticks are escaped, while quotes and Unicode characters are left intact.- Parameters:
name- the field name to escape- Returns:
- the escaped field name
-
getTypeName
Gets the unqualified type name from a fully qualified type name. For example an input of"com.acme.Foo"would result in"Foo".- Parameters:
packageStyleType- the fully qualified type name in dot notation- Returns:
- Type the unqualified name
-
join
Concatenates string values together using a separator. Values are concatenated in order according to theIteratorofvalues. Objects invaluesthat are not strings are converted to strings via theirObject.toString()method.- Parameters:
separator- the separator to use between string valuesvalues- the values to concatenate- Returns:
valuesjoined byseparatorinto a single string
-
join
Concatenates string values together using a comma followed by a space. Values are concatenated in order according to theIteratorofvalues. Objects invaluesthat are not strings are converted to strings via theirObject.toString()method.This method is equivalent to
join(", ", values).- Parameters:
values- the values to concatenate- Returns:
valuesjoined by ", " into a single string
-
join
Concatenates string values together using a separator. Objects invaluesthat are not strings are converted to strings via theirObject.toString()method.- Parameters:
separator- the separator to use between string valuesvalues- the values to concatenate- Returns:
valuesjoined byseparatorinto a single string
-
join
Concatenates string values together using a comma followed by a space. Objects invaluesthat are not strings are converted to strings via theirObject.toString()method.This method is equivalent to
join(", ", values).- Parameters:
values- the values to concatenate- Returns:
valuesjoined by ", " into a single string
-
split
Splits incoming String data into an array of substrings based on a character delimiter. If the delimiter didn't exist, the returned array contains one element equal to the original string data. This method is a subset of String.split() which takes regex and is less efficient.- Parameters:
data- the string to splitdelimiter- the character separating elements- Returns:
- string array
-
parseCSV
Parses a comma-separated list into an array of strings. extra whitespace is ignored- Parameters:
data-- Returns:
-
toCSV
Create a csv from a list of strings- Parameters:
values- the values- Returns:
- a comma-separated list of values
-