2005/5/9

     
 

class AbstractObjectWriter

artefaktur
Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   Namespace Members   Compound Members   Related Pages  

acdk::io::AbstractObjectWriter Class Reference

#include <AbstractObjectWriter.h>

Inheritance diagram for acdk::io::AbstractObjectWriter:

acdk::io::AbstractFilterWriter acdk::io::ObjectWriter acdk::io::AbstractWriter acdk::io::FilterWriter acdk::lang::Object acdk::io::Writer acdk::lang::ObjectBase acdk::lang::dmi::StdDispatch acdk::io::BinaryObjectWriter acdk::xml::XMLObjectWriter acdk::java::serialization::JavaObjectWriter List of all members.

Detailed Description

Standard implementation for Writing Objects into a stream (Serialization/Marshaling) API: ACDK.

Author:
Roger Rene Kommer (mailto:kommer@artefaktur.com)
Version:
Revision
1.27
Date:
Date
2005/03/14 12:20:44
See also:
AbstractObjectReader


Public Member Functions

 AbstractObjectWriter (IN(RWriter) out, int flags=SerializeDefaultFlags)
void resetLocalRefs ()
void flush ()
void write (byte b)
 default implementation: byte cbuf[2]; cbuf[1] = 0; cbuf[0] = c; return write((const byte*)cbuf, 0, 1);

void write (const byte *cstr, int offset, int len)
void setOut (IN(RWriter) writer)
RStorage getStorage ()
 Gets the storage reader.

RWriter getStorageWriter ()
 returns the unfiltered Writer

virtual void writeObject (IN(acdk::lang::Object) obj)
 This version write acdk::lang::Object to a Writer.

virtual void writeObject (IN(RClass) cls, IN(acdk::lang::Object) obj)
 This version writes an acdk::lang::Object to a Writer using the Class.

bool isNamed ()
bool isLabeled ()
bool isTagged ()
bool isReduced ()
bool joinStrings ()
bool withSerialVersionUID ()
virtual void writeTagStart (IN(RString) key, IN(RString) value=Nil)=0
 Writes start of Tag.

virtual void writeTagEnd (IN(RString) key, IN(RString) value=Nil)=0
 Writes end of Tag.

virtual void writeClassId (IN(::acdk::lang::RClass) cls)=0
 Write boot-straping ID for the given, so the corresponding AbstractObjectReader::readClassId() can create an acdk::lang::Object instance.

virtual void writeObjectLocalId (int id)
 In case ObjectWriter should handle writing Objects which may have cyclic references, for each acdk::lang::Object a local reference id.

virtual void writeChar (char b)=0
 From acdk::io::DataWriter.

virtual void writeUcChar (uc2char b)=0
 From acdk::io::DataWriter.

virtual void writeShort (short b)=0
 From acdk::io::DataWriter.

virtual void writeInt (int b)=0
 From acdk::io::DataWriter.

virtual void writeLong (jlong b)=0
 From acdk::io::DataWriter.

virtual void writeFloat (float b)=0
 From acdk::io::DataWriter.

virtual void writeDouble (double b)=0
 From acdk::io::DataWriter.

virtual void write (IN(RbyteArray) array, int offset=0, int len=-1)=0
 From acdk::io::DataWriter.

virtual void writeOpaque (IN(RbyteArray) array)
 From acdk::io::DataWriter.

virtual void writeString (IN(RString) str)
 From acdk::io::DataWriter.

virtual void writeStringImpl (IN(RString) str)=0
virtual void writeScriptVar (acdk::lang::dmi::ScriptVar &sv, bool withTypeInfo=true, bool withFlags=true)
void writeStringElement (IN(RString) str)
void writeBooleanElement (bool b)
void writeCharElement (char b)
void writeUcCharElement (uc2char b)
void writeShortElement (short b)
void writeIntElement (int b)
void writeLongElement (jlong b)
void writeFloatElement (float b)
void writeDoubleElement (double b)
virtual void defaultWriteObject (IN(RClass) cls, IN(acdk::lang::Object) obj)
 if a class implements the writeObject method it can call defaultWriteObject for default object serialization This method only writes the acdk::lang::Object information (the fields) of this class

virtual void writeUnshared (IN(RClass) cls, IN(acdk::lang::Object) obj)
 write a class unshared without any back references to previous written objects

virtual void writeClassDescriptor (IN(RClass) cls, IN(acdk::lang::Object) obj)
 writes a class descriptor of current object.

virtual void writeObjectHierarchy (IN(RClass) cls, IN(acdk::lang::Object) obj)
void writeObject2 (IN(acdk::lang::Object) obj)
 used to write recursive objects

void writeObject2 (IN(RClass) cls, IN(acdk::lang::Object) obj)
 used to write recursive objects


Protected Member Functions

int _lookupStringRef (IN(RString) str)
 looks if a string with same content already written.

void _writeObject (IN(RClass) cls, IN(acdk::lang::Object) obj)

Private Attributes

int _serializeFlags
ObjectArray _lrefs
::acdk::util::RTreeMap _stringCache
 RString -> objectId;.

int _maxStringId


Constructor & Destructor Documentation

acdk::io::AbstractObjectWriter::AbstractObjectWriter IN(RWriter out,
int  flags = SerializeDefaultFlags
[inline]
 

Parameters:
out a storage writer, where to write the data
flags please refer to the Serialize* flags


Member Function Documentation

int acdk::io::AbstractObjectWriter::_lookupStringRef IN(RString str  )  [protected]
 

looks if a string with same content already written.

If found returns ID, otherwise -1

void acdk::io::AbstractObjectWriter::_writeObject IN(RClass cls,
IN(acdk::lang::Object obj
[protected]
 

virtual void acdk::io::AbstractObjectWriter::defaultWriteObject IN(RClass cls,
IN(acdk::lang::Object obj
[virtual]
 

if a class implements the writeObject method it can call defaultWriteObject for default object serialization This method only writes the acdk::lang::Object information (the fields) of this class

Implements acdk::io::ObjectWriter.

void acdk::io::AbstractObjectWriter::flush  )  [inline, virtual]
 

Reimplemented from acdk::io::AbstractFilterWriter.

RStorage acdk::io::AbstractObjectWriter::getStorage  )  [inline, virtual]
 

Gets the storage reader.

If this contains an FilterReader instead of a Storage, the storage reader of this filter reader will be returned (recursive).

Reimplemented from acdk::io::AbstractFilterWriter.

RWriter acdk::io::AbstractObjectWriter::getStorageWriter  )  [inline, virtual]
 

returns the unfiltered Writer

Reimplemented from acdk::io::AbstractFilterWriter.

bool acdk::io::AbstractObjectWriter::isLabeled  )  [inline]
 

bool acdk::io::AbstractObjectWriter::isNamed  )  [inline]
 

bool acdk::io::AbstractObjectWriter::isReduced  )  [inline]
 

bool acdk::io::AbstractObjectWriter::isTagged  )  [inline]
 

bool acdk::io::AbstractObjectWriter::joinStrings  )  [inline]
 

void acdk::io::AbstractObjectWriter::resetLocalRefs  )  [inline]
 

void acdk::io::AbstractObjectWriter::setOut IN(RWriter writer  )  [inline, virtual]
 

Reimplemented from acdk::io::AbstractFilterWriter.

bool acdk::io::AbstractObjectWriter::withSerialVersionUID  )  [inline]
 

virtual void acdk::io::AbstractObjectWriter::write IN(RbyteArray array,
int  offset = 0,
int  len = -1
[pure virtual]
 

From acdk::io::DataWriter.

In the concrete class, you have to implement these classes

Reimplemented from acdk::io::AbstractFilterWriter.

Implemented in acdk::io::BinaryObjectWriter, and acdk::xml::XMLObjectWriter.

void acdk::io::AbstractObjectWriter::write const byte cstr,
int  offset,
int  len
[inline, virtual]
 

Reimplemented from acdk::io::AbstractFilterWriter.

Reimplemented in acdk::io::BinaryObjectWriter.

void acdk::io::AbstractObjectWriter::write byte  b  )  [inline, virtual]
 

default implementation: byte cbuf[2]; cbuf[1] = 0; cbuf[0] = c; return write((const byte*)cbuf, 0, 1);

Reimplemented from acdk::io::AbstractFilterWriter.

Reimplemented in acdk::io::BinaryObjectWriter.

void acdk::io::AbstractObjectWriter::writeBooleanElement bool  b  )  [inline]
 

virtual void acdk::io::AbstractObjectWriter::writeChar char  b  )  [pure virtual]
 

From acdk::io::DataWriter.

In the concrete class, you have to implement these classes

Implements acdk::io::ObjectWriter.

Implemented in acdk::io::BinaryObjectWriter, and acdk::xml::XMLObjectWriter.

void acdk::io::AbstractObjectWriter::writeCharElement char  b  )  [inline]
 

virtual void acdk::io::AbstractObjectWriter::writeClassDescriptor IN(RClass cls,
IN(acdk::lang::Object obj
[virtual]
 

writes a class descriptor of current object.

This method will only be called once for the most derived class The main purpose of the class descriptor is to identify the class to enable restruction out of the stream

Implements acdk::io::ObjectWriter.

virtual void acdk::io::AbstractObjectWriter::writeClassId IN(::acdk::lang::RClass cls  )  [pure virtual]
 

Write boot-straping ID for the given, so the corresponding AbstractObjectReader::readClassId() can create an acdk::lang::Object instance.

if withSerialVersionUID() is true the SerialVersionUID should be written too.

Parameters:
cls may be Nil for writing a Nil object

Implemented in acdk::io::BinaryObjectWriter, and acdk::xml::XMLObjectWriter.

virtual void acdk::io::AbstractObjectWriter::writeDouble double  b  )  [pure virtual]
 

From acdk::io::DataWriter.

In the concrete class, you have to implement these classes

Implements acdk::io::ObjectWriter.

Implemented in acdk::io::BinaryObjectWriter, and acdk::xml::XMLObjectWriter.

void acdk::io::AbstractObjectWriter::writeDoubleElement double  b  )  [inline]
 

virtual void acdk::io::AbstractObjectWriter::writeFloat float  b  )  [pure virtual]
 

From acdk::io::DataWriter.

In the concrete class, you have to implement these classes

Implements acdk::io::ObjectWriter.

Implemented in acdk::io::BinaryObjectWriter, and acdk::xml::XMLObjectWriter.

void acdk::io::AbstractObjectWriter::writeFloatElement float  b  )  [inline]
 

virtual void acdk::io::AbstractObjectWriter::writeInt int  b  )  [pure virtual]
 

From acdk::io::DataWriter.

In the concrete class, you have to implement these classes

Implements acdk::io::ObjectWriter.

Implemented in acdk::io::BinaryObjectWriter, and acdk::xml::XMLObjectWriter.

void acdk::io::AbstractObjectWriter::writeIntElement int  b  )  [inline]
 

virtual void acdk::io::AbstractObjectWriter::writeLong jlong  b  )  [pure virtual]
 

From acdk::io::DataWriter.

In the concrete class, you have to implement these classes

Implements acdk::io::ObjectWriter.

Implemented in acdk::io::BinaryObjectWriter, and acdk::xml::XMLObjectWriter.

void acdk::io::AbstractObjectWriter::writeLongElement jlong  b  )  [inline]
 

virtual void acdk::io::AbstractObjectWriter::writeObject IN(RClass cls,
IN(acdk::lang::Object obj
[virtual]
 

This version writes an acdk::lang::Object to a Writer using the Class.

In normal case, thit version writes the data untagged (i.e. no meta info) into the writer.

Implements acdk::io::ObjectWriter.

virtual void acdk::io::AbstractObjectWriter::writeObject IN(acdk::lang::Object obj  )  [virtual]
 

This version write acdk::lang::Object to a Writer.

In normal case, it also write a description (tagged) of the Class (for ClassLoader) at the beginning.

Parameters:
obj the acdk::lang::Object to writer

Reimplemented from acdk::io::ObjectWriter.

Reimplemented in acdk::java::serialization::JavaObjectWriter.

void acdk::io::AbstractObjectWriter::writeObject2 IN(RClass cls,
IN(acdk::lang::Object obj
 

used to write recursive objects

void acdk::io::AbstractObjectWriter::writeObject2 IN(acdk::lang::Object obj  ) 
 

used to write recursive objects

virtual void acdk::io::AbstractObjectWriter::writeObjectHierarchy IN(RClass cls,
IN(acdk::lang::Object obj
[virtual]
 

virtual void acdk::io::AbstractObjectWriter::writeObjectLocalId int  id  )  [inline, virtual]
 

In case ObjectWriter should handle writing Objects which may have cyclic references, for each acdk::lang::Object a local reference id.

Recursive and duplicated elements will be written only one in the stream. If the implementing ObjectReader does not support local reference resolutions, it should throw NotSupportedException

virtual void acdk::io::AbstractObjectWriter::writeOpaque IN(RbyteArray array  )  [inline, virtual]
 

From acdk::io::DataWriter.

In the concrete class, you have to implement these classes

Reimplemented from acdk::io::DataWriter.

Reimplemented in acdk::xml::XMLObjectWriter.

virtual void acdk::io::AbstractObjectWriter::writeScriptVar acdk::lang::dmi::ScriptVar sv,
bool  withTypeInfo = true,
bool  withFlags = true
[virtual]
 

Parameters:
hasTypeInfo the the is encoded in the stream
withFlags writes also the flags

Reimplemented from acdk::io::ObjectWriter.

virtual void acdk::io::AbstractObjectWriter::writeShort short  b  )  [pure virtual]
 

From acdk::io::DataWriter.

In the concrete class, you have to implement these classes

Implements acdk::io::ObjectWriter.

Implemented in acdk::io::BinaryObjectWriter, and acdk::xml::XMLObjectWriter.

void acdk::io::AbstractObjectWriter::writeShortElement short  b  )  [inline]
 

virtual void acdk::io::AbstractObjectWriter::writeString IN(RString str  )  [virtual]
 

From acdk::io::DataWriter.

Classes derived from AbstractObjectWriter should overwrite writeStringImpl.

Implements acdk::io::ObjectWriter.

Reimplemented in acdk::java::serialization::JavaObjectWriter.

void acdk::io::AbstractObjectWriter::writeStringElement IN(RString str  )  [inline]
 

virtual void acdk::io::AbstractObjectWriter::writeStringImpl IN(RString str  )  [pure virtual]
 

Implemented in acdk::io::BinaryObjectWriter, and acdk::xml::XMLObjectWriter.

virtual void acdk::io::AbstractObjectWriter::writeTagEnd IN(RString key,
IN(RString value = Nil
[pure virtual]
 

Writes end of Tag.

This function will be written, to For example '' for a int type. This function will be called by writeObject if the object should be written with tags

Implemented in acdk::io::BinaryObjectWriter, and acdk::xml::XMLObjectWriter.

virtual void acdk::io::AbstractObjectWriter::writeTagStart IN(RString key,
IN(RString value = Nil
[pure virtual]
 

Writes start of Tag.

This function will be written, toIN( For example '' for a int type in a XML style writer. This function will be called by writeObject if the object should be written with tags

Implemented in acdk::io::BinaryObjectWriter, and acdk::xml::XMLObjectWriter.

virtual void acdk::io::AbstractObjectWriter::writeUcChar uc2char  b  )  [pure virtual]
 

From acdk::io::DataWriter.

In the concrete class, you have to implement these classes

Implements acdk::io::ObjectWriter.

Implemented in acdk::io::BinaryObjectWriter, and acdk::xml::XMLObjectWriter.

void acdk::io::AbstractObjectWriter::writeUcCharElement uc2char  b  )  [inline]
 

virtual void acdk::io::AbstractObjectWriter::writeUnshared IN(RClass cls,
IN(acdk::lang::Object obj
[virtual]
 

write a class unshared without any back references to previous written objects

Implements acdk::io::ObjectWriter.


Member Data Documentation

ObjectArray acdk::io::AbstractObjectWriter::_lrefs [private]
 

int acdk::io::AbstractObjectWriter::_maxStringId [private]
 

int acdk::io::AbstractObjectWriter::_serializeFlags [private]
 

::acdk::util::RTreeMap acdk::io::AbstractObjectWriter::_stringCache [private]
 

RString -> objectId;.