// If field has 'has' method, false means field is null
// and do not attempt to call getValue. Otherwise,
if ( object == null ||
( rf._hasMethod != null && ! ( (Boolean) rf._hasMethod.invoke( object, null ) ).booleanValue() ) )
return null;
else
return rf._getMethod.invoke( object, null );
... ant to determine if the has method is available, the MappingLoader
uses :
hasMethod = javaClass.getMethod( "has" + capitalize( fieldName ), null );
This is the reason why the hasMethod is found in your first example and
not in the second.
The best solution would probably be to let the user specify the
has method name in the mapping file... Feel free to submit a patch :-)
Lars Lindgren wrote:
Hi!
I sent this mail a while ago, but I didn't get an answer so I'll give it another try.
I have discovered that if I have a field defined as the following:
<field name="offset" type="long" get-method="getOffset" set-method="setOffset" />
the method hasOffset() is used to check if offset is defined, but if I have the following definition:
<field name="m_offset" type="long" get-method="getOffset" set-method="setOffset" />
the method getOffset is used to check if the offset is set.
My question is now if it is possible to select which has-method to use?
If it is not, why is there no such possibility. Normally the has-method tells if the value that
the get-method returns is valid. If e.g. the field is of type long there is no way to check if
that value is valid using the getMethod, because there is no null value.
So if I have a variable "offset" (long) and a variable "hasOffset" (boolean), where the last one is
returned by hasOffset() and tells if the offset value is valid, I can control if the value shall be
saved to the XML file. But if I change the name of the offset variable the hasOffset value and
the hasOffset() method is neglected, and the offset value is treated as if it is always a valid
value no matter what the hasOffset value is.
Would really appreciate some help with this!
Best regards
Lars
--
Mickael Guessant
Technical Consultant
http://mguessan.free.fr
mailto:[EMAIL PROTECTED]
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
