org.brains2b.squeler.ddl
Class ColumnDDL

java.lang.Object
  extended by org.brains2b.sql.meta.ColumnModel
      extended by org.brains2b.squeler.ddl.ColumnDDL
All Implemented Interfaces:
org.brains2b.sql.meta.SQLMetaModel, DDLDefinition

public class ColumnDDL
extends org.brains2b.sql.meta.ColumnModel
implements DDLDefinition

ColumnDDL defines and writes a column DDL statement that is used in other DDL statements.

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

Field Summary
 
Fields inherited from interface org.brains2b.squeler.ddl.DDLDefinition
CREATE, DELETE, UPDATE
 
Constructor Summary
ColumnDDL()
          Constructor for ColumnDDL.
ColumnDDL(org.brains2b.sql.meta.ColumnModel model)
           
ColumnDDL(java.lang.String columnName, int dataType, java.lang.String typeName, int columnSize, int decimalDigits, java.lang.String dflt, boolean nullable)
          Constructor for ColumnDDL.
 
Method Summary
 int getAction()
           
 java.lang.StringBuffer getStatement()
           
 java.lang.StringBuffer getStatement(java.lang.String type, int action)
          gets the correct column statement for a DDL type
 java.lang.String getTypeName()
          Implemented here to return a valid Oracle name on the basis of a data type as defined in java.sql.Types
 boolean isDescendingSort()
          check if the column should be sorted in desceding order
 boolean isNullable()
          checks if the column is nullable.
 boolean isQualified()
           
 boolean isReplaceable()
           
 void setAction(int action)
           
 void setColumnName(java.lang.String columnName)
          sets the name for this column
 void setColumnSize(int size)
          sets the length of this column
 void setDataType(short dataType)
          set the data type for this column as defined in java.sql.Types
 void setDecimalDigits(int decimals)
          sets the number of decimal digits.
 void setDescendingSort(boolean descendingSort)
          sets the column to be sorted descending
 void setModel(org.brains2b.sql.meta.SQLMetaModel model)
           
 void setNullable(boolean nullable)
          sets a flag if this column is nullable
 void setTableName(java.lang.String tableName)
          sets the table name for this column
 void setTypeName(java.lang.String typeName)
          set the data type for this column as defined in java.sql.Types
 java.lang.String toString()
           
 
Methods inherited from class org.brains2b.sql.meta.ColumnModel
equals, getColumnSize, getDataType, getDecimalDigits, getDefault, getName, getRecord, getRemarks, getSequence, getTableName, getType, 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
 

Constructor Detail

ColumnDDL

public ColumnDDL()
Constructor for ColumnDDL.


ColumnDDL

public ColumnDDL(org.brains2b.sql.meta.ColumnModel model)

ColumnDDL

public ColumnDDL(java.lang.String columnName,
                 int dataType,
                 java.lang.String typeName,
                 int columnSize,
                 int decimalDigits,
                 java.lang.String dflt,
                 boolean nullable)
Constructor for ColumnDDL.

Parameters:
columnName - String, the columnName which is off course required
dataType - int, the datatype of the column. Must be value defined in java.sql.Types
columnSize - int, the length of this column, not required for all dataypes
decimalDigits - int, the number of decimal positions for a number set to 0 if not required
dflt - String, default value
nullable - boolean, is this a required field, only used if actually set to false
Method Detail

getStatement

public java.lang.StringBuffer getStatement()
                                    throws SquelerDDLException
Specified by:
getStatement in interface DDLDefinition
Throws:
SquelerDDLException
See Also:
DDLWriter.getStatement()

getStatement

public java.lang.StringBuffer getStatement(java.lang.String type,
                                           int action)
                                    throws SquelerDDLException
gets the correct column statement for a DDL type

Parameters:
type - String, the type of object you want to create a column statement for: Use {Object}DDL.TYPE as parameter
Returns:
StringBuffer, a buffer containing the sql statement for the given type for this column
Throws:
SquelerDDLException, - thrown if a valid SQL statement cannot be made from the supplied information
SquelerDDLException

getTypeName

public java.lang.String getTypeName()
Implemented here to return a valid Oracle name on the basis of a data type as defined in java.sql.Types

Overrides:
getTypeName in class org.brains2b.sql.meta.ColumnModel
See Also:
ColumnModel.getTypeName()

setTableName

public void setTableName(java.lang.String tableName)
sets the table name for this column

Parameters:
tableName - String, the tableName

setColumnName

public void setColumnName(java.lang.String columnName)
sets the name for this column

Parameters:
columnName - String, the columnName

setColumnSize

public void setColumnSize(int size)
sets the length of this column

Parameters:
size - int, the size

setDataType

public void setDataType(short dataType)
set the data type for this column as defined in java.sql.Types

Parameters:
dataType - short, the datatype

setTypeName

public void setTypeName(java.lang.String typeName)
set the data type for this column as defined in java.sql.Types

Parameters:
typeName - String, the datatype

setDecimalDigits

public void setDecimalDigits(int decimals)
sets the number of decimal digits.

set to 0 if datatype is not a number

Parameters:
decimals - int, the number of decimal positions

setNullable

public void setNullable(boolean nullable)
sets a flag if this column is nullable

true does not do anything in this respect, while JDBC defines three values for NULLABLE (YES,NO,We don't know)

Parameters:
nullable - boolean, set to false if this column cannot be NULL

isNullable

public boolean isNullable()
checks if the column is nullable.

Warning:true might mean it is nullable or JDBC just doesn't know

Overrides:
isNullable in class org.brains2b.sql.meta.ColumnModel
Returns:
boolean, false if column cannot be null, true if it can or it is undetermined

isDescendingSort

public boolean isDescendingSort()
check if the column should be sorted in desceding order

Only used for IndexDDL, the default is asceding.

Returns:
boolean, true if the column should be ordered descending, false it it should be ordered ascending

setDescendingSort

public void setDescendingSort(boolean descendingSort)
sets the column to be sorted descending

Only used for IndexDDL, the default is asceding.

Parameters:
descendingSort - boolean, set to true if you want this column ordered descending.

toString

public java.lang.String toString()
Specified by:
toString in interface DDLDefinition
Overrides:
toString in class org.brains2b.sql.meta.ColumnModel

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