org.objectweb.david.libs.presentation.portable
Class PortableMarshallerFactory.PortableMarshaller

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--org.omg.CORBA.portable.OutputStream
              |
              +--org.omg.CORBA_2_3.portable.OutputStream
                    |
                    +--org.objectweb.david.apis.presentation.DavidOutputStream
                          |
                          +--org.objectweb.david.libs.presentation.portable.PortableMarshallerFactory.PortableMarshaller
All Implemented Interfaces:
org.objectweb.david.libs.presentation.portable.Constants, DataOutputStream, Marshaller
Direct Known Subclasses:
PortableMarshallerFactory.PortableMarshallerL
Enclosing class:
PortableMarshallerFactory

public abstract class PortableMarshallerFactory.PortableMarshaller
extends DavidOutputStream
implements org.objectweb.david.libs.presentation.portable.Constants

PortableMarshaller is an (abstract) implementation of Marshaller.


Field Summary
static int CHUNKS
           
static int CODEBASE
           
protected  Chunk current
          The current chunk in the message, i.e., the one data are written to.
protected  int encapsulation_start
           
protected  Chunk first
          The first chunk in the message.
static int INDIRECTION_TAG
           
static int MULTIPLE_TYPES
           
static int NULL_TAG
           
protected  int offset
          The offset of the first writable byte in current.
protected  int prev_size
          prev_size is such that prev_size + offset = the current offset in the whole message.
static int SINGLE_TYPE
           
protected  int top
          The offset of the first non-writable byte in current.
static int VALUE_TAG
           
 
Constructor Summary
PortableMarshallerFactory.PortableMarshaller()
          Builds a new marshaller.
 
Method Summary
 void close()
          Closes the stream.
 InputStream create_input_stream()
           
 void endEncapsulation(int previous_encapsulation_start)
           
 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).
 ORB orb()
           
 OutputStream outputStream()
          Returns an output stream to write into the message.
protected  void prepare()
          When offset is equal to top, this method is % called to get a new chunk to write to.
 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.
 int startEncapsulation()
           
 void write_abstract_interface(Object value)
           
 void write_Abstract(Object value)
           
 void write_any_array(Any[] seq, int offset, int length)
           
 void write_any(Any value)
           
 void write_boolean_array(boolean[] array, int off, int len)
           
 void write_boolean(boolean value)
           
 void write_char_array(char[] array, int off, int len)
           
 void write_char(char value)
           
 void write_double(double value)
           
 void write_float(float value)
           
 void write_long(int value)
           
 void write_longdouble(double value)
           
 void write_longlong(long value)
           
 void write_Object(Object value)
          Method used by stubs when they need to send interfaces references.
 void write_octet_array(byte[] array, int off, int len)
           
 void write_octet(byte value)
           
 void write_short(short value)
           
 void write_string(String value)
           
 void write_TypeCode(TypeCode value)
           
 void write_ulong(int value)
           
 void write_ulonglong(long value)
           
 void write_ushort(short value)
           
 void write_value(Serializable value)
           
 void write_Value(Serializable value)
           
 void write_value(Serializable value, BoxedValueHelper factory)
           
 void write_value(Serializable value, Class classe)
          Marshals a value
 void write_value(Serializable value, String repository_id)
           
 void write_wchar(char value)
           
 void write_wstring(String value)
           
 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.
protected  void writePadding(int constraint)
           
 void writeReference(Object value)
          Method used by stubs when they need to send interfaces references.
 void writeString8(String str)
          Writes a string in a message.
 void writeValue(Object value)
          Writes a value in the marshaller.
 
Methods inherited from class org.objectweb.david.apis.presentation.DavidOutputStream
write_Principal
 
Methods inherited from class org.omg.CORBA.portable.OutputStream
write_Context, write_double_array, write_fixed, write_float_array, write_long_array, write_longlong_array, write_short_array, write_ulong_array, write_ulonglong_array, write_ushort_array, write_wchar_array
 
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
 
Methods inherited from interface org.omg.CORBA.DataOutputStream
write_double_array, write_float_array, write_long_array, write_longlong_array, write_short_array, write_ulong_array, write_ulonglong_array, write_ushort_array, write_wchar_array
 

Field Detail

first

protected Chunk first
The first chunk in the message.

current

protected Chunk current
The current chunk in the message, i.e., the one data are written to.

offset

protected int offset
The offset of the first writable byte in current.

top

protected int top
The offset of the first non-writable byte in current.

prev_size

protected int prev_size
prev_size is such that prev_size + offset = the current offset in the whole message.

encapsulation_start

protected int encapsulation_start

NULL_TAG

public static final int NULL_TAG

VALUE_TAG

public static final int VALUE_TAG

CODEBASE

public static final int CODEBASE

SINGLE_TYPE

public static final int SINGLE_TYPE

MULTIPLE_TYPES

public static final int MULTIPLE_TYPES

CHUNKS

public static final int CHUNKS

INDIRECTION_TAG

public static final int INDIRECTION_TAG
Constructor Detail

PortableMarshallerFactory.PortableMarshaller

public PortableMarshallerFactory.PortableMarshaller()
Builds a new marshaller.
Method Detail

orb

public ORB orb()
Overrides:
orb in class OutputStream

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.

Following copied from interface: org.objectweb.jonathan.apis.presentation.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.

Following copied from interface: org.objectweb.jonathan.apis.presentation.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.
Following copied from interface: org.objectweb.jonathan.apis.presentation.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.

Following copied from interface: org.objectweb.jonathan.apis.presentation.Marshaller
Parameters:
offset - 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.

close

public void close()
Description copied from class: DavidOutputStream
Closes the stream.

This method has been added here to solve an exception conflict between OutputStream and Marshaller.

Overrides:
close in class DavidOutputStream

outputStream

public 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.
Following copied from interface: org.objectweb.jonathan.apis.presentation.Marshaller
Returns:
an output stream to write into the message.

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.
Following copied from interface: org.objectweb.jonathan.apis.presentation.Marshaller
Parameters:
marshaller - 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 JonathanException
Writes a byte in a message.
Parameters:
v - a byte;
Throws:
JonathanException - if an error occurs.

writeBoolean

public void writeBoolean(boolean v)
                  throws JonathanException
Writes a boolean in a message.
Parameters:
v - a boolean;
Throws:
JonathanException - if an error occurs.

writeChar8

public void writeChar8(char v)
                throws JonathanException
Writes a char in a message.
Parameters:
v - a char;
Throws:
JonathanException - if an error occurs.

writeString8

public void writeString8(String str)
                  throws JonathanException
Writes a string in a message.
Parameters:
str - a string;
Throws:
JonathanException - if an error occurs.

writeReference

public final void writeReference(Object value)
Method used by stubs when they need to send interfaces references.
Parameters:
exp - the surrogate that must be sent;

writeValue

public final void writeValue(Object value)
Description copied from interface: Marshaller
Writes a value in the marshaller.
Following copied from interface: org.objectweb.jonathan.apis.presentation.Marshaller
Parameters:
obj - an object
Throws:
JonathanException - if a marshal error occurred.

writeByteArray

public void writeByteArray(byte[] array,
                           int off,
                           int len)
                    throws JonathanException
Writes an array of bytes in a message.
Parameters:
array - an array of bytes;
Throws:
JonathanException - if an error occurs.

create_input_stream

public InputStream create_input_stream()
Overrides:
create_input_stream in class OutputStream

write_boolean

public final void write_boolean(boolean value)
Overrides:
write_boolean in class OutputStream

write_char

public final void write_char(char value)
Overrides:
write_char in class OutputStream

write_wchar

public final void write_wchar(char value)
Overrides:
write_wchar in class OutputStream

write_octet

public final void write_octet(byte value)
Overrides:
write_octet in class OutputStream

write_short

public final void write_short(short value)
Overrides:
write_short in class OutputStream

write_ushort

public final void write_ushort(short value)
Overrides:
write_ushort in class OutputStream

write_long

public final void write_long(int value)
Overrides:
write_long in class OutputStream

write_ulong

public final void write_ulong(int value)
Overrides:
write_ulong in class OutputStream

write_longlong

public final void write_longlong(long value)
Overrides:
write_longlong in class OutputStream

write_ulonglong

public final void write_ulonglong(long value)
Overrides:
write_ulonglong in class OutputStream

write_float

public final void write_float(float value)
Overrides:
write_float in class OutputStream

write_double

public final void write_double(double value)
Overrides:
write_double in class OutputStream

write_string

public final void write_string(String value)
Overrides:
write_string in class OutputStream

write_wstring

public final void write_wstring(String value)
Overrides:
write_wstring in class OutputStream

write_Value

public void write_Value(Serializable value)
Parameters:
value -  

write_value

public void write_value(Serializable value)
Overrides:
write_value in class OutputStream

write_value

public void write_value(Serializable value,
                        String repository_id)
Overrides:
write_value in class OutputStream
Parameters:
value -  
rep_id -  

write_value

public void write_value(Serializable value,
                        Class classe)
Marshals a value
Overrides:
write_value in class OutputStream
Parameters:
value -  
classe -  

write_value

public void write_value(Serializable value,
                        BoxedValueHelper factory)
Overrides:
write_value in class OutputStream
Parameters:
value -  
factory -  

write_boolean_array

public final void write_boolean_array(boolean[] array,
                                      int off,
                                      int len)
Overrides:
write_boolean_array in class OutputStream

write_char_array

public final void write_char_array(char[] array,
                                   int off,
                                   int len)
Overrides:
write_char_array in class OutputStream

write_octet_array

public final void write_octet_array(byte[] array,
                                    int off,
                                    int len)
Overrides:
write_octet_array in class OutputStream

write_Object

public final void write_Object(Object value)
Method used by stubs when they need to send interfaces references.
Overrides:
write_Object in class OutputStream
Parameters:
exp - the surrogate that must be sent;

write_TypeCode

public final void write_TypeCode(TypeCode value)
Overrides:
write_TypeCode in class OutputStream

write_any

public final void write_any(Any value)
Overrides:
write_any in class OutputStream

write

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

This method calls the write(byte) method.

Overrides:
write in class OutputStream
Parameters:
b - the byte.
Throws:
IOException - if no buffer to write to could be obtained.

write

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

Overrides:
write in class OutputStream
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.

getContext

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

prepare

protected void prepare()
                throws JonathanException
When offset is equal to top, this method is % called to get a new chunk to write to.
Throws:
JonathanException - if something goes wrong.

write_longdouble

public void write_longdouble(double value)

write_abstract_interface

public void write_abstract_interface(Object value)
Overrides:
write_abstract_interface in class OutputStream

write_Abstract

public void write_Abstract(Object value)

write_any_array

public void write_any_array(Any[] seq,
                            int offset,
                            int length)

startEncapsulation

public int startEncapsulation()
                       throws JonathanException
Overrides:
startEncapsulation in class DavidOutputStream

endEncapsulation

public void endEncapsulation(int previous_encapsulation_start)
                      throws JonathanException
Overrides:
endEncapsulation in class DavidOutputStream

writePadding

protected void writePadding(int constraint)
                     throws JonathanException