org.jacorb.orb
Class CDRInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.omg.CORBA.portable.InputStream
          extended by org.omg.CORBA_2_3.portable.InputStream
              extended by org.jacorb.orb.CDRInputStream
All Implemented Interfaces:
java.io.Closeable
Direct Known Subclasses:
MessageInputStream

public class CDRInputStream
extends InputStream

Read CDR encoded data

Author:
Gerald Brose, FU Berlin $Id: CDRInputStream.java,v 1.115 2007/04/27 19:14:06 francisco Exp $

Field Summary
protected  byte[] buffer
          indices into the actual buffer
protected  int giop_minor
           
protected  int index
           
 boolean littleEndian
           
protected  int pos
           
 
Constructor Summary
CDRInputStream(byte[] buffer, boolean littleEndian)
           
CDRInputStream(ORB orb, byte[] buf)
           
CDRInputStream(ORB orb, byte[] buf, boolean littleEndian)
           
 
Method Summary
 int available()
           
 void close()
           
 void closeEncapsulation()
          close a CDR encapsulation and restore index and byte order information
 int get_pos()
           
 byte[] getBufferCopy()
           
 int getGIOPMinor()
           
 void mark(int readLimit)
           
 boolean markSupported()
           
 void openEncapsulatedArray()
           
 int openEncapsulation()
          open a CDR encapsulation and restore index and byte order information
 ORB orb()
           
 java.lang.Object read_abstract_interface()
          Reads an abstract interface from this stream.
 java.lang.Object read_abstract_interface(java.lang.Class clazz)
          Reads an abstract interface from this stream.
 Any read_any()
           
 void read_boolean_array(boolean[] value, int offset, int length)
          arrays
 boolean read_boolean()
           
 void read_char_array(char[] value, int offset, int length)
          read_char_array reads an character array from the stream.
 char read_char()
          read_char reads a character from the stream.
 void read_double_array(double[] value, int offset, int length)
           
 double read_double()
           
 java.math.BigDecimal read_fixed()
           
 java.math.BigDecimal read_fixed(short digits, short scale)
           
 void read_float_array(float[] value, int offset, int length)
           
 float read_float()
           
 void read_long_array(int[] value, int offset, int length)
           
 int read_long()
           
 void read_longlong_array(long[] value, int offset, int length)
           
 long read_longlong()
           
 Object read_Object()
           
 Object read_Object(java.lang.Class clazz)
           
 void read_octet_array(byte[] value, int offset, int length)
           
 byte read_octet()
           
 Principal read_Principal()
           
 void read_short_array(short[] value, int offset, int length)
           
 short read_short()
          Read methods for big-endian as well as little endian data input contributed by Mark Allerton
 java.lang.String read_string()
          read_string reads a string from the buffer.
 TypeCode read_TypeCode()
           
 void read_ulong_array(int[] value, int offset, int length)
           
 int read_ulong()
           
 void read_ulonglong_array(long[] value, int offset, int length)
           
 long read_ulonglong()
           
 void read_ushort_array(short[] value, int offset, int length)
           
 short read_ushort()
           
 java.io.Serializable read_value()
           
 java.io.Serializable read_value(BoxedValueHelper factory)
          Overrides read_value(factory) in org.omg.CORBA_2_3.portable.InputStream
 java.io.Serializable read_value(java.lang.Class clz)
          Overrides read_value(clz) in org.omg.CORBA_2_3.portable.InputStream
 java.io.Serializable read_value(java.io.Serializable value)
          Unmarshals a valuetype instance from this stream.
 java.io.Serializable read_value(java.lang.String rep_id)
          Overrides read_value(java.io.Serializable value) in org.omg.CORBA_2_3.portable.InputStream
 void read_wchar_array(char[] value, int offset, int length)
           
 char read_wchar()
           
 java.lang.String read_wstring()
           
 int read()
          Reads the next byte of data from the input stream.
 int read(byte[] b)
          Has the effect of read(b, 0, b.length);
 int read(byte[] b, int off, int len)
          Performs as described by java.io.InputStream.read(byte[], int, int), but never blocks.
 void register_value(java.io.Serializable value)
          Stores `value' into this stream's valueMap.
 void reset()
           
 void setCodeSet(int codeSet, int codeSetWide)
           
 void setGIOPMinor(int giop_minor)
           
 void setLittleEndian(boolean b)
           
protected  void skip(int distance)
           
 void updateMutatorConnection(GIOPConnection connection)
          updateMutatorConnection is an accessor that updates the ior mutator.
 
Methods inherited from class org.omg.CORBA.portable.InputStream
read_Context
 
Methods inherited from class java.io.InputStream
skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

giop_minor

protected int giop_minor

littleEndian

public boolean littleEndian

buffer

protected byte[] buffer
indices into the actual buffer


pos

protected int pos

index

protected int index
Constructor Detail

CDRInputStream

public CDRInputStream(ORB orb,
                      byte[] buf)

CDRInputStream

public CDRInputStream(ORB orb,
                      byte[] buf,
                      boolean littleEndian)

CDRInputStream

public CDRInputStream(byte[] buffer,
                      boolean littleEndian)
Method Detail

setGIOPMinor

public void setGIOPMinor(int giop_minor)

getGIOPMinor

public int getGIOPMinor()

close

public void close()
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream

orb

public ORB orb()
Overrides:
orb in class InputStream

setCodeSet

public void setCodeSet(int codeSet,
                       int codeSetWide)

skip

protected final void skip(int distance)

closeEncapsulation

public final void closeEncapsulation()
close a CDR encapsulation and restore index and byte order information


openEncapsulation

public final int openEncapsulation()
open a CDR encapsulation and restore index and byte order information


openEncapsulatedArray

public final void openEncapsulatedArray()

getBufferCopy

public byte[] getBufferCopy()

read

public int read()
         throws java.io.IOException
Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.

Overrides:
read in class InputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
java.io.IOException - if stream is closed.

available

public int available()
Overrides:
available in class java.io.InputStream
Returns:
the number of bytes that can be read (or skipped over) from this input stream. This is not necessarily the number of 'valid' bytes.

read

public int read(byte[] b)
         throws java.io.IOException
Has the effect of read(b, 0, b.length);

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException
See Also:
read(byte[], int, int)

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Performs as described by java.io.InputStream.read(byte[], int, int), but never blocks.

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read_any

public final Any read_any()
Specified by:
read_any in class InputStream

read_boolean

public final boolean read_boolean()
Specified by:
read_boolean in class InputStream

read_boolean_array

public final void read_boolean_array(boolean[] value,
                                     int offset,
                                     int length)
arrays

Specified by:
read_boolean_array in class InputStream

read_char

public final char read_char()
read_char reads a character from the stream.

Specified by:
read_char in class InputStream
Returns:
a char value

read_char_array

public final void read_char_array(char[] value,
                                  int offset,
                                  int length)
read_char_array reads an character array from the stream.

Specified by:
read_char_array in class InputStream
Parameters:
value - a char[], the result array.
offset - an int, an offset into value
length - an int, the length of the array to read

read_double

public final double read_double()
Specified by:
read_double in class InputStream

read_double_array

public final void read_double_array(double[] value,
                                    int offset,
                                    int length)
Specified by:
read_double_array in class InputStream

read_fixed

public final java.math.BigDecimal read_fixed()
Overrides:
read_fixed in class InputStream

read_fixed

public final java.math.BigDecimal read_fixed(short digits,
                                             short scale)
Overrides:
read_fixed in class InputStream

read_float

public final float read_float()
Specified by:
read_float in class InputStream

read_float_array

public final void read_float_array(float[] value,
                                   int offset,
                                   int length)
Specified by:
read_float_array in class InputStream

read_long

public final int read_long()
Specified by:
read_long in class InputStream

read_long_array

public final void read_long_array(int[] value,
                                  int offset,
                                  int length)
Specified by:
read_long_array in class InputStream

read_longlong

public final long read_longlong()
Specified by:
read_longlong in class InputStream

read_longlong_array

public final void read_longlong_array(long[] value,
                                      int offset,
                                      int length)
Specified by:
read_longlong_array in class InputStream

read_Object

public final Object read_Object()
Specified by:
read_Object in class InputStream

read_Object

public Object read_Object(java.lang.Class clazz)
Overrides:
read_Object in class InputStream

read_octet

public final byte read_octet()
Specified by:
read_octet in class InputStream

read_octet_array

public final void read_octet_array(byte[] value,
                                   int offset,
                                   int length)
Specified by:
read_octet_array in class InputStream

read_Principal

public final Principal read_Principal()
Overrides:
read_Principal in class InputStream

read_short

public final short read_short()
Read methods for big-endian as well as little endian data input contributed by Mark Allerton

Specified by:
read_short in class InputStream

read_short_array

public final void read_short_array(short[] value,
                                   int offset,
                                   int length)
Specified by:
read_short_array in class InputStream

read_string

public final java.lang.String read_string()
read_string reads a string from the buffer. It is optimized for whether it is reading a blank string, and whether codeset translation is active.

Specified by:
read_string in class InputStream
Returns:
a String value, possibly blank, never null.

read_TypeCode

public final TypeCode read_TypeCode()
Specified by:
read_TypeCode in class InputStream

read_ulong

public final int read_ulong()
Specified by:
read_ulong in class InputStream

read_ulong_array

public final void read_ulong_array(int[] value,
                                   int offset,
                                   int length)
Specified by:
read_ulong_array in class InputStream

read_ulonglong

public final long read_ulonglong()
Specified by:
read_ulonglong in class InputStream

read_ulonglong_array

public final void read_ulonglong_array(long[] value,
                                       int offset,
                                       int length)
Specified by:
read_ulonglong_array in class InputStream

read_ushort

public final short read_ushort()
Specified by:
read_ushort in class InputStream

read_ushort_array

public final void read_ushort_array(short[] value,
                                    int offset,
                                    int length)
Specified by:
read_ushort_array in class InputStream

read_wchar

public final char read_wchar()
Specified by:
read_wchar in class InputStream

read_wchar_array

public final void read_wchar_array(char[] value,
                                   int offset,
                                   int length)
Specified by:
read_wchar_array in class InputStream

read_wstring

public final java.lang.String read_wstring()
Specified by:
read_wstring in class InputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.InputStream

mark

public void mark(int readLimit)
Overrides:
mark in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

setLittleEndian

public final void setLittleEndian(boolean b)

read_value

public java.io.Serializable read_value()
Overrides:
read_value in class InputStream

read_value

public java.io.Serializable read_value(java.lang.String rep_id)
Overrides read_value(java.io.Serializable value) in org.omg.CORBA_2_3.portable.InputStream

Overrides:
read_value in class InputStream

read_value

public java.io.Serializable read_value(java.io.Serializable value)
Unmarshals a valuetype instance from this stream. The value returned is the same value passed in, with all the data unmarshaled (IDL-to-Java Mapping 1.2, August 2002, 1.13.1, p. 1-39). The specified value is an uninitialized value that is added to the ORB's indirection table before unmarshaling (1.21.4.1, p. 1-117). This method is intended to be called from custom valuetype factories. Unlike the other read_value() methods in this class, this method does not expect a GIOP value tag nor a repository id in the stream. Overrides read_value(value) in org.omg.CORBA_2_3.portable.InputStream

Overrides:
read_value in class InputStream

read_value

public java.io.Serializable read_value(java.lang.Class clz)
Overrides read_value(clz) in org.omg.CORBA_2_3.portable.InputStream

Overrides:
read_value in class InputStream

read_value

public java.io.Serializable read_value(BoxedValueHelper factory)
Overrides read_value(factory) in org.omg.CORBA_2_3.portable.InputStream

Overrides:
read_value in class InputStream

read_abstract_interface

public java.lang.Object read_abstract_interface()
Reads an abstract interface from this stream. The abstract interface Reads an abstract interface from this stream. The abstract interface appears as a union with a boolean discriminator, which is true if the union contains a CORBA object reference, or false if the union contains a value.

Overrides:
read_abstract_interface in class InputStream

read_abstract_interface

public java.lang.Object read_abstract_interface(java.lang.Class clazz)
Reads an abstract interface from this stream. The abstract interface appears as a union with a boolean discriminator, which is true if the union contains a CORBA object reference, or false if the union contains a value.

Overrides:
read_abstract_interface in class InputStream

get_pos

public int get_pos()

register_value

public void register_value(java.io.Serializable value)
Stores `value' into this stream's valueMap. This is provided as a callback for value factories, so that a value factory can store an object into the map before actually reading its state. This is essential for unmarshalling recursive values.


updateMutatorConnection

public void updateMutatorConnection(GIOPConnection connection)
updateMutatorConnection is an accessor that updates the ior mutator. By making callers pass in a GIOPConnection not a transport this allows callers to not have to call getTransport which would require a synchronized lock. Therefore if the mutator has not been enabled this is effectively a NOP.

Parameters:
connection - an org.omg.ETF.Connection value