1 18 package org.objectweb.speedo.genclass.collection; 19 20 import org.objectweb.speedo.mim.api.SpeedoAccessor; 21 22 import java.util.List ; 23 import java.util.Collection ; 24 import java.util.Iterator ; 25 import java.util.ListIterator ; 26 import java.util.ArrayList ; 27 28 32 public class ListImpl extends CollectionImpl implements List { 33 34 35 38 public ListImpl() { 39 super(); 40 } 41 42 45 public SpeedoAccessor createAccessor() { 46 return new ListAccessor(this); 47 } 48 49 public Object createGenClass() { 50 return new ArrayList (); 51 } 52 53 56 public boolean addAll(int i, Collection collection) { 57 if (collection == null) { 58 return true; 59 } 60 int idx = i; 61 Iterator it = collection.iterator(); 62 while(it.hasNext()) { 63 add(idx, it.next()); 64 idx ++; 65 } 66 return idx > i; 67 } 68 69 public Object get(int i) { 70 if (!jdoIsActive) { 71 return ((List ) accessor.collection).get(i); 72 } else { 73 ListAccessor la = (ListAccessor) getSpeedoHome().readIntention(this, null); 74 return la.get(i); 75 } 76 } 77 78 public Object set(int i, Object o) { 79 if (!jdoIsActive) { 80 return ((List ) accessor.collection).set(i,o); 81 } else { 82 ListAccessor la = (ListAccessor) getSpeedoHome().writeIntention(this, null); 83 return la.set(i, o); 84 } 85 } 86 87 public void add(int i, Object o) { 88 if (!jdoIsActive) { 89 ((List ) accessor.collection).add(i, o); 90 } else { 91 ListAccessor la = (ListAccessor) getSpeedoHome().writeIntention(this, null); 92 la.add(i, o); 93 } 94 } 95 96 public Object remove(int i) { 97 if (!jdoIsActive) { 98 return ((List ) accessor.collection).remove(i); 99 } else { 100 ListAccessor la = (ListAccessor) getSpeedoHome().writeIntention(this, null); 101 return la.remove(i); 102 } 103 } 104 105 public int indexOf(Object o) { 106 if (!jdoIsActive) { 107 return ((List ) accessor.collection).indexOf(o); 108 } else { 109 ListAccessor la = (ListAccessor) getSpeedoHome().readIntention(this, null); 110 return la.indexOf(o); 111 } 112 } 113 114 public int lastIndexOf(Object o) { 115 if (!jdoIsActive) { 116 return ((List ) accessor.collection).lastIndexOf(o); 117 } else { 118 ListAccessor la = (ListAccessor) getSpeedoHome().readIntention(this, null); 119 return la.lastIndexOf(o); 120 } 121 } 122 123 public ListIterator listIterator() { 124 if (!jdoIsActive) { 125 return ((List ) accessor.collection).listIterator(); 126 } else { 127 ListAccessor la = (ListAccessor) getSpeedoHome().readIntention(this, null); 128 return la.listIterator(); 129 } 130 } 131 132 public ListIterator listIterator(int i) { 133 if (!jdoIsActive) { 134 return ((List ) accessor.collection).listIterator(i); 135 } else { 136 ListAccessor la = (ListAccessor) getSpeedoHome().readIntention(this, null); 137 return la.listIterator(i); 138 } 139 } 140 141 public List subList(int i, int i1) { 142 if (!jdoIsActive) { 143 return ((List ) accessor.collection).subList(i, i1); 144 } else { 145 ListAccessor la = (ListAccessor) getSpeedoHome().readIntention(this, null); 146 return la.subList(i, i1); 147 } 148 } 149 150 } 151 | Popular Tags |