Package org.jmxtrans.embedded.util
Class StringUtils2
java.lang.Object
org.jmxtrans.embedded.util.StringUtils2
public class StringUtils2 extends Object
Yet another
StringUtils class.- Author:
- Cyrille Le Clerc
-
Method Summary
Modifier and Type Method Description static Stringabbreviate(String str, int max)Abbreviates a String using ellipses.static List<String>delimitedStringToList(String delimitedString)Split given String.static booleanisNullOrEmpty(String value)static Stringjoin(List<String> tokens, String delimiter)Join giventokenswith givendelimiter.static StringreverseTokens(String str, String delimiter)Reverse tokens of given tokenizedstr.
-
Method Details
-
delimitedStringToList
Split given String. Delimiters are",",";"and"\n".- Parameters:
delimitedString-- Returns:
- splitted string or
nullif givendelimitedStringisnull
-
join
Join giventokenswith givendelimiter. Sample: tokens"com", "mycompany, "ecommerce", "server1"with delimiter"."returns"com.mycompany.ecommerce.server1".- Parameters:
tokens-delimiter-- Returns:
- the joined tokens (
nullif giventokensisnull
-
reverseTokens
Reverse tokens of given tokenized
str.Sample: "server1.ecommerce.mycompany.com" returns
"com.mycompany.ecommerce.server1".- Parameters:
str-delimiter-- Returns:
- reversed string or
nullif given string isnull
-
isNullOrEmpty
-
abbreviate
Abbreviates a String using ellipses. This will turn "Now is the time for all good men" into "Now is the time for..."- Parameters:
str- the String to abbreviatemax- the max number of chars of the abbreviated String- Returns:
- the abbreviated string
-