Package com.mckoi.database

## Class DataTableDef

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

    public class DataTableDef
    extends java.lang.Object

A definition of a table. Every table in the database has a definition that describes how it is stored on disk, the column definitions, primary keys/foreign keys, and any check constraints.

Author:
  Tobias Downer

### Constructor Summary

Constructors
`DataTableDef()` Constructs this DataTableDef file.
`DataTableDef​(DataTableDef table_def)` Copy constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addColumn​(DataTableColumnDef col_def)`
`void` `addVirtualColumn​(DataTableColumnDef col_def)` Same as 'addColumn' only this does not perform a check to ensure no two columns are the same.
`DataTableColumnDef` `columnAt​(int column)`
`int` `columnCount()`
`void` `dump​(java.io.PrintStream out)` Outputs to the PrintStream for debugging.
`int` `fastFindColumnName​(java.lang.String col)` A faster way to find a column index given a string column name.
`int` `findColumnName​(java.lang.String column_name)`
`java.lang.String` `getName()`
`java.lang.String` `getSchema()`
`java.lang.String` `getTableClass()`
`TableName` `getTableName()`
`boolean` `immutable()` Returns true if this is immutable.
`DataTableDef` `noColumnCopy()` Returns a copy of this object, except with no columns or constraints.
`java.lang.String` `resolveColumnName​(java.lang.String col_name, boolean ignore_case)` Resolves a single column name to its correct form.
`void` `resolveColumnsInArray​(DatabaseConnection connection, java.util.ArrayList list)` Given a list of column names referencing entries in this table, this will resolve each one to its correct form.
`void` `setImmutable()` Sets this DataTableDef to immutable which means nothing is able to change it.
`void` `setTableClass​(java.lang.String clazz)`
`void` `setTableName​(TableName name)`

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

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

### Constructor Detail

#### DataTableDef

    public DataTableDef()

Constructs this DataTableDef file.

#### DataTableDef

    public DataTableDef​(DataTableDef table_def)

Copy constructor.

### Method Detail

#### setImmutable

    public void setImmutable()

Sets this DataTableDef to immutable which means nothing is able to change it.

#### immutable

    public boolean immutable()

Returns true if this is immutable.

#### dump

    public void dump​(java.io.PrintStream out)

Outputs to the PrintStream for debugging.

#### resolveColumnName

    public java.lang.String resolveColumnName​(java.lang.String col_name,
                                              boolean ignore_case)
                                       throws DatabaseException

Resolves a single column name to its correct form. For example, if the database is in case insensitive mode it'll resolve ID to 'id' if 'id' is in this table. Throws a database exception if a column couldn't be resolved (ambiguous or not found).

Throws:
  `DatabaseException`

#### resolveColumnsInArray

    public void resolveColumnsInArray​(DatabaseConnection connection,
                                      java.util.ArrayList list)
                               throws DatabaseException

Given a list of column names referencing entries in this table, this will resolve each one to its correct form. Throws a database exception if a column couldn't be resolved.

Throws:
  `DatabaseException`

#### setTableName

    public void setTableName​(TableName name)

#### setTableClass

    public void setTableClass​(java.lang.String clazz)

#### addColumn

    public void addColumn​(DataTableColumnDef col_def)

#### addVirtualColumn

    public void addVirtualColumn​(DataTableColumnDef col_def)

Same as 'addColumn' only this does not perform a check to ensure no two columns are the same.

#### getSchema

    public java.lang.String getSchema()

#### getName

    public java.lang.String getName()

#### getTableName

    public TableName getTableName()

#### getTableClass

    public java.lang.String getTableClass()

#### columnCount

    public int columnCount()

#### columnAt

    public DataTableColumnDef columnAt​(int column)

#### findColumnName

    public int findColumnName​(java.lang.String column_name)

#### fastFindColumnName

    public final int fastFindColumnName​(java.lang.String col)

A faster way to find a column index given a string column name. This caches column name -> column index in a HashMap.

#### noColumnCopy

    public DataTableDef noColumnCopy()

Returns a copy of this object, except with no columns or constraints.