Sorry to keep hitting the list ... :-)

In the DescriptorSourceFactory there seems to be special code for attribute
handling while building the write method. It seems to append a 'parse'
method taking a string to the Jtype class. Any ideas why this is restricted
to attributes? Looks like this  might fix my problem. -:))


Lines  394 - 420
        jsc.add("target.");
        jsc.append(member.getWriteMethodName());
        jsc.append("( ");
        if (xsType.isPrimitive() && !SourceGenerator.usePrimitiveWrapper())
{
             jsc.append(xsType.createFromJavaObjectCode("value"));
        } else if (any) {
            jsc.append(" value ");
       } else {
            jsc.append("(");
            jsc.append(xsType.getJType().toString());
            //special handling for the type package
            //when we are dealing with attributes
            //This is a temporary solution since we need to handle
            //the 'types' in specific handlers in the future
            //i.e add specific FieldHandler in
org.exolab.castor.xml.handlers
            //dateTime is not concerned by the following since it is
directly
            //handle by DateFieldHandler
            if (isAttribute && xsType.isDateTime() && xsType.getType() !=
xsType.DATETIME_TYPE) {
                jsc.append(".parse");
                jsc.append(JavaNaming.toJavaClassName(xsType.getName()));
                jsc.append("((String) value))");
            }

            else jsc.append(") value");
        }

----- Original Message -----
From: "Weir, John" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 19, 2002 5:02 PM
Subject: Re: [castor-dev] Problems unmarshalling xs:date derived type


> Bit more Info: - Looks like a Generator bug :-(
>
> The exception happens in the generated code. The Inner class that
implements
> XMLFieldHandler tries to cast the value supplied ( a string ) to a Date.
It
> should probably look at the type, and construct a date ( with appropriate
> cast )
>
> I Couldn't find this on the issue list - might be fixed on CVS - Haven't
> worked out where to look yet - Any thoughts?
>
> John
>
>         handler = (new XMLFieldHandler() {
>             public java.lang.Object getValue( java.lang.Object object )
>                 throws IllegalStateException
>             {
>                 UnadjustedDate target = (UnadjustedDate) object;
>                 return target.getContent();
>             }
>             public void setValue( java.lang.Object object,
java.lang.Object
> value)
>                 throws IllegalStateException, IllegalArgumentException
>             {
>                 try {
>                     UnadjustedDate target = (UnadjustedDate) object;
>                   target.setContent( (org.exolab.castor.types.Date)
value);
>                   // this works target.setContent( new
> org.exolab.castor.types.Date((String)value));
>                 }
>                 catch (Exception ex) {
>                     throw new IllegalStateException(ex.toString());
>                 }
>             }
>             public java.lang.Object newInstance( java.lang.Object parent )
{
>                 return new org.exolab.castor.types.Date();
>             }
>         } );
>
> -----Original Message-----
> From: Weir, John
> Sent: Thursday, September 19, 2002 2:50 PM
> To: [EMAIL PROTECTED]
> Subject: [castor-dev] Problems unmarshalling xs:date derived type
>
>
> Hi, I am having a very similar unmarshalling problem very similar to the
one
> outlined by Diez Roggisch in
> http://www.mail-archive.com/[email protected]/msg07846.html email
> This is the definition that I reference
> <xsd:element name="unadjustedDate">
> <xsd:annotation>
> <xsd:documentation>A date subject to
> adjustment.</xsd:documentation>
> </xsd:annotation>
> <xsd:complexType>
> <xsd:simpleContent>
> <xsd:extension base="xsd:date">
> <xsd:attribute name="id"
> type="xsd:ID"/>
> </xsd:extension>
> </xsd:simpleContent>
> </xsd:complexType>
> </xsd:element>
> and the error outlined below. Using 0.9.3.21 release
>
> Does anyone know what the resolution is ?
>
> john
>
> org.xml.sax.SAXException: unable to add text content to unadjustedDate due
> to the following error: java.lang.IllegalStateException:
> java.lang.ClassCastException: java.lang.String
> at
>
org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:589)
> at

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

Reply via email to