[Simple-support] Boolean Attribute 0 or 1
Brought to you by:
niallg
|
From: jc.jourdon <jc....@7g...> - 2011-09-30 10:15:40
|
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 !!
|