|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.lang.WordUtils
Operations on Strings that contain words.
This class tries to handle null
input gracefully.
An exception will not be thrown for a null
input.
Each method documents its behaviour in more detail.
Constructor Summary | |
WordUtils()
WordWrapUtils instances should NOT be constructed in
standard programming. |
Method Summary | |
static java.lang.String |
capitalize(java.lang.String str)
Capitalizes all the whitespace separated words in a String. |
static java.lang.String |
capitalizeFully(java.lang.String str)
Capitalizes all the whitespace separated words in a String. |
static java.lang.String |
swapCase(java.lang.String str)
Swaps the case of a String using a word based algorithm. Upper case character converts to Lower case Title case character converts to Lower case Lower case character after Whitespace or at start converts to Title case Other Lower case character converts to Upper case Whitespace is defined by Character#isWhitespace(char) .
|
static java.lang.String |
uncapitalize(java.lang.String str)
Uncapitalizes all the whitespace separated words in a String. |
static java.lang.String |
wrap(java.lang.String str,
int wrapLength)
Wraps a single line of text, identifying words by ' ' .
New lines will be separated by the system property line separator.
|
static java.lang.String |
wrap(java.lang.String str,
int wrapLen,
java.lang.String newLine,
boolean wrapLongWords)
Wraps a single line of text, identifying words by ' ' .
Leading spaces on a new line are stripped.
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WordUtils()
WordWrapUtils
instances should NOT be constructed in
standard programming. Instead, the class should be used as
WordWrapUtils.wrap("foo bar", 20);
.
This constructor is public to permit tools that require a JavaBean instance to operate.
Method Detail |
public static java.lang.String wrap(java.lang.String str, int wrapLength)
Wraps a single line of text, identifying words by ' '
.
New lines will be separated by the system property line separator. Very long words, such as URLs will not be wrapped.
Leading spaces on a new line are stripped. Trailing spaces are not stripped.
WordUtils.wrap(null, *) = null WordUtils.wrap("", *) = ""
str
- the String to be word wrapped, may be nullwrapLength
- the column to wrap the words at, less than 1 is treated as 1null
if null inputpublic static java.lang.String wrap(java.lang.String str, int wrapLen, java.lang.String newLine, boolean wrapLongWords)
Wraps a single line of text, identifying words by ' '
.
Leading spaces on a new line are stripped. Trailing spaces are not stripped.
WordUtils.wrap(null, *, *, *) = null WordUtils.wrap("", *, *, *) = ""
str
- the String to be word wrapped, may be nullwrapLength
- the column to wrap the words at, less than 1 is treated as 1newLineStr
- the string to insert for a new line,
null
uses the system property line separatorwrapLongWords
- true if long words (such as URLs) should be wrappednull
if null inputpublic static java.lang.String capitalize(java.lang.String str)
Capitalizes all the whitespace separated words in a String.
Only the first letter of each word is changed. To change all letters to
the capitalized case, use capitalizeFully(String)
.
Whitespace is defined by Character#isWhitespace(char)
.
A null
input String returns null
.
Capitalization uses the unicode title case, normally equivalent to
upper case.
WordUtils.capitalize(null) = null WordUtils.capitalize("") = "" WordUtils.capitalize("i am FINE") = "I Am FINE"
str
- the String to capitalize, may be nullnull
if null String inputuncapitalize(String)
,
capitalizeFully(String)
public static java.lang.String capitalizeFully(java.lang.String str)
Capitalizes all the whitespace separated words in a String. All letters are changed, so the resulting string will be fully changed.
Whitespace is defined by Character#isWhitespace(char)
.
A null
input String returns null
.
Capitalization uses the unicode title case, normally equivalent to
upper case.
WordUtils.capitalize(null) = null WordUtils.capitalize("") = "" WordUtils.capitalize("i am FINE") = "I Am Fine"
str
- the String to capitalize, may be nullnull
if null String inputpublic static java.lang.String uncapitalize(java.lang.String str)
Uncapitalizes all the whitespace separated words in a String. Only the first letter of each word is changed.
Whitespace is defined by Character#isWhitespace(char)
.
A null
input String returns null
.
WordUtils.uncapitalize(null) = null WordUtils.uncapitalize("") = "" WordUtils.uncapitalize("I Am FINE") = "i am fINE"
str
- the String to uncapitalize, may be nullnull
if null String inputcapitalize(String)
public static java.lang.String swapCase(java.lang.String str)
Swaps the case of a String using a word based algorithm.
Whitespace is defined by Character#isWhitespace(char)
.
A null
input String returns null
.
StringUtils.swapCase(null) = null StringUtils.swapCase("") = "" StringUtils.swapCase("The dog has a BONE") = "tHE DOG HAS A bone"
str
- the String to swap case, may be nullnull
if null String input
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |