01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.storage.util;
11:
12: import java.util.ArrayList;
13:
14: import org.mmbase.bridge.Field;
15: import org.mmbase.module.core.MMObjectBuilder;
16:
17: /**
18: * @javadoc
19: *
20: * @since MMBase-1.8
21: * @author Pierre van Rooden
22: * @version $Id: Index.java,v 1.2 2007/02/11 19:21:12 nklasens Exp $
23: */
24: public class Index extends ArrayList<Field> {
25:
26: /**
27: * Name of the 'main' index of a builder (the 'nameless' index of all fields whose 'key' attribute is true)
28: */
29: static final public String MAIN = "main";
30:
31: private MMObjectBuilder builder;
32: private String name;
33: private boolean unique = false;
34:
35: public Index(MMObjectBuilder builder, String name) {
36: super ();
37: this .builder = builder;
38: this .name = name;
39: }
40:
41: public String getName() {
42: return name;
43: }
44:
45: public MMObjectBuilder getParent() {
46: return builder;
47: }
48:
49: public boolean isUnique() {
50: return unique;
51: }
52:
53: public void setUnique(boolean unique) {
54: this .unique = unique;
55: }
56:
57: public synchronized boolean add(Field field) {
58: if (!contains(field)) {
59: return super .add(field);
60: } else {
61: return false;
62: }
63: }
64:
65: public synchronized boolean remove(Field field) {
66: return super.remove(field);
67: }
68:
69: }
|