Package org.apache.flink.util
Class StringValueUtils
- java.lang.Object
-
- org.apache.flink.util.StringValueUtils
-
@PublicEvolving public final class StringValueUtils extends Object
Utility class for efficient operations onStringValue
.All methods in this class are written to be optimized for efficiency and work directly on the StringValues char arrays, avoiding copies. For simplicity and efficiency, the methods only apply to strings whose characters are representable in a single char, ie. strings without surrogate characters.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StringValueUtils.WhitespaceTokenizer
A tokenizer for string values that uses whitespace characters as token delimiters.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
replaceNonWordChars(StringValue string, char replacement)
Replaces all non-word characters in a string by a given character.static void
toLowerCase(StringValue string)
Converts the givenStringValue
into a lower case variant.
-
-
-
Method Detail
-
toLowerCase
public static void toLowerCase(StringValue string)
Converts the givenStringValue
into a lower case variant.- Parameters:
string
- The string to convert to lower case.
-
replaceNonWordChars
public static void replaceNonWordChars(StringValue string, char replacement)
Replaces all non-word characters in a string by a given character. The only characters not replaced are the characters that qualify as word characters or digit characters with respect toCharacter.isLetter(char)
orCharacter.isDigit(char)
, as well as the underscore character.This operation is intended to simplify strings for counting distinct words.
- Parameters:
string
- The string value to have the non-word characters replaced.replacement
- The character to use as the replacement.
-
-