0N/A/*
322N/A * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
157N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
157N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
157N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
157N/A * or visit www.oracle.com if you need additional information or have any
157N/A * questions.
0N/A */
0N/Apackage com.sun.corba.se.impl.encoding;
0N/A
0N/Aimport java.io.IOException;
0N/Aimport java.io.Serializable;
0N/Aimport java.math.BigDecimal;
0N/Aimport java.nio.ByteBuffer;
0N/A
0N/Aimport org.omg.CORBA.TypeCode;
0N/Aimport org.omg.CORBA.Principal;
0N/Aimport org.omg.CORBA.Any;
0N/A
0N/Aimport com.sun.org.omg.SendingContext.CodeBase;
0N/A
0N/Aimport com.sun.corba.se.pept.protocol.MessageMediator;
0N/A
0N/Aimport com.sun.corba.se.spi.logging.CORBALogDomains;
0N/Aimport com.sun.corba.se.spi.orb.ORB;
0N/Aimport com.sun.corba.se.spi.ior.iiop.GIOPVersion;
0N/Aimport com.sun.corba.se.spi.protocol.CorbaMessageMediator;
0N/A
0N/Aimport com.sun.corba.se.impl.logging.ORBUtilSystemException;
0N/Aimport com.sun.corba.se.impl.encoding.CodeSetConversion;
0N/Aimport com.sun.corba.se.impl.encoding.OSFCodeSetRegistry;
0N/Aimport com.sun.corba.se.impl.orbutil.ORBUtility;
0N/Aimport com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
0N/A
0N/A/**
0N/A * This is delegates to the real implementation.
0N/A *
0N/A * NOTE:
0N/A *
0N/A * Before using the stream for valuetype unmarshaling, one must call
0N/A * performORBVersionSpecificInit().
0N/A */
0N/Apublic abstract class CDRInputStream
0N/A extends org.omg.CORBA_2_3.portable.InputStream
0N/A implements com.sun.corba.se.impl.encoding.MarshalInputStream,
0N/A org.omg.CORBA.DataInputStream, org.omg.CORBA.portable.ValueInputStream
0N/A{
0N/A protected CorbaMessageMediator messageMediator;
0N/A private CDRInputStreamBase impl;
0N/A
0N/A // We can move this out somewhere later. For now, it serves its purpose
0N/A // to create a concrete CDR delegate based on the GIOP version.
0N/A private static class InputStreamFactory {
0N/A
0N/A public static CDRInputStreamBase newInputStream(
0N/A ORB orb, GIOPVersion version, byte encodingVersion) {
0N/A switch(version.intValue()) {
0N/A case GIOPVersion.VERSION_1_0:
0N/A return new CDRInputStream_1_0();
0N/A case GIOPVersion.VERSION_1_1:
0N/A return new CDRInputStream_1_1();
0N/A case GIOPVersion.VERSION_1_2:
0N/A if (encodingVersion != Message.CDR_ENC_VERSION) {
0N/A return
0N/A new IDLJavaSerializationInputStream(encodingVersion);
0N/A }
0N/A return new CDRInputStream_1_2();
0N/A // else fall through and report exception.
0N/A default:
0N/A ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb,
0N/A CORBALogDomains.RPC_ENCODING ) ;
0N/A throw wrapper.unsupportedGiopVersion( version ) ;
0N/A }
0N/A }
0N/A }
0N/A
0N/A // Required for the case when a ClientResponseImpl is
0N/A // created with a SystemException due to a dead server/closed
0N/A // connection with no warning. Note that the stream will
0N/A // not be initialized in this case.
0N/A //
0N/A // Probably also required by ServerRequestImpl.
0N/A //
0N/A // REVISIT.
0N/A public CDRInputStream() {
0N/A }
0N/A
0N/A public CDRInputStream(CDRInputStream is) {
0N/A impl = is.impl.dup();
0N/A impl.setParent(this);
0N/A }
0N/A
0N/A public CDRInputStream(org.omg.CORBA.ORB orb,
0N/A ByteBuffer byteBuffer,
0N/A int size,
0N/A boolean littleEndian,
0N/A GIOPVersion version,
0N/A byte encodingVersion,
0N/A BufferManagerRead bufMgr)
0N/A {
0N/A impl = InputStreamFactory.newInputStream((ORB)orb, version,
0N/A encodingVersion);
0N/A
0N/A impl.init(orb, byteBuffer, size, littleEndian, bufMgr);
0N/A
0N/A impl.setParent(this);
0N/A }
0N/A
0N/A // org.omg.CORBA.portable.InputStream
0N/A public final boolean read_boolean() {
0N/A return impl.read_boolean();
0N/A }
0N/A
0N/A public final char read_char() {
0N/A return impl.read_char();
0N/A }
0N/A
0N/A public final char read_wchar() {
0N/A return impl.read_wchar();
0N/A }
0N/A
0N/A public final byte read_octet() {
0N/A return impl.read_octet();
0N/A }
0N/A
0N/A public final short read_short() {
0N/A return impl.read_short();
0N/A }
0N/A
0N/A public final short read_ushort() {
0N/A return impl.read_ushort();
0N/A }
0N/A
0N/A public final int read_long() {
0N/A return impl.read_long();
0N/A }
0N/A
0N/A public final int read_ulong() {
0N/A return impl.read_ulong();
0N/A }
0N/A
0N/A public final long read_longlong() {
0N/A return impl.read_longlong();
0N/A }
0N/A
0N/A public final long read_ulonglong() {
0N/A return impl.read_ulonglong();
0N/A }
0N/A
0N/A public final float read_float() {
0N/A return impl.read_float();
0N/A }
0N/A
0N/A public final double read_double() {
0N/A return impl.read_double();
0N/A }
0N/A
0N/A public final String read_string() {
0N/A return impl.read_string();
0N/A }
0N/A
0N/A public final String read_wstring() {
0N/A return impl.read_wstring();
0N/A }
0N/A
0N/A public final void read_boolean_array(boolean[] value, int offset, int length) {
0N/A impl.read_boolean_array(value, offset, length);
0N/A }
0N/A
0N/A public final void read_char_array(char[] value, int offset, int length) {
0N/A impl.read_char_array(value, offset, length);
0N/A }
0N/A
0N/A public final void read_wchar_array(char[] value, int offset, int length) {
0N/A impl.read_wchar_array(value, offset, length);
0N/A }
0N/A
0N/A public final void read_octet_array(byte[] value, int offset, int length) {
0N/A impl.read_octet_array(value, offset, length);
0N/A }
0N/A
0N/A public final void read_short_array(short[] value, int offset, int length) {
0N/A impl.read_short_array(value, offset, length);
0N/A }
0N/A
0N/A public final void read_ushort_array(short[] value, int offset, int length) {
0N/A impl.read_ushort_array(value, offset, length);
0N/A }
0N/A
0N/A public final void read_long_array(int[] value, int offset, int length) {
0N/A impl.read_long_array(value, offset, length);
0N/A }
0N/A
0N/A public final void read_ulong_array(int[] value, int offset, int length) {
0N/A impl.read_ulong_array(value, offset, length);
0N/A }
0N/A
0N/A public final void read_longlong_array(long[] value, int offset, int length) {
0N/A impl.read_longlong_array(value, offset, length);
0N/A }
0N/A
0N/A public final void read_ulonglong_array(long[] value, int offset, int length) {
0N/A impl.read_ulonglong_array(value, offset, length);
0N/A }
0N/A
0N/A public final void read_float_array(float[] value, int offset, int length) {
0N/A impl.read_float_array(value, offset, length);
0N/A }
0N/A
0N/A public final void read_double_array(double[] value, int offset, int length) {
0N/A impl.read_double_array(value, offset, length);
0N/A }
0N/A
0N/A public final org.omg.CORBA.Object read_Object() {
0N/A return impl.read_Object();
0N/A }
0N/A
0N/A public final TypeCode read_TypeCode() {
0N/A return impl.read_TypeCode();
0N/A }
0N/A public final Any read_any() {
0N/A return impl.read_any();
0N/A }
0N/A
0N/A public final Principal read_Principal() {
0N/A return impl.read_Principal();
0N/A }
0N/A
0N/A public final int read() throws java.io.IOException {
0N/A return impl.read();
0N/A }
0N/A
0N/A public final java.math.BigDecimal read_fixed() {
0N/A return impl.read_fixed();
0N/A }
0N/A
0N/A public final org.omg.CORBA.Context read_Context() {
0N/A return impl.read_Context();
0N/A }
0N/A
0N/A public final org.omg.CORBA.Object read_Object(java.lang.Class clz) {
0N/A return impl.read_Object(clz);
0N/A }
0N/A
0N/A public final org.omg.CORBA.ORB orb() {
0N/A return impl.orb();
0N/A }
0N/A
0N/A // org.omg.CORBA_2_3.portable.InputStream
0N/A public final java.io.Serializable read_value() {
0N/A return impl.read_value();
0N/A }
0N/A
0N/A public final java.io.Serializable read_value(java.lang.Class clz) {
0N/A return impl.read_value(clz);
0N/A }
0N/A
0N/A public final java.io.Serializable read_value(org.omg.CORBA.portable.BoxedValueHelper factory) {
0N/A return impl.read_value(factory);
0N/A }
0N/A
0N/A public final java.io.Serializable read_value(java.lang.String rep_id) {
0N/A return impl.read_value(rep_id);
0N/A }
0N/A
0N/A public final java.io.Serializable read_value(java.io.Serializable value) {
0N/A return impl.read_value(value);
0N/A }
0N/A
0N/A public final java.lang.Object read_abstract_interface() {
0N/A return impl.read_abstract_interface();
0N/A }
0N/A
0N/A public final java.lang.Object read_abstract_interface(java.lang.Class clz) {
0N/A return impl.read_abstract_interface(clz);
0N/A }
0N/A // com.sun.corba.se.impl.encoding.MarshalInputStream
0N/A
0N/A public final void consumeEndian() {
0N/A impl.consumeEndian();
0N/A }
0N/A
0N/A public final int getPosition() {
0N/A return impl.getPosition();
0N/A }
0N/A
0N/A // org.omg.CORBA.DataInputStream
0N/A
0N/A public final java.lang.Object read_Abstract () {
0N/A return impl.read_Abstract();
0N/A }
0N/A
0N/A public final java.io.Serializable read_Value () {
0N/A return impl.read_Value();
0N/A }
0N/A
0N/A public final void read_any_array (org.omg.CORBA.AnySeqHolder seq, int offset, int length) {
0N/A impl.read_any_array(seq, offset, length);
0N/A }
0N/A
0N/A public final void read_boolean_array (org.omg.CORBA.BooleanSeqHolder seq, int offset, int length) {
0N/A impl.read_boolean_array(seq, offset, length);
0N/A }
0N/A
0N/A public final void read_char_array (org.omg.CORBA.CharSeqHolder seq, int offset, int length) {
0N/A impl.read_char_array(seq, offset, length);
0N/A }
0N/A
0N/A public final void read_wchar_array (org.omg.CORBA.WCharSeqHolder seq, int offset, int length) {
0N/A impl.read_wchar_array(seq, offset, length);
0N/A }
0N/A
0N/A public final void read_octet_array (org.omg.CORBA.OctetSeqHolder seq, int offset, int length) {
0N/A impl.read_octet_array(seq, offset, length);
0N/A }
0N/A
0N/A public final void read_short_array (org.omg.CORBA.ShortSeqHolder seq, int offset, int length) {
0N/A impl.read_short_array(seq, offset, length);
0N/A }
0N/A
0N/A public final void read_ushort_array (org.omg.CORBA.UShortSeqHolder seq, int offset, int length) {
0N/A impl.read_ushort_array(seq, offset, length);
0N/A }
0N/A
0N/A public final void read_long_array (org.omg.CORBA.LongSeqHolder seq, int offset, int length) {
0N/A impl.read_long_array(seq, offset, length);
0N/A }
0N/A
0N/A public final void read_ulong_array (org.omg.CORBA.ULongSeqHolder seq, int offset, int length) {
0N/A impl.read_ulong_array(seq, offset, length);
0N/A }
0N/A
0N/A public final void read_ulonglong_array (org.omg.CORBA.ULongLongSeqHolder seq, int offset, int length) {
0N/A impl.read_ulonglong_array(seq, offset, length);
0N/A }
0N/A
0N/A public final void read_longlong_array (org.omg.CORBA.LongLongSeqHolder seq, int offset, int length) {
0N/A impl.read_longlong_array(seq, offset, length);
0N/A }
0N/A
0N/A public final void read_float_array (org.omg.CORBA.FloatSeqHolder seq, int offset, int length) {
0N/A impl.read_float_array(seq, offset, length);
0N/A }
0N/A
0N/A public final void read_double_array (org.omg.CORBA.DoubleSeqHolder seq, int offset, int length) {
0N/A impl.read_double_array(seq, offset, length);
0N/A }
0N/A
0N/A // org.omg.CORBA.portable.ValueBase
0N/A public final String[] _truncatable_ids() {
0N/A return impl._truncatable_ids();
0N/A }
0N/A
0N/A // java.io.InputStream
0N/A public final int read(byte b[]) throws IOException {
0N/A return impl.read(b);
0N/A }
0N/A
0N/A public final int read(byte b[], int off, int len) throws IOException {
0N/A return impl.read(b, off, len);
0N/A }
0N/A
0N/A public final long skip(long n) throws IOException {
0N/A return impl.skip(n);
0N/A }
0N/A
0N/A public final int available() throws IOException {
0N/A return impl.available();
0N/A }
0N/A
0N/A public final void close() throws IOException {
0N/A impl.close();
0N/A }
0N/A
0N/A public final void mark(int readlimit) {
0N/A impl.mark(readlimit);
0N/A }
0N/A
0N/A public final void reset() {
0N/A impl.reset();
0N/A }
0N/A
0N/A public final boolean markSupported() {
0N/A return impl.markSupported();
0N/A }
0N/A
0N/A public abstract CDRInputStream dup();
0N/A
0N/A // Needed by TCUtility
0N/A public final java.math.BigDecimal read_fixed(short digits, short scale) {
0N/A return impl.read_fixed(digits, scale);
0N/A }
0N/A
0N/A public final boolean isLittleEndian() {
0N/A return impl.isLittleEndian();
0N/A }
0N/A
0N/A protected final ByteBuffer getByteBuffer() {
0N/A return impl.getByteBuffer();
0N/A }
0N/A
0N/A protected final void setByteBuffer(ByteBuffer byteBuffer) {
0N/A impl.setByteBuffer(byteBuffer);
0N/A }
0N/A
0N/A protected final void setByteBufferWithInfo(ByteBufferWithInfo bbwi) {
0N/A impl.setByteBufferWithInfo(bbwi);
0N/A }
0N/A
322N/A /**
322N/A * return true if our ByteBuffer is sharing/equal to bb
322N/A */
322N/A protected final boolean isSharing(ByteBuffer bb) {
322N/A return (getByteBuffer() == bb);
322N/A }
322N/A
0N/A public final int getBufferLength() {
0N/A return impl.getBufferLength();
0N/A }
0N/A
0N/A protected final void setBufferLength(int value) {
0N/A impl.setBufferLength(value);
0N/A }
0N/A
0N/A protected final int getIndex() {
0N/A return impl.getIndex();
0N/A }
0N/A
0N/A protected final void setIndex(int value) {
0N/A impl.setIndex(value);
0N/A }
0N/A
0N/A public final void orb(org.omg.CORBA.ORB orb) {
0N/A impl.orb(orb);
0N/A }
0N/A
0N/A public final GIOPVersion getGIOPVersion() {
0N/A return impl.getGIOPVersion();
0N/A }
0N/A
0N/A public final BufferManagerRead getBufferManager() {
0N/A return impl.getBufferManager();
0N/A }
0N/A
0N/A // This should be overridden by any stream (ex: IIOPInputStream)
0N/A // which wants to read values. Thus, TypeCodeInputStream doesn't
0N/A // have to do this.
0N/A public CodeBase getCodeBase() {
0N/A return null;
0N/A }
0N/A
0N/A // Use Latin-1 for GIOP 1.0 or when code set negotiation was not
0N/A // performed.
0N/A protected CodeSetConversion.BTCConverter createCharBTCConverter() {
0N/A return CodeSetConversion.impl().getBTCConverter(OSFCodeSetRegistry.ISO_8859_1,
0N/A impl.isLittleEndian());
0N/A }
0N/A
0N/A // Subclasses must decide what to do here. It's inconvenient to
0N/A // make the class and this method abstract because of dup().
0N/A protected abstract CodeSetConversion.BTCConverter createWCharBTCConverter();
0N/A
0N/A // Prints the current buffer in a human readable form
0N/A void printBuffer() {
0N/A impl.printBuffer();
0N/A }
0N/A
0N/A /**
0N/A * Aligns the current position on the given octet boundary
0N/A * if there are enough bytes available to do so. Otherwise,
0N/A * it just returns. This is used for some (but not all)
0N/A * GIOP 1.2 message headers.
0N/A */
0N/A public void alignOnBoundary(int octetBoundary) {
0N/A impl.alignOnBoundary(octetBoundary);
0N/A }
0N/A
0N/A // Needed by request and reply messages for GIOP versions >= 1.2 only.
0N/A public void setHeaderPadding(boolean headerPadding) {
0N/A impl.setHeaderPadding(headerPadding);
0N/A }
0N/A
0N/A /**
0N/A * This must be called after determining the proper ORB version,
0N/A * and setting it on the stream's ORB instance. It can be called
0N/A * after reading the service contexts, since that is the only place
0N/A * we can get the ORB version info.
0N/A *
0N/A * Trying to unmarshal things requiring repository IDs before calling
0N/A * this will result in NullPtrExceptions.
0N/A */
0N/A public void performORBVersionSpecificInit() {
0N/A // In the case of SystemExceptions, a stream is created
0N/A // with its default constructor (and thus no impl is set).
0N/A if (impl != null)
0N/A impl.performORBVersionSpecificInit();
0N/A }
0N/A
0N/A /**
0N/A * Resets any internal references to code set converters.
0N/A * This is useful for forcing the CDR stream to reacquire
0N/A * converters (probably from its subclasses) when state
0N/A * has changed.
0N/A */
0N/A public void resetCodeSetConverters() {
0N/A impl.resetCodeSetConverters();
0N/A }
0N/A
0N/A public void setMessageMediator(MessageMediator messageMediator)
0N/A {
0N/A this.messageMediator = (CorbaMessageMediator) messageMediator;
0N/A }
0N/A
0N/A public MessageMediator getMessageMediator()
0N/A {
0N/A return messageMediator;
0N/A }
0N/A
0N/A // ValueInputStream -----------------------------
0N/A
0N/A public void start_value() {
0N/A impl.start_value();
0N/A }
0N/A
0N/A public void end_value() {
0N/A impl.end_value();
0N/A }
0N/A}