Package com.mckoi.database

## Class GTPrivMapDataSource

- java.lang.Object
- - com.mckoi.database.GTPrivMapDataSource

All Implemented Interfaces:
  `MutableTableDataSource`, `TableDataSource`

    public class GTPrivMapDataSource
    extends java.lang.Object

A GTDataSource that maps a Privs 11-bit set to strings that represent the priv in human understandable string. Each 11-bit priv set contains 12 entries for each bit that was set.

This table provides a convenient way to join the system grant table and 'expand' the privs that are allowed though it.

Author:
  Tobias Downer

### Constructor Summary

Constructors
`GTPrivMapDataSource​(DatabaseConnection connection)` Constructor.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `addRootLock()` Puts this source under a 'root lock'.
`int` `addRow​(RowData row_data)` Adds a row to the source.
`protected static DataTableColumnDef` `booleanColumn​(java.lang.String name)`
`protected TObject` `columnValue​(int column, java.lang.Object ob)` Returns a TObject that represents a value for the given column in this table.
`void` `constraintIntegrityCheck()` Performs all constraint integrity checks and actions to any modifications based on any changes that happened to the table since that last call to this method.
`protected static DataTableColumnDef` `dateColumn​(java.lang.String name)`
`void` `dispose()` Disposes this table data source.
`void` `flushIndexChanges()` Flushes all changes made on this MutableTableDataSource to the backing index scheme (IndexSet).
`TObject` `getCellContents​(int column, int row)` Returns an object that represents the information in the given cell in the table.
`SelectableScheme` `getColumnScheme​(int column)` Returns the SelectableScheme that we use as an index for rows in the given column of this source.
`DataTableDef` `getDataTableDef()` Returns a DataTableDef object that defines the layout of the table that this data is in.
`com.mckoi.database.MasterTableJournal` `getJournal()` Returns a journal that details the changes to this data source since it was created.
`int` `getRowCount()` Returns the number of rows in this data source.
`TransactionSystem` `getSystem()` Returns the TransactionSystem object that describes global properties about the data source that generated this object.
`protected static DataTableColumnDef` `numericColumn​(java.lang.String name)`
`void` `removeRootLock()` Removes a root lock from this source.
`void` `removeRow​(int row_index)` Completely removes a row from the source.
`RowEnumeration` `rowEnumeration()` Returns an iterator that is used to sequentually step through all valid rows in this source.
`protected static DataTableColumnDef` `stringColumn​(java.lang.String name)` Convenience methods for constructing a DataTableDef for the dynamically generated table.
`int` `updateRow​(int row_index, RowData row_data)` Updates a row in the source.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### GTPrivMapDataSource

    public GTPrivMapDataSource​(DatabaseConnection connection)

Constructor.

### Method Detail

#### getDataTableDef

    public DataTableDef getDataTableDef()

Description copied from interface: `TableDataSource`
Returns a DataTableDef object that defines the layout of the table that this data is in.

This may return 'null' if there is no table definition.

Specified by:
  `getDataTableDef` in interface `TableDataSource`

#### getRowCount

    public int getRowCount()

Description copied from interface: `TableDataSource`
Returns the number of rows in this data source.

NOTE: Returns 'n' - getCellContents(column, row) is not necessarily valid for row = [0..n]. Use 'rowEnumerator' to generate an iterator for valid row values over this data source.

Specified by:
  `getRowCount` in interface `TableDataSource`

#### getCellContents

    public TObject getCellContents​(int column,
                                   int row)

Description copied from interface: `TableDataSource`
Returns an object that represents the information in the given cell in the table. This may be an expensive operation, so calls to it should be kept to a minimum. Note that the offset between two rows is not necessarily 1. Use 'rowEnumeration' to create a row iterator.

Specified by:
  `getCellContents` in interface `TableDataSource`

#### getColumnScheme

    public SelectableScheme getColumnScheme​(int column)

Description copied from interface: `TableDataSource`
Returns the SelectableScheme that we use as an index for rows in the given column of this source. The SelectableScheme is used to determine the relationship between cells in a column.

ISSUE: The scheme returned here should not have the 'insert' or 'remove' methods called (ie. it should be considered immutable). Perhaps we should make a MutableSelectableScheme interface to guarentee this constraint.

Specified by:
  `getColumnScheme` in interface `TableDataSource`

#### columnValue

    protected TObject columnValue​(int column,
                                  java.lang.Object ob)

Returns a TObject that represents a value for the given column in this table. The Object must be of a compatible class to store in the type of the column defined.

#### getSystem

    public TransactionSystem getSystem()

Description copied from interface: `TableDataSource`
Returns the TransactionSystem object that describes global properties about the data source that generated this object.

Specified by:
  `getSystem` in interface `TableDataSource`

#### rowEnumeration

    public RowEnumeration rowEnumeration()

Description copied from interface: `TableDataSource`
Returns an iterator that is used to sequentually step through all valid rows in this source. The iterator is guarenteed to return exactly 'getRowCount' elements. The row elements returned by this iterator are used in 'getCellContents' in the 'row' parameter.

Note that this object is only defined if entries in the table are not added/remove during the lifetime of this iterator. If entries are added or removed from the table while this iterator is open, then calls to 'nextRowIndex' will be undefined.

Specified by:
  `rowEnumeration` in interface `TableDataSource`

#### addRow

    public int addRow​(RowData row_data)

Description copied from interface: `MutableTableDataSource`
Adds a row to the source. This will add a permanent record into the the underlying data structure. It will also update the indexing schemes as appropriate, and also add the row into the set returned by the 'rowEnumeration' iterator.

It returns a row index that is used to reference this data in future queries. Throws an exception if the row additional was not possible because of IO reasons.

Specified by:
  `addRow` in interface `MutableTableDataSource`

#### removeRow

    public void removeRow​(int row_index)

Description copied from interface: `MutableTableDataSource`
Completely removes a row from the source. This will permanently remove the record from the underlying data structure. It also updates the indexing schemes and removes the row index from the set returned by the 'rowEnumeration' iterator.

Throws an exception if the row index does not reference a valid row within the context of this data source.

Specified by:
  `removeRow` in interface `MutableTableDataSource`

#### updateRow

    public int updateRow​(int row_index,
                         RowData row_data)

Description copied from interface: `MutableTableDataSource`
Updates a row in the source. This will make a permanent change to the underlying data structure. It will update the indexing schemes as appropriate, and also add the row into the set returned by the 'rowEnumeration' iterator.

It returns a row index for the new updated records. Throws an exception if the row update was not possible because of IO reasons or the row index not being a valid reference to a record in this data source.

Specified by:
  `updateRow` in interface `MutableTableDataSource`

#### getJournal

    public com.mckoi.database.MasterTableJournal getJournal()

Description copied from interface: `MutableTableDataSource`
Returns a journal that details the changes to this data source since it was created. This method may return a 'null' object to denote that no logging is being done. If this returns a MasterTableJournal, then all 'addRow' and 'removeRow' method calls and their relative order will be described in this journal.

Specified by:
  `getJournal` in interface `MutableTableDataSource`

#### flushIndexChanges

    public void flushIndexChanges()

Description copied from interface: `MutableTableDataSource`
Flushes all changes made on this MutableTableDataSource to the backing index scheme (IndexSet). This is used during the commit phase of this objects lifetime. The transaction control mechanism has found that there are no clashes and now we need to commit the current table view to the conglomerate. Because this object may not update index information immediately, we call this to flush all the changes to the table to the backing index set.

When this method returns, the backing IndexSet of this view will be completely up to date.

Specified by:
  `flushIndexChanges` in interface `MutableTableDataSource`

#### constraintIntegrityCheck

    public void constraintIntegrityCheck()

Description copied from interface: `MutableTableDataSource`
Performs all constraint integrity checks and actions to any modifications based on any changes that happened to the table since that last call to this method. It is important that is called after any call to 'addRow', 'removeRow' or 'updateRow'.

Any constraints that are marked as INITIALLY_IMMEDIATE are checked when this is called, otherwise the constraint is checked at commit time.

Any referential actions are performed when this method is called. If a referential action causes a modification to another table, this method is recursively called on the table modified.

If a referential integrity constraint is violated and a referential action is unable to maintain the integrity of the database, any changes made to the table are reverted.

Specified by:
  `constraintIntegrityCheck` in interface `MutableTableDataSource`

#### dispose

    public void dispose()

Description copied from interface: `MutableTableDataSource`
Disposes this table data source. After this method is called, most use of this object is undefined, except for the 'getCellContent' and 'compareCellContent' methods which are valid provided the source is under a root lock.

Specified by:
  `dispose` in interface `MutableTableDataSource`

#### addRootLock

    public void addRootLock()

Description copied from interface: `MutableTableDataSource`
Puts this source under a 'root lock'. A root lock means the root row structure of this object must not change. A root lock is obtained on a table when a ResultSet keeps hold of an object outside the life of the transaction that created the table. It is important that the order of the rows stays constant (committed deleted rows are not really deleted and reused, etc) while a table holds at least 1 root lock.

Specified by:
  `addRootLock` in interface `MutableTableDataSource`

#### removeRootLock

    public void removeRootLock()

Description copied from interface: `MutableTableDataSource`
Removes a root lock from this source.

Specified by:
  `removeRootLock` in interface `MutableTableDataSource`

#### stringColumn

    protected static DataTableColumnDef stringColumn​(java.lang.String name)

Convenience methods for constructing a DataTableDef for the dynamically generated table.

#### booleanColumn

    protected static DataTableColumnDef booleanColumn​(java.lang.String name)

#### numericColumn

    protected static DataTableColumnDef numericColumn​(java.lang.String name)

#### dateColumn

    protected static DataTableColumnDef dateColumn​(java.lang.String name)