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 TriggerDescriptor  view TriggerDescriptor download TriggerDescriptor.java

java.lang.Object
  extended byorg.apache.derby.iapi.sql.dictionary.TupleDescriptor
      extended byorg.apache.derby.iapi.sql.dictionary.TriggerDescriptor
All Implemented Interfaces:
org.apache.derby.catalog.Dependable, org.apache.derby.iapi.sql.depend.Dependent, java.io.Externalizable, org.apache.derby.iapi.services.io.Formatable, org.apache.derby.iapi.sql.depend.Provider, java.io.Serializable, org.apache.derby.iapi.services.io.TypedFormat, UniqueSQLObjectDescriptor, UniqueTupleDescriptor

public class TriggerDescriptor
extends TupleDescriptor
implements UniqueSQLObjectDescriptor, org.apache.derby.iapi.sql.depend.Provider, org.apache.derby.iapi.sql.depend.Dependent, org.apache.derby.iapi.services.io.Formatable

A trigger.

We are dependent on TableDescriptors, SPSDescriptors (for our WHEN clause and our action). Note that we don't strictly need to be dependent on out SPSes because we could just disallow anyone from dropping an sps of type 'T', but to keep dependencies uniform, we'll do be dependent.

We are a provider for DML (PreparedStatements or SPSes) The public methods for this class are:

  1. getUUID
  2. getName
  3. getSchemaDescriptor
  4. public boolean listensForEvent(int event);
  5. public int getTriggerEventMask();
  6. public Timestamp getCreationTimestamp();
  7. public boolean isBeforeTrigger();
  8. public boolean isRowTrigger();
  9. public UUID getActionId();
  10. public SPSDescriptor getActionSPS();
  11. public UUID getWhenClauseId();
  12. public SPSDescriptor getWhenClauseSPS()
  13. public TableDescriptor getTableDescriptor()
  14. public ReferencedColumns getReferencedColumnsDescriptor()
  15. public int[] getReferencedCols();
  16. public boolean isEnabled();
  17. public void setEnabled();
  18. public void setDisabled();
  19. public boolean needsToFire(int stmtType, int[] modifiedCols)
  20. public String getTriggerDefinition();
  21. public boolean getReferencingOld();
  22. public boolean getReferencingNew();
  23. public String getOldReferencingName();
  24. public String getNewReferencingName();


Field Summary
private  SPSDescriptor actionSPS
           
private  org.apache.derby.catalog.UUID actionSPSId
           
private  java.sql.Timestamp creationTimestamp
           
private  int eventMask
           
private  org.apache.derby.catalog.UUID id
           
private  boolean isBefore
           
private  boolean isEnabled
           
private  boolean isRow
           
private  java.lang.String name
           
private  java.lang.String newReferencingName
           
private  java.lang.String oldReferencingName
           
private  int[] referencedCols
           
private  boolean referencingNew
           
private  boolean referencingOld
           
private  SchemaDescriptor sd
           
static int SYSTRIGGERS_STATE_FIELD
           
private  TableDescriptor td
           
static int TRIGGER_EVENT_DELETE
           
static int TRIGGER_EVENT_INSERT
           
static int TRIGGER_EVENT_UPDATE
           
private  java.lang.String triggerDefinition
           
private  org.apache.derby.catalog.UUID triggerSchemaId
           
private  org.apache.derby.catalog.UUID triggerTableId
           
private  SPSDescriptor whenSPS
           
private  org.apache.derby.catalog.UUID whenSPSId
           
 
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
TriggerDescriptor()
          Niladic constructor, for formatable
TriggerDescriptor(DataDictionary dataDictionary, SchemaDescriptor sd, org.apache.derby.catalog.UUID id, java.lang.String name, int eventMask, boolean isBefore, boolean isRow, boolean isEnabled, TableDescriptor td, org.apache.derby.catalog.UUID whenSPSId, org.apache.derby.catalog.UUID actionSPSId, java.sql.Timestamp creationTimestamp, int[] referencedCols, java.lang.String triggerDefinition, boolean referencingOld, boolean referencingNew, java.lang.String oldReferencingName, java.lang.String newReferencingName)
          Constructor.
 
Method Summary
 org.apache.derby.catalog.UUID getActionId()
          Get the trigger action sps UUID
 SPSDescriptor getActionSPS(org.apache.derby.iapi.sql.conn.LanguageConnectionContext lcc)
          Get the trigger action sps
 java.lang.String getClassType()
          Get the provider's type.
 java.sql.Timestamp getCreationTimestamp()
          Get the time that this trigger was created.
protected  DataDictionary getDataDictionary()
           
 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.
 java.lang.String getName()
          Get the trigger name
 java.lang.String getNewReferencingName()
          Get the new Referencing name, if any, from the REFERENCING clause.
 org.apache.derby.catalog.UUID getObjectID()
          Get the provider's UUID
 java.lang.String getObjectName()
          Return the name of this Provider.
 java.lang.String getOldReferencingName()
          Get the old Referencing name, if any, from the REFERENCING clause.
 int[] getReferencedCols()
          Get the referenced column array for this trigger, used in "alter table drop column", we get the handle and change it
 boolean getReferencingNew()
          Get whether or not NEW was replaced in the REFERENCING clause.
 boolean getReferencingOld()
          Get whether or not OLD was replaced in the REFERENCING clause.
 SchemaDescriptor getSchemaDescriptor()
          Get the triggers schema descriptor
 TableDescriptor getTableDescriptor()
          Get the trigger table descriptor
 org.apache.derby.catalog.UUID getTableId()
           
 java.lang.String getTriggerDefinition()
          Get the original trigger definition.
 int getTriggerEventMask()
          Get the trigger event mask.
 int getTypeFormatId()
          Get the formatID which corresponds to this class.
 org.apache.derby.catalog.UUID getUUID()
          Get the trigger UUID
 org.apache.derby.catalog.UUID getWhenClauseId()
          Get the trigger when clause sps UUID
 SPSDescriptor getWhenClauseSPS()
          Get the trigger when clause sps
 boolean isBeforeTrigger()
          Is this a before trigger
 boolean isEnabled()
          Is this trigger enabled
 boolean isRowTrigger()
          Is this a row trigger
 boolean isValid()
          Check that all of the dependent's dependencies are valid.
 boolean listensForEvent(int event)
          Indicate whether this trigger listens for this type of event.
 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.
 boolean needsToFire(int stmtType, int[] modifiedCols)
          Does this trigger 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 readExternal(java.io.ObjectInput in)
          Read this object from a stream of stored objects.
 void setDisabled()
          Mark this trigger as disabled
 void setEnabled()
          Mark this trigger as enabled
 java.lang.String toString()
          Convert this Object to a human-readable String.
 void writeExternal(java.io.ObjectOutput out)
          Write this object to a stream of stored objects.
 
Methods inherited from class org.apache.derby.iapi.sql.dictionary.TupleDescriptor
getColumnDependableFinder, 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

SYSTRIGGERS_STATE_FIELD

public static final int SYSTRIGGERS_STATE_FIELD
See Also:
Constant Field Values

TRIGGER_EVENT_UPDATE

public static final int TRIGGER_EVENT_UPDATE
See Also:
Constant Field Values

TRIGGER_EVENT_DELETE

public static final int TRIGGER_EVENT_DELETE
See Also:
Constant Field Values

TRIGGER_EVENT_INSERT

public static final int TRIGGER_EVENT_INSERT
See Also:
Constant Field Values

id

private org.apache.derby.catalog.UUID id

name

private java.lang.String name

oldReferencingName

private java.lang.String oldReferencingName

newReferencingName

private java.lang.String newReferencingName

triggerDefinition

private java.lang.String triggerDefinition

sd

private SchemaDescriptor sd

eventMask

private int eventMask

isBefore

private boolean isBefore

isRow

private boolean isRow

referencingOld

private boolean referencingOld

referencingNew

private boolean referencingNew

td

private TableDescriptor td

actionSPSId

private org.apache.derby.catalog.UUID actionSPSId

actionSPS

private SPSDescriptor actionSPS

whenSPSId

private org.apache.derby.catalog.UUID whenSPSId

whenSPS

private SPSDescriptor whenSPS

isEnabled

private boolean isEnabled

referencedCols

private int[] referencedCols

creationTimestamp

private java.sql.Timestamp creationTimestamp

triggerSchemaId

private org.apache.derby.catalog.UUID triggerSchemaId

triggerTableId

private org.apache.derby.catalog.UUID triggerTableId
Constructor Detail

TriggerDescriptor

public TriggerDescriptor()
Niladic constructor, for formatable


TriggerDescriptor

public TriggerDescriptor(DataDictionary dataDictionary,
                         SchemaDescriptor sd,
                         org.apache.derby.catalog.UUID id,
                         java.lang.String name,
                         int eventMask,
                         boolean isBefore,
                         boolean isRow,
                         boolean isEnabled,
                         TableDescriptor td,
                         org.apache.derby.catalog.UUID whenSPSId,
                         org.apache.derby.catalog.UUID actionSPSId,
                         java.sql.Timestamp creationTimestamp,
                         int[] referencedCols,
                         java.lang.String triggerDefinition,
                         boolean referencingOld,
                         boolean referencingNew,
                         java.lang.String oldReferencingName,
                         java.lang.String newReferencingName)
Constructor. Used when creating a trigger from SYS.SYSTRIGGERS

Method Detail

getUUID

public org.apache.derby.catalog.UUID getUUID()
Get the trigger UUID

Specified by:
getUUID in interface UniqueTupleDescriptor

getName

public java.lang.String getName()
Get the trigger name

Specified by:
getName in interface UniqueSQLObjectDescriptor

getTableId

public org.apache.derby.catalog.UUID getTableId()

getSchemaDescriptor

public SchemaDescriptor getSchemaDescriptor()
                                     throws org.apache.derby.iapi.error.StandardException
Get the triggers schema descriptor

Specified by:
getSchemaDescriptor in interface UniqueSQLObjectDescriptor

listensForEvent

public boolean listensForEvent(int event)
Indicate whether this trigger listens for this type of event.


getTriggerEventMask

public int getTriggerEventMask()
Get the trigger event mask. Currently, a trigger may only listen for a single event, though it may OR multiple events in the future.


getCreationTimestamp

public java.sql.Timestamp getCreationTimestamp()
Get the time that this trigger was created.


isBeforeTrigger

public boolean isBeforeTrigger()
Is this a before trigger


isRowTrigger

public boolean isRowTrigger()
Is this a row trigger


getActionId

public org.apache.derby.catalog.UUID getActionId()
Get the trigger action sps UUID


getActionSPS

public SPSDescriptor getActionSPS(org.apache.derby.iapi.sql.conn.LanguageConnectionContext lcc)
                           throws org.apache.derby.iapi.error.StandardException
Get the trigger action sps


getWhenClauseId

public org.apache.derby.catalog.UUID getWhenClauseId()
Get the trigger when clause sps UUID


getWhenClauseSPS

public SPSDescriptor getWhenClauseSPS()
                               throws org.apache.derby.iapi.error.StandardException
Get the trigger when clause sps


getTableDescriptor

public TableDescriptor getTableDescriptor()
                                   throws org.apache.derby.iapi.error.StandardException
Get the trigger table descriptor


getReferencedCols

public int[] getReferencedCols()
Get the referenced column array for this trigger, used in "alter table drop column", we get the handle and change it


isEnabled

public boolean isEnabled()
Is this trigger enabled


setEnabled

public void setEnabled()
Mark this trigger as enabled


setDisabled

public void setDisabled()
Mark this trigger as disabled


needsToFire

public boolean needsToFire(int stmtType,
                           int[] modifiedCols)
                    throws org.apache.derby.iapi.error.StandardException
Does this trigger need to fire on this type of DML?


getTriggerDefinition

public java.lang.String getTriggerDefinition()
Get the original trigger definition.


getReferencingOld

public boolean getReferencingOld()
Get whether or not OLD was replaced in the REFERENCING clause.


getReferencingNew

public boolean getReferencingNew()
Get whether or not NEW was replaced in the REFERENCING clause.


getOldReferencingName

public java.lang.String getOldReferencingName()
Get the old Referencing name, if any, from the REFERENCING clause.


getNewReferencingName

public java.lang.String getNewReferencingName()
Get the new Referencing name, if any, from the REFERENCING clause.


toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


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 trigger -- 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 a trigger.

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

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Read this object from a stream of stored objects.

Specified by:
readExternal in interface java.io.Externalizable

getDataDictionary

protected DataDictionary getDataDictionary()
                                    throws org.apache.derby.iapi.error.StandardException
Overrides:
getDataDictionary in class TupleDescriptor

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Write this object to a stream of stored objects.

Specified by:
writeExternal in interface java.io.Externalizable

getTypeFormatId

public int getTypeFormatId()
Get the formatID which corresponds to this class.

Specified by:
getTypeFormatId in interface org.apache.derby.iapi.services.io.TypedFormat

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

getDescriptorName

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