1 18 package org.objectweb.speedo.genclass.collection; 19 20 import org.objectweb.speedo.genclass.api.SpeedoGenClassProxy; 21 import org.objectweb.speedo.mim.api.SpeedoAccessor; 22 23 import java.util.Collection ; 24 import java.util.Iterator ; 25 import java.util.LinkedList ; 26 import java.util.List ; 27 import java.util.ListIterator ; 28 29 33 public abstract class LinkedListImpl extends LinkedList 34 implements SpeedoGenClassProxy { 35 36 public LinkedListImpl() { 37 super(); 38 accessor = (ListAccessor) createAccessor(); 39 } 40 41 ListAccessor accessor; 42 43 public SpeedoAccessor getReferenceAccessor() { 44 return accessor; 45 } 46 public void setReferenceAccessor(SpeedoAccessor refAcc) { 47 accessor = (ListAccessor) refAcc; 48 } 49 50 53 public boolean add(Object o) { 54 boolean result; 55 if (!jdoIsActive()) { 56 result = accessor.add(o); 57 } else { 58 ListAccessor ca = (ListAccessor) getSpeedoHome().writeIntention(this, null); 59 result = ca.add(o); 60 } 61 return result; 62 } 63 64 public boolean addAll(Collection c) { 65 boolean result; 66 if (!jdoIsActive()) { 67 result = accessor.addAll(c); 68 } else { 69 ListAccessor ca = (ListAccessor) getSpeedoHome().writeIntention(this, null); 70 result = ca.addAll(c); 71 } 72 return result; 73 } 74 75 public void clear() { 76 if (!jdoIsActive()) { 77 accessor.clear(); 78 } else { 79 ListAccessor ca = (ListAccessor) getSpeedoHome().writeIntention(this, null); 80 ca.clear(); 81 } 82 } 83 84 public boolean contains(Object o) { 85 if (!jdoIsActive()) { 86 return accessor.contains(o); 87 } else { 88 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 89 return ca.contains(o); 90 } 91 } 92 93 public boolean containsAll(Collection c) { 94 if (!jdoIsActive()) { 95 return accessor.containsAll(c); 96 } else { 97 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 98 return ca.containsAll(c); 99 } 100 } 101 102 public boolean equals(Object o) { 103 if (!jdoIsActive()) { 104 return accessor.equals(o); 105 } else { 106 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 107 return ca.equals(o); 108 } 109 } 110 111 public boolean isEmpty() { 112 if (!jdoIsActive()) { 113 return accessor.isEmpty(); 114 } else { 115 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 116 return ca.isEmpty(); 117 } 118 } 119 120 public Iterator iterator() { 121 if (!jdoIsActive()) { 122 return accessor.iterator(); 123 } else { 124 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 125 return ca.iterator(); 126 } 127 } 128 129 public boolean remove(Object o) { 130 boolean result; 131 if (!jdoIsActive()) { 132 result = accessor.remove(o); 133 } else { 134 ListAccessor ca = (ListAccessor) getSpeedoHome().writeIntention(this, null); 135 result = ca.remove(o); 136 } 137 return result; 138 } 139 140 public boolean removeAll(Collection c) { 141 boolean result; 142 if (!jdoIsActive()) { 143 result = accessor.removeAll(c); 144 } else { 145 ListAccessor ca = (ListAccessor) getSpeedoHome().writeIntention(this, null); 146 result = ca.removeAll(c); 147 } 148 return result; 149 } 150 151 public boolean retainAll(Collection c) { 152 throw new UnsupportedOperationException (); 153 } 154 155 public int size() { 156 if (!jdoIsActive()) { 157 return accessor.size(); 158 } else { 159 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 160 return ca.size(); 161 } 162 } 163 164 public Object [] toArray() { 165 if (!jdoIsActive()) { 166 return accessor.toArray(); 167 } else { 168 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 169 return ca.toArray(); 170 } 171 } 172 173 public Object [] toArray(Object [] a) { 174 if (!jdoIsActive()) { 175 return accessor.toArray(a); 176 } else { 177 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 178 return ca.toArray(a); 179 } 180 } 181 182 public void add(int index, Object element) { 183 if (!jdoIsActive()) { 184 accessor.add(index, element); 185 } else { 186 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 187 ca.add(index, element); 188 } 189 } 190 public boolean addAll(int index, Collection c) { 191 if (!jdoIsActive()) { 192 return accessor.addAll(index, c); 193 } else { 194 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 195 return ca.addAll(index, c); 196 } 197 } 198 public void addFirst(Object o) { 199 if (!jdoIsActive()) { 200 accessor.add(0, o); 201 } else { 202 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 203 ca.add(0, o); 204 } 205 } 206 public void addLast(Object o) { 207 if (!jdoIsActive()) { 208 accessor.add(o); 209 } else { 210 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 211 ca.add(o); 212 } 213 } 214 public Object get(int index) { 215 if (!jdoIsActive()) { 216 return accessor.get(index); 217 } else { 218 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 219 return ca.get(index); 220 } 221 } 222 public int indexOf(Object elem) { 223 if (!jdoIsActive()) { 224 return accessor.indexOf(elem); 225 } else { 226 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 227 return ca.indexOf(elem); 228 } 229 } 230 public Object remove(int index) { 231 if (!jdoIsActive()) { 232 return accessor.remove(index); 233 } else { 234 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 235 return ca.remove(index); 236 } 237 } 238 public Object set(int index, Object element) { 239 if (!jdoIsActive()) { 240 return accessor.set(index, element); 241 } else { 242 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 243 return ca.set(index, element); 244 } 245 } 246 public int lastIndexOf(Object o) { 247 if (!jdoIsActive()) { 248 return accessor.lastIndexOf(o); 249 } else { 250 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 251 return ca.lastIndexOf(o); 252 } 253 } 254 public ListIterator listIterator() { 255 if (!jdoIsActive()) { 256 return ((List ) accessor.collection).listIterator(); 257 } else { 258 ListAccessor la = (ListAccessor) getSpeedoHome().readIntention(this, null); 259 return la.listIterator(); 260 } 261 } 262 263 public ListIterator listIterator(int i) { 264 if (!jdoIsActive()) { 265 return ((List ) accessor.collection).listIterator(i); 266 } else { 267 ListAccessor la = (ListAccessor) getSpeedoHome().readIntention(this, null); 268 return la.listIterator(i); 269 } 270 } 271 272 public List subList(int i, int i1) { 273 if (!jdoIsActive()) { 274 return ((List ) accessor.collection).subList(i, i1); 275 } else { 276 ListAccessor la = (ListAccessor) getSpeedoHome().readIntention(this, null); 277 return la.subList(i, i1); 278 } 279 } 280 public Object getFirst() { 281 return get(0); 282 } 283 public Object getLast() { 284 if (!jdoIsActive()) { 285 return accessor.get(accessor.size() - 1); 286 } else { 287 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 288 return ca.get(ca.size() - 1); 289 } 290 } 291 public Object removeFirst() { 292 return remove(0); 293 } 294 public Object removeLast() { 295 if (!jdoIsActive()) { 296 return accessor.remove(accessor.size() - 1); 297 } else { 298 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 299 return ca.remove(ca.size() - 1); 300 } 301 } 302 public Object createGenClass() { 303 return new LinkedList (); 304 } 305 306 public SpeedoAccessor createAccessor() { 307 return new ListAccessor(this); 308 } 309 } 310 | Popular Tags |