Class StrUtils


  • public class StrUtils
    extends Object
    Author:
    Jorge Campins
    • Constructor Detail

      • StrUtils

        public StrUtils()
    • Method Detail

      • digest

        public static String digest​(String credentials)
        Digest password or other credentials and convert the result to a corresponding hex string.
        Parameters:
        credentials - Password or other credentials
        Returns:
        the digested hex string. If exception, the plain credentials string is returned.
      • digest

        public static String digest​(String credentials,
                                    String algorithm)
        Digest password or other credentials and convert the result to a corresponding hex string.
        Parameters:
        credentials - Password or other credentials
        algorithm - Algorithm used to do the digest
        Returns:
        the digested hex string. If exception, the plain credentials string is returned.
      • digest

        public static String digest​(String credentials,
                                    String algorithm,
                                    String encoding)
        Digest password using the algorithm especified and convert the result to a corresponding hex string.
        Parameters:
        credentials - Password or other credentials
        algorithm - Algorithm used to do the digest
        encoding - Character encoding of the string to digest
        Returns:
        the digested hex string. If exception, the plain credentials string is returned.
      • ltrimToNull

        public static String ltrimToNull​(String s)
      • rtrimToNull

        public static String rtrimToNull​(String s)
      • allAreBlank

        public static boolean allAreBlank​(String... strings)
      • noneIsBlank

        public static boolean noneIsBlank​(String... strings)
      • notAllAreBlank

        public static boolean notAllAreBlank​(String... strings)
      • oneIsBlank

        public static boolean oneIsBlank​(String... strings)
      • equalsAny

        public static boolean equalsAny​(String string,
                                        String strings)
      • equalsAny

        public static boolean equalsAny​(String string,
                                        String... strings)
      • blankless

        public static String[] blankless​(String... strings)
      • coalesce

        public static String coalesce​(String... strings)
      • coalesceToDefault

        public static String coalesceToDefault​(String defaultString,
                                               String strings)
      • coalesceToDefault

        public static String coalesceToDefault​(String defaultString,
                                               String... strings)
      • coalesceToEmpty

        public static String coalesceToEmpty​(String strings)
      • coalesceToEmpty

        public static String coalesceToEmpty​(String... strings)
      • coalesceToNull

        public static String coalesceToNull​(String strings)
      • coalesceToNull

        public static String coalesceToNull​(String... strings)
      • getLongNumericKey

        public static String getLongNumericKey​(String string)
        Returns a long numeric key for string. See template opcion_menu.sql.vm
        Parameters:
        string - a string
        Returns:
        string's long numeric key
      • getRandomString

        public static String getRandomString()
      • getRandomString

        public static String getRandomString​(int length)
      • getSimpleString

        public static String getSimpleString​(Object obj)
      • getString

        public static String getString​(int n,
                                       char c)
      • getString

        public static String getString​(Object obj)
      • getStringDelimitado

        public static String getStringDelimitado​(Object obj)
      • getStringNoDelimitado

        public static String getStringNoDelimitado​(String delimitado)
      • getStringParametrizado

        public static String getStringParametrizado​(String patron,
                                                    Object... argumentos)
      • getStringSql

        public static String getStringSql​(Object obj)
      • getStringSqlDelimitado

        public static String getStringSqlDelimitado​(Object obj)
      • getStringSqlNoDelimitado

        public static String getStringSqlNoDelimitado​(Object obj)
      • getStringSqlParametrizado

        public static String getStringSqlParametrizado​(String patron,
                                                       Object... argumentos)
      • getNullStringWhenBlankOrEqualsToKey

        public static String getNullStringWhenBlankOrEqualsToKey​(String string,
                                                                 String key)
      • getNullStringWhenBlankOrEqualsToKey

        public static String getNullStringWhenBlankOrEqualsToKey​(String string,
                                                                 String key,
                                                                 String left,
                                                                 String right)
      • esIdentificadorSqlValido

        public static boolean esIdentificadorSqlValido​(String string)
      • esIdentificadorArchivoValido

        public static boolean esIdentificadorArchivoValido​(String string)
      • getIdentificadorSql

        public static String getIdentificadorSql​(String string,
                                                 int maxLength)
      • getIdentificadorSql

        public static String getIdentificadorSql​(String prefix,
                                                 String string,
                                                 String suffix,
                                                 int maxLength)
      • getIdentificadorSql

        public static String getIdentificadorSql​(String string)
      • getIdentificadorSqlLowerCase

        public static String getIdentificadorSqlLowerCase​(String string)
      • getIdentificadorSqlUpperCase

        public static String getIdentificadorSqlUpperCase​(String string)
      • getArtifactName

        public static String getArtifactName​(String string)
      • getArtifactName

        public static String getArtifactName​(String string,
                                             char separator)
      • getArtifactName

        public static String getArtifactName​(String string,
                                             String separator)
      • getIdentifier

        public static String getIdentifier​(String string)
      • getIdentifier

        public static String getIdentifier​(String string,
                                           char separator)
      • getIdentifier

        public static String getIdentifier​(String string,
                                           String separator)
      • getLowerCaseIdentifier

        public static String getLowerCaseIdentifier​(String string)
      • getLowerCaseIdentifier

        public static String getLowerCaseIdentifier​(String string,
                                                    char separator)
      • getLowerCaseIdentifier

        public static String getLowerCaseIdentifier​(String string,
                                                    String separator)
      • getUpperCaseIdentifier

        public static String getUpperCaseIdentifier​(String string)
      • getUpperCaseIdentifier

        public static String getUpperCaseIdentifier​(String string,
                                                    char separator)
      • getUpperCaseIdentifier

        public static String getUpperCaseIdentifier​(String string,
                                                    String separator)
      • getMavenIdentifier

        public static String getMavenIdentifier​(String string)
      • getMavenVersion

        public static String getMavenVersion​(String string)
      • getFileName

        public static String getFileName​(String string)
      • getQualifiedName

        public static String getQualifiedName​(String name,
                                              String qualifier)
      • getUnqualifiedName

        public static String getUnqualifiedName​(String name,
                                                String qualifier)
      • getQualifiedShortName

        public static String getQualifiedShortName​(String name,
                                                   String qualifier)
      • getUnqualifiedShortName

        public static String getUnqualifiedShortName​(String name,
                                                     String qualifier)
      • isASCII

        public static boolean isASCII​(char c)
      • isASCII

        public static boolean isASCII​(String string)
      • ascii

        public static String ascii​(String string)
        replaces all non-printable and control characters in a string with an underscore.
        Parameters:
        string - a string
        Returns:
        an ASCII string
      • ascii

        public static String ascii​(String string,
                                   char replacement)
        replaces all non-printable and control characters in a string with the specified replacement character.
        Parameters:
        string - a string
        replacement - replacement character
        Returns:
        an ASCII string
      • ascii

        public static String ascii​(String string,
                                   String replacement)
        replaces all non-printable and control characters in a string with the specified replacement string.
        Parameters:
        string - a string
        replacement - replacement string
        Returns:
        an ASCII string
      • diacriticless

        public static String diacriticless​(String string)
        replaces all characters with diacritical marks in a string with their corresponding letter.
        Parameters:
        string - a string
        Returns:
        a string without diacritical marks
      • diacriticlessAscii

        public static String diacriticlessAscii​(String string)
        replaces all characters with diacritical marks with their corresponding letter and all non-printable and control characters with an undersocre.
        Parameters:
        string - a string
        Returns:
        an ASCII string
      • diacriticlessAscii

        public static String diacriticlessAscii​(String string,
                                                String replacement)
        replaces all characters with diacritical marks with their corresponding letter and all non-printable and control characters with the specified replacement string.
        Parameters:
        string - a string
        replacement - replacement string
        Returns:
        an ASCII string
      • getStringAscii

        public static String getStringAscii​(String string)
      • getStringUtf8

        public static String getStringUtf8​(String string)
      • getCamelCase

        public static String getCamelCase​(String string)
      • getCamelCase

        public static String getCamelCase​(String string,
                                          boolean toLowerCaseLess)
      • getCamelCase

        public static String getCamelCase​(String string,
                                          String gap,
                                          boolean toLowerCaseLess)
      • getLowerCamelCase

        public static String getLowerCamelCase​(String string)
      • getUpperCamelCase

        public static String getUpperCamelCase​(String string)
      • getSpaceCamelCase

        public static String getSpaceCamelCase​(String string)
      • getHumplessCase

        public static String getHumplessCase​(String string)
      • getHumplessCase

        public static String getHumplessCase​(String string,
                                             char hump)
      • getLowerHumplessCase

        public static String getLowerHumplessCase​(String string)
      • getUpperHumplessCase

        public static String getUpperHumplessCase​(String string)
      • isMixedCase

        public static boolean isMixedCase​(String string)
      • isNotMixedCase

        public static boolean isNotMixedCase​(String string)
      • getWordyString

        public static String getWordyString​(String string)
      • getUnderscoreless

        public static String getUnderscoreless​(String string)
      • getStringHtml

        public static String getStringHtml​(String string)
      • getStringJava

        public static String getStringJava​(String string)
      • getStringXml

        public static String getStringXml​(String string)
      • escapeBundleKey

        public static String escapeBundleKey​(String string)
      • escapeMeta

        public static String escapeMeta​(String string)
      • escapeDoubleQuotes

        public static String escapeDoubleQuotes​(String string)
      • getToken

        public static String getToken​(String string)
      • getToken

        public static String getToken​(String string,
                                      int index)
      • getPatronParametrizado

        public static String getPatronParametrizado​(String string)
      • getParametros

        public static String[] getParametros​(String string)
      • getObjeto

        public static Object getObjeto​(String string)
      • newline

        public static char newline()
      • tab

        public static char tab()
      • tabs

        public static String tabs​(int n)
      • isDelimited

        public static boolean isDelimited​(String string,
                                          char delimiter)
      • isDelimited

        public static boolean isDelimited​(String string,
                                          String delimiter)
      • isDelimited

        public static boolean isDelimited​(String string,
                                          char open,
                                          char close)
      • isDelimited

        public static boolean isDelimited​(String string,
                                          char open,
                                          char close,
                                          char... quotes)
      • isDelimited

        public static boolean isDelimited​(String string,
                                          String open,
                                          String close)
      • isDelimited

        public static boolean isDelimited​(String string,
                                          String open,
                                          String close,
                                          char... quotes)
      • enclose

        public static String enclose​(String argument)
      • enclose

        public static String enclose​(String argument,
                                     char delimiter)
      • enclose

        public static String enclose​(String argument,
                                     char open,
                                     char close)
      • disclose

        public static String disclose​(String argument)
      • disclose

        public static String disclose​(String argument,
                                      char delimiter)
      • disclose

        public static String disclose​(String argument,
                                      char open,
                                      char close)
      • encloseSqlExpression

        public static String encloseSqlExpression​(String expression)
      • discloseSqlExpression

        public static String discloseSqlExpression​(String expression)
      • removeAfter

        public static String removeAfter​(String text,
                                         String search,
                                         String preceding)
        Removes all occurrences of a String within another String that are found after another String.
        Parameters:
        text - the String to search and remove in
        search - the String to search for
        preceding - the String used as lower boundary of the search; if it is null or empty, the search begins at the beginning of text
        Returns:
        the text with any removements processed
      • removeBefore

        public static String removeBefore​(String text,
                                          String search,
                                          String following)
        Removes all occurrences of a String within another String that are found before another String.
        Parameters:
        text - the String to search and remove in
        search - the String to search for
        following - the String used as upper boundary of the search; if it is null or empty, the search ends at the end of text
        Returns:
        the text with any removements processed
      • removeBetween

        public static String removeBetween​(String text,
                                           String search,
                                           String preceding,
                                           String following)
        Removes all occurrences of a String within another String that are found between another two Strings.
        Parameters:
        text - the String to search and remove in
        search - the String to search for
        preceding - the String used as lower boundary of the search; if it is null or empty, the search begins at the beginning of text
        following - the String used as upper boundary of the search; if it is null or empty, the search ends at the end of text
        Returns:
        the text with any removements processed
      • replaceAfter

        public static String replaceAfter​(String text,
                                          String search,
                                          String replacement,
                                          String preceding)
        Replaces all occurrences of a String within another String that are found after another String.
        Parameters:
        text - the String to search and replace in
        search - the String to search for
        replacement - the String to replace it with
        preceding - the String used as lower boundary of the search; if it is null or empty, the search begins at the beginning of text
        Returns:
        the text with any replacements processed
      • replaceBefore

        public static String replaceBefore​(String text,
                                           String search,
                                           String replacement,
                                           String following)
        Replaces all occurrences of a String within another String that are found before another String.
        Parameters:
        text - the String to search and replace in
        search - the String to search for
        replacement - the String to replace it with
        following - the String used as upper boundary of the search; if it is null or empty, the search ends at the end of text
        Returns:
        the text with any replacements processed
      • replaceBetween

        public static String replaceBetween​(String text,
                                            String search,
                                            String replacement,
                                            String preceding,
                                            String following)
        Replaces all occurrences of a String within another String that are found between another two Strings.
        Parameters:
        text - the String to search and replace in
        search - the String to search for
        replacement - the String to replace it with
        preceding - the String used as lower boundary of the search; if it is null or empty, the search begins at the beginning of text
        following - the String used as upper boundary of the search; if it is null or empty, the search ends at the end of text
        Returns:
        the text with any replacements processed
      • removeWords

        public static String removeWords​(String string,
                                         Class<?> dataType)
      • removeWords

        public static String removeWords​(String string,
                                         Class<?> dataType,
                                         char affixType)
      • removeWords

        public static String removeWords​(String string,
                                         Class<?> dataType,
                                         char affixType,
                                         String separator)
      • removeWords

        public static String removeWords​(String string,
                                         String remove,
                                         char affixType)
      • removeWholeWord

        public static String removeWholeWord​(String string,
                                             String remove)
      • removeWholeWord

        public static String removeWholeWord​(String string,
                                             String remove,
                                             char affixType)
      • removeWholeWord

        public static String removeWholeWord​(String string,
                                             String remove,
                                             char affixType,
                                             String separator)
      • replaceOnceRepeatedly

        public static String replaceOnceRepeatedly​(String text,
                                                   String searchString,
                                                   Object... replacements)