org.objectweb.jeremie.libs.presentation.std
Class StdMarshallerFactory.StdUnMarshaller

java.lang.Object
  extended byjava.io.InputStream
      extended byorg.objectweb.jeremie.libs.presentation.std.StdMarshallerFactory.StdUnMarshaller
All Implemented Interfaces:
JRMIUnMarshaller, UnMarshaller
Direct Known Subclasses:
StdMarshallerFactory.StdUnMarshallerD
Enclosing class:
StdMarshallerFactory

public class StdMarshallerFactory.StdUnMarshaller
extends java.io.InputStream
implements JRMIUnMarshaller

StdUnMarshaller is an (abstract) implementation of UnMarshaller.


Field Summary
protected  org.objectweb.jonathan.apis.kernel.Context context
           
protected  Chunk first
           
protected  java.io.ObjectInputStream is
           
protected  int last_offset
           
protected  boolean little_endian
           
protected  int offset
           
 
Constructor Summary
protected StdMarshallerFactory.StdUnMarshaller(Chunk first, int read)
           
 
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).
 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()
           
 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.
 java.lang.Exception readException()
          Reads an exception thrown by a remote method invocation from an underlying stream.
 float readFloat()
          Reads a float.
 int readInt()
          Reads an int.
 long readLong()
          Reads a long.
 java.lang.reflect.Method readMethod(java.lang.Class objclass)
          Reads a method from an underlying stream.
 java.lang.Object[] readParameters()
          Reads the arguments in a remote method invocation from an underlying stream.
 java.lang.Object readReference()
          Method used by stubs when they need to send interfaces references.
 java.lang.Object readResult()
          Reads the result of a remote method invocation from an underlying stream.
 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 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.
 
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

offset

protected int offset

last_offset

protected int last_offset

little_endian

protected boolean little_endian

is

protected java.io.ObjectInputStream is

context

protected org.objectweb.jonathan.apis.kernel.Context context
Constructor Detail

StdMarshallerFactory.StdUnMarshaller

protected StdMarshallerFactory.StdUnMarshaller(Chunk first,
                                               int read)
Method Detail

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.

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

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()
                                     throws org.objectweb.jonathan.apis.kernel.JonathanException
Method used by stubs when they need to send interfaces references.

Specified by:
readReference in interface UnMarshaller
Returns:
a reference to an object.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

readValue

public final java.lang.Object readValue()
                                 throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from interface: UnMarshaller
Reads a value

Specified by:
readValue in interface UnMarshaller
Returns:
an object representing the read value
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

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.

readMethod

public java.lang.reflect.Method readMethod(java.lang.Class objclass)
                                    throws java.rmi.UnmarshalException
Description copied from interface: JRMIUnMarshaller
Reads a method from an underlying stream.

Specified by:
readMethod in interface JRMIUnMarshaller
Parameters:
objclass - a class that declares the method.
Returns:
the method read.
Throws:
java.rmi.UnmarshalException - if something goes wrong.

readParameters

public java.lang.Object[] readParameters()
                                  throws java.rmi.UnmarshalException
Description copied from interface: JRMIUnMarshaller
Reads the arguments in a remote method invocation from an underlying stream.

Specified by:
readParameters in interface JRMIUnMarshaller
Returns:
the objects representing the arguments.
Throws:
java.rmi.UnmarshalException - if something goes wrong.

readResult

public java.lang.Object readResult()
                            throws java.rmi.UnmarshalException
Description copied from interface: JRMIUnMarshaller
Reads the result of a remote method invocation from an underlying stream.

Specified by:
readResult in interface JRMIUnMarshaller
Returns:
the object representing the result.
Throws:
java.rmi.UnmarshalException - if something goes wrong.

readException

public java.lang.Exception readException()
                                  throws java.rmi.UnmarshalException
Description copied from interface: JRMIUnMarshaller
Reads an exception thrown by a remote method invocation from an underlying stream.

Specified by:
readException in interface JRMIUnMarshaller
Returns:
the thrown exception.
Throws:
java.rmi.UnmarshalException - if something goes wrong.

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 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:
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

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:
ChunkProvider

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. The default implementation uses the 'size' method.

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

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.

prepare

protected void prepare()
                throws org.objectweb.jonathan.apis.kernel.JonathanException
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException