Class StringHelper


  • public class StringHelper
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isEmpty​(java.lang.CharSequence cs)
      Code copied 'as is' from apache-commons-lang3, class StringUtils.isEmpty()
      static boolean isIntegerNumber​(java.lang.String cs)
      Note that the method does not allow for a leading sign, either positive or negative.
      static boolean isNumeric​(java.lang.CharSequence cs)
      Code copied 'as is' from apache-commons-lang3, class StringUtils.isNumeric()
      • Methods inherited from class java.lang.Object

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

      • isIntegerNumber

        public static boolean isIntegerNumber​(java.lang.String cs)

        Note that the method does not allow for a leading sign, either positive or negative.

         StringUtils.isIntegerNumber(null)  = false
         StringHelper.isIntegerNumber(""))  = false
         StringHelper.isIntegerNumber(" ")  = false
         StringHelper.isIntegerNumber(" 1 ") = true
         StringHelper.isIntegerNumber("123")  = true
         StringUtils.isIntegerNumber("१२३")  = true
         StringHelper.isIntegerNumber("1.1") = false
         StringHelper.isIntegerNumber("1.1D") = false
         
        Parameters:
        cs - the String to check, may be null
        Returns:
        true if only contains digits or is enclosed by blanks, and is non-null
      • isNumeric

        public static boolean isNumeric​(java.lang.CharSequence cs)
        Code copied 'as is' from apache-commons-lang3, class StringUtils.isNumeric()

        Checks if the CharSequence contains only Unicode digits. A decimal point is not a Unicode digit and returns false.

        null will return false. An empty CharSequence (length()=0) will return false.

        Note that the method does not allow for a leading sign, either positive or negative. Also, if a String passes the numeric test, it may still generate a NumberFormatException when parsed by Integer.parseInt or Long.parseLong, e.g. if the value is outside the range for int or long respectively.

         StringUtils.isNumeric(null)   = false
         StringUtils.isNumeric("")     = false
         StringUtils.isNumeric("  ")   = false
         StringUtils.isNumeric("123")  = true
         StringUtils.isNumeric("१२३")  = true
         StringUtils.isNumeric("12 3") = false
         StringUtils.isNumeric("ab2c") = false
         StringUtils.isNumeric("12-3") = false
         StringUtils.isNumeric("12.3") = false
         StringUtils.isNumeric("-123") = false
         StringUtils.isNumeric("+123") = false
         
        Parameters:
        cs - the CharSequence to check, may be null
        Returns:
        true if only contains digits, and is non-null
      • isEmpty

        public static boolean isEmpty​(java.lang.CharSequence cs)
        Code copied 'as is' from apache-commons-lang3, class StringUtils.isEmpty()

        Checks if a CharSequence is empty ("") or null.

         StringUtils.isEmpty(null)      = true
         StringUtils.isEmpty("")        = true
         StringUtils.isEmpty(" ")       = false
         StringUtils.isEmpty("bob")     = false
         StringUtils.isEmpty("  bob  ") = false
         
        Parameters:
        cs - the CharSequence to check, may be null
        Returns:
        true if the CharSequence is empty or null