Re: [Simple-support] Supporting different root elements
Brought to you by:
niallg
|
From: Jarrod S. <ja...@co...> - 2011-11-06 06:23:55
|
Oops, meant to post that to the list for the future reference of others...
On Sun, Nov 6, 2011 at 5:21 PM, Jarrod Smith <ja...@co...> wrote:
> Thanks for the help Niall, I ended up with this:
>
> public class RootNodeVisitor implements Visitor
> {
> @Override
> public void read(Type arg0, NodeMap<InputNode> arg1) throws Exception
> {
> }
>
> @Override
> public void write(Type type, NodeMap<OutputNode> node) throws Exception
> {
> OutputNode element = node.getNode();
> if (element.isRoot())
> {
> element.setAttribute("error", element.getName()); // Root element
> is either <OK> or <FAIL>.
> }
> }
> }
>
> And modifying the class to support an error attribute:
>
> @Root(strict=false)
> public class MyResponse
> {
> @Attribute
> String error;
>
> ...
>
> On Thu, Nov 3, 2011 at 6:37 PM, Niall Gallagher
> <gal...@ya...> wrote:
>>
>> It sould be possible to do this with a custom strategy implementation. With this you can return the type meta data. Check out the examples in the test cases
>>
>> Sent from Yahoo!7 Mail on Android
>
>>> Thanks Niall,
>>> But I need to be able to tell if the root element is <OK> or <FAIL>. Is this possible?
|