org.jplate.tabular.impl.defaults
Class DefaultTable

java.lang.Object
  extended by org.jplate.tabular.impl.defaults.DefaultTable
All Implemented Interfaces:
TableIfc

public class DefaultTable
extends java.lang.Object
implements TableIfc

Default implementation of a TableIfc.

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/impl/defaults/DefaultTable.java $
    


Field Summary
private  org.apache.commons.logging.Log _log
          Used for logging.
private  RecordFactoryIfc _recordFactory
          Used to create records.
private  java.util.List<RecordIfc> _recordList
          Holds all records that belong to a table.
private  java.lang.String _tableName
          The name of the table.
static java.lang.String DEFAULT_TABLE_NAME
          Default table name.
 
Constructor Summary
DefaultTable()
          Default constructor.
DefaultTable(ListFactoryIfc<RecordIfc> listFactory)
          This constructor uses listFactory to create a List to hold tables that are logically part of a repo.
DefaultTable(RecordFactoryIfc recordFactory, ListFactoryIfc<RecordIfc> listFactory, java.lang.String tableName)
          This constructor sets the table name and uses listFactory to create a List to hold records that are part of a table.
DefaultTable(java.lang.String repoName)
          This constructor sets the repo name and uses a UnsynchronizedLinkedListFactory as the list factory.
 
Method Summary
 void addRecord(RecordIfc record)
          Add a record.
 void close()
          This method will close a table.
 RecordIfc createRecord()
          
 java.util.List<RecordIfc> getRecords()
          Return the collection of records.
 java.lang.String getTableName()
          Return the name of the table.
 void open()
          This method will open an existing table.
 boolean removeRecord(RecordIfc record)
          Remove record.
 void removeRecords()
          This method will force the removal of all records.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TABLE_NAME

public static final java.lang.String DEFAULT_TABLE_NAME
Default table name. Used when one is not supplied on construction.

See Also:
Constant Field Values

_log

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


_recordFactory

private RecordFactoryIfc _recordFactory
Used to create records.


_recordList

private final java.util.List<RecordIfc> _recordList
Holds all records that belong to a table.


_tableName

private final java.lang.String _tableName
The name of the table.

Constructor Detail

DefaultTable

public DefaultTable(RecordFactoryIfc recordFactory,
                    ListFactoryIfc<RecordIfc> listFactory,
                    java.lang.String tableName)
This constructor sets the table name and uses listFactory to create a List to hold records that are part of a table.

Parameters:
listFactory - Used to create a list to hold associated records.
tableName - The name of this table.

DefaultTable

public DefaultTable(ListFactoryIfc<RecordIfc> listFactory)
This constructor uses listFactory to create a List to hold tables that are logically part of a repo. The repo name is set to DEFAULT_TABLE_NAME

Parameters:
listFactory - Used to create a list to hold associated tables.

DefaultTable

public DefaultTable(java.lang.String repoName)
This constructor sets the repo name and uses a UnsynchronizedLinkedListFactory as the list factory.

Parameters:
repoName - The name of this repo.

DefaultTable

public DefaultTable()
Default constructor. Set the repo name to DEFAULT_TABLE_NAME and uses a UnsynchronizedLinkedListFactory as the list factory.

Method Detail

createRecord

public RecordIfc createRecord()

Specified by:
createRecord in interface TableIfc

getTableName

public java.lang.String getTableName()
Return the name of the table.

Specified by:
getTableName in interface TableIfc
Returns:
The name of the table.

open

public void open()
          throws OpenException
This method will open an existing table.

Specified by:
open in interface TableIfc
Throws:
OpenException - If a problem arose opening the table.

close

public void close()
           throws CloseException
This method will close a table.

Specified by:
close in interface TableIfc
Throws:
CloseException - If a problem arose closing the table.

addRecord

public void addRecord(RecordIfc record)
               throws AddException
Add a record.

Specified by:
addRecord in interface TableIfc
Parameters:
record - The record to add.
Throws:
AddException - if any issues arise adding record.

removeRecords

public void removeRecords()
                   throws RemoveException
This method will force the removal of all records.

Specified by:
removeRecords in interface TableIfc
Throws:
RemoveException - if a problem arose removing all records.

removeRecord

public boolean removeRecord(RecordIfc record)
                     throws RemoveException
Remove record.

Specified by:
removeRecord in interface TableIfc
Parameters:
record - The record to remove.
Returns:
true if successful or false if not.
Throws:
RemoveException - if any issues arise removing record.

getRecords

public java.util.List<RecordIfc> getRecords()
Return the collection of records.

Specified by:
getRecords in interface TableIfc
Returns:
the collection of records.