1 7 package com.sun.corba.se.impl.encoding; 8 9 import org.omg.CORBA.CompletionStatus ; 10 import com.sun.corba.se.spi.ior.iiop.GIOPVersion; 11 import com.sun.corba.se.impl.encoding.CodeSetConversion; 12 13 public class CDROutputStream_1_1 extends CDROutputStream_1_0 14 { 15 protected int fragmentOffset = 0; 29 30 protected void alignAndReserve(int align, int n) { 31 32 40 int alignment = computeAlignment(align); 41 42 if (bbwi.position() + n + alignment > bbwi.buflen) { 43 grow(align, n); 44 45 49 alignment = computeAlignment(align); 53 } 54 55 bbwi.position(bbwi.position() + alignment); 56 } 57 58 protected void grow(int align, int n) { 59 int oldSize = bbwi.position(); 61 62 super.grow(align, n); 63 64 if (bbwi.fragmented) { 68 69 bbwi.fragmented = false; 71 72 fragmentOffset += (oldSize - bbwi.position()); 77 } 78 } 79 80 public int get_offset() { 81 return bbwi.position() + fragmentOffset; 82 } 83 84 public GIOPVersion getGIOPVersion() { 85 return GIOPVersion.V1_1; 86 } 87 88 public void write_wchar(char x) 89 { 90 CodeSetConversion.CTBConverter converter = getWCharConverter(); 95 96 converter.convert(x); 97 98 if (converter.getNumBytes() != 2) 99 throw wrapper.badGiop11Ctb(CompletionStatus.COMPLETED_MAYBE); 100 101 alignAndReserve(converter.getAlignment(), 102 converter.getNumBytes()); 103 104 parent.write_octet_array(converter.getBytes(), 105 0, 106 converter.getNumBytes()); 107 } 108 109 public void write_wstring(String value) 110 { 111 if (value == null) { 112 throw wrapper.nullParam(CompletionStatus.COMPLETED_MAYBE); 113 } 114 115 118 int len = value.length() + 1; 119 120 write_long(len); 121 122 CodeSetConversion.CTBConverter converter = getWCharConverter(); 123 124 converter.convert(value); 125 126 internalWriteOctetArray(converter.getBytes(), 0, converter.getNumBytes()); 127 128 write_short((short)0); 130 } 131 } 132 133 | Popular Tags |