That answers my question. Thanks very much.
 
Choudary.

>>> [EMAIL PROTECTED] 07/07/03 10:15AM >>>
Hi,

On Monday, July 7, 2003, at 09:20  AM, Kothapalli Choudary wrote:
> True, but my query was when and why do you need to know that?

You need to know it if the attribute/element is optional.  If you have 
an optional attribute (use="optional" or no use definition) or element 
(minOccurs="0") that maps to a primitive type, Castor needs to know 
whether a value has been explicitly set for it so that it can produce 
correct XML.

You also need to know it if a field is required but has no default 
value.  If it hasn't been set, using the java default (i.e., 0 or 0.0 
or false) could very likely be incorrect.  (And in any case should not 
be assumed to be correct by Castor.)  Without the has method, the 
generated validation code cannot tell the difference between, for 
instance, that an int having been set to 0 and it having not been set 
at all.  "Not having been set" is often an error that needs to be 
caught.

> The same problem will be there for any Java application, but I never 
> had to add a special field for each primitive attribute in all my Java 
> beans. 

Different applications have different requirements.  Any application 
should define some way to handle fields that aren't explicitly set.  In 
Java, this usually takes the form of a documented default value.  For 
Castor, that is not sufficient for the reasons described above.

> Is this functionality needed for JDO?

The has methods are not needed for JDO, but it will use them if they 
are present.  Specifically, it will attempt to store NULL for a field 
whose has method returns false.

> If that is the case, is there any way of turning this off?

If you really object to these methods, you can forestall their creation 
by using Object wrappers for primitives instead of primitives.  See 
http://castor.exolab.org/sourcegen.html#Maps-java-primitive-types-to-
wrapper-object .  (I don't think this should be necessary.  If you 
don't like'em, just don't use'em.)

HTH,
Rhett

--
Rhett Sutphin
Research Assistant (Software)
Coordinated Laboratory for Computational Genomics
   and the Center for Macular Degeneration
University of Iowa - Iowa City - Iowa - 52246
mailto:[EMAIL PROTECTED]

-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to