1 23 package org.objectweb.jorm.runtime.colocated; 24 25 import org.objectweb.jorm.api.PIndexedElem; 26 import org.objectweb.jorm.api.PException; 27 import org.objectweb.jorm.api.PGenClassAccessor; 28 import org.objectweb.jorm.api.PAccessor; 29 import org.objectweb.jorm.naming.api.PName; 30 31 import java.util.Iterator ; 32 import java.util.List ; 33 import java.util.ArrayList ; 34 import java.util.Date ; 35 import java.io.Serializable ; 36 import java.math.BigDecimal ; 37 import java.math.BigInteger ; 38 39 import junit.framework.Assert; 40 41 45 public class GenClass_C implements PGenClassAccessor { 46 47 public List elements; 48 public int expectedSize; 49 50 public GenClass_C(List pnames) { 51 elements = new ArrayList (pnames.size()); 52 for(int i=0; i<pnames.size(); i++) { 53 elements.add(new RefElement((PName) pnames.get(i))); 54 } 55 expectedSize = elements.size(); 56 } 57 58 public GenClass_C(int expectedsize) { 59 expectedSize = expectedsize; 60 elements = new ArrayList (); 61 } 62 63 public boolean equals(Object obj) { 64 Assert.assertNotNull("null object", obj); 65 Assert.assertEquals("Bad class", obj.getClass(), getClass()); 66 GenClass_C o = (GenClass_C) obj; 67 Assert.assertEquals("Bad size", elements.size(), o.elements.size()); 68 for(int i=0; i<elements.size(); i++) { 69 Assert.assertTrue("Expected element <" 70 + ((RefElement) elements.get(i)).element 71 + "> is not present: in " + o.elements, 72 o.elements.contains(elements.get(i))); 73 } 74 for(int i=0; i<o.elements.size(); i++) { 75 Assert.assertTrue("Unexpected element <" 76 + ((RefElement) o.elements.get(i)).element 77 + "> is present", 78 elements.contains(o.elements.get(i))); 79 } 80 return true; 81 } 82 83 86 public void paAdd(PIndexedElem elem, Object conn) throws PException { 87 elements.add(elem); 88 } 89 90 public boolean paDeltaSupported() { 91 return true; 92 } 93 94 public int paGetNbElem() { 95 return elements.size(); 96 } 97 98 public Iterator paIterator() { 99 return elements.iterator(); 100 } 101 102 public void paSetNbElem(int nbelem) { 103 if (nbelem != -1) { 104 Assert.assertEquals("Bad expected size", expectedSize, nbelem); 105 } 106 elements.clear(); 107 } 108 109 public PIndexedElem createPIndexedElem() throws PException { 110 return new RefElement(); 111 } 112 113 114 117 public Object getMemoryInstance() { 118 return this; 119 } 120 121 122 125 public class RefElement implements PIndexedElem { 126 public byte status; 127 public PName element; 128 129 public RefElement() { 130 status = PIndexedElem.ELEM_UNMODIFIED; 131 } 132 133 public RefElement(PName element) { 134 this.status = PIndexedElem.ELEM_CREATED; 135 this.element = element; 136 } 137 138 public RefElement(byte status, PName element) { 139 this.status = status; 140 this.element = element; 141 } 142 143 public boolean equals(Object obj) { 144 return element.equals(((RefElement) obj).element); 145 } 146 147 public String toString() { 148 return "RefElemen(" + element.toString() + ")"; 149 } 150 151 public byte getElemStatus() { 152 return status; 153 } 154 155 public void pieSetRefElem(PName value) throws PException { 156 element = value; 157 } 158 159 public PName pieGetRefElem() throws PException { 160 return element; 161 } 162 163 public boolean pieGetBooleanElem() throws PException { 164 Assert.fail("The element is a reference"); 165 return false; 166 } 167 168 public Boolean pieGetObooleanElem() throws PException { 169 Assert.fail("The element is a reference"); 170 return null; 171 } 172 173 public byte pieGetByteElem() throws PException { 174 Assert.fail("The element is a reference"); 175 return 0; 176 } 177 178 public Byte pieGetObyteElem() throws PException { 179 Assert.fail("The element is a reference"); 180 return null; 181 } 182 183 public byte pieGetByteIndexField(String fn) throws PException { 184 Assert.fail("There is no index"); 185 return 0; 186 } 187 188 public Byte pieGetObyteIndexField(String fn) throws PException { 189 Assert.fail("There is no index"); 190 return null; 191 } 192 193 public char pieGetCharElem() throws PException { 194 Assert.fail("The element is a reference"); 195 return 0; 196 } 197 198 public Character pieGetOcharElem() throws PException { 199 Assert.fail("The element is a reference"); 200 return null; 201 } 202 203 public char pieGetCharIndexField(String fn) throws PException { 204 Assert.fail("There is no index"); 205 return 0; 206 } 207 208 public Character pieGetOcharIndexField(String fn) throws PException { 209 Assert.fail("There is no index"); 210 return null; 211 } 212 213 public short pieGetShortElem() throws PException { 214 Assert.fail("The element is a reference"); 215 return 0; 216 } 217 218 public Short pieGetOshortElem() throws PException { 219 Assert.fail("The element is a reference"); 220 return null; 221 } 222 223 public short pieGetShortIndexField(String fn) throws PException { 224 Assert.fail("There is no index"); 225 return 0; 226 } 227 228 public Short pieGetOshortIndexField(String fn) throws PException { 229 Assert.fail("There is no index"); 230 return null; 231 } 232 233 public int pieGetIntElem() throws PException { 234 Assert.fail("The element is a reference"); 235 return 0; 236 } 237 238 public Integer pieGetOintElem() throws PException { 239 Assert.fail("The element is a reference"); 240 return null; 241 } 242 243 public int pieGetIntIndexField(String fn) throws PException { 244 Assert.fail("There is no index"); 245 return 0; 246 } 247 248 public Integer pieGetOintIndexField(String fn) throws PException { 249 Assert.fail("There is no index"); 250 return null; 251 } 252 253 public long pieGetLongElem() throws PException { 254 Assert.fail("The element is a reference"); 255 return 0; 256 } 257 258 public Long pieGetOlongElem() throws PException { 259 Assert.fail("The element is a reference"); 260 return null; 261 } 262 263 public long pieGetLongIndexField(String fn) throws PException { 264 Assert.fail("There is no index"); 265 return 0; 266 } 267 268 public Long pieGetOlongIndexField(String fn) throws PException { 269 Assert.fail("There is no index"); 270 return null; 271 } 272 273 public float pieGetFloatElem() throws PException { 274 Assert.fail("The element is a reference"); 275 return 0; 276 } 277 278 public Float pieGetOfloatElem() throws PException { 279 Assert.fail("The element is a reference"); 280 return null; 281 } 282 283 public double pieGetDoubleElem() throws PException { 284 Assert.fail("The element is a reference"); 285 return 0; 286 } 287 288 public Double pieGetOdoubleElem() throws PException { 289 Assert.fail("The element is a reference"); 290 return null; 291 } 292 293 public String pieGetStringElem() throws PException { 294 Assert.fail("The element is a reference"); 295 return null; 296 } 297 298 public String pieGetStringIndexField(String fn) throws PException { 299 Assert.fail("There is no index"); 300 return null; 301 } 302 303 public Date pieGetDateElem() throws PException { 304 Assert.fail("The element is a reference"); 305 return null; 306 } 307 308 public Date pieGetDateIndexField(String fn) throws PException { 309 Assert.fail("There is no index"); 310 return null; 311 } 312 313 public char[] pieGetCharArrayElem() throws PException { 314 Assert.fail("The element is a reference"); 315 return new char[0]; 316 } 317 318 public byte[] pieGetByteArrayElem() throws PException { 319 Assert.fail("The element is a reference"); 320 return new byte[0]; 321 } 322 323 public Serializable pieGetSerializedElem() throws PException { 324 Assert.fail("The element is a reference"); 325 return null; 326 } 327 328 public BigDecimal pieGetBigDecimalElem() throws PException { 329 Assert.fail("The element is a reference"); 330 return null; 331 } 332 333 public BigInteger pieGetBigIntegerElem() throws PException { 334 Assert.fail("The element is a reference"); 335 return null; 336 } 337 338 public void pieSetBooleanElem(boolean value) throws PException { 339 Assert.fail("The element is a reference"); 340 } 341 342 public void pieSetObooleanElem(Boolean value) throws PException { 343 Assert.fail("The element is a reference"); 344 } 345 346 public void pieSetByteElem(byte value) throws PException { 347 Assert.fail("The element is a reference"); 348 } 349 350 public void pieSetObyteElem(Byte value) throws PException { 351 Assert.fail("The element is a reference"); 352 } 353 354 public void pieSetByteIndexField(String fn, byte value) throws PException { 355 Assert.fail("There is no index"); 356 } 357 358 public void pieSetObyteIndexField(String fn, Byte value) throws PException { 359 Assert.fail("There is no index"); 360 } 361 362 public void pieSetCharElem(char value) throws PException { 363 Assert.fail("The element is a reference"); 364 } 365 366 public void pieSetOcharElem(Character value) throws PException { 367 Assert.fail("The element is a reference"); 368 } 369 370 public void pieSetCharIndexField(String fn, char value) throws PException { 371 Assert.fail("There is no index"); 372 } 373 374 public void pieSetOcharIndexField(String fn, Character value) throws PException { 375 Assert.fail("There is no index"); 376 } 377 378 public void pieSetShortElem(short value) throws PException { 379 Assert.fail("The element is a reference"); 380 } 381 382 public void pieSetOshortElem(Short value) throws PException { 383 Assert.fail("The element is a reference"); 384 } 385 386 public void pieSetShortIndexField(String fn, short value) throws PException { 387 Assert.fail("There is no index"); 388 } 389 390 public void pieSetOshortIndexField(String fn, Short value) throws PException { 391 Assert.fail("There is no index"); 392 } 393 394 public void pieSetIntElem(int value) throws PException { 395 Assert.fail("The element is a reference"); 396 } 397 398 public void pieSetOintElem(Integer value) throws PException { 399 Assert.fail("The element is a reference"); 400 } 401 402 public void pieSetIntIndexField(String fn, int value) throws PException { 403 Assert.fail("There is no index"); 404 } 405 406 public void pieSetOintIndexField(String fn, Integer value) throws PException { 407 Assert.fail("There is no index"); 408 } 409 410 public void pieSetLongElem(long value) throws PException { 411 Assert.fail("The element is a reference"); 412 } 413 414 public void pieSetOlongElem(Long value) throws PException { 415 Assert.fail("The element is a reference"); 416 } 417 418 public void pieSetLongIndexField(String fn, long value) throws PException { 419 Assert.fail("There is no index"); 420 } 421 422 public void pieSetOlongIndexField(String fn, Long value) throws PException { 423 Assert.fail("There is no index"); 424 } 425 426 public void pieSetFloatElem(float value) throws PException { 427 Assert.fail("The element is a reference"); 428 } 429 430 public void pieSetOfloatElem(Float value) throws PException { 431 Assert.fail("The element is a reference"); 432 } 433 434 public void pieSetDoubleElem(double value) throws PException { 435 Assert.fail("The element is a reference"); 436 } 437 438 public void pieSetOdoubleElem(Double value) throws PException { 439 Assert.fail("The element is a reference"); 440 } 441 442 public void pieSetStringElem(String value) throws PException { 443 Assert.fail("The element is a reference"); 444 } 445 446 public void pieSetStringIndexField(String fn, String value) throws PException { 447 Assert.fail("There is no index"); 448 } 449 450 public void pieSetDateElem(Date value) throws PException { 451 Assert.fail("The element is a reference"); 452 } 453 454 public void pieSetDateIndexField(String fn, Date value) throws PException { 455 Assert.fail("There is no index"); 456 } 457 458 public void pieSetCharArrayElem(char[] value) throws PException { 459 Assert.fail("The element is a reference"); 460 } 461 462 public void pieSetByteArrayElem(byte[] value) throws PException { 463 Assert.fail("The element is a reference"); 464 } 465 466 public void pieSetSerializedElem(Serializable value) throws PException { 467 Assert.fail("The element is a reference"); 468 } 469 470 public void pieSetBigDecimalElem(BigDecimal value) throws PException { 471 Assert.fail("The element is a reference"); 472 } 473 474 public void pieSetBigIntegerElem(BigInteger value) throws PException { 475 Assert.fail("The element is a reference"); 476 } 477 } 478 } 479 | Popular Tags |