01: package xdoclet.modules.ojb.model;
02:
03: /* Copyright 2004-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * 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;
19: import java.util.Iterator;
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: /** The columns */
28: private ArrayList _columns = new ArrayList();
29: /** Whether this index is unique */
30: private boolean _isUnique = false;
31:
32: /**
33: * Creates a new index descriptor definition object.
34: *
35: * @param name The name of the index
36: * @param isUnique Whether this index is unique
37: */
38: public IndexDef(String name, boolean isUnique) {
39: super (name == null ? "" : name);
40: _isUnique = isUnique;
41: }
42:
43: /**
44: * Determines whether this index is the default index.
45: *
46: * @return <code>true</code> if it is the default index
47: */
48: public boolean isDefault() {
49: return (getName() == null) || (getName().length() == 0);
50: }
51:
52: /**
53: * Returns whether this index is unique.
54: *
55: * @return <code>true</code> if this index is an unique index
56: */
57: public boolean isUnique() {
58: return _isUnique;
59: }
60:
61: /**
62: * Adds a column to this index.
63: *
64: * @param column The column
65: */
66: public void addColumn(String column) {
67: if (!_columns.contains(column)) {
68: _columns.add(column);
69: }
70: }
71:
72: /**
73: * Returns an iterator of the columns of this index.
74: *
75: * @return The iterator
76: */
77: public Iterator getColumns() {
78: return _columns.iterator();
79: }
80: }
|