users@jaxb.java.net

Re: Observation regarding jax2b reflection API

From: Kohsuke Kawaguchi <kohsuke.kawaguchi_at_sun.com>
Date: Fri, 03 Feb 2006 09:52:34 -0800

I hope you don't mind my CC-ing this e-mail to JAXB users list. That's
where we'd like discussions like this to happen.

Kishore G wrote:
> I am Kishore G from India. I have been using the reflection API provided
> by you and would like to thank you very much for giving such a wonderful
> library. I just came up with a problem while using the API

Thanks for the kind words. If possible, can you tell me bit about what
you use it for? I'm interested in knowing how it's used.

> //consider the following code snipper assume i get typeInfo correctly
> RuntimeClassInfo typeInfo;
> typeInfo.getProperty("price");
>
> what i feel is that this method should actually take a QName as the
> input parameter in order to accomodate for the name space. This works
> fine if there is only one element by name "price". Consider a case where
> we have test:price and also oag:price under the same element then
> typeInfo.getProperty("price") will always return the same property.

Actually, I think this is correct. The getProperty method takes a name
of the property, which is more like a Java field name. And therefore
it's a string, not a QName.

One property may hold values for multiple element names, or just one, or
any, and similarly a property might be for an attribute (which can be
thought of a separate symbol space altogether), and then finally a
property might be for PCDATA. So it doesn't make sense to use element
QName as the unique identifier of a property.

> Please let me know if my understanding is right or is there any other way to do it.

That said, maybe all you are asking is a convenience method that, given
an element name, identifies the property that such an element will go.
If so, doing something like that wouldn't be too difficult, and it's
something we can consider.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com