BeanIO 1.2.3

org.beanio.types
Class StringTypeHandler

java.lang.Object
  extended by org.beanio.types.StringTypeHandler
All Implemented Interfaces:
TypeHandler

public class StringTypeHandler
extends Object
implements TypeHandler

A type handler implementation for the String class.

Since:
1.0
Author:
Kevin Seim

Field Summary
 
Fields inherited from interface org.beanio.types.TypeHandler
NIL
 
Constructor Summary
StringTypeHandler()
           
 
Method Summary
 String format(Object value)
          Formats the value by calling Object.toString().
 Class<?> getType()
          Returns the class type supported by this handler.
 boolean isNullIfEmpty()
          Returns true if empty string values are parsed as null.
 boolean isTrim()
          Returns true if parse(String) should trim the text.
 String parse(String text)
          Parses a String from the given text.
 void setNullIfEmpty(boolean nullIfEmpty)
          Set to true if the parsed empty strings should be converted to null.
 void setTrim(boolean trim)
          Set to true to trim text when parsing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringTypeHandler

public StringTypeHandler()
Method Detail

parse

public String parse(String text)
Parses a String from the given text.

Specified by:
parse in interface TypeHandler
Parameters:
text - the text to parse
Returns:
the parsed String

format

public String format(Object value)
Formats the value by calling Object.toString().

Specified by:
format in interface TypeHandler
Parameters:
value - the value to format
Returns:
the formatted value, or null if value is null

getType

public 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 interface TypeHandler
Returns:
the class type supported by this handler

isTrim

public boolean isTrim()
Returns true if parse(String) should trim the text. By default, trim is false which allows trimming to be controlled by the field definition.

Returns:
true if parsed text is trimmed

setTrim

public void setTrim(boolean trim)
Set to true to trim text when parsing.

Parameters:
trim - true if text should be trimmed when parsed

isNullIfEmpty

public boolean isNullIfEmpty()
Returns true if empty string values are parsed as null. Defaults to false.

Returns:
true to convert the empty string to null

setNullIfEmpty

public void setNullIfEmpty(boolean nullIfEmpty)
Set to true if the parsed empty strings should be converted to null.

Parameters:
nullIfEmpty - true< to convert empty string to null

BeanIO 1.2.3

Copyright © 2010-2012 Kevin Seim