XStream converting issue (different subclasses in the same list)

Swampy101

New Member
I am only interested in de-serialization. I have some data that looks like this:\[code\] <Data> <Class name='ClassA'> <Object name='ObjectA'> <Relation name='RelationA'> <toObject name='ObjectB'> <toObject name='ObjectC'> </Relation> </Object> <Object name='ObjectB'> <Relation name='RelationB'> <toObject name='ObjectA'> <toObject name='ObjectC'> </Relation> </Object> </Class> <Class name='ClassB'> <Object name='ObjectC'> <Relation name='RelationC'> <toObject name='ObjectB'> </Relation> </Object> <NotUsedRelations> <Relation name='RelationD'> <toObject name='ObjectA'> </Relation> </NotUsedRelations> </Class> </Data> \[/code\]I would like to use Xstream to read it but I am having problems with NotUsedRelations element:\[code\] stream.alias("Data", Model.class); stream.alias("Class", Model.XMLClass.class); stream.alias("Object", Model.XMLObject.class); stream.alias("Relation", Model.XMLRelation.class); stream.alias("toObject", Model.XMLObject.class);\[/code\]Every type in Model extends from an XMLElement abstract class which defines a constructor with Name. Then they all have a \[code\] List<XMLElement> subElements;\[/code\]private var, and his getters/setters.The problem is that Class contains Object subelements as well as an implicit collection of NotUsedRelations, but Relations and Objects are both extending XMLElement, so I would like to put them together in the subElements listI tried different things with stream.addImplicitCollection() and stream.aliasField() but the compiler always complainsA problem is that one type is an implicit collection and the other not, but NotUsedRelations have no real maped class, should be defined as an alias for an implicit collection alone.Thanks in advance for any help!
 
Back
Top