XStream

char cannot be serialized as attribute

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.2.2
  • Fix Version/s: 1.3
  • Component/s: Converters
  • Labels:
    None
  • JDK version and platform:
    Sun Java 1.5.0_04

Description

I would like to serialize 'char' field as xml attribute. I used the following (pseudo)code:

class A {
char x;
}
XStream xstr = new XStream();
xstr.useAttributeFor(A.class, "x");
System.out.println(xstr.toXML(new A()));

But no success. The workaround was to define my own Converter, with which it worked.
I expected that such a thing should be defined by default.

xstr.registerConverter(new SingleValueConverter(){
public Object fromString(String arg0) { return arg0.charAt(0); }
public String toString(Object arg0) { return String.valueOf(((Character)arg0)); }
public boolean canConvert(Class arg0) { return (Character.class.isAssignableFrom(arg0)); }
});

Activity

Hide
Joerg Schaible added a comment -

Fixed in head revision.

Show
Joerg Schaible added a comment - Fixed in head revision.
Hide
Joerg Schaible added a comment -

Closing issues before next release.

Show
Joerg Schaible added a comment - Closing issues before next release.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: