KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > ojb > model > IndexDef


1 package xdoclet.modules.ojb.model;
2
3 /* Copyright 2004-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 import java.util.ArrayList JavaDoc;
19 import java.util.Iterator JavaDoc;
20
21 /**
22  * Definition of an index descriptor for a ojb-persistent class.
23  *
24  * @author <a HREF="mailto:tomdz@users.sourceforge.net">Thomas Dudziak (tomdz@users.sourceforge.net)</a>
25  */

26 public class IndexDef extends DefBase
27 {
28     /** The columns */
29     private ArrayList JavaDoc _columns = new ArrayList JavaDoc();
30     /** Whether this index is unique */
31     private boolean _isUnique = false;
32
33     /**
34      * Creates a new index descriptor definition object.
35      *
36      * @param name The name of the index
37      * @param isUnique Whether this index is unique
38      */

39     public IndexDef(String JavaDoc name, boolean isUnique)
40     {
41         super(name == null ? "" : name);
42         _isUnique = isUnique;
43     }
44
45     /**
46      * Determines whether this index is the default index.
47      *
48      * @return <code>true</code> if it is the default index
49      */

50     public boolean isDefault()
51     {
52         return (getName() == null) || (getName().length() == 0);
53     }
54
55     /**
56      * Returns whether this index is unique.
57      *
58      * @return <code>true</code> if this index is an unique index
59      */

60     public boolean isUnique()
61     {
62         return _isUnique;
63     }
64
65     /**
66      * Adds a column to this index.
67      *
68      * @param column The column
69      */

70     public void addColumn(String JavaDoc column)
71     {
72         if (!_columns.contains(column))
73         {
74             _columns.add(column);
75         }
76     }
77
78     /**
79      * Returns an iterator of the columns of this index.
80      *
81      * @return The iterator
82      */

83     public Iterator JavaDoc getColumns()
84     {
85         return _columns.iterator();
86     }
87 }
88
Popular Tags