History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XSTR-421
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Jakub Neubauer
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XStream

char cannot be serialized as attribute

Created: 29/Aug/07 03:00 AM   Updated: 25/Feb/08 05:01 PM
Component/s: Converters
Affects Version/s: 1.2.2
Fix Version/s: 1.3

JDK version and platform: Sun Java 1.5.0_04


 Description  « Hide
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));
}
});


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Joerg Schaible - 24/Sep/07 02:53 PM
Fixed in head revision.

Joerg Schaible - 25/Feb/08 05:01 PM
Closing issues before next release.