"Anthony Elder" <[EMAIL PROTECTED]> writes:
> I think there may be some misunderstanding about this problem.
>
> If you have a Java bean with a field
>
>       String xyz;   // <-- starts with lowercase
>
> then Java conventions say there will be methods getXyz() and setXyz().
>
> If you change the field name to be:
>
>       String Xyz;   // <-- starts with uppercase
>
> then Java conventions say there will be methods getXyz() and setXyz().
Note
> the methods have identical names in both examples.
>
> The BeanSerializer uses the names of the methods to find what an XML
> element will map to. setXyz() is assumed to mean that there is a field
> named xyz, which maps to an element named xyz. But this assumption is
wrong
> in the second example, and if there is an element named Xyz there is *no
> way* in Java to differentiate the getter and setter methods.

Just to be clear - JavaBeans is a set of patterns on method names
only. There is no requirement whatsoever for there even to be a String
field representing the "xyz" property in this particular case. The
value can be stored as an int and then presented to the outside
world as a float.

>From a JavaBeans perspective, the ONLY thing that matters is the
name of the property - and even that doesn't necessarily come
from the name of the method. If a BeanInfo class were to be
present then that could say property xyz is set by method SetX
and gotten by GetY for example.

Sanjiva.

Reply via email to