Package adalid.commons.util
Class StrUtils
java.lang.Object
adalid.commons.util.StrUtils
- Author:
- Jorge Campins
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanallAreBlank(String... strings) static Stringreplaces all non-printable and control characters in a string with an underscore.static Stringreplaces all non-printable and control characters in a string with the specified replacement character.static Stringreplaces all non-printable and control characters in a string with the specified replacement string.static String[]static Stringstatic 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 Stringstatic 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 password or other credentials and convert the result to a corresponding hex string.static StringDigest password or other credentials and convert the result to a corresponding hex string.static StringDigest password using the algorithm especified and convert the result to a corresponding hex string.static Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic StringdiscloseSqlExpression(String expression) static Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic StringencloseSqlExpression(String expression) static Stringstatic booleanstatic booleanstatic StringescapeBundleKey(String string) static StringescapeDoubleQuotes(String string) static StringescapeMeta(String string) static StringescapeSlashedChars(String string) static booleanesIdentificadorArchivoValido(String string) static booleanesIdentificadorSqlValido(String string) static charfirstWordCase(String string) This method inspects the characters in the first word of the string.static Stringstatic 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 StringgetCrypticName(String prefix, String string, String suffix) 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 StringgetLowerSnakeCase(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 Objectstatic Objectstatic Objectstatic StringgetOracleVersionNumber(String string) static StringgetPageName(String url) static String[]getParametros(String string) static StringgetPatronParametrizado(String string) static StringgetQualifiedName(String name, String qualifier) static StringgetQualifiedShortName(String name, String qualifier) static Stringstatic StringgetRandomString(int length) static StringgetSha256Base36(String string) static StringgetSimpleString(Object obj) static StringgetSnakeCase(String string) static StringgetSnakeCase(String string, char hump) static StringgetSnakeCase(String string, String hump) static StringgetSpaceCamelCase(String string) static StringgetString(int n, char c) static Stringstatic Stringstatic Stringstatic StringgetString(ResourceBundle resourceBundle, String key) static StringgetString(ResourceBundle resourceBundle, String key, String left, String right) static StringgetStringAscii(String string) static Stringstatic StringgetStringHtml(String string) static StringgetStringJava(String string) static StringgetStringJson(String key, Object value) static StringgetStringNoDelimitado(String delimitado) static StringgetStringParametrizado(String patron, Object... argumentos) static StringgetStringSql(Object obj) static Stringstatic Stringstatic StringgetStringSqlParametrizado(String patron, Object... argumentos) static StringgetStringStandard(Object obj) static StringgetStringUtf8(String string) static StringgetStringXml(String string) static StringgetSubString(Clob clob) static Stringstatic Stringstatic Stringstatic Stringstatic 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 StringgetUpperSnakeCase(String string) static StringgetWordyString(String string) static booleanisASCII(char c) static booleanstatic 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 Stringstatic Stringstatic 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 StringremoveWord(String string, String remove) 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 StringReplaces all occurrences of a String within another String that are found between another two Strings.static StringreplaceOnceRepeatedly(String text, String searchString, Object... replacements) static Stringstatic Stringstatic StringseparateLines(String string, int maxLineLength) static StringseparateLines(String string, int maxLineLength, String separator) static StringseparateLines(String string, int maxLineLength, String separator, boolean separatorLine) split a text into a list of lines.static chartab()static Stringtabs(int n) static Stringstatic StringuniteWords(String string1, String string2)
-
Field Details
-
VALID_CHARS
- See Also:
-
MAX_STRING_LENGTH
public static final int MAX_STRING_LENGTH- See Also:
-
-
Constructor Details
-
StrUtils
public StrUtils()
-
-
Method Details
-
digest
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
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
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.
-
getCrypticName
-
getSha256Base36
-
uniteWords
-
separateLines
-
separateLines
-
separateLines
-
split
-
split
-
split
-
split
-
split
public static List<String> split(String string, int max, String separator, boolean separatorLine, String prefix) split a text into a list of lines.- Parameters:
string- the text to split.max- the maximum line length.separator- the paragraph separator string.separatorLine- if true, the paragraph separator is added as a line between paragraphs.prefix- the new line prefix- Returns:
- the list of split.
-
ltrim
-
ltrimToNull
-
rtrim
-
rtrimToNull
-
format
-
getStringJson
-
toString
-
allAreBlank
-
noneIsBlank
-
notAllAreBlank
-
oneIsBlank
-
equalsAny
-
equalsAny
-
blankless
-
blankless
-
blankless
-
coalesce
-
coalesceToDefault
-
coalesceToDefault
-
coalesceToEmpty
-
coalesceToEmpty
-
coalesceToNull
-
coalesceToNull
-
getLongNumericKey
Returns a long numeric key for string. See template opcion_menu.sql.vm- Parameters:
string- a string- Returns:
- string's long numeric key
-
getLongNumericCode
Returns a long numeric code for string.- Parameters:
string- a string- Returns:
- string's long numeric code
- See Also:
-
getLongNumericKeyCode
Returns a long numeric key code for string.- Parameters:
string- a string- Returns:
- string's long numeric key code
-
firstWordCase
This method inspects the characters in the first word of the string. The first word ends with the first character that is not a letter, a digit, a hyphen, or an underscore; if the string contains only those characters, the first word is the entire string.- Parameters:
string- the string to inspect- Returns:
- one of the following characters:
- ? if the string is null or empty
- M if the first word contains both lowercase and uppercase letters
- L if the first word contains only lowercase letters
- U if the first word contains only uppercase letters
- X if the first word contains at least one character that is not a letter (a digit, a hyphen, or an underscore)
-
getRandomString
-
getRandomString
-
getSimpleString
-
getString
-
getString
-
getSubString
-
getStringDelimitado
-
getStringNoDelimitado
-
getStringParametrizado
-
getStringStandard
-
getStringSql
-
getStringSqlDelimitado
-
getStringSqlNoDelimitado
-
getStringSqlParametrizado
-
getString
-
getString
public static String getString(ResourceBundle resourceBundle, String key, String left, String right) -
getString
-
getString
-
getNullStringWhenBlankOrEqualsToKey
-
getNullStringWhenBlankOrEqualsToKey
-
esIdentificadorSqlValido
-
esIdentificadorArchivoValido
-
getIdentificadorSql
-
getIdentificadorSql
-
getIdentificadorSql
-
getIdentificadorSqlLowerCase
-
getIdentificadorSqlUpperCase
-
getArtifactName
-
getArtifactName
-
getArtifactName
-
getIdentifier
-
getIdentifier
-
getIdentifier
-
getLowerCaseIdentifier
-
getLowerCaseIdentifier
-
getLowerCaseIdentifier
-
getUpperCaseIdentifier
-
getUpperCaseIdentifier
-
getUpperCaseIdentifier
-
getMavenIdentifier
-
getMavenVersion
-
getOracleVersionNumber
-
getFileName
-
getFileName
-
getPageName
-
getQualifiedName
-
getUnqualifiedName
-
getQualifiedShortName
-
getUnqualifiedShortName
-
isASCII
public static boolean isASCII(char c) -
isASCII
-
ascii
replaces all non-printable and control characters in a string with an underscore.- Parameters:
string- a string- Returns:
- an ASCII string
-
ascii
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
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
replaces all characters with diacritical marks in a string with their corresponding letter.- Parameters:
string- a string- Returns:
- a string without diacritical marks
-
diacriticlessAscii
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
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
-
getStringAscii
-
getStringUtf8
-
encode
-
decode
-
getCamelCase
-
getCamelCase
-
getCamelCase
-
getCamelCase
-
getLowerCamelCase
-
getUpperCamelCase
-
getSpaceCamelCase
-
getSnakeCase
-
getSnakeCase
-
getSnakeCase
-
getLowerSnakeCase
-
getUpperSnakeCase
-
getHumplessCase
-
getHumplessCase
-
getHumplessCase
-
getLowerHumplessCase
-
getUpperHumplessCase
-
isMixedCase
-
isNotMixedCase
-
getWordyString
-
getUnderscoreless
-
getStringHtml
-
getStringJava
-
getStringXml
-
escapeBundleKey
-
escapeMeta
-
escapeDoubleQuotes
-
escapeSlashedChars
-
getToken
-
getToken
-
getToken
-
getToken
-
getPatronParametrizado
-
getParametros
-
getObjeto
-
getObjeto
-
getObjeto
-
newline
public static char newline() -
tab
public static char tab() -
tabs
-
isDelimited
-
isDelimited
-
isDelimited
-
isDelimited
-
isDelimited
-
isDelimited
-
enclose
-
enclose
-
enclose
-
enclose
-
enclose
-
disclose
-
disclose
-
disclose
-
disclose
-
disclose
-
encloseSqlExpression
-
discloseSqlExpression
-
removeAfter
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
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
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
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
-
removeWords
-
removeWords
-
removeWords
-
removeWord
-
removeWords
-
removeWords
-
removeWords
-
removeWords
-
removeWholeWord
-
removeWholeWord
-
removeWholeWord
-
removeWholeWord
-
replaceOnceRepeatedly
-