Class StringUtils


  • public final class StringUtils
    extends java.lang.Object
    Utility methods on string objects.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.regex.Pattern decimalPattern
      A pattern to match on a signed integer value.
      private static java.lang.IllegalArgumentException KEY_EMPTY_EXCEPTION
      Exception thrown if the input key is empty.
      private static java.lang.IllegalArgumentException KEY_TOO_LONG_EXCEPTION
      Exception thrown if the input key is too long.
      private static int MAX_KEY_LENGTH
      Maximum supported key length.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private StringUtils()
      Private constructor, since this is a purely static class.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isJsonObject​(java.lang.String s)
      Check if a given string is a JSON object.
      static java.lang.String join​(java.util.Collection<java.lang.String> chunks, java.lang.String delimiter)
      Join a collection of strings together into one.
      static void validateKey​(java.lang.String key, boolean binary)
      Check if a given key is valid to transmit.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • decimalPattern

        private static final java.util.regex.Pattern decimalPattern
        A pattern to match on a signed integer value.
      • MAX_KEY_LENGTH

        private static final int MAX_KEY_LENGTH
        Maximum supported key length.
        See Also:
        Constant Field Values
      • KEY_TOO_LONG_EXCEPTION

        private static final java.lang.IllegalArgumentException KEY_TOO_LONG_EXCEPTION
        Exception thrown if the input key is too long.
      • KEY_EMPTY_EXCEPTION

        private static final java.lang.IllegalArgumentException KEY_EMPTY_EXCEPTION
        Exception thrown if the input key is empty.
    • Constructor Detail

      • StringUtils

        private StringUtils()
        Private constructor, since this is a purely static class.
    • Method Detail

      • join

        public static java.lang.String join​(java.util.Collection<java.lang.String> chunks,
                                            java.lang.String delimiter)
        Join a collection of strings together into one.
        Parameters:
        chunks - the chunks to join.
        delimiter - the delimiter between the keys.
        Returns:
        the fully joined string.
      • isJsonObject

        public static boolean isJsonObject​(java.lang.String s)
        Check if a given string is a JSON object.
        Parameters:
        s - the input string.
        Returns:
        true if it is a JSON object, false otherwise.
      • validateKey

        public static void validateKey​(java.lang.String key,
                                       boolean binary)
        Check if a given key is valid to transmit.
        Parameters:
        key - the key to check.
        binary - if binary protocol is used.