Package com.mckoi.database.interpret
Class ConstraintDef
java.lang.Object
com.mckoi.database.interpret.ConstraintDef
- All Implemented Interfaces:
StatementTreeObject
,Serializable
,Cloneable
public final class ConstraintDef
extends Object
implements Serializable, StatementTreeObject, Cloneable
Represents a constraint definition (description) for a table.
- Author:
- Tobias Downer
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
A CHECK constraint.static final int
A FOREIGN_KEY constraint.static final int
A PRIMARY_KEY constraint.static final int
A UNIQUE constraint. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
Performs a DEEP clone of this object if it is mutable, or a deep clone of its mutable members.String[]
Returns the first column list as a string array.String[]
Returns the first column list as a string array.Returns the delete rule if this is a foreign key reference.Returns the update rule if this is a foreign key reference.void
prepareExpressions
(ExpressionPreparer preparer) Prepares all expressions in this statement tree object by passing the ExpressionPreparer object to the 'prepare' method of the expression.void
setCheck
(Expression exp) Sets object up for a check constraint.void
setForeignKey
(String ref_table, ArrayList col_list, ArrayList ref_col_list, String delete_rule, String update_rule) Sets object up for foreign key reference.void
Sets that this constraint is initially deferred.void
Sets the name of the constraint.void
Sets that this constraint is not deferrable.void
setPrimaryKey
(ArrayList list) Sets object up for a primary key constraint.void
Sets object up for a unique constraint.
-
Field Details
-
PRIMARY_KEY
public static final int PRIMARY_KEYA PRIMARY_KEY constraint. With this constraint, the 'column_list' list contains the names of the columns in this table that are defined as the primary key. There may only be one primary key constraint per table.- See Also:
-
UNIQUE
public static final int UNIQUEA UNIQUE constraint. With this constraint, the 'column_list' list contains the names of the columns in this table that must be unique.- See Also:
-
FOREIGN_KEY
public static final int FOREIGN_KEYA FOREIGN_KEY constraint. With this constraint, the 'table_name' string contains the name of the table that this is a foreign key for, the 'column_list' list contains the list of foreign key columns, and 'column_list2' optionally contains the referenced columns.- See Also:
-
CHECK
public static final int CHECKA CHECK constraint. With this constraint, the 'expression' object contains the expression that must evaluate to true when adding a column to the table.- See Also:
-
-
Constructor Details
-
ConstraintDef
public ConstraintDef()
-
-
Method Details
-
setName
Sets the name of the constraint. -
setPrimaryKey
Sets object up for a primary key constraint. -
setUnique
Sets object up for a unique constraint. -
setCheck
Sets object up for a check constraint. -
setForeignKey
public void setForeignKey(String ref_table, ArrayList col_list, ArrayList ref_col_list, String delete_rule, String update_rule) Sets object up for foreign key reference. -
setInitiallyDeferred
public void setInitiallyDeferred()Sets that this constraint is initially deferred. -
setNotDeferrable
public void setNotDeferrable()Sets that this constraint is not deferrable. -
getColumnList
Returns the first column list as a string array. -
getColumnList2
Returns the first column list as a string array. -
getDeleteRule
Returns the delete rule if this is a foreign key reference. -
getUpdateRule
Returns the update rule if this is a foreign key reference. -
prepareExpressions
Description copied from interface:StatementTreeObject
Prepares all expressions in this statement tree object by passing the ExpressionPreparer object to the 'prepare' method of the expression.- Specified by:
prepareExpressions
in interfaceStatementTreeObject
- Throws:
DatabaseException
-
clone
Description copied from interface:StatementTreeObject
Performs a DEEP clone of this object if it is mutable, or a deep clone of its mutable members. If the object is immutable then it may return 'this'.- Specified by:
clone
in interfaceStatementTreeObject
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-