|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.cafesoft.core.util.StringUtils
Provides convenience methods for string manipulations.
| Constructor Summary | |
StringUtils()
|
|
| Method Summary | |
static String |
capitalize(String string)
Capitalize the start of the given String. |
static int |
charOccurences(String string,
char c)
Return the number of occurrences of a given character within a String. |
static String[] |
getStringArray(String s,
String token)
Parse a string for values separated by a single input character. |
static boolean |
hasNonAlpha(String s)
Check a String for a non-alphabetic character: ("0123456789~! |
static boolean |
isFloat(String s)
Determine if a String is a valid float. |
static String |
padString(String s,
int length,
String direction,
String fill)
Pads the right or left of a string with the specified character to a specified length. |
static String[] |
parseStringArray(String string,
String delim)
Parse a String into an array of Strings. |
static String |
replaceTokens(String text,
HashMap map)
Return input text with substitutions for matched values where the matches are designated by names in curley brackets. |
static String |
squeezeAdjacentChars(String value,
char adjChar)
Squeeze adjacent duplicate characters within a String (in place). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public StringUtils()
| Method Detail |
public static boolean hasNonAlpha(String s)
s - the string to evaluate
public static boolean isFloat(String s)
s - the string to evaluate
public static String capitalize(String string)
string - the string to capitalize the first character for
public static int charOccurences(String string,
char c)
string - the String.c - the character.
public static String[] parseStringArray(String string,
String delim)
For example, if string is: value1,value2,value3 and the delimiter is ',', then return an array of 3 Strings.
string - the String be parsed.delim - a String containing the characters than can separate
String values.
public static String squeezeAdjacentChars(String value,
char adjChar)
NOTE: This function looks for the duplicate adjacent character within a string and keep just a single instance of the character. For example, if the slash character '/' is the character to be squeezed:
Original Value Squeezed Value Comments ---------------------------------------------------------------------- // / /dir1/index.html /dir1/index.html No change /dir1//index.html /dir1/index.html /dir1///index.html /dir1/index.html /dir1////index.html /dir1/index.html /dir1//dir2//////index.html /dir1/dir2/index.html /dir1//dir2////// /dir1/dir2/
value - the String containing adjacent duplicate characters to "squeeze".adjChar - the character within the String to be squeezed.
public static String replaceTokens(String text,
HashMap map)
text - The text with match names found in curly bracketsmap - A HashMap of the names and values to replace
public static String padString(String s,
int length,
String direction,
String fill)
s - the string to evaluatelength - the size to make the String will be.direction - fill the right (default) or left side
("right" or "left")fill - the character to use for padding
public static String[] getStringArray(String s,
String token)
s - the string to evaluatetoken - the token that separates the String values
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||