org.placidus.util
Class StringUtil

java.lang.Object
  extended by org.placidus.util.StringUtil

public class StringUtil
extends java.lang.Object

Class is a util class which helper functions for strings.


Constructor Summary
StringUtil()
           
 
Method Summary
static boolean equals(java.lang.String str1, java.lang.String str2)
          Advanced compare of 2 strings: o) if both are null, true will be returned o) if only one of them is null or they does not match, false will be returned
static int getCount(java.lang.String value, java.lang.String stringToSearchFor)
          Counts occurrence of given stringToSearchFor in given value
static long getLong(java.lang.String value)
          Converts given string to long value, if given string is null or empty, 0 will be returned
static java.lang.String getString(long value)
          Creates a string for the given long, if given long is 0, null will be returned
static boolean isEmpty(java.lang.String str)
          Checks if given string is null or empty
static java.lang.String replaceProperties(java.lang.String strContent, java.util.Map<java.lang.String,? extends java.lang.Object> params, java.lang.String startSymbol, java.lang.String endSymbol)
          replaces any occurense of a variable with given parameters
static java.util.List<java.lang.String> splitStringToArrayList(java.lang.String pToSplit, java.lang.String pRegExp)
          To split given string with regexp into a List of strings
static int[] toIntArray(java.util.List<java.lang.String> stringList)
          To convert the given List of strings into an int array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringUtil

public StringUtil()
Method Detail

equals

public static boolean equals(java.lang.String str1,
                             java.lang.String str2)
Advanced compare of 2 strings: o) if both are null, true will be returned o) if only one of them is null or they does not match, false will be returned

Parameters:
str1 - to check
str2 - to check
Returns:
true if strings are equal, or both are null

isEmpty

public static boolean isEmpty(java.lang.String str)
Checks if given string is null or empty

Parameters:
str - to check
Returns:
true if given string is null or empty, otherwise false

getString

public static java.lang.String getString(long value)
Creates a string for the given long, if given long is 0, null will be returned

Parameters:
value - to convert
Returns:
String of given long value, null if given long value was 0

getLong

public static long getLong(java.lang.String value)
Converts given string to long value, if given string is null or empty, 0 will be returned

Parameters:
value - to convert
Returns:
long for given string or 0 if string is null or empty

getCount

public static int getCount(java.lang.String value,
                           java.lang.String stringToSearchFor)
Counts occurrence of given stringToSearchFor in given value

Parameters:
value - to search in
stringToSearchFor - string to search
Returns:
occurrencenumber

splitStringToArrayList

public static java.util.List<java.lang.String> splitStringToArrayList(java.lang.String pToSplit,
                                                                      java.lang.String pRegExp)
To split given string with regexp into a List of strings

Parameters:
pToSplit - string to split
pRegExp - regexp to use
Returns:
List of strings

toIntArray

public static int[] toIntArray(java.util.List<java.lang.String> stringList)
To convert the given List of strings into an int array

Parameters:
stringList - to convert
Returns:
int array for given List of strings, or null if list is null or empty

replaceProperties

public static java.lang.String replaceProperties(java.lang.String strContent,
                                                 java.util.Map<java.lang.String,? extends java.lang.Object> params,
                                                 java.lang.String startSymbol,
                                                 java.lang.String endSymbol)
                                          throws PlacidusException
replaces any occurense of a variable with given parameters

Parameters:
strContent - content to search/replace
params - parameter-values to replace
startSymbol - symbol which defines variable start
endSymbol - symbol which defines variable end
Returns:
new replaces stringcontent
Throws:
PlacidusException - if startsymbol doesnt has an end symbol


Copyright © 2006 DS. All Rights Reserved.