Is this possible to use a "type safe enum class" in a Mapping file?
It keeps giving me error because I don't have a public default constructor on the 
class.

If the XML Schema definition is the only solution I'll go that way. But if it's 
possible using a mapping file I prefer to keep the work I did already.

Thank you

Carl

-----Original Message-----
From: Leeuw van der, Tim [mailto:[EMAIL PROTECTED]
Sent: 5 mars, 2004 15:44
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] typesafe enum in mapping file - how to?



Hi,

Another solution is to create an XML Schema definition, and define simpleTypes as 
follows for the enumerations:

    <xsd:simpleType name="valueType">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="simpel"/>
            <xsd:enumeration value="afgeleid"/>
        </xsd:restriction>
    </xsd:simpleType>

The name of the simpleType is what you use as the type attribute of those elements 
that you want to use the enumerations for.
The SourceGenerator will generate the enum classes for you, and will generate the 
'regular' classes and descriptors using those enums.
(hope I make sense?)


regards and succes with either solution,

--Tim


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and 
is thus for use only by the intended recipient. If you received this in error, please 
contact the sender and delete the e-mail and its attachments from all computers. 



-----Original Message-----
From: Keith Visco [mailto:[EMAIL PROTECTED]
Sent: vrijdag 5 maart 2004 19:16
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] typesafe enum in mapping file - how to?





Castor supports type-safe enum if they have a valueOf method as such:

public <type> valueOf(String stringValue) {

}

That can return the correct instance for the given value.

--Keith


"Letourneau, Carl" wrote:
> 
> Hi castor users,
> 
> I am using Castor to marshal objects and send them over a UDP connection.
> I am using a mapping file to define all the useful fields I need to find at the 
> other end of my connection.
> 
> The problem I have now is that in some of my classes, I have "typesafe enum" fields.
> These "typesafe enum" fields look like this :
> 
> /**
>  * Typesafe enum class
>  */
> public class MyTypeSafeEnum
> {
>     public static final MyTypeSafeEnum VALUE1 = new MyTypeSafeEnum("myValue1");
>     public static final MyTypeSafeEnum VALUE2 = new MyTypeSafeEnum("myValue2");
>     public static final MyTypeSafeEnum VALUE3 = new MyTypeSafeEnum("myValue3");
>     public static final MyTypeSafeEnum VALUE4 = new MyTypeSafeEnum("myValue4");
>     public static final MyTypeSafeEnum VALUE5 = new MyTypeSafeEnum("myValue5");
> 
>     private final String _myName;
> 
>     private MyTypeSafeEnum(final String name)
>     {
>         _myName = name;
>     }
> 
>     public String toString()
>     {
>         return _myName;
>     }
> }
> 
> Is there support in the castor marshalling mapping file for this type of class?
> 
> Thanks for your help
> 
> Regards
> 
> Carl Letourneau
> 
> -----------------------------------------------------------
> 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