com.geekologue.md4j.util
Class StringUtil

java.lang.Object
  extended by com.geekologue.md4j.util.StringUtil

public class StringUtil
extends java.lang.Object

Author:
Manos Batsis Jun 28, 2004

Constructor Summary
StringUtil()
           
 
Method Summary
static java.lang.String enforceTrailingChar(java.lang.String s, char c)
          Enforce a trailing '/' or '\' depending on platform, to ensure the path denotes a directory
static boolean equalsHash(java.lang.String s, java.lang.String hash, java.lang.String algorithm)
           
static boolean getBoolean(java.lang.Object o, boolean bDefault)
           
static java.util.Date getDate(java.lang.String s)
           
static java.lang.Double getDouble(java.lang.String s)
           
static java.lang.Float getFloat(java.lang.String s)
           
static java.lang.String getHash(java.lang.String s)
          Get an MD5 hash for the given string.
static java.lang.Integer getInteger(java.lang.String s)
           
static java.lang.Integer getIntegerOrZero(java.lang.String s)
           
static java.lang.Long getLong(java.lang.String s)
           
static java.lang.String getNullIfEmpty(java.lang.String s)
           
static java.lang.String getValueOrDefault(java.lang.String s, java.lang.String defaultValue)
           
static boolean isEmpty(java.lang.String s)
           
static boolean isInArray(java.lang.String s, java.lang.String[] arr)
          Look for the occurence of a string in an array.
static boolean isInArrayIgnoreCase(java.lang.String s, java.lang.String[] arr)
          Look for the occurence of a string in an array.
static java.lang.String toHex(java.lang.String s)
           
static java.lang.String toString(java.lang.Object obj)
          Return the string representation of a primitive array.
static java.lang.String toXMLString(java.lang.String str)
           
 
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

getNullIfEmpty

public static java.lang.String getNullIfEmpty(java.lang.String s)

getBoolean

public static boolean getBoolean(java.lang.Object o,
                                 boolean bDefault)

getInteger

public static java.lang.Integer getInteger(java.lang.String s)

getLong

public static java.lang.Long getLong(java.lang.String s)

getFloat

public static java.lang.Float getFloat(java.lang.String s)

getDouble

public static java.lang.Double getDouble(java.lang.String s)

getIntegerOrZero

public static java.lang.Integer getIntegerOrZero(java.lang.String s)

equalsHash

public static boolean equalsHash(java.lang.String s,
                                 java.lang.String hash,
                                 java.lang.String algorithm)
                          throws java.security.NoSuchAlgorithmException,
                                 java.io.UnsupportedEncodingException
Throws:
java.security.NoSuchAlgorithmException
java.io.UnsupportedEncodingException

getHash

public static java.lang.String getHash(java.lang.String s)
                                throws java.security.NoSuchAlgorithmException,
                                       java.io.UnsupportedEncodingException
Get an MD5 hash for the given string. Note : only MD5 mode has been tested.

Parameters:
s - The String to hash
algorithm - The algorithm to use (see finals). If if null, the default will be used (MD5)
Returns:
Throws:
java.security.NoSuchAlgorithmException
java.io.UnsupportedEncodingException

toHex

public static java.lang.String toHex(java.lang.String s)

isInArrayIgnoreCase

public static boolean isInArrayIgnoreCase(java.lang.String s,
                                          java.lang.String[] arr)
Look for the occurence of a string in an array. Case insensitive.

Parameters:
s - The string to look for
arr - The array of strings to look in
Returns:
True if the string is found in the array, false otherwise or if either of the arguments is null

isInArray

public static boolean isInArray(java.lang.String s,
                                java.lang.String[] arr)
Look for the occurence of a string in an array. Case sensitive.

Parameters:
s - The string to look for
arr - The array of strings to look in
Returns:
True if the string is found in the array, false otherwise or if either of the arguments is null

getValueOrDefault

public static java.lang.String getValueOrDefault(java.lang.String s,
                                                 java.lang.String defaultValue)

toString

public static java.lang.String toString(java.lang.Object obj)
Return the string representation of a primitive array. Uses the AbstractCollection.toString format.

Parameters:
obj - the array
Returns:
the string representation

isEmpty

public static boolean isEmpty(java.lang.String s)

toXMLString

public static java.lang.String toXMLString(java.lang.String str)

enforceTrailingChar

public static java.lang.String enforceTrailingChar(java.lang.String s,
                                                   char c)
Enforce a trailing '/' or '\' depending on platform, to ensure the path denotes a directory

Parameters:
s -
Returns:

getDate

public static java.util.Date getDate(java.lang.String s)
Parameters:
string -
Returns:


Copyright © 2003-2007 Manos Batsis. All Rights Reserved.