org.objectweb.david.libs.presentation.portable
Class PortableMarshallerFactory.PortableUnMarshaller

java.lang.Object
  extended byjava.io.InputStream
      extended byorg.omg.CORBA.portable.InputStream
          extended byorg.omg.CORBA_2_3.portable.InputStream
              extended byorg.objectweb.david.apis.presentation.DavidInputStream
                  extended byorg.objectweb.david.libs.presentation.portable.PortableMarshallerFactory.PortableUnMarshaller
All Implemented Interfaces:
UnMarshaller
Direct Known Subclasses:
PortableMarshallerFactory.PortableUnMarshallerD
Enclosing class:
PortableMarshallerFactory

public class PortableMarshallerFactory.PortableUnMarshaller
extends DavidInputStream
implements UnMarshaller

PortableUnMarshaller is an implementation of UnMarshaller.


Field Summary
protected  Chunk first
          The first chunk in the message, i.e., the one data are read from.
protected  int last_offset
          last_offset is such that last_offset + offset is equal to the number of bytes read since the beginning of the reading process.
protected  boolean little_endian
          If true, the target unmarshaller expects a little endian encoding of data.
protected  int offset
          offset of the next byte to read in first
 
Constructor Summary
protected PortableMarshallerFactory.PortableUnMarshaller(Chunk first, int read)
          Creates a new unmarshaller.
 
Method Summary
 int available()
          Returns the number of bytes that can be read without blocking.
 int bytesRead()
          Returns the number of bytes read since the beginning.
 void close()
          Closes the target unmarshaller, releasing all underlying resources (including a possible chunk provider).
 void endEncapsulation(int encapsulation_spec)
           
 org.objectweb.jonathan.apis.kernel.Context getContext()
          Returns a Context associated with this unmarshaller.
 java.io.InputStream inputStream()
          Returns an input stream to read data from the unmarshaller.
 boolean isLittleEndian()
          Returns true if this unmarshaller is little-endian, false otherwise.
protected  void prepare()
          When nothing can be read from the current chunk, this method tries to get a new chunk to read data from.
 java.lang.Object read_abstract_interface()
           
 java.lang.Object read_abstract_interface(java.lang.Class clz)
           
 org.omg.CORBA.Any read_any()
           
 void read_boolean_array(boolean[] array, int off, int len)
           
 boolean read_boolean()
           
 void read_char_array(char[] array, int off, int len)
           
 char read_char()
           
 void read_double_array(double[] array, int off, int len)
           
 double read_double()
           
 void read_float_array(float[] array, int off, int len)
           
 float read_float()
           
 void read_long_array(int[] array, int off, int len)
           
 int read_long()
           
 void read_longlong_array(long[] array, int off, int len)
           
 long read_longlong()
           
 org.omg.CORBA.Object read_Object()
           
 org.omg.CORBA.Object read_Object(java.lang.Class classe)
           
 void read_octet_array(byte[] array, int off, int len)
           
 byte read_octet()
           
 void read_short_array(short[] array, int off, int len)
           
 short read_short()
           
 java.lang.String read_string()
           
 org.omg.CORBA.TypeCode read_TypeCode()
           
 void read_ulong_array(int[] array, int off, int len)
           
 int read_ulong()
           
 void read_ulonglong_array(long[] array, int off, int len)
           
 long read_ulonglong()
           
 void read_ushort_array(short[] array, int off, int len)
           
 short read_ushort()
           
 java.io.Serializable read_value()
           
 java.io.Serializable read_value(org.omg.CORBA.portable.BoxedValueHelper factory)
           
 java.io.Serializable read_value(java.lang.Class clz)
           
 java.io.Serializable read_value(java.io.Serializable value)
           
 java.io.Serializable read_value(java.lang.String rep_id)
           
 void read_wchar_array(char[] array, int off, int len)
           
 char read_wchar()
           
 java.lang.String read_wstring()
           
 int read()
          Reads one byte from the message.
 int read(byte[] array, int off, int length)
          Reads data from the message into an array of bytes.
 boolean readBoolean()
          Reads a boolean from a message.
 byte readByte()
          Reads a byte from a message.
 void readByteArray(byte[] array, int off, int len)
          Reads an array of bytes.
 char readChar16()
          Reads a 16 bits char.
 char readChar8()
          Reads a char from a message.
 double readDouble()
          Reads a double.
 float readFloat()
          Reads a float.
 int readInt()
          Reads an int.
 long readLong()
          Reads a long.
 java.lang.Object readReference()
          Method used by stubs when they need to send interfaces references.
 short readShort()
          Reads a short.
 java.lang.String readString16()
          Reads a string composed of 16 bits chars.
 java.lang.String readString8()
          Reads a string composed of 8 bits chars.
 java.lang.Object readValue()
          Reads a value
 void setByteOrder(boolean new_little_endian)
          Sets the byte order (returned by isLittleEndian) of the target unmarshaller
 void setSize(int size)
          Sets the number of bytes readable from the unmarshaller.
 long skip(long n)
          Skips over and discards n bytes of data from this input stream.
protected  void skipPadding(int constraint)
           
 int startEncapsulation()
           
 
Methods inherited from class org.objectweb.david.apis.presentation.DavidInputStream
read_Principal
 
Methods inherited from class org.omg.CORBA.portable.InputStream
orb, read_Context, read_fixed
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

first

protected Chunk first
The first chunk in the message, i.e., the one data are read from.


offset

protected int offset
offset of the next byte to read in first


last_offset

protected int last_offset
last_offset is such that last_offset + offset is equal to the number of bytes read since the beginning of the reading process.


little_endian

protected boolean little_endian
If true, the target unmarshaller expects a little endian encoding of data.

Constructor Detail

PortableMarshallerFactory.PortableUnMarshaller

protected PortableMarshallerFactory.PortableUnMarshaller(Chunk first,
                                                         int read)
Creates a new unmarshaller.

Parameters:
first - the (chain of) chunk(s) to read data from;
read - the number of already read bytes (used to initialize last_offset.
Method Detail

close

public void close()
Description copied from interface: UnMarshaller
Closes the target unmarshaller, releasing all underlying resources (including a possible chunk provider).

Specified by:
close in interface UnMarshaller
Specified by:
close in class DavidInputStream

setSize

public void setSize(int size)
             throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from interface: UnMarshaller
Sets the number of bytes readable from the unmarshaller.

Once this method has been called, it won't be possible to read more than the size specified bytes from this unmarshaller. Knowing the exact number of readable bytes lets the unmarshaller free the resources (such as a chunk provider) that won't be used. This method may block until the expected number of bytes is readable.

Specified by:
setSize in interface UnMarshaller
Parameters:
size - the expected number of readable bytes.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if something goes wrong.

readByte

public byte readByte()
              throws org.objectweb.jonathan.apis.kernel.JonathanException
Reads a byte from a message.

Specified by:
readByte in interface UnMarshaller
Returns:
a byte.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if an IO exception occurs.

readBoolean

public boolean readBoolean()
                    throws org.objectweb.jonathan.apis.kernel.JonathanException
Reads a boolean from a message.

Specified by:
readBoolean in interface UnMarshaller
Returns:
a boolean.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if an IO exception occurs.

readChar8

public char readChar8()
               throws org.objectweb.jonathan.apis.kernel.JonathanException
Reads a char from a message.

Specified by:
readChar8 in interface UnMarshaller
Returns:
a char.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if an IO exception occurs.

readChar16

public char readChar16()
                throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from interface: UnMarshaller
Reads a 16 bits char.

Specified by:
readChar16 in interface UnMarshaller
Returns:
a char.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

readShort

public short readShort()
                throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from interface: UnMarshaller
Reads a short.

Specified by:
readShort in interface UnMarshaller
Returns:
a short.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

readInt

public int readInt()
            throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from interface: UnMarshaller
Reads an int.

Specified by:
readInt in interface UnMarshaller
Returns:
an int.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

readLong

public long readLong()
              throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from interface: UnMarshaller
Reads a long.

Specified by:
readLong in interface UnMarshaller
Returns:
a long.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

readFloat

public float readFloat()
                throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from interface: UnMarshaller
Reads a float.

Specified by:
readFloat in interface UnMarshaller
Returns:
a float.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

readDouble

public double readDouble()
                  throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from interface: UnMarshaller
Reads a double.

Specified by:
readDouble in interface UnMarshaller
Returns:
a double.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

readString8

public java.lang.String readString8()
                             throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from interface: UnMarshaller
Reads a string composed of 8 bits chars.

Specified by:
readString8 in interface UnMarshaller
Returns:
a string.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

readString16

public java.lang.String readString16()
                              throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from interface: UnMarshaller
Reads a string composed of 16 bits chars.

Specified by:
readString16 in interface UnMarshaller
Returns:
a string.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

readReference

public final java.lang.Object readReference()
Method used by stubs when they need to send interfaces references.

Specified by:
readReference in interface UnMarshaller
Returns:
a reference to an object.

readValue

public final java.lang.Object readValue()
Description copied from interface: UnMarshaller
Reads a value

Specified by:
readValue in interface UnMarshaller
Returns:
an object representing the read value

readByteArray

public void readByteArray(byte[] array,
                          int off,
                          int len)
                   throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from interface: UnMarshaller
Reads an array of bytes.

Specified by:
readByteArray in interface UnMarshaller
Parameters:
array - a byte array (of size >= offset + len)
off - the position (in array) of the first byte to write
len - the total number of bytes to read;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

isLittleEndian

public final boolean isLittleEndian()
Returns true if this unmarshaller is little-endian, false otherwise.

Specified by:
isLittleEndian in interface UnMarshaller
Returns:
true if this unmarshaller is little-endian, false otherwise.

setByteOrder

public void setByteOrder(boolean new_little_endian)
Description copied from interface: UnMarshaller
Sets the byte order (returned by isLittleEndian) of the target unmarshaller

Specified by:
setByteOrder in interface UnMarshaller
Parameters:
new_little_endian - the new byte order.

inputStream

public java.io.InputStream inputStream()
Description copied from interface: UnMarshaller
Returns an input stream to read data from the unmarshaller. Closing the returned input stream has the same effect as closing the actual unmarshaller.

Specified by:
inputStream in interface UnMarshaller
Returns:
an input stream to read from the unmarshaller.

read_boolean

public boolean read_boolean()

read_char

public char read_char()

read_wchar

public char read_wchar()

read_octet

public byte read_octet()

read_short

public short read_short()

read_ushort

public short read_ushort()

read_long

public int read_long()

read_ulong

public int read_ulong()

read_longlong

public long read_longlong()

read_ulonglong

public long read_ulonglong()

read_float

public float read_float()

read_double

public double read_double()

read_string

public java.lang.String read_string()

read_wstring

public java.lang.String read_wstring()

read_boolean_array

public void read_boolean_array(boolean[] array,
                               int off,
                               int len)

read_char_array

public void read_char_array(char[] array,
                            int off,
                            int len)

read_wchar_array

public void read_wchar_array(char[] array,
                             int off,
                             int len)

read_octet_array

public void read_octet_array(byte[] array,
                             int off,
                             int len)

read_short_array

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

read_ushort_array

public void read_ushort_array(short[] array,
                              int off,
                              int len)

read_long_array

public void read_long_array(int[] array,
                            int off,
                            int len)

read_ulong_array

public void read_ulong_array(int[] array,
                             int off,
                             int len)

read_longlong_array

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

read_ulonglong_array

public void read_ulonglong_array(long[] array,
                                 int off,
                                 int len)

read_float_array

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

read_double_array

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

read_Object

public org.omg.CORBA.Object read_Object()

read_Object

public org.omg.CORBA.Object read_Object(java.lang.Class classe)

read_any

public org.omg.CORBA.Any read_any()

read_TypeCode

public org.omg.CORBA.TypeCode read_TypeCode()

read_value

public java.io.Serializable read_value()

read_value

public java.io.Serializable read_value(java.lang.String rep_id)

read_value

public java.io.Serializable read_value(java.lang.Class clz)

read_value

public java.io.Serializable read_value(org.omg.CORBA.portable.BoxedValueHelper factory)

read_value

public java.io.Serializable read_value(java.io.Serializable value)

read_abstract_interface

public java.lang.Object read_abstract_interface()

read_abstract_interface

public java.lang.Object read_abstract_interface(java.lang.Class clz)

read

public int read()
         throws java.io.IOException
Reads one byte from the message. If the end of the stream is reached,-1 is returned. The default implementation uses the 'readByte' method.

Returns:
the byte read.
Throws:
java.io.IOException - if an error occurs.
See Also:
readByte()

read

public int read(byte[] array,
                int off,
                int length)
         throws java.io.IOException
Reads data from the message into an array of bytes. The default implementation uses the readByteArray() method.

Parameters:
array - the buffer into which the data is read.
Returns:
the actual number of bytes read.
Throws:
java.io.IOException - if an error occurs.

skip

public long skip(long n)
          throws java.io.IOException
Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.

The default implementation calls the skip(int) method.

Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
java.io.IOException - if an I/O error occurs.

available

public int available()
              throws java.io.IOException
Returns the number of bytes that can be read without blocking.

Returns:
the number of bytes that can be read without blocking;
Throws:
java.io.IOException - if an error occurs.

bytesRead

public int bytesRead()
Description copied from interface: UnMarshaller
Returns the number of bytes read since the beginning.

Specified by:
bytesRead in interface UnMarshaller
Returns:
the number of bytes read since the beginning.

skipPadding

protected void skipPadding(int constraint)
                    throws org.objectweb.jonathan.apis.kernel.JonathanException
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException

startEncapsulation

public int startEncapsulation()
                       throws org.objectweb.jonathan.apis.kernel.JonathanException
Specified by:
startEncapsulation in class DavidInputStream
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException

endEncapsulation

public void endEncapsulation(int encapsulation_spec)
Specified by:
endEncapsulation in class DavidInputStream

getContext

public final org.objectweb.jonathan.apis.kernel.Context getContext()
Description copied from interface: UnMarshaller
Returns a Context associated with this unmarshaller.

Specified by:
getContext in interface UnMarshaller
Returns:
a Context associated with this unmarshaller.

prepare

protected void prepare()
                throws org.objectweb.jonathan.apis.kernel.JonathanException
When nothing can be read from the current chunk, this method tries to get a new chunk to read data from.

Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if something goes wrong.