Class StringUtilities

java.lang.Object
com.yahoo.text.StringUtilities

public class StringUtilities extends Object
Escapes strings into and out of a format where they only contain printable characters. Need to duplicate escape / unescape of strings as we have in C++ for java version of system states.
Author:
Haakon Humberset
  • Constructor Details

    • StringUtilities

      public StringUtilities()
  • Method Details

    • escape

      public static String escape(String source)
    • escape

      public static String escape(String source, char delimiter)
      Escapes strings into a format with only printable ASCII characters.
      Parameters:
      source - The string to escape
      delimiter - Escape this character too, even if it is printable.
      Returns:
      The escaped string
    • unescape

      public static String unescape(String source)
    • implode

      public static String implode(String[] array, String sepString)
      Returns the given array flattened to string, with the given separator string
      Parameters:
      array - the array
      sepString - or null
      Returns:
      imploded array
    • implodeMultiline

      public static String implodeMultiline(List<String> lines)
      Returns the given list flattened to one with newline between
      Returns:
      flattened string
    • truncateSequencesIfNecessary

      public static String truncateSequencesIfNecessary(String text, int maxConsecutiveLength)
      This will truncate sequences in a string of the same character that exceed the maximum allowed length.
      Returns:
      The same string or a new one if truncation is done.
    • stripSuffix

      public static String stripSuffix(String string, String suffix)
    • quote

      public static String quote(Object object)
      Adds single quotes around object.toString Example: '12'
    • split

      public static Set<String> split(String s)
      Splits a string on both space and comma