Class FastDecimalFormat
- java.lang.Object
-
- org.pentaho.reporting.libraries.formatting.FastDecimalFormat
-
- All Implemented Interfaces:
Serializable
,Cloneable
,FastFormat
public class FastDecimalFormat extends Object implements FastFormat
A wrapper around the java.text.DecimalFormat class. This wrapper limits the possible interactions with the wrapped format class and therefore eliminates the need to clone the choice format whenever the wrapper is cloned.- Author:
- Thomas Morgner
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
TYPE_CURRENCY
A format-type constant indicating the system's default currency format.static int
TYPE_DEFAULT
A format-type constant indicating the system's default number format.static int
TYPE_INTEGER
A format-type constant indicating the system's default integer format.static int
TYPE_PERCENT
A format-type constant indicating the system's default percentage format.
-
Constructor Summary
Constructors Constructor Description FastDecimalFormat(int type, Locale locale)
Creates a new date-format for the given default date and time style.FastDecimalFormat(int type, Locale locale, boolean useFormattingFromResources)
Creates a new date-format for the given default date and time style.FastDecimalFormat(String pattern)
Creates a new decimal-format for the given pattern.FastDecimalFormat(String pattern, Locale locale)
Creates a new decimal-format for the given pattern and locale.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
clone()
Clones the formatter.boolean
equals(Object o)
String
format(Object parameters)
Formats the given object in a formatter-specific way.Locale
getLocale()
Returns the current locale of the formatter.String
getPattern()
Returns the currently active pattern.int
hashCode()
-
-
-
Field Detail
-
TYPE_DEFAULT
public static final int TYPE_DEFAULT
A format-type constant indicating the system's default number format.- See Also:
- Constant Field Values
-
TYPE_INTEGER
public static final int TYPE_INTEGER
A format-type constant indicating the system's default integer format.- See Also:
- Constant Field Values
-
TYPE_CURRENCY
public static final int TYPE_CURRENCY
A format-type constant indicating the system's default currency format.- See Also:
- Constant Field Values
-
TYPE_PERCENT
public static final int TYPE_PERCENT
A format-type constant indicating the system's default percentage format.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FastDecimalFormat
public FastDecimalFormat(String pattern)
Creates a new decimal-format for the given pattern.- Parameters:
pattern
- the pattern string.
-
FastDecimalFormat
public FastDecimalFormat(String pattern, Locale locale)
Creates a new decimal-format for the given pattern and locale.- Parameters:
pattern
- the pattern string.locale
- the locale.
-
FastDecimalFormat
public FastDecimalFormat(int type, Locale locale)
Creates a new date-format for the given default date and time style.- Parameters:
type
- the number-style, one of TYPE_INTEGER, TYPE_PERCENT, TYPE_CURRENCY or TYPE_DEFAULT.locale
- the locale.- Throws:
IllegalArgumentException
- if both date and time-style are set to -1.
-
FastDecimalFormat
public FastDecimalFormat(int type, Locale locale, boolean useFormattingFromResources)
Creates a new date-format for the given default date and time style.- Parameters:
type
- the number-style, one of TYPE_INTEGER, TYPE_PERCENT, TYPE_CURRENCY or TYPE_DEFAULT.locale
- the locale.useFormattingFromResources
- always use formatting specified in resources- Throws:
IllegalArgumentException
- if both date and time-style are set to -1.
-
-
Method Detail
-
getLocale
public Locale getLocale()
Returns the current locale of the formatter.- Specified by:
getLocale
in interfaceFastFormat
- Returns:
- the current locale, never null.
-
getPattern
public String getPattern()
Returns the currently active pattern.- Returns:
- the locale.
-
format
public String format(Object parameters)
Formats the given object in a formatter-specific way.- Specified by:
format
in interfaceFastFormat
- Parameters:
parameters
- the parameters for the formatting.- Returns:
- the formatted string.
-
clone
public Object clone()
Clones the formatter.- Specified by:
clone
in interfaceFastFormat
- Overrides:
clone
in classObject
- Returns:
- the clone.
- Throws:
CloneNotSupportedException
- if cloning failed.
-
-