org.brains2b.squeler.ddl
Class TableDDL

java.lang.Object
  extended by org.brains2b.sql.meta.TableModel
      extended by org.brains2b.squeler.ddl.TableDDL
All Implemented Interfaces:
org.brains2b.sql.meta.SQLMetaModel, ColumnRelation, DDLDefinition, DDLWriter

public class TableDDL
extends org.brains2b.sql.meta.TableModel
implements DDLWriter, DDLDefinition, ColumnRelation

Defines a table and writes it to requested output

Version:
$Revision$ $Date$
Author:
dennis@brains2b.nl

Field Summary
 
Fields inherited from interface org.brains2b.squeler.ddl.DDLWriter
CONSTRAINT, INDEX, TABLE
 
Fields inherited from interface org.brains2b.squeler.ddl.DDLDefinition
CREATE, DELETE, UPDATE
 
Constructor Summary
TableDDL()
          Constructor for TableDDL.
TableDDL(java.lang.String catalog, java.lang.String schema, java.lang.String name, java.lang.String remarks)
          Constructor for TableDDL.
TableDDL(org.brains2b.sql.meta.TableModel model)
           
 
Method Summary
 void addColumn(ColumnDDL column)
           
protected  java.lang.StringBuffer createStatement()
           
protected  java.lang.StringBuffer dropStatement()
           
 int getAction()
           
 java.lang.StringBuffer getStatement()
          gets a StringBuffer containing the proper statement for creation
 java.lang.String getTablespace()
           
 boolean isQualified()
           
 boolean isReplaceable()
           
 boolean isTemporary()
           
 void setAction(int action)
           
 void setColumns(java.util.List columns)
           
 void setModel(org.brains2b.sql.meta.SQLMetaModel model)
           
 void setQualified(boolean b)
           
 void setTableCat(java.lang.String tableCat)
           
 void setTableName(java.lang.String tableName)
           
 void setTableSchema(java.lang.String tableSchema)
           
 void setTablespace(java.lang.String tablespace)
           
 void setTemporary(boolean b)
           
 java.lang.String toString()
           
 void write(java.sql.Connection con)
          writes the DDL statement directly to the database.
 void write(java.io.PrintWriter writer)
          Method write.
 
Methods inherited from class org.brains2b.sql.meta.TableModel
equals, getCatalog, getColumns, getIndices, getName, getPrimaryKey, getRecord, getRemarks, getSchema, getType, setIndices, setPrimaryKey, setRecord
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.brains2b.sql.meta.SQLMetaModel
getName, getRecord, getType
 
Methods inherited from interface org.brains2b.squeler.ddl.ColumnRelation
getColumns
 

Constructor Detail

TableDDL

public TableDDL()
Constructor for TableDDL.


TableDDL

public TableDDL(org.brains2b.sql.meta.TableModel model)

TableDDL

public TableDDL(java.lang.String catalog,
                java.lang.String schema,
                java.lang.String name,
                java.lang.String remarks)
Constructor for TableDDL.

Parameters:
catalog -
schema -
name -
remarks -
Method Detail

write

public void write(java.sql.Connection con)
           throws SquelerDDLException,
                  java.sql.SQLException
Description copied from interface: DDLWriter
writes the DDL statement directly to the database.

Specified by:
write in interface DDLWriter
Parameters:
con - java.sql.Connection, the connection to the database, should have been initialized
Throws:
SquelerDDLException - thrown if problems arise with the definition of the statement
java.sql.SQLException - thrown if problems arise writing a correct statement to the database (no privleges to run this action, e.d.)

write

public void write(java.io.PrintWriter writer)
           throws SquelerDDLException,
                  java.io.IOException
Description copied from interface: DDLWriter
Method write.

Specified by:
write in interface DDLWriter
Throws:
SquelerDDLException - thrown if problems arise with the definition of the statement
java.io.IOException - thrown if problems arise writing a correct statement to a file (access denied, could not create file e.d.)

createStatement

protected java.lang.StringBuffer createStatement()
                                          throws SquelerDDLException
Throws:
SquelerDDLException
See Also:
DDLWriter.getStatement()

addColumn

public void addColumn(ColumnDDL column)
Specified by:
addColumn in interface ColumnRelation

setTableCat

public void setTableCat(java.lang.String tableCat)

setTableSchema

public void setTableSchema(java.lang.String tableSchema)

setTableName

public void setTableName(java.lang.String tableName)

isTemporary

public boolean isTemporary()
Returns:
boolean

setTemporary

public void setTemporary(boolean b)
Parameters:
b -

toString

public java.lang.String toString()
Specified by:
toString in interface DDLDefinition
Overrides:
toString in class java.lang.Object

setModel

public void setModel(org.brains2b.sql.meta.SQLMetaModel model)
Specified by:
setModel in interface DDLDefinition

getStatement

public java.lang.StringBuffer getStatement()
                                    throws SquelerDDLException
Description copied from interface: DDLWriter
gets a StringBuffer containing the proper statement for creation

Specified by:
getStatement in interface DDLDefinition
Specified by:
getStatement in interface DDLWriter
Returns:
StringBuffer, the Buffer containing the statement
Throws:
SquelerDDLException - thrown if problems arise with the definition of the statement

dropStatement

protected java.lang.StringBuffer dropStatement()
                                        throws SquelerDDLException
Throws:
SquelerDDLException

getAction

public int getAction()
Specified by:
getAction in interface DDLDefinition

isQualified

public boolean isQualified()
Specified by:
isQualified in interface DDLDefinition

isReplaceable

public boolean isReplaceable()
Specified by:
isReplaceable in interface DDLDefinition

setAction

public void setAction(int action)
Specified by:
setAction in interface DDLDefinition

setQualified

public void setQualified(boolean b)

getTablespace

public java.lang.String getTablespace()

setTablespace

public void setTablespace(java.lang.String tablespace)

setColumns

public void setColumns(java.util.List columns)
Specified by:
setColumns in interface ColumnRelation
Overrides:
setColumns in class org.brains2b.sql.meta.TableModel