com.blackbear.flatworm
Class ConversionHelper

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

public class ConversionHelper
extends java.lang.Object

The ConversionHelper was created to seperate formatting responsibility into a seperate class. This class also makes writing your own converter more of a reality by seperating type conversion from string formatting. String formatting has moved to a seperate class called Util.


Constructor Summary
ConversionHelper()
           
 
Method Summary
 void addConverter(com.blackbear.flatworm.Converter converter)
          Facilitates the storage of multiple converters used by the convert method during processing
 java.lang.String convert(java.lang.String type, java.lang.Object obj, java.util.HashMap options, java.lang.String beanRef)
           
 java.lang.Object convert(java.lang.String type, java.lang.String fieldChars, java.util.HashMap options, java.lang.String beanRef)
           
 java.lang.String transformString(java.lang.String fieldChars, java.util.HashMap options, int length)
          Handles the processing of the Conversion-Options from the flatworm XML file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConversionHelper

public ConversionHelper()
Method Detail

convert

public java.lang.Object convert(java.lang.String type,
                                java.lang.String fieldChars,
                                java.util.HashMap options,
                                java.lang.String beanRef)
                         throws FlatwormConversionException
Parameters:
String - type from the xml configuration file
String - as read from the input file
Hashmap - contains ConversionOoptions (if any) for this field
String - format - "class.property", used for more descriptive exception messages, should something go wrong
Returns:
Object Java type corresponding to the field type, post conversion
Throws:
FlatwormConversionException - - if problems are encountered during the conversion process (wraps other exceptions)

convert

public java.lang.String convert(java.lang.String type,
                                java.lang.Object obj,
                                java.util.HashMap options,
                                java.lang.String beanRef)
                         throws FlatwormConversionException
Throws:
FlatwormConversionException

transformString

public java.lang.String transformString(java.lang.String fieldChars,
                                        java.util.HashMap options,
                                        int length)
Handles the processing of the Conversion-Options from the flatworm XML file

Parameters:
String - string you wish to transform
HashMap - collection of ConversionOption objects
int - used in justification to ensure proper formatting
Returns:
String - string after transformation

addConverter

public void addConverter(com.blackbear.flatworm.Converter converter)
Facilitates the storage of multiple converters used by the convert method during processing

Parameters:
Converter - converter to store