XStream
  1. XStream
  2. XSTR-481

@XStreamConverter hides @XStreamAsAttribute annotation, it seems.

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.3.1
    • Component/s: Annotations
    • Labels:
      None

      Description

      If one is using the @XStreamConverter annotation on a field, XStream seems to ignore @XStreamAsAttribute altogether, and only reacts to an element, not an attribute.

        Issue Links

          Activity

          Hide
          Jörg Schaible added a comment -

          No wonder, you have to provide a SingleValueConverter to ba able to render a value as attribute. However, this was not possible at all with @XStreamConverter in version 1.3. Next version provides this functionality though.

          Show
          Jörg Schaible added a comment - No wonder, you have to provide a SingleValueConverter to ba able to render a value as attribute. However, this was not possible at all with @XStreamConverter in version 1.3. Next version provides this functionality though.
          Hide
          Jörg Schaible added a comment -

          Works in head revision.

          Show
          Jörg Schaible added a comment - Works in head revision.
          Hide
          Jörg Schaible added a comment -

          Set correct fix version.

          Show
          Jörg Schaible added a comment - Set correct fix version.
          Hide
          Jörg Schaible added a comment -

          Fixed for upcoming release.

          Show
          Jörg Schaible added a comment - Fixed for upcoming release.
          Hide
          Jeff Simpson added a comment -

          I'm not seeing the fix.

          I've got the following sequence of annotations:
          @XStreamAlias("dt")
          @XStreamAsAttribute
          @XStreamConverter(SingleValueCalendarConverter.class)
          public Calendar _creationTime = Calendar.getInstance();

          And I'm seeing the correct conversion of the date using the converter, but it's appearing as a child element instead of an attribute.

          Is there something else I'm missing?

          I'm using the snapshot jar off a trunk build from today (3/26/2009).

          Show
          Jeff Simpson added a comment - I'm not seeing the fix. I've got the following sequence of annotations: @XStreamAlias("dt") @XStreamAsAttribute @XStreamConverter(SingleValueCalendarConverter.class) public Calendar _creationTime = Calendar.getInstance(); And I'm seeing the correct conversion of the date using the converter, but it's appearing as a child element instead of an attribute. Is there something else I'm missing? I'm using the snapshot jar off a trunk build from today (3/26/2009).
          Hide
          Jeff Simpson added a comment -

          Follow up.

          I happen to need an ISO8601 date so I was able to use:

          @XStreamConverter(ISO8601GregorianCalendarConverter.class)

          and see this appear as an attribute. It may turn out the server I'm talking to uses a variant of ISO8601 (i.e. bogus) and I'll need to use a custom format. So I'm still curious about this issue.

          Show
          Jeff Simpson added a comment - Follow up. I happen to need an ISO8601 date so I was able to use: @XStreamConverter(ISO8601GregorianCalendarConverter.class) and see this appear as an attribute. It may turn out the server I'm talking to uses a variant of ISO8601 (i.e. bogus) and I'll need to use a custom format. So I'm still curious about this issue.
          Hide
          Jeff Simpson added a comment -

          Ok, I figure out my problem. I was using an example to base my converter on which implemented the Converter interface.

          I changed my converter to extend AbstractSingleValueConverter and changed the marshal and unmarshal methods to toString and fromString respectively and it is appearing correctly as an attribute with my custom format.

          Show
          Jeff Simpson added a comment - Ok, I figure out my problem. I was using an example to base my converter on which implemented the Converter interface. I changed my converter to extend AbstractSingleValueConverter and changed the marshal and unmarshal methods to toString and fromString respectively and it is appearing correctly as an attribute with my custom format.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: