Package dev.aherscu.qa.testing.utils
Class StringUtilsExtensions
- java.lang.Object
-
- org.apache.commons.lang3.StringUtils
-
- dev.aherscu.qa.testing.utils.StringUtilsExtensions
-
@ThreadSafe public class StringUtilsExtensions extends org.apache.commons.lang3.StringUtils
Provides enhanced string utilities.- Author:
- aherscu
-
-
Field Summary
Fields Modifier and Type Field Description static String
COLON
A colon.static String
COMMA
A comma.static String
DASH
A dash.static String
DOT
A dot.static String
DOUBLE_QUOTE
A double quote.static String
ELLIPSIS
An ellipsis is tree dots.static String
EQUAL
A equal.static String
QUOTE
A single quote.static String
SEMI
A semi-colon.static String
SLASH
A forward slash.static String
UNDERSCORE
-
Constructor Summary
Constructors Constructor Description StringUtilsExtensions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
abbreviate(String str, int maxWidth)
static String
abbreviateMiddle(String str, String middle, int length)
static String
format(String template, String pattern, String string)
static String
format(String template, Pattern pattern, String string)
static Collection<String>
groups(String pattern, String string)
static Collection<String>
groups(Pattern pattern, String string)
Splits a string according to specified regular expression groups.static String
ifExcessiveLength(String str, int allowedLength)
If given string has excessive length return its length.static String
left(String str, int length)
static String
length(String str)
Formats the length of given string.static String
length(String str, String format)
Formats the length of given string.static String
prettified(Object object)
Returns the prettified version of an object.static String
substring(String s, Pattern regex)
Extracts a substring by specified regular expression.static String
toUnix(String str)
Converts Windows end-of-line to *nix end-of-line.-
Methods inherited from class org.apache.commons.lang3.StringUtils
abbreviate, abbreviate, abbreviate, appendIfMissing, appendIfMissingIgnoreCase, capitalize, center, center, center, chomp, chomp, chop, compare, compare, compareIgnoreCase, compareIgnoreCase, contains, contains, containsAny, containsAny, containsAny, containsAnyIgnoreCase, containsIgnoreCase, containsNone, containsNone, containsOnly, containsOnly, containsWhitespace, countMatches, countMatches, defaultIfBlank, defaultIfEmpty, defaultString, defaultString, deleteWhitespace, difference, endsWith, endsWithAny, endsWithIgnoreCase, equals, equalsAny, equalsAnyIgnoreCase, equalsIgnoreCase, firstNonBlank, firstNonEmpty, getBytes, getBytes, getCommonPrefix, getDigits, getFuzzyDistance, getIfBlank, getIfEmpty, getJaroWinklerDistance, getLevenshteinDistance, getLevenshteinDistance, indexOf, indexOf, indexOf, indexOf, indexOfAny, indexOfAny, indexOfAny, indexOfAnyBut, indexOfAnyBut, indexOfDifference, indexOfDifference, indexOfIgnoreCase, indexOfIgnoreCase, isAllBlank, isAllEmpty, isAllLowerCase, isAllUpperCase, isAlpha, isAlphanumeric, isAlphanumericSpace, isAlphaSpace, isAnyBlank, isAnyEmpty, isAsciiPrintable, isBlank, isEmpty, isMixedCase, isNoneBlank, isNoneEmpty, isNotBlank, isNotEmpty, isNumeric, isNumericSpace, isWhitespace, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, joinWith, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOfAny, lastIndexOfIgnoreCase, lastIndexOfIgnoreCase, lastOrdinalIndexOf, leftPad, leftPad, leftPad, length, lowerCase, lowerCase, mid, normalizeSpace, ordinalIndexOf, overlay, prependIfMissing, prependIfMissingIgnoreCase, remove, remove, removeAll, removeEnd, removeEndIgnoreCase, removeFirst, removeIgnoreCase, removePattern, removeStart, removeStart, removeStartIgnoreCase, repeat, repeat, repeat, replace, replace, replaceAll, replaceChars, replaceChars, replaceEach, replaceEachRepeatedly, replaceFirst, replaceIgnoreCase, replaceIgnoreCase, replaceOnce, replaceOnceIgnoreCase, replacePattern, reverse, reverseDelimited, right, rightPad, rightPad, rightPad, rotate, split, split, split, split, splitByCharacterType, splitByCharacterTypeCamelCase, splitByWholeSeparator, splitByWholeSeparator, splitByWholeSeparatorPreserveAllTokens, splitByWholeSeparatorPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, startsWith, startsWithAny, startsWithIgnoreCase, strip, strip, stripAccents, stripAll, stripAll, stripEnd, stripStart, stripToEmpty, stripToNull, substring, substring, substringAfter, substringAfter, substringAfterLast, substringAfterLast, substringBefore, substringBefore, substringBeforeLast, substringBetween, substringBetween, substringsBetween, swapCase, toCodePoints, toEncodedString, toRootLowerCase, toRootUpperCase, toString, trim, trimToEmpty, trimToNull, truncate, truncate, uncapitalize, unwrap, unwrap, upperCase, upperCase, valueOf, wrap, wrap, wrapIfMissing, wrapIfMissing
-
-
-
-
Field Detail
-
COLON
public static final String COLON
A colon.- See Also:
- Constant Field Values
-
COMMA
public static final String COMMA
A comma.- See Also:
- Constant Field Values
-
DASH
public static final String DASH
A dash.- See Also:
- Constant Field Values
-
DOT
public static final String DOT
A dot.- See Also:
- Constant Field Values
-
DOUBLE_QUOTE
public static final String DOUBLE_QUOTE
A double quote.- See Also:
- Constant Field Values
-
ELLIPSIS
public static final String ELLIPSIS
An ellipsis is tree dots.- See Also:
- Constant Field Values
-
EQUAL
public static final String EQUAL
A equal.- See Also:
- Constant Field Values
-
QUOTE
public static final String QUOTE
A single quote.- See Also:
- Constant Field Values
-
SEMI
public static final String SEMI
A semi-colon.- See Also:
- Constant Field Values
-
SLASH
public static final String SLASH
A forward slash.- See Also:
- Constant Field Values
-
UNDERSCORE
public static final String UNDERSCORE
- See Also:
- Constant Field Values
-
-
Method Detail
-
groups
public static Collection<String> groups(Pattern pattern, String string)
Splits a string according to specified regular expression groups.groups("(\\d+)(\\w+)", "10FF 99GG")
will return four items: "10", "FF", "99", "GG"- Parameters:
pattern
- compiled regular expression to apply; must contain groupsstring
- the string to split- Returns:
- split string
-
groups
public static Collection<String> groups(String pattern, String string)
-
ifExcessiveLength
public static String ifExcessiveLength(String str, int allowedLength)
If given string has excessive length return its length.- Parameters:
str
- the string to be processedallowedLength
- the allowed length- Returns:
- the length of the string as formatted by
length(String)
-
length
public static String length(String str)
Formats the length of given string.- Parameters:
str
- the string for which to return the length- Returns:
- the length of the string formatted as
(ddd chars)
, where ddd is the actual length
-
length
public static String length(String str, String format)
Formats the length of given string.- Parameters:
str
- the string for which to return the lengthformat
- the template to use for formatting; seeString.format(String, Object...)
- Returns:
- the length of the string formatted as
(ddd chars)
, where ddd is the actual length
-
prettified
public static String prettified(Object object)
Returns the prettified version of an object.- Parameters:
object
- the object- Returns:
<<null>>
fornull
,<<empty>>
for object with length0
, and<<blank>>
for object containing only whitespace characters according toStringUtils.isBlank(CharSequence)
-
substring
public static String substring(String s, Pattern regex)
Extracts a substring by specified regular expression.- Parameters:
s
- the string to extract fromregex
- the regular expression- Returns:
- substring extracted; empty if no match could be found
-
-