Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.iapi.sql.dictionary
Class ConstraintDescriptor  view ConstraintDescriptor download ConstraintDescriptor.java

java.lang.Object
  extended byorg.apache.derby.iapi.sql.dictionary.TupleDescriptor
      extended byorg.apache.derby.iapi.sql.dictionary.ConstraintDescriptor
All Implemented Interfaces:
org.apache.derby.catalog.Dependable, org.apache.derby.iapi.sql.depend.Dependent, org.apache.derby.iapi.sql.depend.Provider, UniqueTupleDescriptor
Direct Known Subclasses:
CheckConstraintDescriptor, KeyConstraintDescriptor

public abstract class ConstraintDescriptor
extends TupleDescriptor
implements UniqueTupleDescriptor, org.apache.derby.iapi.sql.depend.Provider, org.apache.derby.iapi.sql.depend.Dependent

This class is used to get information from a ConstraintDescriptor. A ConstraintDescriptor can represent a constraint on a table or on a column.

Version:
0.1

Field Summary
static int ALL
           
(package private)  ColumnDescriptorList colDL
           
(package private)  org.apache.derby.catalog.UUID constraintId
           
(package private)  java.lang.String constraintName
           
(package private)  boolean deferrable
           
static int DISABLED
           
static int ENABLED
           
(package private)  boolean initiallyDeferred
           
(package private)  boolean isEnabled
           
(package private)  int[] referencedColumns
           
(package private)  SchemaDescriptor schemaDesc
           
static int SYSCONSTRAINTS_STATE_FIELD
           
(package private)  TableDescriptor table
           
 
Fields inherited from class org.apache.derby.iapi.sql.dictionary.TupleDescriptor
COLUMN_LIST, CONGLOMERATE_LIST, CONSTRAINT_LIST, TRIGGER_LIST
 
Fields inherited from interface org.apache.derby.catalog.Dependable
ALIAS, COLUMNS_IN_TABLE, CONGLOMERATE, CONSTRAINT, DEFAULT, FILE, HEAP, INDEX, PREPARED_STATEMENT, SCHEMA, STORED_PREPARED_STATEMENT, TABLE, TRIGGER, VIEW
 
Constructor Summary
(package private) ConstraintDescriptor(DataDictionary dataDictionary, TableDescriptor table, java.lang.String constraintName, boolean deferrable, boolean initiallyDeferred, int[] referencedColumns, org.apache.derby.catalog.UUID constraintId, SchemaDescriptor schemaDesc, boolean isEnabled)
          Constructor for a ConstraintDescriptor
 
Method Summary
 boolean areColumnsComparable(ColumnDescriptorList otherColumns)
          Indicates whether the column descriptor list is type comparable with the constraints columns.
 boolean columnIntersects(int[] columnArray)
          Does a column intersect with our referenced columns
 boolean deferrable()
          Returns TRUE if the constraint is deferrable (we will probably not do deferrable constraints in the initial release, but I want this to be part of the interface).
(package private) static boolean doColumnsIntersect(int[] otherColumns, int[] referencedColumns)
          Does a column in the input set intersect with our referenced columns?
 java.lang.String getClassType()
          Get the provider's type.
 ColumnDescriptorList getColumnDescriptors()
          Get the column descriptors for all the columns referenced by this constraint.
abstract  org.apache.derby.catalog.UUID getConglomerateId()
           
 java.lang.String getConstraintName()
          Gets the name of the constraint.
 java.lang.String getConstraintText()
          Get the text of the constraint.
abstract  int getConstraintType()
          Gets an identifier telling what type of descriptor it is (UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK).
 org.apache.derby.catalog.DependableFinder getDependableFinder()
          Get an object which can be written to disk and which, when read from disk, will find or reconstruct this in-memory Dependable.
 java.lang.String getDescriptorName()
           
 java.lang.String getDescriptorType()
          Each descriptor must identify itself with its type; i.e index, check constraint whatever.
 int[] getKeyColumns()
          RESOLVE: For now the ConstraintDescriptor code stores the array of key columns in the field 'otherColumns'.
 org.apache.derby.catalog.UUID getObjectID()
          Get the provider's UUID
 java.lang.String getObjectName()
          Return the name of this Provider.
 int getReferenceCount()
          Get the number of enabled fks that reference this key.
 int[] getReferencedColumns()
          Returns an array of column ids (i.e.
 SchemaDescriptor getSchemaDescriptor()
          Get the SchemaDescriptor for the schema that this constraint belongs to.
 TableDescriptor getTableDescriptor()
          Get the table descriptor upon which this constraint is declared.
 org.apache.derby.catalog.UUID getTableId()
          Gets the UUID of the table the constraint is on.
 org.apache.derby.catalog.UUID getUUID()
          Gets the UUID of the constraint.
abstract  boolean hasBackingIndex()
          Does this constraint have a backing index?
 boolean initiallyDeferred()
          Returns TRUE if the constraint is initially deferred (we will probably not do initially deferred constraints in the initial release, but I want this to be part of the interface).
 boolean isEnabled()
          Is this constraint active?
 boolean isReferenced()
          Is this constraint referenced? Return false.
 boolean isValid()
          Check that all of the dependent's dependencies are valid.
 void makeInvalid(int action, org.apache.derby.iapi.sql.conn.LanguageConnectionContext lcc)
          Mark the dependent as invalid (due to at least one of its dependencies being invalid).
 void makeValid(org.apache.derby.iapi.sql.conn.LanguageConnectionContext lcc)
          Attempt to revalidate the dependent.
abstract  boolean needsToFire(int stmtType, int[] modifiedCols)
          Does this constraint need to fire on this type of DML?
 void prepareToInvalidate(org.apache.derby.iapi.sql.depend.Provider p, int action, org.apache.derby.iapi.sql.conn.LanguageConnectionContext lcc)
          Prepare to mark the dependent as invalid (due to at least one of its dependencies being invalid).
 void setConstraintId(org.apache.derby.catalog.UUID constraintId)
          Sets the UUID of the constraint.
 void setDisabled()
          Set the constraint to disabled.
 void setEnabled()
          Set the constraint to enabled.
 java.lang.String toString()
          Convert the ColumnDescriptor to a String.
 
Methods inherited from class org.apache.derby.iapi.sql.dictionary.TupleDescriptor
getColumnDependableFinder, getDataDictionary, getDependableFinder, isPersistent, setDataDictionary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.derby.catalog.Dependable
isPersistent
 

Field Detail

ENABLED

public static final int ENABLED
See Also:
Constant Field Values

DISABLED

public static final int DISABLED
See Also:
Constant Field Values

ALL

public static final int ALL
See Also:
Constant Field Values

SYSCONSTRAINTS_STATE_FIELD

public static final int SYSCONSTRAINTS_STATE_FIELD
See Also:
Constant Field Values

table

TableDescriptor table

constraintName

java.lang.String constraintName

deferrable

boolean deferrable

initiallyDeferred

boolean initiallyDeferred

isEnabled

boolean isEnabled

referencedColumns

int[] referencedColumns

constraintId

org.apache.derby.catalog.UUID constraintId

schemaDesc

SchemaDescriptor schemaDesc

colDL

ColumnDescriptorList colDL
Constructor Detail

ConstraintDescriptor

ConstraintDescriptor(DataDictionary dataDictionary,
                     TableDescriptor table,
                     java.lang.String constraintName,
                     boolean deferrable,
                     boolean initiallyDeferred,
                     int[] referencedColumns,
                     org.apache.derby.catalog.UUID constraintId,
                     SchemaDescriptor schemaDesc,
                     boolean isEnabled)
Constructor for a ConstraintDescriptor

Method Detail

getTableId

public org.apache.derby.catalog.UUID getTableId()
Gets the UUID of the table the constraint is on.


setConstraintId

public void setConstraintId(org.apache.derby.catalog.UUID constraintId)
Sets the UUID of the constraint.


getUUID

public org.apache.derby.catalog.UUID getUUID()
Gets the UUID of the constraint.

Specified by:
getUUID in interface UniqueTupleDescriptor

getConstraintName

public java.lang.String getConstraintName()
Gets the name of the constraint.


getConstraintType

public abstract int getConstraintType()
Gets an identifier telling what type of descriptor it is (UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK).


getConglomerateId

public abstract org.apache.derby.catalog.UUID getConglomerateId()

getConstraintText

public java.lang.String getConstraintText()
Get the text of the constraint. (Only non-null/meaningful for check constraints.)


deferrable

public boolean deferrable()
Returns TRUE if the constraint is deferrable (we will probably not do deferrable constraints in the initial release, but I want this to be part of the interface).


initiallyDeferred

public boolean initiallyDeferred()
Returns TRUE if the constraint is initially deferred (we will probably not do initially deferred constraints in the initial release, but I want this to be part of the interface).


getReferencedColumns

public int[] getReferencedColumns()
Returns an array of column ids (i.e. ordinal positions) for the columns referenced in this table for a primary key, unique key, referential, or check constraint.


hasBackingIndex

public abstract boolean hasBackingIndex()
Does this constraint have a backing index?


getSchemaDescriptor

public SchemaDescriptor getSchemaDescriptor()
Get the SchemaDescriptor for the schema that this constraint belongs to.


getKeyColumns

public int[] getKeyColumns()
RESOLVE: For now the ConstraintDescriptor code stores the array of key columns in the field 'otherColumns'. Jerry plans to re-organize things. For now to minimize his rototill I've implemented this function on the old structures. All new code should use getKeyColumns to get a constraint's key columns.


isEnabled

public boolean isEnabled()
Is this constraint active?


setEnabled

public void setEnabled()
Set the constraint to enabled. Does not update the data dictionary


setDisabled

public void setDisabled()
Set the constraint to disabled. Does not update the data dictionary


isReferenced

public boolean isReferenced()
Is this constraint referenced? Return false. Overridden by ReferencedKeyConstraints.


getReferenceCount

public int getReferenceCount()
Get the number of enabled fks that reference this key. Overriden by ReferencedKeyConstraints.


needsToFire

public abstract boolean needsToFire(int stmtType,
                                    int[] modifiedCols)
Does this constraint need to fire on this type of DML?


getTableDescriptor

public TableDescriptor getTableDescriptor()
Get the table descriptor upon which this constraint is declared.


getColumnDescriptors

public ColumnDescriptorList getColumnDescriptors()
                                          throws org.apache.derby.iapi.error.StandardException
Get the column descriptors for all the columns referenced by this constraint.


areColumnsComparable

public boolean areColumnsComparable(ColumnDescriptorList otherColumns)
                             throws org.apache.derby.iapi.error.StandardException
Indicates whether the column descriptor list is type comparable with the constraints columns. The types have to be identical AND in the same order to succeed.


columnIntersects

public boolean columnIntersects(int[] columnArray)
Does a column intersect with our referenced columns


doColumnsIntersect

static boolean doColumnsIntersect(int[] otherColumns,
                                  int[] referencedColumns)
Does a column in the input set intersect with our referenced columns?


toString

public java.lang.String toString()
Convert the ColumnDescriptor to a String.


getDependableFinder

public org.apache.derby.catalog.DependableFinder getDependableFinder()
Description copied from interface: org.apache.derby.catalog.Dependable
Get an object which can be written to disk and which, when read from disk, will find or reconstruct this in-memory Dependable.

Specified by:
getDependableFinder in interface org.apache.derby.catalog.Dependable

getObjectName

public java.lang.String getObjectName()
Return the name of this Provider. (Useful for errors.)

Specified by:
getObjectName in interface org.apache.derby.catalog.Dependable

getObjectID

public org.apache.derby.catalog.UUID getObjectID()
Get the provider's UUID

Specified by:
getObjectID in interface org.apache.derby.catalog.Dependable

getClassType

public java.lang.String getClassType()
Get the provider's type.

Specified by:
getClassType in interface org.apache.derby.catalog.Dependable

isValid

public boolean isValid()
Check that all of the dependent's dependencies are valid.

Specified by:
isValid in interface org.apache.derby.iapi.sql.depend.Dependent

prepareToInvalidate

public void prepareToInvalidate(org.apache.derby.iapi.sql.depend.Provider p,
                                int action,
                                org.apache.derby.iapi.sql.conn.LanguageConnectionContext lcc)
                         throws org.apache.derby.iapi.error.StandardException
Prepare to mark the dependent as invalid (due to at least one of its dependencies being invalid).

Specified by:
prepareToInvalidate in interface org.apache.derby.iapi.sql.depend.Dependent

makeInvalid

public void makeInvalid(int action,
                        org.apache.derby.iapi.sql.conn.LanguageConnectionContext lcc)
                 throws org.apache.derby.iapi.error.StandardException
Mark the dependent as invalid (due to at least one of its dependencies being invalid). Always an error for a constraint -- should never have gotten here.

Specified by:
makeInvalid in interface org.apache.derby.iapi.sql.depend.Dependent

makeValid

public void makeValid(org.apache.derby.iapi.sql.conn.LanguageConnectionContext lcc)
Attempt to revalidate the dependent. Meaningless for constraints.

Specified by:
makeValid in interface org.apache.derby.iapi.sql.depend.Dependent

getDescriptorName

public java.lang.String getDescriptorName()
Overrides:
getDescriptorName in class TupleDescriptor

getDescriptorType

public java.lang.String getDescriptorType()
Description copied from class: TupleDescriptor
Each descriptor must identify itself with its type; i.e index, check constraint whatever.

Overrides:
getDescriptorType in class TupleDescriptor