org.apache.ws.jaxme.sqls

Interface Table

public interface Table

Abstract description of a table.

Author: Jochen Wiedmann

Nested Class Summary
static interfaceTable.Name
Method Summary
ColumngetColumn(Column.Name name)

Returns the column with the given name or null, if no such column exists.

ColumngetColumn(String name)

Returns the column with the given name or null, if no such column exists.

IteratorgetColumns()

Returns the table columns.

DeleteStatementgetDeleteStatement()

Returns an UPDATE statement for updating a column in the table.

IteratorgetForeignKeys()

Returns an {@link Iterator} to the foreign keys defined on the table.

IteratorgetIndexes()

Returns an {@link Iterator} to the indexes defined on the table.

InsertStatementgetInsertStatement()

Returns an INSERT statement for filling all the values.

Table.NamegetName()

Returns the table name.

IndexgetPrimaryKey()

Returns the tables primary key, if any, or null, if the table doesn't have a primary key.

StringgetQName()

Returns the tables qualified name, which is getSchema().getName() + "." + getName().

SchemagetSchema()

Returns the table schema.

SelectStatementgetSelectStatement()

Returns a SELECT statement for selecting all the columns.

UpdateStatementgetUpdateStatement()

Returns an UPDATE statement for updating a column in the table.

ColumnnewColumn(Column.Name name, Column.Type pType)

Creates a new column.

ColumnnewColumn(String name, Column.Type pType)

Creates a new column.

ForeignKeynewForeignKey(Table pReferencedTable)

Creates a new foreign key referencing the given table.

IndexnewIndex()

Creates a new, non-unique index on the table.

IndexnewKey()

Creates a new, unique index on the table.

IndexnewPrimaryKey()

Creates a new primary key on the table.

Method Detail

getColumn

public Column getColumn(Column.Name name)

Returns the column with the given name or null, if no such column exists.

getColumn

public Column getColumn(String name)

Returns the column with the given name or null, if no such column exists.

getColumns

public Iterator getColumns()

Returns the table columns.

getDeleteStatement

public DeleteStatement getDeleteStatement()

Returns an UPDATE statement for updating a column in the table. In other words: If the table FOO has the primary key columns A and B, then the statement DELETE FROM FOO WHERE A = ? AND B = ? will be returned.

Throws: IllegalStateException The table doesn't have a primary key.

See Also: newDeleteStatement

getForeignKeys

public Iterator getForeignKeys()

Returns an {@link Iterator} to the foreign keys defined on the table.

getIndexes

public Iterator getIndexes()

Returns an {@link Iterator} to the indexes defined on the table. This iterator includes the primary key, if any.

getInsertStatement

public InsertStatement getInsertStatement()

Returns an INSERT statement for filling all the values. In other words: If the table FOO has the columns A, B, and C, then the statement INSERT INTO FOO (A,B,C) VALUES (?, ?, ?) will be returned.

See Also: newInsertStatement

getName

public Table.Name getName()

Returns the table name.

getPrimaryKey

public Index getPrimaryKey()

Returns the tables primary key, if any, or null, if the table doesn't have a primary key.

getQName

public String getQName()

Returns the tables qualified name, which is getSchema().getName() + "." + getName(). If the schema is the default schema, returns getName().

getSchema

public Schema getSchema()

Returns the table schema.

getSelectStatement

public SelectStatement getSelectStatement()

Returns a SELECT statement for selecting all the columns. In other words: If the table FOO has the columns A, B, and C, then the statement SELECT A, B, C FROM FOO will be returned.

See Also: newSelectStatement

getUpdateStatement

public UpdateStatement getUpdateStatement()

Returns an UPDATE statement for updating a column in the table. In other words: If the table FOO has the columns A, B, C and D with the primary key columns A and B, then the statement UPDATE FOO SET C = ?, D = ? WHERE A = ? AND B = ? will be returned.

Throws: IllegalStateException The table doesn't have a primary key.

See Also: newUpdateStatement

newColumn

public Column newColumn(Column.Name name, Column.Type pType)

Creates a new column.

newColumn

public Column newColumn(String name, Column.Type pType)

Creates a new column.

newForeignKey

public ForeignKey newForeignKey(Table pReferencedTable)

Creates a new foreign key referencing the given table.

newIndex

public Index newIndex()

Creates a new, non-unique index on the table.

newKey

public Index newKey()

Creates a new, unique index on the table.

newPrimaryKey

public Index newPrimaryKey()

Creates a new primary key on the table.

Throws: IllegalStateException A primary key has already been created.