001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.catalog.IndexInfoImpl
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.sql.catalog;
023:
024: import org.apache.derby.iapi.services.sanity.SanityManager;
025:
026: import org.apache.derby.iapi.sql.dictionary.CatalogRowFactory;
027: import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
028: import org.apache.derby.iapi.sql.dictionary.IndexRowGenerator;
029:
030: import org.apache.derby.catalog.UUID;
031:
032: /**
033: * A poor mans structure used in DataDictionaryImpl.java.
034: * Used to save information about system indexes.
035: *
036: * @author jerry
037: */
038: class IndexInfoImpl {
039: private IndexRowGenerator irg;
040:
041: private long conglomerateNumber;
042:
043: private final CatalogRowFactory crf;
044: private final int indexNumber;
045:
046: /**
047: * Constructor
048: *
049: * @param indexNumber (0-based) number of index within catalog's indexes
050: * @param crf CatalogRowFactory for the catalog
051: */
052: IndexInfoImpl(int indexNumber, CatalogRowFactory crf) {
053: this .crf = crf;
054: this .indexNumber = indexNumber;
055: this .conglomerateNumber = -1;
056: }
057:
058: /**
059: * Get the conglomerate number for the index.
060: *
061: * @return long The conglomerate number for the index.
062: */
063: long getConglomerateNumber() {
064: return conglomerateNumber;
065: }
066:
067: /**
068: * Set the conglomerate number for the index.
069: *
070: * @param conglomerateNumber The conglomerateNumber for the index.
071: */
072: void setConglomerateNumber(long conglomerateNumber) {
073: this .conglomerateNumber = conglomerateNumber;
074: }
075:
076: /**
077: * Get the index name for the index.
078: *
079: * @return String The index name for the index.
080: */
081: String getIndexName() {
082: return crf.getIndexName(indexNumber);
083: }
084:
085: /**
086: * Get the column count for the index.
087: *
088: * @return int The column count for the index.
089: */
090: int getColumnCount() {
091: return crf.getIndexColumnCount(indexNumber);
092: }
093:
094: /**
095: * Get the IndexRowGenerator for this index.
096: *
097: * @return IndexRowGenerator The IRG for this index.
098: */
099: IndexRowGenerator getIndexRowGenerator() {
100: return irg;
101: }
102:
103: /**
104: * Set the IndexRowGenerator for this index.
105: *
106: * @param irg The IndexRowGenerator for this index.
107: */
108: void setIndexRowGenerator(IndexRowGenerator irg) {
109: this .irg = irg;
110: }
111:
112: /**
113: * Get the base column position for a column within a catalog
114: * given the (0-based) column number for the column within the index.
115: *
116: * @param colNumber The column number within the index
117: *
118: * @return int The base column position for the column.
119: */
120: int getBaseColumnPosition(int colNumber) {
121: return crf.getIndexColumnPositions(indexNumber)[colNumber];
122: }
123:
124: /**
125: * Return whether or not this index is declared unique
126: *
127: * @return boolean Whether or not this index is declared unique
128: */
129: boolean isIndexUnique() {
130: return crf.isIndexUnique(indexNumber);
131: }
132: }
|