Package com.mckoi.database.interpret
Class ConstraintDef
- java.lang.Object
-
- com.mckoi.database.interpret.ConstraintDef
-
- All Implemented Interfaces:
StatementTreeObject
,java.io.Serializable
,java.lang.Cloneable
public final class ConstraintDef extends java.lang.Object implements java.io.Serializable, StatementTreeObject, java.lang.Cloneable
Represents a constraint definition (description) for a table.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
CHECK
A CHECK constraint.(package private) Expression
check_expression
(package private) java.util.ArrayList
column_list
(package private) java.util.ArrayList
column_list2
(package private) short
deferred
(package private) java.lang.String
delete_rule
static int
FOREIGN_KEY
A FOREIGN_KEY constraint.(package private) java.lang.String
name
(package private) Expression
original_check_expression
static int
PRIMARY_KEY
A PRIMARY_KEY constraint.(package private) java.lang.String
reference_table_name
(package private) static long
serialVersionUID
(package private) int
type
static int
UNIQUE
A UNIQUE constraint.(package private) java.lang.String
update_rule
-
Constructor Summary
Constructors Constructor Description ConstraintDef()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Performs a DEEP clone of this object if it is mutable, or a deep clone of its mutable members.java.lang.String[]
getColumnList()
Returns the first column list as a string array.java.lang.String[]
getColumnList2()
Returns the first column list as a string array.java.lang.String
getDeleteRule()
Returns the delete rule if this is a foreign key reference.java.lang.String
getUpdateRule()
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(java.lang.String ref_table, java.util.ArrayList col_list, java.util.ArrayList ref_col_list, java.lang.String delete_rule, java.lang.String update_rule)
Sets object up for foreign key reference.void
setInitiallyDeferred()
Sets that this constraint is initially deferred.void
setName(java.lang.String name)
Sets the name of the constraint.void
setNotDeferrable()
Sets that this constraint is not deferrable.void
setPrimaryKey(java.util.ArrayList list)
Sets object up for a primary key constraint.void
setUnique(java.util.ArrayList list)
Sets object up for a unique constraint.
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
- See Also:
- Constant Field Values
-
PRIMARY_KEY
public static final int PRIMARY_KEY
A 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:
- Constant Field Values
-
UNIQUE
public static final int UNIQUE
A UNIQUE constraint. With this constraint, the 'column_list' list contains the names of the columns in this table that must be unique.- See Also:
- Constant Field Values
-
FOREIGN_KEY
public static final int FOREIGN_KEY
A 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:
- Constant Field Values
-
CHECK
public static final int CHECK
A 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:
- Constant Field Values
-
type
int type
-
name
java.lang.String name
-
check_expression
Expression check_expression
-
original_check_expression
Expression original_check_expression
-
column_list
java.util.ArrayList column_list
-
column_list2
java.util.ArrayList column_list2
-
reference_table_name
java.lang.String reference_table_name
-
update_rule
java.lang.String update_rule
-
delete_rule
java.lang.String delete_rule
-
deferred
short deferred
-
-
Method Detail
-
setName
public void setName(java.lang.String name)
Sets the name of the constraint.
-
setPrimaryKey
public void setPrimaryKey(java.util.ArrayList list)
Sets object up for a primary key constraint.
-
setUnique
public void setUnique(java.util.ArrayList list)
Sets object up for a unique constraint.
-
setCheck
public void setCheck(Expression exp)
Sets object up for a check constraint.
-
setForeignKey
public void setForeignKey(java.lang.String ref_table, java.util.ArrayList col_list, java.util.ArrayList ref_col_list, java.lang.String delete_rule, java.lang.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
public java.lang.String[] getColumnList()
Returns the first column list as a string array.
-
getColumnList2
public java.lang.String[] getColumnList2()
Returns the first column list as a string array.
-
getDeleteRule
public java.lang.String getDeleteRule()
Returns the delete rule if this is a foreign key reference.
-
getUpdateRule
public java.lang.String getUpdateRule()
Returns the update rule if this is a foreign key reference.
-
prepareExpressions
public void prepareExpressions(ExpressionPreparer preparer) throws DatabaseException
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
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
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 classjava.lang.Object
- Throws:
java.lang.CloneNotSupportedException
-
-