Package io.deephaven.engine.util.string
Class StringUtils
java.lang.Object
io.deephaven.engine.util.string.StringUtils
- All Implemented Interfaces:
Serializable
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface to make auto-keying by toString() safer and more flexible. -
Field Summary
Modifier and TypeFieldDescriptionstatic final StringCache<CompressedString>
static final StringCache<String>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <VALUE_TYPE extends StringUtils.StringKeyedObject>
io.deephaven.hash.KeyedObjectKey<CharSequence,VALUE_TYPE> Generic accessor for the singleton CharSequenceKey instance.static String
Extracts a message from a throwable.static <STRING_LIKE_TYPE extends CharSequence>
@NotNull StringCache<STRING_LIKE_TYPE>getStringCache
(Class<STRING_LIKE_TYPE> dataType) static boolean
Convenience method to combine null and isEmpty checks on a String.static <VALUE_TYPE extends StringUtils.StringKeyedObject>
io.deephaven.hash.KeyedObjectKey<CharSequence,VALUE_TYPE> Generic accessor for the singleton CharSequenceKey instance, with support for null keys.static <VALUE_TYPE>
io.deephaven.hash.KeyedObjectKey.NullSafeBasic<String,VALUE_TYPE> Generic accessor for the singleton NullSafeStringKey instance.static <VALUE_TYPE extends StringUtils.StringKeyedObject>
io.deephaven.hash.KeyedObjectKey.NullSafeBasic<String,VALUE_TYPE> Generic accessor for the singleton NullSafeStringKeyedObjectKey instance.static void
replaceArrayValue
(String[] masterStrings, String[] toReplaceStrings, String startsWithValue) Possibly replace an array element in one array with an array element in another array.static TableDefinition
rewriteStringColumnTypes
(TableDefinition tableDefinition) Re-write all non-partitioning String columns in the definition to use CompressedString data type.static <VALUE_TYPE>
io.deephaven.hash.KeyedObjectKey.Basic<String,VALUE_TYPE> Generic accessor for the singleton StringKey instance.static <VALUE_TYPE extends StringUtils.StringKeyedObject>
io.deephaven.hash.KeyedObjectKey.Basic<String,VALUE_TYPE> Generic accessor for the singleton StringKeyedObjectKey instance.
-
Field Details
-
STRING_CACHE
-
COMPRESSED_STRING_CACHE
-
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
rewriteStringColumnTypes
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
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
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
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 usetoReplaceStrings
- the string array in which to perform the substitutionstartsWithValue
- the starts-with value to search for
-