|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Tagging interface for enum classes that should be serialized automatically
using the ReflectionBasedSerializer
In order to support automatic deserialization, a static method
IEnum valueOf(String s) has to be provided by the enum
implementation.
Also, a toString() implementation has to be provided, such that
enumValue == EnumClass.valueOf( enumValue.toString() );
An example IEnum implementation:
;
private String name;
public static LayoutStyle valueOf(String s) {
if (s != null) {
for (int i = 0; i < values.length; i++) {
if (values[i].toString().equals(s)) {
return values[i];
}
}
}
throw new IllegalArgumentException("Invalid enum value: " + s);
}
private LayoutStyle(String name) {
this.name = name;
}
public String toString() {
return this.name;
}
}
}
ReflectionBasedSerializer,
ReflectionBasedDeserializer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||