org.jplate.tabular.parser.impl.defaults
Class DefaultTableBuilder

java.lang.Object
  extended by org.jplate.tabular.parser.impl.defaults.DefaultTableBuilder
All Implemented Interfaces:
BuilderIfc<TableIfc>, JPlateBuilderIfc<TableIfc>, CdvBuilderIfc<TableIfc>, CdvTableBuilderIfc, CsvBuilderIfc<TableIfc>, CsvTableBuilderIfc, TabularBuilderIfc<TableIfc>, TdvBuilderIfc<TableIfc>, TdvTableBuilderIfc

public class DefaultTableBuilder
extends java.lang.Object
implements CdvTableBuilderIfc, CsvTableBuilderIfc, TdvTableBuilderIfc

Default implementation of a tabular builder. Please note this class implements all of the builder interfaces defined in the Tabular project. This is actually reasonable due to all builders being of type TabularBuilderIfc. Therefore, as a simple solution, the aforementioned interfaces are implemented here.

Modifications:
    $Date: 2008-12-02 12:32:45 -0500 (Tue, 02 Dec 2008) $
    $Revision: 479 $
    $Author: sfloess $
    $HeadURL: https://jplate.svn.sourceforge.net/svnroot/jplate/trunk/src/dev/java/org/jplate/tabular/parser/impl/defaults/DefaultTableBuilder.java $
    


Field Summary
private  RecordIfc _currentRecord
          Holds the current record.
private  org.apache.commons.logging.Log _log
          Used for logging.
private  TableFactoryIfc _tableFactory
          Factory to create tables.
private  TableIfc _tableResult
          Holds the build result.
 
Constructor Summary
DefaultTableBuilder()
          Default constructor.
DefaultTableBuilder(TableFactoryIfc tableFactory)
          This constructor sets the table factory used when creating results.
 
Method Summary
 void buildEnd(int line, int column)
          This method is called when parsing has completed.
 void buildField(java.lang.String field, int line, int column)
          This method is called when a field is encountered.
 void buildOmittedField(int line, int column)
          This method is called when a field is omitted.
 void buildQuotedField(java.lang.String field, int line, int column)
          This method is called when a quoted field is found.
 void buildRecord(int line)
          This method is called when a record is to be built.
 void buildStart()
          This method is called when parsing is to begin.
protected  RecordIfc getCurrentRecord()
          Return the current record.
 TableIfc getResult()
          Return the built object.
 void reset()
          Reset any result currently held.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_log

private final transient org.apache.commons.logging.Log _log
Used for logging.


_tableFactory

private final TableFactoryIfc _tableFactory
Factory to create tables.


_tableResult

private TableIfc _tableResult
Holds the build result.


_currentRecord

private RecordIfc _currentRecord
Holds the current record.

Constructor Detail

DefaultTableBuilder

public DefaultTableBuilder(TableFactoryIfc tableFactory)
This constructor sets the table factory used when creating results.

Parameters:
tableFactory - The factory who can create tables.

DefaultTableBuilder

public DefaultTableBuilder()
Default constructor.

Method Detail

getCurrentRecord

protected RecordIfc getCurrentRecord()
Return the current record.

Returns:
the current record.

getResult

public TableIfc getResult()
Return the built object.

Specified by:
getResult in interface BuilderIfc<TableIfc>
Returns:
the built object.

reset

public void reset()
Reset any result currently held.

Specified by:
reset in interface BuilderIfc<TableIfc>

buildStart

public void buildStart()
                throws JPlateBuildingException
This method is called when parsing is to begin.

Specified by:
buildStart in interface JPlateBuilderIfc<TableIfc>
Throws:
JPlateBuildingException

buildEnd

public void buildEnd(int line,
                     int column)
              throws JPlateBuildingException
This method is called when parsing has completed.

Specified by:
buildEnd in interface JPlateBuilderIfc<TableIfc>
Parameters:
line - The line where parsing ended.
column - The column number where parsing ended.
Throws:
JPlateBuildingException

buildRecord

public void buildRecord(int line)
                 throws JPlateBuildingException
This method is called when a record is to be built. No column value is presented for any line, the starting column will always be 1.

Specified by:
buildRecord in interface TabularBuilderIfc<TableIfc>
Parameters:
line - The line number where the record was found.
Throws:
JPlateBuildingException - If there is a problem building the record.

buildField

public void buildField(java.lang.String field,
                       int line,
                       int column)
                throws JPlateBuildingException
This method is called when a field is encountered.

Specified by:
buildField in interface TabularBuilderIfc<TableIfc>
Parameters:
field - The data in the field.
line - The line where field starts.
column - The column number where field starts.
Throws:
JPlateBuildingException - If there is a problem building the field.

buildOmittedField

public void buildOmittedField(int line,
                              int column)
                       throws JPlateBuildingException
This method is called when a field is omitted.

Specified by:
buildOmittedField in interface TabularBuilderIfc<TableIfc>
Parameters:
line - represents the line where the omitted field starts.
column - represents the column where the omitted field starts.
Throws:
JPlateBuildingException - if there is a problem building the omitted field.

buildQuotedField

public void buildQuotedField(java.lang.String field,
                             int line,
                             int column)
                      throws JPlateBuildingException
This method is called when a quoted field is found.

Specified by:
buildQuotedField in interface CsvBuilderIfc<TableIfc>
Parameters:
field - A quoted field.
line - The line where the field starts.
column - The column number where the field starts.
Throws:
JPlateBuildingException - If there is a problem building field.