users@jaxb.java.net

Re: how to get the annotations with the methods in stead of with the fields?

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Thu, 26 Nov 2009 16:51:46 +0100

On Thu, Nov 26, 2009 at 4:21 PM, xtien <christine_at_christine.nl> wrote:

>
>
>
> Wolfgang Laun-2 wrote:
> >
> > On Thu, Nov 26, 2009 at 2:34 PM, xtien <christine_at_christine.nl> wrote:
> >>
> >> The Jaxb Eclipse plugin generates @XmlElement annotations with the field
> >> names. In my app, it would be more convenient to have the annotations
> >> with
> >> the getter.
> >
> > Why? Perhaps you post what you want to achieve.
> >
>
> Does it matter?
>

There might be another way of getting what you want, from the XmlElement
annotation.

In my code at some point I have a getter method. The code invokes the method
> on a class. With this invocation, the code needs the name of the element
> that's in the information from the XmlElement. If the naming of methods and
> fields were standard, I could simply get the annotation from the field by
> creating the field name from the getter name and get the fields annotation.
>

The JAXB plugin just uses xjc to generate classes from an XML schema, and
this
produces, for a field called fooBar, a getter getFooBar (or isFooBar for
boolean).
Weird names *might* muddle the issue, but basically it's quite simple.


> However, the classes are genereated based on xml from a system that does
> not
> conform to standard field names. I am not in control of that system. It's
> hard to create a field name from a getter name, so that's why it would be
> convenient to have the annotation with the getter.
> Actually, all I want to do is retrieve the original element name in a piece
> of code where I have the getter method but not the field that it goes with.
>
>
Anyway, assuming you get the @XmlElement annotation, what's in there that
is so desirable to have in an application? (I admit, I'm *very* curious ;-)

-W



> --
> View this message in context:
> http://old.nabble.com/how-to-get-the-annotations-with-the-methods-in-stead-of-with-the-fields--tp26529506p26530937.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>