A
org.apache.cocoon.forms.datatype.Datatype Datatype implementation for
types implementing Joshua Bloch's
typesafe enum pattern.
See the following code for an example:
package com.example;
public class Sex {
public static final Sex MALE = new Sex("M");
public static final Sex FEMALE = new Sex("F");
private String code;
private Sex(String code) { this.code = code; }
}
If your enumerated type does not provide a
java.lang.Object.toString method, the enum convertor will use the fully qualified class name,
followed by the name of the public static final field referring to
each instance, i.e. "com.example.Sex.MALE", "com.example.Sex.FEMALE"
and so on.
If you provide a toString() method which returns something
different, you should also provide a fromString(String, Locale)
method to convert those strings back to instances.
version: $Id: EnumType.java 449149 2006-09-23 03:58:05Z crossley $ |