atg.cortex
Class TableDeclaration

java.lang.Object
  extended by atg.cortex.TableDeclaration

public class TableDeclaration
extends java.lang.Object

This represents the declaration of a table, comprised of ColumnDeclaration objects. This object can be used to create, drop, or check the existence of the table.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Constructor Summary
TableDeclaration(java.lang.String pName)
          Constructs a new TableDeclaration
 
Method Summary
 void addColumn(ColumnDeclaration pColumn)
          Adds a column declarations to the list of columns for the table.
 void createTable(java.sql.Connection pConnection, TypeInfoMap pTypeInfoMap)
          Executes the CREATE TABLE statement needed to create this table with the specified column declarations.
 void dropTable(java.sql.Connection pConnection)
          Executes the DROP TABLE statement needed to remove the table with this TableDeclaration's name.
 ColumnDeclaration getColumn(int pIndex)
          Returns the ColumnDeclaration at the specified index
 ColumnDeclaration getColumn(java.lang.String pColumnName)
          Returns the ColumnDeclaration for the given name, or null if none found.
 int getColumnCount()
          Returns the number of columns added to the table
 java.lang.String getCreateTableStatement(java.sql.Connection pConnection, TypeInfoMap pTypeInfoMap)
          Returns the CREATE TABLE statement that would be used to create this table.
 java.lang.String getName()
          Returns the name of the table
 boolean isCreated(java.sql.Connection pConnection)
          Returns true if there is a table with the same name as this TableDeclaration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values
Constructor Detail

TableDeclaration

public TableDeclaration(java.lang.String pName)
Constructs a new TableDeclaration

Parameters:
pName - the name of the table
Method Detail

addColumn

public void addColumn(ColumnDeclaration pColumn)
Adds a column declarations to the list of columns for the table.


getName

public java.lang.String getName()
Returns the name of the table


getColumnCount

public int getColumnCount()
Returns the number of columns added to the table


getColumn

public ColumnDeclaration getColumn(int pIndex)
Returns the ColumnDeclaration at the specified index


getColumn

public ColumnDeclaration getColumn(java.lang.String pColumnName)
Returns the ColumnDeclaration for the given name, or null if none found.


createTable

public void createTable(java.sql.Connection pConnection,
                        TypeInfoMap pTypeInfoMap)
                 throws java.sql.SQLException
Executes the CREATE TABLE statement needed to create this table with the specified column declarations.

Parameters:
pConnection - the Connection to be used to create the table
pTypeInfoMap - the TypeInfoMap mapping JDBC types to database-specific types
Throws:
java.sql.SQLException - if a SQL error occurred

getCreateTableStatement

public java.lang.String getCreateTableStatement(java.sql.Connection pConnection,
                                                TypeInfoMap pTypeInfoMap)
                                         throws java.sql.SQLException
Returns the CREATE TABLE statement that would be used to create this table.

Throws:
java.sql.SQLException

dropTable

public void dropTable(java.sql.Connection pConnection)
               throws java.sql.SQLException
Executes the DROP TABLE statement needed to remove the table with this TableDeclaration's name.

Parameters:
pConnection - the Connection to be used to drop the table
Throws:
java.sql.SQLException - if a SQL error occurred

isCreated

public boolean isCreated(java.sql.Connection pConnection)
                  throws java.sql.SQLException
Returns true if there is a table with the same name as this TableDeclaration. Does not check to see if that table has the same column definitions as the TableDeclaration.

Parameters:
pConnection - the Connection to be used to test existence of the table
Throws:
java.sql.SQLException - if a SQL error occurred