public class StringUtils
extends java.lang.Object
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
areAllCharsInRange(java.lang.String value,
char start,
char end)
Indicate whether the String value has ALL of it's characters
in the specified range of characters.
|
static java.lang.String |
convertStringToCharEntities(java.lang.String str)
Convert a string to a set of character entities.
|
static java.lang.String |
getTextAsFormattedLines(java.lang.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(java.lang.String value,
char start,
char end)
Indicate whether the String value has at least one
character in the range specified.
|
static boolean |
hasValue(java.lang.String v)
Determine whether the specified string contains a value, where
having a value means:
(string != null) && (!string.equals (""))
|
static java.lang.String |
removeChar(java.lang.String str,
char c)
Given a particular String, remove any instances of the given
character from it and return a new String.
|
static java.lang.String |
replaceAllStrings(java.lang.String text,
java.util.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 java.lang.String |
replaceAllStrings(java.lang.String text,
java.util.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 java.lang.String |
replaceString(java.lang.String text,
java.lang.String str,
java.lang.String replace)
Replace all instances of the specified string in the text given.
|
static java.lang.String |
replaceString(java.lang.String text,
java.lang.String str,
java.lang.String replace,
boolean caseSensitive)
Replace all instances of the specified string in the text given.
|
static java.util.List |
tokenizeString(java.lang.String str,
java.lang.String token)
A method to chop up a String on another multi-character String and
then return the results in a List.
|
public static java.lang.String convertStringToCharEntities(java.lang.String str)
str
- The string to convert.public static java.lang.String getTextAsFormattedLines(java.lang.String text, int lineLength)
text
- The text to format.lineLength
- The line length to format the text to.public static boolean hasCharInRange(java.lang.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 java.util.List tokenizeString(java.lang.String str, java.lang.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(java.lang.String v)
(string != null) && (!string.equals (""))
true
if the string has a value, false
otherwise.public static java.lang.String replaceAllStrings(java.lang.String text, java.util.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 java.lang.String replaceAllStrings(java.lang.String text, java.util.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 java.lang.String replaceString(java.lang.String text, java.lang.String str, java.lang.String replace, boolean caseSensitive) throws java.lang.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.java.lang.NullPointerException
public static java.lang.String replaceString(java.lang.String text, java.lang.String str, java.lang.String replace) throws java.lang.NullPointerException
text
- The text to perform the replacement on.str
- The string to find in the text.replace
- The string to replace "str" with.java.lang.NullPointerException
- If any of the arguments are null indicating which one is at fault.public static boolean areAllCharsInRange(java.lang.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 java.lang.String removeChar(java.lang.String str, char c)
str
- The String to search for the removals.c
- The character to remove.