org.databene.benerator.consumer
Class TextFileExporter

java.lang.Object
  extended by org.databene.benerator.consumer.AbstractConsumer
      extended by org.databene.benerator.consumer.FormattingConsumer
          extended by org.databene.benerator.consumer.TextFileExporter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, Consumer, FileExporter
Direct Known Subclasses:
CSVEntityExporter, FixedWidthEntityExporter, ScriptedEntityExporter, SQLEntityExporter

public class TextFileExporter
extends FormattingConsumer
implements FileExporter

Parent class for Exporters that export data to a text file.

Created: 11.07.2008 09:50:46

Since:
0.5.4
Author:
Volker Bergmann

Field Summary
protected  boolean append
           
protected  java.lang.String encoding
           
protected  java.lang.String lineSeparator
           
protected  java.io.PrintWriter printer
           
protected  java.lang.String uri
           
protected  boolean wasAppended
           
 
Fields inherited from class org.databene.benerator.consumer.FormattingConsumer
plainConverter
 
Constructor Summary
TextFileExporter()
           
TextFileExporter(java.lang.String uri)
           
TextFileExporter(java.lang.String uri, java.lang.String encoding, java.lang.String lineSeparator)
           
 
Method Summary
 void close()
          When called, the implementor has to close and free all resources.
 void flush()
          Is called by Benerator for advising the Consumer to finish processing of the objects consumed so far.
 java.lang.String getEncoding()
           
 java.lang.String getLineSeparator()
           
 java.lang.String getUri()
           
protected  void initPrinter(java.lang.Object data)
           
 boolean isAppend()
           
protected  void postInitPrinter(java.lang.Object data)
          This method is called after printer initialization and before writing the first data entry.
protected  void preClosePrinter()
          This method is called after writing the last data entry and before closing the underlying printer.
protected  void println()
           
 void setAppend(boolean append)
           
 void setEncoding(java.lang.String encoding)
           
 void setLineSeparator(java.lang.String lineSeparator)
           
 void setUri(java.lang.String uri)
           
protected  void startConsumingImpl(java.lang.Object data)
          Writes the data to the output file.
 void startProductConsumption(java.lang.Object data)
           
 java.lang.String toString()
           
 
Methods inherited from class org.databene.benerator.consumer.FormattingConsumer
format, getDateCapitalization, getDatePattern, getDateTimePattern, getDecimalPattern, getDecimalSeparator, getIntegralPattern, getNullString, getTimePattern, getTimestampCapitalization, getTimestampPattern, setDateCapitalization, setDatePattern, setDateTimePattern, setDecimalPattern, setDecimalSeparator, setIntegralPattern, setNullString, setTimePattern, setTimestampCapitalization, setTimestampPattern
 
Methods inherited from class org.databene.benerator.consumer.AbstractConsumer
finishConsuming, finishProductConsumption, startConsuming
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.databene.benerator.Consumer
finishConsuming, startConsuming
 

Field Detail

uri

protected java.lang.String uri

encoding

protected java.lang.String encoding

lineSeparator

protected java.lang.String lineSeparator

append

protected boolean append

wasAppended

protected boolean wasAppended

printer

protected java.io.PrintWriter printer
Constructor Detail

TextFileExporter

public TextFileExporter()

TextFileExporter

public TextFileExporter(java.lang.String uri)

TextFileExporter

public TextFileExporter(java.lang.String uri,
                        java.lang.String encoding,
                        java.lang.String lineSeparator)
Method Detail

postInitPrinter

protected void postInitPrinter(java.lang.Object data)
This method is called after printer initialization and before writing the first data entry. Overwrite this method in child classes e.g. for writing a file header.

Parameters:
data - the first data item to write to the file

startConsumingImpl

protected void startConsumingImpl(java.lang.Object data)
Writes the data to the output file. It uses the parent class settings for rendering the object. Overwrite this in a child class for custom output formats.

Parameters:
data - the data object to output

preClosePrinter

protected void preClosePrinter()
This method is called after writing the last data entry and before closing the underlying printer. Overwrite this method in child classes e.g. for writing a file footer.


getUri

public java.lang.String getUri()
Specified by:
getUri in interface FileExporter

setUri

public void setUri(java.lang.String uri)

getEncoding

public java.lang.String getEncoding()

setEncoding

public void setEncoding(java.lang.String encoding)

getLineSeparator

public java.lang.String getLineSeparator()

setLineSeparator

public void setLineSeparator(java.lang.String lineSeparator)

isAppend

public boolean isAppend()

setAppend

public void setAppend(boolean append)

startProductConsumption

public final void startProductConsumption(java.lang.Object data)
Specified by:
startProductConsumption in class AbstractConsumer

flush

public void flush()
Description copied from interface: Consumer
Is called by Benerator for advising the Consumer to finish processing of the objects consumed so far. In Benerator descriptor files, the flushing behavior is controlled by the pageSize attribute.

Specified by:
flush in interface java.io.Flushable
Specified by:
flush in interface Consumer
Overrides:
flush in class AbstractConsumer

close

public void close()
Description copied from interface: Consumer
When called, the implementor has to close and free all resources. It will not receive any more calls.

Specified by:
close in interface java.io.Closeable
Specified by:
close in interface Consumer
Overrides:
close in class AbstractConsumer

initPrinter

protected void initPrinter(java.lang.Object data)
                    throws java.io.IOException
Throws:
java.io.IOException

println

protected void println()

toString

public java.lang.String toString()
Overrides:
toString in class AbstractConsumer


Copyright © 2013. All Rights Reserved.