KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > bsf > smartValueObject > container > SmartSet


1 package org.bsf.smartValueObject.container;
2
3 import org.bsf.smartValueObject.container.AbstractSmartContainer;
4 import org.bsf.smartValueObject.Versionable;
5
6 import java.util.Set JavaDoc;
7 import java.util.Iterator JavaDoc;
8 import java.util.Collection JavaDoc;
9
10 /**
11  * A smart wrapper class around <tt>java.util.Set</tt>.
12  *
13  * @see org.bsf.smartValueObject.container.SmartContainer
14  * @see java.util.Set
15  */

16 public class SmartSet extends AbstractSmartContainer implements Set JavaDoc {
17     /** The underlying set. */
18     private Set JavaDoc set;
19
20     /**
21      * Inititalize SmartCollection
22      * @param s set to be wrapped.
23      * @param v version object
24      */

25     public SmartSet(Set JavaDoc s, Versionable v) {
26         super(v);
27         this.set = s;
28     }
29
30     protected boolean addToContainer(Object JavaDoc o) {
31         return set.add(o);
32     }
33
34     protected Object JavaDoc addToContainer(Object JavaDoc key, Object JavaDoc o) {
35         throw new UnsupportedOperationException JavaDoc();
36     }
37
38     protected Object JavaDoc getFromContainer(Object JavaDoc key) {
39         throw new UnsupportedOperationException JavaDoc();
40     }
41
42     protected boolean removeFromContainer(Object JavaDoc o) {
43         return set.remove(o);
44     }
45
46     protected Object JavaDoc removeKeyFromContainer(Object JavaDoc key) {
47         throw new UnsupportedOperationException JavaDoc();
48     }
49
50     protected boolean containerContains(Object JavaDoc o) {
51         return set.contains(o);
52     }
53
54     protected boolean containerContainsKey(Object JavaDoc key) {
55         throw new UnsupportedOperationException JavaDoc();
56     }
57
58     protected int containerSize() {
59         return set.size();
60     }
61
62     protected Iterator JavaDoc containerIterator() {
63         return set.iterator();
64     }
65
66     protected void containerClear() {
67         set.clear();
68     }
69
70     protected Object JavaDoc[] toObjectArray() {
71         return set.toArray();
72     }
73
74     public boolean remove(Object JavaDoc o) {
75         return removeObject(o);
76     }
77
78     public boolean containsAll(Collection JavaDoc c) {
79         return false;
80     }
81
82     public boolean addAll(Collection JavaDoc c) {
83         return false;
84     }
85
86     public boolean retainAll(Collection JavaDoc c) {
87         return false;
88     }
89
90     public boolean removeAll(Collection JavaDoc c) {
91         return false;
92     }
93
94     public Iterator JavaDoc getIterator() {
95         return this.set.iterator();
96     }
97
98     public Object JavaDoc getContainer() {
99         return set;
100     }
101
102     public String JavaDoc toString() {
103         return "SmartSet [" + set.toString() + "]";
104     }
105 }
106
Popular Tags