Class Strings
- java.lang.Object
-
- org.jboss.hal.resources.Strings
-
public final class Strings extends Object
Collection of string helper methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringabbreviate(String str, int offset, int maxWidth)static StringabbreviateFqClassName(String fqcn)static StringabbreviateMiddle(String string, int maxLength)static Stringcapitalize(String str)static StringgetDomain(String url)static StringgetParent(String path)static Stringsanitize(String str)static Stringstrip(String str, String stripChars)Strips any of a set of characters from the start and end of a String.static StringstripEnd(String str, String stripChars)Strips any of a set of characters from the end of a String.static StringstripStart(String str, String stripChars)Strips any of a set of characters from the start of a String.static StringsubstringAfterLast(String str, String separator)
-
-
-
Method Detail
-
strip
public static String strip(String str, String stripChars)
Strips any of a set of characters from the start and end of a String. This is similar to
String.trim()but allows the characters to be stripped to be controlled.A
nullinput String returnsnull. An empty string ("") input returns the empty string.StringUtils.strip(null, *) = null StringUtils.strip("", *) = "" StringUtils.strip("abc", null) = "abc" StringUtils.strip(" abc", null) = "abc" StringUtils.strip("abc ", null) = "abc" StringUtils.strip(" abc ", null) = "abc" StringUtils.strip(" abcyx", "xyz") = " abc"- Parameters:
str- the String to remove characters from, may be nullstripChars- the characters to remove, null treated as whitespace- Returns:
- the stripped String,
nullif null String input
-
stripStart
public static String stripStart(String str, String stripChars)
Strips any of a set of characters from the start of a String.
A
nullinput String returnsnull. An empty string ("") input returns the empty string.If the stripChars String is
null, whitespace is stripped as defined byCharacter.isWhitespace(char).StringUtils.stripStart(null, *) = null StringUtils.stripStart("", *) = "" StringUtils.stripStart("abc", "") = "abc" StringUtils.stripStart("abc", null) = "abc" StringUtils.stripStart(" abc", null) = "abc" StringUtils.stripStart("abc ", null) = "abc " StringUtils.stripStart(" abc ", null) = "abc " StringUtils.stripStart("yxabc ", "xyz") = "abc "- Parameters:
str- the String to remove characters from, may be nullstripChars- the characters to remove, null treated as whitespace- Returns:
- the stripped String,
nullif null String input
-
stripEnd
public static String stripEnd(String str, String stripChars)
Strips any of a set of characters from the end of a String.
A
nullinput String returnsnull. An empty string ("") input returns the empty string.If the stripChars String is
null, whitespace is stripped as defined byCharacter.isWhitespace(char).StringUtils.stripEnd(null, *) = null StringUtils.stripEnd("", *) = "" StringUtils.stripEnd("abc", "") = "abc" StringUtils.stripEnd("abc", null) = "abc" StringUtils.stripEnd(" abc", null) = " abc" StringUtils.stripEnd("abc ", null) = "abc" StringUtils.stripEnd(" abc ", null) = " abc" StringUtils.stripEnd(" abcyx", "xyz") = " abc" StringUtils.stripEnd("120.00", ".0") = "12"- Parameters:
str- the String to remove characters from, may be nullstripChars- the set of characters to remove, null treated as whitespace- Returns:
- the stripped String,
nullif null String input
-
-