Re: [Simple-support] using mapping files with Simple XML
Brought to you by:
niallg
|
From: Alexey S. <al...@gm...> - 2011-02-18 23:19:23
|
Thanks to both Aaron and Niall for the detailed answers.
Looks like I have to ignore Android platform then and stick with old Castor
XML, which works OK for "real" Java.
On Fri, Feb 18, 2011 at 2:29 AM, Aaron Digulla <di...@he...> wrote:
> Zitat von Niall Gallagher <gal...@ya...>:
>
> > Hi,
> > There are some options in such cases, for instance you can write
> > your own Converter to perform mappings on specific objects. Another
> > is to accept both like so.
> > @Attribute(required=false)private String name;
> > @Attribute(required=false)private String login;
> > @Validateprivate void commit() throws Exception { if(name != null)
> > { setUserName(name); } else if(login != null) {
> > setUserName(login); }}
>
> His question was: "How can I achieve this *without* annotations?"
>
> Alexey, Simple-XML builds an internal data structure from the
> annotations. Unfortunately, all the code is package private and Niall
> doesn't use factories which you can override (for example
> ScannerFactory is created with new inside the constructor of Support).
>
> That means Simple XML is useless if you can't annotate your classes
> and you're not willing to patch the sources.
>
> Regards,
>
>
> >
> > --- On Thu, 17/2/11, Alexey Skor <al...@gm...> wrote:
> >
> > From: Alexey Skor <al...@gm...>
> > Subject: [Simple-support] using mapping files with Simple XML
> > To: sim...@li...
> > Received: Thursday, 17 February, 2011, 4:13 PM
> >
> > Hi!
> > I'm working on a Java API for Redmine's REST service (www.redmine.org).
> >
> > One of the users has recently submitted a bug that my API does not
> > work under Android OS:
> > https://code.google.com/p/redmine-java-api/issues/detail?id=17
> >
> >
> > I'm using Castor XML now, but unfortunately it does not work
> > under Android so I'm looking for some other solution...I'd like to
> > give SimpleXML a try, but don't want to add SimpleXML-specific
> > annotations to my objects. moreover having annotations is not
> > flexible - unfortunately, objects can be provided by the server in
> > different xml formats depending on how exactly I requested them.
> > so, in one case "user name" can be stored in "name" attribute, and
> > in another XML response from the REST service the same "user name"
> > can be provided in "login" attribute.
> >
> > the way I deal with this in Castor XML is I use different XML
> > mapping files for different requests/responses. e.g. one XML mapping
> > file for getting "users list" and and another mapping for getting
> > "project and its user/owner info".
> >
> >
> > any advice?
> > --
> > Alex
> >
> > -----Inline Attachment Follows-----
> >
> >
> ------------------------------------------------------------------------------
> > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> > Pinpoint memory and threading errors before they happen.
> > Find and fix more than 250 security defects in the development cycle.
> > Locate bottlenecks in serial and parallel code that limit performance.
> > http://p.sf.net/sfu/intel-dev2devfeb
> > -----Inline Attachment Follows-----
> >
> > _______________________________________________
> > Simple-support mailing list
> > Sim...@li...
> > https://lists.sourceforge.net/lists/listinfo/simple-support
> >
> >
> >
> >
>
>
>
> --
> Aaron "Optimizer" Digulla a.k.a. Philmann Dark
> "It's not the universe that's limited, it's our imagination.
> Follow me and I'll show you something beyond the limits."
> http://www.pdark.de/ http://blog.pdark.de/
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
--
Alex
|