goldengate.common.utility
Class GgStringUtils

java.lang.Object
  extended by goldengate.common.utility.GgStringUtils

public class GgStringUtils
extends Object

Various utilities for reading files, transforming dates, ...

Author:
Frederic Bregier

Field Summary
static Charset UTF8
          Format used for Files
 
Constructor Summary
GgStringUtils()
           
 
Method Summary
static String fillString(char fillChar, int count)
          Build a String with count chars using fillChar
static Timestamp fixDate(String date)
          Get a date in String and return the corresponding Timestamp
static Timestamp fixDate(String date, Timestamp before)
          From a date in String format and a Timestamp, return the Timestamp as :
if before = null as date
if before !
static boolean getBoolean(org.dom4j.Node node)
          Read a boolean value (0,1,true,false) from a node
static int getInteger(org.dom4j.Node node)
          Read an integer value from a node
static String readFile(String filename)
          Read file and return "" if an error occurs
static String readFileException(String filename)
          Read a file and return its content in String format
static boolean replace(StringBuilder builder, String find, String replace)
          Make a replacement of first "find" string by "replace" string into the StringBuilder
static void replaceAll(StringBuilder builder, String find, String replace)
          Make replacement of all "find" string by "replace" string into the StringBuilder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF8

public static final Charset UTF8
Format used for Files

Constructor Detail

GgStringUtils

public GgStringUtils()
Method Detail

readFileException

public static String readFileException(String filename)
                                throws InvalidArgumentException,
                                       FileTransferException
Read a file and return its content in String format

Parameters:
filename -
Returns:
the content of the File in String format
Throws:
InvalidArgumentException - for File not found
FileTransferException - for reading exception

readFile

public static String readFile(String filename)
Read file and return "" if an error occurs

Parameters:
filename -
Returns:
the string associated with the file, or "" if an error occurs

fixDate

public static Timestamp fixDate(String date)
Get a date in String and return the corresponding Timestamp

Parameters:
date -
Returns:
the corresponding Timestamp

fixDate

public static Timestamp fixDate(String date,
                                Timestamp before)
From a date in String format and a Timestamp, return the Timestamp as :
if before = null as date
if before != null and before < date, as date
if before != null and before >= date, as before end of day (23:59:59:9999)

Parameters:
date -
before -
Returns:
the end date

getBoolean

public static boolean getBoolean(org.dom4j.Node node)
Read a boolean value (0,1,true,false) from a node

Parameters:
node -
Returns:
the corresponding value

getInteger

public static int getInteger(org.dom4j.Node node)
                      throws InvalidArgumentException
Read an integer value from a node

Parameters:
node -
Returns:
the corresponding value
Throws:
InvalidArgumentException

replace

public static boolean replace(StringBuilder builder,
                              String find,
                              String replace)
Make a replacement of first "find" string by "replace" string into the StringBuilder

Parameters:
builder -
find -
replace -

replaceAll

public static void replaceAll(StringBuilder builder,
                              String find,
                              String replace)
Make replacement of all "find" string by "replace" string into the StringBuilder

Parameters:
builder -
find -
replace -

fillString

public static String fillString(char fillChar,
                                int count)
Build a String with count chars using fillChar

Parameters:
fillChar -
count -
Returns:
the String of length count filled with fillChar


Copyright © 2009-2012 Frederic Bregier. All Rights Reserved.