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(Unknown
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:151)
        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(RemoteTestRu
nner.java:329)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
java:218)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner
.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

Reply via email to