Package adalid.commons.util
Class StrUtils
- java.lang.Object
-
- adalid.commons.util.StrUtils
-
public class StrUtils extends Object
- Author:
- Jorge Campins
-
-
Field Summary
Fields Modifier and Type Field Description static StringVALID_CHARS
-
Constructor Summary
Constructors Constructor Description StrUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanallAreBlank(String... strings)static Stringascii(String string)replaces all non-printable and control characters in a string with an underscore.static Stringascii(String string, char replacement)replaces all non-printable and control characters in a string with the specified replacement character.static Stringascii(String string, String replacement)replaces all non-printable and control characters in a string with the specified replacement string.static String[]blankless(String... strings)static List<String>blankless(List<String> strings)static Set<String>blankless(Set<String> strings)static Stringcoalesce(String... strings)static StringcoalesceToDefault(String defaultString, String strings)static StringcoalesceToDefault(String defaultString, String... strings)static StringcoalesceToEmpty(String strings)static StringcoalesceToEmpty(String... strings)static StringcoalesceToNull(String strings)static StringcoalesceToNull(String... strings)static Stringdiacriticless(String string)replaces all characters with diacritical marks in a string with their corresponding letter.static StringdiacriticlessAscii(String string)replaces all characters with diacritical marks with their corresponding letter and all non-printable and control characters with an undersocre.static StringdiacriticlessAscii(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.static Stringdigest(String credentials)Digest password or other credentials and convert the result to a corresponding hex string.static Stringdigest(String credentials, String algorithm)Digest password or other credentials and convert the result to a corresponding hex string.static Stringdigest(String credentials, String algorithm, String encoding)Digest password using the algorithm especified and convert the result to a corresponding hex string.static Stringdisclose(String argument)static Stringdisclose(String argument, char delimiter)static Stringdisclose(String argument, char open, char close)static Stringdisclose(String argument, String delimiter)static Stringdisclose(String argument, String open, String close)static StringdiscloseSqlExpression(String expression)static Stringenclose(String argument)static Stringenclose(String argument, char delimiter)static Stringenclose(String argument, char open, char close)static Stringenclose(String argument, String delimiter)static Stringenclose(String argument, String open, String close)static StringencloseSqlExpression(String expression)static booleanequalsAny(String string, String strings)static booleanequalsAny(String string, String... strings)static StringescapeBundleKey(String string)static StringescapeDoubleQuotes(String string)static StringescapeMeta(String string)static booleanesIdentificadorArchivoValido(String string)static booleanesIdentificadorSqlValido(String string)static StringgetArtifactName(String string)static StringgetArtifactName(String string, char separator)static StringgetArtifactName(String string, String separator)static StringgetCamelCase(String string)static StringgetCamelCase(String string, boolean toLowerCaseLess)static StringgetCamelCase(String string, String gap)static StringgetCamelCase(String string, String gap, boolean toLowerCaseLess)static StringgetFileName(String string)static StringgetFileName(String string, String separator)static StringgetHumplessCase(String string)static StringgetHumplessCase(String string, char hump)static StringgetHumplessCase(String string, String hump)static StringgetIdentificadorSql(String string)static StringgetIdentificadorSql(String string, int maxLength)static StringgetIdentificadorSql(String prefix, String string, String suffix, int maxLength)static StringgetIdentificadorSqlLowerCase(String string)static StringgetIdentificadorSqlUpperCase(String string)static StringgetIdentifier(String string)static StringgetIdentifier(String string, char separator)static StringgetIdentifier(String string, String separator)static StringgetLongNumericCode(String string)Returns a long numeric code for string.static StringgetLongNumericKey(String string)Returns a long numeric key for string.static StringgetLongNumericKeyCode(String string)Returns a long numeric key code for string.static StringgetLowerCamelCase(String string)static StringgetLowerCaseIdentifier(String string)static StringgetLowerCaseIdentifier(String string, char separator)static StringgetLowerCaseIdentifier(String string, String separator)static StringgetLowerHumplessCase(String string)static StringgetMavenIdentifier(String string)static StringgetMavenVersion(String string)static StringgetNullStringWhenBlankOrEqualsToKey(String string, String key)static StringgetNullStringWhenBlankOrEqualsToKey(String string, String key, String left, String right)static ObjectgetObjeto(String string)static ObjectgetObjeto(String string, Class<?> clazz)static ObjectgetObjeto(String string, String clazz)static String[]getParametros(String string)static StringgetPatronParametrizado(String string)static StringgetQualifiedName(String name, String qualifier)static StringgetQualifiedShortName(String name, String qualifier)static StringgetRandomString()static StringgetRandomString(int length)static StringgetSimpleString(Object obj)static StringgetSpaceCamelCase(String string)static StringgetString(int n, char c)static StringgetString(Object obj)static StringgetString(String equals, String separator, String open, String close, Object object)static StringgetString(String equals, String separator, String open, String close, Object... objects)static StringgetString(ResourceBundle resourceBundle, String key)static StringgetString(ResourceBundle resourceBundle, String key, String left, String right)static StringgetStringAscii(String string)static StringgetStringDelimitado(Object obj)static StringgetStringHtml(String string)static StringgetStringJava(String string)static StringgetStringNoDelimitado(String delimitado)static StringgetStringParametrizado(String patron, Object... argumentos)static StringgetStringSql(Object obj)static StringgetStringSqlDelimitado(Object obj)static StringgetStringSqlNoDelimitado(Object obj)static StringgetStringSqlParametrizado(String patron, Object... argumentos)static StringgetStringUtf8(String string)static StringgetStringXml(String string)static StringgetToken(String string)static StringgetToken(String string, int index)static StringgetToken(String string, int index, String regex)static StringgetToken(String string, String regex)static StringgetUnderscoreless(String string)static StringgetUnqualifiedName(String name, String qualifier)static StringgetUnqualifiedShortName(String name, String qualifier)static StringgetUpperCamelCase(String string)static StringgetUpperCaseIdentifier(String string)static StringgetUpperCaseIdentifier(String string, char separator)static StringgetUpperCaseIdentifier(String string, String separator)static StringgetUpperHumplessCase(String string)static StringgetWordyString(String string)static booleanisASCII(char c)static booleanisASCII(String string)static booleanisDelimited(String string, char delimiter)static booleanisDelimited(String string, char open, char close)static booleanisDelimited(String string, char open, char close, char... quotes)static booleanisDelimited(String string, String delimiter)static booleanisDelimited(String string, String open, String close)static booleanisDelimited(String string, String open, String close, char... quotes)static booleanisMixedCase(String string)static booleanisNotMixedCase(String string)static Stringltrim(String s)static StringltrimToNull(String s)static charnewline()static booleannoneIsBlank(String... strings)static booleannotAllAreBlank(String... strings)static booleanoneIsBlank(String... strings)static StringremoveAfter(String text, String search, String preceding)Removes all occurrences of a String within another String that are found after another String.static StringremoveBefore(String text, String search, String following)Removes all occurrences of a String within another String that are found before another String.static StringremoveBetween(String text, String search, String preceding, String following)Removes all occurrences of a String within another String that are found between another two Strings.static StringremoveWholeWord(String string, String remove)static StringremoveWholeWord(String string, String remove, char affixType)static StringremoveWholeWord(String string, String remove, char affixType, String separator)static StringremoveWholeWord(String string, String remove, String separator)static StringremoveWords(String string, Class<?> dataType)static StringremoveWords(String string, Class<?> dataType, char affixType)static StringremoveWords(String string, Class<?> dataType, char affixType, String separator)static StringremoveWords(String string, Class<?> dataType, String separator)static StringremoveWords(String string, String remove)static StringremoveWords(String string, String remove, char affixType)static StringremoveWords(String string, String remove, char affixType, String separator)static StringremoveWords(String string, String remove, String separator)static StringreplaceAfter(String text, String search, String replacement, String preceding)Replaces all occurrences of a String within another String that are found after another String.static StringreplaceBefore(String text, String search, String replacement, String following)Replaces all occurrences of a String within another String that are found before another String.static StringreplaceBetween(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.static StringreplaceOnceRepeatedly(String text, String searchString, Object... replacements)static Stringrtrim(String s)static StringrtrimToNull(String s)static chartab()static Stringtabs(int n)static StringtoString(Object obj)
-
-
-
Field Detail
-
VALID_CHARS
public static final String VALID_CHARS
- See Also:
- Constant Field Values
-
-
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 credentialsalgorithm- 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 credentialsalgorithm- Algorithm used to do the digestencoding- Character encoding of the string to digest- Returns:
- the digested hex string. If exception, the plain credentials string is returned.
-
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)
-
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
-
getLongNumericCode
public static String getLongNumericCode(String string)
Returns a long numeric code for string.- Parameters:
string- a string- Returns:
- string's long numeric code
- See Also:
LongUtils.getNewId(java.lang.String)
-
getLongNumericKeyCode
public static String getLongNumericKeyCode(String string)
Returns a long numeric key code for string.- Parameters:
string- a string- Returns:
- string's long numeric key code
- See Also:
ProyectoBase.getEntityNumber(java.lang.String),ProyectoBase.getEntityParameterNumber(java.lang.String),ProyectoBase.getOperationNumber(java.lang.String),ProyectoBase.getOperationParameterNumber(java.lang.String),ProyectoBase.getPageNumber(java.lang.String),ProyectoBase.getParameterNumber(java.lang.String)
-
getRandomString
public static String getRandomString()
-
getRandomString
public static String getRandomString(int length)
-
getString
public static String getString(int n, char c)
-
getStringParametrizado
public static String getStringParametrizado(String patron, Object... argumentos)
-
getStringSqlParametrizado
public static String getStringSqlParametrizado(String patron, Object... argumentos)
-
getString
public static String getString(ResourceBundle resourceBundle, String key)
-
getString
public static String getString(ResourceBundle resourceBundle, String key, String left, String right)
-
getString
public static String getString(String equals, String separator, String open, String close, Object object)
-
getString
public static String getString(String equals, String separator, String open, String close, Object... objects)
-
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 prefix, String string, String suffix, int maxLength)
-
getLowerCaseIdentifier
public static String getLowerCaseIdentifier(String string, String separator)
-
getUpperCaseIdentifier
public static String getUpperCaseIdentifier(String string, String separator)
-
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 stringreplacement- 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 stringreplacement- 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 stringreplacement- replacement string- Returns:
- an ASCII string
-
isMixedCase
public static boolean isMixedCase(String string)
-
isNotMixedCase
public static boolean isNotMixedCase(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, 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, char... quotes)
-
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 insearch- the String to search forpreceding- 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 insearch- the String to search forfollowing- 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 insearch- the String to search forpreceding- the String used as lower boundary of the search; if it is null or empty, the search begins at the beginning of textfollowing- 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 insearch- the String to search forreplacement- the String to replace it withpreceding- 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 insearch- the String to search forreplacement- the String to replace it withfollowing- 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 insearch- the String to search forreplacement- the String to replace it withpreceding- the String used as lower boundary of the search; if it is null or empty, the search begins at the beginning of textfollowing- 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, char affixType, String separator)
-
removeWords
public static String removeWords(String string, String remove, char affixType, String separator)
-
removeWholeWord
public static String removeWholeWord(String string, String remove, String separator)
-
removeWholeWord
public static String removeWholeWord(String string, String remove, char affixType, String separator)
-
-