XStream
  1. XStream
  2. XSTR-192

Implicit Collections are not symmetric in inheritance heirarchy

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1.1
    • Component/s: None
    • Labels:
      None

      Description

      – From Walt Dixon –

      Lets say I have an XML document:

      <outer>
      <inner id="1"/>
      ...
      <inner id="n"/>
      </outer>

      That has an underlying class structure like:

      public class Node {
      private String id;
      private Node parent;
      private ArrayList children = new ArrayList();
      ...
      }

      public class Outer extends Node {
      ...
      }

      public class Inner extends Node {
      ...
      }

      With the following aliases - and the implicit
      collection directive - the xml file unmarshalls
      fine

      xs.alias("outer", Outer.class);
      xs.alias("inner", Inner.class);
      xs.addImplicitCollection(Outer.class, "children");

      However, marshalling the objects back to XML produces
      asymmetric results. (i.e. the collection is now explicit)

      <outer>
      <children>
      <inner id="1"/>
      ...
      <inner id="n"/>
      </children>
      </outer>

      I did however find that by adding an implicit collection
      to Node - it marshaled properly?

      xs.addImplicitCollection(Node.class, "children");

      Is this intentional - it seems a bit asymmetric?

      With the xs.addImplicitCollection(Outer.class, "children")
      The children aren't unmarshalled correctly

      And without the
      xs.addImplicitCollection(Node.class, "children");
      The children aren't marshalled correctly.

        People

        • Assignee:
          Unassigned
          Reporter:
          Joe Walnes
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: