com.blackbear.flatworm
Class Util

java.lang.Object
  extended by com.blackbear.flatworm.Util

public final class Util
extends java.lang.Object

Static final class to hold string manipulation methods


Constructor Summary
Util()
           
 
Method Summary
static java.lang.String defaultValue(java.lang.String str, java.lang.String value, java.util.HashMap options)
          If str is length zero (after trimming), value is returned.
static java.lang.String formatDate(java.util.Date date, java.lang.String defaultDateFormat, java.util.HashMap options)
          Different from the method in CoreConverters, this one is used for file creation

Specified in flatworm XML file like: <conversion-option name="format" value="yyyy-MM-dd"/>
static java.lang.String getValue(java.util.HashMap options, java.lang.String key)
          Conversion-Option now stored in class, more than a simple Hashmap lookup
static java.lang.String justify(java.lang.String str, java.lang.String value, java.util.HashMap options, int length)
          Removes pre-determined chracters from string based on Java Patterns

Specified in flatworm XML file like: <conversion-option name="justify" value="right"/>
static java.lang.String[] split(java.lang.String str, char chrSplit, char chrQuote)
          split divides a string into many strings based on a delimiter The main difference between this split and the one that comes with Java is this one will ignore delimiters that are within quoted fields NOTE: Delimiter will be ignored once chrQuote is encountered.
static java.lang.String strip(java.lang.String str, java.lang.String value, java.util.HashMap options)
          Removes pre-determined chracters from string based on Java Patterns

Specified in flatworm XML file like: <conversion-option name="strip-chars" value="non-numeric"/>
static java.lang.String substring(java.lang.String str, java.lang.String value, java.util.HashMap options)
          

Specified in flatworm XML file like: <conversion-option name="substring" value="1,10"/>
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

split

public static java.lang.String[] split(java.lang.String str,
                                       char chrSplit,
                                       char chrQuote)
split divides a string into many strings based on a delimiter The main difference between this split and the one that comes with Java is this one will ignore delimiters that are within quoted fields

NOTE: Delimiter will be ignored once chrQuote is encountered. Consideration will begin once matching chrQuote is encountered

Parameters:
String - you want to split
char - you want to split the string on
char - you want to be considered to be your quoting character
Returns:
String[] String array containing results

formatDate

public static java.lang.String formatDate(java.util.Date date,
                                          java.lang.String defaultDateFormat,
                                          java.util.HashMap options)
                                   throws java.lang.Exception
Different from the method in CoreConverters, this one is used for file creation

Specified in flatworm XML file like: <conversion-option name="format" value="yyyy-MM-dd"/>

Parameters:
Date - to be converted to a string
String - defaultDateFormat is provided by FileCreator and is used when the date format is not supplied in the Flatworm XML file
HashMap - collection of ConversionOptions to gather further justification options
Returns:
String
Throws:
java.lang.Exception - - if date format is not specified in the XML file or given to FileCreator. At least one must be specified.

justify

public static java.lang.String justify(java.lang.String str,
                                       java.lang.String value,
                                       java.util.HashMap options,
                                       int length)
Removes pre-determined chracters from string based on Java Patterns

Specified in flatworm XML file like: <conversion-option name="justify" value="right"/>

Parameters:
String - field to be justified
String - value can be ('left'|'right'|'both') - default value is 'both' if not specified
HashMap - collection of ConversionOptions to gather further justification options
int - used in file creation to ensure string is padded to the proper length
Returns:
String

strip

public static java.lang.String strip(java.lang.String str,
                                     java.lang.String value,
                                     java.util.HashMap options)
Removes pre-determined chracters from string based on Java Patterns

Specified in flatworm XML file like: <conversion-option name="strip-chars" value="non-numeric"/>

Parameters:
String - field to be stripped
String - value can be ('non-numeric'|'non-alpha'|'non-alphanumeric')
HashMap - collection of ConversionOptions, for future enhancement
Returns:
String

substring

public static java.lang.String substring(java.lang.String str,
                                         java.lang.String value,
                                         java.util.HashMap options)


Specified in flatworm XML file like: <conversion-option name="substring" value="1,10"/>

Parameters:
String - value of field
String - default value
HashMap - collection of ConversionOptions, for future enhancement
Returns:
String

defaultValue

public static java.lang.String defaultValue(java.lang.String str,
                                            java.lang.String value,
                                            java.util.HashMap options)
If str is length zero (after trimming), value is returned. Defualt values should not be specified in the flatworm XML file when you want a string of only spaces.

Parameters:
String - value of field
String - default value
HashMap - collection of ConversionOptions, for future enhancement
Returns:
String

getValue

public static java.lang.String getValue(java.util.HashMap options,
                                        java.lang.String key)
Conversion-Option now stored in class, more than a simple Hashmap lookup

Parameters:
HashMap - options The conversion-option values for the field
String - The key to lookup appropriate ConversionOption
Returns:
The string that contains value of the ConversionOption