public class TableSpec extends Object
An application constructs a TableSpec without regard to the underlying database kind, and then the TableSpec is converted to a DB-specific CREATE TABLE DDL command by a DDLConverter before the command is issued via JDBC.
| Constructor and Description |
|---|
TableSpec(String name,
List<ColumnSpec> columnSpecs,
String primaryColumnName)
Constructs a TableSpec given a name, a set of ColumnSpecs, and the name
of the primary key column.
|
TableSpec(String name,
List<ColumnSpec> columnSpecs,
String primaryColumnName,
String type)
Constructs a TableSpec given a name, a set of ColumnSpecs, the name of
the primary key column, and a table type.
|
| Modifier and Type | Method and Description |
|---|---|
void |
assertConsistent()
Ensures that the TableSpec is internally consistent.
|
Iterator<ColumnSpec> |
columnSpecIterator()
Gets an iterator over the columns.
|
String |
getName()
Gets the name of the table.
|
String |
getPrimaryColumnName()
Gets the name of the primary key column.
|
static List<TableSpec> |
getTableSpecs(InputStream in)
Gets a TableSpec for each table element in the stream, where the stream
contains a valid XML document containing one or more table elements,
wrapped in the root element.
|
String |
getType()
Gets the type of the table.
|
public TableSpec(String name, List<ColumnSpec> columnSpecs, String primaryColumnName) throws InconsistentTableSpecException
name - The table name.columnSpecs - ColumnSpec objects describing columns in the table.primaryColumnName - The column that is the primary key for the table.InconsistentTableSpecException - if inconsistencies are detected in table specifications.public TableSpec(String name, List<ColumnSpec> columnSpecs, String primaryColumnName, String type) throws InconsistentTableSpecException
name - The table name.columnSpecs - ColumnSpec objects describing columns in the table.primaryColumnName - The column that is the primary key for the table.type - The table type.InconsistentTableSpecException - if inconsistencies are detected in table specifications.public static List<TableSpec> getTableSpecs(InputStream in) throws InconsistentTableSpecException, IOException
Input is of the form:
<database>
<table name="tableName" primaryKey="primaryColumnName" type="tableType">
<column name="columnName"
type="typeSpec"
autoIncrement="isAutoIncremented"
index="indexName"
notNull="isNotNull"
unique="isUnique"
default="defaultValue"
foreignKey="foreignTableName.columnName onDeleteAction"/>
</table>
</database>
About the attributes:
in - The xml-encoded table specs.InconsistentTableSpecException - if inconsistencies are detected in table specifications.IOException - if an IO error occurs.public void assertConsistent()
throws InconsistentTableSpecException
InconsistentTableSpecException - If it's inconsistent.public String getName()
public String getPrimaryColumnName()
public String getType()
public Iterator<ColumnSpec> columnSpecIterator()
Copyright © 2013 DuraSpace. All Rights Reserved.