KickJava   Java API By Example, From Geeks To Geeks.

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


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

15 public class SmartCollection extends AbstractSmartContainer
16                               implements Collection JavaDoc {
17     private Collection JavaDoc coll;
18
19     public SmartCollection(Collection JavaDoc c, Versionable v) {
20         super(v);
21         coll = c;
22     }
23
24     protected boolean addToContainer(Object JavaDoc o) {
25         return coll.add(o);
26     }
27
28     protected Object JavaDoc addToContainer(Object JavaDoc key, Object JavaDoc o) {
29         throw new UnsupportedOperationException JavaDoc();
30     }
31
32     protected Object JavaDoc getFromContainer(Object JavaDoc key) {
33         throw new UnsupportedOperationException JavaDoc();
34     }
35
36     protected boolean removeFromContainer(Object JavaDoc o) {
37         return coll.remove(o);
38     }
39
40     protected Object JavaDoc removeKeyFromContainer(Object JavaDoc key) {
41         throw new UnsupportedOperationException JavaDoc();
42     }
43
44     protected boolean containerContains(Object JavaDoc o) {
45         return coll.contains(o);
46     }
47
48     protected boolean containerContainsKey(Object JavaDoc key) {
49         throw new UnsupportedOperationException JavaDoc();
50     }
51
52     protected int containerSize() {
53         return coll.size();
54     }
55
56     protected Iterator JavaDoc containerIterator() {
57         return coll.iterator();
58     }
59
60     protected void containerClear() {
61         coll.clear();
62     }
63
64     protected Object JavaDoc[] toObjectArray() {
65         return coll.toArray();
66     }
67
68     public Object JavaDoc getContainer() {
69         return coll;
70     }
71
72     public boolean remove(Object JavaDoc o) {
73         return removeObject(o);
74     }
75
76     public boolean containsAll(Collection JavaDoc c) {
77         return false;
78     }
79
80     public boolean addAll(Collection JavaDoc c) {
81         return false;
82     }
83
84     public boolean removeAll(Collection JavaDoc c) {
85         return false;
86     }
87
88     public boolean retainAll(Collection JavaDoc c) {
89         return false;
90     }
91 }
92
Popular Tags