Hi Mario,

It is hard for me to comment as you have not given full information about
your class.

However, from what I understand, you have a class in which you have defined
an enum type.

And the class will have members of that enum type.

public class A {

    static enum PropertyIds {
        Dummy
    };

    private PropertyId fPropertyId = PropertyIds.Dummy;

    ...

}

So if you write out an object of this class A a = new A();:

           out.writeObject(a);

On reading, you will get back the object with fPropertyId set to the saved
value.

     A a = (A)in.readObject();

So what you need is a coder for the class that has declared the enum type
within it and not a coder for the enum type itself.

Thanks and regards,

Janak

>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] Behalf Of Mario H.
>Castillo
>Sent: Thursday, October 05, 2006 10:09 PM
>To: [EMAIL PROTECTED] Com
>Subject: [ULC-developer] Enum coder
>
>
>Janak,
>
>I want to make sure this the correct process.
>
>I have a class that looks like this:
>
>    static enum PropertyIds {
>        Dummy
>    };
>
>and I have implemented a coder that looks like this.
>
>public class PropertyIdsCoder implements IStreamCoder {
>
>    public String getPeerClassName() {
>        return PropertyFactory.PropertyIds.class.getName();
>    }
>
>    public void writeObject(IObjectOutputStream out, Object data) {
>        try {
>            out.writeObject(PropertyFactory.PropertyIds.Dummy.name());
>        } catch (IOException e) {
>            e.printStackTrace();  //To change body of catch statement
>       }
>    }
>
>    public Object readObject(IObjectInputStream in) throws IOException {
>     String s = (String)in.readObject();
>        Enum p = PropertyFactory.PropertyIds.valueOf(s);
>        return p;
>    }
>
>}
>
>Is correct?
>
>Mario
>Abacus Research
>
>
>_______________________________________________
>ULC-developer mailing list
>[email protected]
>http://lists.canoo.com/mailman/listinfo/ulc-developer

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to