Package org.beanio.internal.util
Class ToStringEnumTypeHandler
- java.lang.Object
-
- org.beanio.internal.util.ToStringEnumTypeHandler
-
- All Implemented Interfaces:
TypeHandler
public class ToStringEnumTypeHandler extends java.lang.Object implements TypeHandler
AnEnum
type handler that usesEnum.toString()
to parse and format Enum values.- Since:
- 2.0.1
-
-
Field Summary
-
Fields inherited from interface org.beanio.types.TypeHandler
NIL
-
-
Constructor Summary
Constructors Constructor Description ToStringEnumTypeHandler(java.lang.Class<java.lang.Enum> type)
Constructs a newToStringEnumTypeHandler
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
format(java.lang.Object value)
Formats a Java object into field text.java.lang.Class<?>
getType()
Returns the class type supported by this handler.java.lang.Object
parse(java.lang.String text)
Parses field text into a Java object.
-
-
-
Method Detail
-
parse
public java.lang.Object parse(java.lang.String text) throws TypeConversionException
Description copied from interface:TypeHandler
Parses field text into a Java object.- Specified by:
parse
in interfaceTypeHandler
- Parameters:
text
- the field text to parse, which may be null if the field was not passed in the record- Returns:
- the parsed Java object
- Throws:
TypeConversionException
- if the text cannot be parsed
-
format
public java.lang.String format(java.lang.Object value)
Description copied from interface:TypeHandler
Formats a Java object into field text.- Specified by:
format
in interfaceTypeHandler
- Parameters:
value
- the Java object to format, which may be null- Returns:
- the formatted field text, or
null
to indicate the value is not present, orTypeHandler.NIL
for XML formatted streams
-
getType
public java.lang.Class<?> getType()
Description copied from interface:TypeHandler
Returns the class type supported by this handler. Primitive types should not be returned by this method- use the object equivalent instead.- Specified by:
getType
in interfaceTypeHandler
- Returns:
- the class type supported by this handler
-
-