1 7 package com.sun.corba.se.impl.encoding; 8 9 import java.io.Serializable ; 10 import java.io.ObjectInputStream ; 11 import java.io.ByteArrayInputStream ; 12 import java.io.IOException ; 13 import java.nio.ByteBuffer ; 14 import java.math.BigDecimal ; 15 import java.util.LinkedList ; 16 17 import com.sun.corba.se.spi.orb.ORB; 18 import com.sun.corba.se.spi.ior.IOR; 19 import com.sun.corba.se.spi.ior.IORFactories; 20 import com.sun.corba.se.spi.ior.iiop.GIOPVersion; 21 import com.sun.corba.se.spi.logging.CORBALogDomains; 22 import com.sun.corba.se.spi.presentation.rmi.StubAdapter; 23 import com.sun.corba.se.spi.presentation.rmi.PresentationManager; 24 import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults; 25 26 import com.sun.corba.se.impl.util.Utility; 27 import com.sun.corba.se.impl.orbutil.ORBUtility; 28 import com.sun.corba.se.impl.corba.TypeCodeImpl; 29 import com.sun.corba.se.impl.util.RepositoryId; 30 import com.sun.corba.se.impl.orbutil.ORBConstants; 31 import com.sun.corba.se.impl.logging.ORBUtilSystemException; 32 import com.sun.corba.se.impl.protocol.giopmsgheaders.Message; 33 34 import org.omg.CORBA.Any ; 35 import org.omg.CORBA.TypeCode ; 36 import org.omg.CORBA.Principal ; 37 import org.omg.CORBA.portable.IDLEntity ; 38 39 58 public class IDLJavaSerializationInputStream extends CDRInputStreamBase { 59 60 private ORB orb; 61 private int bufSize; 62 private ByteBuffer buffer; 63 private byte encodingVersion; 64 private ObjectInputStream is; 65 private _ByteArrayInputStream bis; 66 private BufferManagerRead bufferManager; 67 68 private final int directReadLength = Message.GIOPMessageHeaderLength + 4; 70 71 private boolean markOn; 73 private int peekIndex, peekCount; 74 private LinkedList markedItemQ = new LinkedList (); 75 76 protected ORBUtilSystemException wrapper; 77 78 class _ByteArrayInputStream extends ByteArrayInputStream { 79 80 _ByteArrayInputStream(byte[] buf) { 81 super(buf); 82 } 83 84 int getPosition() { 85 return this.pos; 86 } 87 88 void setPosition(int value) { 89 if (value < 0 || value > count) { 90 throw new IndexOutOfBoundsException (); 91 } 92 this.pos = value; 93 } 94 } 95 96 class MarshalObjectInputStream extends ObjectInputStream { 97 98 ORB orb; 99 100 MarshalObjectInputStream(java.io.InputStream out, ORB orb) 101 throws IOException { 102 103 super(out); 104 this.orb = orb; 105 106 java.security.AccessController.doPrivileged( 107 new java.security.PrivilegedAction () { 108 public Object run() { 109 enableResolveObject(true); 111 return null; 112 } 113 } 114 ); 115 } 116 117 120 protected final Object resolveObject(Object obj) throws IOException { 121 try { 122 if (StubAdapter.isStub(obj)) { 123 StubAdapter.connect(obj, orb); 124 } 125 } catch (java.rmi.RemoteException re) { 126 IOException ie = new IOException ("resolveObject failed"); 127 ie.initCause(re); 128 throw ie; 129 } 130 return obj; 131 } 132 } 133 134 public IDLJavaSerializationInputStream(byte encodingVersion) { 135 super(); 136 this.encodingVersion = encodingVersion; 137 } 138 139 public void init(org.omg.CORBA.ORB orb, 140 ByteBuffer byteBuffer, 141 int bufSize, 142 boolean littleEndian, 143 BufferManagerRead bufferManager) { 144 this.orb = (ORB) orb; 145 this.bufSize = bufSize; 146 this.bufferManager = bufferManager; 147 buffer = byteBuffer; 148 wrapper = 149 ORBUtilSystemException.get((ORB)orb, CORBALogDomains.RPC_ENCODING); 150 151 byte[] buf; 152 if (buffer.hasArray()) { 153 buf = buffer.array(); 154 } else { 155 buf = new byte[bufSize]; 156 buffer.get(buf); 157 } 158 bis = new _ByteArrayInputStream(buf); 161 } 162 163 private void initObjectInputStream() { 165 if (is != null) { 167 throw wrapper.javaStreamInitFailed(); 168 } 169 try { 170 is = new MarshalObjectInputStream(bis, orb); 171 } catch (Exception e) { 172 throw wrapper.javaStreamInitFailed(e); 173 } 174 } 175 176 178 180 public boolean read_boolean() { 181 if (!markOn && !(markedItemQ.isEmpty())) { return ((Boolean )markedItemQ.removeFirst()).booleanValue(); 183 } 184 if (markOn && !(markedItemQ.isEmpty()) && 185 (peekIndex < peekCount)) { return ((Boolean )markedItemQ.get(peekIndex++)).booleanValue(); 187 } 188 try { 189 boolean value = is.readBoolean(); 190 if (markOn) { markedItemQ.addLast(Boolean.valueOf(value)); 192 } 193 return value; 194 } catch (Exception e) { 195 throw wrapper.javaSerializationException(e, "read_boolean"); 196 } 197 } 198 199 public char read_char() { 200 if (!markOn && !(markedItemQ.isEmpty())) { return ((Character )markedItemQ.removeFirst()).charValue(); 202 } 203 if (markOn && !(markedItemQ.isEmpty()) && 204 (peekIndex < peekCount)) { return ((Character )markedItemQ.get(peekIndex++)).charValue(); 206 } 207 try { 208 char value = is.readChar(); 209 if (markOn) { markedItemQ.addLast(new Character (value)); 211 } 212 return value; 213 } catch (Exception e) { 214 throw wrapper.javaSerializationException(e, "read_char"); 215 } 216 } 217 218 public char read_wchar() { 219 return this.read_char(); 220 } 221 222 public byte read_octet() { 223 224 if (bis.getPosition() < directReadLength) { 226 byte b = (byte) bis.read(); 227 if (bis.getPosition() == directReadLength) { 228 initObjectInputStream(); 229 } 230 return b; 231 } 232 233 if (!markOn && !(markedItemQ.isEmpty())) { return ((Byte )markedItemQ.removeFirst()).byteValue(); 235 } 236 237 if (markOn && !(markedItemQ.isEmpty()) && 238 (peekIndex < peekCount)) { return ((Byte )markedItemQ.get(peekIndex++)).byteValue(); 240 } 241 242 try { 243 byte value = is.readByte(); 244 if (markOn) { markedItemQ.addLast(new Byte (value)); 247 } 248 return value; 249 } catch (Exception e) { 250 throw wrapper.javaSerializationException(e, "read_octet"); 251 } 252 } 253 254 public short read_short() { 255 if (!markOn && !(markedItemQ.isEmpty())) { return ((Short )markedItemQ.removeFirst()).shortValue(); 257 } 258 if (markOn && !(markedItemQ.isEmpty()) && 259 (peekIndex < peekCount)) { return ((Short )markedItemQ.get(peekIndex++)).shortValue(); 261 } 262 263 try { 264 short value = is.readShort(); 265 if (markOn) { markedItemQ.addLast(new Short (value)); 267 } 268 return value; 269 } catch (Exception e) { 270 throw wrapper.javaSerializationException(e, "read_short"); 271 } 272 } 273 274 public short read_ushort() { 275 return this.read_short(); 276 } 277 278 public int read_long() { 279 280 if (bis.getPosition() < directReadLength) { 282 283 int b1 = (bis.read() << 24) & 0xFF000000; 286 int b2 = (bis.read() << 16) & 0x00FF0000; 287 int b3 = (bis.read() << 8) & 0x0000FF00; 288 int b4 = (bis.read() << 0) & 0x000000FF; 289 290 if (bis.getPosition() == directReadLength) { 291 initObjectInputStream(); 292 } else if (bis.getPosition() > directReadLength) { 293 wrapper.javaSerializationException("read_long"); 296 } 297 298 return (b1 | b2 | b3 | b4); 299 } 300 301 if (!markOn && !(markedItemQ.isEmpty())) { return ((Integer )markedItemQ.removeFirst()).intValue(); 303 } 304 305 if (markOn && !(markedItemQ.isEmpty()) && 306 (peekIndex < peekCount)) { return ((Integer )markedItemQ.get(peekIndex++)).intValue(); 308 } 309 310 try { 311 int value = is.readInt(); 312 if (markOn) { markedItemQ.addLast(new Integer (value)); 314 } 315 return value; 316 } catch (Exception e) { 317 throw wrapper.javaSerializationException(e, "read_long"); 318 } 319 } 320 321 public int read_ulong() { 322 return this.read_long(); 323 } 324 325 public long read_longlong() { 326 if (!markOn && !(markedItemQ.isEmpty())) { return ((Long )markedItemQ.removeFirst()).longValue(); 328 } 329 if (markOn && !(markedItemQ.isEmpty()) && 330 (peekIndex < peekCount)) { return ((Long )markedItemQ.get(peekIndex++)).longValue(); 332 } 333 334 try { 335 long value = is.readLong(); 336 if (markOn) { markedItemQ.addLast(new Long (value)); 338 } 339 return value; 340 } catch (Exception e) { 341 throw wrapper.javaSerializationException(e, "read_longlong"); 342 } 343 } 344 345 public long read_ulonglong() { 346 return read_longlong(); 347 } 348 349 public float read_float() { 350 if (!markOn && !(markedItemQ.isEmpty())) { return ((Float )markedItemQ.removeFirst()).floatValue(); 352 } 353 if (markOn && !(markedItemQ.isEmpty()) && 354 (peekIndex < peekCount)) { return ((Float )markedItemQ.get(peekIndex++)).floatValue(); 356 } 357 358 try { 359 float value = is.readFloat(); 360 if (markOn) { markedItemQ.addLast(new Float (value)); 362 } 363 return value; 364 } catch (Exception e) { 365 throw wrapper.javaSerializationException(e, "read_float"); 366 } 367 } 368 369 public double read_double() { 370 if (!markOn && !(markedItemQ.isEmpty())) { return ((Double )markedItemQ.removeFirst()).doubleValue(); 372 } 373 if (markOn && !(markedItemQ.isEmpty()) && 374 (peekIndex < peekCount)) { return ((Double )markedItemQ.get(peekIndex++)).doubleValue(); 376 } 377 378 try { 379 double value = is.readDouble(); 380 if (markOn) { markedItemQ.addLast(new Double (value)); 382 } 383 return value; 384 } catch (Exception e) { 385 throw wrapper.javaSerializationException(e, "read_double"); 386 } 387 } 388 389 391 public String read_string() { 392 if (!markOn && !(markedItemQ.isEmpty())) { return (String ) markedItemQ.removeFirst(); 394 } 395 if (markOn && !(markedItemQ.isEmpty()) && 396 (peekIndex < peekCount)) { return (String ) markedItemQ.get(peekIndex++); 398 } 399 try { 400 String value = is.readUTF(); 401 if (markOn) { markedItemQ.addLast(value); 403 } 404 return value; 405 } catch (Exception e) { 406 throw wrapper.javaSerializationException(e, "read_string"); 407 } 408 } 409 410 public String read_wstring() { 411 if (!markOn && !(markedItemQ.isEmpty())) { return (String ) markedItemQ.removeFirst(); 413 } 414 if (markOn && !(markedItemQ.isEmpty()) && 415 (peekIndex < peekCount)) { return (String ) markedItemQ.get(peekIndex++); 417 } 418 try { 419 String value = (String ) is.readObject(); 420 if (markOn) { markedItemQ.addLast(value); 422 } 423 return value; 424 } catch (Exception e) { 425 throw wrapper.javaSerializationException(e, "read_wstring"); 426 } 427 } 428 429 431 public void read_boolean_array(boolean[] value, int offset, int length){ 432 for(int i = 0; i < length; i++) { 433 value[i+offset] = read_boolean(); 434 } 435 } 436 437 public void read_char_array(char[] value, int offset, int length) { 438 for(int i=0; i < length; i++) { 439 value[i+offset] = read_char(); 440 } 441 } 442 443 public void read_wchar_array(char[] value, int offset, int length) { 444 read_char_array(value, offset, length); 445 } 446 447 public void read_octet_array(byte[] value, int offset, int length) { 448 for(int i=0; i < length; i++) { 449 value[i+offset] = read_octet(); 450 } 451 462 } 463 464 public void read_short_array(short[] value, int offset, int length) { 465 for(int i=0; i < length; i++) { 466 value[i+offset] = read_short(); 467 } 468 } 469 470 public void read_ushort_array(short[] value, int offset, int length) { 471 read_short_array(value, offset, length); 472 } 473 474 public void read_long_array(int[] value, int offset, int length) { 475 for(int i=0; i < length; i++) { 476 value[i+offset] = read_long(); 477 } 478 } 479 480 public void read_ulong_array(int[] value, int offset, int length) { 481 read_long_array(value, offset, length); 482 } 483 484 public void read_longlong_array(long[] value, int offset, int length) { 485 for(int i=0; i < length; i++) { 486 value[i+offset] = read_longlong(); 487 } 488 } 489 490 public void read_ulonglong_array(long[] value, int offset, int length) { 491 read_longlong_array(value, offset, length); 492 } 493 494 public void read_float_array(float[] value, int offset, int length) { 495 for(int i=0; i < length; i++) { 496 value[i+offset] = read_float(); 497 } 498 } 499 500 public void read_double_array(double[] value, int offset, int length) { 501 for(int i=0; i < length; i++) { 502 value[i+offset] = read_double(); 503 } 504 } 505 506 508 public org.omg.CORBA.Object read_Object() { 509 return read_Object(null); 510 } 511 512 public TypeCode read_TypeCode() { 513 TypeCodeImpl tc = new TypeCodeImpl(orb); 514 tc.read_value(parent); 515 return tc; 516 } 517 518 public Any read_any() { 519 520 Any any = orb.create_any(); 521 TypeCodeImpl tc = new TypeCodeImpl(orb); 522 523 525 try { 532 tc.read_value(parent); 533 } catch (org.omg.CORBA.MARSHAL ex) { 534 if (tc.kind().value() != org.omg.CORBA.TCKind._tk_value) { 535 throw ex; 536 } 537 ex.printStackTrace(); 540 } 541 542 any.read_value(parent, tc); 544 545 return any; 546 } 547 548 public Principal read_Principal() { 549 int len = read_long(); 552 byte[] pvalue = new byte[len]; 553 read_octet_array(pvalue,0,len); 554 Principal p = new com.sun.corba.se.impl.corba.PrincipalImpl(); 555 p.name(pvalue); 556 return p; 557 } 558 559 public BigDecimal read_fixed() { 560 return new BigDecimal (read_fixed_buffer().toString()); 561 } 562 563 private StringBuffer read_fixed_buffer() { 571 StringBuffer buffer = new StringBuffer (64); 572 byte doubleDigit; 573 int firstDigit; 574 int secondDigit; 575 boolean wroteFirstDigit = false; 576 boolean more = true; 577 while (more) { 578 doubleDigit = read_octet(); 579 firstDigit = (int)((doubleDigit & 0xf0) >> 4); 580 secondDigit = (int)(doubleDigit & 0x0f); 581 if (wroteFirstDigit || firstDigit != 0) { 582 buffer.append(Character.forDigit(firstDigit, 10)); 583 wroteFirstDigit = true; 584 } 585 if (secondDigit == 12) { 586 if ( ! wroteFirstDigit) { 588 return new StringBuffer ("0.0"); 590 } else { 591 } 594 more = false; 595 } else if (secondDigit == 13) { 596 buffer.insert(0, '-'); 598 more = false; 599 } else { 600 buffer.append(Character.forDigit(secondDigit, 10)); 601 wroteFirstDigit = true; 602 } 603 } 604 return buffer; 605 } 606 607 public org.omg.CORBA.Object read_Object(java.lang.Class clz) { 608 609 IOR ior = IORFactories.makeIOR(parent) ; 611 if (ior.isNil()) { 612 return null; 613 } 614 615 PresentationManager.StubFactoryFactory sff = 616 ORB.getStubFactoryFactory(); 617 String codeBase = ior.getProfile().getCodebase(); 618 PresentationManager.StubFactory stubFactory = null; 619 620 if (clz == null) { 621 RepositoryId rid = RepositoryId.cache.getId(ior.getTypeId() ); 622 String className = rid.getClassName(); 623 boolean isIDLInterface = rid.isIDLType(); 624 625 if (className == null || className.equals( "" )) { 626 stubFactory = null; 627 } else { 628 try { 629 stubFactory = sff.createStubFactory(className, 630 isIDLInterface, codeBase, (Class ) null, 631 (ClassLoader ) null); 632 } catch (Exception exc) { 633 stubFactory = null ; 638 } 639 } 640 } else if (StubAdapter.isStubClass(clz)) { 641 stubFactory = PresentationDefaults.makeStaticStubFactory(clz); 642 } else { 643 boolean isIDL = IDLEntity .class.isAssignableFrom(clz); 645 646 stubFactory = sff.createStubFactory( 647 clz.getName(), isIDL, codeBase, clz, clz.getClassLoader()); 648 } 649 650 return CDRInputStream_1_0.internalIORToObject(ior, stubFactory, orb); 651 } 652 653 public org.omg.CORBA.ORB orb() { 654 return this.orb; 655 } 656 657 659 public java.io.Serializable read_value() { 660 if (!markOn && !(markedItemQ.isEmpty())) { return (Serializable ) markedItemQ.removeFirst(); 662 } 663 if (markOn && !(markedItemQ.isEmpty()) && 664 (peekIndex < peekCount)) { return (Serializable ) markedItemQ.get(peekIndex++); 666 } 667 try { 668 Serializable value = (java.io.Serializable ) is.readObject(); 669 if (markOn) { markedItemQ.addLast(value); 671 } 672 return value; 673 } catch (Exception e) { 674 throw wrapper.javaSerializationException(e, "read_value"); 675 } 676 } 677 678 public java.io.Serializable read_value(java.lang.Class clz) { 679 return read_value(); 680 } 681 682 public java.io.Serializable read_value( 683 org.omg.CORBA.portable.BoxedValueHelper factory) { 684 return read_value(); 685 } 686 687 public java.io.Serializable read_value(java.lang.String rep_id) { 688 return read_value(); 689 } 690 691 public java.io.Serializable read_value(java.io.Serializable value) { 692 return read_value(); 693 } 694 695 public java.lang.Object read_abstract_interface() { 696 return read_abstract_interface(null); 697 } 698 699 public java.lang.Object read_abstract_interface(java.lang.Class clz) { 700 boolean isObject = read_boolean(); 701 if (isObject) { 702 return read_Object(clz); 703 } else { 704 return read_value(); 705 } 706 } 707 708 public void consumeEndian() { 710 throw wrapper.giopVersionError(); 711 } 712 713 public int getPosition() { 714 try { 715 return bis.getPosition(); 716 } catch (Exception e) { 717 throw wrapper.javaSerializationException(e, "getPosition"); 718 } 719 } 720 721 public java.lang.Object read_Abstract() { 723 return read_abstract_interface(); 724 } 725 726 public java.io.Serializable read_Value() { 727 return read_value(); 728 } 729 730 public void read_any_array (org.omg.CORBA.AnySeqHolder seq, 731 int offset, int length) { 732 read_any_array(seq.value, offset, length); 733 } 734 735 private final void read_any_array(org.omg.CORBA.Any [] value, 736 int offset, int length) { 737 for(int i=0; i < length; i++) { 738 value[i+offset] = read_any(); 739 } 740 } 741 742 public void read_boolean_array (org.omg.CORBA.BooleanSeqHolder seq, 743 int offset, int length){ 744 read_boolean_array(seq.value, offset, length); 745 } 746 747 public void read_char_array (org.omg.CORBA.CharSeqHolder seq, 748 int offset, int length){ 749 read_char_array(seq.value, offset, length); 750 } 751 752 public void read_wchar_array (org.omg.CORBA.WCharSeqHolder seq, 753 int offset, int length){ 754 read_wchar_array(seq.value, offset, length); 755 } 756 757 public void read_octet_array (org.omg.CORBA.OctetSeqHolder seq, 758 int offset, int length){ 759 read_octet_array(seq.value, offset, length); 760 } 761 762 public void read_short_array (org.omg.CORBA.ShortSeqHolder seq, 763 int offset, int length){ 764 read_short_array(seq.value, offset, length); 765 } 766 767 public void read_ushort_array (org.omg.CORBA.UShortSeqHolder seq, 768 int offset, int length){ 769 read_ushort_array(seq.value, offset, length); 770 } 771 772 public void read_long_array (org.omg.CORBA.LongSeqHolder seq, 773 int offset, int length){ 774 read_long_array(seq.value, offset, length); 775 } 776 777 public void read_ulong_array (org.omg.CORBA.ULongSeqHolder seq, 778 int offset, int length){ 779 read_ulong_array(seq.value, offset, length); 780 } 781 782 public void read_ulonglong_array (org.omg.CORBA.ULongLongSeqHolder seq, 783 int offset, int length){ 784 read_ulonglong_array(seq.value, offset, length); 785 } 786 787 public void read_longlong_array (org.omg.CORBA.LongLongSeqHolder seq, 788 int offset, int length){ 789 read_longlong_array(seq.value, offset, length); 790 } 791 792 public void read_float_array (org.omg.CORBA.FloatSeqHolder seq, 793 int offset, int length){ 794 read_float_array(seq.value, offset, length); 795 } 796 797 public void read_double_array (org.omg.CORBA.DoubleSeqHolder seq, 798 int offset, int length){ 799 read_double_array(seq.value, offset, length); 800 } 801 802 804 public String [] _truncatable_ids() { 805 throw wrapper.giopVersionError(); 806 } 807 808 812 818 public void mark(int readLimit) { 819 if (markOn || is == null) { 822 throw wrapper.javaSerializationException("mark"); 823 } 824 markOn = true; 825 if (!(markedItemQ.isEmpty())) { 826 peekIndex = 0; 827 peekCount = markedItemQ.size(); 828 } 829 836 } 837 838 public void reset() { 839 markOn = false; 840 peekIndex = 0; 841 peekCount = 0; 842 853 } 854 855 public boolean markSupported() { 866 return true; 867 } 868 869 public CDRInputStreamBase dup() { 871 872 CDRInputStreamBase result = null ; 873 874 try { 875 result = (CDRInputStreamBase) this.getClass().newInstance(); 876 } catch (Exception e) { 877 throw wrapper.couldNotDuplicateCdrInputStream(e); 878 } 879 880 result.init(this.orb, this.buffer, this.bufSize, false, null); 881 882 ((IDLJavaSerializationInputStream)result).skipBytes(getPosition()); 884 885 ((IDLJavaSerializationInputStream)result). 887 setMarkData(markOn, peekIndex, peekCount, 888 (LinkedList ) markedItemQ.clone()); 889 890 return result; 891 } 892 893 void skipBytes(int len) { 895 try { 896 is.skipBytes(len); 897 } catch (Exception e) { 898 throw wrapper.javaSerializationException(e, "skipBytes"); 899 } 900 } 901 902 void setMarkData(boolean markOn, int peekIndex, int peekCount, 904 LinkedList markedItemQ) { 905 this.markOn = markOn; 906 this.peekIndex = peekIndex; 907 this.peekCount = peekCount; 908 this.markedItemQ = markedItemQ; 909 } 910 911 public java.math.BigDecimal read_fixed(short digits, short scale) { 913 StringBuffer buffer = read_fixed_buffer(); 915 if (digits != buffer.length()) 916 throw wrapper.badFixed( new Integer (digits), 917 new Integer (buffer.length()) ) ; 918 buffer.insert(digits - scale, '.'); 919 return new BigDecimal (buffer.toString()); 920 } 921 922 public boolean isLittleEndian() { 924 throw wrapper.giopVersionError(); 925 } 926 927 void setHeaderPadding(boolean headerPadding) { 929 } 932 933 935 public ByteBuffer getByteBuffer() { 936 throw wrapper.giopVersionError(); 937 } 938 939 public void setByteBuffer(ByteBuffer byteBuffer) { 940 throw wrapper.giopVersionError(); 941 } 942 943 public void setByteBufferWithInfo(ByteBufferWithInfo bbwi) { 944 throw wrapper.giopVersionError(); 945 } 946 947 public int getBufferLength() { 948 return bufSize; 949 } 950 951 public void setBufferLength(int value) { 952 } 955 956 public int getIndex() { 957 return bis.getPosition(); 958 } 959 960 public void setIndex(int value) { 961 try { 962 bis.setPosition(value); 963 } catch (IndexOutOfBoundsException e) { 964 throw wrapper.javaSerializationException(e, "setIndex"); 965 } 966 } 967 968 public void orb(org.omg.CORBA.ORB orb) { 969 this.orb = (ORB) orb; 970 } 971 972 public BufferManagerRead getBufferManager() { 973 return bufferManager; 974 } 975 976 public GIOPVersion getGIOPVersion() { 977 return GIOPVersion.V1_2; 978 } 979 980 com.sun.org.omg.SendingContext.CodeBase getCodeBase() { 981 return parent.getCodeBase(); 982 } 983 984 void printBuffer() { 985 byte[] buf = this.buffer.array(); 986 987 System.out.println("+++++++ Input Buffer ++++++++"); 988 System.out.println(); 989 System.out.println("Current position: " + getPosition()); 990 System.out.println("Total length : " + this.bufSize); 991 System.out.println(); 992 993 char[] charBuf = new char[16]; 994 995 try { 996 997 for (int i = 0; i < buf.length; i += 16) { 998 999 int j = 0; 1000 1001 while (j < 16 && j + i < buf.length) { 1006 int k = buf[i + j]; 1007 if (k < 0) 1008 k = 256 + k; 1009 String hex = Integer.toHexString(k); 1010 if (hex.length() == 1) 1011 hex = "0" + hex; 1012 System.out.print(hex + " "); 1013 j++; 1014 } 1015 1016 while (j < 16) { 1020 System.out.print(" "); 1021 j++; 1022 } 1023 1024 int x = 0; 1027 1028 while (x < 16 && x + i < buf.length) { 1029 if (ORBUtility.isPrintable((char)buf[i + x])) { 1030 charBuf[x] = (char) buf[i + x]; 1031 } else { 1032 charBuf[x] = '.'; 1033 } 1034 x++; 1035 } 1036 System.out.println(new String (charBuf, 0, x)); 1037 } 1038 } catch (Throwable t) { 1039 t.printStackTrace(); 1040 } 1041 System.out.println("++++++++++++++++++++++++++++++"); 1042 } 1043 1044 void alignOnBoundary(int octetBoundary) { 1045 throw wrapper.giopVersionError(); 1046 } 1047 1048 void performORBVersionSpecificInit() { 1049 } 1051 1052 public void resetCodeSetConverters() { 1053 } 1055 1056 1058 public void start_value() { 1059 throw wrapper.giopVersionError(); 1060 } 1061 1062 public void end_value() { 1063 throw wrapper.giopVersionError(); 1064 } 1065} 1066 | Popular Tags |