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

java.lang.Object
  extended byjava.io.OutputStream
      extended byorg.omg.CORBA.portable.OutputStream
          extended byorg.omg.CORBA_2_3.portable.OutputStream
              extended byorg.objectweb.david.apis.presentation.DavidOutputStream
                  extended byorg.objectweb.david.libs.presentation.portable.PortableMarshallerFactory.PortableMarshaller
All Implemented Interfaces:
org.objectweb.david.libs.presentation.portable.Constants, org.omg.CORBA.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.
 org.omg.CORBA.portable.InputStream create_input_stream()
           
 void endEncapsulation(int previous_encapsulation_start)
           
 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).
 org.omg.CORBA.ORB orb()
           
 java.io.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(java.lang.Object value)
           
 void write_Abstract(java.lang.Object value)
           
 void write_any_array(org.omg.CORBA.Any[] seq, int offset, int length)
           
 void write_any(org.omg.CORBA.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(org.omg.CORBA.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(java.lang.String value)
           
 void write_TypeCode(org.omg.CORBA.TypeCode value)
           
 void write_ulong(int value)
           
 void write_ulonglong(long value)
           
 void write_ushort(short value)
           
 void write_value(java.io.Serializable value)
           
 void write_Value(java.io.Serializable value)
           
 void write_value(java.io.Serializable value, org.omg.CORBA.portable.BoxedValueHelper factory)
           
 void write_value(java.io.Serializable value, java.lang.Class classe)
          Marshals a value
 void write_value(java.io.Serializable value, java.lang.String repository_id)
           
 void write_wchar(char value)
           
 void write_wstring(java.lang.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(java.lang.Object value)
          Method used by stubs when they need to send interfaces references.
 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 org.objectweb.david.apis.presentation.DavidOutputStream
_truncatable_ids, 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
See Also:
Constant Field Values

VALUE_TAG

public static final int VALUE_TAG
See Also:
Constant Field Values

CODEBASE

public static final int CODEBASE
See Also:
Constant Field Values

SINGLE_TYPE

public static final int SINGLE_TYPE
See Also:
Constant Field Values

MULTIPLE_TYPES

public static final int MULTIPLE_TYPES
See Also:
Constant Field Values

CHUNKS

public static final int CHUNKS
See Also:
Constant Field Values

INDIRECTION_TAG

public static final int INDIRECTION_TAG
See Also:
Constant Field Values
Constructor Detail

PortableMarshallerFactory.PortableMarshaller

public PortableMarshallerFactory.PortableMarshaller()
Builds a new marshaller.

Method Detail

orb

public org.omg.CORBA.ORB orb()

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 class: DavidOutputStream
Closes the stream.

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

Specified by:
close in interface Marshaller
Specified by:
close in class DavidOutputStream

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.

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)
Method used by stubs when they need to send interfaces references.

Specified by:
writeReference in interface Marshaller
Parameters:
value - an object reference

writeValue

public final void writeValue(java.lang.Object value)
Description copied from interface: Marshaller
Writes a value in the marshaller.

Specified by:
writeValue in interface Marshaller
Parameters:
value - an object

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.

create_input_stream

public org.omg.CORBA.portable.InputStream create_input_stream()

write_boolean

public final void write_boolean(boolean value)
Specified by:
write_boolean in interface org.omg.CORBA.DataOutputStream

write_char

public final void write_char(char value)
Specified by:
write_char in interface org.omg.CORBA.DataOutputStream

write_wchar

public final void write_wchar(char value)
Specified by:
write_wchar in interface org.omg.CORBA.DataOutputStream

write_octet

public final void write_octet(byte value)
Specified by:
write_octet in interface org.omg.CORBA.DataOutputStream

write_short

public final void write_short(short value)
Specified by:
write_short in interface org.omg.CORBA.DataOutputStream

write_ushort

public final void write_ushort(short value)
Specified by:
write_ushort in interface org.omg.CORBA.DataOutputStream

write_long

public final void write_long(int value)
Specified by:
write_long in interface org.omg.CORBA.DataOutputStream

write_ulong

public final void write_ulong(int value)
Specified by:
write_ulong in interface org.omg.CORBA.DataOutputStream

write_longlong

public final void write_longlong(long value)
Specified by:
write_longlong in interface org.omg.CORBA.DataOutputStream

write_ulonglong

public final void write_ulonglong(long value)
Specified by:
write_ulonglong in interface org.omg.CORBA.DataOutputStream

write_float

public final void write_float(float value)
Specified by:
write_float in interface org.omg.CORBA.DataOutputStream

write_double

public final void write_double(double value)
Specified by:
write_double in interface org.omg.CORBA.DataOutputStream

write_string

public final void write_string(java.lang.String value)
Specified by:
write_string in interface org.omg.CORBA.DataOutputStream

write_wstring

public final void write_wstring(java.lang.String value)
Specified by:
write_wstring in interface org.omg.CORBA.DataOutputStream

write_Value

public void write_Value(java.io.Serializable value)
Specified by:
write_Value in interface org.omg.CORBA.DataOutputStream
Parameters:
value -

write_value

public void write_value(java.io.Serializable value)

write_value

public void write_value(java.io.Serializable value,
                        java.lang.String repository_id)
Parameters:
value -

write_value

public void write_value(java.io.Serializable value,
                        java.lang.Class classe)
Marshals a value

Parameters:
value -
classe -

write_value

public void write_value(java.io.Serializable value,
                        org.omg.CORBA.portable.BoxedValueHelper factory)
Parameters:
value -
factory -

write_boolean_array

public final void write_boolean_array(boolean[] array,
                                      int off,
                                      int len)
Specified by:
write_boolean_array in interface org.omg.CORBA.DataOutputStream

write_char_array

public final void write_char_array(char[] array,
                                   int off,
                                   int len)
Specified by:
write_char_array in interface org.omg.CORBA.DataOutputStream

write_octet_array

public final void write_octet_array(byte[] array,
                                    int off,
                                    int len)
Specified by:
write_octet_array in interface org.omg.CORBA.DataOutputStream

write_Object

public final void write_Object(org.omg.CORBA.Object value)
Method used by stubs when they need to send interfaces references.

Specified by:
write_Object in interface org.omg.CORBA.DataOutputStream

write_TypeCode

public final void write_TypeCode(org.omg.CORBA.TypeCode value)
Specified by:
write_TypeCode in interface org.omg.CORBA.DataOutputStream

write_any

public final void write_any(org.omg.CORBA.Any value)
Specified by:
write_any in interface org.omg.CORBA.DataOutputStream

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

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.

prepare

protected void prepare()
                throws org.objectweb.jonathan.apis.kernel.JonathanException
When offset is equal to top, this method is % called to get a new chunk to write to.

Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if something goes wrong.

write_longdouble

public void write_longdouble(double value)
Specified by:
write_longdouble in interface org.omg.CORBA.DataOutputStream

write_abstract_interface

public void write_abstract_interface(java.lang.Object value)

write_Abstract

public void write_Abstract(java.lang.Object value)
Specified by:
write_Abstract in interface org.omg.CORBA.DataOutputStream

write_any_array

public void write_any_array(org.omg.CORBA.Any[] seq,
                            int offset,
                            int length)
Specified by:
write_any_array in interface org.omg.CORBA.DataOutputStream

startEncapsulation

public int startEncapsulation()
                       throws org.objectweb.jonathan.apis.kernel.JonathanException
Specified by:
startEncapsulation in class DavidOutputStream
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException

endEncapsulation

public void endEncapsulation(int previous_encapsulation_start)
                      throws org.objectweb.jonathan.apis.kernel.JonathanException
Specified by:
endEncapsulation in class DavidOutputStream
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException

writePadding

protected void writePadding(int constraint)
                     throws org.objectweb.jonathan.apis.kernel.JonathanException
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException