views:

270

answers:

1

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that are stored in the collection (primarily their IDs, and not the remaining contents of each element).

Anyone have an idea of how I might go about this?

Thanks

+2  A: 

You can either specify that all the collection element fields except for ID should not be serialized by either:

  1. Declaring them transient
  2. Annotation them with @XStreamOmitField
  3. Calling xstream.omitField()

Or you can write your own converter.

ChssPly76
writing your own converter is actually pretty simple, so don't overlook that option if for some reason the others ones aren't feasible for you.
matt b