users@jaxb.java.net

RE: Accessing JAXB mappings

From: Moravec Jan <Jan.Moravec_at_ips-ag.cz>
Date: Fri, 27 Aug 2004 16:30:52 +0200

Did not know about JXPATH. It looks pretty good, however, I think I still need to extract the mapping info from JAXB context somehow. Why? Because JXPATH has no clue about what method mapping JAXB is using. Eg.

For XPath:

/address_book/entry[1]/general/first_name

JXPATH will attempt to perform:

getAddress_book().getEntry().get(0).getGeneral().setFirst_name(...)

But I would need:

getAddressBook().getEntry().get( 0 ).getGeneral().setFirstName( 'Jan' )

because that's the mapping JAXB generates. To make things more difficult, JAXB allows one to customize the mapping using a property file. So in the end to access the contents of the address_book element you may end up using a method named getFoo() etc.

Thanks for the JXPATH pointer it will definitely save me from writing the reflection stuff.

Cheers,
Jan Moravec


>
> I need to be able to perform something like:
>
> getAddressBook().getEntry().get( 0 ).getGeneral().setFirstName( 'Jan' )



Thanks for the pointer anyway, it will definitelly save me from writing the reflection stuff.



-----Original Message-----
From: dev_at_samizdatdigital.org [mailto:dev_at_samizdatdigital.org]
Sent: Friday, August 27, 2004 4:07 PM
To: users_at_jaxb.dev.java.net
Subject: Re: Accessing JAXB mappings


have you considered jxpath?

jon

On Aug 26, 2004, at 11:42 PM, Moravec Jan wrote:

> Hello,
>
> Is it possible to access JAXB element name to method name mapping at
> runtime? What I would like to achieve is to set/get a particular value
> in the content tree using Java reflection and XPath.
>
> For example,
>
> To set a value of a content tree element identified with an XPath that
> looks like
>
> /address_book/entry[1]/general/first_name
>
> I need to be able to perform something like:
>
> getAddressBook().getEntry().get( 0 ).getGeneral().setFirstName( 'Jan' )
>
> For this to happen I need to find out what method/type each of the
> XPath elements maps onto. I would expect it would be accessible
> through the JAXBContext, but it does not seem to be the case.
>
> In the worst case I could derive the method names by stripping '_'
> from XPath element names and converting first letters to capitals, but
> that would be a hack as the setter/getter method names can be
> customized using a property file anyway (never tried, but glimsed an
> example somewhere).
>
> Thanks a lot,
> Jan Moravec
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net