|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.plexus.util.StringUtils
Common String
manipulation routines.
Originally from Turbine and the GenerationJavaCore library.
Constructor Summary | |
StringUtils()
StringUtils instances should NOT be constructed in
standard programming. |
Method Summary | |
static java.lang.String |
abbreviate(java.lang.String s,
int maxWidth)
Turn "Now is the time for all good men" into "Now is the time for..." |
static java.lang.String |
abbreviate(java.lang.String s,
int offset,
int maxWidth)
Turn "Now is the time for all good men" into "...is the time for..." |
static java.lang.String |
addAndDeHump(java.lang.String view)
|
static java.lang.String |
capitalise(java.lang.String str)
Capitalise a String. |
static java.lang.String |
capitaliseAllWords(java.lang.String str)
Capitalise all the words in a String. |
static java.lang.String |
capitalizeFirstLetter(java.lang.String data)
|
static java.lang.String |
center(java.lang.String str,
int size)
Center a String in a larger String of size n . |
static java.lang.String |
center(java.lang.String str,
int size,
java.lang.String delim)
Center a String in a larger String of size n . |
static java.lang.String |
chomp(java.lang.String str)
Remove the last newline, and everything after it from a String. |
static java.lang.String |
chomp(java.lang.String str,
java.lang.String sep)
Remove the last value of a supplied String, and everything after it from a String. |
static java.lang.String |
chompLast(java.lang.String str)
Remove a newline if and only if it is at the end of the supplied String. |
static java.lang.String |
chompLast(java.lang.String str,
java.lang.String sep)
Remove a value if and only if the String ends with that value. |
static java.lang.String |
chop(java.lang.String str)
Remove the last character from a String. |
static java.lang.String |
chopNewline(java.lang.String str)
Remove \n from end of a String if it's there. |
static java.lang.String |
clean(java.lang.String str)
Removes control characters, including whitespace, from both ends of this String, handling null by returning
an empty String. |
static java.lang.String |
concatenate(java.lang.Object[] array)
Concatenates elements of an array into a single String. |
static int |
countMatches(java.lang.String str,
java.lang.String sub)
How many times is the substring in the larger String. |
static java.lang.String |
defaultString(java.lang.Object obj)
Returns either the passed in Object as a String,
or, if the Object is null , an empty
String. |
static java.lang.String |
defaultString(java.lang.Object obj,
java.lang.String defaultString)
Returns either the passed in Object as a String,
or, if the Object is null , a passed
in default String. |
static java.lang.String |
deleteWhitespace(java.lang.String str)
Deletes all whitespaces from a String. |
static java.lang.String |
difference(java.lang.String s1,
java.lang.String s2)
Compare two strings, and return the portion where they differ. |
static int |
differenceAt(java.lang.String s1,
java.lang.String s2)
Compare two strings, and return the index at which the strings begin to differ. |
static boolean |
equals(java.lang.String str1,
java.lang.String str2)
Compares two Strings, returning true if they are equal. |
static boolean |
equalsIgnoreCase(java.lang.String str1,
java.lang.String str2)
Compares two Strings, returning true if they are equal ignoring
the case. |
static java.lang.String |
escape(java.lang.String str)
Escapes any values it finds into their String form. |
static java.lang.String |
getChomp(java.lang.String str,
java.lang.String sep)
Remove everything and return the last value of a supplied String, and everything after it from a String. |
static java.lang.String |
getNestedString(java.lang.String str,
java.lang.String tag)
Get the String that is nested in between two instances of the same String. |
static java.lang.String |
getNestedString(java.lang.String str,
java.lang.String open,
java.lang.String close)
Get the String that is nested in between two Strings. |
static java.lang.String |
getPrechomp(java.lang.String str,
java.lang.String sep)
Remove and return everything before the first value of a supplied String from another String. |
static int |
indexOfAny(java.lang.String str,
java.lang.String[] searchStrs)
Find the first index of any of a set of potential substrings. |
static java.lang.String |
interpolate(java.lang.String text,
java.util.Map namespace)
|
static boolean |
isAlpha(java.lang.String str)
Checks if the String contains only unicode letters. |
static boolean |
isAlphanumeric(java.lang.String str)
Checks if the String contains only unicode letters or digits. |
static boolean |
isAlphanumericSpace(java.lang.String str)
Checks if the String contains only unicode letters, digits or space ( ' ' ). |
static boolean |
isAlphaSpace(java.lang.String str)
Checks if the String contains only unicode letters and space ( ' ' ). |
static boolean |
isEmpty(java.lang.String str)
Checks if a (trimmed) String is null or empty. |
static boolean |
isNotEmpty(java.lang.String str)
Checks if a String is non null and is
not empty (length > 0 ). |
static boolean |
isNumeric(java.lang.String str)
Checks if the String contains only unicode digits. |
static boolean |
isNumericSpace(java.lang.String str)
Checks if the String contains only unicode digits or space ( ' ' ). |
static boolean |
isWhitespace(java.lang.String str)
Checks if the String contains only whitespace. |
static java.lang.String |
join(java.util.Iterator iterator,
java.lang.String separator)
Joins the elements of the provided Iterator into
a single String containing the provided elements. |
static java.lang.String |
join(java.lang.Object[] array,
java.lang.String separator)
Joins the elements of the provided array into a single String containing the provided list of elements. |
static int |
lastIndexOfAny(java.lang.String str,
java.lang.String[] searchStrs)
Find the latest index of any of a set of potential substrings. |
static java.lang.String |
left(java.lang.String str,
int len)
Gets the leftmost n characters of a String. |
static java.lang.String |
leftPad(java.lang.String str,
int size)
Left pad a String with spaces. |
static java.lang.String |
leftPad(java.lang.String str,
int size,
java.lang.String delim)
Left pad a String with a specified string. |
static java.lang.String |
lowerCase(java.lang.String str)
Convert a String to lower case, null String
returns null . |
static java.lang.String |
lowercaseFirstLetter(java.lang.String data)
|
static java.lang.String |
mid(java.lang.String str,
int pos,
int len)
Gets n characters from the middle of a String. |
static java.lang.String |
overlayString(java.lang.String text,
java.lang.String overlay,
int start,
int end)
Overlay a part of a String with another String. |
static java.lang.String |
prechomp(java.lang.String str,
java.lang.String sep)
Remove the first value of a supplied String, and everything before it from a String. |
static java.lang.String |
removeAndHump(java.lang.String data,
java.lang.String replaceThis)
|
static java.lang.String |
repeat(java.lang.String str,
int repeat)
Repeat a String n times to form a
new string. |
static java.lang.String |
replace(java.lang.String text,
char repl,
char with)
Replace all occurances of a char within another char. |
static java.lang.String |
replace(java.lang.String text,
char repl,
char with,
int max)
Replace a char with another char inside a larger String, for the first max values of the search char. |
static java.lang.String |
replace(java.lang.String text,
java.lang.String repl,
java.lang.String with)
Replace all occurances of a String within another String. |
static java.lang.String |
replace(java.lang.String text,
java.lang.String repl,
java.lang.String with,
int max)
Replace a String with another String inside a larger String, for the first max values of the search String. |
static java.lang.String |
replaceOnce(java.lang.String text,
char repl,
char with)
Replace a char with another char inside a larger String, once. |
static java.lang.String |
replaceOnce(java.lang.String text,
java.lang.String repl,
java.lang.String with)
Replace a String with another String inside a larger String, once. |
static java.lang.String |
reverse(java.lang.String str)
Reverse a String. |
static java.lang.String |
reverseDelimitedString(java.lang.String str,
java.lang.String delimiter)
Reverses a String that is delimited by a specific character. |
static java.lang.String |
right(java.lang.String str,
int len)
Gets the rightmost n characters of a String. |
static java.lang.String |
rightPad(java.lang.String str,
int size)
Right pad a String with spaces. |
static java.lang.String |
rightPad(java.lang.String str,
int size,
java.lang.String delim)
Right pad a String with a specified string. |
static java.lang.String[] |
split(java.lang.String str)
Splits the provided text into a array, using whitespace as the separator. |
static java.lang.String[] |
split(java.lang.String text,
java.lang.String separator)
|
static java.lang.String[] |
split(java.lang.String str,
java.lang.String separator,
int max)
Splits the provided text into a array, based on a given separator. |
static java.lang.String |
strip(java.lang.String str)
Remove whitespace from the front and back of a String. |
static java.lang.String |
strip(java.lang.String str,
java.lang.String delim)
Remove a specified String from the front and back of a String. |
static java.lang.String[] |
stripAll(java.lang.String[] strs)
Strip whitespace from the front and back of every String in the array. |
static java.lang.String[] |
stripAll(java.lang.String[] strs,
java.lang.String delimiter)
Strip the specified delimiter from the front and back of every String in the array. |
static java.lang.String |
stripEnd(java.lang.String str,
java.lang.String strip)
Strip any of a supplied String from the end of a String. |
static java.lang.String |
stripStart(java.lang.String str,
java.lang.String strip)
Strip any of a supplied String from the start of a String. |
static java.lang.String |
substring(java.lang.String str,
int start)
Gets a substring from the specified string avoiding exceptions. |
static java.lang.String |
substring(java.lang.String str,
int start,
int end)
Gets a substring from the specified String avoiding exceptions. |
static java.lang.String |
swapCase(java.lang.String str)
Swaps the case of String. |
static java.lang.String |
trim(java.lang.String str)
Removes control characters, including whitespace, from both ends of this String, handling null by returning
null . |
static java.lang.String |
uncapitalise(java.lang.String str)
Uncapitalise a String. |
static java.lang.String |
uncapitaliseAllWords(java.lang.String str)
Uncapitalise all the words in a string. |
static java.lang.String |
upperCase(java.lang.String str)
Convert a String to upper case, null String
returns null . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public StringUtils()
StringUtils
instances should NOT be constructed in
standard programming. Instead, the class should be used as
StringUtils.trim(" foo ");
.
This constructor is public to permit tools that require a JavaBean manager to operate.
Method Detail |
public static java.lang.String clean(java.lang.String str)
Removes control characters, including whitespace, from both
ends of this String, handling null
by returning
an empty String.
str
- the String to check
null
)String.trim()
public static java.lang.String trim(java.lang.String str)
Removes control characters, including whitespace, from both
ends of this String, handling null
by returning
null
.
str
- the String to check
null
)String.trim()
public static java.lang.String deleteWhitespace(java.lang.String str)
Deletes all whitespaces from a String.
Whitespace is defined by
Character.isWhitespace(char)
.
str
- String target to delete whitespace from
java.lang.NullPointerException
public static boolean isNotEmpty(java.lang.String str)
Checks if a String is non null
and is
not empty (length > 0
).
str
- the String to check
public static boolean isEmpty(java.lang.String str)
Checks if a (trimmed) String is null
or empty.
str
- the String to check
true
if the String is null
, or
length zero once trimmedpublic static boolean equals(java.lang.String str1, java.lang.String str2)
Compares two Strings, returning true
if they are equal.
null
s are handled without exceptions. Two null
references are considered to be equal. The comparison is case sensitive.
str1
- the first stringstr2
- the second string
true
if the Strings are equal, case sensitive, or
both null
String.equals(Object)
public static boolean equalsIgnoreCase(java.lang.String str1, java.lang.String str2)
Compares two Strings, returning true
if they are equal ignoring
the case.
Nulls
are handled without exceptions. Two null
references are considered equal. Comparison is case insensitive.
str1
- the first stringstr2
- the second string
true
if the Strings are equal, case insensitive, or
both null
String.equalsIgnoreCase(String)
public static int indexOfAny(java.lang.String str, java.lang.String[] searchStrs)
Find the first index of any of a set of potential substrings.
null
String will return -1
.
str
- the String to checksearchStrs
- the Strings to search for
java.lang.NullPointerException
- if any of searchStrs[i] is null
public static int lastIndexOfAny(java.lang.String str, java.lang.String[] searchStrs)
Find the latest index of any of a set of potential substrings.
null
string will return -1
.
str
- the String to checksearchStrs
- the Strings to search for
java.lang.NullPointerException
- if any of searchStrs[i] is null
public static java.lang.String substring(java.lang.String str, int start)
Gets a substring from the specified string avoiding exceptions.
A negative start position can be used to start n
characters from the end of the String.
str
- the String to get the substring fromstart
- the position to start from, negative means
count back from the end of the String by this many characters
public static java.lang.String substring(java.lang.String str, int start, int end)
Gets a substring from the specified String avoiding exceptions.
A negative start position can be used to start/end n
characters from the end of the String.
str
- the String to get the substring fromstart
- the position to start from, negative means
count back from the end of the string by this many charactersend
- the position to end at (exclusive), negative means
count back from the end of the String by this many characters
public static java.lang.String left(java.lang.String str, int len)
Gets the leftmost n
characters of a String.
If n
characters are not available, or the
String is null
, the String will be returned without
an exception.
str
- the String to get the leftmost characters fromlen
- the length of the required String
java.lang.IllegalArgumentException
- if len is less than zeropublic static java.lang.String right(java.lang.String str, int len)
Gets the rightmost n
characters of a String.
If n
characters are not available, or the String
is null
, the String will be returned without an
exception.
str
- the String to get the rightmost characters fromlen
- the length of the required String
java.lang.IllegalArgumentException
- if len is less than zeropublic static java.lang.String mid(java.lang.String str, int pos, int len)
Gets n
characters from the middle of a String.
If n
characters are not available, the remainder
of the String will be returned without an exception. If the
String is null
, null
will be returned.
str
- the String to get the characters frompos
- the position to start fromlen
- the length of the required String
java.lang.IndexOutOfBoundsException
- if pos is out of bounds
java.lang.IllegalArgumentException
- if len is less than zeropublic static java.lang.String[] split(java.lang.String str)
Splits the provided text into a array, using whitespace as the separator.
The separator is not included in the returned String array.
str
- the String to parse
public static java.lang.String[] split(java.lang.String text, java.lang.String separator)
split(String, String, int)
public static java.lang.String[] split(java.lang.String str, java.lang.String separator, int max)
Splits the provided text into a array, based on a given separator.
The separator is not included in the returned String array. The
maximum number of splits to perfom can be controlled. A null
separator will cause parsing to be on whitespace.
This is useful for quickly splitting a String directly into
an array of tokens, instead of an enumeration of tokens (as
StringTokenizer
does).
str
- The string to parse.separator
- Characters used as the delimiters. If
null
, splits on whitespace.max
- The maximum number of elements to include in the
array. A zero or negative value implies no limit.
public static java.lang.String concatenate(java.lang.Object[] array)
Concatenates elements of an array into a single String.
The difference from join is that concatenate has no delimiter.
array
- the array of values to concatenate.
public static java.lang.String join(java.lang.Object[] array, java.lang.String separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. A
null
separator is the same as a blank String.
array
- the array of values to join togetherseparator
- the separator character to use
public static java.lang.String join(java.util.Iterator iterator, java.lang.String separator)
Joins the elements of the provided Iterator
into
a single String containing the provided elements.
No delimiter is added before or after the list. A
null
separator is the same as a blank String.
iterator
- the Iterator
of values to join togetherseparator
- the separator character to use
public static java.lang.String replaceOnce(java.lang.String text, char repl, char with)
Replace a char with another char inside a larger String, once.
A null
reference passed to this method is a no-op.
text
- text to search and replace inrepl
- char to search forwith
- char to replace with
replace(String text, char repl, char with, int max)
public static java.lang.String replace(java.lang.String text, char repl, char with)
Replace all occurances of a char within another char.
A null
reference passed to this method is a no-op.
text
- text to search and replace inrepl
- char to search forwith
- char to replace with
replace(String text, char repl, char with, int max)
public static java.lang.String replace(java.lang.String text, char repl, char with, int max)
Replace a char with another char inside a larger String,
for the first max
values of the search char.
A null
reference passed to this method is a no-op.
text
- text to search and replace inrepl
- char to search forwith
- char to replace withmax
- maximum number of values to replace, or -1
if no maximum
public static java.lang.String replaceOnce(java.lang.String text, java.lang.String repl, java.lang.String with)
Replace a String with another String inside a larger String, once.
A null
reference passed to this method is a no-op.
text
- text to search and replace inrepl
- String to search forwith
- String to replace with
replace(String text, String repl, String with, int max)
public static java.lang.String replace(java.lang.String text, java.lang.String repl, java.lang.String with)
Replace all occurances of a String within another String.
A null
reference passed to this method is a no-op.
text
- text to search and replace inrepl
- String to search forwith
- String to replace with
replace(String text, String repl, String with, int max)
public static java.lang.String replace(java.lang.String text, java.lang.String repl, java.lang.String with, int max)
Replace a String with another String inside a larger String,
for the first max
values of the search String.
A null
reference passed to this method is a no-op.
text
- text to search and replace inrepl
- String to search forwith
- String to replace withmax
- maximum number of values to replace, or -1
if no maximum
public static java.lang.String overlayString(java.lang.String text, java.lang.String overlay, int start, int end)
Overlay a part of a String with another String.
text
- String to do overlaying inoverlay
- String to overlaystart
- int to start overlaying atend
- int to stop overlaying before
java.lang.NullPointerException
- if text or overlay is null
public static java.lang.String center(java.lang.String str, int size)
Center a String in a larger String of size n
.
Uses spaces as the value to buffer the String with.
Equivalent to center(str, size, " ")
.
str
- String to centersize
- int size of new String
java.lang.NullPointerException
- if str is null
public static java.lang.String center(java.lang.String str, int size, java.lang.String delim)
Center a String in a larger String of size n
.
Uses a supplied String as the value to buffer the String with.
str
- String to centersize
- int size of new Stringdelim
- String to buffer the new String with
java.lang.NullPointerException
- if str or delim is null
java.lang.ArithmeticException
- if delim is the empty Stringpublic static java.lang.String chomp(java.lang.String str)
Remove the last newline, and everything after it from a String.
str
- String to chomp the newline from
java.lang.NullPointerException
- if str is null
public static java.lang.String chomp(java.lang.String str, java.lang.String sep)
Remove the last value of a supplied String, and everything after it from a String.
str
- String to chomp fromsep
- String to chomp
java.lang.NullPointerException
- if str or sep is null
public static java.lang.String chompLast(java.lang.String str)
Remove a newline if and only if it is at the end of the supplied String.
str
- String to chomp from
java.lang.NullPointerException
- if str is null
public static java.lang.String chompLast(java.lang.String str, java.lang.String sep)
Remove a value if and only if the String ends with that value.
str
- String to chomp fromsep
- String to chomp
java.lang.NullPointerException
- if str or sep is null
public static java.lang.String getChomp(java.lang.String str, java.lang.String sep)
Remove everything and return the last value of a supplied String, and everything after it from a String.
str
- String to chomp fromsep
- String to chomp
java.lang.NullPointerException
- if str or sep is null
public static java.lang.String prechomp(java.lang.String str, java.lang.String sep)
Remove the first value of a supplied String, and everything before it from a String.
str
- String to chomp fromsep
- String to chomp
java.lang.NullPointerException
- if str or sep is null
public static java.lang.String getPrechomp(java.lang.String str, java.lang.String sep)
Remove and return everything before the first value of a supplied String from another String.
str
- String to chomp fromsep
- String to chomp
java.lang.NullPointerException
- if str or sep is null
public static java.lang.String chop(java.lang.String str)
Remove the last character from a String.
If the String ends in \r\n
, then remove both
of them.
str
- String to chop last character from
java.lang.NullPointerException
- if str is null
public static java.lang.String chopNewline(java.lang.String str)
Remove \n
from end of a String if it's there.
If a \r
precedes it, then remove that too.
str
- String to chop a newline from
java.lang.NullPointerException
- if str is null
public static java.lang.String escape(java.lang.String str)
Escapes any values it finds into their String form.
So a tab becomes the characters '\\'
and
't'
.
str
- String to escape values in
java.lang.NullPointerException
- if str is null
public static java.lang.String repeat(java.lang.String str, int repeat)
Repeat a String n
times to form a
new string.
str
- String to repeatrepeat
- number of times to repeat str
java.lang.NegativeArraySizeException
- if repeat < 0
java.lang.NullPointerException
- if str is null
public static java.lang.String rightPad(java.lang.String str, int size)
Right pad a String with spaces.
The String is padded to the size of n
.
str
- String to repeatsize
- number of times to repeat str
java.lang.NullPointerException
- if str is null
public static java.lang.String rightPad(java.lang.String str, int size, java.lang.String delim)
Right pad a String with a specified string.
The String is padded to the size of n
.
str
- String to pad outsize
- size to pad todelim
- String to pad with
java.lang.NullPointerException
- if str or delim is null
java.lang.ArithmeticException
- if delim is the empty Stringpublic static java.lang.String leftPad(java.lang.String str, int size)
Left pad a String with spaces.
The String is padded to the size of n
.
str
- String to pad outsize
- size to pad to
java.lang.NullPointerException
- if str or delim is null
public static java.lang.String leftPad(java.lang.String str, int size, java.lang.String delim)
str
- String to pad outsize
- size to pad todelim
- String to pad with
java.lang.NullPointerException
- if str or delim is null
java.lang.ArithmeticException
- if delim is the empty stringpublic static java.lang.String strip(java.lang.String str)
Remove whitespace from the front and back of a String.
str
- the String to remove whitespace from
public static java.lang.String strip(java.lang.String str, java.lang.String delim)
Remove a specified String from the front and back of a String.
If whitespace is wanted to be removed, used the
strip(java.lang.String)
method.
str
- the String to remove a string fromdelim
- the String to remove at start and end
public static java.lang.String[] stripAll(java.lang.String[] strs)
Strip whitespace from the front and back of every String in the array.
strs
- the Strings to remove whitespace from
public static java.lang.String[] stripAll(java.lang.String[] strs, java.lang.String delimiter)
Strip the specified delimiter from the front and back of every String in the array.
strs
- the Strings to remove a String fromdelimiter
- the String to remove at start and end
public static java.lang.String stripEnd(java.lang.String str, java.lang.String strip)
Strip any of a supplied String from the end of a String.
If the strip String is null
, whitespace is
stripped.
str
- the String to remove characters fromstrip
- the String to remove
public static java.lang.String stripStart(java.lang.String str, java.lang.String strip)
Strip any of a supplied String from the start of a String.
If the strip String is null
, whitespace is
stripped.
str
- the String to remove characters fromstrip
- the String to remove
public static java.lang.String upperCase(java.lang.String str)
Convert a String to upper case, null
String
returns null
.
str
- the String to uppercase
public static java.lang.String lowerCase(java.lang.String str)
Convert a String to lower case, null
String
returns null
.
str
- the string to lowercase
public static java.lang.String uncapitalise(java.lang.String str)
Uncapitalise a String.
That is, convert the first character into lower-case.
null
is returned as null
.
str
- the String to uncapitalise
public static java.lang.String capitalise(java.lang.String str)
Capitalise a String.
That is, convert the first character into title-case.
null
is returned as null
.
str
- the String to capitalise
public static java.lang.String swapCase(java.lang.String str)
Swaps the case of String.
Properly looks after making sure the start of words are Titlecase and not Uppercase.
null
is returned as null
.
str
- the String to swap the case of
public static java.lang.String capitaliseAllWords(java.lang.String str)
Capitalise all the words in a String.
Uses Character.isWhitespace(char)
as a
separator between words.
null
will return null
.
str
- the String to capitalise
public static java.lang.String uncapitaliseAllWords(java.lang.String str)
Uncapitalise all the words in a string.
Uses Character.isWhitespace(char)
as a
separator between words.
null
will return null
.
str
- the string to uncapitalise
public static java.lang.String getNestedString(java.lang.String str, java.lang.String tag)
Get the String that is nested in between two instances of the same String.
If str
is null
, will
return null
.
str
- the String containing nested-stringtag
- the String before and after nested-string
null
java.lang.NullPointerException
- if tag is null
public static java.lang.String getNestedString(java.lang.String str, java.lang.String open, java.lang.String close)
Get the String that is nested in between two Strings.
str
- the String containing nested-stringopen
- the String before nested-stringclose
- the String after nested-string
null
java.lang.NullPointerException
- if open or close is null
public static int countMatches(java.lang.String str, java.lang.String sub)
How many times is the substring in the larger String.
null
returns 0
.
str
- the String to checksub
- the substring to count
null
java.lang.NullPointerException
- if sub is null
public static boolean isAlpha(java.lang.String str)
Checks if the String contains only unicode letters.
null
will return false
.
An empty String will return true
.
str
- the String to check
true
if only contains letters, and is non-nullpublic static boolean isWhitespace(java.lang.String str)
Checks if the String contains only whitespace.
null
will return false
. An
empty String will return true
.
str
- the String to check
true
if only contains whitespace, and is non-nullpublic static boolean isAlphaSpace(java.lang.String str)
Checks if the String contains only unicode letters and
space (' '
).
null
will return false
. An
empty String will return true
.
str
- the String to check
true
if only contains letters and space,
and is non-nullpublic static boolean isAlphanumeric(java.lang.String str)
Checks if the String contains only unicode letters or digits.
null
will return false
. An empty
String will return true
.
str
- the String to check
true
if only contains letters or digits,
and is non-nullpublic static boolean isAlphanumericSpace(java.lang.String str)
Checks if the String contains only unicode letters, digits
or space (' '
).
null
will return false
. An empty
String will return true
.
str
- the String to check
true
if only contains letters, digits or space,
and is non-nullpublic static boolean isNumeric(java.lang.String str)
Checks if the String contains only unicode digits.
null
will return false
.
An empty String will return true
.
str
- the String to check
true
if only contains digits, and is non-nullpublic static boolean isNumericSpace(java.lang.String str)
Checks if the String contains only unicode digits or space
(' '
).
null
will return false
. An empty
String will return true
.
str
- the String to check
true
if only contains digits or space,
and is non-nullpublic static java.lang.String defaultString(java.lang.Object obj)
Returns either the passed in Object
as a String,
or, if the Object
is null
, an empty
String.
obj
- the Object to check
null
public static java.lang.String defaultString(java.lang.Object obj, java.lang.String defaultString)
Returns either the passed in Object
as a String,
or, if the Object
is null
, a passed
in default String.
obj
- the Object to checkdefaultString
- the default String to return if str is
null
null
public static java.lang.String reverse(java.lang.String str)
Reverse a String.
null
String returns null
.
str
- the String to reverse
public static java.lang.String reverseDelimitedString(java.lang.String str, java.lang.String delimiter)
Reverses a String that is delimited by a specific character.
The Strings between the delimiters are not reversed.
Thus java.lang.String becomes String.lang.java (if the delimiter
is '.'
).
str
- the String to reversedelimiter
- the delimiter to use
public static java.lang.String abbreviate(java.lang.String s, int maxWidth)
Specifically:
If str is less than max characters long, return it. Else abbreviate it to (substring(str, 0, max-3) + "..."). If maxWidth is less than 3, throw an IllegalArgumentException. In no case will it return a string of length greater than maxWidth.
maxWidth
- maximum length of result stringpublic static java.lang.String abbreviate(java.lang.String s, int offset, int maxWidth)
Works like abbreviate(String, int), but allows you to specify a "left edge" offset. Note that this left edge is not necessarily going to be the leftmost character in the result, or the first character following the ellipses, but it will appear somewhere in the result. In no case will it return a string of length greater than maxWidth.
offset
- left edge of source stringmaxWidth
- maximum length of result stringpublic static java.lang.String difference(java.lang.String s1, java.lang.String s2)
E.g. strdiff("i am a machine", "i am a robot") -> "robot"
public static int differenceAt(java.lang.String s1, java.lang.String s2)
E.g. strdiff("i am a machine", "i am a robot") -> 7
public static java.lang.String interpolate(java.lang.String text, java.util.Map namespace)
public static java.lang.String removeAndHump(java.lang.String data, java.lang.String replaceThis)
public static java.lang.String capitalizeFirstLetter(java.lang.String data)
public static java.lang.String lowercaseFirstLetter(java.lang.String data)
public static java.lang.String addAndDeHump(java.lang.String view)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |