Well, that's only the way it works in the generated code. If you're just
doing your own binding to existing code, JiBX uses the enum valueOf()
method by default, which also throws an exception if the supplied value
doesn't match:
http://download.oracle.com/javase/1,5.0/docs/api/java/lang/Enum.html#valueOf%28java.lang.Class,%20java.lang.String%29
To get around this, just create your own deserializer method and
reference that in the binding. You can then either call the standard
valueOf() method and catch the exception, just returning an empty
string, or do your own conversion.
- Dennis
Dennis M. Sosnoski
Java SOA and Web Services Consulting <http://www.sosnoski.com/consult.html>
Axis2/CXF/Metro SOA and Web Services Training
<http://www.sosnoski.com/training.html>
Web Services Jump-Start <http://www.sosnoski.com/jumpstart.html>
On 09/30/2011 04:54 PM, Steel City Phantom wrote:
beautiful, so its the enumeration itself generating the exception not
jibx. thats beautiful, i can handle that.
and as a rule i never use code generators. i do everything by hand.
i don't like losing that control
On Thu, Sep 29, 2011 at 5:21 AM, Dennis Sosnoski <d...@sosnoski.com
<mailto:d...@sosnoski.com>> wrote:
If you're generating code from schema there's no way to handle
this automatically, but you could modify the generated binding.
You should have two static conversion methods defined in your
generated enumeration class, convert(String) and
fromValue(String). The exception is being thrown by the
fromValue() method, which is used by the binding. If you instead
use the convert() method it'll just return a null if the value is
not found, which should do what you want.
- Dennis
Dennis M. Sosnoski
Java SOA and Web Services Consulting
<http://www.sosnoski.com/consult.html>
Axis2/CXF/Metro SOA and Web Services Training
<http://www.sosnoski.com/training.html>
Web Services Jump-Start <http://www.sosnoski.com/jumpstart.html>
On 09/24/2011 02:52 AM, Steel City Phantom wrote:
ive got a schema that is going to a pojo as enumerations and
groups. keeping code synced between 43 applications is getting
to be a pain real quick,
is there a way where i can tell jibx if an enumeration value is
in the XML but not in the enumerations class so simply ignore it
instead of throwing a parse error?
--
You want it fast, cheap, or right. Pick two!!
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net <mailto:jibx-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/jibx-users
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and
makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
<mailto:jibx-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/jibx-users
--
You want it fast, cheap, or right. Pick two!!
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users