refactor approach to serialization

Description

The current ItemSerializer interface actually serialises a collection of items; the DOMElementSerializer implementation ignores all but the first of those.

It would be better for ItemSerializer to only serialise a single Item<T> and leave the orchestration (or not) of the Collection to the calling stage.

Both establishing and flushing/closing the OutputStream should be left to the caller; at present, the DOMElementSerializer closes the stream passed in even though it does not open it in the first place.

These changes will allow more reusability of ItemSerializer instances, for example in contexts such as MDA-76.

Environment

None

Activity

Show:

Ian Young December 22, 2015 at 6:01 PM

Closed on release 0.9.0.

Ian Young March 25, 2015 at 11:26 AM

Rev. 400 addresses this in full:

Added ItemCollectionSerializer interface.
SerializationStage now takes an ItemCollectionSerializer rather than iterating over the collection itself.
Added a SimpleItemCollectionSerializer which just iterates.
Extended DOMElementSerializer to implement both interfaces, just serializing the first item in a collection.

Ian Young March 25, 2015 at 9:53 AM

Reopening to introduce the ItemCollectionSerializer abstraction as described in the first comment.

Ian Young May 31, 2014 at 1:36 PM

Done, rev 370.

Ian Young March 8, 2014 at 1:23 PM

More musing: may make sense to establish both an ItemSerializer for single items and an ItemCollectionSerializer operating on a collection. It's not necessary for DOM, because you want to do the combination of items into a single one in a separate stage, but the distinction might make more sense for things like JSON output.

Fixed

Details

Assignee

Reporter

Fix versions

Affects versions

Created March 7, 2014 at 6:16 PM
Updated December 22, 2015 at 6:01 PM
Resolved March 25, 2015 at 11:26 AM

Flag notifications