java.lang.Objectorg.objectweb.telosys.util.StrUtil
Utility class for String operations
Method Summary | |
static int |
countChar(java.lang.String s,
char c)
Count the number of occurrences of the given character in the given string |
static boolean |
getBoolean(java.lang.String sVal)
Converts the given string to boolean, without Exception. |
static java.util.Date |
getDate(java.lang.String sDate)
Returns the Date instance corresponding to the given date/time/datetime parameter in ISO format : . "" or null : returns null . |
static java.sql.Date |
getDateFR(java.lang.String sDate)
Return a date instance from a date in French format |
static java.sql.Date |
getDateISO(java.lang.String sDate)
Return a date instance from a date in ISO format |
static double |
getDouble(java.lang.String sVal)
Converts the given string to double, without Exception. |
static double |
getDouble(java.lang.String sVal,
double dDefaultValue)
Converts the given string to double, without Exception. |
static double |
getDoubleStrict(java.lang.String sVal)
Converts the given string to double, throws an Exception if the value cannot be converted. |
static int |
getInt(java.lang.String sVal)
Converts the given string to integer, without Exception. |
static int |
getInt(java.lang.String sVal,
int iDefaultValue)
Converts the given string to integer, without Exception. |
static int |
getIntStrict(java.lang.String sVal)
Converts the given string to integer, throws an Exception if the value cannot be converted. |
static java.lang.String |
getLimitedString(java.lang.String sVal,
int iMaxLength)
Returns a truncated string if its length exceed the max parameter. |
static java.lang.String |
getProtectedString(java.lang.String sVal)
Replaces all the '"' characters by '"', returns "" if the given string is null |
static boolean |
isFirstCharAlpha(java.lang.String s)
Returns TRUE if the first character of the string is an alphabetic character ( from 'a' to 'z' and from 'A' to 'Z' ) |
static java.lang.String |
notNull(java.lang.String s)
Returns a "not null" string |
static boolean |
nullOrVoid(java.lang.String s)
Returns true if the given String is null or void or blank ( "", " ", " " ) |
static java.lang.String |
removeAllBlanks(java.lang.String s)
Remove all the blank characters in the given string eg : returns "abc" for " a b c " |
static java.lang.String |
removeQuotes(java.lang.String s,
char c)
Removes the quote characters if they are located at the first and last position of the string The string is returned "as is" if there's no quotes at the begining and at the end |
static java.lang.String |
replaceVar(java.lang.String s,
java.lang.String sVarName,
java.lang.String sVarValue)
Replace the given variable name by the given value Only the first occurrence of the variable is replaced. |
static java.lang.String[] |
split(java.lang.String s,
char c)
Split a string using the given char as separator ( simple split without "reg exp" ) |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static int countChar(java.lang.String s, char c)
s
- c
-
public static boolean getBoolean(java.lang.String sVal)
sVal
- : the string to convert
public static java.lang.String getLimitedString(java.lang.String sVal, int iMaxLength)
sVal
- :iMaxLength
- :
public static java.lang.String getProtectedString(java.lang.String sVal)
sVal
- :
public static java.lang.String notNull(java.lang.String s)
s
- :
public static boolean nullOrVoid(java.lang.String s)
s
-
public static int getInt(java.lang.String sVal, int iDefaultValue)
sVal
- value to convertiDefaultValue
- default value to use if the string is null or contains an invalid integer value
public static int getIntStrict(java.lang.String sVal)
sVal
-
TelosysRuntimeException
- if the given value is null or invalidpublic static int getInt(java.lang.String sVal)
sVal
-
public static double getDouble(java.lang.String sVal, double dDefaultValue)
sVal
- value to convertdDefaultValue
- : Default value if the string is null or contains an invalid value
public static double getDoubleStrict(java.lang.String sVal)
sVal
-
TelosysRuntimeException
- if the given value is null or invalidpublic static double getDouble(java.lang.String sVal)
sVal
- value to convert
public static java.util.Date getDate(java.lang.String sDate)
sDate
-
TelosysRuntimeException
- if the given string cannot be convertedpublic static java.sql.Date getDateFR(java.lang.String sDate)
sDate
- : date in French format ( "DD/MM/YYYY" )
public static java.sql.Date getDateISO(java.lang.String sDate)
sDate
- : date in ISO format ( "YYYY-MM-DD" )
public static final java.lang.String removeAllBlanks(java.lang.String s)
s
-
public static java.lang.String removeQuotes(java.lang.String s, char c)
s
- the stringc
- the quote character to use ( eg '\'', '"' )
public static java.lang.String[] split(java.lang.String s, char c)
s
- : the string to splitc
- : the separator
public static boolean isFirstCharAlpha(java.lang.String s)
s
-
public static java.lang.String replaceVar(java.lang.String s, java.lang.String sVarName, java.lang.String sVarValue)
s
- the initial string ( e.g. "bla bla bla ${MyVar} bla bla" )sVarName
- the variable name ( e.g. "${MyVar}" )sVarValue
- the variable value