1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.fjank.jcache.collection;
20
21 import java.util.Collection;
22 import java.util.Iterator;
23 import org.fjank.jcache.CacheGroup;
24 import org.fjank.jcache.CacheObject;
25
26
27
28
29
30 public class CollectionProxy implements Collection {
31 private Collection coll;
32 private CacheGroup group;
33
34
35
36
37 public CollectionProxy(Collection collection, CacheGroup group) {
38 this.coll=collection;
39 this.group=group;
40 }
41
42
43
44
45 public int hashCode() {
46 return coll.hashCode();
47 }
48
49
50
51
52
53 public boolean add(Object o) {
54 return coll.add(o);
55 }
56
57
58
59
60 public String toString() {
61 return coll.toString();
62 }
63
64
65
66
67 public Object[] toArray() {
68 return coll.toArray();
69 }
70
71
72
73
74
75 public boolean addAll(Collection c) {
76 return coll.addAll(c);
77 }
78
79
80
81
82
83 public boolean retainAll(Collection c) {
84 return coll.retainAll(c);
85 }
86
87
88
89
90
91 public boolean contains(Object o) {
92
93 for (Iterator iter = coll.iterator(); iter.hasNext();) {
94 CacheObject obj = (CacheObject) iter.next();
95 if(obj.get()==o) return true;
96 }
97 return false;
98 }
99
100
101
102
103 public void clear() {
104 coll.clear();
105 }
106
107
108
109
110
111 public boolean containsAll(Collection c) {
112 return coll.containsAll(c);
113 }
114
115
116
117
118 public int size() {
119 return coll.size();
120 }
121
122
123
124
125
126 public boolean removeAll(Collection c) {
127 return coll.removeAll(c);
128 }
129
130
131
132
133 public boolean isEmpty() {
134 return coll.isEmpty();
135 }
136
137
138
139
140 public boolean equals(Object obj) {
141 return coll.equals(obj);
142 }
143
144
145
146
147
148 public boolean remove(Object o) {
149 return coll.remove(o);
150 }
151
152
153
154
155 public Iterator iterator() {
156 return coll.iterator();
157 }
158
159
160
161
162
163 public Object[] toArray(Object[] a) {
164 return coll.toArray(a);
165 }
166
167 }