net.sf.jsefa.common.converter
Class BigDecimalConverter

java.lang.Object
  extended by net.sf.jsefa.common.converter.BigDecimalConverter
All Implemented Interfaces:
SimpleTypeConverter

public class BigDecimalConverter
extends Object
implements SimpleTypeConverter

Converter for BigDecimal objects.
The format consists of two Strings. The first denotes the Locale and the second is a pattern as used by DecimalFormat.

It is thread-safe (the access to the non-thread-safe DecimalFormat is synchronized).

Author:
Norman Lahme-Huetig

Constructor Summary
protected BigDecimalConverter(SimpleTypeConverterConfiguration configuration)
          Constructs a new BigDecimalConverter.
 
Method Summary
static BigDecimalConverter create(SimpleTypeConverterConfiguration configuration)
          Creates a BigDecimalConverter.
 BigDecimal fromString(String value)
          Converts the given String object into an object with the simple data type this converter is intended for.
protected  String[] getDefaultFormat()
          Returns the default format which is used when no format is given.
 String toString(Object value)
          Converts the given value to a String object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BigDecimalConverter

protected BigDecimalConverter(SimpleTypeConverterConfiguration configuration)
Constructs a new BigDecimalConverter.
If no format is given, the default format (see getDefaultFormat()) is used.

Parameters:
configuration - the configuration
Throws:
ConversionException - if the given format is not valid.
Method Detail

create

public static BigDecimalConverter create(SimpleTypeConverterConfiguration configuration)
Creates a BigDecimalConverter.
If no format is given, the default format (see getDefaultFormat()) is used.

Parameters:
configuration - the configuration
Returns:
a big decimal converter
Throws:
ConversionException - if the given format is not valid.

fromString

public final BigDecimal fromString(String value)
Converts the given String object into an object with the simple data type this converter is intended for.

Specified by:
fromString in interface SimpleTypeConverter
Parameters:
value - the String object to convert
Returns:
the converted value

toString

public final String toString(Object value)
Converts the given value to a String object.

Specified by:
toString in interface SimpleTypeConverter
Parameters:
value - the value to convert
Returns:
the converted value

getDefaultFormat

protected String[] getDefaultFormat()
Returns the default format which is used when no format is given.

Returns:
the default format.


Copyright © 2014. All rights reserved.