KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > serversystem > dmlvalidation > constraintsystem > ConstraintSystem


1 package com.daffodilwoods.daffodildb.server.serversystem.dmlvalidation.constraintsystem;
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  * <p>Title: Constraint System</p>
10  * <p>Description: </p>
11  * Constraint System maintains a list of constraint Databases along with their URL,
12  * and fetches the Database when it is required by passing its URL.
13  */

14 public class ConstraintSystem implements _ConstraintSystem {
15
16    /**
17     * returns true if the constraints are of deferred type.
18     */

19    private boolean deferrable ;
20
21    /**
22     * An instance of datadictionary system used to create a new instance of constraint database.
23     */

24    private _DataDictionarySystem dataDictionarySystem;
25
26    /**
27     * used to maintain a list of constraint databases
28     */

29    private WeakOrderedKeyList constraintDatabaseList = new WeakOrderedKeyList( new CTusjohDbtfJoTfotjujwfDpnqbsbups() );
30
31    /**
32     * constructs an object of constraint system with the given arguments.
33     * @param dDictionarySystem object of datadictionary system
34     * @param deff boolean that detemines whether the constraints are immediate or deffered type.
35     * @throws DException
36     */

37    public ConstraintSystem( _DataDictionarySystem dDictionarySystem, boolean deff ) throws DException {
38       dataDictionarySystem = dDictionarySystem;
39       deferrable = deff;
40    }
41
42    /**
43     * retreives an object of ConstraintDatabase with the given database URL
44     * If the database is not present in the list , it creates a new instance of the database
45     * and adds it up in the list.
46     * @param databaseURL name of the database.
47     * @return _ConstraintDatabase object of interface constraint database that is retreived by the method.
48     * @throws DException
49     */

50
51    public synchronized _ConstraintDatabase getConstraintDatabase(String JavaDoc databaseURL ) throws DException {
52          _ConstraintDatabase constraintDatabase = ( _ConstraintDatabase ) constraintDatabaseList.get(databaseURL);
53       if(constraintDatabase != null)
54          return constraintDatabase;
55       _DataDictionary dataDictionary = dataDictionarySystem.getDataDictionary(databaseURL);
56       constraintDatabase = new ConstraintDatabase( dataDictionary, deferrable );
57       constraintDatabaseList.put(databaseURL, constraintDatabase);
58       return constraintDatabase;
59    }
60
61    public void deleteDatabase(String JavaDoc databaseURL) throws DException{
62       constraintDatabaseList.remove(databaseURL);
63    }
64
65
66 }
67
Popular Tags