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

java.lang.Object
  extended by org.jplate.foundation.parser.impl.AbstractJPlateListBuilder<java.util.List<java.lang.String>>
      extended by org.jplate.tabular.parser.impl.defaults.DefaultTabularListBuilder
All Implemented Interfaces:
BuilderIfc<java.util.List<java.util.List<java.lang.String>>>, JPlateBuilderIfc<java.util.List<java.util.List<java.lang.String>>>, JPlateListBuilderIfc<java.util.List<java.lang.String>>, CdvBuilderIfc<java.util.List<java.util.List<java.lang.String>>>, CdvListBuilderIfc, CsvBuilderIfc<java.util.List<java.util.List<java.lang.String>>>, CsvListBuilderIfc, TabularBuilderIfc<java.util.List<java.util.List<java.lang.String>>>, TdvBuilderIfc<java.util.List<java.util.List<java.lang.String>>>, TdvListBuilderIfc

public class DefaultTabularListBuilder
extends AbstractJPlateListBuilder<java.util.List<java.lang.String>>
implements CdvListBuilderIfc, CsvListBuilderIfc, TdvListBuilderIfc

Implementation of a TabularBuilderIfc that uses List to hold rows and fields. 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/DefaultTabularListBuilder.java $
    


Field Summary
private  java.util.List<java.lang.String> _currentRecord
          Holds the current record.
private  ListFactoryIfc<java.lang.String> _listRecordFactory
          Factory to create.
private  org.apache.commons.logging.Log _log
          Used for logging.
static java.lang.String OMITTED_FIELD
          Denotes an omitted field.
 
Constructor Summary
DefaultTabularListBuilder()
          Default constructor.
DefaultTabularListBuilder(ListFactoryIfc<java.util.List<java.lang.String>> listResultFactory, ListFactoryIfc<java.lang.String> listRecordFactory)
          This constructor sets the list 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.
protected  java.util.List<java.lang.String> getCurrentRecord()
          Return the current record.
 
Methods inherited from class org.jplate.foundation.parser.impl.AbstractJPlateListBuilder
buildStart, getActualResultList, getResult, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jplate.foundation.parser.JPlateBuilderIfc
buildStart
 
Methods inherited from interface org.jplate.foundation.gof.builder.BuilderIfc
getResult, reset
 

Field Detail

OMITTED_FIELD

public static final java.lang.String OMITTED_FIELD
Denotes an omitted field.

See Also:
Constant Field Values

_log

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


_listRecordFactory

private final ListFactoryIfc<java.lang.String> _listRecordFactory
Factory to create.


_currentRecord

private java.util.List<java.lang.String> _currentRecord
Holds the current record.

Constructor Detail

DefaultTabularListBuilder

public DefaultTabularListBuilder(ListFactoryIfc<java.util.List<java.lang.String>> listResultFactory,
                                 ListFactoryIfc<java.lang.String> listRecordFactory)
This constructor sets the list factory used when creating results.

Parameters:
listResultFactory - The factory who creates lists to hold records.
listRecordFactory - The factory who creates lists for fields.

DefaultTabularListBuilder

public DefaultTabularListBuilder()
Default constructor. Uses UnsynchronizedLinkedListFactory to create the list of records and fields.

Method Detail

getCurrentRecord

protected java.util.List<java.lang.String> getCurrentRecord()
Return the current record.

Returns:
the current record.

buildEnd

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

Specified by:
buildEnd in interface JPlateBuilderIfc<java.util.List<java.util.List<java.lang.String>>>
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<java.util.List<java.util.List<java.lang.String>>>
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<java.util.List<java.util.List<java.lang.String>>>
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<java.util.List<java.util.List<java.lang.String>>>
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<java.util.List<java.util.List<java.lang.String>>>
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.