BeanIO 2.0.4

org.beanio.types
Interface TypeHandler

All Known Subinterfaces:
ConfigurableTypeHandler
All Known Implementing Classes:
AbstractXmlDateTypeHandler, BigDecimalTypeHandler, BigIntegerTypeHandler, BooleanTypeHandler, ByteTypeHandler, CharacterTypeHandler, DateTypeHandler, DoubleTypeHandler, EnumTypeHandler, FloatTypeHandler, IntegerTypeHandler, LongTypeHandler, NumberTypeHandler, ShortTypeHandler, StringTypeHandler, ToStringEnumTypeHandler, URLTypeHandler, UUIDTypeHandler, XmlBooleanTypeHandler, XmlDateTimeTypeHandler, XmlDateTypeHandler, XmlTimeTypeHandler

public interface TypeHandler

A TypeHandler is used to convert field text into a Java object and vice versa.

Implementations should be thread-safe if multiple threads may concurrently process the same stream type. All included BeanIO type handlers are thread safe.

Since:
1.0
Author:
Kevin Seim

Field Summary
static String NIL
          This constant can be returned from format(Object) for XML formatted streams to indicate a nillable element should be set to nil even if the field's minimum occurrences is zero.
 
Method Summary
 String format(Object value)
          Formats a Java object into field text.
 Class<?> getType()
          Returns the class type supported by this handler.
 Object parse(String text)
          Parses field text into a Java object.
 

Field Detail

NIL

static final String NIL
This constant can be returned from format(Object) for XML formatted streams to indicate a nillable element should be set to nil even if the field's minimum occurrences is zero. In all other cases, if NIL is returned, the formatted value is treated as null.

Method Detail

parse

Object parse(String text)
             throws TypeConversionException
Parses field text into a Java object.

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

String format(Object value)
Formats a Java object into field text.

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, or NIL for XML formatted streams

getType

Class<?> getType()
Returns the class type supported by this handler. Primitive types should not be returned by this method- use the object equivalent instead.

Returns:
the class type supported by this handler

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim