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 Details

    • 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:
    • 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:
    • 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:
    • 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:
  • Constructor Details

    • ConstraintDef

      public ConstraintDef()
  • Method Details

    • setName

      public void setName(String name)
      Sets the name of the constraint.
    • setPrimaryKey

      public void setPrimaryKey(ArrayList list)
      Sets object up for a primary key constraint.
    • setUnique

      public void setUnique(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(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

      public String[] getColumnList()
      Returns the first column list as a string array.
    • getColumnList2

      public String[] getColumnList2()
      Returns the first column list as a string array.
    • getDeleteRule

      public String getDeleteRule()
      Returns the delete rule if this is a foreign key reference.
    • getUpdateRule

      public 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 interface StatementTreeObject
      Throws:
      DatabaseException
    • clone

      public Object clone() throws 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 interface StatementTreeObject
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException