1 7 package com.sun.corba.se.impl.encoding; 8 9 import java.io.IOException ; 10 import java.io.Serializable ; 11 import java.math.BigDecimal ; 12 import java.nio.ByteBuffer ; 13 14 import org.omg.CORBA.TypeCode ; 15 import org.omg.CORBA.Principal ; 16 import org.omg.CORBA.Any ; 17 18 import com.sun.corba.se.pept.protocol.MessageMediator; 19 20 import com.sun.corba.se.spi.orb.ORB; 21 import com.sun.corba.se.spi.logging.CORBALogDomains; 22 import com.sun.corba.se.spi.ior.iiop.GIOPVersion; 23 import com.sun.corba.se.spi.protocol.CorbaMessageMediator; 24 25 import com.sun.corba.se.impl.encoding.CodeSetConversion; 26 import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry; 27 import com.sun.corba.se.impl.orbutil.ORBConstants; 28 import com.sun.corba.se.impl.logging.ORBUtilSystemException; 29 import com.sun.corba.se.impl.protocol.giopmsgheaders.Message; 30 31 34 public abstract class CDROutputStream 35 extends org.omg.CORBA_2_3.portable.OutputStream 36 implements com.sun.corba.se.impl.encoding.MarshalOutputStream, 37 org.omg.CORBA.DataOutputStream , org.omg.CORBA.portable.ValueOutputStream 38 { 39 private CDROutputStreamBase impl; 40 protected ORB orb ; 41 protected ORBUtilSystemException wrapper ; 42 protected CorbaMessageMediator corbaMessageMediator; 43 44 45 private static class OutputStreamFactory { 48 49 public static CDROutputStreamBase newOutputStream( 50 ORB orb, GIOPVersion version, byte encodingVersion) { 51 switch(version.intValue()) { 52 case GIOPVersion.VERSION_1_0: 53 return new CDROutputStream_1_0(); 54 case GIOPVersion.VERSION_1_1: 55 return new CDROutputStream_1_1(); 56 case GIOPVersion.VERSION_1_2: 57 if (encodingVersion != Message.CDR_ENC_VERSION) { 58 return 59 new IDLJavaSerializationOutputStream(encodingVersion); 60 } 61 return new CDROutputStream_1_2(); 62 default: 63 ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb, 64 CORBALogDomains.RPC_ENCODING ) ; 65 throw wrapper.unsupportedGiopVersion( version ) ; 68 } 69 } 70 } 71 72 77 81 public CDROutputStream(ORB orb, 82 GIOPVersion version, 83 byte encodingVersion, 84 boolean littleEndian, 85 BufferManagerWrite bufferManager, 86 byte streamFormatVersion, 87 boolean usePooledByteBuffers) 88 { 89 impl = OutputStreamFactory.newOutputStream(orb, version, 90 encodingVersion); 91 impl.init(orb, littleEndian, bufferManager, 92 streamFormatVersion, usePooledByteBuffers); 93 94 impl.setParent(this); 95 this.orb = orb ; 96 this.wrapper = ORBUtilSystemException.get( orb, 97 CORBALogDomains.RPC_ENCODING ) ; 98 } 99 100 public CDROutputStream(ORB orb, 101 GIOPVersion version, 102 byte encodingVersion, 103 boolean littleEndian, 104 BufferManagerWrite bufferManager, 105 byte streamFormatVersion) 106 { 107 this(orb, version, encodingVersion, littleEndian, 108 bufferManager, streamFormatVersion, true); 109 } 110 111 113 public abstract org.omg.CORBA.portable.InputStream create_input_stream(); 115 116 public final void write_boolean(boolean value) { 117 impl.write_boolean(value); 118 } 119 public final void write_char(char value) { 120 impl.write_char(value); 121 } 122 public final void write_wchar(char value) { 123 impl.write_wchar(value); 124 } 125 public final void write_octet(byte value) { 126 impl.write_octet(value); 127 } 128 public final void write_short(short value) { 129 impl.write_short(value); 130 } 131 public final void write_ushort(short value) { 132 impl.write_ushort(value); 133 } 134 public final void write_long(int value) { 135 impl.write_long(value); 136 } 137 public final void write_ulong(int value) { 138 impl.write_ulong(value); 139 } 140 public final void write_longlong(long value) { 141 impl.write_longlong(value); 142 } 143 public final void write_ulonglong(long value) { 144 impl.write_ulonglong(value); 145 } 146 public final void write_float(float value) { 147 impl.write_float(value); 148 } 149 public final void write_double(double value) { 150 impl.write_double(value); 151 } 152 public final void write_string(String value) { 153 impl.write_string(value); 154 } 155 public final void write_wstring(String value) { 156 impl.write_wstring(value); 157 } 158 159 public final void write_boolean_array(boolean[] value, int offset, int length) { 160 impl.write_boolean_array(value, offset, length); 161 } 162 public final void write_char_array(char[] value, int offset, int length) { 163 impl.write_char_array(value, offset, length); 164 } 165 public final void write_wchar_array(char[] value, int offset, int length) { 166 impl.write_wchar_array(value, offset, length); 167 } 168 public final void write_octet_array(byte[] value, int offset, int length) { 169 impl.write_octet_array(value, offset, length); 170 } 171 public final void write_short_array(short[] value, int offset, int length) { 172 impl.write_short_array(value, offset, length); 173 } 174 public final void write_ushort_array(short[] value, int offset, int length){ 175 impl.write_ushort_array(value, offset, length); 176 } 177 public final void write_long_array(int[] value, int offset, int length) { 178 impl.write_long_array(value, offset, length); 179 } 180 public final void write_ulong_array(int[] value, int offset, int length) { 181 impl.write_ulong_array(value, offset, length); 182 } 183 public final void write_longlong_array(long[] value, int offset, int length) { 184 impl.write_longlong_array(value, offset, length); 185 } 186 public final void write_ulonglong_array(long[] value, int offset,int length) { 187 impl.write_ulonglong_array(value, offset, length); 188 } 189 public final void write_float_array(float[] value, int offset, int length) { 190 impl.write_float_array(value, offset, length); 191 } 192 public final void write_double_array(double[] value, int offset, int length) { 193 impl.write_double_array(value, offset, length); 194 } 195 public final void write_Object(org.omg.CORBA.Object value) { 196 impl.write_Object(value); 197 } 198 public final void write_TypeCode(TypeCode value) { 199 impl.write_TypeCode(value); 200 } 201 public final void write_any(Any value) { 202 impl.write_any(value); 203 } 204 205 public final void write_Principal(Principal value) { 206 impl.write_Principal(value); 207 } 208 209 public final void write(int b) throws java.io.IOException { 210 impl.write(b); 211 } 212 213 public final void write_fixed(java.math.BigDecimal value) { 214 impl.write_fixed(value); 215 } 216 217 public final void write_Context(org.omg.CORBA.Context ctx, 218 org.omg.CORBA.ContextList contexts) { 219 impl.write_Context(ctx, contexts); 220 } 221 222 public final org.omg.CORBA.ORB orb() { 223 return impl.orb(); 224 } 225 226 public final void write_value(java.io.Serializable value) { 228 impl.write_value(value); 229 } 230 231 public final void write_value(java.io.Serializable value, java.lang.Class clz) { 232 impl.write_value(value, clz); 233 } 234 235 public final void write_value(java.io.Serializable value, String repository_id) { 236 impl.write_value(value, repository_id); 237 } 238 239 public final void write_value(java.io.Serializable value, 240 org.omg.CORBA.portable.BoxedValueHelper factory) { 241 impl.write_value(value, factory); 242 } 243 244 public final void write_abstract_interface(java.lang.Object obj) { 245 impl.write_abstract_interface(obj); 246 } 247 248 public final void write(byte b[]) throws IOException { 250 impl.write(b); 251 } 252 253 public final void write(byte b[], int off, int len) throws IOException { 254 impl.write(b, off, len); 255 } 256 257 public final void flush() throws IOException { 258 impl.flush(); 259 } 260 261 public final void close() throws IOException { 262 impl.close(); 263 } 264 265 public final void start_block() { 267 impl.start_block(); 268 } 269 270 public final void end_block() { 271 impl.end_block(); 272 } 273 274 public final void putEndian() { 275 impl.putEndian(); 276 } 277 278 public void writeTo(java.io.OutputStream s) 279 throws IOException 280 { 281 impl.writeTo(s); 282 } 283 284 public final byte[] toByteArray() { 285 return impl.toByteArray(); 286 } 287 288 public final void write_Abstract (java.lang.Object value) { 290 impl.write_Abstract(value); 291 } 292 293 public final void write_Value (java.io.Serializable value) { 294 impl.write_Value(value); 295 } 296 297 public final void write_any_array(org.omg.CORBA.Any [] seq, int offset, int length) { 298 impl.write_any_array(seq, offset, length); 299 } 300 301 public void setMessageMediator(MessageMediator messageMediator) 302 { 303 this.corbaMessageMediator = (CorbaMessageMediator) messageMediator; 304 } 305 306 public MessageMediator getMessageMediator() 307 { 308 return corbaMessageMediator; 309 } 310 311 public final String [] _truncatable_ids() { 313 return impl._truncatable_ids(); 314 } 315 316 protected final int getSize() { 318 return impl.getSize(); 319 } 320 321 protected final int getIndex() { 322 return impl.getIndex(); 323 } 324 325 protected int getRealIndex(int index) { 326 return index; 328 } 329 330 protected final void setIndex(int value) { 331 impl.setIndex(value); 332 } 333 334 protected final ByteBuffer getByteBuffer() { 335 return impl.getByteBuffer(); 336 } 337 338 protected final void setByteBuffer(ByteBuffer byteBuffer) { 339 impl.setByteBuffer(byteBuffer); 340 } 341 342 public final boolean isLittleEndian() { 343 return impl.isLittleEndian(); 344 } 345 346 public ByteBufferWithInfo getByteBufferWithInfo() { 349 return impl.getByteBufferWithInfo(); 350 } 351 352 protected void setByteBufferWithInfo(ByteBufferWithInfo bbwi) { 353 impl.setByteBufferWithInfo(bbwi); 354 } 355 356 public final BufferManagerWrite getBufferManager() { 358 return impl.getBufferManager(); 359 } 360 361 public final void write_fixed(java.math.BigDecimal bigDecimal, short digits, short scale) { 362 impl.write_fixed(bigDecimal, digits, scale); 363 } 364 365 public final void writeOctetSequenceTo(org.omg.CORBA.portable.OutputStream s) { 366 impl.writeOctetSequenceTo(s); 367 } 368 369 public final GIOPVersion getGIOPVersion() { 370 return impl.getGIOPVersion(); 371 } 372 373 public final void writeIndirection(int tag, int posIndirectedTo) { 374 impl.writeIndirection(tag, posIndirectedTo); 375 } 376 377 protected CodeSetConversion.CTBConverter createCharCTBConverter() { 380 return CodeSetConversion.impl().getCTBConverter(OSFCodeSetRegistry.ISO_8859_1); 381 } 382 383 protected abstract CodeSetConversion.CTBConverter createWCharCTBConverter(); 386 387 protected final void freeInternalCaches() { 388 impl.freeInternalCaches(); 389 } 390 391 void printBuffer() { 392 impl.printBuffer(); 393 } 394 395 public void alignOnBoundary(int octetBoundary) { 396 impl.alignOnBoundary(octetBoundary); 397 } 398 399 public void setHeaderPadding(boolean headerPadding) { 401 impl.setHeaderPadding(headerPadding); 402 } 403 404 406 public void start_value(String rep_id) { 407 impl.start_value(rep_id); 408 } 409 410 public void end_value() { 411 impl.end_value(); 412 } 413 } 414 | Popular Tags |