|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gentlyweb.utils.StringUtils
public class StringUtils
Constructor Summary | |
---|---|
StringUtils()
|
Method Summary | |
---|---|
static boolean |
areAllCharsInRange(String value,
char start,
char end)
Indicate whether the String value has ALL of it's characters in the specified range of characters. |
static String |
convertStringToCharEntities(String str)
Convert a string to a set of character entities. |
static String |
getTextAsFormattedLines(String text,
int lineLength)
Given a chunk of text format it so that you return a new String with the line length equal to that passed in. |
static boolean |
hasCharInRange(String value,
char start,
char end)
Indicate whether the String value has at least one character in the range specified. |
static boolean |
hasValue(String v)
Determine whether the specified string contains a value, where having a value means:
(string != null) && (!string.equals (""))
|
static String |
removeChar(String str,
char c)
Given a particular String, remove any instances of the given character from it and return a new String. |
static String |
replaceAllStrings(String text,
Map map)
Given a Map of String/String (or Object/Object, they will be converted to Strings before replacement) replace all instances of each one in the specified text. |
static String |
replaceAllStrings(String text,
Map map,
boolean caseSensitive)
Given a Map of String/String (or Object/Object, they will be converted to Strings before replacement) replace all instances of each one in the specified text. |
static String |
replaceString(String text,
String str,
String replace)
Replace all instances of the specified string in the text given. |
static String |
replaceString(String text,
String str,
String replace,
boolean caseSensitive)
Replace all instances of the specified string in the text given. |
static List |
tokenizeString(String str,
String token)
A method to chop up a String on another multi-character String and then return the results in a List. |
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 String convertStringToCharEntities(String str)
str
- The string to convert.
public static String getTextAsFormattedLines(String text, int lineLength)
text
- The text to format.lineLength
- The line length to format the text to.
public static boolean hasCharInRange(String value, char start, char end)
value
- The value to check.start
- The starting character of the range.end
- The end character of the range.
true
if it has at least
one character in the range, false
otherwise.public static List tokenizeString(String str, String token)
str
- The String to chop up.token
- The token to look for. This should be just a plain
String, this method doesn't support regular expressions.
public static boolean hasValue(String v)
(string != null) && (!string.equals (""))
true
if the string has a value, false
otherwise.public static String replaceAllStrings(String text, Map map, boolean caseSensitive)
text
- The text to perform the replacements on.map
- The map of String to find in the text and replace with the value of the map (String).caseSensitive
- Indicate whether we should consider case when searching for the strings.
public static String replaceAllStrings(String text, Map map)
text
- The text to perform the replacements on.map
- The map of String to find in the text and replace with the value of the map (String).
public static String replaceString(String text, String str, String replace, boolean caseSensitive) throws NullPointerException
It should be noted that we take copies of text and str prior to performing the replacements.
text
- The text to perform the replacement on.str
- The string to find in the text.replace
- The string to replace "str" with.caseSensitive
- Indicate whether we should consider case
when searching for the string.
NullPointerExceptio
- If any of the arguments are null indicating which one is at fault.
NullPointerException
public static String replaceString(String text, String str, String replace) throws NullPointerException
text
- The text to perform the replacement on.str
- The string to find in the text.replace
- The string to replace "str" with.
NullPointerException
- If any of the arguments are null indicating which one is at fault.public static boolean areAllCharsInRange(String value, char start, char end)
Note: if you set start == end then you check to see if a String is made up of the same character, not useful all the time but it is sometimes.
value
- The value to check.start
- The starting character of the range.end
- The end character of the range.
true
if they are, false
otherwise.public static String removeChar(String str, char c)
str
- The String to search for the removals.c
- The character to remove.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |