org.objectweb.jonathan.presentation.api

Interface Marshaller

public interface Marshaller

Marshaller is the type of basic types marshallers. They should be used by protocols.

Method Summary

void
close()
This method causes the message to lose all its references to the underlying chunks, and release each of them.
Context
getContext()
Returns a Context associated with this marshaller.
int
getOffset()
Returns the current offset in the message, i.e., the position in the message at which the next byte will be written.
Chunk
getState()
Returns the state of the message as a (chain of) chunk(s).
boolean
isLittleEndian()
Returns true if this marshaller is little-endian, false otherwise.
OutputStream
outputStream()
Returns an output stream to write into the message.
void
reset()
This method causes the message to lose all its references to the underlying chunks, without releasing them.
boolean
sameContents(Marshaller marshaller)
Checks if the target marshaller and the provided one have the same contents, i.e., they contain the same bits.
void
setOffset(int offset)
Sets the offset in the message.
void
write(Chunk chunk)
Writes a chunk in the message.
void
writeBoolean(boolean b)
Writes a boolean.
void
writeByte(byte b)
Writes a byte.
void
writeByteArray(byte[] array, int offset, int length)
Writes an array of bytes.
void
writeChar16(char i)
Writes a 16 bits char.
void
writeChar8(char i)
Writes an 8 bits char.
void
writeDouble(double d)
Writes a double.
void
writeFloat(float f)
Writes a float.
void
writeInt(int i)
Writes an int.
void
writeLong(long i)
Writes a long.
void
writeReference(Object obj)
Writes an object reference in the marshaller.
void
writeShort(short i)
Writes a short.
void
writeString16(String s)
Writes a string of 16 bits chars.
void
writeString8(String s)
Writes a string of 8 bits chars.
void
writeValue(Object obj)
Writes a value in the marshaller.

Method Details

close

public void close()


getContext

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

Returns:
a Context associated with this marshaller.


getOffset

public int getOffset()
Returns the current offset in the message, i.e., the position in the message at which the next byte will be written.

Returns:
the current offset in the message.


getState

public Chunk getState()
Returns the state of the message as a (chain of) chunk(s).

The returned chunk(s) are NOT duplicated. If the caller keeps a reference to them, it must reset the message, and not continue to use it.

Returns:
the state of the message as a (chain of) chunk(s).


isLittleEndian

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

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


outputStream

public OutputStream outputStream()
Returns an output stream to write into the message. Closing the output stream has the same effect as closing the marshaller itself.

Returns:
an output stream to write into the message.


reset

public void reset()
This method causes the message to lose all its references to the underlying chunks, without releasing them. This method must not be used if no reference to chunks present in the message is held by an entity in charge of their release. It also releases the context associated with the target marshaller.


sameContents

public boolean sameContents(Marshaller marshaller)
Checks if the target marshaller and the provided one have the same contents, i.e., they contain the same bits.

Parameters:
marshaller - a marshaller;

Returns:
true if the target marshaller and the provided one have the same contents, false otherwise.


setOffset

public void setOffset(int offset)
Sets the offset in the message.

This method may be used to override data already written into the message.

Parameters:
offset - the new offset.


write

public void write(Chunk chunk)
Writes a chunk in the message.

The target becomes the "owner" of the provided chunk, and therefore is not supposed to duplicate it. If the entity invoking this operation wants to keep a reference to the chunk, it must be duplicated.

Parameters:
chunk - the chunk to be written.


writeBoolean

public void writeBoolean(boolean b)
            throws JonathanException
Writes a boolean.

Parameters:
b - a boolean;


writeByte

public void writeByte(byte b)
            throws JonathanException
Writes a byte.

Parameters:
b - a byte;


writeByteArray

public void writeByteArray(byte[] array,
                           int offset,
                           int length)
            throws JonathanException
Writes an array of bytes.

Parameters:
array - an array of bytes;


writeChar16

public void writeChar16(char i)
            throws JonathanException
Writes a 16 bits char.

Parameters:
i - a char;


writeChar8

public void writeChar8(char i)
            throws JonathanException
Writes an 8 bits char.

The method used to translate the provided char into an 8 bits entity is not specified.

Parameters:
i - a char;


writeDouble

public void writeDouble(double d)
            throws JonathanException
Writes a double.

Parameters:
d - a double;


writeFloat

public void writeFloat(float f)
            throws JonathanException
Writes a float.

Parameters:
f - a float;


writeInt

public void writeInt(int i)
            throws JonathanException
Writes an int.

Parameters:
i - an int;


writeLong

public void writeLong(long i)
            throws JonathanException
Writes a long.

Parameters:
i - a long;


writeReference

public void writeReference(Object obj)
            throws JonathanException
Writes an object reference in the marshaller.

Parameters:
obj - an object reference


writeShort

public void writeShort(short i)
            throws JonathanException
Writes a short.

Parameters:
i - a short;


writeString16

public void writeString16(String s)
            throws JonathanException
Writes a string of 16 bits chars.

Parameters:
s - a string;


writeString8

public void writeString8(String s)
            throws JonathanException
Writes a string of 8 bits chars.

Parameters:
s - a string;


writeValue

public void writeValue(Object obj)
            throws JonathanException
Writes a value in the marshaller.

Parameters:
obj - an object

Since:
3.0 a2