its.SQL
Class Table

java.lang.Object
  extended byits.SQL.Table

public class Table
extends java.lang.Object

Provides an object-oriented view of a table from an SDD Schema. Created and used by the SDD Parser to store information parsed from the SDD Schema frame.


Constructor Summary
Table(java.lang.String name)
          Creates an empty Table object.
Table(java.lang.String name, Variable[] columns)
          Creates a Table containing the given columns.
Table(Table t)
          Returns a new Table object that is a clone of the given Table object.
 
Method Summary
 void addVariable(Variable v)
          Adds a column to the table.
 java.util.Enumeration columns()
          returns an Enumeration of all variables in the table
 java.util.Vector getForeign()
          Returns a Vector of ForeignData objects describing all foreign-key references for this table.
 java.lang.String getName()
          gets the table name
 int getNumberOfColumns()
          gets the number of columns in the table
 java.util.Vector getPrimaryKey()
          Returns a Vector of String objects that contain the names of the columns that form the primary key for this table.
 Variable getVariable(int index)
          gets the variable at the given index
 Variable getVariable(java.lang.String name)
          gets the variable with the given name
 java.util.Hashtable getVariableHashtable()
           
 java.util.Vector getVariableVector()
           
 boolean hasVariable(java.lang.String name)
           
 void setName(java.lang.String strName)
           
 void setTablespace(java.lang.String s)
          This causes the table to generate the TABLESPACE modifier at the end of its list of elements, containing a vendor-specific string that is a hint to the database about where to store a table.
 java.lang.String toSql()
          Generates the CREATE TABLE statement that defines this table
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Table

public Table(java.lang.String name,
             Variable[] columns)
Creates a Table containing the given columns.

Parameters:
name - the table's name
columns - the list of column data types

Table

public Table(java.lang.String name)
Creates an empty Table object. Columns can be added with the addVariable method.

Parameters:
name - the table's name

Table

public Table(Table t)
Returns a new Table object that is a clone of the given Table object. Makes copies of the Variable objects contained within the Table.

Method Detail

addVariable

public void addVariable(Variable v)
Adds a column to the table. Used by the SDD Schema parser to build up a table object. If a column with the same name as the given column already exists in the table, it will be replaced.


getName

public java.lang.String getName()
gets the table name

Returns:
table name

setName

public void setName(java.lang.String strName)

getVariableVector

public java.util.Vector getVariableVector()
Returns:
the list of columns in this table

getVariableHashtable

public java.util.Hashtable getVariableHashtable()
Returns:
a hashtable mapping column names to Variable objects

getVariable

public Variable getVariable(int index)
                     throws java.lang.IllegalArgumentException
gets the variable at the given index

Parameters:
index - the index into the list of variables
Returns:
variable a column variable
Throws:
java.lang.IllegalArgumentException - if the given index is out of bounds

getVariable

public Variable getVariable(java.lang.String name)
                     throws java.lang.IllegalArgumentException
gets the variable with the given name

Parameters:
name - the name of that variable
Returns:
variable a column variable
Throws:
java.lang.IllegalArgumentException - if the table does not contain a column with the given name

hasVariable

public boolean hasVariable(java.lang.String name)
Returns:
true if the table contains a column with the given name

columns

public java.util.Enumeration columns()
returns an Enumeration of all variables in the table


getNumberOfColumns

public int getNumberOfColumns()
gets the number of columns in the table

Returns:
the number of columns

setTablespace

public void setTablespace(java.lang.String s)
This causes the table to generate the TABLESPACE modifier at the end of its list of elements, containing a vendor-specific string that is a hint to the database about where to store a table.


getForeign

public java.util.Vector getForeign()
Returns a Vector of ForeignData objects describing all foreign-key references for this table. The SDD Schema parser validates the correctness of these constraints when it builds the vector.


getPrimaryKey

public java.util.Vector getPrimaryKey()
Returns a Vector of String objects that contain the names of the columns that form the primary key for this table. For a table with a multiple-column PRIMARY KEY statement, the column names will be in the stated order. Be aware that adding Variables with the PRIMARY_KEY constraint has no effect on this vector.


toSql

public java.lang.String toSql()
Generates the CREATE TABLE statement that defines this table