Class StringUtil


  • public final class StringUtil
    extends Object
    Escapes/unescapes strings
    • Method Detail

      • quote

        public static String quote​(Object o,
                                   char leftHandChar)
      • toHexString

        public static String toHexString​(byte theByte)
      • toHexString

        public static String toHexString​(byte[] bytes)
      • toHexString

        public static String toHexString​(byte[] bytes,
                                         String delim)
      • upperCaseFirstLetter

        public static String upperCaseFirstLetter​(String s)
      • toString

        public static String toString​(String[] args)
      • toString

        public static String toString​(String delim,
                                      Object... args)
        Turn an array (or varargs) set of Objects into a String using the specified delimiter.
      • getPrefix

        public static String getPrefix​(Set<String> prefixes,
                                       String s)
        Returns:
        the prefix found, or null if not found
      • getSecondsString

        public static String getSecondsString​(long nanos)
        Parameters:
        nanos - elapsed nanoseconds
        Returns:
        a String describing the elapsed duration in seconds
      • getMillisString

        public static String getMillisString​(long nanos)
        Parameters:
        nanos - elapsed nanoseconds
        Returns:
        a String describing the elapsed duration in seconds
      • getTimingString

        public static String getTimingString​(long nanos,
                                             TimeUnit timeUnit)
      • getTimingString

        public static String getTimingString​(long nanos)
        Get a String representing the specified number of nanoseconds, choosing the appropriate units based on magnitude of the value.
        Parameters:
        nanos - elapsed nanoseconds
        Returns:
        a String describing the elapsed duration
      • toStringArray

        public static <T> String[] toStringArray​(Collection<T> c)
        Returns:
        String[]
      • toStringArray

        public static String[] toStringArray​(Object[] items)
      • objectNamesToStrings

        public static List<String> objectNamesToStrings​(Collection<ObjectName> objectNames)
        Convert ObjectName into a Set of String. The resulting strings are more readable than just a simple toString() on the ObjectName; they are sorted and output in preferential order.
      • objectNamesToStrings

        public static String[] objectNamesToStrings​(ObjectName[] objectNames)
        Convert a Set of ObjectName into a Set of String