1 18 package org.objectweb.speedo.genclass.map; 19 20 import org.objectweb.speedo.genclass.GenClass; 21 import org.objectweb.speedo.mim.api.SpeedoAccessor; 22 23 import java.util.Map ; 24 import java.util.Collection ; 25 import java.util.Set ; 26 import java.util.HashMap ; 27 28 public class MapImpl extends GenClass implements Map { 29 30 33 public MapImpl() { 34 super(); 35 accessor = (MapAccessor) createAccessor(); 36 } 37 38 42 public int size() { 43 if (!jdoIsActive) { 44 return accessor.size(); 45 } else { 46 MapAccessor ca = (MapAccessor) getSpeedoHome().readIntention(this, null); 47 return ca.size(); 48 } 49 } 50 51 public boolean isEmpty() { 52 if (!jdoIsActive) { 53 return accessor.isEmpty(); 54 } else { 55 MapAccessor ca = (MapAccessor) getSpeedoHome().readIntention(this, null); 56 return ca.isEmpty(); 57 } 58 } 59 60 public boolean containsKey(Object key) { 61 if (!jdoIsActive) { 62 return accessor.containsKey(key); 63 } else { 64 MapAccessor ca = (MapAccessor) getSpeedoHome().readIntention(this, null); 65 return ca.containsKey(key); 66 } 67 } 68 69 public boolean containsValue(Object value) { 70 if (!jdoIsActive) { 71 return accessor.containsValue(value); 72 } else { 73 MapAccessor ca = (MapAccessor) getSpeedoHome().readIntention(this, null); 74 return ca.containsValue(value); 75 } 76 } 77 78 public Object get(Object key) { 79 if (!jdoIsActive) { 80 return accessor.get(key); 81 } else { 82 MapAccessor ca = (MapAccessor) getSpeedoHome().readIntention(this, null); 83 return ca.get(key); 84 } 85 } 86 87 public Object put(Object key, Object value) { 88 if (!jdoIsActive) { 89 return accessor.put(key, value); 90 } else { 91 MapAccessor ca = (MapAccessor) getSpeedoHome().writeIntention(this, null); 92 return ca.put(key, value); 93 } 94 } 95 96 public Object remove(Object key) { 97 if (!jdoIsActive) { 98 return accessor.remove(key); 99 } else { 100 MapAccessor ca = (MapAccessor) getSpeedoHome().writeIntention(this, null); 101 return ca.remove(key); 102 } 103 } 104 105 public void putAll(Map t) { 106 if (!jdoIsActive) { 107 accessor.putAll(t); 108 } else { 109 MapAccessor ca = (MapAccessor) getSpeedoHome().writeIntention(this, null); 110 ca.putAll(t); 111 } 112 } 113 114 public void clear() { 115 if (!jdoIsActive) { 116 accessor.clear(); 117 } else { 118 MapAccessor ca = (MapAccessor) getSpeedoHome().writeIntention(this, null); 119 ca.clear(); 120 } 121 } 122 123 public Set keySet() { 124 if (!jdoIsActive) { 125 return accessor.keySet(); 126 } else { 127 MapAccessor ca = (MapAccessor) getSpeedoHome().readIntention(this, null); 128 return ca.keySet(); 129 } 130 } 131 132 public Collection values() { 133 if (!jdoIsActive) { 134 return accessor.values(); 135 } else { 136 MapAccessor ca = (MapAccessor) getSpeedoHome().writeIntention(this, null); 137 return ca.values(); 138 } 139 } 140 141 public Set entrySet() { 142 if (!jdoIsActive) { 143 return accessor.entrySet(); 144 } else { 145 MapAccessor ca = (MapAccessor) getSpeedoHome().readIntention(this, null); 146 return ca.entrySet(); 147 } 148 } 149 150 153 public void setGCValue(Object o) { 154 if (jdoIsActive) { 155 MapAccessor ca = (MapAccessor) getSpeedoHome().writeIntention(this, null); 156 ca.clear(); 157 if (o != null) { 158 ca.putAll(((Map ) o)); 159 } 160 } else { 161 accessor.clear(); 162 if (o != null) { 163 accessor.putAll(((Map ) o)); 164 } 165 } 166 } 167 168 MapAccessor accessor; 169 170 public SpeedoAccessor getReferenceAccessor() { 171 return accessor; 172 } 173 public void setReferenceAccessor(SpeedoAccessor refAcc) { 174 accessor = (MapAccessor) refAcc; 175 } 176 public SpeedoAccessor createAccessor() { 177 return new MapAccessor(this); 178 } 179 180 public Object createGenClass() { 181 return new HashMap (); 182 } 183 184 } 185 | Popular Tags |