Details
-
Type: Bug
-
Status: Closed
-
Priority: 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)
public String toString(Object arg0)
{ return String.valueOf(((Character)arg0)); }public boolean canConvert(Class arg0)
{ return (Character.class.isAssignableFrom(arg0)); }});
Fixed in head revision.