org.objectweb.fractal.rmi.io
Class RmiUnMarshaller

java.lang.Object
  extended byjava.io.InputStream
      extended byorg.objectweb.fractal.rmi.io.RmiUnMarshaller
All Implemented Interfaces:
UnMarshaller

public class RmiUnMarshaller
extends InputStream
implements UnMarshaller

An UnMarshaller that uses an RmiObjectInputStream to unmarshall object values.


Field Summary
protected  ContextFactory contextFactory
          The context factory used to create the context associated with this marshaller.
protected  NamingContext domain
          The domain used to instantiate is.
protected  ObjectInputStream is
          The object input stream used to unmarshall object values.
 
Constructor Summary
RmiUnMarshaller(NamingContext domain, ContextFactory contextFactory, Chunk chunk, int read)
          Constructs a new RmiUnMarshaller.
RmiUnMarshaller(NamingContext domain, ContextFactory contextFactory, ChunkProvider provider)
          Constructs a new RmiUnMarshaller.
 
Method Summary
 int available()
           
 int bytesRead()
          Returns the number of bytes read since the beginning.
 void close()
          Closes this input stream and releases any system resources associated with the stream.
 Context getContext()
          Returns a Context associated with this unmarshaller.
protected  void initObjectStream()
          Instantiates the delegate object input stream is.
 InputStream inputStream()
          Returns an input stream to read data from the unmarshaller.
 boolean isLittleEndian()
          Returns true if this unmarshaller is little-endian, false otherwise.
 int read()
           
 int read(byte[] array, int off, int length)
           
 boolean readBoolean()
          Reads a boolean.
 byte readByte()
          Reads a byte.
 void readByteArray(byte[] array, int off, int len)
          Reads an array of bytes.
 char readChar16()
          Reads a 16 bits char.
 char readChar8()
          Reads a 8 bits char.
 double readDouble()
          Reads a double.
 float readFloat()
          Reads a float.
 int readInt()
          Reads an int.
 long readLong()
          Reads a long.
 Object readReference()
          Reads a reference to an object.
 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 littleEndian)
          Sets the byte order of this unmarshaller.
 void setSize(int size)
          Sets the number of bytes readable from the unmarshaller.
 long skip(long n)
           
 
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

domain

protected NamingContext domain
The domain used to instantiate is.


contextFactory

protected ContextFactory contextFactory
The context factory used to create the context associated with this marshaller. See getContext.


is

protected ObjectInputStream is
The object input stream used to unmarshall object values. This stream is lazily instantiated, i.e., it is instantiated at the first call to readValue or to readReference.

Constructor Detail

RmiUnMarshaller

public RmiUnMarshaller(NamingContext domain,
                       ContextFactory contextFactory,
                       Chunk chunk,
                       int read)
Constructs a new RmiUnMarshaller.

Parameters:
domain - the domain to be used to instantiate is.
contextFactory - the context factory to be used to create the context associated with this marshaller.
chunk - a (chain of) chunk(s).
read - the number of bytes already read from the message.

RmiUnMarshaller

public RmiUnMarshaller(NamingContext domain,
                       ContextFactory contextFactory,
                       ChunkProvider provider)
Constructs a new RmiUnMarshaller.

Parameters:
domain - the domain to be used to instantiate is.
contextFactory - the context factory to be used to create the context associated with this marshaller.
provider - a chunk provider.
Method Detail

isLittleEndian

public 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 littleEndian)
Sets the byte order of this unmarshaller.

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

getContext

public final Context getContext()
Returns a Context associated with this unmarshaller.

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

bytesRead

public int bytesRead()
Returns the number of bytes read since the beginning.

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

setSize

public void setSize(int size)
             throws JonathanException
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:
JonathanException - if something goes wrong.

inputStream

public InputStream inputStream()
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.

readByte

public byte readByte()
              throws JonathanException
Reads a byte.

Specified by:
readByte in interface UnMarshaller
Returns:
a byte.
Throws:
JonathanException - if the format of the data is incompatible with the request.

readBoolean

public boolean readBoolean()
                    throws JonathanException
Reads a boolean.

Specified by:
readBoolean in interface UnMarshaller
Returns:
a boolean.
Throws:
JonathanException - if the format of the data is incompatible with the request.

readChar8

public char readChar8()
               throws JonathanException
Reads a 8 bits char.

Specified by:
readChar8 in interface UnMarshaller
Returns:
a char.
Throws:
JonathanException - if the format of the data is incompatible with the request.

readChar16

public char readChar16()
                throws JonathanException
Reads a 16 bits char.

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

readShort

public short readShort()
                throws JonathanException
Reads a short.

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

readInt

public int readInt()
            throws JonathanException
Reads an int.

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

readFloat

public float readFloat()
                throws JonathanException
Reads a float.

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

readLong

public long readLong()
              throws JonathanException
Reads a long.

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

readDouble

public double readDouble()
                  throws JonathanException
Reads a double.

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

readString8

public String readString8()
                   throws JonathanException
Reads a string composed of 8 bits chars.

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

readString16

public String readString16()
                    throws JonathanException
Reads a string composed of 16 bits chars.

Specified by:
readString16 in interface UnMarshaller
Returns:
a string.
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
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:
JonathanException - if the format of the data is incompatible with the request.

readReference

public Object readReference()
                     throws JonathanException
Reads a reference to an object.

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

readValue

public Object readValue()
                 throws JonathanException
Reads a value.

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

available

public int available()
              throws IOException
Throws:
IOException

read

public int read()
         throws IOException
Throws:
IOException

read

public int read(byte[] array,
                int off,
                int length)
         throws IOException
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Throws:
IOException

close

public void close()
Closes this input stream and releases any system resources associated with the stream.

Specified by:
close in interface UnMarshaller

initObjectStream

protected void initObjectStream()
                         throws IOException
Instantiates the delegate object input stream is. This method creates RmiObjectInputStream stream.

Throws:
IOException - if the delegate object input stream cannot be created.