Fine by me. Just trying to get my head around the issue at hand ...

Werner 

> -----Original Message-----
> From: Ralf Joachim [mailto:[EMAIL PROTECTED] 
> Sent: Mittwoch, 22. März 2006 15:02
> To: [email protected]
> Subject: Re: [castor-user] Castor defaults numeric java objects to 0
> 
> Werner,
> 
> if the properties in the class are defined as follows:
> 
> private String first = null;
> private Integer second = new Integer(5);
> 
> and the unmarshalled XML does not include tags or attributes 
> for this properties. Their default value defined in the class 
> should not be changed at unmarshal process.
> 
> Having said that at field mapping you need to define 
> required="false" at the corresponding tags/attributes.
> 
> Therefore I don't see any reason why we need to define a 
> default value or nillable attribute in mapping as this can be 
> defined in the source code of the class.
> 
> Regards
> Ralf
> 
> 
> Werner Guttmann schrieb:
> > Ralf,
> > 
> > I read Stephen's comment in the way that the source 
> generator apparently (to be verified) can deal with nillable 
> being used in an XML Schema. That imho would imply that the 
> XMLClassDescriptots being generated know how to deal with 
> such situations. If that's the case, my idea was to 
> 'implement' a similar (if not the same .. ;-)) funtionality 
> for people not using the source generator, but relying on 
> mapping files only.
> > 
> > Werner
> > 
> > 
> >>-----Original Message-----
> >>From: Ralf Joachim [mailto:[EMAIL PROTECTED]
> >>Sent: Mittwoch, 22. März 2006 10:03
> >>To: [email protected]
> >>Subject: Re: [castor-user] Castor defaults numeric java objects to 0
> >>
> >>I don't think something should be added to the mapping file. 
> >>The user should be able to set default value in his source code and 
> >>Castor should only change this value when a corresponding tag or 
> >>attribute is unmarshalled. If Castor changes a property 
> when it should 
> >>not then this is a bug.
> >>
> >>When there is no possibility to define a default value for 
> a property 
> >>with source generator then we should add this feature to source 
> >>generator.
> >>
> >>Ralf
> >>
> >>
> >>Werner Guttmann schrieb:
> >>
> >>>Stephen, Michael,
> >>>
> >>>Why don't we add a 'nillable' attribute to the mapping file ? 
> >>>
> >>>Werner
> >>>
> >>>
> >>>
> >>>>-----Original Message-----
> >>>>From: Stephen Bash [mailto:[EMAIL PROTECTED]
> >>>>Sent: Dienstag, 21. März 2006 21:12
> >>>>To: [email protected]
> >>>>Subject: Re: [castor-user] Castor defaults numeric java 
> objects to 0
> >>>>
> >>>>Michael-
> >>>>
> >>>>So I remembered this discussion a while back and dug through the 
> >>>>archives to find it.
> >>>>
> >>>>http://marc.theaimsgroup.com/?l=castor-user&m=112267315616893&w=2
> >>>>
> >>>>If you're using a schema and source generation, then 
> possibly using 
> >>>>nillable in the schema will help.
> >>>>
> >>>>Just went digging through the code, and while there doesn't
> >>
> >>seem to be
> >>
> >>>>a way to access nillable from the mapping file, you can set
> >>
> >>nillable
> >>
> >>>>if you get your hands on the XMLFieldDescriptorImpl.  I
> >>
> >>could see an
> >>
> >>>>implementation (albeit non-optimal) where a mapping file 
> is loaded, 
> >>>>and then the the necessary ClassDescriptors are retrieved
> >>
> >>in order to
> >>
> >>>>get the XMLFieldDescriptor objects and set nillable to true.
> >>>>
> >>>>Sorry I can't be of much more help.
> >>>>
> >>>>Stephen
> >>>>
> >>>>
> >>>>On 3/21/06, Michael Heath <[EMAIL PROTECTED]> wrote:
> >>>>
> >>>>
> >>>>>True objects, Floats, Integers, etc.
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>From: "Stephen Bash" <[EMAIL PROTECTED]>
> >>>>>>Reply-To: [email protected]
> >>>>>>To: [email protected]
> >>>>>>Subject: Re: [castor-user] Castor defaults numeric java
> >>>>
> >>>>objects to 0
> >>>>
> >>>>
> >>>>>>Date: Tue, 21 Mar 2006 14:18:36 -0500
> >>>>>>
> >>>>>>Michael-
> >>>>>>
> >>>>>>What types of objects are we referring to?  Primitives, 
> primitive 
> >>>>>>wrappers or true objects?
> >>>>>>
> >>>>>>Thanks,
> >>>>>>Stephen
> >>>>>>
> >>>>>>
> >>>>>>On 3/21/06, Michael Heath <[EMAIL PROTECTED]> wrote:
> >>>>>>
> >>>>>>
> >>>>>>>Hi,
> >>>>>>>
> >>>>>>>I have XML I am unmarhsalling and when the field is
> >>>>
> >>>>empty I want
> >>>>
> >>>>
> >>>>>>>to have
> >>>>>>
> >>>>>>the
> >>>>>>
> >>>>>>
> >>>>>>>java object set to null.
> >>>>>>>
> >>>>>>>The default behaviour appears to be setting the java
> >>>>
> >>>>object to a 0
> >>>>
> >>>>
> >>>>>>>value...this is of course a big problem if the value is
> >>>>
> >>>>supposed
> >>>>
> >>>>
> >>>>>>>to be
> >>>>>>
> >>>>>>empty
> >>>>>>
> >>>>>>
> >>>>>>>and not 0.
> >>>>>>>
> >>>>>>>Can anyone advise? I wrote a custom field handler but
> >>>>
> >>>>this seems
> >>>>
> >>>>
> >>>>>>>to be called after the object is created and set to 0.
> >>>>>>>
> >>>>>>>thanks
> >>>>>>>M
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>-------------------------------------------------
> >>>>>>>If you wish to unsubscribe from this list, please send 
> an empty 
> >>>>>>>message to the following address:
> >>>>>>>
> >>>>>>>[EMAIL PROTECTED]
> >>>>>>>-------------------------------------------------
> >>>>>>>
> >>>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>-------------------------------------------------
> >>>>>If you wish to unsubscribe from this list, please send an empty 
> >>>>>message to the following address:
> >>>>>
> >>>>>[EMAIL PROTECTED]
> >>>>>-------------------------------------------------
> >>>>>
> >>>>>
> >>>>
> >>>-------------------------------------------------
> >>>If you wish to unsubscribe from this list, please send an empty 
> >>>message to the following address:
> >>>
> >>>[EMAIL PROTECTED]
> >>>-------------------------------------------------
> >>
> >>--
> >>
> >>Syscon Ingenieurbüro für
> >>Meß- und Datentechnik GmbH
> >>Ralf Joachim
> >>Raiffeisenstraße 11
> >>D-72127 Kusterdingen
> >>Germany
> >>
> >>Tel.   +49 7071 3690 52
> >>Mobil: +49 173 9630135
> >>Fax    +49 7071 3690 98
> >>
> >>Email: [EMAIL PROTECTED]
> >>Web:   www.syscon-world.de
> >>
> >>-------------------------------------------------
> >>If you wish to unsubscribe from this list, please send an empty 
> >>message to the following address:
> >>
> >>[EMAIL PROTECTED]
> >>-------------------------------------------------
> >>
> >>
> >>
> > 
> > 
> > -------------------------------------------------
> > If you wish to unsubscribe from this list, please send an empty 
> > message to the following address:
> > 
> > [EMAIL PROTECTED]
> > -------------------------------------------------
> 
> -- 
> 
> Syscon Ingenieurbüro für
> Meß- und Datentechnik GmbH
> Ralf Joachim
> Raiffeisenstraße 11
> D-72127 Kusterdingen
> Germany
> 
> Tel.   +49 7071 3690 52
> Mobil: +49 173 9630135
> Fax    +49 7071 3690 98
> 
> Email: [EMAIL PROTECTED]
> Web:   www.syscon-world.de
> 
> -------------------------------------------------
> If you wish to unsubscribe from this list, please send an 
> empty message to the following address:
> 
> [EMAIL PROTECTED]
> -------------------------------------------------
> 
> 
> 

-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to