corba/src/share/classes/com/sun/corba/se/impl/encoding/IDLJavaSerializationInputStream.java
author ohair
Tue, 25 May 2010 15:52:11 -0700
changeset 5555 b2b5ed3f0d0d
parent 4 02bb8761fcce
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     1
/*
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     2
 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
02bb8761fcce Initial load
duke
parents:
diff changeset
     4
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
02bb8761fcce Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    10
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
02bb8761fcce Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
02bb8761fcce Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
02bb8761fcce Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
02bb8761fcce Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
02bb8761fcce Initial load
duke
parents:
diff changeset
    16
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
02bb8761fcce Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
02bb8761fcce Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
02bb8761fcce Initial load
duke
parents:
diff changeset
    20
 *
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    23
 * questions.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    24
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    25
package com.sun.corba.se.impl.encoding;
02bb8761fcce Initial load
duke
parents:
diff changeset
    26
02bb8761fcce Initial load
duke
parents:
diff changeset
    27
import java.io.Serializable;
02bb8761fcce Initial load
duke
parents:
diff changeset
    28
import java.io.ObjectInputStream;
02bb8761fcce Initial load
duke
parents:
diff changeset
    29
import java.io.ByteArrayInputStream;
02bb8761fcce Initial load
duke
parents:
diff changeset
    30
import java.io.IOException;
02bb8761fcce Initial load
duke
parents:
diff changeset
    31
import java.nio.ByteBuffer;
02bb8761fcce Initial load
duke
parents:
diff changeset
    32
import java.math.BigDecimal;
02bb8761fcce Initial load
duke
parents:
diff changeset
    33
import java.util.LinkedList;
02bb8761fcce Initial load
duke
parents:
diff changeset
    34
02bb8761fcce Initial load
duke
parents:
diff changeset
    35
import com.sun.corba.se.spi.orb.ORB;
02bb8761fcce Initial load
duke
parents:
diff changeset
    36
import com.sun.corba.se.spi.ior.IOR;
02bb8761fcce Initial load
duke
parents:
diff changeset
    37
import com.sun.corba.se.spi.ior.IORFactories;
02bb8761fcce Initial load
duke
parents:
diff changeset
    38
import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
02bb8761fcce Initial load
duke
parents:
diff changeset
    39
import com.sun.corba.se.spi.logging.CORBALogDomains;
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
import com.sun.corba.se.spi.presentation.rmi.StubAdapter;
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
import com.sun.corba.se.spi.presentation.rmi.PresentationManager;
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults;
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
import com.sun.corba.se.impl.util.Utility;
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
import com.sun.corba.se.impl.orbutil.ORBUtility;
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
import com.sun.corba.se.impl.corba.TypeCodeImpl;
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
import com.sun.corba.se.impl.util.RepositoryId;
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
import com.sun.corba.se.impl.orbutil.ORBConstants;
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
import com.sun.corba.se.impl.logging.ORBUtilSystemException;
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
import org.omg.CORBA.Any;
02bb8761fcce Initial load
duke
parents:
diff changeset
    53
import org.omg.CORBA.TypeCode;
02bb8761fcce Initial load
duke
parents:
diff changeset
    54
import org.omg.CORBA.Principal;
02bb8761fcce Initial load
duke
parents:
diff changeset
    55
import org.omg.CORBA.portable.IDLEntity;
02bb8761fcce Initial load
duke
parents:
diff changeset
    56
02bb8761fcce Initial load
duke
parents:
diff changeset
    57
/**
02bb8761fcce Initial load
duke
parents:
diff changeset
    58
 * Implementation class that uses Java serialization for input streams.
02bb8761fcce Initial load
duke
parents:
diff changeset
    59
 * This assumes a GIOP version 1.2 message format.
02bb8761fcce Initial load
duke
parents:
diff changeset
    60
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    61
 * This class uses a ByteArrayInputStream as the underlying buffer. The
02bb8761fcce Initial load
duke
parents:
diff changeset
    62
 * first 16 bytes are directly read out of the underlying buffer. This allows
02bb8761fcce Initial load
duke
parents:
diff changeset
    63
 * [GIOPHeader (12 bytes) + requestID (4 bytes)] to be read as bytes.
02bb8761fcce Initial load
duke
parents:
diff changeset
    64
 * Subsequent write operations on this output stream object uses
02bb8761fcce Initial load
duke
parents:
diff changeset
    65
 * ObjectInputStream class to read into the buffer. This allows unmarshaling
02bb8761fcce Initial load
duke
parents:
diff changeset
    66
 * complex types and graphs using the ObjectInputStream implementation.
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
 * Note, this class assumes a GIOP 1.2 style header. Further, the first
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
 * 12 bytes, that is, the GIOPHeader is read directly from the received
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
 * message, before this stream object is called. So, this class effectively
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
 * reads only the requestID (4 bytes) directly, and uses the
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
 * ObjectInputStream for further unmarshaling.
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
 * @author Ram Jeyaraman
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
public class IDLJavaSerializationInputStream extends CDRInputStreamBase {
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
    private ORB orb;
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
    private int bufSize;
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
    private ByteBuffer buffer;
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
    private byte encodingVersion;
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
    private ObjectInputStream is;
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
    private _ByteArrayInputStream bis;
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
    private BufferManagerRead bufferManager;
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
    // [GIOPHeader(12) + requestID(4)] bytes
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
    private final int directReadLength = Message.GIOPMessageHeaderLength + 4;
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
    // Used for mark / reset operations.
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
    private boolean markOn;
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
    private int peekIndex, peekCount;
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
    private LinkedList markedItemQ = new LinkedList();
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
    protected ORBUtilSystemException wrapper;
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
02bb8761fcce Initial load
duke
parents:
diff changeset
    96
    class _ByteArrayInputStream extends ByteArrayInputStream {
02bb8761fcce Initial load
duke
parents:
diff changeset
    97
02bb8761fcce Initial load
duke
parents:
diff changeset
    98
        _ByteArrayInputStream(byte[] buf) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    99
            super(buf);
02bb8761fcce Initial load
duke
parents:
diff changeset
   100
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   101
02bb8761fcce Initial load
duke
parents:
diff changeset
   102
        int getPosition() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   103
            return this.pos;
02bb8761fcce Initial load
duke
parents:
diff changeset
   104
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   105
02bb8761fcce Initial load
duke
parents:
diff changeset
   106
        void setPosition(int value) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   107
            if (value < 0 || value > count) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   108
                throw new IndexOutOfBoundsException();
02bb8761fcce Initial load
duke
parents:
diff changeset
   109
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   110
            this.pos = value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   111
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   112
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   113
02bb8761fcce Initial load
duke
parents:
diff changeset
   114
    class MarshalObjectInputStream extends ObjectInputStream {
02bb8761fcce Initial load
duke
parents:
diff changeset
   115
02bb8761fcce Initial load
duke
parents:
diff changeset
   116
        ORB orb;
02bb8761fcce Initial load
duke
parents:
diff changeset
   117
02bb8761fcce Initial load
duke
parents:
diff changeset
   118
        MarshalObjectInputStream(java.io.InputStream out, ORB orb)
02bb8761fcce Initial load
duke
parents:
diff changeset
   119
                throws IOException {
02bb8761fcce Initial load
duke
parents:
diff changeset
   120
02bb8761fcce Initial load
duke
parents:
diff changeset
   121
            super(out);
02bb8761fcce Initial load
duke
parents:
diff changeset
   122
            this.orb = orb;
02bb8761fcce Initial load
duke
parents:
diff changeset
   123
02bb8761fcce Initial load
duke
parents:
diff changeset
   124
            java.security.AccessController.doPrivileged(
02bb8761fcce Initial load
duke
parents:
diff changeset
   125
                new java.security.PrivilegedAction() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   126
                    public Object run() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   127
                        // needs SerializablePermission("enableSubstitution")
02bb8761fcce Initial load
duke
parents:
diff changeset
   128
                        enableResolveObject(true);
02bb8761fcce Initial load
duke
parents:
diff changeset
   129
                        return null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   130
                    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   131
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   132
            );
02bb8761fcce Initial load
duke
parents:
diff changeset
   133
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   134
02bb8761fcce Initial load
duke
parents:
diff changeset
   135
        /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   136
         * Connect the Stub to the ORB.
02bb8761fcce Initial load
duke
parents:
diff changeset
   137
         */
02bb8761fcce Initial load
duke
parents:
diff changeset
   138
        protected final Object resolveObject(Object obj) throws IOException {
02bb8761fcce Initial load
duke
parents:
diff changeset
   139
            try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   140
                if (StubAdapter.isStub(obj)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   141
                    StubAdapter.connect(obj, orb);
02bb8761fcce Initial load
duke
parents:
diff changeset
   142
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   143
            } catch (java.rmi.RemoteException re) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   144
                IOException ie = new IOException("resolveObject failed");
02bb8761fcce Initial load
duke
parents:
diff changeset
   145
                ie.initCause(re);
02bb8761fcce Initial load
duke
parents:
diff changeset
   146
                throw ie;
02bb8761fcce Initial load
duke
parents:
diff changeset
   147
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   148
            return obj;
02bb8761fcce Initial load
duke
parents:
diff changeset
   149
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   150
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   151
02bb8761fcce Initial load
duke
parents:
diff changeset
   152
    public IDLJavaSerializationInputStream(byte encodingVersion) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   153
        super();
02bb8761fcce Initial load
duke
parents:
diff changeset
   154
        this.encodingVersion = encodingVersion;
02bb8761fcce Initial load
duke
parents:
diff changeset
   155
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   156
02bb8761fcce Initial load
duke
parents:
diff changeset
   157
    public void init(org.omg.CORBA.ORB orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
   158
                     ByteBuffer byteBuffer,
02bb8761fcce Initial load
duke
parents:
diff changeset
   159
                     int bufSize,
02bb8761fcce Initial load
duke
parents:
diff changeset
   160
                     boolean littleEndian,
02bb8761fcce Initial load
duke
parents:
diff changeset
   161
                     BufferManagerRead bufferManager) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   162
        this.orb = (ORB) orb;
02bb8761fcce Initial load
duke
parents:
diff changeset
   163
        this.bufSize = bufSize;
02bb8761fcce Initial load
duke
parents:
diff changeset
   164
        this.bufferManager = bufferManager;
02bb8761fcce Initial load
duke
parents:
diff changeset
   165
        buffer = byteBuffer;
02bb8761fcce Initial load
duke
parents:
diff changeset
   166
        wrapper =
02bb8761fcce Initial load
duke
parents:
diff changeset
   167
            ORBUtilSystemException.get((ORB)orb, CORBALogDomains.RPC_ENCODING);
02bb8761fcce Initial load
duke
parents:
diff changeset
   168
02bb8761fcce Initial load
duke
parents:
diff changeset
   169
        byte[] buf;
02bb8761fcce Initial load
duke
parents:
diff changeset
   170
        if (buffer.hasArray()) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   171
            buf = buffer.array();
02bb8761fcce Initial load
duke
parents:
diff changeset
   172
        } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   173
            buf = new byte[bufSize];
02bb8761fcce Initial load
duke
parents:
diff changeset
   174
            buffer.get(buf);
02bb8761fcce Initial load
duke
parents:
diff changeset
   175
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   176
        // Note: at this point, the buffer position is zero. The setIndex()
02bb8761fcce Initial load
duke
parents:
diff changeset
   177
        // method call can be used to set a desired read index.
02bb8761fcce Initial load
duke
parents:
diff changeset
   178
        bis = new _ByteArrayInputStream(buf);
02bb8761fcce Initial load
duke
parents:
diff changeset
   179
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   180
02bb8761fcce Initial load
duke
parents:
diff changeset
   181
    // Called from read_octet or read_long or read_ulong method.
02bb8761fcce Initial load
duke
parents:
diff changeset
   182
    private void initObjectInputStream() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   183
        //System.out.print(" is ");
02bb8761fcce Initial load
duke
parents:
diff changeset
   184
        if (is != null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   185
            throw wrapper.javaStreamInitFailed();
02bb8761fcce Initial load
duke
parents:
diff changeset
   186
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   187
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   188
            is = new MarshalObjectInputStream(bis, orb);
02bb8761fcce Initial load
duke
parents:
diff changeset
   189
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   190
            throw wrapper.javaStreamInitFailed(e);
02bb8761fcce Initial load
duke
parents:
diff changeset
   191
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   192
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   193
02bb8761fcce Initial load
duke
parents:
diff changeset
   194
    // org.omg.CORBA.portable.InputStream
02bb8761fcce Initial load
duke
parents:
diff changeset
   195
02bb8761fcce Initial load
duke
parents:
diff changeset
   196
    // Primitive types.
02bb8761fcce Initial load
duke
parents:
diff changeset
   197
02bb8761fcce Initial load
duke
parents:
diff changeset
   198
    public boolean read_boolean() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   199
        if (!markOn && !(markedItemQ.isEmpty())) { // dequeue
02bb8761fcce Initial load
duke
parents:
diff changeset
   200
            return ((Boolean)markedItemQ.removeFirst()).booleanValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   201
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   202
        if (markOn && !(markedItemQ.isEmpty()) &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   203
                (peekIndex < peekCount)) { // peek
02bb8761fcce Initial load
duke
parents:
diff changeset
   204
            return ((Boolean)markedItemQ.get(peekIndex++)).booleanValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   205
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   206
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   207
            boolean value = is.readBoolean();
02bb8761fcce Initial load
duke
parents:
diff changeset
   208
            if (markOn) { // enqueue
02bb8761fcce Initial load
duke
parents:
diff changeset
   209
                markedItemQ.addLast(Boolean.valueOf(value));
02bb8761fcce Initial load
duke
parents:
diff changeset
   210
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   211
            return value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   212
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   213
            throw wrapper.javaSerializationException(e, "read_boolean");
02bb8761fcce Initial load
duke
parents:
diff changeset
   214
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   215
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   216
02bb8761fcce Initial load
duke
parents:
diff changeset
   217
    public char read_char() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   218
        if (!markOn && !(markedItemQ.isEmpty())) { // dequeue
02bb8761fcce Initial load
duke
parents:
diff changeset
   219
            return ((Character)markedItemQ.removeFirst()).charValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   220
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   221
        if (markOn && !(markedItemQ.isEmpty()) &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   222
                (peekIndex < peekCount)) { // peek
02bb8761fcce Initial load
duke
parents:
diff changeset
   223
            return ((Character)markedItemQ.get(peekIndex++)).charValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   224
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   225
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   226
            char value = is.readChar();
02bb8761fcce Initial load
duke
parents:
diff changeset
   227
            if (markOn) { // enqueue
02bb8761fcce Initial load
duke
parents:
diff changeset
   228
                markedItemQ.addLast(new Character(value));
02bb8761fcce Initial load
duke
parents:
diff changeset
   229
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   230
            return value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   231
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   232
            throw wrapper.javaSerializationException(e, "read_char");
02bb8761fcce Initial load
duke
parents:
diff changeset
   233
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   234
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   235
02bb8761fcce Initial load
duke
parents:
diff changeset
   236
    public char read_wchar() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   237
        return this.read_char();
02bb8761fcce Initial load
duke
parents:
diff changeset
   238
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   239
02bb8761fcce Initial load
duke
parents:
diff changeset
   240
    public byte read_octet() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   241
02bb8761fcce Initial load
duke
parents:
diff changeset
   242
        // check if size < [ GIOPHeader(12) + requestID(4)] bytes
02bb8761fcce Initial load
duke
parents:
diff changeset
   243
        if (bis.getPosition() < directReadLength) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   244
            byte b = (byte) bis.read();
02bb8761fcce Initial load
duke
parents:
diff changeset
   245
            if (bis.getPosition() == directReadLength) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   246
                initObjectInputStream();
02bb8761fcce Initial load
duke
parents:
diff changeset
   247
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   248
            return b;
02bb8761fcce Initial load
duke
parents:
diff changeset
   249
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   250
02bb8761fcce Initial load
duke
parents:
diff changeset
   251
        if (!markOn && !(markedItemQ.isEmpty())) { // dequeue
02bb8761fcce Initial load
duke
parents:
diff changeset
   252
            return ((Byte)markedItemQ.removeFirst()).byteValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   253
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   254
02bb8761fcce Initial load
duke
parents:
diff changeset
   255
        if (markOn && !(markedItemQ.isEmpty()) &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   256
                (peekIndex < peekCount)) { // peek
02bb8761fcce Initial load
duke
parents:
diff changeset
   257
            return ((Byte)markedItemQ.get(peekIndex++)).byteValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   258
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   259
02bb8761fcce Initial load
duke
parents:
diff changeset
   260
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   261
            byte value = is.readByte();
02bb8761fcce Initial load
duke
parents:
diff changeset
   262
            if (markOn) { // enqueue
02bb8761fcce Initial load
duke
parents:
diff changeset
   263
                //markedItemQ.addLast(Byte.valueOf(value)); // only in JDK 1.5
02bb8761fcce Initial load
duke
parents:
diff changeset
   264
                markedItemQ.addLast(new Byte(value));
02bb8761fcce Initial load
duke
parents:
diff changeset
   265
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   266
            return value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   267
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   268
            throw wrapper.javaSerializationException(e, "read_octet");
02bb8761fcce Initial load
duke
parents:
diff changeset
   269
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   270
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   271
02bb8761fcce Initial load
duke
parents:
diff changeset
   272
    public short read_short() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   273
        if (!markOn && !(markedItemQ.isEmpty())) { // dequeue
02bb8761fcce Initial load
duke
parents:
diff changeset
   274
            return ((Short)markedItemQ.removeFirst()).shortValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   275
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   276
        if (markOn && !(markedItemQ.isEmpty()) &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   277
                (peekIndex < peekCount)) { // peek
02bb8761fcce Initial load
duke
parents:
diff changeset
   278
            return ((Short)markedItemQ.get(peekIndex++)).shortValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   279
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   280
02bb8761fcce Initial load
duke
parents:
diff changeset
   281
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   282
            short value = is.readShort();
02bb8761fcce Initial load
duke
parents:
diff changeset
   283
            if (markOn) { // enqueue
02bb8761fcce Initial load
duke
parents:
diff changeset
   284
                markedItemQ.addLast(new Short(value));
02bb8761fcce Initial load
duke
parents:
diff changeset
   285
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   286
            return value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   287
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   288
            throw wrapper.javaSerializationException(e, "read_short");
02bb8761fcce Initial load
duke
parents:
diff changeset
   289
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   290
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   291
02bb8761fcce Initial load
duke
parents:
diff changeset
   292
    public short read_ushort() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   293
        return this.read_short();
02bb8761fcce Initial load
duke
parents:
diff changeset
   294
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   295
02bb8761fcce Initial load
duke
parents:
diff changeset
   296
    public int read_long() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   297
02bb8761fcce Initial load
duke
parents:
diff changeset
   298
        // check if size < [ GIOPHeader(12) + requestID(4)] bytes
02bb8761fcce Initial load
duke
parents:
diff changeset
   299
        if (bis.getPosition() < directReadLength) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   300
02bb8761fcce Initial load
duke
parents:
diff changeset
   301
            // Use big endian (network byte order). This is fixed.
02bb8761fcce Initial load
duke
parents:
diff changeset
   302
            // Both the writer and reader use the same byte order.
02bb8761fcce Initial load
duke
parents:
diff changeset
   303
            int b1 = (bis.read() << 24) & 0xFF000000;
02bb8761fcce Initial load
duke
parents:
diff changeset
   304
            int b2 = (bis.read() << 16) & 0x00FF0000;
02bb8761fcce Initial load
duke
parents:
diff changeset
   305
            int b3 = (bis.read() << 8)  & 0x0000FF00;
02bb8761fcce Initial load
duke
parents:
diff changeset
   306
            int b4 = (bis.read() << 0)  & 0x000000FF;
02bb8761fcce Initial load
duke
parents:
diff changeset
   307
02bb8761fcce Initial load
duke
parents:
diff changeset
   308
            if (bis.getPosition() == directReadLength) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   309
                initObjectInputStream();
02bb8761fcce Initial load
duke
parents:
diff changeset
   310
            } else if (bis.getPosition() > directReadLength) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   311
                // Cannot happen. All direct reads are contained
02bb8761fcce Initial load
duke
parents:
diff changeset
   312
                // within the first 16 bytes.
02bb8761fcce Initial load
duke
parents:
diff changeset
   313
                wrapper.javaSerializationException("read_long");
02bb8761fcce Initial load
duke
parents:
diff changeset
   314
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   315
02bb8761fcce Initial load
duke
parents:
diff changeset
   316
            return (b1 | b2 | b3 | b4);
02bb8761fcce Initial load
duke
parents:
diff changeset
   317
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   318
02bb8761fcce Initial load
duke
parents:
diff changeset
   319
        if (!markOn && !(markedItemQ.isEmpty())) { // dequeue
02bb8761fcce Initial load
duke
parents:
diff changeset
   320
            return ((Integer)markedItemQ.removeFirst()).intValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   321
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   322
02bb8761fcce Initial load
duke
parents:
diff changeset
   323
        if (markOn && !(markedItemQ.isEmpty()) &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   324
                (peekIndex < peekCount)) { // peek
02bb8761fcce Initial load
duke
parents:
diff changeset
   325
            return ((Integer)markedItemQ.get(peekIndex++)).intValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   326
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   327
02bb8761fcce Initial load
duke
parents:
diff changeset
   328
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   329
            int value = is.readInt();
02bb8761fcce Initial load
duke
parents:
diff changeset
   330
            if (markOn) { // enqueue
02bb8761fcce Initial load
duke
parents:
diff changeset
   331
                markedItemQ.addLast(new Integer(value));
02bb8761fcce Initial load
duke
parents:
diff changeset
   332
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   333
            return value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   334
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   335
            throw wrapper.javaSerializationException(e, "read_long");
02bb8761fcce Initial load
duke
parents:
diff changeset
   336
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   337
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   338
02bb8761fcce Initial load
duke
parents:
diff changeset
   339
    public int read_ulong() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   340
        return this.read_long();
02bb8761fcce Initial load
duke
parents:
diff changeset
   341
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   342
02bb8761fcce Initial load
duke
parents:
diff changeset
   343
    public long read_longlong() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   344
        if (!markOn && !(markedItemQ.isEmpty())) { // dequeue
02bb8761fcce Initial load
duke
parents:
diff changeset
   345
            return ((Long)markedItemQ.removeFirst()).longValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   346
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   347
        if (markOn && !(markedItemQ.isEmpty()) &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   348
                (peekIndex < peekCount)) { // peek
02bb8761fcce Initial load
duke
parents:
diff changeset
   349
            return ((Long)markedItemQ.get(peekIndex++)).longValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   350
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   351
02bb8761fcce Initial load
duke
parents:
diff changeset
   352
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   353
            long value = is.readLong();
02bb8761fcce Initial load
duke
parents:
diff changeset
   354
            if (markOn) { // enqueue
02bb8761fcce Initial load
duke
parents:
diff changeset
   355
                markedItemQ.addLast(new Long(value));
02bb8761fcce Initial load
duke
parents:
diff changeset
   356
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   357
            return value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   358
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   359
            throw wrapper.javaSerializationException(e, "read_longlong");
02bb8761fcce Initial load
duke
parents:
diff changeset
   360
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   361
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   362
02bb8761fcce Initial load
duke
parents:
diff changeset
   363
    public long read_ulonglong() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   364
        return read_longlong();
02bb8761fcce Initial load
duke
parents:
diff changeset
   365
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   366
02bb8761fcce Initial load
duke
parents:
diff changeset
   367
    public float read_float() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   368
        if (!markOn && !(markedItemQ.isEmpty())) { // dequeue
02bb8761fcce Initial load
duke
parents:
diff changeset
   369
            return ((Float)markedItemQ.removeFirst()).floatValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   370
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   371
        if (markOn && !(markedItemQ.isEmpty()) &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   372
                (peekIndex < peekCount)) { // peek
02bb8761fcce Initial load
duke
parents:
diff changeset
   373
            return ((Float)markedItemQ.get(peekIndex++)).floatValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   374
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   375
02bb8761fcce Initial load
duke
parents:
diff changeset
   376
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   377
            float value = is.readFloat();
02bb8761fcce Initial load
duke
parents:
diff changeset
   378
            if (markOn) { // enqueue
02bb8761fcce Initial load
duke
parents:
diff changeset
   379
                markedItemQ.addLast(new Float(value));
02bb8761fcce Initial load
duke
parents:
diff changeset
   380
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   381
            return value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   382
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   383
            throw wrapper.javaSerializationException(e, "read_float");
02bb8761fcce Initial load
duke
parents:
diff changeset
   384
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   385
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   386
02bb8761fcce Initial load
duke
parents:
diff changeset
   387
    public double read_double() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   388
        if (!markOn && !(markedItemQ.isEmpty())) { // dequeue
02bb8761fcce Initial load
duke
parents:
diff changeset
   389
            return ((Double)markedItemQ.removeFirst()).doubleValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   390
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   391
        if (markOn && !(markedItemQ.isEmpty()) &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   392
                (peekIndex < peekCount)) { // peek
02bb8761fcce Initial load
duke
parents:
diff changeset
   393
            return ((Double)markedItemQ.get(peekIndex++)).doubleValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   394
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   395
02bb8761fcce Initial load
duke
parents:
diff changeset
   396
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   397
            double value = is.readDouble();
02bb8761fcce Initial load
duke
parents:
diff changeset
   398
            if (markOn) { // enqueue
02bb8761fcce Initial load
duke
parents:
diff changeset
   399
                markedItemQ.addLast(new Double(value));
02bb8761fcce Initial load
duke
parents:
diff changeset
   400
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   401
            return value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   402
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   403
            throw wrapper.javaSerializationException(e, "read_double");
02bb8761fcce Initial load
duke
parents:
diff changeset
   404
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   405
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   406
02bb8761fcce Initial load
duke
parents:
diff changeset
   407
    // String types.
02bb8761fcce Initial load
duke
parents:
diff changeset
   408
02bb8761fcce Initial load
duke
parents:
diff changeset
   409
    public String read_string() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   410
        if (!markOn && !(markedItemQ.isEmpty())) { // dequeue
02bb8761fcce Initial load
duke
parents:
diff changeset
   411
            return (String) markedItemQ.removeFirst();
02bb8761fcce Initial load
duke
parents:
diff changeset
   412
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   413
        if (markOn && !(markedItemQ.isEmpty()) &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   414
            (peekIndex < peekCount)) { // peek
02bb8761fcce Initial load
duke
parents:
diff changeset
   415
            return (String) markedItemQ.get(peekIndex++);
02bb8761fcce Initial load
duke
parents:
diff changeset
   416
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   417
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   418
            String value = is.readUTF();
02bb8761fcce Initial load
duke
parents:
diff changeset
   419
            if (markOn) { // enqueue
02bb8761fcce Initial load
duke
parents:
diff changeset
   420
                markedItemQ.addLast(value);
02bb8761fcce Initial load
duke
parents:
diff changeset
   421
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   422
            return value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   423
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   424
            throw wrapper.javaSerializationException(e, "read_string");
02bb8761fcce Initial load
duke
parents:
diff changeset
   425
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   426
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   427
02bb8761fcce Initial load
duke
parents:
diff changeset
   428
    public String read_wstring() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   429
        if (!markOn && !(markedItemQ.isEmpty())) { // dequeue
02bb8761fcce Initial load
duke
parents:
diff changeset
   430
            return (String) markedItemQ.removeFirst();
02bb8761fcce Initial load
duke
parents:
diff changeset
   431
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   432
        if (markOn && !(markedItemQ.isEmpty()) &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   433
                (peekIndex < peekCount)) { // peek
02bb8761fcce Initial load
duke
parents:
diff changeset
   434
            return (String) markedItemQ.get(peekIndex++);
02bb8761fcce Initial load
duke
parents:
diff changeset
   435
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   436
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   437
            String value = (String) is.readObject();
02bb8761fcce Initial load
duke
parents:
diff changeset
   438
            if (markOn) { // enqueue
02bb8761fcce Initial load
duke
parents:
diff changeset
   439
                markedItemQ.addLast(value);
02bb8761fcce Initial load
duke
parents:
diff changeset
   440
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   441
            return value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   442
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   443
            throw wrapper.javaSerializationException(e, "read_wstring");
02bb8761fcce Initial load
duke
parents:
diff changeset
   444
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   445
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   446
02bb8761fcce Initial load
duke
parents:
diff changeset
   447
    // Array types.
02bb8761fcce Initial load
duke
parents:
diff changeset
   448
02bb8761fcce Initial load
duke
parents:
diff changeset
   449
    public void read_boolean_array(boolean[] value, int offset, int length){
02bb8761fcce Initial load
duke
parents:
diff changeset
   450
        for(int i = 0; i < length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   451
            value[i+offset] = read_boolean();
02bb8761fcce Initial load
duke
parents:
diff changeset
   452
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   453
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   454
02bb8761fcce Initial load
duke
parents:
diff changeset
   455
    public void read_char_array(char[] value, int offset, int length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   456
        for(int i=0; i < length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   457
            value[i+offset] = read_char();
02bb8761fcce Initial load
duke
parents:
diff changeset
   458
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   459
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   460
02bb8761fcce Initial load
duke
parents:
diff changeset
   461
    public void read_wchar_array(char[] value, int offset, int length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   462
        read_char_array(value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   463
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   464
02bb8761fcce Initial load
duke
parents:
diff changeset
   465
    public void read_octet_array(byte[] value, int offset, int length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   466
        for(int i=0; i < length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   467
            value[i+offset] = read_octet();
02bb8761fcce Initial load
duke
parents:
diff changeset
   468
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   469
        /* // Cannot use this efficient read due to mark/reset support.
02bb8761fcce Initial load
duke
parents:
diff changeset
   470
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   471
            while (length > 0) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   472
                int n = is.read(value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   473
                offset += n;
02bb8761fcce Initial load
duke
parents:
diff changeset
   474
                length -= n;
02bb8761fcce Initial load
duke
parents:
diff changeset
   475
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   476
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   477
            throw wrapper.javaSerializationException(e, "read_octet_array");
02bb8761fcce Initial load
duke
parents:
diff changeset
   478
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   479
        */
02bb8761fcce Initial load
duke
parents:
diff changeset
   480
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   481
02bb8761fcce Initial load
duke
parents:
diff changeset
   482
    public void read_short_array(short[] value, int offset, int length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   483
        for(int i=0; i < length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   484
            value[i+offset] = read_short();
02bb8761fcce Initial load
duke
parents:
diff changeset
   485
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   486
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   487
02bb8761fcce Initial load
duke
parents:
diff changeset
   488
    public void read_ushort_array(short[] value, int offset, int length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   489
        read_short_array(value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   490
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   491
02bb8761fcce Initial load
duke
parents:
diff changeset
   492
    public void read_long_array(int[] value, int offset, int length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   493
        for(int i=0; i < length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   494
            value[i+offset] = read_long();
02bb8761fcce Initial load
duke
parents:
diff changeset
   495
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   496
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   497
02bb8761fcce Initial load
duke
parents:
diff changeset
   498
    public void read_ulong_array(int[] value, int offset, int length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   499
        read_long_array(value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   500
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   501
02bb8761fcce Initial load
duke
parents:
diff changeset
   502
    public void read_longlong_array(long[] value, int offset, int length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   503
        for(int i=0; i < length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   504
            value[i+offset] = read_longlong();
02bb8761fcce Initial load
duke
parents:
diff changeset
   505
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   506
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   507
02bb8761fcce Initial load
duke
parents:
diff changeset
   508
    public void read_ulonglong_array(long[] value, int offset, int length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   509
        read_longlong_array(value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   510
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   511
02bb8761fcce Initial load
duke
parents:
diff changeset
   512
    public void read_float_array(float[] value, int offset, int length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   513
        for(int i=0; i < length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   514
            value[i+offset] = read_float();
02bb8761fcce Initial load
duke
parents:
diff changeset
   515
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   516
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   517
02bb8761fcce Initial load
duke
parents:
diff changeset
   518
    public void read_double_array(double[] value, int offset, int length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   519
        for(int i=0; i < length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   520
            value[i+offset] = read_double();
02bb8761fcce Initial load
duke
parents:
diff changeset
   521
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   522
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   523
02bb8761fcce Initial load
duke
parents:
diff changeset
   524
    // Complex types.
02bb8761fcce Initial load
duke
parents:
diff changeset
   525
02bb8761fcce Initial load
duke
parents:
diff changeset
   526
    public org.omg.CORBA.Object read_Object() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   527
        return read_Object(null);
02bb8761fcce Initial load
duke
parents:
diff changeset
   528
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   529
02bb8761fcce Initial load
duke
parents:
diff changeset
   530
    public TypeCode read_TypeCode() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   531
        TypeCodeImpl tc = new TypeCodeImpl(orb);
02bb8761fcce Initial load
duke
parents:
diff changeset
   532
        tc.read_value(parent);
02bb8761fcce Initial load
duke
parents:
diff changeset
   533
        return tc;
02bb8761fcce Initial load
duke
parents:
diff changeset
   534
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   535
02bb8761fcce Initial load
duke
parents:
diff changeset
   536
    public Any read_any() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   537
02bb8761fcce Initial load
duke
parents:
diff changeset
   538
        Any any = orb.create_any();
02bb8761fcce Initial load
duke
parents:
diff changeset
   539
        TypeCodeImpl tc = new TypeCodeImpl(orb);
02bb8761fcce Initial load
duke
parents:
diff changeset
   540
02bb8761fcce Initial load
duke
parents:
diff changeset
   541
        // read off the typecode
02bb8761fcce Initial load
duke
parents:
diff changeset
   542
02bb8761fcce Initial load
duke
parents:
diff changeset
   543
        // REVISIT We could avoid this try-catch if we could peek the typecode
02bb8761fcce Initial load
duke
parents:
diff changeset
   544
        // kind off this stream and see if it is a tk_value.
02bb8761fcce Initial load
duke
parents:
diff changeset
   545
        // Looking at the code we know that for tk_value the Any.read_value()
02bb8761fcce Initial load
duke
parents:
diff changeset
   546
        // below ignores the tc argument anyway (except for the kind field).
02bb8761fcce Initial load
duke
parents:
diff changeset
   547
        // But still we would need to make sure that the whole typecode,
02bb8761fcce Initial load
duke
parents:
diff changeset
   548
        // including encapsulations, is read off.
02bb8761fcce Initial load
duke
parents:
diff changeset
   549
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   550
            tc.read_value(parent);
02bb8761fcce Initial load
duke
parents:
diff changeset
   551
        } catch (org.omg.CORBA.MARSHAL ex) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   552
            if (tc.kind().value() != org.omg.CORBA.TCKind._tk_value) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   553
                throw ex;
02bb8761fcce Initial load
duke
parents:
diff changeset
   554
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   555
            // We can be sure that the whole typecode encapsulation has been
02bb8761fcce Initial load
duke
parents:
diff changeset
   556
            // read off.
02bb8761fcce Initial load
duke
parents:
diff changeset
   557
            ex.printStackTrace();
02bb8761fcce Initial load
duke
parents:
diff changeset
   558
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   559
02bb8761fcce Initial load
duke
parents:
diff changeset
   560
        // read off the value of the any.
02bb8761fcce Initial load
duke
parents:
diff changeset
   561
        any.read_value(parent, tc);
02bb8761fcce Initial load
duke
parents:
diff changeset
   562
02bb8761fcce Initial load
duke
parents:
diff changeset
   563
        return any;
02bb8761fcce Initial load
duke
parents:
diff changeset
   564
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   565
02bb8761fcce Initial load
duke
parents:
diff changeset
   566
    public Principal read_Principal() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   567
        // We don't need an implementation for this method, since principal
02bb8761fcce Initial load
duke
parents:
diff changeset
   568
        // is absent in GIOP version 1.2 or above.
02bb8761fcce Initial load
duke
parents:
diff changeset
   569
        int len = read_long();
02bb8761fcce Initial load
duke
parents:
diff changeset
   570
        byte[] pvalue = new byte[len];
02bb8761fcce Initial load
duke
parents:
diff changeset
   571
        read_octet_array(pvalue,0,len);
02bb8761fcce Initial load
duke
parents:
diff changeset
   572
        Principal p = new com.sun.corba.se.impl.corba.PrincipalImpl();
02bb8761fcce Initial load
duke
parents:
diff changeset
   573
        p.name(pvalue);
02bb8761fcce Initial load
duke
parents:
diff changeset
   574
        return p;
02bb8761fcce Initial load
duke
parents:
diff changeset
   575
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   576
02bb8761fcce Initial load
duke
parents:
diff changeset
   577
    public BigDecimal read_fixed() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   578
        return new BigDecimal(read_fixed_buffer().toString());
02bb8761fcce Initial load
duke
parents:
diff changeset
   579
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   580
02bb8761fcce Initial load
duke
parents:
diff changeset
   581
    // Each octet contains (up to) two decimal digits. If the fixed type has
02bb8761fcce Initial load
duke
parents:
diff changeset
   582
    // an odd number of decimal digits, then the representation
02bb8761fcce Initial load
duke
parents:
diff changeset
   583
    // begins with the first (most significant) digit.
02bb8761fcce Initial load
duke
parents:
diff changeset
   584
    // Otherwise, this first half-octet is all zero, and the first digit
02bb8761fcce Initial load
duke
parents:
diff changeset
   585
    // is in the second half-octet.
02bb8761fcce Initial load
duke
parents:
diff changeset
   586
    // The sign configuration, in the last half-octet of the representation,
02bb8761fcce Initial load
duke
parents:
diff changeset
   587
    // is 0xD for negative numbers and 0xC for positive and zero values.
02bb8761fcce Initial load
duke
parents:
diff changeset
   588
    private StringBuffer read_fixed_buffer() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   589
        StringBuffer buffer = new StringBuffer(64);
02bb8761fcce Initial load
duke
parents:
diff changeset
   590
        byte doubleDigit;
02bb8761fcce Initial load
duke
parents:
diff changeset
   591
        int firstDigit;
02bb8761fcce Initial load
duke
parents:
diff changeset
   592
        int secondDigit;
02bb8761fcce Initial load
duke
parents:
diff changeset
   593
        boolean wroteFirstDigit = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   594
        boolean more = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   595
        while (more) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   596
            doubleDigit = read_octet();
02bb8761fcce Initial load
duke
parents:
diff changeset
   597
            firstDigit = (int)((doubleDigit & 0xf0) >> 4);
02bb8761fcce Initial load
duke
parents:
diff changeset
   598
            secondDigit = (int)(doubleDigit & 0x0f);
02bb8761fcce Initial load
duke
parents:
diff changeset
   599
            if (wroteFirstDigit || firstDigit != 0) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   600
                buffer.append(Character.forDigit(firstDigit, 10));
02bb8761fcce Initial load
duke
parents:
diff changeset
   601
                wroteFirstDigit = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   602
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   603
            if (secondDigit == 12) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   604
                // positive number or zero
02bb8761fcce Initial load
duke
parents:
diff changeset
   605
                if ( ! wroteFirstDigit) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   606
                    // zero
02bb8761fcce Initial load
duke
parents:
diff changeset
   607
                    return new StringBuffer("0.0");
02bb8761fcce Initial load
duke
parents:
diff changeset
   608
                } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   609
                    // positive number
02bb8761fcce Initial load
duke
parents:
diff changeset
   610
                    // done
02bb8761fcce Initial load
duke
parents:
diff changeset
   611
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   612
                more = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   613
            } else if (secondDigit == 13) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   614
                // negative number
02bb8761fcce Initial load
duke
parents:
diff changeset
   615
                buffer.insert(0, '-');
02bb8761fcce Initial load
duke
parents:
diff changeset
   616
                more = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   617
            } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   618
                buffer.append(Character.forDigit(secondDigit, 10));
02bb8761fcce Initial load
duke
parents:
diff changeset
   619
                wroteFirstDigit = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   620
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   621
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   622
        return buffer;
02bb8761fcce Initial load
duke
parents:
diff changeset
   623
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   624
02bb8761fcce Initial load
duke
parents:
diff changeset
   625
    public org.omg.CORBA.Object read_Object(java.lang.Class clz) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   626
02bb8761fcce Initial load
duke
parents:
diff changeset
   627
        // In any case, we must first read the IOR.
02bb8761fcce Initial load
duke
parents:
diff changeset
   628
        IOR ior = IORFactories.makeIOR(parent) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   629
        if (ior.isNil()) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   630
            return null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   631
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   632
02bb8761fcce Initial load
duke
parents:
diff changeset
   633
        PresentationManager.StubFactoryFactory sff =
02bb8761fcce Initial load
duke
parents:
diff changeset
   634
            ORB.getStubFactoryFactory();
02bb8761fcce Initial load
duke
parents:
diff changeset
   635
        String codeBase = ior.getProfile().getCodebase();
02bb8761fcce Initial load
duke
parents:
diff changeset
   636
        PresentationManager.StubFactory stubFactory = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   637
02bb8761fcce Initial load
duke
parents:
diff changeset
   638
        if (clz == null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   639
            RepositoryId rid = RepositoryId.cache.getId(ior.getTypeId() );
02bb8761fcce Initial load
duke
parents:
diff changeset
   640
            String className = rid.getClassName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   641
            boolean isIDLInterface = rid.isIDLType();
02bb8761fcce Initial load
duke
parents:
diff changeset
   642
02bb8761fcce Initial load
duke
parents:
diff changeset
   643
            if (className == null || className.equals( "" )) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   644
                stubFactory = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   645
            } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   646
                try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   647
                    stubFactory = sff.createStubFactory(className,
02bb8761fcce Initial load
duke
parents:
diff changeset
   648
                        isIDLInterface, codeBase, (Class) null,
02bb8761fcce Initial load
duke
parents:
diff changeset
   649
                        (ClassLoader) null);
02bb8761fcce Initial load
duke
parents:
diff changeset
   650
                } catch (Exception exc) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   651
                    // Could not create stubFactory, so use null.
02bb8761fcce Initial load
duke
parents:
diff changeset
   652
                    // XXX stubFactory handling is still too complex:
02bb8761fcce Initial load
duke
parents:
diff changeset
   653
                    // Can we resolve the stubFactory question once in
02bb8761fcce Initial load
duke
parents:
diff changeset
   654
                    // a single place?
02bb8761fcce Initial load
duke
parents:
diff changeset
   655
                    stubFactory = null ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   656
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   657
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   658
        } else if (StubAdapter.isStubClass(clz)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   659
            stubFactory = PresentationDefaults.makeStaticStubFactory(clz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   660
        } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   661
            // clz is an interface class
02bb8761fcce Initial load
duke
parents:
diff changeset
   662
            boolean isIDL = IDLEntity.class.isAssignableFrom(clz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   663
02bb8761fcce Initial load
duke
parents:
diff changeset
   664
            stubFactory = sff.createStubFactory(
02bb8761fcce Initial load
duke
parents:
diff changeset
   665
                 clz.getName(), isIDL, codeBase, clz, clz.getClassLoader());
02bb8761fcce Initial load
duke
parents:
diff changeset
   666
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   667
02bb8761fcce Initial load
duke
parents:
diff changeset
   668
        return CDRInputStream_1_0.internalIORToObject(ior, stubFactory, orb);
02bb8761fcce Initial load
duke
parents:
diff changeset
   669
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   670
02bb8761fcce Initial load
duke
parents:
diff changeset
   671
    public org.omg.CORBA.ORB orb() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   672
        return this.orb;
02bb8761fcce Initial load
duke
parents:
diff changeset
   673
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   674
02bb8761fcce Initial load
duke
parents:
diff changeset
   675
    // org.omg.CORBA_2_3.portable.InputStream
02bb8761fcce Initial load
duke
parents:
diff changeset
   676
02bb8761fcce Initial load
duke
parents:
diff changeset
   677
    public java.io.Serializable read_value() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   678
        if (!markOn && !(markedItemQ.isEmpty())) { // dequeue
02bb8761fcce Initial load
duke
parents:
diff changeset
   679
            return (Serializable) markedItemQ.removeFirst();
02bb8761fcce Initial load
duke
parents:
diff changeset
   680
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   681
        if (markOn && !(markedItemQ.isEmpty()) &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   682
                (peekIndex < peekCount)) { // peek
02bb8761fcce Initial load
duke
parents:
diff changeset
   683
            return (Serializable) markedItemQ.get(peekIndex++);
02bb8761fcce Initial load
duke
parents:
diff changeset
   684
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   685
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   686
            Serializable value = (java.io.Serializable) is.readObject();
02bb8761fcce Initial load
duke
parents:
diff changeset
   687
            if (markOn) { // enqueue
02bb8761fcce Initial load
duke
parents:
diff changeset
   688
                markedItemQ.addLast(value);
02bb8761fcce Initial load
duke
parents:
diff changeset
   689
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   690
            return value;
02bb8761fcce Initial load
duke
parents:
diff changeset
   691
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   692
            throw wrapper.javaSerializationException(e, "read_value");
02bb8761fcce Initial load
duke
parents:
diff changeset
   693
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   694
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   695
02bb8761fcce Initial load
duke
parents:
diff changeset
   696
    public java.io.Serializable read_value(java.lang.Class clz) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   697
        return read_value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   698
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   699
02bb8761fcce Initial load
duke
parents:
diff changeset
   700
    public java.io.Serializable read_value(
02bb8761fcce Initial load
duke
parents:
diff changeset
   701
            org.omg.CORBA.portable.BoxedValueHelper factory) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   702
        return read_value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   703
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   704
02bb8761fcce Initial load
duke
parents:
diff changeset
   705
    public java.io.Serializable read_value(java.lang.String rep_id) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   706
        return read_value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   707
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   708
02bb8761fcce Initial load
duke
parents:
diff changeset
   709
    public java.io.Serializable read_value(java.io.Serializable value) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   710
        return read_value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   711
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   712
02bb8761fcce Initial load
duke
parents:
diff changeset
   713
    public java.lang.Object read_abstract_interface() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   714
        return read_abstract_interface(null);
02bb8761fcce Initial load
duke
parents:
diff changeset
   715
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   716
02bb8761fcce Initial load
duke
parents:
diff changeset
   717
    public java.lang.Object read_abstract_interface(java.lang.Class clz) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   718
        boolean isObject = read_boolean();
02bb8761fcce Initial load
duke
parents:
diff changeset
   719
        if (isObject) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   720
            return read_Object(clz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   721
        } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   722
            return read_value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   723
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   724
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   725
02bb8761fcce Initial load
duke
parents:
diff changeset
   726
    // com.sun.corba.se.impl.encoding.MarshalInputStream
02bb8761fcce Initial load
duke
parents:
diff changeset
   727
    public void consumeEndian() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   728
        throw wrapper.giopVersionError();
02bb8761fcce Initial load
duke
parents:
diff changeset
   729
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   730
02bb8761fcce Initial load
duke
parents:
diff changeset
   731
    public int getPosition() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   732
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   733
            return bis.getPosition();
02bb8761fcce Initial load
duke
parents:
diff changeset
   734
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   735
            throw wrapper.javaSerializationException(e, "getPosition");
02bb8761fcce Initial load
duke
parents:
diff changeset
   736
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   737
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   738
02bb8761fcce Initial load
duke
parents:
diff changeset
   739
    // org.omg.CORBA.DataInputStream
02bb8761fcce Initial load
duke
parents:
diff changeset
   740
    public java.lang.Object read_Abstract() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   741
        return read_abstract_interface();
02bb8761fcce Initial load
duke
parents:
diff changeset
   742
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   743
02bb8761fcce Initial load
duke
parents:
diff changeset
   744
    public java.io.Serializable read_Value() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   745
        return read_value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   746
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   747
02bb8761fcce Initial load
duke
parents:
diff changeset
   748
    public void read_any_array (org.omg.CORBA.AnySeqHolder seq,
02bb8761fcce Initial load
duke
parents:
diff changeset
   749
                                int offset, int length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   750
        read_any_array(seq.value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   751
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   752
02bb8761fcce Initial load
duke
parents:
diff changeset
   753
    private final void read_any_array(org.omg.CORBA.Any[] value,
02bb8761fcce Initial load
duke
parents:
diff changeset
   754
                                     int offset, int length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   755
        for(int i=0; i < length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   756
            value[i+offset] = read_any();
02bb8761fcce Initial load
duke
parents:
diff changeset
   757
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   758
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   759
02bb8761fcce Initial load
duke
parents:
diff changeset
   760
    public void read_boolean_array (org.omg.CORBA.BooleanSeqHolder seq,
02bb8761fcce Initial load
duke
parents:
diff changeset
   761
                                    int offset, int length){
02bb8761fcce Initial load
duke
parents:
diff changeset
   762
        read_boolean_array(seq.value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   763
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   764
02bb8761fcce Initial load
duke
parents:
diff changeset
   765
    public void read_char_array (org.omg.CORBA.CharSeqHolder seq,
02bb8761fcce Initial load
duke
parents:
diff changeset
   766
                                 int offset, int length){
02bb8761fcce Initial load
duke
parents:
diff changeset
   767
        read_char_array(seq.value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   768
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   769
02bb8761fcce Initial load
duke
parents:
diff changeset
   770
    public void read_wchar_array (org.omg.CORBA.WCharSeqHolder seq,
02bb8761fcce Initial load
duke
parents:
diff changeset
   771
                                  int offset, int length){
02bb8761fcce Initial load
duke
parents:
diff changeset
   772
        read_wchar_array(seq.value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   773
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   774
02bb8761fcce Initial load
duke
parents:
diff changeset
   775
    public void read_octet_array (org.omg.CORBA.OctetSeqHolder seq,
02bb8761fcce Initial load
duke
parents:
diff changeset
   776
                                  int offset, int length){
02bb8761fcce Initial load
duke
parents:
diff changeset
   777
        read_octet_array(seq.value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   778
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   779
02bb8761fcce Initial load
duke
parents:
diff changeset
   780
    public void read_short_array (org.omg.CORBA.ShortSeqHolder seq,
02bb8761fcce Initial load
duke
parents:
diff changeset
   781
                                  int offset, int length){
02bb8761fcce Initial load
duke
parents:
diff changeset
   782
        read_short_array(seq.value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   783
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   784
02bb8761fcce Initial load
duke
parents:
diff changeset
   785
    public void read_ushort_array (org.omg.CORBA.UShortSeqHolder seq,
02bb8761fcce Initial load
duke
parents:
diff changeset
   786
                                   int offset, int length){
02bb8761fcce Initial load
duke
parents:
diff changeset
   787
        read_ushort_array(seq.value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   788
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   789
02bb8761fcce Initial load
duke
parents:
diff changeset
   790
    public void read_long_array (org.omg.CORBA.LongSeqHolder seq,
02bb8761fcce Initial load
duke
parents:
diff changeset
   791
                                 int offset, int length){
02bb8761fcce Initial load
duke
parents:
diff changeset
   792
        read_long_array(seq.value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   793
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   794
02bb8761fcce Initial load
duke
parents:
diff changeset
   795
    public void read_ulong_array (org.omg.CORBA.ULongSeqHolder seq,
02bb8761fcce Initial load
duke
parents:
diff changeset
   796
                                  int offset, int length){
02bb8761fcce Initial load
duke
parents:
diff changeset
   797
        read_ulong_array(seq.value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   798
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   799
02bb8761fcce Initial load
duke
parents:
diff changeset
   800
    public void read_ulonglong_array (org.omg.CORBA.ULongLongSeqHolder seq,
02bb8761fcce Initial load
duke
parents:
diff changeset
   801
                                      int offset, int length){
02bb8761fcce Initial load
duke
parents:
diff changeset
   802
        read_ulonglong_array(seq.value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   803
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   804
02bb8761fcce Initial load
duke
parents:
diff changeset
   805
    public void read_longlong_array (org.omg.CORBA.LongLongSeqHolder seq,
02bb8761fcce Initial load
duke
parents:
diff changeset
   806
                                     int offset, int length){
02bb8761fcce Initial load
duke
parents:
diff changeset
   807
        read_longlong_array(seq.value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   808
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   809
02bb8761fcce Initial load
duke
parents:
diff changeset
   810
    public void read_float_array (org.omg.CORBA.FloatSeqHolder seq,
02bb8761fcce Initial load
duke
parents:
diff changeset
   811
                                  int offset, int length){
02bb8761fcce Initial load
duke
parents:
diff changeset
   812
        read_float_array(seq.value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   813
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   814
02bb8761fcce Initial load
duke
parents:
diff changeset
   815
    public void read_double_array (org.omg.CORBA.DoubleSeqHolder seq,
02bb8761fcce Initial load
duke
parents:
diff changeset
   816
                                   int offset, int length){
02bb8761fcce Initial load
duke
parents:
diff changeset
   817
        read_double_array(seq.value, offset, length);
02bb8761fcce Initial load
duke
parents:
diff changeset
   818
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   819
02bb8761fcce Initial load
duke
parents:
diff changeset
   820
    // org.omg.CORBA.portable.ValueBase
02bb8761fcce Initial load
duke
parents:
diff changeset
   821
02bb8761fcce Initial load
duke
parents:
diff changeset
   822
    public String[] _truncatable_ids() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   823
        throw wrapper.giopVersionError();
02bb8761fcce Initial load
duke
parents:
diff changeset
   824
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   825
02bb8761fcce Initial load
duke
parents:
diff changeset
   826
    // java.io.InputStream
02bb8761fcce Initial load
duke
parents:
diff changeset
   827
    // REVISIT - should we make these throw UnsupportedOperationExceptions?
02bb8761fcce Initial load
duke
parents:
diff changeset
   828
    // Right now, they'll go up to the java.io versions!
02bb8761fcce Initial load
duke
parents:
diff changeset
   829
02bb8761fcce Initial load
duke
parents:
diff changeset
   830
    //     public int read(byte b[]) throws IOException;
02bb8761fcce Initial load
duke
parents:
diff changeset
   831
    //     public int read(byte b[], int off, int len) throws IOException
02bb8761fcce Initial load
duke
parents:
diff changeset
   832
    //     public long skip(long n) throws IOException;
02bb8761fcce Initial load
duke
parents:
diff changeset
   833
    //     public int available() throws IOException;
02bb8761fcce Initial load
duke
parents:
diff changeset
   834
    //     public void close() throws IOException;
02bb8761fcce Initial load
duke
parents:
diff changeset
   835
02bb8761fcce Initial load
duke
parents:
diff changeset
   836
    public void mark(int readLimit) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   837
        // Nested mark disallowed.
02bb8761fcce Initial load
duke
parents:
diff changeset
   838
        // Further, mark is not supported until first 16 bytes are read.
02bb8761fcce Initial load
duke
parents:
diff changeset
   839
        if (markOn || is == null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   840
            throw wrapper.javaSerializationException("mark");
02bb8761fcce Initial load
duke
parents:
diff changeset
   841
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   842
        markOn = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   843
        if (!(markedItemQ.isEmpty())) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   844
            peekIndex = 0;
02bb8761fcce Initial load
duke
parents:
diff changeset
   845
            peekCount = markedItemQ.size();
02bb8761fcce Initial load
duke
parents:
diff changeset
   846
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   847
        /*
02bb8761fcce Initial load
duke
parents:
diff changeset
   848
        // Note: only ByteArrayInputStream supports mark/reset.
02bb8761fcce Initial load
duke
parents:
diff changeset
   849
        if (is == null || is.markSupported() == false) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   850
            throw wrapper.javaSerializationException("mark");
02bb8761fcce Initial load
duke
parents:
diff changeset
   851
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   852
        is.mark(readLimit);
02bb8761fcce Initial load
duke
parents:
diff changeset
   853
        */
02bb8761fcce Initial load
duke
parents:
diff changeset
   854
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   855
02bb8761fcce Initial load
duke
parents:
diff changeset
   856
    public void reset() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   857
        markOn = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   858
        peekIndex = 0;
02bb8761fcce Initial load
duke
parents:
diff changeset
   859
        peekCount = 0;
02bb8761fcce Initial load
duke
parents:
diff changeset
   860
        /*
02bb8761fcce Initial load
duke
parents:
diff changeset
   861
        // Note: only ByteArrayInputStream supports mark/reset.
02bb8761fcce Initial load
duke
parents:
diff changeset
   862
        if (is == null || is.markSupported() == false) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   863
            throw wrapper.javaSerializationException("mark");
02bb8761fcce Initial load
duke
parents:
diff changeset
   864
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   865
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   866
            is.reset();
02bb8761fcce Initial load
duke
parents:
diff changeset
   867
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   868
            throw wrapper.javaSerializationException(e, "reset");
02bb8761fcce Initial load
duke
parents:
diff changeset
   869
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   870
        */
02bb8761fcce Initial load
duke
parents:
diff changeset
   871
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   872
02bb8761fcce Initial load
duke
parents:
diff changeset
   873
    // This should return false so that outside users (people using the JDK)
02bb8761fcce Initial load
duke
parents:
diff changeset
   874
    // don't have any guarantees that mark/reset will work in their
02bb8761fcce Initial load
duke
parents:
diff changeset
   875
    // custom marshaling code.  This is necessary since they could do things
02bb8761fcce Initial load
duke
parents:
diff changeset
   876
    // like expect obj1a == obj1b in the following code:
02bb8761fcce Initial load
duke
parents:
diff changeset
   877
    //
02bb8761fcce Initial load
duke
parents:
diff changeset
   878
    // is.mark(10000);
02bb8761fcce Initial load
duke
parents:
diff changeset
   879
    // Object obj1a = is.readObject();
02bb8761fcce Initial load
duke
parents:
diff changeset
   880
    // is.reset();
02bb8761fcce Initial load
duke
parents:
diff changeset
   881
    // Object obj1b = is.readObject();
02bb8761fcce Initial load
duke
parents:
diff changeset
   882
    //
02bb8761fcce Initial load
duke
parents:
diff changeset
   883
    public boolean markSupported() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   884
        return true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   885
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   886
02bb8761fcce Initial load
duke
parents:
diff changeset
   887
    // Needed by AnyImpl and ServiceContexts
02bb8761fcce Initial load
duke
parents:
diff changeset
   888
    public CDRInputStreamBase dup() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   889
02bb8761fcce Initial load
duke
parents:
diff changeset
   890
        CDRInputStreamBase result = null ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   891
02bb8761fcce Initial load
duke
parents:
diff changeset
   892
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   893
            result = (CDRInputStreamBase) this.getClass().newInstance();
02bb8761fcce Initial load
duke
parents:
diff changeset
   894
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   895
            throw wrapper.couldNotDuplicateCdrInputStream(e);
02bb8761fcce Initial load
duke
parents:
diff changeset
   896
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   897
02bb8761fcce Initial load
duke
parents:
diff changeset
   898
        result.init(this.orb, this.buffer, this.bufSize, false, null);
02bb8761fcce Initial load
duke
parents:
diff changeset
   899
02bb8761fcce Initial load
duke
parents:
diff changeset
   900
        // Set the buffer position.
02bb8761fcce Initial load
duke
parents:
diff changeset
   901
        ((IDLJavaSerializationInputStream)result).skipBytes(getPosition());
02bb8761fcce Initial load
duke
parents:
diff changeset
   902
02bb8761fcce Initial load
duke
parents:
diff changeset
   903
        // Set mark related data.
02bb8761fcce Initial load
duke
parents:
diff changeset
   904
        ((IDLJavaSerializationInputStream)result).
02bb8761fcce Initial load
duke
parents:
diff changeset
   905
            setMarkData(markOn, peekIndex, peekCount,
02bb8761fcce Initial load
duke
parents:
diff changeset
   906
                        (LinkedList) markedItemQ.clone());
02bb8761fcce Initial load
duke
parents:
diff changeset
   907
02bb8761fcce Initial load
duke
parents:
diff changeset
   908
        return result;
02bb8761fcce Initial load
duke
parents:
diff changeset
   909
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   910
02bb8761fcce Initial load
duke
parents:
diff changeset
   911
    // Used exclusively by the dup() method.
02bb8761fcce Initial load
duke
parents:
diff changeset
   912
    void skipBytes(int len) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   913
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   914
            is.skipBytes(len);
02bb8761fcce Initial load
duke
parents:
diff changeset
   915
        } catch (Exception e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   916
            throw wrapper.javaSerializationException(e, "skipBytes");
02bb8761fcce Initial load
duke
parents:
diff changeset
   917
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   918
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   919
02bb8761fcce Initial load
duke
parents:
diff changeset
   920
    // Used exclusively by the dup() method.
02bb8761fcce Initial load
duke
parents:
diff changeset
   921
    void setMarkData(boolean markOn, int peekIndex, int peekCount,
02bb8761fcce Initial load
duke
parents:
diff changeset
   922
                     LinkedList markedItemQ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   923
        this.markOn = markOn;
02bb8761fcce Initial load
duke
parents:
diff changeset
   924
        this.peekIndex = peekIndex;
02bb8761fcce Initial load
duke
parents:
diff changeset
   925
        this.peekCount = peekCount;
02bb8761fcce Initial load
duke
parents:
diff changeset
   926
        this.markedItemQ = markedItemQ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   927
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   928
02bb8761fcce Initial load
duke
parents:
diff changeset
   929
    // Needed by TCUtility
02bb8761fcce Initial load
duke
parents:
diff changeset
   930
    public java.math.BigDecimal read_fixed(short digits, short scale) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   931
        // digits isn't really needed here
02bb8761fcce Initial load
duke
parents:
diff changeset
   932
        StringBuffer buffer = read_fixed_buffer();
02bb8761fcce Initial load
duke
parents:
diff changeset
   933
        if (digits != buffer.length())
02bb8761fcce Initial load
duke
parents:
diff changeset
   934
            throw wrapper.badFixed( new Integer(digits),
02bb8761fcce Initial load
duke
parents:
diff changeset
   935
                new Integer(buffer.length()) ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   936
        buffer.insert(digits - scale, '.');
02bb8761fcce Initial load
duke
parents:
diff changeset
   937
        return new BigDecimal(buffer.toString());
02bb8761fcce Initial load
duke
parents:
diff changeset
   938
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   939
02bb8761fcce Initial load
duke
parents:
diff changeset
   940
    // Needed by TypeCodeImpl
02bb8761fcce Initial load
duke
parents:
diff changeset
   941
    public boolean isLittleEndian() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   942
        throw wrapper.giopVersionError();
02bb8761fcce Initial load
duke
parents:
diff changeset
   943
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   944
02bb8761fcce Initial load
duke
parents:
diff changeset
   945
    // Needed by request and reply messages for GIOP versions >= 1.2 only.
02bb8761fcce Initial load
duke
parents:
diff changeset
   946
    void setHeaderPadding(boolean headerPadding) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   947
        // no-op. We don't care about body alignment while using
02bb8761fcce Initial load
duke
parents:
diff changeset
   948
        // Java serialization. What the GIOP spec states does not apply here.
02bb8761fcce Initial load
duke
parents:
diff changeset
   949
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   950
02bb8761fcce Initial load
duke
parents:
diff changeset
   951
    // Needed by IIOPInputStream and other subclasses
02bb8761fcce Initial load
duke
parents:
diff changeset
   952
02bb8761fcce Initial load
duke
parents:
diff changeset
   953
    public ByteBuffer getByteBuffer() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   954
        throw wrapper.giopVersionError();
02bb8761fcce Initial load
duke
parents:
diff changeset
   955
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   956
02bb8761fcce Initial load
duke
parents:
diff changeset
   957
    public void setByteBuffer(ByteBuffer byteBuffer) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   958
        throw wrapper.giopVersionError();
02bb8761fcce Initial load
duke
parents:
diff changeset
   959
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   960
02bb8761fcce Initial load
duke
parents:
diff changeset
   961
    public void setByteBufferWithInfo(ByteBufferWithInfo bbwi) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   962
        throw wrapper.giopVersionError();
02bb8761fcce Initial load
duke
parents:
diff changeset
   963
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   964
02bb8761fcce Initial load
duke
parents:
diff changeset
   965
    public int getBufferLength() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   966
        return bufSize;
02bb8761fcce Initial load
duke
parents:
diff changeset
   967
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   968
02bb8761fcce Initial load
duke
parents:
diff changeset
   969
    public void setBufferLength(int value) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   970
        // this is redundant, since buffer size was already specified
02bb8761fcce Initial load
duke
parents:
diff changeset
   971
        // as part of the init call. So, ignore.
02bb8761fcce Initial load
duke
parents:
diff changeset
   972
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   973
02bb8761fcce Initial load
duke
parents:
diff changeset
   974
    public int getIndex() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   975
        return bis.getPosition();
02bb8761fcce Initial load
duke
parents:
diff changeset
   976
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   977
02bb8761fcce Initial load
duke
parents:
diff changeset
   978
    public void setIndex(int value) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   979
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   980
            bis.setPosition(value);
02bb8761fcce Initial load
duke
parents:
diff changeset
   981
        } catch (IndexOutOfBoundsException e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   982
            throw wrapper.javaSerializationException(e, "setIndex");
02bb8761fcce Initial load
duke
parents:
diff changeset
   983
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   984
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   985
02bb8761fcce Initial load
duke
parents:
diff changeset
   986
    public void orb(org.omg.CORBA.ORB orb) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   987
        this.orb = (ORB) orb;
02bb8761fcce Initial load
duke
parents:
diff changeset
   988
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   989
02bb8761fcce Initial load
duke
parents:
diff changeset
   990
    public BufferManagerRead getBufferManager() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   991
        return bufferManager;
02bb8761fcce Initial load
duke
parents:
diff changeset
   992
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   993
02bb8761fcce Initial load
duke
parents:
diff changeset
   994
    public GIOPVersion getGIOPVersion() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   995
        return GIOPVersion.V1_2;
02bb8761fcce Initial load
duke
parents:
diff changeset
   996
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   997
02bb8761fcce Initial load
duke
parents:
diff changeset
   998
    com.sun.org.omg.SendingContext.CodeBase getCodeBase() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   999
        return parent.getCodeBase();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1000
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1001
02bb8761fcce Initial load
duke
parents:
diff changeset
  1002
    void printBuffer() {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1003
        byte[] buf = this.buffer.array();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1004
02bb8761fcce Initial load
duke
parents:
diff changeset
  1005
        System.out.println("+++++++ Input Buffer ++++++++");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1006
        System.out.println();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1007
        System.out.println("Current position: " + getPosition());
02bb8761fcce Initial load
duke
parents:
diff changeset
  1008
        System.out.println("Total length : " + this.bufSize);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1009
        System.out.println();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1010
02bb8761fcce Initial load
duke
parents:
diff changeset
  1011
        char[] charBuf = new char[16];
02bb8761fcce Initial load
duke
parents:
diff changeset
  1012
02bb8761fcce Initial load
duke
parents:
diff changeset
  1013
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1014
02bb8761fcce Initial load
duke
parents:
diff changeset
  1015
            for (int i = 0; i < buf.length; i += 16) {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1016
02bb8761fcce Initial load
duke
parents:
diff changeset
  1017
                int j = 0;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1018
02bb8761fcce Initial load
duke
parents:
diff changeset
  1019
                // For every 16 bytes, there is one line
02bb8761fcce Initial load
duke
parents:
diff changeset
  1020
                // of output.  First, the hex output of
02bb8761fcce Initial load
duke
parents:
diff changeset
  1021
                // the 16 bytes with each byte separated
02bb8761fcce Initial load
duke
parents:
diff changeset
  1022
                // by a space.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1023
                while (j < 16 && j + i < buf.length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1024
                    int k = buf[i + j];
02bb8761fcce Initial load
duke
parents:
diff changeset
  1025
                    if (k < 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1026
                        k = 256 + k;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1027
                    String hex = Integer.toHexString(k);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1028
                    if (hex.length() == 1)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1029
                        hex = "0" + hex;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1030
                    System.out.print(hex + " ");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1031
                    j++;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1032
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1033
02bb8761fcce Initial load
duke
parents:
diff changeset
  1034
                // Add any extra spaces to align the
02bb8761fcce Initial load
duke
parents:
diff changeset
  1035
                // text column in case we didn't end
02bb8761fcce Initial load
duke
parents:
diff changeset
  1036
                // at 16
02bb8761fcce Initial load
duke
parents:
diff changeset
  1037
                while (j < 16) {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1038
                    System.out.print("   ");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1039
                    j++;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1040
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1041
02bb8761fcce Initial load
duke
parents:
diff changeset
  1042
                // Now output the ASCII equivalents.  Non-ASCII
02bb8761fcce Initial load
duke
parents:
diff changeset
  1043
                // characters are shown as periods.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1044
                int x = 0;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1045
02bb8761fcce Initial load
duke
parents:
diff changeset
  1046
                while (x < 16 && x + i < buf.length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1047
                    if (ORBUtility.isPrintable((char)buf[i + x])) {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1048
                        charBuf[x] = (char) buf[i + x];
02bb8761fcce Initial load
duke
parents:
diff changeset
  1049
                    } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1050
                        charBuf[x] = '.';
02bb8761fcce Initial load
duke
parents:
diff changeset
  1051
                    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1052
                    x++;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1053
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1054
                System.out.println(new String(charBuf, 0, x));
02bb8761fcce Initial load
duke
parents:
diff changeset
  1055
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1056
        } catch (Throwable t) {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1057
            t.printStackTrace();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1058
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1059
        System.out.println("++++++++++++++++++++++++++++++");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1060
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1061
02bb8761fcce Initial load
duke
parents:
diff changeset
  1062
    void alignOnBoundary(int octetBoundary) {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1063
        throw wrapper.giopVersionError();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1064
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1065
02bb8761fcce Initial load
duke
parents:
diff changeset
  1066
    void performORBVersionSpecificInit() {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1067
        // No-op.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1068
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1069
02bb8761fcce Initial load
duke
parents:
diff changeset
  1070
    public void resetCodeSetConverters() {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1071
        // No-op.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1072
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1073
02bb8761fcce Initial load
duke
parents:
diff changeset
  1074
    // ValueInputStream -------------------------
02bb8761fcce Initial load
duke
parents:
diff changeset
  1075
02bb8761fcce Initial load
duke
parents:
diff changeset
  1076
    public void start_value() {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1077
        throw wrapper.giopVersionError();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1078
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1079
02bb8761fcce Initial load
duke
parents:
diff changeset
  1080
    public void end_value() {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1081
        throw wrapper.giopVersionError();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1082
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1083
}