Robert,
I have created bug 28954 in Bugzilla for you.. There is a sample commons
lang enum plus the unit test demonstrating it failing. Stepping through the
code, the creator does get called, however, it never has the name value
populated, even though in the xml there is the name attribute!
Eric
-Original Message-
From: robert burrell donkin
[mailto:[EMAIL PROTECTED]
Sent: Thursday, May 06, 2004 11:09 PM
To: Jakarta Commons Developers List
Subject: Re: [betwixt][lang] Persisting Enum's via Betwixt
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:[EMAIL PROTECTED]
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:[EMAIL PROTECTED]
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
enumClassclass
com.upstate.kinaseprofiler.reactiongenerator.TemplateType/enumClass
nameKP/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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]