org.apache.ws.jaxme.sqls
Interface Table

All Known Subinterfaces:
DB2Table, HsqlDbTable
All Known Implementing Classes:
DB2TableImpl, HsqlDbTableImpl, TableImpl, ViewImpl

public interface Table

Abstract description of a table.

Author:
Jochen Wiedmann

Nested Class Summary
static interface Table.Name
           
 
Method Summary
 Column getColumn(Column.Name name)
          Returns the column with the given name or null, if no such column exists.
 Column getColumn(java.lang.String name)
          Returns the column with the given name or null, if no such column exists.
 java.util.Iterator getColumns()
          Returns the table columns.
 DeleteStatement getDeleteStatement()
          Returns an UPDATE statement for updating a column in the table.
 java.util.Iterator getForeignKeys()
          Returns an Iterator to the foreign keys defined on the table.
 java.util.Iterator getIndexes()
          Returns an Iterator to the indexes defined on the table.
 InsertStatement getInsertStatement()
          Returns an INSERT statement for filling all the values.
 Table.Name getName()
          Returns the table name.
 Index getPrimaryKey()
          Returns the tables primary key, if any, or null, if the table doesn't have a primary key.
 java.lang.String getQName()
          Returns the tables qualified name, which is getSchema().getName() + "." + getName().
 Schema getSchema()
          Returns the table schema.
 SelectStatement getSelectStatement()
          Returns a SELECT statement for selecting all the columns.
 UpdateStatement getUpdateStatement()
          Returns an UPDATE statement for updating a column in the table.
 Column newColumn(Column.Name name, Column.Type pType)
          Creates a new column.
 Column newColumn(java.lang.String name, Column.Type pType)
          Creates a new column.
 ForeignKey newForeignKey(Table pReferencedTable)
          Creates a new foreign key referencing the given table.
 Index newIndex()
          Creates a new, non-unique index on the table.
 Index newKey()
          Creates a new, unique index on the table.
 Index newPrimaryKey()
          Creates a new primary key on the table.
 

Method Detail

getName

Table.Name getName()

Returns the table name.


getSchema

Schema getSchema()

Returns the table schema.


getColumns

java.util.Iterator getColumns()

Returns the table columns.


newColumn

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

Creates a new column.


newColumn

Column newColumn(java.lang.String name,
                 Column.Type pType)

Creates a new column.


getColumn

Column getColumn(Column.Name name)

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


getColumn

Column getColumn(java.lang.String name)

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


newKey

Index newKey()

Creates a new, unique index on the table.


newIndex

Index newIndex()

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


newPrimaryKey

Index newPrimaryKey()

Creates a new primary key on the table.

Throws:
java.lang.IllegalStateException - A primary key has already been created.

newForeignKey

ForeignKey newForeignKey(Table pReferencedTable)

Creates a new foreign key referencing the given table.


getInsertStatement

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:
SQLFactory.newInsertStatement()

getSelectStatement

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:
SQLFactory.newSelectStatement()

getUpdateStatement

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:
java.lang.IllegalStateException - The table doesn't have a primary key.
See Also:
SQLFactory.newUpdateStatement()

getDeleteStatement

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:
java.lang.IllegalStateException - The table doesn't have a primary key.
See Also:
SQLFactory.newDeleteStatement()

getQName

java.lang.String getQName()

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


getPrimaryKey

Index getPrimaryKey()

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


getIndexes

java.util.Iterator getIndexes()

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


getForeignKeys

java.util.Iterator getForeignKeys()

Returns an Iterator to the foreign keys defined on the table.