KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > serversystem > dmlvalidation > triggersystem > TriggerDatabase


1 package com.daffodilwoods.daffodildb.server.serversystem.dmlvalidation.triggersystem;
2
3 import com.daffodilwoods.daffodildb.server.datadictionarysystem.*;
4 import com.daffodilwoods.daffodildb.utils.comparator.*;
5 import com.daffodilwoods.database.general.*;
6 import com.daffodilwoods.database.resource.*;
7
8 /**
9  *
10  * <p>Title: Trigger Database</p>
11  * <p>Description: </p>
12  * trigger Database maintains a list of all the trigger tables in the database.
13 * It retreives the table from the list when a call is made to get the table and
14  * removes the table from the list when the method remove table is called.
15  */

16 public class TriggerDatabase implements _TriggerDatabase {
17
18    /**
19     * instance of _DDSTriggerOperations used to create a new trigger table.
20     */

21   private _DDSTriggerOperations ddsTriggerOperations;
22
23   /**
24    * used to maintain a list of all the trigger tables in the list.
25    */

26   private WeakOrderedKeyList triggerTablePool = new WeakOrderedKeyList( new CTusjohDbtfJoTfotjujwfDpnqbsbups() );
27
28   /**
29    * Used to construct a trigger table with the given arguments.
30    * @param ddsTriggerOperations instance of _DDSTriggerOperations
31    * @throws DException
32    */

33   public TriggerDatabase( _DDSTriggerOperations ddsTriggerOperations ) throws DException {
34     this.ddsTriggerOperations = ddsTriggerOperations;
35   }
36   /**
37    * retreives the trigger table for geven tableName from the tables list.
38    * If the table is not present in the list , it creates a new instance of the table
39    * and adds it up in the list.
40    * @param tableName name of the table.
41    * @return instance of _trigger table that has been retreived by the get Table method.
42    * @throws DException
43    */

44
45   public _TriggerTable getTriggerTable(QualifiedIdentifier tableName) throws DException {
46         _TriggerTable triggerTable = (_TriggerTable)triggerTablePool.get( tableName.getIdentifier() );
47     if( triggerTable != null )
48       return triggerTable;
49     _TriggerCharacteristics triggerCharacteristics = ddsTriggerOperations.getTriggerCharacteristics( tableName, true );
50     triggerTable = new TriggerTable( triggerCharacteristics , tableName );
51     triggerTablePool.put( tableName.getIdentifier() , triggerTable );
52     return triggerTable;
53   }
54
55   /**
56    * removes the tableName from the triggerTable pool that maintains all the tables in the database.
57    * @param tableName name of table
58    * @throws DException
59    */

60
61   public void removeTable(QualifiedIdentifier tableName ) throws DException {
62         triggerTablePool.remove(tableName.getIdentifier());
63   }
64 }
65
Popular Tags