|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectStringUtil
public class StringUtil
Provides some handy utilities missing from the Java String class, such as splitting on spaces, and joining with spaces, as well as case mapping.
Field Summary | |
---|---|
private static Pattern |
spacePat
Used for splitting strings on spaces |
Constructor Summary | |
---|---|
StringUtil()
|
Method Summary | |
---|---|
static String |
copyCase(String pattern,
String in)
Examines the pattern string to see whether it's lowercase, uppercase, or title case, and then applies that case to the given input string. |
static String |
escapeHTMLChars(String in)
Replaces 'special' HTML characters with their corresponding character entity references. |
static boolean |
isLowerCase(String in)
Check if the given string is all lower-case |
static boolean |
isTitleCase(String in)
Checks if the given string is "title case", i.e. the first letter is uppercase and the rest are lower case. |
static boolean |
isUpperCase(String in)
Check if the given string is all upper-case |
static String |
join(Object[] in)
Join a number of strings (or other objects) into a single string, separated by spaces. |
static String |
join(Object[] in,
String separator)
Join a number of strings (or other objects) into a single string. |
static String |
justifyLeft(String in,
int len)
Same as padEnd(String, int) |
static String |
justifyRight(String in,
int len)
Same as padStart(String, int) |
static String |
padEnd(String in,
int len)
Pad the end of a string with spaces to make its final length >= len |
static String |
padEnd(String in,
int len,
char padChar)
Pad the end of a string with the given character to make its final length >= len |
static String |
padStart(String in,
int len)
Pad the start of a string with spaces to make its final length >= len |
static String |
padStart(String in,
int len,
char padChar)
Pad the start of a string with the given character to make its final length >= len |
static String[] |
splitWords(String in)
Break a string up into words, defined by whitespace boundaries. |
static String |
toTitleCase(String in)
Convert a string to "title case", i.e. making the first letter of each word uppercase, and the rest of the letters lowercase. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Pattern spacePat
Constructor Detail |
---|
public StringUtil()
Method Detail |
---|
public static String join(Object[] in)
in
- array of Strings or objects to join
public static String join(Object[] in, String separator)
in
- array of Strings or objects to joinseparator
- a string to put between them
public static String padEnd(String in, int len)
public static String justifyLeft(String in, int len)
padEnd(String, int)
public static String padEnd(String in, int len, char padChar)
public static String padStart(String in, int len)
public static String justifyRight(String in, int len)
padStart(String, int)
public static String padStart(String in, int len, char padChar)
public static String copyCase(String pattern, String in)
pattern
- string to examine for casein
- string to convert to the same case as 'pattern'
public static boolean isUpperCase(String in)
public static boolean isLowerCase(String in)
public static boolean isTitleCase(String in)
public static String toTitleCase(String in)
public static String[] splitWords(String in)
in
- a string to break up
public static String escapeHTMLChars(String in)
in
- The string to work on
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |