Arnaud Blandin wrote:
> 
> Hi Stan,
> 
> According to your code, you are using the static methods of the
> Marshaller and so your mapping is not taken into account.
> Try to switch to the static methods.

You mean switch to the non-static methods. Make sure the method you call
takes only one parameter.

--K


> 
> Hope that helps,
> Arnaud
> 
> > -----Original Message-----
> > From: Tyree, Stan [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, October 09, 2002 4:32 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [castor-dev] CastorXML Timestamp issue
> >
> > Keith,
> >
> > I made those changes but something is still not right.  I can see
> > that it
> > creates my TimestampFieldHandler but it doesn't call any functions
> > from that
> > class.  None of the functions like getValue and setValue get called.
> >
> > I'm going to get the CVS version to see what it is doing internally.
> >
> >
> > Thanks,
> >
> >
> > Stan T.
> >
> >
> >       public String toXML(Object domObject)
> >       {
> >               // Load Mapping
> >               Mapping mapping = null;
> >               try
> >               {
> >                       mapping = new Mapping();
> >               mapping.loadMapping("FPMapping.xml");
> >               }
> >               catch (Exception e)
> >               {
> >                       mapping = null;
> >                       log.warn("Could not load the mapping.xml
> > file.",e);
> >               }
> >
> >               // Create a File to marshal to
> >               StringWriter writer = new StringWriter(1024);
> >               // Marshal the person object
> >               Marshaller marsh = new Marshaller(writer);
> >               if (mapping != null)
> >               {
> >                       marsh.setMapping(mapping);
> >               }
> >               marsh.marshal(domObject, writer);
> >               return writer.toString();
> >       }
> >
> >
> > -----Original Message-----
> > From: Keith Visco [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, October 07, 2002 5:21 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [castor-dev] CastorXML Timestamp issue
> > Importance: Low
> >
> >
> > Stan,
> >
> > You field mapping should look as follows:
> >
> >  <field name="timestampValue" type="string"
> > handler="com.firepond.util.xml.TimestampFieldHandler" >
> >     <bind-xml name="timestamp-value" node="element"/>
> >  </field>
> >
> > Note the type="string".
> >
> > Your FieldHandler should handle the conversion to/from a string
> > value.
> >
> > setValue() will be given a string as it's, you construct your
> > Timestamp from
> > the string and pass it to your object.
> >
> > getValue() should return the string value of the Timestamp.
> >
> > --Keith
> >
> >
> > "Tyree, Stan" wrote:
> > >
> > > Ok, I've implemented an initial version of a TimestampFieldHandler
> > but
> > > Castor is unable to "construct" a Timestamp object since
> > > java.sql.Timestamp doesn't have a default constructor.  I've
> > looked at
> > > the code and it is throwing an exception when it looks for a
> > default
> > > constructor on the Timestamp class in the ClassDescriptorImpl. Is
> > > there a way to overcome this by directing it to use another
> > > ClassDescriptorImpl via my mapping file?
> > >
> > > Also, is there a place on the Castor website that has information
> > > about what attributes can be used for the different elements in a
> > > mapping.xml file? I've been looking at
> > > http://castor.exolab.org/xml-mapping.html and it didn't have
> > anything
> > > for the "handler" attribute on the <FIELD> element.
> > >
> > > Thanks,
> > >
> > > Stan T.
> > >
> > > 046 [main] FATAL test.testXMLUtility  - Error
> > > org.exolab.castor.mapping.MappingException: The Java class
> > > java.sql.Timestamp is not constructable -- it does not contain a
> > > default public constructor
> > >         at
> > >
> > org.exolab.castor.mapping.loader.ClassDescriptorImpl.<init>(Unknown
> > Source)
> > >         at
> > >
> > org.exolab.castor.mapping.loader.MappingLoader.createDescriptor(Unkn
> > ow
> > > n
> > > Source)
> > >         at
> > org.exolab.castor.xml.XMLMappingLoader.createDescriptor(Unknown
> > > Source)
> > >         at
> > > org.exolab.castor.mapping.loader.MappingLoader.loadMapping(Unknown
> > Source)
> > >         at org.exolab.castor.mapping.Mapping.getResolver(Unknown
> > Source)
> > >         at org.exolab.castor.mapping.Mapping.getResolver(Unknown
> > Source)
> > >         at org.exolab.castor.xml.Marshaller.setMapping(Unknown
> > Source)
> > >         at
> > >
> > com.firepond.util.xml.XMLUtility.toCasterXMLString(XMLUtility.java:1
> > 51)
> > >         at
> > test.testXMLUtility.testExportXML(testXMLUtility.java:103)
> > >         at java.lang.reflect.Method.invoke(Native Method)
> > >         at junit.framework.TestCase.runTest(TestCase.java:166)
> > >         at junit.framework.TestCase.runBare(TestCase.java:140)
> > >         at
> > junit.framework.TestResult$1.protect(TestResult.java:106)
> > >         at
> > junit.framework.TestResult.runProtected(TestResult.java:124)
> > >         at junit.framework.TestResult.run(TestResult.java:109)
> > >         at junit.framework.TestCase.run(TestCase.java:131)
> > >         at junit.framework.TestSuite.runTest(TestSuite.java:173)
> > >         at junit.framework.TestSuite.run(TestSuite.java:168)
> > >         at
> > >
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remo
> > teTestRu
> > > nner.java:329)
> > >         at
> > >
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTes
> > tRunner.
> > > java:218)
> > >         at
> > >
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTe
> > stRunner
> > > .java:151)
> > >
> > > <?xml version="1.0"?>
> > > <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD
> > Version
> > > 1.0//EN"
> > >                          "http://castor.exolab.org/mapping.dtd";>
> > > <mapping>
> > >
> > >     <class name="test.xml.TestA">
> > >         <map-to xml="TestA"/>
> > >                         :
> > >                         :
> > >                         :
> > >         <field name="timestampValue" type="java.sql.Timestamp"
> > > handler="com.firepond.util.xml.TimestampFieldHandler" >
> > >             <bind-xml name="timestamp-value" node="element"/>
> > >         </field>
> > >                         :
> > >                         :
> > >                         :
> > >     </class>
> > >
> > > -----Original Message-----
> > > From: Keith Visco [mailto:[EMAIL PROTECTED]]
> > > Sent: Friday, October 04, 2002 3:30 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [castor-dev] CastorXML Timestamp issue
> > > Importance: Low
> > >
> > > You received the ZoneMastBiz object because that is the parent
> > object
> > > in which the field needs to be set, or retrieved from.
> > >
> > > If you are using the CVS version and you want information about
> > > *which* field it is, try extending AbstractFieldHandler. You can
> > then
> > > determine information about the field by using the
> > > getFieldDescriptor() method:
> > >
> > >    public Object getValue(Object _obj) throws
> > IllegalStateException
> > >    {
> > >
> > >         if (getFieldDescriptor().getName().equals("User27")) {
> > >             ...
> > >         }
> > >    }
> > >
> > >
> > > --Keith
> > >
> > > Tin wrote:
> > > >
> > > > Hi,
> > > >   I have tried your suggestion, but my custom field handler will
> > get
> > > > the object that contains the field. There is no way to tell
> > which
> > > > field I want to handle. ex, my mapping file
> > > > -------------------
> > > > <class name="ZoneMastBiz">
> > > > <field name="User27" type="java.sql.Timestamp"
> > > > handler="TimestampFieldHandler">
> > > >   <bind-xml name="User27" node="element"/>
> > > > </field>
> > > > -------------------
> > > >
> > > > In my field handler, I got the object ZoneMastBiz, which I think
> > it
> > > > should be "User27". So, I can "handler" it myself. Any
> > suggestion?
> > > >
> > > > my handler implement
> > > > ----------------------
> > > > public class TimestampFieldHandler extends XMLFieldHandler {
> > > >   ...
> > > >
> > > >   public Object getValue(Object _obj) throws
> > IllegalStateException
> > > >   {
> > > >     /* I got ZoneMastBiz here. How could I know it is called
> > within
> > > > the field "User27" ? */
> > > >   }
> > > >   ...
> > > > }
> > > > -----Original Message-----
> > > > From: Arnaud Blandin [mailto:[EMAIL PROTECTED]]
> > > > Sent: Friday, October 04, 2002 5:49 AM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: Re: [castor-dev] CastorXML Timestamp issue
> > > >
> > > > Hi Stan,
> > > >
> > > > We can't integrate the patch the way it is since it doesn't fit
> > with
> > > > the current code base and semantics of Castor. The best way to
> > > > provide marshalling and unmarshalling of such a class is to use
> > the
> > > > pluggable FieldHandler API in Castor. What you have to do is
> > write a
> > > > specific FieldHandler that will help the marshalling framework
> > to
> > > > marshal/unmarshal a java.sql.TimeStamp. You can take a look at
> > > > org.exolab.castor.xml.handlers.DateFieldHandler as an example.
> > Once
> > > > your handler is ready you can specify it using the 'handler'
> > > > attribute of the <field> element in a mapping file. Feel free
> > also
> > > > to send us the handler so that we can integrate it in the next
> > > > release.
> > > >
> > > > Thanks,
> > > >
> > > > Arnaud
> > > >
> > > > -----Original Message-----
> > > > From: Tyree, Stan [mailto:[EMAIL PROTECTED]]
> > > > Sent: Thursday, October 03, 2002 9:03 PM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: [castor-dev] CastorXML Timestamp issue
> > > >
> > > > Quan,
> > > >
> > > > I saw this post and didn't see your fix in the latest version of
> > > > castor.  Do you know if anyone has plans of addressing the
> > > > problem/solution you had?
> > > >
> > > > http://www.mail-archive.com/[email protected]/msg01422.html
> > > >
> > > > Thanks,
> > > >
> > > > Stan T.
> > > >
> > > > -----------------------------------------------------------
> > > > 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

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

Reply via email to