Thanks so much. 

Like an idiot, I found the appropriate constructor after I sent that out
yesterday. It works like a champ now.

Thanks again.

--
Sean LeBlanc
Software Developer
insightamerica
"Those who do not understand Unix are condemned to reinvent it, poorly."
--Henry Spencer

-----Original Message-----
From: Keith Visco [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 19, 2004 4:18 PM
To: '[EMAIL PROTECTED]'
Subject: Re: [castor-dev] Marshalling the type Calendar?




Sean,

If you use unmarshal(class, reader) then indeed you're using a *static*
method. So the mapping file cannot be used...so you must change to something
like the following:

Mapping myMapping = new Mapping(); myMapping.loadMapping("...");

Unmarshaller unm = new Unmarshaller(class); unm.setMapping(myMapping);
unm.unmarshal(reader);

Hope that helps,

--Keith

Sean Leblanc wrote:
> 
> Thanks, I changed this. Now the generated XML looks cleaner.
> 
> I also found that my problem was that I was not calling unmarshal 
> correctly. I was only using the reader class as an arg. This was 
> causing the errors because I was not sending the classname in. 
> However, if I call this one:
> 
> unmarshall(class, reader)
> 
> I get a warning that it's static in my IDE. And the date coming back 
> is null, even though it's in the file. How should I be calling 
> unmarshall() so that it sees my mapping and does not error out?
> 
> Thanks,
> 
> --
> Sean LeBlanc
> Software Developer
> insightamerica
> "Those who do not understand Unix are condemned to reinvent it, 
> poorly." --Henry Spencer
> 
> -----Original Message-----
> From: Keith Visco [mailto:[EMAIL PROTECTED]
> Sent: Thursday, February 19, 2004 2:29 PM
> To: '[EMAIL PROTECTED]'
> Subject: Re: [castor-dev] Marshalling the type Calendar?
> 
> Hi Sean,
> 
> Try setting the type to be "string" instead of "java.util.Calendar".
> 
> The type needs to be whatever your FieldHandler returns from the
> getValue() of your handler, not what it is before your conversion.
> 
> --Keith
> 
> Sean Leblanc wrote:
> >
> > Thanks.
> >
> > I created a FieldHandler for the calendar field. I can see it in the 
> > corresponding marshalled XML. However, when I try to unmarshall it, 
> > I get an error (below). Do I have to create some extra information 
> > in the mapping.xml in order to handle this? I've been playing with 
> > some different things, but none seem to have an effect. The latest 
> > iteration of my mapping.xml is:
> >
> > <mapping>
> >    <class name="com.MotorVehicleRecord" auto-complete="true"/>
> >    <class name="com.DepartmentActionRecord" auto-complete="true">
> >         <map-to xml="department-action-records"/>
> >    </class>
> >    <class name="com.MasterRecord" auto-complete="true">
> >       <field name="birthDate" type="java.util.Calendar" 
> > handler="com.MyCalendarFieldHandler"/>
> >    </class>
> > </mapping>
> >
> >      [java] #endElement: mapping
> >      [java] Marshalled mvr.
> >      [java] #startElement: motor-vehicle-record
> >      [java] #startElement: department-action-records
> >      [java] unable to find FieldDescriptor for 
> > 'department-action-records' in ClassDescriptor of file-reader
> >      [java] #startElement: department-youth-flag
> >      [java] java.lang.NullPointerException
> >      [java]     at
> > org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler
> > .j
> > ava:14
> > 10)
> >      [java]     at
> >
> org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.j
> ava:11
> > 49)
> >      [java]     at
> > org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
> >      [java]     at
> > org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unk
> > nown
> > Source)
> >      [java]     at
> >
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentD
> ispatc
> > her.dispatch(Unknown Source)
> >      [java]     at
> > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(U
> > nknown
> > Source)
> >      [java]     at
> > org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> >      [java]     at
> org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
> > Source)
> >      [java]     at org.apache.xerces.parsers.XMLParser.parse(Unknown
> Source)
> >      [java]     at
> org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
> > Source)
> >      [java]     at
> > org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:583)
> >      [java]     at
> > org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:491)
> >      [java]     at TestRecord.main(TestRecord.java:438)
> >      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> >      [java]     at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> ava:39
> > )
> >      [java]     at
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl
> > .java:25)
> >      [java]     at java.lang.reflect.Method.invoke(Method.java:324)
> >      [java]     at
> > org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:208)
> >      [java]     at
> > org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:150)
> >      [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:443)
> >      [java]     at
> > org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:163)
> >      [java]     at
> org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
> >      [java]     at org.apache.tools.ant.Task.perform(Task.java:341)
> >      [java]     at org.apache.tools.ant.Target.execute(Target.java:309)
> >      [java]     at
> org.apache.tools.ant.Target.performTasks(Target.java:336)
> >      [java]     at
> > org.apache.tools.ant.Project.executeTarget(Project.java:1339)
> >      [java]     at
> > org.apache.tools.ant.Project.executeTargets(Project.java:1255)
> >      [java]     at org.apache.tools.ant.Main.runBuild(Main.java:609)
> >      [java]     at org.apache.tools.ant.Main.start(Main.java:196)
> >      [java]     at org.apache.tools.ant.Main.main(Main.java:235)
> >
> > --
> > Sean LeBlanc
> > Software Developer
> > insightamerica
> > "Those who do not understand Unix are condemned to reinvent it, 
> > poorly." --Henry Spencer
> >
> > -----Original Message-----
> > From: Keith Visco [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, February 19, 2004 11:53 AM
> > To: '[EMAIL PROTECTED]'
> > Subject: Re: [castor-dev] Marshalling the type Calendar?
> >
> > Hi Sean,
> >
> > There is currently no built-in support java.util.Calendar. You can 
> > probably write a quick GeneralizedFieldHandler that converts the 
> > Calendar to a java.util.Date or event a string during marshalling 
> > (and back again during unmarshalling).
> >
> > The GeneralizedFieldHandler can be specified in the mapping file 
> > such
> > as:
> >
> > mapping.xml
> > <mapping>
> >    <class name="com.acme.MyClass" auto-complete="true">
> >       <field name="calendar" type="string" 
> > handler="com.acme.MyCalendarFieldHandler"/>
> >    </class>
> > </mapping>
> >
> > By using auto-complete="true" this allows you to continue using 
> > introspection for all other fields so you don't have to write a 
> > complete mapping file.
> >
> > There is also another way in Castor 0.9.5.3 RC1 which is to create a 
> > FieldHandlerFactory instance that can return your 
> > GeneralizedFieldHandler for all instances of java.util.Calendar 
> > during introspection.
> >
> > See this thread for more details on that:
> >
> > http://www.mail-archive.com/castor-dev%40exolab.org/msg16665.html
> >
> > --Keith
> >
> > Sean Leblanc wrote:
> > >
> > > Hello,
> > >
> > > I'm using Castor to marshall some classes I already have. I'm 
> > > following the simple way to marshall as outlined here:
> > >
> > > http://www.castor.org/xml-framework.html
> > >
> > > After I worked through the problem of not having changed the 
> > > castor.properties files (unmarshalling was failing prior to that) 
> > > it worked beautifully.
> > >
> > > However, (java.util.)Calendar items in my classes are NOT being 
> > > marshalled. Do I have to create a mapping file in order to do 
> > > this? Or are there some settings in the properties file that 
> > > control this?
> > >
> > > TIA,
> > >
> > > --
> > > Sean LeBlanc
> > > Software Developer
> > > insightamerica
> > > "Those who do not understand Unix are condemned to reinvent it, 
> > > poorly." --Henry Spencer e-Mail Notice: This communication may 
> > > contain sensitive information.  If you are not the intended 
> > > recipient, or believe that you have received this communication in 
> > > error, do not print, copy, retransmit, disseminate, or otherwise 
> > > use the information contained herein for any purpose.  Please 
> > > alert the sender that you have received this message in error and 
> > > delete the copy that you received.
> > >
> > > -----------------------------------------------------------
> > > 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
> > e-Mail Notice: This communication may contain sensitive information. 
> > If you are not the intended recipient, or believe that you have 
> > received this communication in error, do not print, copy, 
> > retransmit, disseminate, or otherwise use the information contained 
> > herein for any purpose.  Please alert the sender that you have 
> > received this message in error and delete the copy that you 
> > received.
> >
> > -----------------------------------------------------------
> > 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
> e-Mail Notice: This communication may contain sensitive information.  
> If you are not the intended recipient, or believe that you have 
> received this communication in error, do not print, copy, retransmit, 
> disseminate, or otherwise use the information contained herein for any 
> purpose.  Please alert the sender that you have received this message 
> in error and delete the copy that you received.
> 
> -----------------------------------------------------------
> 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
e-Mail Notice: This communication may contain sensitive information.  If you
are not the intended recipient, or believe that you have received this
communication in error, do not print, copy, retransmit, disseminate, or
otherwise use the information contained herein for any purpose.  Please
alert the sender that you have received this message in error and delete the
copy that you received.

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

Reply via email to