1 23 24 package org.objectweb.jorm.runtime.gcbasictypeelem; 25 26 import org.objectweb.jorm.api.PGenClassAccessor; 27 import org.objectweb.jorm.api.PIndexedElem; 28 import org.objectweb.jorm.api.PException; 29 import org.objectweb.jorm.type.api.PType; 30 import org.objectweb.jorm.type.api.PExceptionTyping; 31 import org.objectweb.jorm.naming.api.PName; 32 33 import java.util.Iterator ; 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 44 public class GcBasicTypeAccessor implements PGenClassAccessor { 45 private boolean[] boolean_value; 46 private byte[] byte_value; 47 private char[] char_value; 48 private short[] short_value; 49 private int[] int_value; 50 private long[] long_value; 51 private float[] float_value; 52 private double[] double_value; 53 private Object [] object_value; 54 private int typeCode, nbElem, nextToAdd; 55 56 public GcBasicTypeAccessor(int typecode, int nbelem) throws PException { 57 typeCode = typecode; 58 nbElem = nbelem; 59 switch (typeCode) { 60 case PType.TYPECODE_BOOLEAN: 61 boolean_value = new boolean[nbelem]; 62 break; 63 case PType.TYPECODE_BYTE: 64 byte_value = new byte[nbelem]; 65 break; 66 case PType.TYPECODE_CHAR: 67 char_value = new char[nbelem]; 68 break; 69 case PType.TYPECODE_SHORT: 70 short_value = new short[nbelem]; 71 break; 72 case PType.TYPECODE_INT: 73 int_value = new int[nbelem]; 74 break; 75 case PType.TYPECODE_LONG: 76 long_value = new long[nbelem]; 77 break; 78 case PType.TYPECODE_FLOAT: 79 float_value = new float[nbelem]; 80 break; 81 case PType.TYPECODE_DOUBLE: 82 double_value = new double[nbelem]; 83 break; 84 case PType.TYPECODE_OBJBOOLEAN: 85 case PType.TYPECODE_OBJBYTE: 86 case PType.TYPECODE_OBJCHAR: 87 case PType.TYPECODE_OBJSHORT: 88 case PType.TYPECODE_OBJINT: 89 case PType.TYPECODE_OBJLONG: 90 case PType.TYPECODE_OBJFLOAT: 91 case PType.TYPECODE_OBJDOUBLE: 92 case PType.TYPECODE_STRING: 93 case PType.TYPECODE_DATE: 94 case PType.TYPECODE_BYTEARRAY: 95 case PType.TYPECODE_CHARARRAY: 96 case PType.TYPECODE_BIGDECIMAL: 97 case PType.TYPECODE_SERIALIZED: 98 object_value = new Object [nbelem]; 99 break; 100 default : 101 throw new PExceptionTyping("Wrong field type."); 102 } 103 } 104 105 public int getTypeCode() { 106 return typeCode; 107 } 108 109 public void setElem(int pos, Object o) { 110 object_value[pos] = o; 111 } 112 113 public void setElem(int pos, boolean o) { 114 boolean_value[pos] = o; 115 } 116 117 public void setElem(int pos, byte o) { 118 byte_value[pos] = o; 119 } 120 121 public void setElem(int pos, char o) { 122 char_value[pos] = o; 123 } 124 125 public void setElem(int pos, short o) { 126 short_value[pos] = o; 127 } 128 129 public void setElem(int pos, int o) { 130 int_value[pos] = o; 131 } 132 133 public void setElem(int pos, long o) { 134 long_value[pos] = o; 135 } 136 137 public void setElem(int pos, float o) { 138 float_value[pos] = o; 139 } 140 141 public void setElem(int pos, double o) { 142 double_value[pos] = o; 143 } 144 145 public boolean equals(Object other) { 146 switch (typeCode) { 147 case PType.TYPECODE_BOOLEAN: 148 return assertEqualArray("boolean values error (1)", boolean_value 149 , ((GcBasicTypeAccessor) other).boolean_value) 150 && assertEqualArray("boolean values error (2)", 151 ((GcBasicTypeAccessor) other).boolean_value, 152 boolean_value); 153 case PType.TYPECODE_BYTE: 154 return assertEqualArray("byte values error (1)", byte_value 155 , ((GcBasicTypeAccessor) other).byte_value, true) 156 && assertEqualArray("byte values error (2)", 157 ((GcBasicTypeAccessor) other).byte_value, 158 byte_value, true); 159 case PType.TYPECODE_CHAR: 160 return assertEqualArray("char values error (1)", char_value 161 , ((GcBasicTypeAccessor) other).char_value) 162 && assertEqualArray("char values error (2)", 163 ((GcBasicTypeAccessor) other).char_value, 164 char_value); 165 case PType.TYPECODE_SHORT: 166 return assertEqualArray("short values error (1)", short_value 167 , ((GcBasicTypeAccessor) other).short_value) 168 && assertEqualArray("short values error (2)", 169 ((GcBasicTypeAccessor) other).short_value, 170 short_value); 171 case PType.TYPECODE_INT: 172 return assertEqualArray("int values error (1)", int_value 173 , ((GcBasicTypeAccessor) other).int_value) 174 && assertEqualArray("int values error (2)", 175 ((GcBasicTypeAccessor) other).int_value, 176 int_value); 177 case PType.TYPECODE_LONG: 178 return assertEqualArray("long values error (1)", long_value 179 , ((GcBasicTypeAccessor) other).long_value) 180 && assertEqualArray("long values error (2)", 181 ((GcBasicTypeAccessor) other).long_value, 182 long_value); 183 case PType.TYPECODE_FLOAT: 184 return assertEqualArray("float values error (1)", float_value 185 , ((GcBasicTypeAccessor) other).float_value) 186 && assertEqualArray("float values error (2)", 187 ((GcBasicTypeAccessor) other).float_value, 188 float_value); 189 case PType.TYPECODE_DOUBLE: 190 return assertEqualArray("double values error (1)", double_value 191 , ((GcBasicTypeAccessor) other).double_value) 192 && assertEqualArray("double values error (2)", 193 ((GcBasicTypeAccessor) other).double_value, 194 double_value); 195 case PType.TYPECODE_BYTEARRAY: 196 case PType.TYPECODE_CHARARRAY: 197 case PType.TYPECODE_OBJBOOLEAN: 198 case PType.TYPECODE_OBJBYTE: 199 case PType.TYPECODE_OBJCHAR: 200 case PType.TYPECODE_OBJSHORT: 201 case PType.TYPECODE_OBJINT: 202 case PType.TYPECODE_OBJLONG: 203 case PType.TYPECODE_OBJFLOAT: 204 case PType.TYPECODE_OBJDOUBLE: 205 case PType.TYPECODE_STRING: 206 case PType.TYPECODE_DATE: 207 case PType.TYPECODE_BIGDECIMAL: 208 case PType.TYPECODE_SERIALIZED: 209 return assertEqualArray("object values error (1)", object_value 210 , ((GcBasicTypeAccessor) other).object_value) 211 && assertEqualArray("object values error (2)", 212 ((GcBasicTypeAccessor) other).object_value, 213 object_value); 214 default : 215 Assert.fail("Unmanaged Type code: " + typeCode); 216 return false; 217 } 218 } 219 220 221 private boolean assertEqualArray(String msg, boolean[] a1, boolean[] a2) { 222 Assert.assertEquals(msg + ": bad array size", a1.length, a2.length); 223 if (a1.length != a2.length) { 224 return false; 225 } 226 for (int i = 0; i < a1.length; i++) { 227 boolean exist = false; 228 for (int j = 0; j < a2.length && !exist; j++) { 229 exist = a1[i] == a2[j]; 230 } 231 if (!exist) { 232 Assert.fail(msg + ": element " + a1[i] + " has not been found"); 233 return false; 234 } 235 } 236 return true; 237 } 238 239 private boolean assertEqualArray(String msg, byte[] a1, byte[] a2, boolean fail) { 240 Assert.assertEquals(msg + ": bad array size", a1.length, a2.length); 241 if (a1.length != a2.length) { 242 return false; 243 } 244 for (int i = 0; i < a1.length; i++) { 245 boolean exist = false; 246 for (int j = 0; j < a2.length && !exist; j++) { 247 exist = a1[i] == a2[j]; 248 } 249 if (!exist) { 250 if (fail) { 251 Assert.fail(msg + ": element " + a1[i] + " has not been found"); 252 } 253 return false; 254 } 255 } 256 return true; 257 } 258 259 private boolean assertEqualArray(String msg, short[] a1, short[] a2) { 260 Assert.assertEquals(msg + ": bad array size", a1.length, a2.length); 261 if (a1.length != a2.length) { 262 return false; 263 } 264 for (int i = 0; i < a1.length; i++) { 265 boolean exist = false; 266 for (int j = 0; j < a2.length && !exist; j++) { 267 exist = a1[i] == a2[j]; 268 } 269 if (!exist) { 270 Assert.fail(msg + ": element " + a1[i] + " has not been found"); 271 return false; 272 } 273 } 274 return true; 275 } 276 277 private boolean assertEqualArray(String msg, int[] a1, int[] a2) { 278 Assert.assertEquals(msg + ": bad array size", a1.length, a2.length); 279 if (a1.length != a2.length) { 280 return false; 281 } 282 for (int i = 0; i < a1.length; i++) { 283 boolean exist = false; 284 for (int j = 0; j < a2.length && !exist; j++) { 285 exist = a1[i] == a2[j]; 286 } 287 if (!exist) { 288 Assert.fail(msg + ": element " + a1[i] + " has not been found"); 289 return false; 290 } 291 } 292 return true; 293 } 294 295 private boolean assertEqualArray(String msg, long[] a1, long[] a2) { 296 Assert.assertEquals(msg + ": bad array size", a1.length, a2.length); 297 if (a1.length != a2.length) { 298 return false; 299 } 300 for (int i = 0; i < a1.length; i++) { 301 boolean exist = false; 302 for (int j = 0; j < a2.length && !exist; j++) { 303 exist = a1[i] == a2[j]; 304 } 305 if (!exist) { 306 Assert.fail(msg + ": element " + a1[i] + " has not been found"); 307 return false; 308 } 309 } 310 return true; 311 } 312 313 private boolean assertEqualArray(String msg, float[] a1, float[] a2) { 314 Assert.assertEquals(msg + ": bad array size", a1.length, a2.length); 315 if (a1.length != a2.length) { 316 return false; 317 } 318 for (int i = 0; i < a1.length; i++) { 319 boolean exist = false; 320 for (int j = 0; j < a2.length && !exist; j++) { 321 exist = a1[i] == a2[j]; 322 } 323 if (!exist) { 324 Assert.fail(msg + ": element " + a1[i] + " has not been found"); 325 return false; 326 } 327 } 328 return true; 329 } 330 331 private boolean assertEqualArray(String msg, double[] a1, double[] a2) { 332 Assert.assertEquals(msg + ": bad array size", a1.length, a2.length); 333 if (a1.length != a2.length) { 334 return false; 335 } 336 for (int i = 0; i < a1.length; i++) { 337 boolean exist = false; 338 for (int j = 0; j < a2.length && !exist; j++) { 339 exist = a1[i] == a2[j]; 340 } 341 if (!exist) { 342 Assert.fail(msg + ": element " + a1[i] + " has not been found"); 343 return false; 344 } 345 } 346 return true; 347 } 348 349 private boolean assertEqualArray(String msg, char[] a1, char[] a2) { 350 Assert.assertEquals(msg + ": bad array size", a1.length, a2.length); 351 if (a1.length != a2.length) { 352 return false; 353 } 354 for (int i = 0; i < a1.length; i++) { 355 boolean exist = false; 356 for (int j = 0; j < a2.length && !exist; j++) { 357 exist = a1[i] == a2[j]; 358 } 359 if (!exist) { 360 Assert.fail(msg + ": element " + a1[i] + " has not been found"); 361 return false; 362 } 363 } 364 return true; 365 } 366 367 private boolean assertEqualArray(String msg, Object [] a1, Object [] a2) { 368 Assert.assertEquals(msg + ": bad array size", a1.length, a2.length); 369 if (a1.length != a2.length) { 370 return false; 371 } 372 for (int i = 0; i < a1.length; i++) { 373 boolean exist = false; 374 if (a1[i] == null) { 375 for (int j = 0; j < a2.length && !exist; j++) { 376 exist = a2[j] == null; 377 } 378 } else if (a1[i] instanceof byte[]) { 379 for (int j = 0; j < a2.length && !exist; j++) { 380 exist = assertEqualArray(msg, (byte[]) a1[i], (byte[]) a2[i], false); 381 } 382 } else if (a1[i] instanceof char[]) { 383 for (int j = 0; j < a2.length && !exist; j++) { 384 exist = assertEqualArray(msg, (char[]) a1[i], (char[]) a2[i]); 385 } 386 } else if (a1[i] instanceof Date ) { 387 for (int j = 0; j < a2.length && !exist; j++) { 388 exist = (a1[i] == null && a1[i] == a2[j]) 389 || (a1[i] != null 390 && a2[i] != null 391 && ((Date ) a1[i]).getTime()==((Date ) a2[i]).getTime()); 392 } 393 } else { 394 for (int j = 0; j < a2.length && !exist; j++) { 395 exist = (a1[i] == null && a1[i] == a2[j]) 396 || (a1[i] != null && a1[i].equals(a2[j])); 397 } 398 } 399 if (!exist) { 400 Assert.fail(msg + ": element (" + i + "): " + toString(a1[i]) + " has not been found in " + toString(a2)); 401 return false; 402 } 403 } 404 return true; 405 } 406 String toString(Object o) { 407 if (o == null) { 408 return "null"; 409 } else if (o instanceof byte[]) { 410 return toString((byte[]) o); 411 } else if (o instanceof char[]) { 412 return toString((char[]) o); 413 } else if (o instanceof Object []) { 414 return toString((Object []) o); 415 } else { 416 return o.toString(); 417 } 418 } 419 String toString(Object [] os) { 420 StringBuffer sb = new StringBuffer ("["); 421 String sep =""; 422 for(int i=0; i<os.length; i++) { 423 sb.append(sep); 424 sep = ","; 425 sb.append(toString(os[i])); 426 } 427 sb.append(']'); 428 return sb.toString(); 429 } 430 431 String toString(byte[] bs) { 432 StringBuffer sb = new StringBuffer ("["); 433 String sep =""; 434 for(int i=0; i<bs.length; i++) { 435 sb.append(sep); 436 sep = ","; 437 sb.append(bs[i]); 438 } 439 sb.append(']'); 440 return sb.toString(); 441 } 442 443 String toString(char[] cs) { 444 StringBuffer sb = new StringBuffer ("["); 445 String sep =""; 446 for(int i=0; i<cs.length; i++) { 447 sb.append(sep); 448 sep = ","; 449 sb.append(cs[i]); 450 } 451 sb.append(']'); 452 return sb.toString(); 453 } 454 455 456 458 public void paAdd(PIndexedElem elem, Object conn) throws PException { 459 if (nextToAdd == -1) { 460 throw new PException("Wrong number of elements retrieved!"); 461 } 462 switch (typeCode) { 463 case PType.TYPECODE_BOOLEAN: 464 boolean_value[nextToAdd] = elem.pieGetBooleanElem(); 465 break; 466 case PType.TYPECODE_BYTE: 467 byte_value[nextToAdd] = elem.pieGetByteElem(); 468 break; 469 case PType.TYPECODE_CHAR: 470 char_value[nextToAdd] = elem.pieGetCharElem(); 471 break; 472 case PType.TYPECODE_SHORT: 473 short_value[nextToAdd] = elem.pieGetShortElem(); 474 break; 475 case PType.TYPECODE_INT: 476 int_value[nextToAdd] = elem.pieGetIntElem(); 477 break; 478 case PType.TYPECODE_LONG: 479 long_value[nextToAdd] = elem.pieGetLongElem(); 480 break; 481 case PType.TYPECODE_FLOAT: 482 float_value[nextToAdd] = elem.pieGetFloatElem(); 483 break; 484 case PType.TYPECODE_DOUBLE: 485 double_value[nextToAdd] = elem.pieGetDoubleElem(); 486 break; 487 case PType.TYPECODE_OBJBOOLEAN: 488 case PType.TYPECODE_OBJBYTE: 489 case PType.TYPECODE_OBJCHAR: 490 case PType.TYPECODE_OBJSHORT: 491 case PType.TYPECODE_OBJINT: 492 case PType.TYPECODE_OBJLONG: 493 case PType.TYPECODE_OBJFLOAT: 494 case PType.TYPECODE_OBJDOUBLE: 495 case PType.TYPECODE_STRING: 496 case PType.TYPECODE_DATE: 497 case PType.TYPECODE_BYTEARRAY: 498 case PType.TYPECODE_CHARARRAY: 499 case PType.TYPECODE_BIGDECIMAL: 500 case PType.TYPECODE_SERIALIZED: 501 object_value[nextToAdd] = ((BasicTypeIndexedElem) elem).getObjectValue(); 502 break; 503 default : 504 throw new PExceptionTyping("Wrong field type."); 505 } 506 nextToAdd ++; 507 } 508 509 public boolean paDeltaSupported() { 510 return false; 511 } 512 513 public int paGetNbElem() { 514 return nbElem; 515 } 516 517 public Iterator paIterator() { 518 return new GcIterator(this); 519 } 520 521 public void paSetNbElem(int nbelem) { 522 if (nbelem == -1) { 523 nextToAdd = 0; 524 return; 525 } 526 if (nbelem == nbElem) { 527 nextToAdd = 0; 528 return; 529 } 530 nextToAdd = -1; 531 Assert.assertEquals("Wrong number of elements", nbElem, nbelem); 532 } 533 534 536 public Object getMemoryInstance() { 537 return this; 538 } 539 540 542 public PIndexedElem createPIndexedElem() throws PException { 543 return new BasicTypeIndexedElem(typeCode); 544 } 545 546 class GcIterator implements Iterator { 548 private int nextToRead = 0; 549 private GcBasicTypeAccessor theGC; 550 551 GcIterator(GcBasicTypeAccessor gc) { 552 theGC = gc; 553 } 554 555 public boolean hasNext() { 556 return nextToRead < theGC.nbElem; 557 } 558 559 public Object next() { 560 if (!hasNext()) { 561 return null; 562 } 563 try { 564 BasicTypeIndexedElem pie = (BasicTypeIndexedElem) 565 theGC.createPIndexedElem(); 566 switch (theGC.typeCode) { 567 case PType.TYPECODE_BOOLEAN: 568 pie.pieSetBooleanElem(boolean_value[nextToRead]); 569 break; 570 case PType.TYPECODE_BYTE: 571 pie.pieSetByteElem(byte_value[nextToRead]); 572 break; 573 case PType.TYPECODE_CHAR: 574 pie.pieSetCharElem(char_value[nextToRead]); 575 break; 576 case PType.TYPECODE_SHORT: 577 pie.pieSetShortElem(short_value[nextToRead]); 578 break; 579 case PType.TYPECODE_INT: 580 pie.pieSetIntElem(int_value[nextToRead]); 581 break; 582 case PType.TYPECODE_LONG: 583 pie.pieSetLongElem(long_value[nextToRead]); 584 break; 585 case PType.TYPECODE_FLOAT: 586 pie.pieSetFloatElem(float_value[nextToRead]); 587 break; 588 case PType.TYPECODE_DOUBLE: 589 pie.pieSetDoubleElem(double_value[nextToRead]); 590 break; 591 case PType.TYPECODE_OBJBOOLEAN: 592 pie.pieSetObooleanElem((Boolean ) object_value[nextToRead]); 593 break; 594 case PType.TYPECODE_OBJBYTE: 595 pie.pieSetObyteElem((Byte ) object_value[nextToRead]); 596 break; 597 case PType.TYPECODE_OBJCHAR: 598 pie.pieSetOcharElem((Character ) object_value[nextToRead]); 599 break; 600 case PType.TYPECODE_OBJSHORT: 601 pie.pieSetOshortElem((Short ) object_value[nextToRead]); 602 break; 603 case PType.TYPECODE_OBJINT: 604 pie.pieSetOintElem((Integer ) object_value[nextToRead]); 605 break; 606 case PType.TYPECODE_OBJLONG: 607 pie.pieSetOlongElem((Long ) object_value[nextToRead]); 608 break; 609 case PType.TYPECODE_OBJFLOAT: 610 pie.pieSetOfloatElem((Float ) object_value[nextToRead]); 611 break; 612 case PType.TYPECODE_OBJDOUBLE: 613 pie.pieSetOdoubleElem((Double ) object_value[nextToRead]); 614 break; 615 case PType.TYPECODE_STRING: 616 pie.pieSetStringElem((String ) object_value[nextToRead]); 617 break; 618 case PType.TYPECODE_DATE: 619 pie.pieSetDateElem((Date ) object_value[nextToRead]); 620 break; 621 case PType.TYPECODE_BYTEARRAY: 622 pie.pieSetByteArrayElem((byte[]) object_value[nextToRead]); 623 break; 624 case PType.TYPECODE_CHARARRAY: 625 pie.pieSetCharArrayElem((char[]) object_value[nextToRead]); 626 break; 627 case PType.TYPECODE_BIGDECIMAL: 628 pie.pieSetBigDecimalElem((BigDecimal ) object_value[nextToRead]); 629 break; 630 case PType.TYPECODE_SERIALIZED: 631 pie.setObjectValue(object_value[nextToRead]); 632 break; 633 default : 634 throw new PExceptionTyping("Wrong field type."); 635 } 636 nextToRead++; 637 return pie; 638 } catch (PException e) { 639 e.printStackTrace(); 640 } 641 return null; 642 } 643 644 public void remove() { 645 } 646 } 647 } 648 649 class BasicTypeIndexedElem implements PIndexedElem { 650 private boolean boolean_value; 651 private byte byte_value; 652 private char char_value; 653 private short short_value; 654 private int int_value; 655 private long long_value; 656 private float float_value; 657 private double double_value; 658 private Object object_value; 659 private int typeCode; 660 661 public BasicTypeIndexedElem(int typecode) throws PException { 662 typeCode = typecode; 663 } 664 665 public Object getObjectValue() { 666 return object_value; 667 } 668 669 public void setObjectValue(Object o) { 670 object_value = o; 671 } 672 673 public byte getElemStatus() { 674 return 0; 675 } 676 677 public boolean pieGetBooleanElem() throws PException { 678 if (typeCode != PType.TYPECODE_BOOLEAN) { 679 throw new PException("Wrong type!!"); 680 } 681 return boolean_value; 682 } 683 684 public Boolean pieGetObooleanElem() throws PException { 685 if (typeCode != PType.TYPECODE_OBJBOOLEAN) { 686 throw new PException("Wrong type!!"); 687 } 688 return (Boolean ) object_value; 689 } 690 691 public byte pieGetByteElem() throws PException { 692 if (typeCode != PType.TYPECODE_BYTE) { 693 throw new PException("Wrong type!!"); 694 } 695 return byte_value; 696 } 697 698 public Byte pieGetObyteElem() throws PException { 699 if (typeCode != PType.TYPECODE_OBJBYTE) { 700 throw new PException("Wrong type!!"); 701 } 702 return (Byte ) object_value; 703 } 704 705 public byte pieGetByteIndexField(String fn) throws PException { 706 return 0; 707 } 708 709 public Byte pieGetObyteIndexField(String fn) throws PException { 710 return null; 711 } 712 713 public char pieGetCharElem() throws PException { 714 if (typeCode != PType.TYPECODE_CHAR) { 715 throw new PException("Wrong type!!"); 716 } 717 return char_value; 718 } 719 720 public Character pieGetOcharElem() throws PException { 721 if (typeCode != PType.TYPECODE_OBJCHAR) { 722 throw new PException("Wrong type!!"); 723 } 724 return (Character ) object_value; 725 } 726 727 public char pieGetCharIndexField(String fn) throws PException { 728 return 0; 729 } 730 731 public Character pieGetOcharIndexField(String fn) throws PException { 732 return null; 733 } 734 735 public short pieGetShortElem() throws PException { 736 if (typeCode != PType.TYPECODE_SHORT) { 737 throw new PException("Wrong type!!"); 738 } 739 return short_value; 740 } 741 742 public Short pieGetOshortElem() throws PException { 743 if (typeCode != PType.TYPECODE_OBJSHORT) { 744 throw new PException("Wrong type!!"); 745 } 746 return (Short ) object_value; 747 } 748 749 public short pieGetShortIndexField(String fn) throws PException { 750 return 0; 751 } 752 753 public Short pieGetOshortIndexField(String fn) throws PException { 754 return null; 755 } 756 757 public int pieGetIntElem() throws PException { 758 if (typeCode != PType.TYPECODE_INT) { 759 throw new PException("Wrong type!!"); 760 } 761 return int_value; 762 } 763 764 public Integer pieGetOintElem() throws PException { 765 if (typeCode != PType.TYPECODE_OBJINT) { 766 throw new PException("Wrong type!!"); 767 } 768 return (Integer ) object_value; 769 } 770 771 public int pieGetIntIndexField(String fn) throws PException { 772 return 0; 773 } 774 775 public Integer pieGetOintIndexField(String fn) throws PException { 776 return null; 777 } 778 779 public long pieGetLongElem() throws PException { 780 if (typeCode != PType.TYPECODE_LONG) { 781 throw new PException("Wrong type!!"); 782 } 783 return long_value; 784 } 785 786 public Long pieGetOlongElem() throws PException { 787 if (typeCode != PType.TYPECODE_OBJLONG) { 788 throw new PException("Wrong type!!"); 789 } 790 return (Long ) object_value; 791 } 792 793 public long pieGetLongIndexField(String fn) throws PException { 794 return 0; 795 } 796 797 public Long pieGetOlongIndexField(String fn) throws PException { 798 return null; 799 } 800 801 public float pieGetFloatElem() throws PException { 802 if (typeCode != PType.TYPECODE_FLOAT) { 803 throw new PException("Wrong type!!"); 804 } 805 return float_value; 806 } 807 808 public Float pieGetOfloatElem() throws PException { 809 if (typeCode != PType.TYPECODE_OBJFLOAT) { 810 throw new PException("Wrong type!!"); 811 } 812 return (Float ) object_value; 813 } 814 815 public double pieGetDoubleElem() throws PException { 816 if (typeCode != PType.TYPECODE_DOUBLE) { 817 throw new PException("Wrong type!!"); 818 } 819 return double_value; 820 } 821 822 public Double pieGetOdoubleElem() throws PException { 823 if (typeCode != PType.TYPECODE_OBJDOUBLE) { 824 throw new PException("Wrong type!!"); 825 } 826 return (Double ) object_value; 827 } 828 829 public String pieGetStringElem() throws PException { 830 if (typeCode != PType.TYPECODE_STRING) { 831 throw new PException("Wrong type!!"); 832 } 833 return (String ) object_value; 834 } 835 836 public String pieGetStringIndexField(String fn) throws PException { 837 return null; 838 } 839 840 public Date pieGetDateElem() throws PException { 841 if (typeCode != PType.TYPECODE_DATE) { 842 throw new PException("Wrong type!!"); 843 } 844 return (Date ) object_value; 845 } 846 847 public Date pieGetDateIndexField(String fn) throws PException { 848 return null; 849 } 850 851 public char[] pieGetCharArrayElem() throws PException { 852 if (typeCode != PType.TYPECODE_CHARARRAY) { 853 throw new PException("Wrong type!!"); 854 } 855 return (char[]) object_value; 856 } 857 858 public byte[] pieGetByteArrayElem() throws PException { 859 if (typeCode != PType.TYPECODE_BYTEARRAY) { 860 throw new PException("Wrong type!!"); 861 } 862 return (byte[]) object_value; 863 } 864 865 public Serializable pieGetSerializedElem() throws PException { 866 if (typeCode != PType.TYPECODE_SERIALIZED) { 867 throw new PException("Wrong type!!"); 868 } 869 return (Serializable ) object_value; 870 } 871 872 public BigDecimal pieGetBigDecimalElem() throws PException { 873 if (typeCode != PType.TYPECODE_BIGDECIMAL) { 874 throw new PException("Wrong type!!"); 875 } 876 return (BigDecimal ) object_value; 877 } 878 879 public BigInteger pieGetBigIntegerElem() throws PException { 880 if (typeCode != PType.TYPECODE_BIGINTEGER) { 881 throw new PException("Wrong type!!"); 882 } 883 return (BigInteger ) object_value; 884 } 885 886 public PName pieGetRefElem() throws PException { 887 throw new PException("Wrong type!!"); 888 } 889 890 public void pieSetBooleanElem(boolean value) throws PException { 891 if (typeCode != PType.TYPECODE_BOOLEAN) { 892 throw new PException("Wrong type!!"); 893 } 894 boolean_value = value; 895 } 896 897 public void pieSetObooleanElem(Boolean value) throws PException { 898 if (typeCode != PType.TYPECODE_OBJBOOLEAN) { 899 throw new PException("Wrong type!!"); 900 } 901 object_value = value; 902 } 903 904 public void pieSetByteElem(byte value) throws PException { 905 if (typeCode != PType.TYPECODE_BYTE) { 906 throw new PException("Wrong type!!"); 907 } 908 byte_value = value; 909 } 910 911 public void pieSetObyteElem(Byte value) throws PException { 912 if (typeCode != PType.TYPECODE_OBJBYTE) { 913 throw new PException("Wrong type!!"); 914 } 915 object_value = value; 916 } 917 918 public void pieSetByteIndexField(String fn, byte value) throws PException { 919 } 920 921 public void pieSetObyteIndexField(String fn, Byte value) throws PException { 922 } 923 924 public void pieSetCharElem(char value) throws PException { 925 if (typeCode != PType.TYPECODE_CHAR) { 926 throw new PException("Wrong type!!"); 927 } 928 char_value = value; 929 } 930 931 public void pieSetOcharElem(Character value) throws PException { 932 if (typeCode != PType.TYPECODE_OBJCHAR) { 933 throw new PException("Wrong type!!"); 934 } 935 object_value = value; 936 } 937 938 public void pieSetCharIndexField(String fn, char value) throws PException { 939 } 940 941 public void pieSetOcharIndexField(String fn, Character value) throws PException { 942 } 943 944 public void pieSetShortElem(short value) throws PException { 945 if (typeCode != PType.TYPECODE_SHORT) { 946 throw new PException("Wrong type!!"); 947 } 948 short_value = value; 949 } 950 951 public void pieSetOshortElem(Short value) throws PException { 952 if (typeCode != PType.TYPECODE_OBJSHORT) { 953 throw new PException("Wrong type!!"); 954 } 955 object_value = value; 956 } 957 958 public void pieSetShortIndexField(String fn, short value) throws PException { 959 } 960 961 public void pieSetOshortIndexField(String fn, Short value) throws PException { 962 } 963 964 public void pieSetIntElem(int value) throws PException { 965 if (typeCode != PType.TYPECODE_INT) { 966 throw new PException("Wrong type!!"); 967 } 968 int_value = value; 969 } 970 971 public void pieSetOintElem(Integer value) throws PException { 972 if (typeCode != PType.TYPECODE_OBJINT) { 973 throw new PException("Wrong type!!"); 974 } 975 object_value = value; 976 } 977 978 public void pieSetIntIndexField(String fn, int value) throws PException { 979 } 980 981 public void pieSetOintIndexField(String fn, Integer value) throws PException { 982 } 983 984 public void pieSetLongElem(long value) throws PException { 985 if (typeCode != PType.TYPECODE_LONG) { 986 throw new PException("Wrong type!!"); 987 } 988 long_value = value; 989 } 990 991 public void pieSetOlongElem(Long value) throws PException { 992 if (typeCode != PType.TYPECODE_OBJLONG) { 993 throw new PException("Wrong type!!"); 994 } 995 object_value = value; 996 } 997 998 public void pieSetLongIndexField(String fn, long value) throws PException { 999 } 1000 1001 public void pieSetOlongIndexField(String fn, Long value) throws PException { 1002 } 1003 1004 public void pieSetFloatElem(float value) throws PException { 1005 if (typeCode != PType.TYPECODE_FLOAT) { 1006 throw new PException("Wrong type!!"); 1007 } 1008 float_value = value; 1009 } 1010 1011 public void pieSetOfloatElem(Float value) throws PException { 1012 if (typeCode != PType.TYPECODE_OBJFLOAT) { 1013 throw new PException("Wrong type!!"); 1014 } 1015 object_value = value; 1016 } 1017 1018 public void pieSetDoubleElem(double value) throws PException { 1019 if (typeCode != PType.TYPECODE_DOUBLE) { 1020 throw new PException("Wrong type!!"); 1021 } 1022 double_value = value; 1023 } 1024 1025 public void pieSetOdoubleElem(Double value) throws PException { 1026 if (typeCode != PType.TYPECODE_OBJDOUBLE) { 1027 throw new PException("Wrong type!!"); 1028 } 1029 object_value = value; 1030 } 1031 1032 public void pieSetStringElem(String value) throws PException { 1033 if (typeCode != PType.TYPECODE_STRING) { 1034 throw new PException("Wrong type!!"); 1035 } 1036 object_value = value; 1037 } 1038 1039 public void pieSetStringIndexField(String fn, String value) throws PException { 1040 } 1041 1042 public void pieSetDateElem(Date value) throws PException { 1043 if (typeCode != PType.TYPECODE_DATE) { 1044 throw new PException("Wrong type!!"); 1045 } 1046 object_value = value; 1047 } 1048 1049 public void pieSetDateIndexField(String fn, Date value) throws PException { 1050 } 1051 1052 public void pieSetCharArrayElem(char[] value) throws PException { 1053 if (typeCode != PType.TYPECODE_CHARARRAY) { 1054 throw new PException("Wrong type!!"); 1055 } 1056 object_value = value; 1057 } 1058 1059 public void pieSetByteArrayElem(byte[] value) throws PException { 1060 if (typeCode != PType.TYPECODE_BYTEARRAY) { 1061 throw new PException("Wrong type!!"); 1062 } 1063 object_value = value; 1064 } 1065 1066 public void pieSetSerializedElem(Serializable value) throws PException { 1067 if (typeCode != PType.TYPECODE_SERIALIZED) { 1068 throw new PException("Wrong type!!"); 1069 } 1070 object_value = value; 1071 } 1072 1073 public void pieSetBigDecimalElem(BigDecimal value) throws PException { 1074 if (typeCode != PType.TYPECODE_BIGDECIMAL) { 1075 throw new PException("Wrong type!!"); 1076 } 1077 object_value = value; 1078 } 1079 1080 public void pieSetBigIntegerElem(BigInteger value) throws PException { 1081 if (typeCode != PType.TYPECODE_BIGINTEGER) { 1082 throw new PException("Wrong type!!"); 1083 } 1084 object_value = value; 1085 } 1086 1087 public void pieSetRefElem(PName value) throws PException { 1088 throw new PException("Wrong type!!"); 1089 } 1090} 1091 | Popular Tags |