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.
 org.objectweb.jonathan.apis.kernel.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 Detail

write

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.

writeByte

void writeByte(byte b)
               throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes a byte.

Parameters:
b - a byte;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

writeBoolean

void writeBoolean(boolean b)
                  throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes a boolean.

Parameters:
b - a boolean;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

writeChar8

void writeChar8(char i)
                throws org.objectweb.jonathan.apis.kernel.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;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

writeChar16

void writeChar16(char i)
                 throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes a 16 bits char.

Parameters:
i - a char;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

writeShort

void writeShort(short i)
                throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes a short.

Parameters:
i - a short;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

writeInt

void writeInt(int i)
              throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes an int.

Parameters:
i - an int;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

writeLong

void writeLong(long i)
               throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes a long.

Parameters:
i - a long;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

writeFloat

void writeFloat(float f)
                throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes a float.

Parameters:
f - a float;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

writeDouble

void writeDouble(double d)
                 throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes a double.

Parameters:
d - a double;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

writeString8

void writeString8(String s)
                  throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes a string of 8 bits chars.

Parameters:
s - a string;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

writeString16

void writeString16(String s)
                   throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes a string of 16 bits chars.

Parameters:
s - a string;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

writeReference

void writeReference(Object obj)
                    throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes an object reference in the marshaller.

Parameters:
obj - an object reference
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

writeValue

void writeValue(Object obj)
                throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes a value in the marshaller.

Parameters:
obj - an object
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.
Since:
3.0 a2

writeByteArray

void writeByteArray(byte[] array,
                    int offset,
                    int length)
                    throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes an array of bytes.

Parameters:
array - an array of bytes;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

outputStream

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.

sameContents

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.

isLittleEndian

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

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

getState

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

getOffset

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.

setOffset

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.

getContext

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

Returns:
a Context associated with this marshaller.

reset

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.


close

void close()
This method causes the message to lose all its references to the underlying chunks, and release each of them. It also released the context.