1 18 package org.objectweb.speedo.genclass.map; 19 20 import org.objectweb.speedo.mim.api.SpeedoAccessor; 21 import org.objectweb.speedo.genclass.api.SpeedoGenClassProxy; 22 23 import java.util.Properties ; 24 import java.util.Enumeration ; 25 import java.util.Map ; 26 import java.util.Set ; 27 import java.util.Collection ; 28 import java.util.Collections ; 29 import java.io.InputStream ; 30 import java.io.IOException ; 31 import java.io.OutputStream ; 32 import java.io.PrintStream ; 33 import java.io.PrintWriter ; 34 35 39 public abstract class PropertiesImpl 40 extends Properties 41 implements SpeedoGenClassProxy { 42 43 public PropertiesImpl() { 44 super(); 45 accessor = (MapAccessor) createAccessor(); 46 } 47 48 public synchronized String toString() { 49 return ""; 50 } 51 52 MapAccessor accessor; 53 54 public SpeedoAccessor getReferenceAccessor() { 55 return accessor; 56 } 57 public void setReferenceAccessor(SpeedoAccessor refAcc) { 58 accessor = (MapAccessor) refAcc; 59 } 60 61 public Object createGenClass() { 62 return new Properties (); 63 } 64 65 public SpeedoAccessor createAccessor() { 66 return new MapAccessor(this); 67 } 68 69 72 public synchronized Object setProperty(String s, String s1) { 73 if (!jdoIsActive()) { 74 return accessor.put(s, s1); 75 } else { 76 MapAccessor ma = (MapAccessor) getSpeedoHome().writeIntention(this, null); 77 return ma.put(s, s1); 78 } 79 } 80 81 public synchronized void load(InputStream inputStream) throws IOException { 82 Properties p = new Properties (); 83 p.load(inputStream); 84 if (!jdoIsActive()) { 85 accessor.putAll(p); 86 } else { 87 MapAccessor ma = (MapAccessor) getSpeedoHome().writeIntention(this, null); 88 ma.putAll(p); 89 } 90 } 91 92 public synchronized void store(OutputStream outputStream, String s) throws IOException { 93 Properties p = new Properties (); 94 if (!jdoIsActive()) { 95 p.putAll(accessor); 96 } else { 97 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 98 p.putAll(ma); 99 } 100 p.store(outputStream, s); 101 } 102 103 public String getProperty(String s) { 104 if (!jdoIsActive()) { 105 return (String ) accessor.get(s); 106 } else { 107 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 108 return (String ) ma.get(s); 109 } 110 } 111 112 public String getProperty(String s, String s1) { 113 String res; 114 if (!jdoIsActive()) { 115 res = (String ) accessor.get(s); 116 } else { 117 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 118 res = (String ) ma.get(s) ; 119 } 120 return res == null ? s1 : s; 121 } 122 123 public Enumeration propertyNames() { 124 if (!jdoIsActive()) { 125 return Collections.enumeration(accessor.entrySet()); 126 } else { 127 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 128 return Collections.enumeration(ma.keySet()); 129 } 130 } 131 132 public void list(PrintStream printStream) { 133 if (!jdoIsActive()) { 134 super.list(printStream); 135 } else { 136 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 137 Properties p = new Properties (); 138 p.putAll(ma); 139 p.list(printStream); 140 } 141 } 142 143 public void list(PrintWriter printWriter) { 144 Properties p = new Properties (); 145 if (!jdoIsActive()) { 146 p.putAll(accessor); 147 } else { 148 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 149 p.putAll(ma); 150 } 151 p.list(printWriter); 152 } 153 154 public int size() { 155 if (!jdoIsActive()) { 156 return accessor.size(); 157 } else { 158 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 159 return ma.size(); 160 } 161 } 162 163 public boolean isEmpty() { 164 if (!jdoIsActive()) { 165 return accessor.isEmpty(); 166 } else { 167 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 168 return ma.isEmpty(); 169 } 170 } 171 172 public synchronized Enumeration keys() { 173 if (!jdoIsActive()) { 174 return Collections.enumeration(accessor.keySet()); 175 } else { 176 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 177 return Collections.enumeration(ma.keySet()); 178 } 179 } 180 181 public synchronized Enumeration elements() { 182 if (!jdoIsActive()) { 183 return Collections.enumeration(accessor.values()); 184 } else { 185 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 186 return Collections.enumeration(ma.values()); 187 } 188 } 189 190 public synchronized boolean contains(Object o) { 191 if (!jdoIsActive()) { 192 return accessor.containsKey(o); 193 } else { 194 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 195 return ma.containsKey(o); 196 } 197 } 198 199 public boolean containsValue(Object o) { 200 if (!jdoIsActive()) { 201 return accessor.containsValue(o); 202 } else { 203 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 204 return ma.containsValue(o); 205 } 206 } 207 208 public synchronized boolean containsKey(Object o) { 209 if (!jdoIsActive()) { 210 return accessor.containsKey(o); 211 } else { 212 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 213 return ma.containsKey(o); 214 } 215 } 216 217 public synchronized Object get(Object o) { 218 if (!jdoIsActive()) { 219 return accessor.get(o); 220 } else { 221 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 222 return ma.get(o); 223 } 224 } 225 226 protected void rehash() { 227 if (!jdoIsActive()) { 228 super.rehash(); 229 } else { 230 getSpeedoHome().readIntention(this, null); 231 } 232 } 233 234 public synchronized Object put(Object o, Object o1) { 235 if (!jdoIsActive()) { 236 return accessor.put(o, o1); 237 } else { 238 MapAccessor ma = (MapAccessor) getSpeedoHome().writeIntention(this, null); 239 return ma.put(o, o1); 240 } 241 } 242 243 public synchronized Object remove(Object o) { 244 if (!jdoIsActive()) { 245 return accessor.remove(o); 246 } else { 247 MapAccessor ma = (MapAccessor) getSpeedoHome().writeIntention(this, null); 248 return ma.remove(o); 249 } 250 } 251 252 public synchronized void putAll(Map map) { 253 if (!jdoIsActive()) { 254 accessor.putAll(map); 255 } else { 256 MapAccessor ma = (MapAccessor) getSpeedoHome().writeIntention(this, null); 257 ma.putAll(map); 258 } 259 } 260 261 public synchronized void clear() { 262 if (!jdoIsActive()) { 263 accessor.clear(); 264 } else { 265 MapAccessor ma = (MapAccessor) getSpeedoHome().writeIntention(this, null); 266 ma.clear(); 267 } 268 } 269 270 public Set keySet() { 271 if (!jdoIsActive()) { 272 return accessor.keySet(); 273 } else { 274 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 275 return ma.keySet(); 276 } 277 } 278 279 public Set entrySet() { 280 if (!jdoIsActive()) { 281 return accessor.entrySet(); 282 } else { 283 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 284 return ma.entrySet(); 285 } 286 } 287 288 public Collection values() { 289 if (!jdoIsActive()) { 290 return accessor.values(); 291 } else { 292 MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null); 293 return ma.values(); 294 } 295 } 296 } 297 | Popular Tags |