[Simple-support] Serializing a tree of custon objects
Brought to you by:
niallg
|
From: <cw...@cs...> - 2013-04-29 16:49:12
|
All-
I have an acyclic tree of custom objects that I need to serialize in a
custom manner ('custom' for data access patterns -- I don't need or want
to reconstruct the entire object, just certain aspects of each).
These objects form an logical boolean expression to be evaluated later --
non-leaf nodes define the logical operator, while leaf-nodes provide the
particular operands.
I'm amenable to two serialization models --
a) Enumerate (and uniquely identify) all leaves of the object tree, and
build a section in the XML file that represents this library. The
expression can be stored, with operators, as an element of another XML
node.
b) Traverse the tree, building a hierarchy that more closely represents
the objects' relationships.
I've found RegistryStrategy allows me to hook into the marshalling stream
with useful Converters. This pattern gets me "access" to the root of the
tree, but it's not clear from the tutorial ([1]) how to then traverse into
the tree, and allows other objects in my dataset to be marshalled
effectively.
The TreeStrategy, would, at first blush, seem to be more appropriate as I
have a tree of objects... lacking a brief example, it's tough to know this
with certainty. I assume I'd need to subclass this to be more contextual?
Can strategies be combined? I see that some of the defined Strategy
classes accept nesting of Strategies via constructor parameter, but not
all. Specifically, the TreeStrategy does not.
Thoughts on how to achieve a custom serialization?
Thanks!
CH
[1] http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php
|