Class StringUtils


  • public class StringUtils
    extends Object

    StringUtils: utility class of String utilities.

    • Constructor Summary

      Constructors 
      Constructor Description
      StringUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean equals​(String s1, String s2)
      Checks if 2 strings are equals, accounting for null cases.
      static int fastStringHash​(String contextStr)  
      static String getOrDefault​(String s, String defaultString)
      Returns string s, or defaultString if s is null.
      static String intToHexStr​(int value, int strLen)  
      static String intToStr​(int value, int strLen)  
      static boolean isEmpty​(String s)
      Checks if string is empty, handling null String case.
      static int length​(String s)
      Returns string length, handling null String case as length of 0.
      static String longToHexStr​(long value, int strLen)  
      static String longToStr​(long value, int strLen)  
      static String stampToString​(long stamp)
      Convert a duration (milliseconds) to a formatted string.
      static String stampToStringNoUnits​(long stamp)
      Convert a duration (milliseconds) to a formatted string.
      static long stringToMilliseconds​(String stamp)
      Convert a hh:mm:ss.SSS string to milliseconds No validation that hh:mm:ss are valid ranges
      static String toStringList​(WMSProperties properties)
      Convert properties to comma-separated string
      static String toStringList​(String[] strings)
      Convert array of Strings to comma-separated string
      static String toStringList​(java.util.List<String> strings)
      Convert list of Strings to comma-separated string
      static String valueOf​(String s)
      Returns string, handling null String case as "".
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StringUtils

        public StringUtils()
    • Method Detail

      • intToStr

        public static String intToStr​(int value,
                                      int strLen)
      • intToHexStr

        public static String intToHexStr​(int value,
                                         int strLen)
      • longToStr

        public static String longToStr​(long value,
                                       int strLen)
      • longToHexStr

        public static String longToHexStr​(long value,
                                          int strLen)
      • isEmpty

        public static boolean isEmpty​(String s)
        Checks if string is empty, handling null String case.
        Parameters:
        s -
        Returns:
        false is string is null or "", true otherwise
      • length

        public static int length​(String s)
        Returns string length, handling null String case as length of 0.
        Parameters:
        s -
        Returns:
        0 if string is null, or length of string.
      • valueOf

        public static String valueOf​(String s)
        Returns string, handling null String case as "".
        Parameters:
        s -
        Returns:
        "" if string is null, or string value.
      • getOrDefault

        public static String getOrDefault​(String s,
                                          String defaultString)
        Returns string s, or defaultString if s is null.
        Parameters:
        s -
        defaultString -
        Returns:
        "" if string is null, or string value.
      • stampToString

        public static String stampToString​(long stamp)
        Convert a duration (milliseconds) to a formatted string.
        Parameters:
        stamp - duration (milliseconds)
        Returns:
        formatted string (example: 3 days 4 minutes 1 seconds)
      • stampToStringNoUnits

        public static String stampToStringNoUnits​(long stamp)
        Convert a duration (milliseconds) to a formatted string.
        Parameters:
        stamp - duration (milliseconds)
        Returns:
        formatted string (example: 03:04:01.123 hours:minutes:seconds.miliseconds)
      • stringToMilliseconds

        public static long stringToMilliseconds​(String stamp)
        Convert a hh:mm:ss.SSS string to milliseconds No validation that hh:mm:ss are valid ranges
        Parameters:
        stamp - string (hours:minutes:seconds.miliseconds)
        Returns:
        milliseconds, -1 is parse failed
      • equals

        public static boolean equals​(String s1,
                                     String s2)
        Checks if 2 strings are equals, accounting for null cases. If both are null, they are considered equal.
        Parameters:
        s1 - string one
        s2 - string 2
        Returns:
        true is the strings are equal
      • toStringList

        public static String toStringList​(WMSProperties properties)
        Convert properties to comma-separated string
        Parameters:
        properties -
        Returns:
        comma-separated string
      • toStringList

        public static String toStringList​(java.util.List<String> strings)
        Convert list of Strings to comma-separated string
        Parameters:
        strings -
        Returns:
        comma-separated string
      • toStringList

        public static String toStringList​(String[] strings)
        Convert array of Strings to comma-separated string
        Parameters:
        strings -
        Returns:
        comma-separated string
      • fastStringHash

        public static int fastStringHash​(String contextStr)