Thanks for the information. Is it possible to make these wrapper classes and field handler classes as inner class in the original class? Right now it seems mapping file doesn't like $ in the class name?
Thanks. - Wei Chen -----Original Message----- From: Keith Visco [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 09, 2003 2:19 AM To: [EMAIL PROTECTED] Subject: Re: [castor-dev] XML: read-only properties Currently constructor arguments are not supported. It's definately something we're planning on supporting, but right now it's not supported. The work-around is to use a wrapper class that is used during the unmarshalling process (and is discarded after unmarshalling) and a custom FieldHandler. You should be able to find a number of examples using a FieldHandler by searching the archive: http://www.mail-archive.com/[email protected]/ Sorry for the inconvenience. --Keith Wei Chen wrote: > > The values are set through constructors. E.g. > > public class A { > String name; > public A(String name) {this.name = name;} > public String getName() {return this.name;} > } > > Thanks. > > - Wei Chen > > -----Original Message----- > From: Keith Visco [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, January 08, 2003 11:45 AM > To: [EMAIL PROTECTED] > Subject: Re: [castor-dev] XML: read-only properties > > Wei Chen wrote: > > > > But how does Castor set the value during unmarshalling? > > But then they wouldn't be read-only right? Maybe I am misunderstanding > you. > > --K > > > -----Original Message----- > > From: Keith Visco [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, January 07, 2003 11:54 AM > > To: [EMAIL PROTECTED] > > Subject: Re: [castor-dev] XML: read-only properties > > > > If something is read-only, just specify a get-method in the mapping > > file, without specifying a set-method. If you don't specify any > accesor > > methods Castor will automatically try to determine them, but if you > > specify just one, then Castor will not look for the other, so it's a > way > > to handle read-only. > > > > --Keith > > > > Wei Chen wrote: > > > > > > Hi, > > > > > > I am learning castor and wondering what is the best practice to > handle > > > read-only properties. > > > > > > So far I made it working by writing field handlers and specifying > them > > > in the mapping file. > > > > > > It seems I can not write field handler as an inner class (mapping > > loader > > > complaints about the $ in class name). And I have to write one for > > each > > > handle (there is no way to combine them). All these result in > > explosion > > > of java files. > > > > > > What is best practice for handling read-only properties? > > > > > > Thanks. > > > > > > - Wei Chen > > > > > > ----------------------------------------------------------- > > > If you wish to unsubscribe from this mailing, send mail to > > > [EMAIL PROTECTED] with a subject of: > > > unsubscribe castor-dev > > > > ----------------------------------------------------------- > > If you wish to unsubscribe from this mailing, send mail to > > [EMAIL PROTECTED] with a subject of: > > unsubscribe castor-dev > > > > ----------------------------------------------------------- > > If you wish to unsubscribe from this mailing, send mail to > > [EMAIL PROTECTED] with a subject of: > > unsubscribe castor-dev > > ----------------------------------------------------------- > If you wish to unsubscribe from this mailing, send mail to > [EMAIL PROTECTED] with a subject of: > unsubscribe castor-dev > > ----------------------------------------------------------- > If you wish to unsubscribe from this mailing, send mail to > [EMAIL PROTECTED] with a subject of: > unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
