org.brains2b.sql.meta
Class ConstraintModel

java.lang.Object
  extended by org.brains2b.sql.meta.ConstraintModel
All Implemented Interfaces:
SQLMetaModel

public class ConstraintModel
extends java.lang.Object
implements SQLMetaModel

Wrapper around the constraint definition from DatabaseMetaData

Class is read-only, use SquelerDDL:ConstraintDDL for changing columns

Version:
1.01 [26-10-2007]
Author:
dennis@brains2b.nl
See Also:
SQLMetaData, SQLRecord

Field Summary
static java.lang.String CHECK
          constant for a check constraint
static java.lang.String FOREIGN_KEY
          constant for a foreign key constraint
static java.lang.String PRIMARY_KEY
          constant for a primary key constraint
 
Constructor Summary
protected ConstraintModel()
          Constructor only used by ConstraintDDL
  ConstraintModel(java.lang.String type, SQLRecord record)
          Create a ConstriantModel of this specific type on the basis of the provided SQLRecord
 
Method Summary
protected  void addColumn(ColumnModel model)
          add a ColumnModel as a part of this ConstraintModel
 boolean equals(java.lang.Object obj)
           
 java.util.List getColumns()
          get the Columns referenced by this constraint
 java.lang.String getName()
          get the name for this model's instance
 SQLRecord getRecord()
          the record which defines all the values for the model
 java.lang.String getTableName()
          get the table name for this Constraint
 java.lang.String getType()
          get the type of Object defined by the meta model
protected  void setColumns(java.util.List columns)
          set the columns for this Model
protected  void setRecord(SQLRecord record)
          set the record for this Model
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIMARY_KEY

public static final java.lang.String PRIMARY_KEY
constant for a primary key constraint

See Also:
Constant Field Values

FOREIGN_KEY

public static final java.lang.String FOREIGN_KEY
constant for a foreign key constraint

See Also:
Constant Field Values

CHECK

public static final java.lang.String CHECK
constant for a check constraint

See Also:
Constant Field Values
Constructor Detail

ConstraintModel

protected ConstraintModel()
Constructor only used by ConstraintDDL


ConstraintModel

public ConstraintModel(java.lang.String type,
                       SQLRecord record)
Create a ConstriantModel of this specific type on the basis of the provided SQLRecord

Parameters:
type - String, one of the constants (PRIMARY_KEY|FOREIGN_KEY|CHECK)
record - SQLRecord, the record describing this constraint
Throws:
java.lang.IllegalArgumentException - if type is not in (PRIMARY_KEY|FOREIGN_KEY|CHECK)
Method Detail

getName

public java.lang.String getName()
get the name for this model's instance

This is equal to the name of the table,column, etc.

Specified by:
getName in interface SQLMetaModel
Returns:
String

getRecord

public SQLRecord getRecord()
the record which defines all the values for the model

Specified by:
getRecord in interface SQLMetaModel
Returns:
SQLRecord

getTableName

public java.lang.String getTableName()
get the table name for this Constraint

Returns:
String

getType

public java.lang.String getType()
get the type of Object defined by the meta model

returned value depends on the model: TABLE,COLUMN,INDEX

Specified by:
getType in interface SQLMetaModel
Returns:
String

getColumns

public java.util.List getColumns()
get the Columns referenced by this constraint

Returns:
List of ColumnModel, null if this is constraint is of type CHECK

setRecord

protected void setRecord(SQLRecord record)
set the record for this Model

Parameters:
record - SQLRecord

setColumns

protected void setColumns(java.util.List columns)
set the columns for this Model

Parameters:
columns - List

addColumn

protected void addColumn(ColumnModel model)
add a ColumnModel as a part of this ConstraintModel

Parameters:
model - ColumnModel

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object