public class StringUtil extends Object
Constructor and Description |
---|
StringUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
escapeHtmlLight(String s) |
static String |
formatDuration(long time)
This method will format the long to a string like this:
3d17:23:47 where d=days h=hours m=minutes s=seconds |
static boolean |
getBoolean(String s) |
static boolean |
getBoolean(String pStr,
boolean pDefaultValue)
This method will return
true if and only if the attribute s
are equal with either of the String below:
true
yes
on
active
1
else false is returned. |
static String |
getStringValue(Object pValue)
Returns a
String for the passed value. |
static boolean |
isEmpty(String pStr)
Tests a string, to see if it is null or an empty String.
|
static Map |
parseStringMap(String pString,
String pSeparator,
String pEqual)
Parses a key=value String separated by a given set of characters, into an
Map of Strings. |
static Map |
parseStringMap(String str,
String sep,
String equal,
boolean keyToInteger,
boolean valueToInteger)
Parses a key=value String separated by a given set of characters, into an
Map of Strings. |
public static String NEWLINE
public static boolean isEmpty(String pStr)
pStr
- The string to checkpublic static Map parseStringMap(String pString, String pSeparator, String pEqual)
Map
of Strings. Example: key1=value2,key2=value2.pString
- the string we want to parsepSeparator
- the separator (Example: ,)pEqual
- the key - value separator (Example: =)Map
. Rerturns null
if the input string is null or emptypublic static Map parseStringMap(String str, String sep, String equal, boolean keyToInteger, boolean valueToInteger)
Map
of Strings. Example: key1=value2,key2=value2.str
- the string we want to parsesep
- the separator (Example: ,)equal
- the key - value separator (Example: =)keyToInteger
- convert the key to Integer. If this fails the key/value will be inserted as stringsvalueToInteger
- convert the value to Integer. If this fails the key/value will be inserted as stringsMap
. Rerturns null
if the input string is null or emptypublic static boolean getBoolean(String pStr, boolean pDefaultValue)
true
if and only if the attribute s
are equal with either of the String
below:
pStr
- the String we will checkpDefaultValue
- the default value to return if s is null
true
if the String s is true, default
if the s is null
, else false.public static boolean getBoolean(String s)
public static String formatDuration(long time)
If the biggest timeunit is 0 it will not be displayed.
time
- the time to be formatedpublic static String getStringValue(Object pValue)
String
for the passed value.
Mostly, this will just correspond to the toString()
but in rare cases were the this method returns non intuitive
results, this method will return an improved representation of
pValue
.
If null
is passed, an empty string is returned.pValue
- The value© 1998- 2018 Stibo DX