KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > datadictionarysystem > IndexInformation


1 /**
2 import com.daffodilwoods.database.resource.DException;
3     This class stores information about particular index & provides this
4     information to indexes class.
5 */

6 package com.daffodilwoods.daffodildb.server.datadictionarysystem;
7 import com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation;
8 import com.daffodilwoods.database.resource.*;
9 import com.daffodilwoods.database.general.*;
10 import java.util.ArrayList JavaDoc;
11 import com.daffodilwoods.daffodildb.server.sql99.utils._Reference;
12
13 public class IndexInformation implements _IndexInformation{
14    public QualifiedIdentifier sourceTableName;
15    public String JavaDoc indexName;
16    public String JavaDoc indexTableName;
17    public String JavaDoc[] indexColumnName;
18    public int[] indexColumnIndexes;
19    public boolean[] orderType;
20    public long rootClusterAddress;
21    public int rootClusterSize;
22    public int rootClusterRecordNumber;
23    public int numberOfRecords;
24    public String JavaDoc indexColumns;
25    public String JavaDoc orderTypeColumn;
26    public boolean fixedVariable;
27    public boolean isUpdate;
28    public boolean is_system_generated;
29    public boolean is_default = false;
30    /**
31      * this class is for storing the information of a particular index
32     */

33
34    public IndexInformation(QualifiedIdentifier sourceTableName,String JavaDoc indexName,String JavaDoc indexTableName,
35                            String JavaDoc[] indexColumnName,int[] indexColumnIndexes,boolean[] orderType,long rootClusterAddress,int rootClusterSize,
36                            int rootClusterRecordNumber,int numberOfRecords,boolean fixedVariable,boolean isSystemGenerated)
37    {
38       this.sourceTableName = sourceTableName;
39       this.indexName = indexName;
40       this.indexTableName = indexTableName;
41       this.indexColumnName = indexColumnName;
42       this.rootClusterAddress = rootClusterAddress;
43       this.rootClusterSize = rootClusterSize;
44       this.rootClusterRecordNumber = rootClusterRecordNumber;
45       this.numberOfRecords = numberOfRecords;
46       this.fixedVariable = fixedVariable;
47       this.orderType = orderType;
48       indexColumns = "";
49       orderTypeColumn = "";
50       this.indexColumnIndexes = indexColumnIndexes;
51       is_system_generated = isSystemGenerated;
52       /*if ( indexColumnName!= null )
53         for(int i = 0 ; i < indexColumnName.length ; i++)
54            indexColumns += indexColumnName[i] + ",";
55       if(!indexColumns.equals(""))
56          indexColumns = indexColumns.substring(0,indexColumns.length()-1);
57       for(int i = 0 ; i < orderType.length ; i++)
58          orderTypeColumn += orderType[i] + ",";
59       if(!orderTypeColumn.equals(""))
60          orderTypeColumn = orderTypeColumn.substring(0,orderTypeColumn.length()-1);*/

61
62       if( indexColumnName != null ){
63          StringBuffer JavaDoc st = new StringBuffer JavaDoc(50);
64          st.append(indexColumnName[0]);
65          for(int i=1;i<indexColumnName.length;i++){
66             st.append(',');st.append(indexColumnName[i]);
67          }
68          indexColumns = st.toString();
69       }
70       if( orderType != null ){
71          StringBuffer JavaDoc st = new StringBuffer JavaDoc(50);
72          st.append(orderType[0]);
73          for (int i = 1; i < orderType.length; i++) {
74             st.append(',');st.append(orderType[i]);
75          }
76          orderTypeColumn = st.toString();
77       }
78    }
79
80   public String JavaDoc[] getColumns() throws DException {
81      return indexColumnName;
82   }
83
84   public boolean[] getOrderOfColumns() throws DException {
85      return orderType;
86   }
87
88   public int[] getColumnIndexes() throws DException {
89      return indexColumnIndexes;
90   }
91
92   public boolean isVariableColumn() throws DException {
93      return fixedVariable;
94   }
95
96
97    public QualifiedIdentifier getQualifiedIdentifier() throws DException {
98      return new QualifiedIdentifier(null,null,indexName);
99    }
100
101   public QualifiedIdentifier getIndexTableName() throws DException {
102     return new QualifiedIdentifier (sourceTableName.catalog,sourceTableName.schema,indexTableName);
103   }
104   public Object JavaDoc[][] getColumnInformation() throws DException{
105      ArrayList JavaDoc indexStructure = new ArrayList JavaDoc();
106      for(int i =0 ; i < indexColumnName.length; i++){
107       Object JavaDoc[] structure = null;
108       try {
109          structure = new Object JavaDoc[] {indexColumnName[i], new Boolean JavaDoc(orderType[i]), new Integer JavaDoc(indexColumnIndexes[i]), new Integer JavaDoc(i)};
110       } catch (ArrayIndexOutOfBoundsException JavaDoc ex) {
111          throw ex;
112       }
113         indexStructure.add(structure);
114      }
115      return (Object JavaDoc [][])indexStructure.toArray(new Object JavaDoc[0][]);
116   }
117
118   public String JavaDoc getIndexName() throws DException {
119     return indexName;
120   }
121   public int getSize() throws DException {
122      return 0;
123   }
124   public long getRootClusterAddress() throws DException {
125       return rootClusterAddress;
126   }
127   public int getRootClusterSize() throws DException {
128     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation method*/
129     throw new java.lang.UnsupportedOperationException JavaDoc("Method getRootClusterSize() not yet implemented.");
130   }
131   public short getRootClusterRecordNumber() throws DException {
132     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation method*/
133     throw new java.lang.UnsupportedOperationException JavaDoc("Method getRootClusterRecordNumber() not yet implemented.");
134   }
135   public int getNumberOfRecords() throws DException {
136     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation method*/
137     throw new java.lang.UnsupportedOperationException JavaDoc("Method getNumberOfRecords() not yet implemented.");
138   }
139   public void setControlClusterAddress(int parm1) throws DException {
140       rootClusterAddress = parm1;
141   }
142   public void setRootClusterSize(int parm1) throws DException {
143     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation method*/
144     throw new java.lang.UnsupportedOperationException JavaDoc("Method setRootClusterSize() not yet implemented.");
145   }
146   public void setRootClusterRecordNumber(int parm1) throws DException {
147     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation method*/
148     throw new java.lang.UnsupportedOperationException JavaDoc("Method setRootClusterRecordNumber() not yet implemented.");
149   }
150   public void setNumberOfRecords(int parm1) throws DException {
151     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation method*/
152     throw new java.lang.UnsupportedOperationException JavaDoc("Method setNumberOfRecords() not yet implemented.");
153   }
154     public boolean isDefault() {
155         /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation method*/
156         return is_default;
157       }
158
159     public void update() throws DException {
160     if(!isUpdate){
161       int size = indexColumnName.length;
162       int len = indexColumnName.length + 1;
163       String JavaDoc [] names = new String JavaDoc[len];
164       int [] indexes = new int[len];
165       boolean [] types = new boolean[len];
166       System.arraycopy(indexColumnName,0,names,0,size);
167       System.arraycopy(indexColumnIndexes,0,indexes,0,size);
168       System.arraycopy(orderType,0,types,0,size);
169       names[size] = SystemFields.systemFields[SystemFields.rowId];
170       indexes[size] = SystemFields.rowId;
171       types[size] = true;
172       indexColumnName = names;
173       indexColumnIndexes = indexes;
174       orderType = types;
175       isUpdate = true;
176     }
177   }
178
179     public int getControlClusterAddress() throws DException {
180         return (int)rootClusterAddress;
181     }
182
183     public boolean isSystemGenerated(){
184         return is_system_generated;
185     }
186
187     public boolean isUpdated(){
188         return isUpdate;
189     }
190
191     public void setColumnNames(String JavaDoc[] columnNames) throws DException{
192       indexColumnName = columnNames;
193     }
194   public void setColumnIndexes(int[] columnIndexes) throws DException{
195     indexColumnIndexes = columnIndexes;
196   }
197   public void setOrderOfColumns(boolean[] orderOfColumns) throws DException{
198     orderType = orderOfColumns;
199   }
200   public void setIsUpdatedFlag(boolean isUpdated0) throws DException{
201     isUpdate = isUpdated0;
202   }
203
204 public void setDefault(){
205     is_default = true;
206   }
207 }
208
Popular Tags