public class StringUtilsHelper extends org.apache.commons.lang.StringUtils
Constructor and Description |
---|
StringUtilsHelper() |
Modifier and Type | Method and Description |
---|---|
static String |
format(String plainText)
Formats the argument string without any indentation, the text will be
wrapped at the default column.
|
static String |
format(String plainText,
String indentation)
Formats the given argument with the specified indentation, wrapping the
text at a 64 column margin.
|
static String |
format(String plainText,
String indentation,
int wrapAtColumn)
Formats the given argument with the specified indentation, wrapping the
text at the desired column margin.
|
static String |
format(String plainText,
String indentation,
int wrapAtColumn,
boolean htmlStyle)
Formats the given argument with the specified indentation, wrapping the
text at the desired column margin.
|
static String |
getLineSeparator()
Gets the line separator.
|
static String |
lowerCamelCaseName(String string)
Returns the argument string as a camel cased name beginning with a
lowercased letter.
|
static String |
pluralize(String singularNoun)
Linguistically pluralizes a singular noun.
|
static String |
prefixWithAPredicate(String word)
Takes an English word as input and prefixes it with 'a ' or 'an '
depending on the first character of the argument String.
|
static String |
removeLastOccurrence(String string,
String value)
Removes the last occurrence of the oldValue found within the string.
|
static String |
replaceSuffix(String src,
String suffixOld,
String suffixNew)
Replaces a given suffix of the source string with a new one.
|
static String |
separate(String string,
String separator)
Converts the argument to lowercase, removes all non-word characters, and
replaces each of those sequences by the separator.
|
static Boolean |
startsWithLowercaseLetter(String string)
Returns true if the input string starts with a lowercase letter.
|
static Boolean |
startsWithUppercaseLetter(String string)
Returns true if the input string starts with an uppercase letter.
|
static String |
suffixLines(String multiLines,
String suffix)
Suffixes each line with the argument suffix.
|
static String |
toPhrase(String string)
Converts into a string suitable as a human readable phrase, First
character is uppercase (the rest is left unchanged), words are separated
by a space.
|
static String |
toResourceMessage(String multiLines)
Converts any multi-line String into a version that is suitable to be
included as-is in properties resource bundle.
|
static String |
toResourceMessageKey(String string)
Converts the argument into a message key in a properties resource bundle,
all lowercase characters, words are separated by dots.
|
static String |
toSingleLine(String string)
Converts multi-line text into a single line, normalizing whitespace in the
process.
|
static String |
upperCamelCaseName(String string)
Returns the argument string as a camel cased name beginning with an
uppercased letter.
|
abbreviate, abbreviate, abbreviateMiddle, capitalise, capitaliseAllWords, capitalize, center, center, center, chomp, chomp, chompLast, chompLast, chop, chopNewline, clean, concatenate, contains, contains, containsAny, containsAny, containsIgnoreCase, containsNone, containsNone, containsOnly, containsOnly, countMatches, defaultIfBlank, defaultIfEmpty, defaultString, defaultString, deleteSpaces, deleteWhitespace, difference, endsWith, endsWithAny, endsWithIgnoreCase, equals, equalsIgnoreCase, escape, getChomp, getCommonPrefix, getLevenshteinDistance, getNestedString, getNestedString, getPrechomp, indexOf, indexOf, indexOf, indexOf, indexOfAny, indexOfAny, indexOfAny, indexOfAnyBut, indexOfAnyBut, indexOfDifference, indexOfDifference, indexOfIgnoreCase, indexOfIgnoreCase, isAllLowerCase, isAllUpperCase, isAlpha, isAlphanumeric, isAlphanumericSpace, isAlphaSpace, isAsciiPrintable, isBlank, isEmpty, isNotBlank, isNotEmpty, isNumeric, isNumericSpace, isWhitespace, join, join, join, join, join, join, join, join, join, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOfAny, lastIndexOfIgnoreCase, lastIndexOfIgnoreCase, lastOrdinalIndexOf, left, leftPad, leftPad, leftPad, length, lowerCase, lowerCase, mid, normalizeSpace, ordinalIndexOf, overlay, overlayString, prechomp, remove, remove, removeEnd, removeEndIgnoreCase, removeStart, removeStartIgnoreCase, repeat, repeat, replace, replace, replaceChars, replaceChars, replaceEach, replaceEachRepeatedly, replaceOnce, reverse, reverseDelimited, reverseDelimitedString, right, rightPad, rightPad, rightPad, split, split, split, split, splitByCharacterType, splitByCharacterTypeCamelCase, splitByWholeSeparator, splitByWholeSeparator, splitByWholeSeparatorPreserveAllTokens, splitByWholeSeparatorPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, startsWith, startsWithAny, startsWithIgnoreCase, strip, strip, stripAll, stripAll, stripEnd, stripStart, stripToEmpty, stripToNull, substring, substring, substringAfter, substringAfterLast, substringBefore, substringBeforeLast, substringBetween, substringBetween, substringsBetween, swapCase, trim, trimToEmpty, trimToNull, uncapitalise, uncapitalize, upperCase, upperCase
public StringUtilsHelper()
public static String replaceSuffix(String src, String suffixOld, String suffixNew)
Replaces a given suffix of the source string with a new one. If the suffix isn't present, the string is returned unmodified.
src
- the String
for which the suffix should be
replacedsuffixOld
- a String
with the suffix that should be
replacedsuffixNew
- a String
with the new suffixString
with the given suffix replaced or
unmodified if the suffix isn't presentpublic static String upperCamelCaseName(String string)
Returns the argument string as a camel cased name beginning with an uppercased letter.
Non word characters be removed and the letter following such a character will be uppercased.
string
- any stringpublic static String removeLastOccurrence(String string, String value)
string
- the String to remove the value
from.value
- the value to remove.public static String lowerCamelCaseName(String string)
Returns the argument string as a camel cased name beginning with a lowercased letter.
Non word characters be removed and the letter following such a character will be uppercased.
string
- any stringpublic static Boolean startsWithLowercaseLetter(String string)
string
- any stringpublic static Boolean startsWithUppercaseLetter(String string)
string
- any stringpublic static String toResourceMessageKey(String string)
string
- any stringpublic static String toPhrase(String string)
string
- any stringpublic static String separate(String string, String separator)
string
- separator
- public static String suffixLines(String multiLines, String suffix)
multiLines
- A String, optionally containing many linessuffix
- The suffix to append to the end of each linepublic static String toResourceMessage(String multiLines)
multiLines
- A String, optionally containing many linesnull
if the input String was blank.public static String prefixWithAPredicate(String word)
The characters 'a', 'e', 'i' and 'o' will yield the 'an' predicate while all the others will yield the 'a' predicate.
word
- the word needing the predicatepublic static String toSingleLine(String string)
string
- A String, may be nullpublic static String pluralize(String singularNoun)
noun
becomes nouns
key
becomes keys
word
becomes words
property
becomes properties
bus
becomes busses
boss
becomes bosses
Whitespace as well as null
arguments will return an
empty String.
singularNoun
- A singular noun to pluralizenull
or blank.public static String format(String plainText)
plainText
- format(String, String)
public static String format(String plainText, String indentation)
plainText
- indentation
- format(String, String, int)
public static String format(String plainText, String indentation, int wrapAtColumn)
plainText
- indentation
- wrapAtColumn
- format(String, String, int, boolean)
public static String format(String plainText, String indentation, int wrapAtColumn, boolean htmlStyle)
Formats the given argument with the specified indentation, wrapping the text at the desired column margin.
When enabling htmlStyle the returned text will be suitable for display in HTML environments such as JavaDoc, all newlines will be replaced by paragraphs.
This method trims the input text: all leading and trailing whitespace will be removed.
If for some reason this method would fail it will return the plainText argument.
plainText
- the text to format, the empty string will be returned in
case this argument is null
; long words will be
placed on a newline but will never be wrappedindentation
- the empty string will be used if this argument would
be null
wrapAtColumn
- does not take into account the length of the
indentation, needs to be strictly positivehtmlStyle
- whether or not to make sure the returned string is
suited for display in HTML environments such as JavaDocnull
IllegalArgumentException
- when the wrapAtColumn
argument is not strictly positivepublic static String getLineSeparator()
Copyright © 2003–2014 AndroMDA.org. All rights reserved.