2.17.2: 2011-06-17

net.sf.basedb.util.formatter
Class NumberFormatter

java.lang.Object
  extended by net.sf.basedb.util.formatter.NumberFormatter
All Implemented Interfaces:
Formatter<Number>

public class NumberFormatter
extends Object
implements Formatter<Number>

Formats a number for output on a web page.

Version:
2.2
Author:
nicklas
Last modified
$Date: 2010-09-29 11:21:45 +0200 (Wed, 29 Sep 2010) $

Field Summary
private  boolean doubleValues
           
private  int numDecimals
           
 
Constructor Summary
NumberFormatter(int numDecimals, boolean doubleValues)
          Create a new number formatter.
 
Method Summary
 String format(Number value)
          Format a value by converting it to a string.
 Number parseString(String value)
          Parse a string and return a value of the correct type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numDecimals

private int numDecimals

doubleValues

private boolean doubleValues
Constructor Detail

NumberFormatter

public NumberFormatter(int numDecimals,
                       boolean doubleValues)
Create a new number formatter.

Parameters:
numDecimals - The number of decimals to display, or a negative value to display all decimals
doubleValues - If the parseString(String) should return double or float values
See Also:
Values.formatNumber(Float, int)
Method Detail

format

public String format(Number value)
Description copied from interface: Formatter
Format a value by converting it to a string.

Specified by:
format in interface Formatter<Number>
Parameters:
value - The value to format
Returns:
A formatted string

parseString

public Number parseString(String value)
Description copied from interface: Formatter
Parse a string and return a value of the correct type. A null input string should (unless otherwise documented by a specific formatter implementation) be allowed and may return null or any other "default" value.

Specified by:
parseString in interface Formatter<Number>
Parameters:
value - The string to parse
Returns:
An object

2.17.2: 2011-06-17