org.axiondb.engine.tables
Class BaseTable

java.lang.Object
  extended by org.axiondb.event.BaseTableModificationPublisher
      extended by org.axiondb.engine.tables.AbstractBaseTable
          extended by org.axiondb.engine.tables.BaseTable
All Implemented Interfaces:
RowSource, Table
Direct Known Subclasses:
BaseDiskTable, MemoryTable

public abstract class BaseTable
extends AbstractBaseTable
implements Table

An abstract base implementation of Table.

Version:
$Revision: 1.28 $ $Date: 2005/12/22 09:02:31 $

Field Summary
 
Fields inherited from interface org.axiondb.Table
REGULAR_TABLE_TYPE, SYSTEM_TABLE_TYPE
 
Constructor Summary
BaseTable(java.lang.String name)
           
 
Method Summary
 void addColumn(Column col)
          Add the given Columnto this table.
 void addConstraint(Constraint constraint)
           
 void addIndex(Index index)
          Add an index, associating it with a Column, and adding it as a org.axiondb.TableModificationListenerto the table.
 void addRow(Row row)
          Insert the given Row.
abstract  void applyDeletes(org.apache.commons.collections.primitives.IntCollection rowids)
          Remove the specified rows from this table and any associated indices.
protected  void applyDeletesToIndices(org.apache.commons.collections.primitives.IntCollection rowIds)
           
abstract  void applyInserts(RowCollection rows)
          Insert the given rows into this table and any associated indices.
protected  void applyInsertsToIndices(RowCollection rows)
           
abstract  void applyUpdates(RowCollection rows)
          Update the given rows in this table and any associated indices.
protected  void applyUpdatesToIndices(RowCollection rows)
           
 void checkpoint()
           
protected  void clearCache()
           
 void deleteRow(Row row)
          Delete the given Row.
 void drop()
          Drop this table from the database.
abstract  void freeRowId(int id)
          Un-reserve a row id.
 Column getColumn(int index)
          Return the Columncorresponding to the given zero-based index .
 Column getColumn(java.lang.String name)
          Return the Columnfor the given name .
 int getColumnCount()
          Return the number of Columns I contain.
 java.util.List getColumnIdentifiers()
          Return an readonly Listover the ColumnIdentifiersfor my Columns.
 int getColumnIndex(java.lang.String name)
          Return the zero-based index of the Columnwith the given name .
 Constraint getConstraint(java.lang.String name)
           
 java.util.Iterator getConstraints()
           
 RowIterator getIndexedRows(RowSource source, Selectable node, boolean readOnly)
           
 RowIterator getIndexedRows(Selectable node, boolean readOnly)
           
 Index getIndexForColumn(Column column)
          Return the first Indexthat pertains to the given Column, or null if no such Indexexists.
 java.util.Iterator getIndices()
          Obtain an Iteratorover my indices.
 java.lang.String getName()
          Get the name of this table.
abstract  int getNextRowId()
          Reserve a row id.
abstract  Row getRow(int id)
           
abstract  int getRowCount()
          Return the number of Rows I contain.
protected abstract  RowIterator getRowIterator()
           
 RowIterator getRowIterator(boolean readOnly)
          Obtain an iteratorover my Rows.
 Sequence getSequence()
           
 java.lang.String getType()
          Get the type of this table.
 boolean hasColumn(ColumnIdentifier id)
          Indicate whether the ColumnIdentifierreferences a column in this table
 boolean hasIndex(java.lang.String name)
           
 boolean isColumnIndexed(Column column)
          Check to see if an Indexexists for the given Column
 boolean isPrimaryKeyConstraintExists(java.lang.String columnName)
          check if primary constraint exists on a column
 boolean isUniqueConstraintExists(java.lang.String columnName)
          check if unique constraint exists on a column
 RowDecorator makeRowDecorator()
           
 TransactableTable makeTransactableTable()
          Create a TransactableTablefor this table.
protected  void notifyColumnsOfNewLobDir(java.io.File directory)
           
abstract  void populateIndex(Index index)
          Populate an Index, adding my current rows to it.
protected  void readColumns(java.io.ObjectInputStream in)
           
protected  void readConstraints(java.io.ObjectInputStream in, Database db)
           
protected  void recreateIndices()
           
 void remount(java.io.File dir, boolean datafilesonly)
          Notify this table that its disk-location has moved.
 Constraint removeConstraint(java.lang.String name)
           
 void removeIndex(Index index)
          Remove an index, both from the indices and as a TableModificationListener
 void rename(java.lang.String oldName, java.lang.String newName)
           
protected  void setName(java.lang.String name)
           
 void setSequence(Sequence seq)
           
protected  void setType(java.lang.String type)
           
 void shutdown()
          The database is shutting down, shutdown this table also.
 java.lang.String toString()
           
protected  void truncateIndices()
           
 void updateRow(Row oldrow, Row newrow)
          Update the given Row.
protected  void writeColumns(java.io.ObjectOutputStream out)
           
protected  void writeConstraints(java.io.ObjectOutputStream out)
           
 
Methods inherited from class org.axiondb.engine.tables.AbstractBaseTable
checkConstraints, checkConstraints, checkConstraints, getMatchingRows, hasDeferredConstraint, isDeferAll, migrate
 
Methods inherited from class org.axiondb.event.BaseTableModificationPublisher
addTableModificationListener, getTableModificationListeners, publishEvent, removeTableModificationListener, setDeferAllConstraints
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.axiondb.Table
addTableModificationListener, getMatchingRows, getTableModificationListeners, migrate, removeTableModificationListener, setDeferAllConstraints, truncate
 

Constructor Detail

BaseTable

public BaseTable(java.lang.String name)
Method Detail

applyDeletes

public abstract void applyDeletes(org.apache.commons.collections.primitives.IntCollection rowids)
                           throws AxionException
Description copied from interface: Table
Remove the specified rows from this table and any associated indices. This process is allowed to be destructive, the table my delete values from the given list.

Specified by:
applyDeletes in interface Table
Throws:
AxionException

applyInserts

public abstract void applyInserts(RowCollection rows)
                           throws AxionException
Description copied from interface: Table
Insert the given rows into this table and any associated indices. This process is allowed to be destructive, the table my delete rows from the given list.

Specified by:
applyInserts in interface Table
Parameters:
rows - a collection of Rows
Throws:
AxionException

applyUpdates

public abstract void applyUpdates(RowCollection rows)
                           throws AxionException
Description copied from interface: Table
Update the given rows in this table and any associated indices. This process is allowed to be destructive, the table my delete rows from the given list.

Specified by:
applyUpdates in interface Table
Throws:
AxionException

freeRowId

public abstract void freeRowId(int id)
Description copied from interface: Table
Un-reserve a row id.

Specified by:
freeRowId in interface Table

getNextRowId

public abstract int getNextRowId()
Description copied from interface: Table
Reserve a row id.

Specified by:
getNextRowId in interface Table

getRowCount

public abstract int getRowCount()
Description copied from interface: Table
Return the number of Rows I contain.

Specified by:
getRowCount in interface Table

populateIndex

public abstract void populateIndex(Index index)
                            throws AxionException
Description copied from interface: Table
Populate an Index, adding my current rows to it. Does not addthe index.

Specified by:
populateIndex in interface Table
Throws:
AxionException
See Also:
Table.addIndex(org.axiondb.Index)

getRow

public abstract Row getRow(int id)
                    throws AxionException
Specified by:
getRow in interface RowSource
Throws:
AxionException

getRowIterator

protected abstract RowIterator getRowIterator()
                                       throws AxionException
Throws:
AxionException

getRowIterator

public RowIterator getRowIterator(boolean readOnly)
                           throws AxionException
Description copied from interface: Table
Obtain an iteratorover my Rows.

Specified by:
getRowIterator in interface Table
Parameters:
readOnly - when true, the caller does not expect to be able to modify (i.e., call RowIterator.set(org.axiondb.Row)or RowIterator.remove()on) the returned RowIterator, the returned iterator may be unmodifiable.
Throws:
AxionException

addRow

public void addRow(Row row)
            throws AxionException
Description copied from interface: Table
Insert the given Row.

Specified by:
addRow in interface Table
Throws:
AxionException

checkpoint

public void checkpoint()
                throws AxionException
Specified by:
checkpoint in interface Table
Throws:
AxionException

setSequence

public void setSequence(Sequence seq)
                 throws AxionException
Specified by:
setSequence in interface Table
Throws:
AxionException

getSequence

public final Sequence getSequence()
Specified by:
getSequence in interface Table

deleteRow

public void deleteRow(Row row)
               throws AxionException
Description copied from interface: Table
Delete the given Row.

Specified by:
deleteRow in interface Table
Throws:
AxionException

updateRow

public void updateRow(Row oldrow,
                      Row newrow)
               throws AxionException
Description copied from interface: Table
Update the given Row.

Specified by:
updateRow in interface Table
Throws:
AxionException

truncateIndices

protected void truncateIndices()
                        throws AxionException
Throws:
AxionException

recreateIndices

protected void recreateIndices()
                        throws AxionException
Throws:
AxionException

toString

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

getName

public final java.lang.String getName()
Description copied from interface: Table
Get the name of this table.

Specified by:
getName in interface Table

getType

public final java.lang.String getType()
Description copied from interface: Table
Get the type of this table.

Specified by:
getType in interface Table

setType

protected void setType(java.lang.String type)

setName

protected void setName(java.lang.String name)

addConstraint

public void addConstraint(Constraint constraint)
                   throws AxionException
Specified by:
addConstraint in interface Table
Throws:
AxionException

getConstraint

public final Constraint getConstraint(java.lang.String name)
Specified by:
getConstraint in interface Table

removeConstraint

public Constraint removeConstraint(java.lang.String name)
Specified by:
removeConstraint in interface Table

isUniqueConstraintExists

public boolean isUniqueConstraintExists(java.lang.String columnName)
check if unique constraint exists on a column

Specified by:
isUniqueConstraintExists in interface Table
Parameters:
columnName - name of the columm
Returns:
true if uniqueConstraint exists on the column

isPrimaryKeyConstraintExists

public boolean isPrimaryKeyConstraintExists(java.lang.String columnName)
check if primary constraint exists on a column

Specified by:
isPrimaryKeyConstraintExists in interface Table
Parameters:
ColumnName - name of the column
Returns:
if PrimaryKeyConstraint exists on the column

getConstraints

public java.util.Iterator getConstraints()
Specified by:
getConstraints in interface Table

addIndex

public void addIndex(Index index)
              throws AxionException
Description copied from interface: Table
Add an index, associating it with a Column, and adding it as a org.axiondb.TableModificationListenerto the table.

Specified by:
addIndex in interface Table
Throws:
AxionException
See Also:
Table.addIndex(org.axiondb.Index), Table.addTableModificationListener(org.axiondb.event.TableModificationListener), Table.getIndexForColumn(org.axiondb.Column), Table.isColumnIndexed(org.axiondb.Column), Table.populateIndex(org.axiondb.Index)

removeIndex

public void removeIndex(Index index)
                 throws AxionException
Description copied from interface: Table
Remove an index, both from the indices and as a TableModificationListener

Specified by:
removeIndex in interface Table
Throws:
AxionException

getIndexForColumn

public Index getIndexForColumn(Column column)
Description copied from interface: Table
Return the first Indexthat pertains to the given Column, or null if no such Indexexists.

Specified by:
getIndexForColumn in interface Table
Returns:
the pertinent Column, or null if no such Indexexists

isColumnIndexed

public boolean isColumnIndexed(Column column)
Description copied from interface: Table
Check to see if an Indexexists for the given Column

Specified by:
isColumnIndexed in interface Table
Parameters:
column - Columnto check
Returns:
true iff there is an existing Indexfor the given Column

getIndexedRows

public RowIterator getIndexedRows(Selectable node,
                                  boolean readOnly)
                           throws AxionException
Specified by:
getIndexedRows in interface Table
readOnly - when true, the caller does not expect to be able to modify (i.e., call RowIterator.set(org.axiondb.Row)or RowIterator.remove()on) the returned RowIterator, the returned iterator may be unmodifiable.
Throws:
AxionException

getIndexedRows

public RowIterator getIndexedRows(RowSource source,
                                  Selectable node,
                                  boolean readOnly)
                           throws AxionException
Specified by:
getIndexedRows in interface Table
Throws:
AxionException

addColumn

public void addColumn(Column col)
               throws AxionException
Add the given Columnto this table. This implementation throws an AxionExceptionif rows have already been added to the table.

Specified by:
addColumn in interface Table
Throws:
AxionException

clearCache

protected final void clearCache()

hasColumn

public boolean hasColumn(ColumnIdentifier id)
Description copied from interface: Table
Indicate whether the ColumnIdentifierreferences a column in this table

Specified by:
hasColumn in interface Table

getColumn

public final Column getColumn(int index)
Description copied from interface: Table
Return the Columncorresponding to the given zero-based index .

Specified by:
getColumn in interface Table

getColumn

public Column getColumn(java.lang.String name)
Description copied from interface: Table
Return the Columnfor the given name .

Specified by:
getColumn in interface Table

getColumnIndex

public int getColumnIndex(java.lang.String name)
                   throws AxionException
Description copied from interface: Table
Return the zero-based index of the Columnwith the given name .

Specified by:
getColumnIndex in interface RowSource
Specified by:
getColumnIndex in interface Table
Throws:
AxionException

getColumnIdentifiers

public java.util.List getColumnIdentifiers()
Description copied from interface: Table
Return an readonly Listover the ColumnIdentifiersfor my Columns.

Specified by:
getColumnIdentifiers in interface Table

getColumnCount

public final int getColumnCount()
Description copied from interface: Table
Return the number of Columns I contain.

Specified by:
getColumnCount in interface RowSource
Specified by:
getColumnCount in interface Table

drop

public void drop()
          throws AxionException
Description copied from interface: Table
Drop this table from the database.

Specified by:
drop in interface Table
Throws:
AxionException

remount

public void remount(java.io.File dir,
                    boolean datafilesonly)
             throws AxionException
Description copied from interface: Table
Notify this table that its disk-location has moved.

Specified by:
remount in interface Table
Throws:
AxionException

rename

public void rename(java.lang.String oldName,
                   java.lang.String newName)
            throws AxionException
Specified by:
rename in interface Table
Throws:
AxionException

shutdown

public void shutdown()
              throws AxionException
Description copied from interface: Table
The database is shutting down, shutdown this table also.

Specified by:
shutdown in interface Table
Throws:
AxionException

makeRowDecorator

public RowDecorator makeRowDecorator()
Specified by:
makeRowDecorator in interface RowSource
Specified by:
makeRowDecorator in interface Table

makeTransactableTable

public TransactableTable makeTransactableTable()
Description copied from interface: Table
Create a TransactableTablefor this table.

Specified by:
makeTransactableTable in interface Table

getIndices

public java.util.Iterator getIndices()
Description copied from interface: Table
Obtain an Iteratorover my indices.

Specified by:
getIndices in interface Table

hasIndex

public boolean hasIndex(java.lang.String name)
Specified by:
hasIndex in interface Table

notifyColumnsOfNewLobDir

protected void notifyColumnsOfNewLobDir(java.io.File directory)
                                 throws AxionException
Throws:
AxionException

writeColumns

protected void writeColumns(java.io.ObjectOutputStream out)
                     throws java.io.IOException
Throws:
java.io.IOException

readColumns

protected void readColumns(java.io.ObjectInputStream in)
                    throws java.io.IOException,
                           java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeConstraints

protected void writeConstraints(java.io.ObjectOutputStream out)
                         throws java.io.IOException
Throws:
java.io.IOException

readConstraints

protected void readConstraints(java.io.ObjectInputStream in,
                               Database db)
                        throws java.io.IOException,
                               java.lang.ClassNotFoundException,
                               AxionException
Throws:
java.io.IOException
java.lang.ClassNotFoundException
AxionException

applyDeletesToIndices

protected void applyDeletesToIndices(org.apache.commons.collections.primitives.IntCollection rowIds)
                              throws AxionException
Throws:
AxionException

applyUpdatesToIndices

protected void applyUpdatesToIndices(RowCollection rows)
                              throws AxionException
Throws:
AxionException

applyInsertsToIndices

protected void applyInsertsToIndices(RowCollection rows)
                              throws AxionException
Throws:
AxionException