Re: [Simple-support] Boolean Attribute 0 or 1
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2011-10-10 08:01:50
|
For primitives like boolean you must use a Transform not a Converter
________________________________
From: jc.jourdon <jc....@7g...>
To: sim...@li...
Sent: Friday, 30 September 2011 10:47 AM
Subject: [Simple-support] Boolean Attribute 0 or 1
hello,
you've done a great job with this tool and i already parsed many
different XML from soap servers since last 3 days, but i encountered
boolean attributes with "0" or "1"
<list mybool1="0" mybool2="1" attr1="attr" attr2="attr">
<page mybool3="1">
...
</page>
<page mybool3="0">
...
</page>
...
</list>
I tried to create this class :
public class Boolean01Converter implements Converter<Boolean>
{
@Override
public Boolean read(InputNode node) throws Exception {
return new Boolean(node.getValue().equals("1"));
}
@Override
public void write(OutputNode node, Boolean value) throws Exception {
node.setValue(value.booleanValue()?"1":"0");
}
}
and implemented it on my object definition :
@Root(name="list")
public class ListFcts
{
@Attribute
@Convert(Boolean01Converter.class)
private Boolean mybool1;
@Attribute
@Convert(Boolean01Converter.class)
private Boolean mybool2;
@Attribute
private int ...
@ElementList(name="page", inline=true)
private List<Page> pages;
}
But i still get false for every boolean.
Also : how can I attach the converter to the Persister instead of
declaring it on @Attributes hundred times ?
Many thanks in advance !!
------------------------------------------------------------------------------
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
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support |