Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.birt.core.format
Class NumberFormatter

    java.lang.Object
      org.eclipse.birt.core.format.NumberFormatter

All Implemented Interfaces:
  IFormatter

    public class NumberFormatter

extends java.lang.Object
implements IFormatter

Defines a number formatting class. It does the following: 1. In constructor, convert format string to Java format string. 2. Expose a format function, which does the following: a. Format number using Java format string b. Do some post-processing, i.e., e or E, minus sign handling, etc.

Nested Class Summary

Nested classes/interfaces inherited from interface org.eclipse.birt.core.format.IFormatter
`IFormatter.DefaultFormatter`

Field Summary
`protected java.text.DecimalFormat` | `decimalFormat`
`protected char` | `decimalSeparator` The default format of Double is Double.toString(); need to localize the result of Double.toString() to get the final result.
`protected java.lang.String` | `formatPattern` the format pattern
`protected com.ibm.icu.util.ULocale` | `locale` the locale used for formatting
`protected static java.util.logging.Logger` | `logger` logger used to log syntax errors.
`protected java.text.NumberFormat` | `numberFormat` a java.text.NumberFormat format object.
`protected boolean` | `parseBigDecimal` Flag whether to parse numbers and return BigDecimal values.

Constructor Summary
`NumberFormatter()` constructor with no argument
`NumberFormatter(java.util.Locale locale)` Deprecated. since 2.1
`NumberFormatter(java.lang.String format)` constructor with a format string as parameter
`NumberFormatter(java.lang.String pattern, java.util.Locale locale)` Deprecated. since 2.1
`NumberFormatter(java.lang.String pattern, com.ibm.icu.util.ULocale locale)` constructor that takes a format pattern and a locale
`NumberFormatter(com.ibm.icu.util.ULocale locale)`

Method Summary
`void` | `applyPattern(java.lang.String patternStr)` initializes numeric format pattern
`java.lang.String` | `format(java.math.BigDecimal bigDecimal)` formats a BigDecimal value into a string
`java.lang.String` | `format(double num)`
`java.lang.String` | `format(long num)` formats a long integer
`java.lang.String` | `format(java.lang.Number number)`
`java.lang.String` | `formatValue(java.lang.Object value)` format the value object into a string.
`java.lang.String` | `getFormatCode()`
`java.lang.String` | `getPattern()` returns the original format string.
`boolean` | `isParseBigDecimal()` Returns whether decimal numbers are returned as BigDecimal instances.
`java.lang.Number` | `parse(java.lang.String number)` Parses the input string into a formatted date type.
`void` | `setParseBigDecimal(boolean parseBigDecimal)` Sets whether decimal numbers must be returned as BigDecimal instances.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### logger

    protected static java.util.logging.Logger logger

  logger used to log syntax errors.

### formatPattern

    protected java.lang.String formatPattern

  the format pattern

### parseBigDecimal

    protected boolean parseBigDecimal

  Flag whether to parse numbers and return BigDecimal values.

### locale

    protected com.ibm.icu.util.ULocale locale

  the locale used for formatting

### numberFormat

    protected java.text.NumberFormat numberFormat

  a java.text.NumberFormat format object. We want to use the createNumberFormat() and format() methods

### decimalFormat

    protected java.text.DecimalFormat decimalFormat

### decimalSeparator

    protected char decimalSeparator

  The default format of Double is Double.toString(); need to localize the result of Double.toString() to get the final result. decimalSeparator is the localized decimal separator. currently the exponential character isnt exposed by JDK, so just leave it for future

  See Also:
    `of java.text.DecimalFormatSymbols#exponential`

Constructor Detail

### NumberFormatter

    public NumberFormatter()

  constructor with no argument

### NumberFormatter

    public NumberFormatter(java.lang.String format)

  constructor with a format string as parameter

  Parameters:
    `format` - format string

### NumberFormatter

    public NumberFormatter(com.ibm.icu.util.ULocale locale)

Parameters:
  `locale` - the locale used for numer format

### NumberFormatter

    public NumberFormatter(java.util.Locale locale)

  Deprecated. since 2.1

### NumberFormatter

    public NumberFormatter(java.lang.String pattern,
                           com.ibm.icu.util.ULocale locale)

  constructor that takes a format pattern and a locale

  Parameters:
    `pattern` - numeric format pattern
    `locale` - locale used to format the number

### NumberFormatter

    public NumberFormatter(java.lang.String pattern,
                           java.util.Locale locale)

  Deprecated. since 2.1

Method Detail

### getPattern

    public java.lang.String getPattern()

  returns the original format string.

### getFormatCode

    public java.lang.String getFormatCode()

### applyPattern

    public void applyPattern(java.lang.String patternStr)

  initializes numeric format pattern

  Parameters:
    `patternStr` - ths string used for formatting numeric data

### format

    public java.lang.String format(double num)

  Parameters:
    `num` - the number to be formatted
  Returns:
    the formatted string

### format

    public java.lang.String format(java.math.BigDecimal bigDecimal)

  formats a BigDecimal value into a string

  Parameters:
    `big` - decimal value
  Returns:
    formatted string

### format

    public java.lang.String format(java.lang.Number number)

### format

    public java.lang.String format(long num)

  formats a long integer

  Parameters:
    `num` - the number to be formatted
  Returns:
    the formatted string

### isParseBigDecimal

    public boolean isParseBigDecimal()

  Returns whether decimal numbers are returned as BigDecimal instances.

  Returns:
    the parseBigDecimal

### setParseBigDecimal

    public void setParseBigDecimal(boolean parseBigDecimal)

  Sets whether decimal numbers must be returned as BigDecimal instances.

  Parameters:
    `parseBigDecimal` - the parseBigDecimal to set

### parse

    public java.lang.Number parse(java.lang.String number)
                           throws java.text.ParseException

  Parses the input string into a formatted date type.

  Parameters:
    `number` - the input string to parse
  Returns:
    the formatted date
  Throws:
    `java.text.ParseException` - if the beginning of the specified string cannot be parsed.

### formatValue

    public java.lang.String formatValue(java.lang.Object value)

  Description copied from interface: `IFormatter`
  format the value object into a string.

  Specified by:
    `formatValue` in interface `IFormatter`
  Returns:

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008 Actuate Corp. All rights reserved.