org.objectweb.jonathan.apis.presentation
Interface UnMarshaller

All Known Subinterfaces:
JRMIUnMarshaller
All Known Implementing Classes:
DavidInputStream, PortableMarshallerFactory.PortableUnMarshaller, StdMarshallerFactory.StdUnMarshaller

public interface UnMarshaller

UnMarshaller is the type of basic types unmarshallers. It should be used by protocols.


Method Summary
 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.
 boolean readBoolean()
          Reads a boolean.
 byte readByte()
          Reads a byte.
 void readByteArray(byte[] array, int offset, 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.
 java.lang.Object readReference()
          Reads a reference to an object.
 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.
 

Method Detail

readByte

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

Returns:
a byte.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

readBoolean

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

Returns:
a boolean.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

readChar8

public char readChar8()
               throws org.objectweb.jonathan.apis.kernel.JonathanException
Reads a 8 bits char.

Returns:
a char.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

readChar16

public char readChar16()
                throws org.objectweb.jonathan.apis.kernel.JonathanException
Reads a 16 bits char.

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
Reads a short.

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
Reads an int.

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
Reads a long.

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
Reads a float.

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
Reads a double.

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
Reads a string composed of 8 bits chars.

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
Reads a string composed of 16 bits chars.

Returns:
a string.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

readReference

public java.lang.Object readReference()
                               throws org.objectweb.jonathan.apis.kernel.JonathanException
Reads a reference to an object.

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 java.lang.Object readValue()
                           throws org.objectweb.jonathan.apis.kernel.JonathanException
Reads a value

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 offset,
                          int len)
                   throws org.objectweb.jonathan.apis.kernel.JonathanException
Reads an array of bytes.

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:
org.objectweb.jonathan.apis.kernel.JonathanException - if the format of the data is incompatible with the request.

inputStream

public java.io.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.

Returns:
an input stream to read from the unmarshaller.

isLittleEndian

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

Returns:
true if this unmarshaller is little-endian, false otherwise.

setByteOrder

public void setByteOrder(boolean little_endian)
Sets the byte order (returned by isLittleEndian) of the target unmarshaller

Parameters:
little_endian - the new byte order.

bytesRead

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

Returns:
the number of bytes read since the beginning.

setSize

public void setSize(int size)
             throws org.objectweb.jonathan.apis.kernel.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.

Parameters:
size - the expected number of readable bytes.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if something goes wrong.

close

public void close()
Closes the target unmarshaller, releasing all underlying resources (including a possible chunk provider).


getContext

public org.objectweb.jonathan.apis.kernel.Context getContext()
Returns a Context associated with this unmarshaller.

Returns:
a Context associated with this unmarshaller.