Package com.mckoi.database
Class DataTableDef
java.lang.Object
com.mckoi.database.DataTableDef
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
ConstructorsConstructorDescriptionConstructs this DataTableDef file.DataTableDef
(DataTableDef table_def) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.columnAt
(int column) int
void
dump
(PrintStream out) Outputs to the PrintStream for debugging.final int
fastFindColumnName
(String col) A faster way to find a column index given a string column name.int
findColumnName
(String column_name) getName()
boolean
Returns true if this is immutable.Returns a copy of this object, except with no columns or constraints.resolveColumnName
(String col_name, boolean ignore_case) Resolves a single column name to its correct form.void
resolveColumnsInArray
(DatabaseConnection connection, ArrayList list) Given a list of column names referencing entries in this table, this will resolve each one to its correct form.void
Sets this DataTableDef to immutable which means nothing is able to change it.void
setTableClass
(String clazz) void
setTableName
(TableName name)
-
Constructor Details
-
DataTableDef
public DataTableDef()Constructs this DataTableDef file. -
DataTableDef
Copy constructor.
-
-
Method Details
-
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
Outputs to the PrintStream for debugging. -
resolveColumnName
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, 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
-
setTableClass
-
addColumn
-
addVirtualColumn
Same as 'addColumn' only this does not perform a check to ensure no two columns are the same. -
getSchema
-
getName
-
getTableName
-
getTableClass
-
columnCount
public int columnCount() -
columnAt
-
findColumnName
-
fastFindColumnName
A faster way to find a column index given a string column name. This caches column name -> column index in a HashMap. -
noColumnCopy
Returns a copy of this object, except with no columns or constraints.
-