Class StringUtils


  • public class StringUtils
    extends java.lang.Object
    Version:
    July 18, 2017
    Author:
    Javier Rojas Blum
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void addQueryStringParam​(java.lang.StringBuilder queryStringBuilder, java.lang.String key, java.lang.Object value)  
      static void addQueryStringParam​(java.lang.StringBuilder queryStringBuilder, java.lang.String key, java.util.Collection<?> value)  
      static java.lang.String base64urlencode​(java.lang.String string)  
      static boolean equals​(java.lang.String str1, java.lang.String str2)
      Deprecated.
      it is possible to use directly: org.apache.commons.lang.StringUtils.equals(str1, str2);
      static boolean equalsIgnoringSpaces​(java.lang.String a, java.lang.String b)  
      static java.lang.String generateRandomCode​(byte seedLength)
      Generates a random code using a byte array as its seed.
      static java.lang.String generateRandomReadableCode​(byte length)
      Generates a code using a base of 20 characters easy to read for users, using parametrized length separated by dashes with intervals of 4 characters.
      static java.lang.String implode​(java.lang.String[] inputArray, java.lang.String glueString)
      Method to join array elements of type string
      static java.lang.String implode​(java.util.Collection<? extends java.lang.Object> collection, java.lang.String glueString)
      Method to join a list of elements of type string
      static java.lang.String implodeEnum​(java.util.List<? extends HasParamName> inputList, java.lang.String glueString)  
      static java.lang.String nullToEmpty​(java.lang.String str)  
      static java.util.Date parseSilently​(java.lang.String string)  
      static java.util.List<java.lang.String> spaceSeparatedToList​(java.lang.String spaceSeparatedString)  
      static org.json.JSONArray toJSONArray​(java.util.List<? extends java.lang.Object> inputList)  
      static java.util.List<java.lang.String> toList​(org.json.JSONArray jsonArray)  
      • Methods inherited from class java.lang.Object

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

      • nullToEmpty

        public static java.lang.String nullToEmpty​(java.lang.String str)
      • equals

        @Deprecated
        public static boolean equals​(java.lang.String str1,
                                     java.lang.String str2)
        Deprecated.
        it is possible to use directly: org.apache.commons.lang.StringUtils.equals(str1, str2);
        Check if first and second String Params are equals, even if both are null.
        Parameters:
        str1 - first String param
        str2 - second String param
        Returns:
        true if both are null, true if both are equals, false in other cases
      • equalsIgnoringSpaces

        public static boolean equalsIgnoringSpaces​(java.lang.String a,
                                                   java.lang.String b)
      • implode

        public static java.lang.String implode​(java.lang.String[] inputArray,
                                               java.lang.String glueString)
        Method to join array elements of type string
        Parameters:
        inputArray - Array which contains strings
        glueString - String between each array element
        Returns:
        String containing all array elements separated by glue string.
      • implode

        public static java.lang.String implode​(java.util.Collection<? extends java.lang.Object> collection,
                                               java.lang.String glueString)
        Method to join a list of elements of type string
        Parameters:
        collection - List which contains strings
        glueString - String between each array element
        Returns:
        String containing all array elements separated by glue string.
      • implodeEnum

        public static java.lang.String implodeEnum​(java.util.List<? extends HasParamName> inputList,
                                                   java.lang.String glueString)
      • spaceSeparatedToList

        public static java.util.List<java.lang.String> spaceSeparatedToList​(java.lang.String spaceSeparatedString)
      • toJSONArray

        public static org.json.JSONArray toJSONArray​(java.util.List<? extends java.lang.Object> inputList)
      • toList

        public static java.util.List<java.lang.String> toList​(org.json.JSONArray jsonArray)
                                                       throws org.json.JSONException
        Throws:
        org.json.JSONException
      • parseSilently

        public static java.util.Date parseSilently​(java.lang.String string)
      • addQueryStringParam

        public static void addQueryStringParam​(java.lang.StringBuilder queryStringBuilder,
                                               java.lang.String key,
                                               java.lang.Object value)
                                        throws java.io.UnsupportedEncodingException
        Throws:
        java.io.UnsupportedEncodingException
      • addQueryStringParam

        public static void addQueryStringParam​(java.lang.StringBuilder queryStringBuilder,
                                               java.lang.String key,
                                               java.util.Collection<?> value)
                                        throws java.io.UnsupportedEncodingException
        Throws:
        java.io.UnsupportedEncodingException
      • generateRandomReadableCode

        public static java.lang.String generateRandomReadableCode​(byte length)
        Generates a code using a base of 20 characters easy to read for users, using parametrized length separated by dashes with intervals of 4 characters.
      • generateRandomCode

        public static java.lang.String generateRandomCode​(byte seedLength)
        Generates a random code using a byte array as its seed.
        Parameters:
        seedLength - Length of the byte array
      • base64urlencode

        public static java.lang.String base64urlencode​(java.lang.String string)