|
Anyframe Core | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectanyframe.common.util.StringUtil
public abstract class StringUtil
String Utility Class
| Method Summary | |
|---|---|
static boolean |
containsInvalidChars(String str,
char[] invalidChars)
Checks that the String contains certain characters. |
static boolean |
containsInvalidChars(String str,
String invalidChars)
Checks that the String contains certain characters. |
static boolean |
containsMaxSequence(String str,
String maxSeqNumber)
It returns true if string contains a sequence of the same character. |
static String |
convertToCamelCase(String underScore)
Convert a string that may contain underscores to camel case. |
static String |
convertToCamelCase(String targetString,
char posChar)
This method convert "string_util" to "stringUtil" |
static String |
convertToUnderScore(String camelCase)
Convert a camel case string to underscore representation. |
static String |
decodeString(String str)
Decode a string using Base64 encoding. |
static String |
encodePassword(String password,
String algorithm)
Encode a string using algorithm specified in web.xml and return the resulting encrypted password. |
static String |
encodeString(String str)
Encode a string using Base64 encoding. |
static String |
fillString(String originalStr,
char ch,
int cipers)
Make a new String that filled original to a special char as cipers |
static String |
getLastString(String origStr,
String strToken)
Break a string into specific tokens and return a String of last location. |
static String[] |
getStringArray(String str,
String strToken)
If original String has token, Break a string into specific tokens and change String Array. |
static List |
getTokens(String lst)
Return token list which is separated by "," |
static List |
getTokens(String lst,
String separator)
Return token list |
static String |
integer2string(int integer)
It converts integer type to String ( 27 -> '27') StringUtil.integer2string(14) = '14' |
static boolean |
isAlpha(String str)
Checks if the String contains only unicode letters. |
static boolean |
isAlphaNumeric(String str)
Checks if the String contains only unicode letters or digits. |
static boolean |
isEmpty(String str)
If string is null or empty string, return true. |
static boolean |
isEmptyTrimmed(String foo)
Determine whether a (trimmed) string is empty |
static boolean |
isNotEmpty(String str)
If string is null or empty string, return false. |
static boolean |
isNumeric(String str)
Checks if the String contains only unicode digits. |
static boolean |
isPatternMatching(String str,
String pattern)
It returns true if str matches the pattern string. |
static String |
replace(String str,
String replacedStr,
String replaceStr)
replace replaced string to specific string from original string. |
static String |
reverse(String str)
Reverses a String as per StringBuffer.reverse(). |
static int |
string2integer(String str)
It converts the string representation of a number to integer type (eg |
static String |
swapFirstLetterCase(String str)
convert first letter to a big letter or a small letter. |
static String |
trim(String origString,
String trimString)
If original String has a specific String, remove specific Strings from original String. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String encodePassword(String password,
String algorithm)
password - Password or other credentials to use in authenticating this
usernamealgorithm - Algorithm used to do the digest
public static String encodeString(String str)
str - String to be encoded
public static String decodeString(String str)
str - String to be decoded
public static String swapFirstLetterCase(String str)
StringUtil.trim('Password') = 'password'
StringUtil.trim('password') = 'Password'
str - String to be swapped
public static String trim(String origString,
String trimString)
StringUtil.trim('pass*word', '*') = 'password'
origString - original StringtrimString - String to be trimmed
public static String getLastString(String origStr,
String strToken)
StringUtil.getLastString('password*password*a*b*c', '*') = 'c'
origStr - original StringstrToken - specific tokens
public static String[] getStringArray(String str,
String strToken)
StringUtil.getStringArray('passwordabcpassword', 'abc') = String[]{'password','password'}
StringUtil.getStringArray('pasword*password', 'abc') = String[]{'pasword*password'}
str - original StringstrToken - specific String token
public static boolean isNotEmpty(String str)
StringUtil.isNotEmpty('') = false
StringUtil.isNotEmpty(null) = false
StringUtil.isNotEmpty('abc') = true
str - original String
public static boolean isEmpty(String str)
StringUtil.isEmpty('') = true
StringUtil.isEmpty(null) = true
StringUtil.isEmpty('abc') = false
str - original String
public static String replace(String str,
String replacedStr,
String replaceStr)
StringUtil.replace('work$id', '$', '.') = 'work.id'
str - original StringreplacedStr - to be replaced StringreplaceStr - replace String
public static int string2integer(String str)
StringUtil.string2integer('14') = 14
str - string representation of a number
public static String integer2string(int integer)
StringUtil.integer2string(14) = '14'
integer - integer type
public static boolean isPatternMatching(String str,
String pattern)
throws Exception
StringUtil.isPatternMatching('abc-def', '*-*') = true
StringUtil.isPatternMatching('abc', '*-*') = false
str - original Stringpattern - pattern String
Exception - fail to check pattern matched
public static boolean containsMaxSequence(String str,
String maxSeqNumber)
StringUtil.containsMaxSequence('password', '2') = true
StringUtil.containsMaxSequence('my000', '3') = true
StringUtil.containsMaxSequence('abbbbc', '5') = false
str - original StringmaxSeqNumber - a sequence of the same character
public static boolean containsInvalidChars(String str,
char[] invalidChars)
Checks that the String contains certain characters.
A null String will return false. A
null invalid character array will return
false. An empty String ("") always returns false.
StringUtil.containsInvalidChars(null, *) = false
StringUtil.containsInvalidChars(*, null) = false
StringUtil.containsInvalidChars("", *) = false
StringUtil.containsInvalidChars("ab", '') = false
StringUtil.containsInvalidChars("abab", 'xyz') = false
StringUtil.containsInvalidChars("ab1", 'xyz') = false
StringUtil.containsInvalidChars("xbz", 'xyz') = true
str - the String to check, may be nullinvalidChars - an array of invalid chars, may be null
public static boolean containsInvalidChars(String str,
String invalidChars)
Checks that the String contains certain characters.
A null String will return false. A
null invalid character array will return
false. An empty String ("") always returns false.
StringUtil.containsInvalidChars(null, *) = false
StringUtil.containsInvalidChars(*, null) = false
StringUtil.containsInvalidChars("", *) = false
StringUtil.containsInvalidChars("ab", '') = false
StringUtil.containsInvalidChars("abab", 'xyz') = false
StringUtil.containsInvalidChars("ab1", 'xyz') = false
StringUtil.containsInvalidChars("xbz", 'xyz') = true
str - the String to check, may be nullinvalidChars - a String of invalid chars, may be null
public static boolean isAlphaNumeric(String str)
Checks if the String contains only unicode letters or digits.
null will return false. An empty String
("") will return false.
StringUtil.isAlphaNumeric(null) = false
StringUtil.isAlphaNumeric("") = false
StringUtil.isAlphaNumeric(" ") = false
StringUtil.isAlphaNumeric("abc") = true
StringUtil.isAlphaNumeric("ab c") = false
StringUtil.isAlphaNumeric("ab2c") = true
StringUtil.isAlphaNumeric("ab-c") = false
str - the String to check, may be null
true if only contains letters or digits, and is
non-nullpublic static boolean isAlpha(String str)
Checks if the String contains only unicode letters.
null will return false. An empty String
("") will return false.
StringUtil.isAlpha(null) = false
StringUtil.isAlpha("") = false
StringUtil.isAlpha(" ") = false
StringUtil.isAlpha("abc") = true
StringUtil.isAlpha("ab2c") = false
StringUtil.isAlpha("ab-c") = false
str - the String to check, may be null
true if only contains letters, and is non-nullpublic static boolean isNumeric(String str)
Checks if the String contains only unicode digits. A decimal point is not a unicode digit and returns false.
null will return false. An empty String
("") will return false.
StringUtil.isNumeric(null) = false
StringUtil.isNumeric("") = false
StringUtil.isNumeric(" ") = false
StringUtil.isNumeric("123") = true
StringUtil.isNumeric("12 3") = false
StringUtil.isNumeric("ab2c") = false
StringUtil.isNumeric("12-3") = false
StringUtil.isNumeric("12.3") = false
str - the String to check, may be null
true if only contains digits, and is non-nullpublic static String reverse(String str)
Reverses a String as per StringBuffer.reverse().
StringUtil.reverse(null) = null
StringUtil.reverse("") = ""
StringUtil.reverse("bat") = "tab"
str - the String to reverse, may be null
null if null String input
public static String fillString(String originalStr,
char ch,
int cipers)
originalStr - original Stringch - a special charcipers - cipers
public static final boolean isEmptyTrimmed(String foo)
foo - The text to check.
public static List getTokens(String lst,
String separator)
lst - separator -
public static List getTokens(String lst)
lst -
public static String convertToCamelCase(String targetString,
char posChar)
String - targetStringchar - posChar
public static String convertToCamelCase(String underScore)
underScore - Underscore name.
public static String convertToUnderScore(String camelCase)
camelCase - Camel case name.
|
Anyframe Core | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||