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.ArrayList ; 26 import java.util.List ; 27 import java.util.ListIterator ; 28 29 33 public abstract class ArrayListImpl extends ArrayList 34 implements SpeedoGenClassProxy { 35 36 public ArrayListImpl() { 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 Object get(int index) { 199 if (!jdoIsActive()) { 200 return accessor.get(index); 201 } else { 202 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 203 return ca.get(index); 204 } 205 } 206 public int indexOf(Object elem) { 207 if (!jdoIsActive()) { 208 return accessor.indexOf(elem); 209 } else { 210 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 211 return ca.indexOf(elem); 212 } 213 } 214 public Object remove(int index) { 215 if (!jdoIsActive()) { 216 return accessor.remove(index); 217 } else { 218 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 219 return ca.remove(index); 220 } 221 } 222 public Object set(int index, Object element) { 223 if (!jdoIsActive()) { 224 return accessor.set(index, element); 225 } else { 226 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 227 return ca.set(index, element); 228 } 229 } 230 public int lastIndexOf(Object o) { 231 if (!jdoIsActive()) { 232 return accessor.lastIndexOf(o); 233 } else { 234 ListAccessor ca = (ListAccessor) getSpeedoHome().readIntention(this, null); 235 return ca.lastIndexOf(o); 236 } 237 } 238 public ListIterator listIterator() { 239 if (!jdoIsActive()) { 240 return ((List ) accessor.collection).listIterator(); 241 } else { 242 ListAccessor la = (ListAccessor) getSpeedoHome().readIntention(this, null); 243 return la.listIterator(); 244 } 245 } 246 247 public ListIterator listIterator(int i) { 248 if (!jdoIsActive()) { 249 return ((List ) accessor.collection).listIterator(i); 250 } else { 251 ListAccessor la = (ListAccessor) getSpeedoHome().readIntention(this, null); 252 return la.listIterator(i); 253 } 254 } 255 256 public List subList(int i, int i1) { 257 if (!jdoIsActive()) { 258 return ((List ) accessor.collection).subList(i, i1); 259 } else { 260 ListAccessor la = (ListAccessor) getSpeedoHome().readIntention(this, null); 261 return la.subList(i, i1); 262 } 263 } 264 public Object createGenClass() { 265 return new ArrayList (); 266 } 267 268 public SpeedoAccessor createAccessor() { 269 return new ListAccessor(this); 270 } 271 } 272 | Popular Tags |