org.objectweb.telosys.util
Class StrUtil

java.lang.Object
  extended byorg.objectweb.telosys.util.StrUtil

public final class StrUtil
extends java.lang.Object


Method Summary
static int countChar(java.lang.String s, char c)
          Count the number of occurrence of the given chararcter in the given string
static boolean getBoolean(java.lang.String sVal)
           
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)
           
static double getDouble(java.lang.String sVal, double dDefaultValue)
           
static int getInt(java.lang.String sVal)
           
static int getInt(java.lang.String sVal, int iDefaultValue)
           
static java.lang.String getLimitedString(java.lang.String sVal, int iMaxLength)
           
static java.lang.String getProtectedString(java.lang.String sVal)
           
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)
           
static boolean nullOrVoid(java.lang.String s)
          Returns true if the given String is null or void ( "", " ", " " )
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
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

countChar

public static int countChar(java.lang.String s,
                            char c)
Count the number of occurrence of the given chararcter in the given string

Parameters:
s -
c -
Returns:
the number of char c in string s

getBoolean

public static boolean getBoolean(java.lang.String sVal)
Parameters:
sVal - : the string to convert
Returns:
boolean : true is the string is "1" or "true" ( after trim ), else ( other values or null ) false

getLimitedString

public static java.lang.String getLimitedString(java.lang.String sVal,
                                                int iMaxLength)
Parameters:
sVal - :
iMaxLength - :
Returns:
String :

getProtectedString

public static java.lang.String getProtectedString(java.lang.String sVal)
Parameters:
sVal - :
Returns:
String : chaine avec caractères protégés

notNull

public static java.lang.String notNull(java.lang.String s)
Parameters:
s - :
Returns:
String :

nullOrVoid

public static boolean nullOrVoid(java.lang.String s)
Returns true if the given String is null or void ( "", " ", " " )

Parameters:
s -
Returns:

getInt

public static int getInt(java.lang.String sVal,
                         int iDefaultValue)
Parameters:
sVal - : String value to convert
iDefaultValue - : Default value if the string is null or contains an invalid integer value
Returns:

getInt

public static int getInt(java.lang.String sVal)
Parameters:
sVal - :
Returns:
int :

getDouble

public static double getDouble(java.lang.String sVal,
                               double dDefaultValue)
Parameters:
sVal - : String value to convert
dDefaultValue - : Default value if the string is null or contains an invalid value
Returns:

getDouble

public static double getDouble(java.lang.String sVal)
Parameters:
sVal - :
Returns:
int :

getDateFR

public static java.sql.Date getDateFR(java.lang.String sDate)
Return a date instance from a date in French format

Parameters:
sDate - : date in French format ( "DD/MM/YYYY" )
Returns:
java.sql.Date : the date instance ( or null is the input date is not valid )

getDateISO

public static java.sql.Date getDateISO(java.lang.String sDate)
Return a date instance from a date in ISO format

Parameters:
sDate - : date in ISO format ( "YYYY-MM-DD" )
Returns:
java.sql.Date : the date instance ( or null is the input date is not valid )

removeQuotes

public 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

Parameters:
s - the string
c - the quote character to use ( eg '\'', '"' )
Returns:

split

public 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" )

Parameters:
s - : the string to split
c - : the separator
Returns:
: array of 'tokens' ( never null, size = 0 if the string is null, else 1 to N )

isFirstCharAlpha

public 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' )

Parameters:
s -
Returns:

replaceVar

public 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

Parameters:
s - the initial string ( e.g. "bla bla bla ${MyVar} bla bla" )
sVarName - the variable name ( e.g. "${MyVar}" )
sVarValue - the variable value
Returns:
the string after variable replacement