org.objectweb.jeremie.libs.presentation.std
Class StdMarshallerFactory.StdMarshaller

java.lang.Object
  extended byjava.io.OutputStream
      extended byorg.objectweb.jeremie.libs.presentation.std.StdMarshallerFactory.StdMarshaller
All Implemented Interfaces:
JRMIMarshaller, Marshaller
Direct Known Subclasses:
StdMarshallerFactory.StdMarshallerL
Enclosing class:
StdMarshallerFactory

public abstract class StdMarshallerFactory.StdMarshaller
extends java.io.OutputStream
implements JRMIMarshaller

StdMarshaller is an (abstract) implementation of Marshaller.


Field Summary
protected  org.objectweb.jonathan.apis.kernel.Context context
           
protected  Chunk current
           
protected  Chunk first
           
protected  int offset
           
protected  org.objectweb.jeremie.libs.presentation.std.StdMarshallerFactory.JRMIOutputStream os
           
protected  int top
           
 
Constructor Summary
StdMarshallerFactory.StdMarshaller()
           
 
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).
 java.io.OutputStream outputStream()
          Returns an output stream to write into the message.
protected  void prepare()
           
 void reset()
          This method causes the message to lose all its references to the underlying chunks, without releasing them.
 boolean sameContents(Marshaller other)
          Checks if the target marshaller and the provided one have the same contents, i.e., they contain the same bits.
 void setOffset(int off)
          Sets the offset in the message.
 void write(byte[] array, int off, int len)
          Writes 'len' bytes from the specified byte array starting at offset 'off' to this output message.
 void write(Chunk chunk)
          Writes a chunk in the message.
 void write(int b)
          Writes the specified byte to this message.
 void writeBoolean(boolean v)
          Writes a boolean in a message.
 void writeByte(byte v)
          Writes a byte in a message.
 void writeByteArray(byte[] array, int off, int len)
          Writes an array of bytes in a message.
 void writeChar8(char v)
          Writes a char in a message.
 void writeException(java.lang.Exception ex)
          Writes an exception thrown by a remote method invocation to an underlying stream.
 void writeMethod(java.lang.reflect.Method method)
          Writes the method in a remote method invocation to an underlying stream.
 void writeParameters(java.lang.Object[] params)
          Writes the arguments in a remote method invocation to an underlying stream.
 void writeReference(java.lang.Object value)
          Method used by stubs when they need to send interfaces references.
 void writeResult(java.lang.Object result)
          Writes the result of a remote method invocation to an underlying stream.
 void writeString8(java.lang.String str)
          Writes a string in a message.
 void writeValue(java.lang.Object value)
          Writes a value in the marshaller.
 
Methods inherited from class java.io.OutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.jonathan.apis.presentation.Marshaller
isLittleEndian, writeChar16, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeString16
 

Field Detail

first

protected Chunk first

current

protected Chunk current

offset

protected int offset

top

protected int top

os

protected org.objectweb.jeremie.libs.presentation.std.StdMarshallerFactory.JRMIOutputStream os

context

protected org.objectweb.jonathan.apis.kernel.Context context
Constructor Detail

StdMarshallerFactory.StdMarshaller

public StdMarshallerFactory.StdMarshaller()
Method Detail

write

public void write(Chunk chunk)
Description copied from interface: Marshaller
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.

Specified by:
write in interface Marshaller
Parameters:
chunk - the chunk to be written.

getState

public Chunk getState()
Description copied from interface: Marshaller
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.

Specified by:
getState in interface Marshaller
Returns:
the state of the message as a (chain of) chunk(s).

getOffset

public int getOffset()
Description copied from interface: Marshaller
Returns the current offset in the message, i.e., the position in the message at which the next byte will be written.

Specified by:
getOffset in interface Marshaller
Returns:
the current offset in the message.

setOffset

public void setOffset(int off)
Description copied from interface: Marshaller
Sets the offset in the message.

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

Specified by:
setOffset in interface Marshaller
Parameters:
off - the new offset.

reset

public void reset()
Description copied from interface: Marshaller
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.

Specified by:
reset in interface Marshaller

close

public void close()
Description copied from interface: Marshaller
This method causes the message to lose all its references to the underlying chunks, and release each of them. It also released the context.

Specified by:
close in interface Marshaller

outputStream

public java.io.OutputStream outputStream()
Description copied from interface: Marshaller
Returns an output stream to write into the message. Closing the output stream has the same effect as closing the marshaller itself.

Specified by:
outputStream in interface Marshaller
Returns:
an output stream to write into the message.

getContext

public final org.objectweb.jonathan.apis.kernel.Context getContext()
Description copied from interface: Marshaller
Returns a Context associated with this marshaller.

Specified by:
getContext in interface Marshaller
Returns:
a Context associated with this marshaller.

sameContents

public final boolean sameContents(Marshaller other)
Description copied from interface: Marshaller
Checks if the target marshaller and the provided one have the same contents, i.e., they contain the same bits.

Specified by:
sameContents in interface Marshaller
Parameters:
other - a marshaller;
Returns:
true if the target marshaller and the provided one have the same contents, false otherwise.

writeByte

public void writeByte(byte v)
               throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes a byte in a message.

Specified by:
writeByte in interface Marshaller
Parameters:
v - a byte;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if an error occurs.

writeBoolean

public void writeBoolean(boolean v)
                  throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes a boolean in a message.

Specified by:
writeBoolean in interface Marshaller
Parameters:
v - a boolean;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if an error occurs.

writeChar8

public void writeChar8(char v)
                throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes a char in a message.

Specified by:
writeChar8 in interface Marshaller
Parameters:
v - a char;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if an error occurs.

writeString8

public void writeString8(java.lang.String str)
                  throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes a string in a message.

Specified by:
writeString8 in interface Marshaller
Parameters:
str - a string;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if an error occurs.

writeReference

public final void writeReference(java.lang.Object value)
                          throws org.objectweb.jonathan.apis.kernel.JonathanException
Method used by stubs when they need to send interfaces references.

Specified by:
writeReference in interface Marshaller
Parameters:
value - an object reference
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

writeValue

public final void writeValue(java.lang.Object value)
                      throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from interface: Marshaller
Writes a value in the marshaller.

Specified by:
writeValue in interface Marshaller
Parameters:
value - an object
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if a marshal error occurred.

writeByteArray

public void writeByteArray(byte[] array,
                           int off,
                           int len)
                    throws org.objectweb.jonathan.apis.kernel.JonathanException
Writes an array of bytes in a message.

Specified by:
writeByteArray in interface Marshaller
Parameters:
array - an array of bytes;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if an error occurs.

write

public final void write(int b)
                 throws java.io.IOException
Writes the specified byte to this message.

This method calls the write(byte) method.

Parameters:
b - the byte.
Throws:
java.io.IOException - if no buffer to write to could be obtained.

write

public final void write(byte[] array,
                        int off,
                        int len)
                 throws java.io.IOException
Writes 'len' bytes from the specified byte array starting at offset 'off' to this output message.

Parameters:
off - the start offset in the data.
len - the number of bytes to write.
Throws:
java.io.IOException

writeMethod

public void writeMethod(java.lang.reflect.Method method)
                 throws java.rmi.MarshalException
Description copied from interface: JRMIMarshaller
Writes the method in a remote method invocation to an underlying stream.

Specified by:
writeMethod in interface JRMIMarshaller
Parameters:
method - the method to be written.
Throws:
java.rmi.MarshalException - if something goes wrong.

writeParameters

public void writeParameters(java.lang.Object[] params)
                     throws java.rmi.MarshalException
Description copied from interface: JRMIMarshaller
Writes the arguments in a remote method invocation to an underlying stream.

Specified by:
writeParameters in interface JRMIMarshaller
Parameters:
params - the objects representing the arguments.
Throws:
java.rmi.MarshalException - if something goes wrong.

writeResult

public void writeResult(java.lang.Object result)
                 throws java.rmi.MarshalException
Description copied from interface: JRMIMarshaller
Writes the result of a remote method invocation to an underlying stream.

Specified by:
writeResult in interface JRMIMarshaller
Parameters:
result - the object representing the result.
Throws:
java.rmi.MarshalException - if something goes wrong.

writeException

public void writeException(java.lang.Exception ex)
                    throws java.rmi.MarshalException
Description copied from interface: JRMIMarshaller
Writes an exception thrown by a remote method invocation to an underlying stream.

Specified by:
writeException in interface JRMIMarshaller
Parameters:
ex - the thrown exception.
Throws:
java.rmi.MarshalException - if something goes wrong.

prepare

protected void prepare()
                throws org.objectweb.jonathan.apis.kernel.JonathanException
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException