[Simple-support] Converter not being called for Attributes (2.7)
Brought to you by:
niallg
|
From: Farago, T. <tam...@cr...> - 2013-07-01 07:45:49
|
Hi,
Using Simpl 2.7 I have added several converters through the
RegistryStrategy to convert enum values from their XML value to the
value we are using in the project. However the converter is not being
called for attributes.
For example:
@Root(name = "TEST")
public class TestView {
@Element public MyEnumType enum1;
@Element public OtherTestView subclass;
@Attribute public MyEnumType enum3;
}
public class OtherTestView {
@Attribute public MyEnumType enum2;
}
public enum MyEnumType {
Continuous("CONTINUOUS");
public final String val;
MyEnumType(String val) {this.val = val;}
}
My converter simply loops over all the enum values and returns the one
that matches 'val'.
The generated XML is as follows; you can see it correctly works for
enum1, which is the converted value, but not for the other two
@Attribute annotated values. The same goes for deserializing, it simply
fails because it cannot find the value.
<TEST enum3="Continuous">
<enum1>CONTINUOUS</enum1>
<subclass enum2="Continuous"/>
</TEST>
Am I missing something, or is this simply not supported? I can get
conversion to work by implementing the Transform class for MyEnumType,
but I find it very strange I have to go through that route.
Cheers,
Tomi
===============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
===============================================================================
|