Class StringValueUtils


  • @PublicEvolving
    public final class StringValueUtils
    extends Object
    Utility class for efficient operations on StringValue.

    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.

    • Method Detail

      • toLowerCase

        public static void toLowerCase​(StringValue string)
        Converts the given StringValue 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 to Character.isLetter(char) or Character.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.