org.brains2b.squeler.ddl
Class IndexDDL

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

public class IndexDDL
extends org.brains2b.sql.meta.IndexModel
implements DDLWriter, DDLDefinition, ColumnRelation

Holds the data and creates an index for the defined values

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
IndexDDL()
          Constructor for IndexDDL.
IndexDDL(java.lang.String indexName, java.lang.String tableName, boolean unique)
          Method IndexDDL.
 
Method Summary
 void addColumn(ColumnDDL column)
          adds a Column to the Index
 int getAction()
           
 java.lang.StringBuffer getStatement()
          gets a StringBuffer containing the proper statement for creation
 java.lang.String getTablespace()
           
 boolean isDropWithTable()
           
 boolean isQualified()
           
 boolean isReplaceable()
           
 void setAction(int action)
           
 void setColumns(java.util.List columns)
           
 void setDropWithTable(boolean dropWithTable)
           
 void setModel(org.brains2b.sql.meta.SQLMetaModel model)
           
 void setTablespace(java.lang.String tablespace)
           
 void setUnique(boolean unique)
           
 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.IndexModel
addColumn, equals, getColumns, getName, getRecord, getTableName, getType, isUnique, 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

IndexDDL

public IndexDDL()
Constructor for IndexDDL.


IndexDDL

public IndexDDL(java.lang.String indexName,
                java.lang.String tableName,
                boolean unique)
Method IndexDDL.

Parameters:
indexName - String, the name of the index needs to be unique for the schema or catalog
tableName - String, the name of the table this index is created on.
unique - boolean, true if you want to create a unique index
Method Detail

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
See Also:
DDLWriter.getStatement()

addColumn

public void addColumn(ColumnDDL column)
adds a Column to the Index

At least one column is required, but you can add as many as the database supports. The columns will be defined in the index in the order which you add them

Note:If the column has a table defined and it is not the same as the table for this index getStatement will throw a SquelerException.

Specified by:
addColumn in interface ColumnRelation
Parameters:
column - ColumnDDL, the column on which this index should be created.
See Also:
ColumnDDL

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.)

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.)

toString

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

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

setModel

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

setColumns

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

getTablespace

public java.lang.String getTablespace()

setTablespace

public void setTablespace(java.lang.String tablespace)

isDropWithTable

public boolean isDropWithTable()

setDropWithTable

public void setDropWithTable(boolean dropWithTable)

setUnique

public void setUnique(boolean unique)