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 intA CHECK constraint.static final intA FOREIGN_KEY constraint.static final intA PRIMARY_KEY constraint.static final intA 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.voidprepareExpressions(ExpressionPreparer preparer) Prepares all expressions in this statement tree object by passing the ExpressionPreparer object to the 'prepare' method of the expression.voidsetCheck(Expression exp) Sets object up for a check constraint.voidsetForeignKey(String ref_table, ArrayList col_list, ArrayList ref_col_list, String delete_rule, String update_rule) Sets object up for foreign key reference.voidSets that this constraint is initially deferred.voidSets the name of the constraint.voidSets that this constraint is not deferrable.voidsetPrimaryKey(ArrayList list) Sets object up for a primary key constraint.voidSets 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:StatementTreeObjectPrepares all expressions in this statement tree object by passing the ExpressionPreparer object to the 'prepare' method of the expression.- Specified by:
prepareExpressionsin interfaceStatementTreeObject- Throws:
DatabaseException
-
clone
Description copied from interface:StatementTreeObjectPerforms 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:
clonein interfaceStatementTreeObject- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-