Class StringUtil

java.lang.Object
com.pervasive.datarush.util.StringUtil

public class StringUtil extends Object
Utility methods for operating on strings.
  • Constructor Details

    • StringUtil

      public StringUtil()
  • Method Details

    • escapeAndQuote

      public static String escapeAndQuote(String str)
      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

      public static String unescapeAndQuote(String str)
      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

      public static String formatFieldName(String name)
      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

      public static String escapeFieldName(String name)
      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

      public static String getTypeName(String packageStyleType)
      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

      public static String join(String separator, Iterable<?> values)
      Concatenates string values together using a separator. Values are concatenated in order according to the Iterator of values. Objects in values that are not strings are converted to strings via their Object.toString() method.
      Parameters:
      separator - the separator to use between string values
      values - the values to concatenate
      Returns:
      values joined by separator into a single string
    • join

      public static String join(Iterable<?> values)
      Concatenates string values together using a comma followed by a space. Values are concatenated in order according to the Iterator of values. Objects in values that are not strings are converted to strings via their Object.toString() method.

      This method is equivalent to join(", ", values).

      Parameters:
      values - the values to concatenate
      Returns:
      values joined by ", " into a single string
    • join

      public static String join(String separator, Object[] values)
      Concatenates string values together using a separator. Objects in values that are not strings are converted to strings via their Object.toString() method.
      Parameters:
      separator - the separator to use between string values
      values - the values to concatenate
      Returns:
      values joined by separator into a single string
    • join

      public static String join(Object[] values)
      Concatenates string values together using a comma followed by a space. Objects in values that are not strings are converted to strings via their Object.toString() method.

      This method is equivalent to join(", ", values).

      Parameters:
      values - the values to concatenate
      Returns:
      values joined by ", " into a single string
    • split

      public static final String[] split(String data, char delimiter)
      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 split
      delimiter - the character separating elements
      Returns:
      string array
    • parseCSV

      public static String[] parseCSV(String data)
      Parses a comma-separated list into an array of strings. extra whitespace is ignored
      Parameters:
      data -
      Returns:
    • toCSV

      public static String toCSV(Collection<String> values)
      Create a csv from a list of strings
      Parameters:
      values - the values
      Returns:
      a comma-separated list of values