com.blackbear.flatworm
Class FileCreator

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

public class FileCreator
extends java.lang.Object

Used to create a flatfile. This class wraps the functionality that used to be in the main() of the examples. This way, the client knows less about the internal workings of FlatWorm.


Constructor Summary
FileCreator(java.io.InputStream config, java.io.OutputStream stream)
           
FileCreator(java.io.InputStream config, java.lang.String file)
           
FileCreator(java.lang.String config, java.io.OutputStream stream)
           
FileCreator(java.lang.String config, java.lang.String file)
          Constructor for FileCreator
 
Method Summary
 void close()
          Close the output file, since we are using buffered IO, this is very important.
 void open()
          Open the newfile for writing
 void setBean(java.lang.String name, java.lang.Object bean)
          This is a convienence method that lets the writer know about your bean without having to pass a HashMap to write()
 void setRecordSeperator(java.lang.String recordSeperator)
          Flatworm does not assume you want a newline between records, call this method to set your record delimiter.
 void write(java.lang.String recordName)
          Write information to the output file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileCreator

public FileCreator(java.lang.String config,
                   java.lang.String file)
            throws FlatwormCreatorException
Constructor for FileCreator

Parameters:
String - full path to the FlatWorm XML configuration file
String - full path to output file
Throws:
FlatwormCreatorException - - wraps FlatwormConfigurationValueException & FlatwormUnsetFieldValueException (to reduce number of exceptions clients have to be aware of)

FileCreator

public FileCreator(java.lang.String config,
                   java.io.OutputStream stream)
            throws FlatwormCreatorException
Throws:
FlatwormCreatorException

FileCreator

public FileCreator(java.io.InputStream config,
                   java.lang.String file)
            throws FlatwormCreatorException
Throws:
FlatwormCreatorException

FileCreator

public FileCreator(java.io.InputStream config,
                   java.io.OutputStream stream)
            throws FlatwormCreatorException
Throws:
FlatwormCreatorException
Method Detail

open

public void open()
          throws FlatwormCreatorException
Open the newfile for writing

Throws:
java.io.IOException - - if there is some sort of filesystem related problem
FlatwormCreatorException

setBean

public void setBean(java.lang.String name,
                    java.lang.Object bean)
This is a convienence method that lets the writer know about your bean without having to pass a HashMap to write()

Parameters:
String - name of bean as defined in your flatworm XML file
Object - the bean

setRecordSeperator

public void setRecordSeperator(java.lang.String recordSeperator)
Flatworm does not assume you want a newline between records, call this method to set your record delimiter.

Parameters:
String - what you want to seperate your records. Could be "\n"

close

public void close()
           throws java.io.IOException
Close the output file, since we are using buffered IO, this is very important.

Parameters:
String - what you want to seperate your records. Could be "\n"
Throws:
java.io.IOException - - If the file system chooses not to close your file for some unknown reason

write

public void write(java.lang.String recordName)
           throws java.io.IOException,
                  FlatwormCreatorException
Write information to the output file. Make sure you have called the setBean() method with the needed beans before calling this method.

Parameters:
String - recordname as defined in your flatworm XML file
Throws:
java.io.IOException - - If the file system has a problem with you writing information to the recently opened file.
FlatwormCreationException - - wraps varius Exceptions so client doesn't have to handle too many
FlatwormCreatorException