anderix.datajets
Class TableDefinition

java.lang.Object
  extended by anderix.datajets.TableDefinition

public class TableDefinition
extends java.lang.Object

Contains information about a physical database table. TableDefinition allows a DataJet to contain all the information neccessary to build a corresponding table in which to store its data. When using a TableDefinition object, it is usually neccessary to include information about your database platform that may not be portable to other platforms.

See Also:
Definable

Constructor Summary
TableDefinition(java.lang.String table, java.lang.String idField, java.lang.String idFieldProperties)
          Constructor that begins the physical table definition.
 
Method Summary
 void addField(java.lang.String fieldName, java.lang.String fieldProperties)
          Adds a field to the table definition.
 SqlBuilder createSqlBuilder()
          Creates a SqlBuilder object based on the TableDefinition.
 void createTable(java.sql.Connection con, boolean dropTableFirst)
          Creates a physical database table based on the TableDefinition.
 void createTable(ConnectionGenerator generator, boolean dropTableFirst)
          Creates a physical database table based on the TableDefinition.
 void createTable(java.lang.String driver, java.lang.String connectionString, boolean dropTableFirst)
          Creates a physical database table based on the TableDefinition.
 java.lang.String getFieldName(int fieldIndex)
          Returns the name of the field located at the specified index.
 java.lang.String[] getFieldNames()
          Returns the names of all field specified.
 java.lang.String[] getFieldProperties()
          Returns the properties of all field specified.
 java.lang.String getFieldProperties(int fieldIndex)
          Returns the properties for the field located at the specified index.
 java.lang.String getTable()
          Returns the name of the table.
 int indexOf(java.lang.String fieldName)
          Finds the index of the field specified.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableDefinition

public TableDefinition(java.lang.String table,
                       java.lang.String idField,
                       java.lang.String idFieldProperties)
Constructor that begins the physical table definition.

Parameters:
table - name of the physical database table
idField - name of the field to use as identity
idFieldProperties - string that defines the id field
Method Detail

addField

public void addField(java.lang.String fieldName,
                     java.lang.String fieldProperties)
Adds a field to the table definition.

Parameters:
fieldName - name of the field to add
fieldProperties - string that defines the field

getTable

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

Returns:
name of the table

indexOf

public int indexOf(java.lang.String fieldName)
Finds the index of the field specified.

Parameters:
fieldName - name of field to find index of
Returns:
index of the field; or -1 if not found

getFieldName

public java.lang.String getFieldName(int fieldIndex)
Returns the name of the field located at the specified index.

Parameters:
fieldIndex - index of field to return
Returns:
name of the field

getFieldNames

public java.lang.String[] getFieldNames()
Returns the names of all field specified.

Returns:
array containing all the names of the fields

getFieldProperties

public java.lang.String getFieldProperties(int fieldIndex)
Returns the properties for the field located at the specified index.

Parameters:
fieldIndex - index of field to return
Returns:
properties of the field

getFieldProperties

public java.lang.String[] getFieldProperties()
Returns the properties of all field specified.

Returns:
array containing all the properties of the fields

createSqlBuilder

public SqlBuilder createSqlBuilder()
Creates a SqlBuilder object based on the TableDefinition.

Returns:
new SqlBuilder object

createTable

public void createTable(ConnectionGenerator generator,
                        boolean dropTableFirst)
                 throws DataJetException
Creates a physical database table based on the TableDefinition.

Parameters:
generator - ConnectionGenerator with database connection information
dropTableFirst - set to true to drop existing table before creating table
Throws:
DataJetException - if the connection information provided to the DataJet object is incorrect or if the DataJet has not been initialized

createTable

public void createTable(java.lang.String driver,
                        java.lang.String connectionString,
                        boolean dropTableFirst)
                 throws DataJetException
Creates a physical database table based on the TableDefinition.

Parameters:
driver - string name of driver class to load
connectionString - database url to create Connection object
dropTableFirst - set to true to drop existing table before creating table
Throws:
DataJetException - if the connection information provided to the DataJet object is incorrect or if the DataJet has not been initialized

createTable

public void createTable(java.sql.Connection con,
                        boolean dropTableFirst)
                 throws DataJetException
Creates a physical database table based on the TableDefinition.

Parameters:
con - existing connection to the database server
dropTableFirst - set to true to drop existing table before creating table
Throws:
DataJetException - if the DataJet has not been initialized