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