commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertburrelldon...@blueyonder.co.uk>
Subject Re: [betwixt][lang] Persisting Enum's via Betwixt
Date Thu, 06 May 2004 21:09:28 GMT
hi eric

if you're not using CVS HEAD then you need to upgrade.

if you are and the custom object creator isn't working then if you post 
a unit test you're willing to contribute to bugzilla i'll take a look 
when i find a minute (or two).

- robert

On 6 May 2004, at 17:54, Eric Pugh wrote:

> Interesting..  I'll try that..  I found a chunk in the Betwixt site 
> aobut
> using a custom object creater..  however, I didn't get that to work
> successfully..
>
> I'll give this a try..
>
> Eric
>
>> -----Original Message-----
>> From: Inger, Matthew [mailto:Inger@Synygy.com]
>> Sent: Thursday, May 06, 2004 5:15 PM
>> To: 'Jakarta Commons Developers List'
>> Subject: RE: [betwixt][lang] Persisting Enum's via Betwixt
>>
>>
>> Whatever you're reading in has to have a default constructor
>>
>> To avoid having this directly in your enum itself,
>> you should be able to create a proxy class for your
>> enum which can be the object which is serialized.
>> The TemplateType will be converted to this type upon
>> write, and the proxy converted back to TemplateType on
>> read.
>>
>> public class TemplateTypeProxy implements Serializable {
>>    private String name;
>>
>>    public TemplateTypeProxy() {
>>    }
>>
>>    public void setName(String name) {
>>       this.name =name;
>>    }
>>
>>    public String getName() {
>>       return name;
>>    }
>>
>>    public Object readObject() {
>>        if (name.equals(TemplateType.KP.getValue())) {
>>           return TemplateType.KP;
>>        else if (name.equals(TemplateType.IC50.getValue())) {
>>           return TemplateType.IC50;
>>        else
>>           return null;
>>    }
>> }
>>
>> public final class TemplateType extends Enum {
>>     ...
>>
>>     public Object writeObject() {
>>        return new TemplateTypeProxy(getValue());
>>     }
>> }
>>
>>
>> This of course, assumes that Betwixt pays attention
>> to the Serializable interface, and these methods.
>>
>> -----Original Message-----
>> From: Eric Pugh [mailto:epugh@upstate.com]
>> Sent: Thursday, May 06, 2004 9:02 AM
>> To: Commons-Dev
>> Subject: [betwixt][lang] Persisting Enum's via Betwixt
>>
>>
>> Hi all,
>>
>> I am attempting to persist my custom Enumeration that extends Enum via
>> Betwixt, however, I can't seem to get it to read back in.  It writes 
>> out
>> fine, but not back in.  Does anyone have a unit test demonstrating 
>> this?
>> Does this need to be added to Betwixt?
>>
>> It seems likely maybe I am stumbling over something with statics
>> maybe?  Or
>> final keyword?
>>
>> Eric Pugh
>>
>> xml:
>>
>> <templateType id="3">
>>     <enumClass>class
>> com.upstate.kinaseprofiler.reactiongenerator.TemplateType</enumClass>
>>     <name>KP</name>
>>   </templateType>
>>
>> java:
>> public final class TemplateType extends Enum
>> {
>>     public static final TemplateType KP = new TemplateType("KP");
>>     public static final TemplateType IC50 = new TemplateType("IC50");
>>
>>     public TemplateType(String color)
>>     {
>>         super(color);
>>     }
>>
>>     public static TemplateType getEnum(String type)
>>     {
>>         return (TemplateType) getEnum(TemplateType.class, type);
>>     }
>> 	public static void setEnum(String type)
>> 	{
>> 		this =  getEnum(TemplateType.class, type);
>> 	}
>>     public static Map getEnumMap()
>>     {
>>         return getEnumMap(TemplateType.class);
>>     }
>>
>>     public static List getEnumList()
>>     {
>>         return getEnumList(TemplateType.class);
>>     }
>>
>>     public static Iterator iterator()
>>     {
>>         return iterator(TemplateType.class);
>>     }
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message