org.javaWebGen.util
Class StringUtil

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

public abstract class StringUtil
extends java.lang.Object

Misc static String methods that needed a home somewhere

Version:
$Revision: 1.2 $
Author:
Kevin Scott

Constructor Summary
StringUtil()
           
 
Method Summary
static java.lang.String covertBytes(byte[] buffer)
          converts a byte array to a printable string will ignore empty byte that =0 used to covert byte[] buffers to a string
static java.lang.String replace(java.lang.String input, java.lang.Object[] parms)
          replace text special tags(IE {1}) in a string like MessageFormat except it can handle unlimited number of parms (IE >10).
static java.lang.String replace(java.lang.String input, java.lang.String searchText, java.lang.String replaceText)
          replace text in a string will replaces All occurrences of the search String.
static java.lang.String SHAencode(java.lang.String input)
          Encode a string using SHA1 Message Digest
static java.lang.String sqlEsc(java.lang.String text, java.lang.String withText)
          Used to escape ' with withText
static java.lang.String sqlEscWithBackslash(java.lang.String input)
          Used to escape sql strings replaces ' whith \'
static java.lang.String sqlEscWithSingleQuote(java.lang.String input)
           
static java.lang.String truncate(int size, java.lang.String input)
          Returns a string truncated to a specific size ignoring training spaces
 
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

covertBytes

public static java.lang.String covertBytes(byte[] buffer)
converts a byte array to a printable string will ignore empty byte that =0 used to covert byte[] buffers to a string

Parameters:
buffer - of bytes to convert to a string
Returns:
a string from a byte array

replace

public static java.lang.String replace(java.lang.String input,
                                       java.lang.Object[] parms)
replace text special tags(IE {1}) in a string like MessageFormat except it can handle unlimited number of parms (IE >10). Will skip parms if it can not find the correct tag

Parameters:
input - text
parms - parameters
Returns:
finished string with substitution
See Also:
MessageFormat

replace

public static java.lang.String replace(java.lang.String input,
                                       java.lang.String searchText,
                                       java.lang.String replaceText)
replace text in a string will replaces All occurrences of the search String. BEWARE it returns null if searchText and replaceText are equal

Parameters:
input - text to search in
searchText - to search for
replaceText - to replace search string with
Returns:
finished text

SHAencode

public static java.lang.String SHAencode(java.lang.String input)
Encode a string using SHA1 Message Digest

Parameters:
input -
Returns:
hash of input string

truncate

public static java.lang.String truncate(int size,
                                        java.lang.String input)
Returns a string truncated to a specific size ignoring training spaces

Parameters:
size - number of chars to allow
input -
Returns:
truncated String

sqlEscWithSingleQuote

public static java.lang.String sqlEscWithSingleQuote(java.lang.String input)

sqlEscWithBackslash

public static java.lang.String sqlEscWithBackslash(java.lang.String input)
Used to escape sql strings replaces ' whith \'

Parameters:
input - text
Returns:
text that is escaped text

sqlEsc

public static java.lang.String sqlEsc(java.lang.String text,
                                      java.lang.String withText)
Used to escape ' with withText

Parameters:
text - to add escape chars
withText - string to escape with
Returns:
text that is escaped


Copyright(C) 2003-2006 Kevin Scott - All Rights Reserved.