|
BeanIO 1.2.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.beanio.types.NumberTypeHandler
public abstract class NumberTypeHandler
Base class for type handlers that parse objects extending from Number. If a pattern is set, a DecimalFormat is used to parse and format the value. Otherwise, the value is parsed and formatted using the Number subclass specific to this type handler.
DecimalFormat
Field Summary |
---|
Fields inherited from interface org.beanio.types.ConfigurableTypeHandler |
---|
FORMAT_SETTING |
Fields inherited from interface org.beanio.types.TypeHandler |
---|
NIL |
Constructor Summary | |
---|---|
NumberTypeHandler()
|
Method Summary | |
---|---|
protected DecimalFormat |
createDecimalFormat()
Creates a DecimalFormat for parsing and formatting the number value. |
protected abstract Number |
createNumber(BigDecimal bg)
Parses a Number from a BigDecimal. |
protected abstract Number |
createNumber(String text)
Parses a Number from text. |
String |
format(Object value)
Formats a Number by calling toString(). |
String |
getPattern()
Returns the DecimalFormat pattern to use to parse and format the number value. |
TypeHandler |
newInstance(Properties properties)
Creates a customized instance of this type handler. |
Number |
parse(String text)
Parses a Number from the given text. |
void |
setPattern(String pattern)
Sets the DeimcalFormat pattern to use to parse and format the number value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.beanio.types.TypeHandler |
---|
getType |
Constructor Detail |
---|
public NumberTypeHandler()
Method Detail |
---|
public final Number parse(String text) throws TypeConversionException
parse
in interface TypeHandler
text
- the text to parse
TypeConversionException
- if the text is not a valid numberprotected abstract Number createNumber(String text) throws NumberFormatException
text
- the text to convert to a Number
NumberFormatException
- if the text is not a valid numberprotected abstract Number createNumber(BigDecimal bg) throws ArithmeticException
bg
- the BigDecimal version of the number
ArithmeticException
- if the BigDecimal cannot be converted
to the Number type supported by this handlerpublic TypeHandler newInstance(Properties properties) throws IllegalArgumentException
ConfigurableTypeHandler
newInstance
in interface ConfigurableTypeHandler
properties
- the properties for customizing the instance
IllegalArgumentException
- if a property value is invalidprotected DecimalFormat createDecimalFormat()
public String format(Object value)
format
in interface TypeHandler
value
- the number to format
public String getPattern()
public void setPattern(String pattern)
pattern
- the DecimalFormat pattern
|
BeanIO 1.2.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |