Class StringUtils

java.lang.Object
io.deephaven.engine.util.string.StringUtils
All Implemented Interfaces:
Serializable

public class StringUtils extends Object implements Serializable
See Also:
  • Field Details

  • Constructor Details

    • StringUtils

      public StringUtils()
  • Method Details

    • rewriteStringColumnTypes

      public static TableDefinition rewriteStringColumnTypes(TableDefinition tableDefinition)
      Re-write all non-partitioning String columns in the definition to use CompressedString data type. Note this should only be called when it's known that the source will only provide String data with single-byte encodings.
      Parameters:
      tableDefinition - table definition
      Returns:
      the new table definition
    • isNullOrEmpty

      public static boolean isNullOrEmpty(String s)
      Convenience method to combine null and isEmpty checks on a String.
      Parameters:
      s - a String, possibly null
      Returns:
      true if the string is null or is empty
    • getStringCache

      @NotNull public static <STRING_LIKE_TYPE extends CharSequence> @NotNull StringCache<STRING_LIKE_TYPE> getStringCache(Class<STRING_LIKE_TYPE> dataType)
    • stringKey

      public static <VALUE_TYPE> io.deephaven.hash.KeyedObjectKey.Basic<String,VALUE_TYPE> stringKey()
      Generic accessor for the singleton StringKey instance.
      Type Parameters:
      VALUE_TYPE - The type of the value for this key implementation
      Returns:
      A String->StringKeyedObject key representation instance.
    • nullSafeStringKey

      public static <VALUE_TYPE> io.deephaven.hash.KeyedObjectKey.NullSafeBasic<String,VALUE_TYPE> nullSafeStringKey()
      Generic accessor for the singleton NullSafeStringKey instance.
      Type Parameters:
      VALUE_TYPE - The type of the value for this key implementation
      Returns:
      A String->StringKeyedObject key representation instance that supports null keys.
    • stringKeyedObjectKey

      public static <VALUE_TYPE extends StringUtils.StringKeyedObject> io.deephaven.hash.KeyedObjectKey.Basic<String,VALUE_TYPE> stringKeyedObjectKey()
      Generic accessor for the singleton StringKeyedObjectKey instance.
      Type Parameters:
      VALUE_TYPE - The type of the value for this key implementation
      Returns:
      A String->StringKeyedObject key representation instance.
    • nullSafeStringKeyedObjectKey

      public static <VALUE_TYPE extends StringUtils.StringKeyedObject> io.deephaven.hash.KeyedObjectKey.NullSafeBasic<String,VALUE_TYPE> nullSafeStringKeyedObjectKey()
      Generic accessor for the singleton NullSafeStringKeyedObjectKey instance.
      Type Parameters:
      VALUE_TYPE - The type of the value for this key implementation
      Returns:
      A String->StringKeyedObject key representation instance that supports null keys.
    • charSequenceKey

      public static <VALUE_TYPE extends StringUtils.StringKeyedObject> io.deephaven.hash.KeyedObjectKey<CharSequence,VALUE_TYPE> charSequenceKey()
      Generic accessor for the singleton CharSequenceKey instance.
      Type Parameters:
      VALUE_TYPE - The type of the value for this key implementation
      Returns:
      A CharSequence->StringKeyedObject key representation instance.
    • nullSafeCharSequenceKey

      public static <VALUE_TYPE extends StringUtils.StringKeyedObject> io.deephaven.hash.KeyedObjectKey<CharSequence,VALUE_TYPE> nullSafeCharSequenceKey()
      Generic accessor for the singleton CharSequenceKey instance, with support for null keys.
      Type Parameters:
      VALUE_TYPE - The type of the value for this key implementation
      Returns:
      A CharSequence->StringKeyedObject key representation instance.
    • extractMessage

      public static String extractMessage(Throwable t)
      Extracts a message from a throwable. If the message is null or empty, returns toString instead.
      Parameters:
      t - the throwable
      Returns:
      the message or the string
    • replaceArrayValue

      public static void replaceArrayValue(String[] masterStrings, String[] toReplaceStrings, String startsWithValue)
      Possibly replace an array element in one array with an array element in another array. The master strings are searched to see if they contain an element that starts with the startsWithValue. If so, and the strings to be replaced also contain an element which starts with startsWithValue, then that value is replaced with the master string array's value. If multiple values match, only the first value for each array is processed.
      Parameters:
      masterStrings - the string array containing the values to use
      toReplaceStrings - the string array in which to perform the substitution
      startsWithValue - the starts-with value to search for