KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > storage > util > Index


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.storage.util;
11
12 import java.util.ArrayList JavaDoc;
13
14 import org.mmbase.module.core.MMObjectBuilder;
15
16 /**
17  * @javadoc
18  *
19  * @since MMBase-1.8
20  * @author Pierre van Rooden
21  * @version $Id: Index.java,v 1.1 2005/08/22 08:14:02 pierre Exp $
22  */

23 public class Index extends ArrayList JavaDoc {
24
25     /**
26      * Name of the 'main' index of a builder (the 'nameless' index of all fields whose 'key' attribute is true)
27      */

28     static final public String JavaDoc MAIN = "main";
29
30     private MMObjectBuilder builder;
31     private String JavaDoc name;
32     private boolean unique = false;
33
34     public Index(MMObjectBuilder builder, String JavaDoc name) {
35         super();
36         this.builder = builder;
37         this.name = name;
38     }
39
40     public String JavaDoc getName() {
41         return name;
42     }
43
44     public MMObjectBuilder getParent() {
45         return builder;
46     }
47
48     public boolean isUnique() {
49         return unique;
50     }
51
52     public void setUnique(boolean unique) {
53         this.unique = unique;
54     }
55
56     public synchronized boolean add(Object JavaDoc field) {
57         if (!contains(field)) {
58             return super.add(field);
59         } else {
60             return false;
61         }
62     }
63
64     public synchronized boolean remove(Object JavaDoc field) {
65         return super.remove(field);
66     }
67
68 }
69
Popular Tags