org.objectweb.jonathan.presentation.api

Interface UnMarshaller

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).
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.
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.
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 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 Details

bytesRead

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

Returns:
the number of bytes read since the beginning.


close

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


getContext

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

Returns:
a Context associated with this unmarshaller.


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.

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.


readBoolean

public boolean readBoolean()
            throws JonathanException
Reads a boolean.

Returns:
a boolean.


readByte

public byte readByte()
            throws JonathanException
Reads a byte.

Returns:
a byte.


readByteArray

public void readByteArray(byte[] array,
                          int offset,
                          int len)
            throws 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;


readChar16

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

Returns:
a char.


readChar8

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

Returns:
a char.


readDouble

public double readDouble()
            throws JonathanException
Reads a double.

Returns:
a double.


readFloat

public float readFloat()
            throws JonathanException
Reads a float.

Returns:
a float.


readInt

public int readInt()
            throws JonathanException
Reads an int.

Returns:
an int.


readLong

public long readLong()
            throws JonathanException
Reads a long.

Returns:
a long.


readReference

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

Returns:
a reference to an object.


readShort

public short readShort()
            throws JonathanException
Reads a short.

Returns:
a short.


readString16

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

Returns:
a string.


readString8

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

Returns:
a string.


readValue

public Object readValue()
            throws JonathanException
Reads a value

Returns:
an object representing the read value


setByteOrder

public void setByteOrder(boolean little_endian)

Parameters:
little_endian - the new byte order.


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.

Parameters:
size - the expected number of readable bytes.