org.openorb.orb.iiop
Class CDRInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byorg.omg.CORBA.portable.InputStream
          extended byorg.omg.CORBA_2_3.portable.InputStream
              extended byorg.openorb.orb.io.AbstractInputStream
                  extended byorg.openorb.orb.iiop.CDRInputStream
All Implemented Interfaces:
ExtendedInputStream

public class CDRInputStream
extends AbstractInputStream

This class implements CDR for IIOP

Version:
$Revision: 1.22 $ $Date: 2004/08/20 10:08:12 $
Author:
Chris Wood

Constructor Summary
CDRInputStream(org.omg.CORBA.ORB orb, boolean bigEndian, org.omg.GIOP.Version version, BufferSource source)
          Constructor used by lower layer.
CDRInputStream(org.omg.CORBA.ORB orb, boolean bigEndian, org.omg.GIOP.Version version, StorageBuffer buf)
          Constructor used by codec.
 
Method Summary
 void addIndirect(int offset, java.lang.Object value)
          This operation is used to add an indirection for an unmarshaled value type.
 void alignment(int size)
          Adjust alignment.
 void begin_encapsulation()
          Encapsulation begin.
 boolean bigEndian()
          Get the endian mode
 void bigEndian(boolean bigEndian)
          Set the endian mode
 void enableLogging(Logger logger)
           
 void end_encapsulation()
          skip to end of current encapsulation
protected  Logger getLogger()
           
protected  java.util.Map getValueCache()
          Provides access to the value cache for subclasses (e.g.
 java.lang.String getValueCodebase()
          Return the codebase for the value.
 int index()
          Get the current index in the buffer.
protected  org.omg.CORBA.portable.ValueFactory loadFactoryWithID(java.lang.String id, java.lang.String url)
          Load a OBV factory from its ID.
 void mark(int readlimit)
          Set a mark at the current buffer position.
 org.omg.CORBA.ORB orb()
          Get the orb associated with the stream.
 java.lang.Object read_abstract_interface()
          Read an abstract interface
 java.lang.Object read_abstract_interface(java.lang.Class clz)
          Read an abstract interface
 org.omg.CORBA.Any read_any()
          Read an any
 void read_boolean_array(boolean[] val, int off, int len)
          Read an IDL boolean array
 boolean read_boolean()
          Return an IDL boolean
 void read_char_array(char[] val, int voff, int len)
          Read an IDL char array from the stream
 char read_char()
          Return an IDL char
 org.omg.CORBA.Context read_Context()
          Read a context
 void read_double_array(double[] val, int off, int len)
          Read a double array
 double read_double()
          Return an IDL double
 java.math.BigDecimal read_fixed()
          Deprecated. Loses scale and precision, see http://www.omg.org/issues/issue3431.txt
 java.math.BigDecimal read_fixed(short digits, short scale)
          read a fixed.
 java.math.BigDecimal read_fixed(org.omg.CORBA.TypeCode type)
          read a fixed.
 void read_float_array(float[] val, int off, int len)
          Read a float array
 float read_float()
          Return an IDL float
 void read_long_array(int[] val, int off, int len)
          Read a long array
 int read_long()
          Return an IDL long
 void read_longlong_array(long[] val, int off, int len)
          Read a long long array
 long read_longlong()
          Return an IDL long long
 org.omg.CORBA.Object read_Object()
          Read an object
 org.omg.CORBA.Object read_Object(java.lang.Class clz)
          Read an Object
 void read_octet_array(byte[] val, int off, int len)
          Read an octet array
 byte read_octet()
          Return an IDL octet
 org.omg.CORBA.Principal read_Principal()
          Read a principal
 void read_short_array(short[] val, int off, int len)
          Read a short array
 short read_short()
          Return an IDL short
 java.lang.String read_string()
          Return an IDL string
 org.omg.CORBA.TypeCode read_TypeCode()
          Read a typecode
 java.lang.String[] read_typeids(int tag)
           
 void read_ulong_array(int[] val, int off, int len)
          Read an unsigned long array
 int read_ulong()
          Return an IDL unsigned long
 void read_ulonglong_array(long[] val, int off, int len)
          Read an unsigned long long array
 long read_ulonglong()
          Return an IDL unsigned long long
 void read_ushort_array(short[] val, int off, int len)
          Read an unsigned short array
 short read_ushort()
          Return an IDL unsigned short
 java.io.Serializable read_value()
          Read a value from a CDR stream
 java.io.Serializable read_value(org.omg.CORBA.portable.BoxedValueHelper boxhelp)
          Read a value from a CDR stream
 java.io.Serializable read_value(java.lang.Class clz)
          Read a value from a CDR stream
 java.io.Serializable read_value(java.io.Serializable value)
          Read value state from the stream.
 java.io.Serializable read_value(java.lang.String rep_id)
          Read a value from a CDR stream
 void read_wchar_array(char[] val, int voff, int vlen)
          Read a wchar array
 char read_wchar()
          Read a wchar from the input stream.
 java.lang.String read_wstring()
          Return an IDL wstring
 void reset_index()
          Reset the index to 0.
 void reset()
          Reset the current position to the latest mark.
 void setCodesets(int tcsc, int tcsw)
          Set the translation codesets.
 long skip(long count)
          Skip over bytes.
protected  java.io.Serializable value_extended_unmarshal(int offset, java.lang.Class clz, java.lang.String repo_id, java.lang.String codeBase, org.omg.SendingContext.RunTime sendingCtxt)
          This function should be overloaded by base types to allow marshaling of extended value types, RMI over IIOP for example.
 org.omg.GIOP.Version version()
          Get the CDR protocol version
 
Methods inherited from class org.openorb.orb.io.AbstractInputStream
available, cancel, force_skip, get_codebase, markSupported, next, read, read, read
 
Methods inherited from class java.io.InputStream
close
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CDRInputStream

public CDRInputStream(org.omg.CORBA.ORB orb,
                      boolean bigEndian,
                      org.omg.GIOP.Version version,
                      StorageBuffer buf)
Constructor used by codec. Extending classes must implement a constructor with this exact signature.


CDRInputStream

public CDRInputStream(org.omg.CORBA.ORB orb,
                      boolean bigEndian,
                      org.omg.GIOP.Version version,
                      BufferSource source)
Constructor used by lower layer. Extending classes must implement a constructor with this exact signature.

Method Detail

enableLogging

public void enableLogging(Logger logger)

getLogger

protected Logger getLogger()

orb

public org.omg.CORBA.ORB orb()
Get the orb associated with the stream.


setCodesets

public void setCodesets(int tcsc,
                        int tcsw)
Set the translation codesets.


index

public int index()
Get the current index in the buffer.


reset_index

public void reset_index()
Reset the index to 0. This affects the alignment. Using this inside an encapsulation may cause unexpected behaviour.


version

public org.omg.GIOP.Version version()
Get the CDR protocol version


bigEndian

public boolean bigEndian()
Get the endian mode


bigEndian

public void bigEndian(boolean bigEndian)
Set the endian mode


alignment

public void alignment(int size)
Adjust alignment.


begin_encapsulation

public void begin_encapsulation()
Encapsulation begin.


end_encapsulation

public void end_encapsulation()
skip to end of current encapsulation


skip

public long skip(long count)
Skip over bytes.

Overrides:
skip in class AbstractInputStream
Parameters:
count - The number of bytes to skip.

mark

public void mark(int readlimit)
Description copied from class: AbstractInputStream
Set a mark at the current buffer position.

Overrides:
mark in class AbstractInputStream
Parameters:
readlimit - NOT USED

reset

public void reset()
           throws java.io.IOException
Description copied from class: AbstractInputStream
Reset the current position to the latest mark.

Overrides:
reset in class AbstractInputStream
Throws:
java.io.IOException - An IOException is thrown when there is no mark where the buffer can be reset to.

read_boolean

public boolean read_boolean()
Return an IDL boolean


read_char

public char read_char()
Return an IDL char


read_wchar

public char read_wchar()
Read a wchar from the input stream.

Returns:
'\0' When no wchar encoder is set or the letter represented by the bytes is longer than 1.

read_octet

public byte read_octet()
Return an IDL octet


read_short

public short read_short()
Return an IDL short


read_ushort

public short read_ushort()
Return an IDL unsigned short


read_long

public int read_long()
Return an IDL long


read_ulong

public int read_ulong()
Return an IDL unsigned long


read_longlong

public long read_longlong()
Return an IDL long long


read_ulonglong

public long read_ulonglong()
Return an IDL unsigned long long


read_float

public float read_float()
Return an IDL float


read_double

public double read_double()
Return an IDL double


read_string

public java.lang.String read_string()
Return an IDL string


read_wstring

public java.lang.String read_wstring()
Return an IDL wstring


read_boolean_array

public void read_boolean_array(boolean[] val,
                               int off,
                               int len)
Read an IDL boolean array


read_char_array

public void read_char_array(char[] val,
                            int voff,
                            int len)
Read an IDL char array from the stream


read_wchar_array

public void read_wchar_array(char[] val,
                             int voff,
                             int vlen)
Read a wchar array


read_octet_array

public void read_octet_array(byte[] val,
                             int off,
                             int len)
Read an octet array


read_short_array

public void read_short_array(short[] val,
                             int off,
                             int len)
Read a short array


read_ushort_array

public void read_ushort_array(short[] val,
                              int off,
                              int len)
Read an unsigned short array


read_long_array

public void read_long_array(int[] val,
                            int off,
                            int len)
Read a long array


read_ulong_array

public void read_ulong_array(int[] val,
                             int off,
                             int len)
Read an unsigned long array


read_longlong_array

public void read_longlong_array(long[] val,
                                int off,
                                int len)
Read a long long array


read_ulonglong_array

public void read_ulonglong_array(long[] val,
                                 int off,
                                 int len)
Read an unsigned long long array


read_float_array

public void read_float_array(float[] val,
                             int off,
                             int len)
Read a float array


read_double_array

public void read_double_array(double[] val,
                              int off,
                              int len)
Read a double array


read_TypeCode

public org.omg.CORBA.TypeCode read_TypeCode()
Read a typecode


read_any

public org.omg.CORBA.Any read_any()
Read an any


read_Principal

public org.omg.CORBA.Principal read_Principal()
Read a principal


read_Object

public org.omg.CORBA.Object read_Object()
Read an object


read_Object

public org.omg.CORBA.Object read_Object(java.lang.Class clz)
Read an Object


read_Context

public org.omg.CORBA.Context read_Context()
Read a context


read_fixed

public java.math.BigDecimal read_fixed()
Deprecated. Loses scale and precision, see http://www.omg.org/issues/issue3431.txt

Read a fixed


read_fixed

public java.math.BigDecimal read_fixed(org.omg.CORBA.TypeCode type)
read a fixed.


read_fixed

public java.math.BigDecimal read_fixed(short digits,
                                       short scale)
read a fixed.


read_value

public java.io.Serializable read_value()
Read a value from a CDR stream


read_value

public java.io.Serializable read_value(java.lang.String rep_id)
Read a value from a CDR stream


read_value

public java.io.Serializable read_value(java.lang.Class clz)
Read a value from a CDR stream


read_value

public java.io.Serializable read_value(org.omg.CORBA.portable.BoxedValueHelper boxhelp)
Read a value from a CDR stream


read_typeids

public java.lang.String[] read_typeids(int tag)

read_value

public java.io.Serializable read_value(java.io.Serializable value)
Read value state from the stream. Called externally by factories with uninitialized value. One of the other read_value functions always appears above it in the call stack.


value_extended_unmarshal

protected java.io.Serializable value_extended_unmarshal(int offset,
                                                        java.lang.Class clz,
                                                        java.lang.String repo_id,
                                                        java.lang.String codeBase,
                                                        org.omg.SendingContext.RunTime sendingCtxt)
This function should be overloaded by base types to allow marshaling of extended value types, RMI over IIOP for example. It should return null if the repository ID or class is not unmarshaled by the function. All calls to this function with an offset equal to a previous value must not unmarshal from the stream.


read_abstract_interface

public java.lang.Object read_abstract_interface()
Read an abstract interface

Returns:
the readed object ( An CORBA.Object or a value type )

read_abstract_interface

public java.lang.Object read_abstract_interface(java.lang.Class clz)
Read an abstract interface

Parameters:
clz - the stub class for an object
Returns:
the readed object ( An CORBA.Object or a value type )

addIndirect

public void addIndirect(int offset,
                        java.lang.Object value)
This operation is used to add an indirection for an unmarshaled value type. This method updates the indirection table and puts the offset where the data starts in the IIOP stream to the hash table. Once an indirection is found the data can be accessed by the offset. It is called by the ValueHander as soon as the target object is instantiated.


getValueCodebase

public java.lang.String getValueCodebase()
Return the codebase for the value. This method is called from the value handler.

Returns:
The URL describing the place where to load the class for the value.

loadFactoryWithID

protected org.omg.CORBA.portable.ValueFactory loadFactoryWithID(java.lang.String id,
                                                                java.lang.String url)
Load a OBV factory from its ID.


getValueCache

protected java.util.Map getValueCache()
Provides access to the value cache for subclasses (e.g. RMIInputStream)

Returns:
value cache map