1 18 package org.objectweb.speedo.genclass.collection; 19 20 import org.objectweb.speedo.mim.api.SpeedoAccessor; 21 import org.objectweb.speedo.genclass.api.SpeedoGenClassProxy; 22 import java.util.Collection ; 23 import java.util.HashSet ; 24 import java.util.Iterator ; 25 26 30 public abstract class HashSetImpl 31 extends HashSet 32 implements SpeedoGenClassProxy { 33 34 public HashSetImpl() { 35 super(); 36 accessor = (SetAccessor) createAccessor(); 37 } 38 39 SetAccessor accessor; 40 41 public SpeedoAccessor getReferenceAccessor() { 42 return accessor; 43 } 44 public void setReferenceAccessor(SpeedoAccessor refAcc) { 45 accessor = (SetAccessor) refAcc; 46 } 47 48 49 52 public boolean add(Object o) { 53 boolean result; 54 if (!jdoIsActive()) { 55 result = accessor.add(o); 56 } else { 57 SetAccessor ca = (SetAccessor) getSpeedoHome().writeIntention(this, null); 58 result = ca.add(o); 59 } 60 return result; 61 } 62 63 public boolean addAll(Collection c) { 64 boolean result; 65 if (!jdoIsActive()) { 66 result = accessor.addAll(c); 67 } else { 68 SetAccessor ca = (SetAccessor) getSpeedoHome().writeIntention(this, null); 69 result = ca.addAll(c); 70 } 71 return result; 72 } 73 74 public void clear() { 75 if (!jdoIsActive()) { 76 accessor.clear(); 77 } else { 78 SetAccessor ca = (SetAccessor) getSpeedoHome().writeIntention(this, null); 79 ca.clear(); 80 } 81 } 82 83 public boolean contains(Object o) { 84 if (!jdoIsActive()) { 85 return accessor.contains(o); 86 } else { 87 SetAccessor ca = (SetAccessor) getSpeedoHome().readIntention(this, null); 88 return ca.contains(o); 89 } 90 } 91 92 public boolean containsAll(Collection c) { 93 if (!jdoIsActive()) { 94 return accessor.containsAll(c); 95 } else { 96 SetAccessor ca = (SetAccessor) getSpeedoHome().readIntention(this, null); 97 return ca.containsAll(c); 98 } 99 } 100 101 public boolean equals(Object o) { 102 if (!jdoIsActive()) { 103 return accessor.equals(o); 104 } else { 105 SetAccessor ca = (SetAccessor) getSpeedoHome().readIntention(this, null); 106 return ca.equals(o); 107 } 108 } 109 110 public boolean isEmpty() { 111 if (!jdoIsActive()) { 112 return accessor.isEmpty(); 113 } else { 114 SetAccessor ca = (SetAccessor) getSpeedoHome().readIntention(this, null); 115 return ca.isEmpty(); 116 } 117 } 118 119 public Iterator iterator() { 120 if (!jdoIsActive()) { 121 return accessor.iterator(); 122 } else { 123 SetAccessor ca = (SetAccessor) getSpeedoHome().readIntention(this, null); 124 return ca.iterator(); 125 } 126 } 127 128 public boolean remove(Object o) { 129 boolean result; 130 if (!jdoIsActive()) { 131 result = accessor.remove(o); 132 } else { 133 SetAccessor ca = (SetAccessor) getSpeedoHome().writeIntention(this, null); 134 result = ca.remove(o); 135 } 136 return result; 137 } 138 139 public boolean removeAll(Collection c) { 140 boolean result; 141 if (!jdoIsActive()) { 142 result = accessor.removeAll(c); 143 } else { 144 SetAccessor ca = (SetAccessor) getSpeedoHome().writeIntention(this, null); 145 result = ca.removeAll(c); 146 } 147 return result; 148 } 149 150 public boolean retainAll(Collection c) { 151 throw new UnsupportedOperationException (); 152 } 153 154 public int size() { 155 if (!jdoIsActive()) { 156 return accessor.size(); 157 } else { 158 SetAccessor ca = (SetAccessor) getSpeedoHome().readIntention(this, null); 159 return ca.size(); 160 } 161 } 162 163 public Object [] toArray() { 164 if (!jdoIsActive()) { 165 return accessor.toArray(); 166 } else { 167 SetAccessor ca = (SetAccessor) getSpeedoHome().readIntention(this, null); 168 return ca.toArray(); 169 } 170 } 171 172 public Object [] toArray(Object [] a) { 173 if (!jdoIsActive()) { 174 return accessor.toArray(a); 175 } else { 176 SetAccessor ca = (SetAccessor) getSpeedoHome().readIntention(this, null); 177 return ca.toArray(a); 178 } 179 } 180 181 184 public Object createGenClass() { 185 return new HashSet (); 186 } 187 188 public SpeedoAccessor createAccessor() { 189 return new SetAccessor(this); 190 } 191 } 192 | Popular Tags |