All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.roguewave.vsj.CollectableStreamer

java.lang.Object
   |
   +----com.roguewave.vsj.CollectableStreamer

public class CollectableStreamer
extends Object
implements ObjectStreamer
Class CollectableStreamer is an ObjectStreamer for mapping Java classes to C++ subclasses of class RWCollectable from Tools.h++. These classes are marked "Polymorphic" in the Persistence Section of the Tools.h++ Class Reference and include any user-defined classes that are made persistent by use of the Tools.h++ RWDEFINE_COLLECTABLE macro.

The code in this class corresponds to the "behind the scenes" code in Tools.h++ from class RWCollectable and generated automatically through the use of the RWDEFINE_COLLECTABLE macro. In particular, this code is responsible for preceding the object with a class ID. This allows for the streaming of an object without the need to know its exact class at the time the object is being written or read. In addition, these methods take care of of reading and writing back-references---for objects that are encountered mulitple times---in order to maintain the shape of a graph of objects, as well as allow for circular references.

Before using a CollectableStreamer you must register one or more classes that implement the DefineCollectable interface. The DefineCollectable interface contains methods roughly corresponding to the saveGuts and restoreGuts functions that one must define for a particular class when using the RWDEFINE_COLLECTABLE macro. You must register a DefineCollectable for every particular class that may be encountered by the CollectableStreamer when reading or writing a graph of objects.

See Also:
DefineCollectable

Variable Index

 o classIdToDefcoll_
Maps C++ classIds to DefineCollectables
 o dupStrIdMarker
Announces a back-reference to a stringId:
 o javaClassToDefcoll_
Maps Java Class objects to DefineCollectables
 o strIdMarker
Announces a stringId:
 o stringIdToDefcoll_
Maps C++ stringIds to DefineCollectables

Constructor Index

 o CollectableStreamer()

Method Index

 o getDefineCollectable(Class)
Return the registered DefineCollectable corresponding to the given Java Class object.
 o register(DefineCollectable)
Use the register method to prepare this CollectableStreamer to save and restore objects associated with a particular Tools.h++ class ID.
 o restore(VirtualInputStream)
Read an object, or graph of objects, written using the same class ID and back-referencing protocol used by the code in the Tools.h++ RWCollectable class and RWDEFINE_COLLECTABLE macro.
 o save(Object, VirtualOutputStream)
Write an object, or graph of objects, written using the same class ID and back-referencing protocol used by the code in the Tools.h++ RWCollectable class and RWDEFINE_COLLECTABLE macro.

Variables

 o classIdToDefcoll_
 protected Hashtable classIdToDefcoll_
Maps C++ classIds to DefineCollectables

 o stringIdToDefcoll_
 protected Hashtable stringIdToDefcoll_
Maps C++ stringIds to DefineCollectables

 o javaClassToDefcoll_
 protected Hashtable javaClassToDefcoll_
Maps Java Class objects to DefineCollectables

 o strIdMarker
 protected static final int strIdMarker
Announces a stringId:

 o dupStrIdMarker
 protected static final int dupStrIdMarker
Announces a back-reference to a stringId:

Constructors

 o CollectableStreamer
 public CollectableStreamer()

Methods

 o restore
 public Object restore(VirtualInputStream vstr) throws IOException
Read an object, or graph of objects, written using the same class ID and back-referencing protocol used by the code in the Tools.h++ RWCollectable class and RWDEFINE_COLLECTABLE macro.

For each class ID read from the stream, a corresponding implementation of the DefineCollectable interface must have been registered with this CollectableStreamer.

See Also:
DefineCollectable
 o save
 public void save(Object obj,
                  VirtualOutputStream vstr) throws IOException
Write an object, or graph of objects, written using the same class ID and back-referencing protocol used by the code in the Tools.h++ RWCollectable class and RWDEFINE_COLLECTABLE macro.

For each Java class written to the stream, a corresponding implementation of the DefineCollectable interface must have been registered with this CollectableStreamer.

 o register
 public void register(DefineCollectable collstr)
Use the register method to prepare this CollectableStreamer to save and restore objects associated with a particular Tools.h++ class ID. By supplying an implementation of the DefineCollectable interface you effectively map a Tools.h++ class ID to a Java class. Before saving or restoring an object, or graph of objects, each different type of object that may be encountered must have a corresponding DefineCollectable registered with this CollectableStreamer.

 o getDefineCollectable
 public DefineCollectable getDefineCollectable(Class aClass)
Return the registered DefineCollectable corresponding to the given Java Class object.


All Packages  Class Hierarchy  This Package  Previous  Next  Index