[Simple-support] Parsing an XML containing Java keyword
Brought to you by:
niallg
|
From: Mishra, D. <c_d...@qu...> - 2012-06-29 11:24:43
|
Hi,
We are working on an Android project which consumes some web-services not in our control. These web-services respond with an XML, with text value as "new". Example :
<myEnum>new</myEnum>
As per the XSD, we need a Java enum to code for this.
public enum MyEnum {
@Element(name="new")
new("new"), // but we can't use 'new' here as it's a Java keyword
old("old");
}
SimpleXml seems to use valueOf() - which we can't overrride and hence we are unable to proceed. Please suggest some alternatives. I got this working after changing SimpleXml source code, but this is not acceptable to my team !
PS : The exception if it helps (when I use NEW instead of new)
java.lang.IllegalArgumentException: No enum const class pojos2.MyEnum.new
at java.lang.Enum.valueOf(Unknown Source)
at org.simpleframework.xml.transform.EnumTransform.read(EnumTransform.java:58)
Thanks,
Deepak
|