XStream
  1. XStream
  2. XSTR-365

Multiple implicit collections with @XStreamImplicitCollection annotation

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.2
    • Component/s: None
    • Labels:
      None
    • JDK version and platform:
      1.5

      Description

      Hello,
      I was trying to map an XML file with multiple collections that must mapped as implicit collections.

      I would like to map them using Java 5 annotations, but at the class level I can use a single @XStreamImplicitCollection having a single String parameter for the collection. Don't know if I missed something, or if I'm using the wrong approach. Please let me know if I'm in the latter case.

      At present, for having things working, I modified XStreamImplicitCollection.java and Annotation.java sources for having an array of parameters. So I can map multiple collection writing the following code:

      @XStreamAlias("Widget")
      @XStreamImplicitCollection(

      {"properties", "containers"}

      )
      public class Widget {
      private String Name;
      private List<Property> properties = new ArrayList<Property>();
      private List<Container> containers = new ArrayList<Container>();
      }

      I attached the modified sources and the diff file. Hope this can help.

      1. annotations.diff
        1 kB
        Lucio Benfante
      2. Annotations.java
        9 kB
        Lucio Benfante
      3. Annotations.java
        8 kB
        Lucio Benfante
      4. implicit_collections.diff
        3 kB
        Lucio Benfante
      5. ImplicitCollectionTest.java
        2 kB
        Lucio Benfante
      6. XStreamImplicit.java
        0.6 kB
        Lucio Benfante
      7. XStreamImplicitCollection.java
        0.4 kB
        Lucio Benfante

        People

        • Assignee:
          Unassigned
          Reporter:
          Lucio Benfante
        • Votes:
          0 Vote for this issue
          Watchers:
          1 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: