com.endeca.portal.format
Class NumberFormatter
java.lang.Object
com.endeca.portal.format.Formatter
com.endeca.portal.format.NumberFormatter
- All Implemented Interfaces:
- FormatSettings, NumberFormatSettings, java.io.Serializable
public class NumberFormatter
- extends Formatter
- implements NumberFormatSettings, java.io.Serializable
Formatter for formatting Number, Currency or Percentage types based on locale and format settings.
If the value of a format setting is DEFAULT, the value of the format setting of its parent will be used if it is not DEFAULT.
Otherwise, system default value of that format setting will be used.
- See Also:
- Serialized Form
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
DEFAULT_INCLUDE_GROUPING_SEPARATOR
public static final NumberFormatSettings.IncludeGroupingSeparator DEFAULT_INCLUDE_GROUPING_SEPARATOR
DEFAULT_DECIMAL_PLACES_MODE
public static final NumberFormatSettings.DecimalPlacesMode DEFAULT_DECIMAL_PLACES_MODE
DEFAULT_DECIMAL_PLACES
public static final int DEFAULT_DECIMAL_PLACES
- See Also:
- Constant Field Values
DEFAULT_INTEGER_DECIMAL_PLACES
public static final int DEFAULT_INTEGER_DECIMAL_PLACES
- See Also:
- Constant Field Values
DEFAULT_FORMAT_PATTERN
public static final NumberFormatSettings.FormatPattern DEFAULT_FORMAT_PATTERN
DEFAULT_DECIMAL_SEPARATOR
public static final NumberFormatSettings.DecimalSeparator DEFAULT_DECIMAL_SEPARATOR
DEFAULT_GROUPINGSEPARATOR
public static final NumberFormatSettings.GroupingSeparator DEFAULT_GROUPINGSEPARATOR
DEFAULT_CURRENCY_SYMBOL
public static final java.lang.String DEFAULT_CURRENCY_SYMBOL
- See Also:
- Constant Field Values
DEFAULT_INCLUDE_CURRENCY_SYMBOL
public static final NumberFormatSettings.IncludeCurrencySymbol DEFAULT_INCLUDE_CURRENCY_SYMBOL
DEFAULT_INCLUDE_PERCENTAGE_SIGN
public static final NumberFormatSettings.IncludePercentageSign DEFAULT_INCLUDE_PERCENTAGE_SIGN
NumberFormatter
public NumberFormatter()
NumberFormatter
public NumberFormatter(FormatSettings.Type type)
getMergedType
public FormatSettings.Type getMergedType()
- Return the merged type based on the following rules:
Child's type will be honored if parent is null or the parent's type is NUMBER.
Otherwise, if the parent's type is either CURRENCY or PERCENTAGE, parent's type will be honored.
- Specified by:
getMergedType in interface NumberFormatSettings
getIsInteger
public boolean getIsInteger()
- Specified by:
getIsInteger in interface NumberFormatSettings
setIsInteger
public void setIsInteger(boolean isInteger)
getDecimalPlacesMode
public NumberFormatSettings.DecimalPlacesMode getDecimalPlacesMode()
- Specified by:
getDecimalPlacesMode in interface NumberFormatSettings
setDecimalPlacesMode
public void setDecimalPlacesMode(NumberFormatSettings.DecimalPlacesMode decimalPlacesMode)
getMergedDecimalPlacesMode
public NumberFormatSettings.DecimalPlacesMode getMergedDecimalPlacesMode()
- Specified by:
getMergedDecimalPlacesMode in interface NumberFormatSettings
getDecimalPlaces
public int getDecimalPlaces()
- Specified by:
getDecimalPlaces in interface NumberFormatSettings
setDecimalPlaces
public void setDecimalPlaces(int decimalPlaces)
getMergedDecimalPlaces
public int getMergedDecimalPlaces()
- Specified by:
getMergedDecimalPlaces in interface NumberFormatSettings
getDecimalSeparator
public NumberFormatSettings.DecimalSeparator getDecimalSeparator()
- Specified by:
getDecimalSeparator in interface NumberFormatSettings
setDecimalSeparator
public void setDecimalSeparator(NumberFormatSettings.DecimalSeparator decimalSeparator)
getMergedDecimalSeparator
public NumberFormatSettings.DecimalSeparator getMergedDecimalSeparator()
- Specified by:
getMergedDecimalSeparator in interface NumberFormatSettings
getGroupingSeparator
public NumberFormatSettings.GroupingSeparator getGroupingSeparator()
- Specified by:
getGroupingSeparator in interface NumberFormatSettings
setGroupingSeparator
public void setGroupingSeparator(NumberFormatSettings.GroupingSeparator groupingSeparator)
getMergedGroupingSeparator
public NumberFormatSettings.GroupingSeparator getMergedGroupingSeparator()
- Specified by:
getMergedGroupingSeparator in interface NumberFormatSettings
getCurrencySymbol
public java.lang.String getCurrencySymbol()
- Specified by:
getCurrencySymbol in interface NumberFormatSettings
setCurrencySymbol
public void setCurrencySymbol(java.lang.String currencySymbol)
getMergedCurrencySymbol
public java.lang.String getMergedCurrencySymbol()
- Specified by:
getMergedCurrencySymbol in interface NumberFormatSettings
getIncludeCurrencySymbol
public NumberFormatSettings.IncludeCurrencySymbol getIncludeCurrencySymbol()
- Specified by:
getIncludeCurrencySymbol in interface NumberFormatSettings
setIncludeCurrencySymbol
public void setIncludeCurrencySymbol(NumberFormatSettings.IncludeCurrencySymbol includeCurrencySymbol)
getMergedIncludeCurrencySymbol
public NumberFormatSettings.IncludeCurrencySymbol getMergedIncludeCurrencySymbol()
- Specified by:
getMergedIncludeCurrencySymbol in interface NumberFormatSettings
getIncludeGroupingSeparator
public NumberFormatSettings.IncludeGroupingSeparator getIncludeGroupingSeparator()
- Specified by:
getIncludeGroupingSeparator in interface NumberFormatSettings
setIncludeGroupingSeparator
public void setIncludeGroupingSeparator(NumberFormatSettings.IncludeGroupingSeparator includeGroupingSeparator)
getMergedIncludeGroupingSeparator
public NumberFormatSettings.IncludeGroupingSeparator getMergedIncludeGroupingSeparator()
- Specified by:
getMergedIncludeGroupingSeparator in interface NumberFormatSettings
getFormatPattern
public NumberFormatSettings.FormatPattern getFormatPattern()
- Specified by:
getFormatPattern in interface NumberFormatSettings
setFormatPattern
public void setFormatPattern(NumberFormatSettings.FormatPattern formatPattern)
getMergedFormatPattern
public NumberFormatSettings.FormatPattern getMergedFormatPattern()
- Specified by:
getMergedFormatPattern in interface NumberFormatSettings
getIncludePercentageSign
public NumberFormatSettings.IncludePercentageSign getIncludePercentageSign()
- Specified by:
getIncludePercentageSign in interface NumberFormatSettings
setIncludePercentageSign
public void setIncludePercentageSign(NumberFormatSettings.IncludePercentageSign includePercentageSign)
getMergedIncludePercentageSign
public NumberFormatSettings.IncludePercentageSign getMergedIncludePercentageSign()
- Specified by:
getMergedIncludePercentageSign in interface NumberFormatSettings
getCachedJavaFormat
protected java.text.NumberFormat getCachedJavaFormat()
clearCachedJavaFormat
protected void clearCachedJavaFormat()
localeChanged
protected void localeChanged()
- Description copied from class:
Formatter
- Subclasses can override this method to clear/reset some cached data that is dependent on locale, for example cached Java format.
- Overrides:
localeChanged in class Formatter
parentFormatSettingsChanged
protected void parentFormatSettingsChanged()
- Description copied from class:
Formatter
- Subclasses can override this method to clear/reset some cached data that is dependent on parent format settings,
for example cached Java format.
- Overrides:
parentFormatSettingsChanged in class Formatter
createJavaFormat
protected void createJavaFormat()
initializeJavaFormat
protected void initializeJavaFormat()
getDecimalSeparatorChar
protected static char getDecimalSeparatorChar(NumberFormatSettings.DecimalSeparator decimalSeparator)
getGroupingSeparatorChar
protected static char getGroupingSeparatorChar(NumberFormatSettings.GroupingSeparator groupingSeparator)
format
public java.lang.String format(java.lang.String rawString)
throws Formatter.FormatParseException
- Specified by:
format in class Formatter
- Throws:
Formatter.FormatParseException
format
public java.lang.String format(double rawNumber)
getCurrencyList
public static java.lang.String[] getCurrencyList()