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

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--org.omg.CORBA.portable.InputStream
              |
              +--org.omg.CORBA_2_3.portable.InputStream
                    |
                    +--org.objectweb.david.apis.presentation.DavidInputStream
                          |
                          +--org.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)
           
 Context getContext()
          Returns a Context associated with this unmarshaller.
 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.
 Object read_abstract_interface()
           
 Object read_abstract_interface(Class clz)
           
 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()
           
 Object read_Object()
           
 Object read_Object(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()
           
 String read_string()
           
 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()
           
 Serializable read_value()
           
 Serializable read_value(BoxedValueHelper factory)
           
 Serializable read_value(Class clz)
           
 Serializable read_value(Serializable value)
           
 Serializable read_value(String rep_id)
           
 void read_wchar_array(char[] array, int off, int len)
           
 char read_wchar()
           
 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.
 Object readReference()
          Method used by stubs when they need to send interfaces references.
 short readShort()
          Reads a short.
 String readString16()
          Reads a string composed of 16 bits chars.
 String readString8()
          Reads a string composed of 8 bits chars.
 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
Overrides:
close in class DavidInputStream

setSize

public void setSize(int size)
             throws 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
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Parameters:
size - the expected number of readable bytes.
Throws:
JonathanException - if something goes wrong.

readByte

public byte readByte()
              throws JonathanException
Reads a byte from a message.
Specified by:
readByte in interface UnMarshaller
Returns:
a byte.
Throws:
JonathanException - if an IO exception occurs.

readBoolean

public boolean readBoolean()
                    throws JonathanException
Reads a boolean from a message.
Specified by:
readBoolean in interface UnMarshaller
Returns:
a boolean.
Throws:
JonathanException - if an IO exception occurs.

readChar8

public char readChar8()
               throws JonathanException
Reads a char from a message.
Specified by:
readChar8 in interface UnMarshaller
Returns:
a char.
Throws:
JonathanException - if an IO exception occurs.

readChar16

public char readChar16()
                throws JonathanException
Description copied from interface: UnMarshaller
Reads a 16 bits char.
Specified by:
readChar16 in interface UnMarshaller
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Returns:
a char.
Throws:
JonathanException - if the format of the data is incompatible with the request.

readShort

public short readShort()
                throws JonathanException
Description copied from interface: UnMarshaller
Reads a short.
Specified by:
readShort in interface UnMarshaller
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Returns:
a short.
Throws:
JonathanException - if the format of the data is incompatible with the request.

readInt

public int readInt()
            throws JonathanException
Description copied from interface: UnMarshaller
Reads an int.
Specified by:
readInt in interface UnMarshaller
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Returns:
an int.
Throws:
JonathanException - if the format of the data is incompatible with the request.

readLong

public long readLong()
              throws JonathanException
Description copied from interface: UnMarshaller
Reads a long.
Specified by:
readLong in interface UnMarshaller
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Returns:
a long.
Throws:
JonathanException - if the format of the data is incompatible with the request.

readFloat

public float readFloat()
                throws JonathanException
Description copied from interface: UnMarshaller
Reads a float.
Specified by:
readFloat in interface UnMarshaller
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Returns:
a float.
Throws:
JonathanException - if the format of the data is incompatible with the request.

readDouble

public double readDouble()
                  throws JonathanException
Description copied from interface: UnMarshaller
Reads a double.
Specified by:
readDouble in interface UnMarshaller
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Returns:
a double.
Throws:
JonathanException - if the format of the data is incompatible with the request.

readString8

public String readString8()
                   throws JonathanException
Description copied from interface: UnMarshaller
Reads a string composed of 8 bits chars.
Specified by:
readString8 in interface UnMarshaller
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Returns:
a string.
Throws:
JonathanException - if the format of the data is incompatible with the request.

readString16

public String readString16()
                    throws JonathanException
Description copied from interface: UnMarshaller
Reads a string composed of 16 bits chars.
Specified by:
readString16 in interface UnMarshaller
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Returns:
a string.
Throws:
JonathanException - if the format of the data is incompatible with the request.

readReference

public final Object readReference()
Method used by stubs when they need to send interfaces references.
Specified by:
readReference in interface UnMarshaller
Parameters:
exp - the surrogate that must be sent;

readValue

public final Object readValue()
Description copied from interface: UnMarshaller
Reads a value
Specified by:
readValue in interface UnMarshaller
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Returns:
an object representing the read value
Throws:
JonathanException - if the format of the data is incompatible with the request.

readByteArray

public void readByteArray(byte[] array,
                          int off,
                          int len)
                   throws JonathanException
Description copied from interface: UnMarshaller
Reads an array of bytes.
Specified by:
readByteArray in interface UnMarshaller
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Parameters:
array - a byte array (of size >= offset + len)
offset - the position (in array) of the first byte to write
len - the total number of bytes to read;
Throws:
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
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Parameters:
little_endian - the new byte order.

inputStream

public 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
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Returns:
an input stream to read from the unmarshaller.

read_boolean

public boolean read_boolean()
Overrides:
read_boolean in class InputStream

read_char

public char read_char()
Overrides:
read_char in class InputStream

read_wchar

public char read_wchar()
Overrides:
read_wchar in class InputStream

read_octet

public byte read_octet()
Overrides:
read_octet in class InputStream

read_short

public short read_short()
Overrides:
read_short in class InputStream

read_ushort

public short read_ushort()
Overrides:
read_ushort in class InputStream

read_long

public int read_long()
Overrides:
read_long in class InputStream

read_ulong

public int read_ulong()
Overrides:
read_ulong in class InputStream

read_longlong

public long read_longlong()
Overrides:
read_longlong in class InputStream

read_ulonglong

public long read_ulonglong()
Overrides:
read_ulonglong in class InputStream

read_float

public float read_float()
Overrides:
read_float in class InputStream

read_double

public double read_double()
Overrides:
read_double in class InputStream

read_string

public String read_string()
Overrides:
read_string in class InputStream

read_wstring

public String read_wstring()
Overrides:
read_wstring in class InputStream

read_boolean_array

public void read_boolean_array(boolean[] array,
                               int off,
                               int len)
Overrides:
read_boolean_array in class InputStream

read_char_array

public void read_char_array(char[] array,
                            int off,
                            int len)
Overrides:
read_char_array in class InputStream

read_wchar_array

public void read_wchar_array(char[] array,
                             int off,
                             int len)
Overrides:
read_wchar_array in class InputStream

read_octet_array

public void read_octet_array(byte[] array,
                             int off,
                             int len)
Overrides:
read_octet_array in class InputStream

read_short_array

public void read_short_array(short[] array,
                             int off,
                             int len)
Overrides:
read_short_array in class InputStream

read_ushort_array

public void read_ushort_array(short[] array,
                              int off,
                              int len)
Overrides:
read_ushort_array in class InputStream

read_long_array

public void read_long_array(int[] array,
                            int off,
                            int len)
Overrides:
read_long_array in class InputStream

read_ulong_array

public void read_ulong_array(int[] array,
                             int off,
                             int len)
Overrides:
read_ulong_array in class InputStream

read_longlong_array

public void read_longlong_array(long[] array,
                                int off,
                                int len)
Overrides:
read_longlong_array in class InputStream

read_ulonglong_array

public void read_ulonglong_array(long[] array,
                                 int off,
                                 int len)
Overrides:
read_ulonglong_array in class InputStream

read_float_array

public void read_float_array(float[] array,
                             int off,
                             int len)
Overrides:
read_float_array in class InputStream

read_double_array

public void read_double_array(double[] array,
                              int off,
                              int len)
Overrides:
read_double_array in class InputStream

read_Object

public Object read_Object()
Overrides:
read_Object in class InputStream

read_Object

public Object read_Object(Class classe)
Overrides:
read_Object in class InputStream

read_any

public Any read_any()
Overrides:
read_any in class InputStream

read_TypeCode

public TypeCode read_TypeCode()
Overrides:
read_TypeCode in class InputStream

read_value

public Serializable read_value()
Overrides:
read_value in class InputStream

read_value

public Serializable read_value(String rep_id)
Overrides:
read_value in class InputStream

read_value

public Serializable read_value(Class clz)
Overrides:
read_value in class InputStream

read_value

public Serializable read_value(BoxedValueHelper factory)
Overrides:
read_value in class InputStream

read_value

public Serializable read_value(Serializable value)
Overrides:
read_value in class InputStream

read_abstract_interface

public Object read_abstract_interface()
Overrides:
read_abstract_interface in class InputStream

read_abstract_interface

public Object read_abstract_interface(Class clz)
Overrides:
read_abstract_interface in class InputStream

read

public int read()
         throws 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.
Overrides:
read in class InputStream
Returns:
the byte read.
Throws:
IOException - if an error occurs.
See Also:
readByte()

read

public int read(byte[] array,
                int off,
                int length)
         throws IOException
Reads data from the message into an array of bytes. The default implementation uses the readByteArray() method.
Overrides:
read in class InputStream
Parameters:
array - the buffer into which the data is read.
the - start offset of the data.
the - maximum number of bytes read.
Returns:
the actual number of bytes read.
Throws:
IOException - if an error occurs.

skip

public long skip(long n)
          throws 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.

Overrides:
skip in class InputStream
Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
IOException - if an I/O error occurs.

available

public int available()
              throws IOException
Returns the number of bytes that can be read without blocking.
Overrides:
available in class InputStream
Returns:
the number of bytes that can be read without blocking;
Throws:
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
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Returns:
the number of bytes read since the beginning.

skipPadding

protected void skipPadding(int constraint)
                    throws JonathanException

startEncapsulation

public int startEncapsulation()
                       throws JonathanException
Overrides:
startEncapsulation in class DavidInputStream

endEncapsulation

public void endEncapsulation(int encapsulation_spec)
Overrides:
endEncapsulation in class DavidInputStream

getContext

public final Context getContext()
Description copied from interface: UnMarshaller
Returns a Context associated with this unmarshaller.
Specified by:
getContext in interface UnMarshaller
Following copied from interface: org.objectweb.jonathan.apis.presentation.UnMarshaller
Returns:
a Context associated with this unmarshaller.

prepare

protected void prepare()
                throws JonathanException
When nothing can be read from the current chunk, this method tries to get a new chunk to read data from.
Throws:
JonathanException - if something goes wrong.