KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > dods > trans > Index


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: Index.java,v 1.1 2004/09/03 13:43:13 sinisa Exp $
22  */

23
24 /*
25  *
26  * @author Nenad Vico
27  * @since LBS1.8
28  * @version $Revision: 1.1 $
29  *
30  */

31 package org.enhydra.dods.trans;
32
33 import java.util.ArrayList JavaDoc;
34
35 /**
36  * This class represents index object.
37  */

38 public class Index {
39     
40     /**
41      * list of indexed columns
42      */

43     protected ArrayList JavaDoc indColumn = new ArrayList JavaDoc();
44
45     /**
46      * id of index
47      */

48     protected String JavaDoc id = null;
49
50     /**
51      * This variable contains information weather index is unique.
52      * True - is unique.
53      * False - is not unique.
54      */

55     protected boolean unique = false;
56
57     /**
58      * This variable contains information weather index is clustered.
59      * True - is clustered.
60      * False - is not clustered.
61      */

62     protected boolean clustered = false;
63
64     /**
65      * default constructor
66      */

67     public Index() {
68         this.id = null;
69         this.unique = false;
70     }
71
72     /**
73      * Constructor (String, boolean)
74      *
75      * @param id Index id.
76      * @param unique True if index is unique, otherwise false.
77      */

78     public Index(String JavaDoc id, boolean unique) {
79         this.id = id;
80         this.unique = unique;
81     }
82
83     /**
84      * Set index id.
85      *
86      * @param id Index id.
87      */

88     public void id(String JavaDoc id) {
89         this.id = id;
90     }
91
92     /**
93      * Set index to/not to be unique.
94      *
95      * @param unique True if index is unique, otherwise false.
96      */

97     public void isUnique(boolean unique) {
98         this.unique = unique;
99     }
100
101     /**
102      * Set index to/not to be clustered.
103      *
104      * @param clustered True if index is clustered, otherwise false.
105      */

106     public void isClustered(boolean clustered) {
107         this.clustered = clustered;
108     }
109
110     /**
111      * Add indexed column.
112      *
113      * @param id Indexed column's id.
114      */

115     public void addIndexColumn(String JavaDoc id) {
116         indColumn.add(new String JavaDoc(id));
117     }
118
119     /**
120      * Get number of indexed columns.
121      *
122      * @return Number of indexed columns.
123      */

124     public int size() {
125         return indColumn.size();
126     }
127
128     /**
129      * Get index id
130      *
131      * @return Index id.
132      */

133     public String JavaDoc id() {
134         return id;
135     }
136
137     /**
138      * Get information whether column is unique.
139      *
140      * @return True if column is unique, otherwise false.
141      */

142     public boolean isUnique() {
143         return unique;
144     }
145
146     /**
147      * Get information whether column is clustered.
148      *
149      * @return True if column is clustered, otherwise false.
150      */

151     public boolean isClustered() {
152         return clustered;
153     }
154
155     /**
156      * Get indexed columns.
157      *
158      * @return Indexed columns.
159      */

160     public ArrayList JavaDoc indexColumns() {
161         return indColumn;
162     }
163
164     /**
165      * Get indexed column with appropriate index.
166      *
167      * @param index Index of indexed column.
168      *
169      * @return Id of indexed column.
170      */

171     public String JavaDoc indexColumn(int index) {
172         return (String JavaDoc) indColumn.get(index);
173     }
174
175     /**
176      * Get String representation.
177      *
178      * @return String representation.
179      */

180     public String JavaDoc toString() {
181         StringBuffer JavaDoc ret = new StringBuffer JavaDoc("id=").append(id).append(" unique=").append(unique).append(" index columns: ");
182
183         for (int i = 0; i < indColumn.size(); i++) {
184             ret.append(indColumn.get(i)).append(" ");
185         }
186         return ret.toString();
187     }
188
189     public static void main(String JavaDoc[] args) {
190         Index ind = new Index("MeinIndexName1", true);
191
192         ind.addIndexColumn("KEYVALUE");
193         ind.addIndexColumn("ATTRTYPE");
194         System.out.println("Index: \n" + ind);
195     }
196 }
197
Popular Tags