
| Key: |
XSTR-421
|
| Type: |
Bug
|
| Status: |
Closed
|
| Resolution: |
Fixed
|
| Priority: |
Minor
|
| Assignee: |
Unassigned
|
| Reporter: |
Jakub Neubauer
|
| Votes: |
0
|
| Watchers: |
0
|
|
If you were logged in you would be able to see more operations.
|
|
|
XStream
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
|
|
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));
}
});
|
|
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));
}
});
|
Show » |
|