How to XMLEncode an element of a typesafe enum

Hi,

how can I XMLEncode an element of a typesafe enum (see typesafe enum pattern).

I've tried to implement Serializable and to specify following methods:

private Object writeReplace()throws ObjectStreamException{

return BAR_REPLACE

}

private Object readResolve()throws ObjectStreamException{

return Foo.BAR;

}

But it still complaints that there is no public constructor (which is part of the typesafe enum pattern).

Any suggestions?

Thanks a lot.

Greets

Puce

[850 byte] By [Puce] at [2007-9-27 21:14:09]
# 1

Serializable workes if you have a default/public constructor. That is an object of the type is constructed and the attribute values are populated from the stream. Do not use java.io.Serializable - you have to use java.io.Externalizable and then take the entire responsibility to serialize/deserialize yourself.

Ironluca

Ironluca at 2007-7-7 3:07:14 > top of Java-index,Other Topics,Patterns & OO Design...