Re: [Simple-support] Parsing an XML containing Java keyword
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2012-07-02 08:28:39
|
I am not sure what your trying to do here, but what you should do is implement your own EnumTransform and plug it in to the Persister using a Matcher.
--- On Fri, 29/6/12, Mishra, Deepak <c_d...@qu...> wrote:
From: Mishra, Deepak <c_d...@qu...>
Subject: [Simple-support] Parsing an XML containing Java keyword
To: "sim...@li..." <sim...@li...>
Received: Friday, 29 June, 2012, 3:49 AM
#yiv897925473 P {margin-top:0;margin-bottom:0;}
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
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|