org.ujac.util.text
Class SmartDecimalFormat

java.lang.Object
  extended by java.text.Format
      extended by java.text.NumberFormat
          extended by java.text.DecimalFormat
              extended by org.ujac.util.text.SmartDecimalFormat
All Implemented Interfaces:
Serializable, Cloneable

public class SmartDecimalFormat
extends DecimalFormat

Name: SmartDecimalFormat
Description: A number format class, implementing a smarter way of rounding which performs better than the BigDecimalFormat class.

Author:
lauerc
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.NumberFormat
NumberFormat.Field
 
Field Summary
 
Fields inherited from class java.text.NumberFormat
FRACTION_FIELD, INTEGER_FIELD
 
Constructor Summary
SmartDecimalFormat()
          Constructs a SmartDecimalFormat instance with no specific attributes.
SmartDecimalFormat(String pattern)
          Constructs a SmartDecimalFormat instance with specific attributes.
SmartDecimalFormat(String pattern, DecimalFormatSymbols symbols)
          Constructs a SmartDecimalFormat instance with specific attributes.
SmartDecimalFormat(String pattern, DecimalFormatSymbols symbols, int roundingMode)
          Constructs a SmartDecimalFormat instance with specific attributes.
SmartDecimalFormat(String pattern, int roundingMode)
          Constructs a SmartDecimalFormat instance with specific attributes.
 
Method Summary
 StringBuffer format(double number, StringBuffer result, FieldPosition fieldPosition)
           
 int getRoundingModeId()
          Gets the rounding mode.
 void setRoundingModeId(int roundingMode)
          Sets the rounding mode.
 
Methods inherited from class java.text.DecimalFormat
applyLocalizedPattern, applyPattern, clone, equals, format, format, formatToCharacterIterator, getCurrency, getDecimalFormatSymbols, getGroupingSize, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getMultiplier, getNegativePrefix, getNegativeSuffix, getPositivePrefix, getPositiveSuffix, getRoundingMode, hashCode, isDecimalSeparatorAlwaysShown, isParseBigDecimal, parse, setCurrency, setDecimalFormatSymbols, setDecimalSeparatorAlwaysShown, setGroupingSize, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setMultiplier, setNegativePrefix, setNegativeSuffix, setParseBigDecimal, setPositivePrefix, setPositiveSuffix, setRoundingMode, toLocalizedPattern, toPattern
 
Methods inherited from class java.text.NumberFormat
format, format, getAvailableLocales, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setGroupingUsed, setParseIntegerOnly
 
Methods inherited from class java.text.Format
format, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmartDecimalFormat

public SmartDecimalFormat()
Constructs a SmartDecimalFormat instance with no specific attributes.


SmartDecimalFormat

public SmartDecimalFormat(String pattern)
Constructs a SmartDecimalFormat instance with specific attributes.

Parameters:
pattern - The format pattern.

SmartDecimalFormat

public SmartDecimalFormat(String pattern,
                          int roundingMode)
Constructs a SmartDecimalFormat instance with specific attributes.

Parameters:
pattern - The format pattern.
roundingMode - The initial rounding mode.

SmartDecimalFormat

public SmartDecimalFormat(String pattern,
                          DecimalFormatSymbols symbols)
Constructs a SmartDecimalFormat instance with specific attributes.

Parameters:
pattern - The format pattern.
symbols - The format symbols.

SmartDecimalFormat

public SmartDecimalFormat(String pattern,
                          DecimalFormatSymbols symbols,
                          int roundingMode)
Constructs a SmartDecimalFormat instance with specific attributes.

Parameters:
pattern - The format pattern.
symbols - The format symbols.
roundingMode - The initial rounding mode.
Method Detail

format

public StringBuffer format(double number,
                           StringBuffer result,
                           FieldPosition fieldPosition)
Overrides:
format in class DecimalFormat
See Also:
NumberFormat.format(double, java.lang.StringBuffer, java.text.FieldPosition)

getRoundingModeId

public int getRoundingModeId()
Gets the rounding mode.

Returns:
The current rounding mode.

setRoundingModeId

public void setRoundingModeId(int roundingMode)
Sets the rounding mode.

Parameters:
roundingMode - The rounding mode to set.


Copyright © 2003-2004 UJAC.org. All Rights Reserved.