public class EnumTranslator<E extends java.lang.Enum<E>> extends IllegalArgumentExceptionSimpleValueTranslator<E>
MAX_STRING_REPRESENTATION_LENGTH| Constructor and Description |
|---|
EnumTranslator(java.lang.Class<E> enumClass)
Creates a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Class<E> |
getObjectClass()
Returns the Java class of object instances created by this translator.
|
java.lang.String |
javaToRepresentation(java.lang.Object object,
WriterStreamDataProvider<?> streamDataProvider)
Converts the object by invoking its
Object.toString() method. |
protected E |
parseValue(java.lang.String representation,
ReaderStreamDataProvider<?> streamDataProvider) |
representationToJavahasStringRepresentation, readXMLRepresentation, writeXMLRepresentationequals, hashCodepublic EnumTranslator(java.lang.Class<E> enumClass)
enumClass - the class of enum to be translated with the new instancejava.lang.NullPointerException - if enumClass is nullpublic java.lang.Class<E> getObjectClass()
ObjectTranslator
Note that ObjectTranslator.javaToRepresentation(Object, WriterStreamDataProvider) and ObjectTranslator.writeXMLRepresentation(XMLStreamWriter, Object, WriterStreamDataProvider) may also
accept instances of other classes. This is independent from the return value here.
protected E parseValue(java.lang.String representation, ReaderStreamDataProvider<?> streamDataProvider) throws java.lang.IllegalArgumentException
parseValue in class IllegalArgumentExceptionSimpleValueTranslator<E extends java.lang.Enum<E>>java.lang.IllegalArgumentExceptionpublic java.lang.String javaToRepresentation(java.lang.Object object, WriterStreamDataProvider<?> streamDataProvider) throws java.lang.UnsupportedOperationException, java.lang.ClassCastException
SimpleValueTranslatorObject.toString() method.javaToRepresentation in interface ObjectTranslator<E extends java.lang.Enum<E>>javaToRepresentation in class SimpleValueTranslator<E extends java.lang.Enum<E>>object - the object to be convertedstreamDataProvider - TODOjava.lang.UnsupportedOperationException - if objects handled by this instance can only be represented as XMLjava.lang.ClassCastException - if the specified object is not an instance of the supported class or does not implement the supported
interfaceObjectTranslator.javaToRepresentation(java.lang.Object, WriterStreamDataProvider)