1 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 30 public class CollectionProxy implements Collection { 31 private Collection coll; 32 private CacheGroup group; 33 37 public CollectionProxy(Collection collection, CacheGroup group) { 38 this.coll=collection; 39 this.group=group; 40 } 41 42 45 public int hashCode() { 46 return coll.hashCode(); 47 } 48 49 53 public boolean add(Object o) { 54 return coll.add(o); 55 } 56 57 60 public String toString() { 61 return coll.toString(); 62 } 63 64 67 public Object [] toArray() { 68 return coll.toArray(); 69 } 70 71 75 public boolean addAll(Collection c) { 76 return coll.addAll(c); 77 } 78 79 83 public boolean retainAll(Collection c) { 84 return coll.retainAll(c); 85 } 86 87 91 public boolean contains(Object o) { 92 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 103 public void clear() { 104 coll.clear(); 105 } 106 107 111 public boolean containsAll(Collection c) { 112 return coll.containsAll(c); 113 } 114 115 118 public int size() { 119 return coll.size(); 120 } 121 122 126 public boolean removeAll(Collection c) { 127 return coll.removeAll(c); 128 } 129 130 133 public boolean isEmpty() { 134 return coll.isEmpty(); 135 } 136 137 140 public boolean equals(Object obj) { 141 return coll.equals(obj); 142 } 143 144 148 public boolean remove(Object o) { 149 return coll.remove(o); 150 } 151 152 155 public Iterator iterator() { 156 return coll.iterator(); 157 } 158 159 163 public Object [] toArray(Object [] a) { 164 return coll.toArray(a); 165 } 166 167 } 168 | Popular Tags |