1 7 package com.sun.corba.se.impl.encoding; 8 9 import com.sun.corba.se.spi.ior.iiop.GIOPVersion; 10 11 public class CDRInputStream_1_1 extends CDRInputStream_1_0 12 { 13 protected int fragmentOffset = 0; 15 16 public GIOPVersion getGIOPVersion() { 17 return GIOPVersion.V1_1; 18 } 19 20 public CDRInputStreamBase dup() { 22 CDRInputStreamBase result = super.dup(); 23 24 ((CDRInputStream_1_1)result).fragmentOffset = this.fragmentOffset; 25 26 return result; 27 } 28 29 protected int get_offset() { 30 return bbwi.position() + fragmentOffset; 31 } 32 33 protected void alignAndCheck(int align, int n) { 34 35 36 checkBlockLength(align, n); 37 38 int alignment = computeAlignment(bbwi.position(), align); 41 42 if (bbwi.position() + n + alignment > bbwi.buflen) { 43 44 if (bbwi.position() + alignment == bbwi.buflen) 48 { 49 bbwi.position(bbwi.position() + alignment); 50 } 51 52 grow(align, n); 53 54 58 alignment = computeAlignment(bbwi.position(), align); 59 } 60 61 bbwi.position(bbwi.position() + alignment); 62 } 63 64 protected void grow(int align, int n) { 68 69 bbwi.needed = n; 70 71 int oldSize = bbwi.position(); 74 75 bbwi = bufferManagerRead.underflow(bbwi); 76 77 if (bbwi.fragmented) { 78 79 fragmentOffset += (oldSize - bbwi.position()); 84 85 markAndResetHandler.fragmentationOccured(bbwi); 86 87 bbwi.fragmented = false; 89 } 90 } 91 92 94 private class FragmentableStreamMemento extends StreamMemento 95 { 96 private int fragmentOffset_; 97 98 public FragmentableStreamMemento() 99 { 100 super(); 101 102 fragmentOffset_ = fragmentOffset; 103 } 104 } 105 106 public java.lang.Object createStreamMemento() { 107 return new FragmentableStreamMemento(); 108 } 109 110 public void restoreInternalState(java.lang.Object streamMemento) 111 { 112 super.restoreInternalState(streamMemento); 113 114 fragmentOffset 115 = ((FragmentableStreamMemento)streamMemento).fragmentOffset_; 116 } 117 118 120 public char read_wchar() { 121 alignAndCheck(2, 2); 126 127 char[] result = getConvertedChars(2, getWCharConverter()); 130 131 if (getWCharConverter().getNumChars() > 1) 136 throw wrapper.btcResultMoreThanOneChar() ; 137 138 return result[0]; 139 } 140 141 public String read_wstring() { 142 int len = read_long(); 145 146 if (len == 0) 153 return new String (""); 154 155 checkForNegativeLength(len); 156 157 len = len - 1; 162 163 char[] result = getConvertedChars(len * 2, getWCharConverter()); 164 165 read_short(); 167 168 return new String (result, 0, getWCharConverter().getNumChars()); 169 } 170 171 } 172 | Popular Tags |