KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > catalog > IndexInfoImpl


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.catalog.IndexInfoImpl
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.catalog;
23
24 import org.apache.derby.iapi.services.sanity.SanityManager;
25
26 import org.apache.derby.iapi.sql.dictionary.CatalogRowFactory;
27 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
28 import org.apache.derby.iapi.sql.dictionary.IndexRowGenerator;
29
30 import org.apache.derby.catalog.UUID;
31
32 /**
33 * A poor mans structure used in DataDictionaryImpl.java.
34 * Used to save information about system indexes.
35 *
36 * @author jerry
37 */

38 class IndexInfoImpl
39 {
40     private IndexRowGenerator irg;
41
42     private long conglomerateNumber;
43     
44     private final CatalogRowFactory crf;
45     private final int indexNumber;
46
47     /**
48      * Constructor
49      *
50      * @param indexNumber (0-based) number of index within catalog's indexes
51      * @param crf CatalogRowFactory for the catalog
52      */

53     IndexInfoImpl(int indexNumber, CatalogRowFactory crf)
54     {
55         this.crf = crf;
56         this.indexNumber = indexNumber;
57         this.conglomerateNumber = -1;
58     }
59
60     /**
61      * Get the conglomerate number for the index.
62      *
63      * @return long The conglomerate number for the index.
64      */

65     long getConglomerateNumber()
66     {
67         return conglomerateNumber;
68     }
69
70     /**
71      * Set the conglomerate number for the index.
72      *
73      * @param conglomerateNumber The conglomerateNumber for the index.
74      */

75     void setConglomerateNumber(long conglomerateNumber)
76     {
77         this.conglomerateNumber = conglomerateNumber;
78     }
79
80     /**
81      * Get the index name for the index.
82      *
83      * @return String The index name for the index.
84      */

85     String JavaDoc getIndexName()
86     {
87         return crf.getIndexName(indexNumber);
88     }
89
90     /**
91      * Get the column count for the index.
92      *
93      * @return int The column count for the index.
94      */

95     int getColumnCount()
96     {
97         return crf.getIndexColumnCount(indexNumber);
98     }
99
100     /**
101      * Get the IndexRowGenerator for this index.
102      *
103      * @return IndexRowGenerator The IRG for this index.
104      */

105     IndexRowGenerator getIndexRowGenerator()
106     {
107         return irg;
108     }
109
110     /**
111      * Set the IndexRowGenerator for this index.
112      *
113      * @param irg The IndexRowGenerator for this index.
114      */

115     void setIndexRowGenerator(IndexRowGenerator irg)
116     {
117         this.irg = irg;
118     }
119
120     /**
121      * Get the base column position for a column within a catalog
122      * given the (0-based) column number for the column within the index.
123      *
124      * @param colNumber The column number within the index
125      *
126      * @return int The base column position for the column.
127      */

128     int getBaseColumnPosition(int colNumber)
129     {
130         return crf.getIndexColumnPositions(indexNumber)[colNumber];
131     }
132
133     /**
134      * Return whether or not this index is declared unique
135      *
136      * @return boolean Whether or not this index is declared unique
137      */

138     boolean isIndexUnique()
139     {
140         return crf.isIndexUnique(indexNumber);
141     }
142 }
143
Popular Tags