BeanIO 1.2.3

org.beanio.types
Interface TypeHandler

All Known Subinterfaces:
ConfigurableTypeHandler
All Known Implementing Classes:
AbstractXmlDateTypeHandler, BigDecimalTypeHandler, BigIntegerTypeHandler, BooleanTypeHandler, ByteTypeHandler, CharacterTypeHandler, DateTypeHandler, DoubleTypeHandler, FloatTypeHandler, IntegerTypeHandler, LongTypeHandler, NumberTypeHandler, ShortTypeHandler, StringTypeHandler, 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 1.2.3

Copyright © 2010-2012 Kevin Seim