Hi,

I am trying to un-marshall an value into an enum that doesn't have a
legal Java identifier. I am following the instructions from here:

http://www.castor.org/1.2/srcgen-properties.html#SimpleType-Enumerations

Below is my enum class:

public enum SnmpV3SecurityLevelPrivacyPrivacyProtocol
{
    /** Available levels. **/
    NONE("NONE"), DES("DES"), VALUE_3DES("3DES"), AES128("AES128"),
AES192("AES192"), AES256("AES256");

     /** Value for this instance. **/
    private String              value;


    /**
     * Private constructor. Initialises the value instance variable so
the resource key can be
     * returned.
     *
     * @param value
     *            Value to initialise this enum with.
     */
    private SnmpV3SecurityLevelPrivacyPrivacyProtocol(final String value)
    {
        this.value = value;
    }

    public static SnmpV3SecurityLevelPrivacyPrivacyProtocol
fromValue(final String value)
    {
        for (SnmpV3SecurityLevelPrivacyPrivacyProtocol protocol :
SnmpV3SecurityLevelPrivacyPrivacyProtocol.values())
        {
            if (protocol.value.equals(value))
            {
                return protocol;
            }
        }
        throw new IllegalArgumentException(value);

    }

    public String value()
    {
        return this.value;
    }

    public String toString()
    {
        return this.value;
    }
}

The Marshalling aspect works fine, as the value is marshalled as
"3DES", however, when I try to unmarshall, I get the following
exception:

org.springframework.oxm.UnmarshallingFailureException: Castor
unmarshalling exception; nested exception is
org.exolab.castor.xml.MarshalException:
java.lang.IllegalArgumentException: No enum const class
SnmpV3SecurityLevelPrivacyPrivacyProtocol.3DES

Can anybody provide any assistance as to what I may be doing wrong?

Thanks in advance,

Kevin.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to