users@jaxb.java.net

Accessing JAXB mappings

From: Moravec Jan <Jan.Moravec_at_ips-ag.cz>
Date: Fri, 27 Aug 2004 08:42:05 +0200

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