XStream
  1. XStream
  2. XSTR-645

Annotation @XStreamOmitField has no effect

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Not A Bug
    • Affects Version/s: 1.3.1
    • Fix Version/s: None
    • Component/s: Annotations
    • Labels:
      None
    • JDK version and platform:
      1.6.0_23 for Windows

      Description

      This is the class to be serialized with XStream:

      import com.thoughtworks.xstream.annotations.XStreamOmitField;

      public class XStreamTestObject

      { int shouldNotBeOmitted = 1; @XStreamOmitField int shouldBeOmitted = 2; }

      The @XStreamOmitField has no effect. Using XStream.omitField() does the job as required. This is the class that calls the serialization

      import com.thoughtworks.xstream.XStream;

      public class XStreamTestMain {

      public static void main(String[] args)

      { XStream xs = new XStream(); System.out.println("using annotation-------------------------"); System.out.println(xs.toXML(new XStreamTestObject())); xs.omitField(XStreamTestObject.class, "shouldBeOmitted"); System.out.println("using omitField()------------------------"); System.out.println(xs.toXML(new XStreamTestObject())); }

      }

      And this is the output:
      using annotation-------------------------
      <XStreamTestObject>
      <shouldNotBeOmitted>1</shouldNotBeOmitted>
      <shouldBeOmitted>2</shouldBeOmitted>
      </XStreamTestObject>
      using omitField()------------------------
      <XStreamTestObject>
      <shouldNotBeOmitted>1</shouldNotBeOmitted>
      </XStreamTestObject>

      1. XStreamTestMain.java
        0.5 kB
        Klaus Hammer
      2. XStreamTestObject.java
        0.2 kB
        Klaus Hammer

        People

        • Assignee:
          Jörg Schaible
          Reporter:
          Klaus Hammer
        • Votes:
          0 Vote for this issue
          Watchers:
          1 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: