KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > datasystem > persistentsystem > DatabaseUserTable


1 package com.daffodilwoods.daffodildb.server.datasystem.persistentsystem;
2
3 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*;
4 import com.daffodilwoods.database.resource.*;
5 import com.daffodilwoods.daffodildb.server.sql99.utils._Reference;
6
7 /**
8  *
9  It has the Fixed or Varibale recordcluster to read and write data in cluster.It is the Iterator Specific
10  Class.
11  */

12 public final class DatabaseUserTable {
13
14   /**
15    * Column Bytes Table for operations IUDS.
16    */

17   private _TableList table;
18
19   /**
20    * Record cluster to distinguish operations of differnt type table e.g.
21    * FixedRecordCluster,VariableRecordCluster,PartialFixedRecordCluster,PartialVariableRecordCluster etc.
22    */

23   private _RecordCluster recordCluster;
24
25
26     DatabaseUserTable(_TableList table1,_RecordCluster recordCluster0){
27         table = table1;
28         recordCluster = recordCluster0;
29     }
30     /**
31      * Doesn't Used Now
32      * @throws DException
33      */

34     void rollBack() throws DException{
35                table.rollBack();
36     }
37
38
39     /**
40      * Called from dataBaseUserTableIterator to get ColumnBytes Table
41      * @return _TableList ColumnBytesTable
42      */

43     _TableList getTable() {
44         return table;
45     }
46
47     /**
48      * To insert values .
49      * @param _DatabaseUser _DatabaseUser - user which performs insert operation.
50      * @param values Object - values to insert.
51      * @throws DException
52      * @return Object - TableKey where record is inserted.
53      */

54     Object JavaDoc insert(_DatabaseUser _DatabaseUser,Object JavaDoc values) throws DException {
55                return table.insert(_DatabaseUser,recordCluster,values);
56     }
57     /**
58      * To Update a record with given new values.
59      * @param _DatabaseUser _DatabaseUser - user which performs update operation.
60      * @param key Object - Table key whose record is to be updated with new values.
61      * @param values Object - New values of record.
62      * @throws DException
63      * @return Object - Table key of record updated it can be same as paased or
64      * different if record can't be update at old storage space.
65      */

66     Object JavaDoc update(_DatabaseUser _DatabaseUser,Object JavaDoc key, Object JavaDoc values) throws DException {
67                return table.update(_DatabaseUser,recordCluster,key,values);
68     }
69     /**
70      * To delete a record
71      * @param _DatabaseUser _DatabaseUser - user which performs update operation.
72      * @param key Object - Table key of record to be deleted.
73      * @throws DException
74      * @return Object - tableKey of the deleted record.
75      */

76     Object JavaDoc delete(_DatabaseUser _DatabaseUser,Object JavaDoc key) throws DException {
77                return table.delete(_DatabaseUser,recordCluster,key);
78     }
79
80     /**
81      * To get a specified columns of a record whose key is passed.
82      * @param key Object - Table key of record to be fetched.
83      * @param columns int[] - columns to be geted from that record.
84      * @throws DException
85      * @return Object - Values of specified columns.
86      */

87     Object JavaDoc getColumnObjects(Object JavaDoc key,int[] columns) throws DException {
88         return table.getColumnValues((TableKey)key,recordCluster,columns);
89     }
90     /**
91      * To check validity of record taht record is active or deleted.
92      * @param key Object - TableKey of record whose validity is to be checked
93      * @throws DException
94      */

95     void checkValidity(Object JavaDoc key)throws DException{
96                table.checkValidity(recordCluster,key);
97     }
98
99      int getFreeSpace(Object JavaDoc key) throws DException{
100                ((VariableRecordCluster)recordCluster).setCluster((Cluster)((TableKey)key).cluster.get());
101                return ((VariableRecordCluster)recordCluster).freeSpace();
102     }
103
104     /**
105      * To get a specified columns of a record whose key is passed.
106      * @param key Object - Table key of record to be fetched.
107      * @param column int - column index to be geted from that record.
108      * @throws DException
109      * @return Object - Values of specified column.
110      */

111     Object JavaDoc getColumnObjects(Object JavaDoc key,int column) throws DException {
112         return table.getColumnValues((TableKey)key,recordCluster,column);
113     }
114     /**
115      * To get a record.
116      * @param key Object - TableKey of record which is to be retrived.
117      * @throws DException
118      * @return Object - Values of record.
119      */

120     Object JavaDoc getColumnObjects(Object JavaDoc key) throws DException {
121         return table.getColumnValues((TableKey)key,recordCluster);
122     }
123
124     /**
125      * To get Table characteristics.
126      * @throws DException
127      * @return _TableCharacteristics
128      */

129     _TableCharacteristics getTableCharacteristics()throws DException{
130         return table.getTableCharacteristics();
131     }
132
133 }
134
Popular Tags