ICU 4.8.1.1  4.8.1.1
Public Types | Public Member Functions | Static Public Member Functions
DecimalFormatSymbols Class Reference

This class represents the set of symbols needed by DecimalFormat to format numbers. More...

#include <dcfmtsym.h>

Inheritance diagram for DecimalFormatSymbols:
UObject UMemory

Public Types

enum  ENumberFormatSymbol {
  kDecimalSeparatorSymbol, kGroupingSeparatorSymbol, kPatternSeparatorSymbol, kPercentSymbol,
  kZeroDigitSymbol, kDigitSymbol, kMinusSignSymbol, kPlusSignSymbol,
  kCurrencySymbol, kIntlCurrencySymbol, kMonetarySeparatorSymbol, kExponentialSymbol,
  kPerMillSymbol, kPadEscapeSymbol, kInfinitySymbol, kNaNSymbol,
  kSignificantDigitSymbol, kMonetaryGroupingSeparatorSymbol, kOneDigitSymbol, kTwoDigitSymbol,
  kThreeDigitSymbol, kFourDigitSymbol, kFiveDigitSymbol, kSixDigitSymbol,
  kSevenDigitSymbol, kEightDigitSymbol, kNineDigitSymbol, kFormatSymbolCount
}
 Constants for specifying a number format symbol. More...

Public Member Functions

 DecimalFormatSymbols (const Locale &locale, UErrorCode &status)
 Create a DecimalFormatSymbols object for the given locale.
 DecimalFormatSymbols (UErrorCode &status)
 Create a DecimalFormatSymbols object for the default locale.
 DecimalFormatSymbols (const DecimalFormatSymbols &)
 Copy constructor.
DecimalFormatSymbolsoperator= (const DecimalFormatSymbols &)
 Assignment operator.
virtual ~DecimalFormatSymbols ()
 Destructor.
UBool operator== (const DecimalFormatSymbols &other) const
 Return true if another object is semantically equal to this one.
UBool operator!= (const DecimalFormatSymbols &other) const
 Return true if another object is semantically unequal to this one.
UnicodeString getSymbol (ENumberFormatSymbol symbol) const
 Get one of the format symbols by its enum constant.
void setSymbol (ENumberFormatSymbol symbol, const UnicodeString &value, const UBool propogateDigits)
 Set one of the format symbols by its enum constant.
Locale getLocale () const
 Returns the locale for which this object was constructed.
Locale getLocale (ULocDataLocaleType type, UErrorCode &status) const
 Returns the locale for this object.
const UnicodeStringgetPatternForCurrencySpacing (UCurrencySpacing type, UBool beforeCurrency, UErrorCode &status) const
 Get pattern string for 'CurrencySpacing' that can be applied to currency format.
void setPatternForCurrencySpacing (UCurrencySpacing type, UBool beforeCurrency, const UnicodeString &pattern)
 Set pattern string for 'CurrencySpacing' that can be applied to currency format.
virtual UClassID getDynamicClassID () const
 ICU "poor man's RTTI", returns a UClassID for the actual class.
const UnicodeStringgetConstSymbol (ENumberFormatSymbol symbol) const
 _Internal_ function - more efficient version of getSymbol, returning a const reference to one of the symbol strings.
const UChargetCurrencyPattern (void) const
 Returns that pattern stored in currecy info.

Static Public Member Functions

static UClassID getStaticClassID ()
 ICU "poor man's RTTI", returns a UClassID for this class.

Detailed Description

This class represents the set of symbols needed by DecimalFormat to format numbers.

DecimalFormat creates for itself an instance of DecimalFormatSymbols from its locale data. If you need to change any of these symbols, you can get the DecimalFormatSymbols object from your DecimalFormat and modify it.

Here are the special characters used in the parts of the subpattern, with notes on their usage.

 
        Symbol   Meaning
          0      a digit
          #      a digit, zero shows as absent
          .      placeholder for decimal separator
          ,      placeholder for grouping separator.
          ;      separates formats.
          -      default negative prefix.
          %      divide by 100 and show as percentage
          X      any other characters can be used in the prefix or suffix
          '      used to quote special characters in a prefix or suffix.

[Notes]

If there is no explicit negative subpattern, - is prefixed to the positive form. That is, "0.00" alone is equivalent to "0.00;-0.00".

The grouping separator is commonly used for thousands, but in some countries for ten-thousands. The interval is a constant number of digits between the grouping characters, such as 100,000,000 or 1,0000,0000. If you supply a pattern with multiple grouping characters, the interval between the last one and the end of the integer is the one that is used. So "#,##,###,####" == "######,####" == "##,####,####".

This class only handles localized digits where the 10 digits are contiguous in Unicode, from 0 to 9. Other digits sets (such as superscripts) would need a different subclass.

Definition at line 84 of file dcfmtsym.h.


Member Enumeration Documentation

Constants for specifying a number format symbol.

Stable:
ICU 2.0
Enumerator:
kDecimalSeparatorSymbol 

The decimal separator.

kGroupingSeparatorSymbol 

The grouping separator.

kPatternSeparatorSymbol 

The pattern separator.

kPercentSymbol 

The percent sign.

kZeroDigitSymbol 

Zero.

kDigitSymbol 

Character representing a digit in the pattern.

kMinusSignSymbol 

The minus sign.

kPlusSignSymbol 

The plus sign.

kCurrencySymbol 

The currency symbol.

kIntlCurrencySymbol 

The international currency symbol.

kMonetarySeparatorSymbol 

The monetary separator.

kExponentialSymbol 

The exponential symbol.

kPerMillSymbol 

Per mill symbol - replaces kPermillSymbol.

kPadEscapeSymbol 

Escape padding character.

kInfinitySymbol 

Infinity symbol.

kNaNSymbol 

Nan symbol.

kSignificantDigitSymbol 

Significant digit symbol.

Stable:
ICU 3.0
kMonetaryGroupingSeparatorSymbol 

The monetary grouping separator.

Stable:
ICU 3.6
kOneDigitSymbol 

One.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.6
kTwoDigitSymbol 

Two.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.6
kThreeDigitSymbol 

Three.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.6
kFourDigitSymbol 

Four.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.6
kFiveDigitSymbol 

Five.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.6
kSixDigitSymbol 

Six.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.6
kSevenDigitSymbol 

Seven.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.6
kEightDigitSymbol 

Eight.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.6
kNineDigitSymbol 

Nine.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.6
kFormatSymbolCount 

count symbol constants

Definition at line 90 of file dcfmtsym.h.


Constructor & Destructor Documentation

DecimalFormatSymbols::DecimalFormatSymbols ( const Locale locale,
UErrorCode status 
)

Create a DecimalFormatSymbols object for the given locale.

Parameters:
localeThe locale to get symbols for.
statusInput/output parameter, set to success or failure code upon return.
Stable:
ICU 2.0

Create a DecimalFormatSymbols object for the default locale.

This constructor will not fail. If the resource file data is not available, it will use hard-coded last-resort data and set status to U_USING_FALLBACK_ERROR.

Parameters:
statusInput/output parameter, set to success or failure code upon return.
Stable:
ICU 2.0

Copy constructor.

Stable:
ICU 2.0

Destructor.

Stable:
ICU 2.0

Member Function Documentation

_Internal_ function - more efficient version of getSymbol, returning a const reference to one of the symbol strings.

The returned reference becomes invalid when the symbol is changed or when the DecimalFormatSymbols are destroyed. ### TODO markus 2002oct11: Consider proposing getConstSymbol() to be really public.

Parameters:
symbolConstant to indicate a number format symbol.
Returns:
the format symbol by the param 'symbol'
Internal:
Do not use. This API is for internal use only.

Definition at line 403 of file dcfmtsym.h.

References kFormatSymbolCount.

const UChar * DecimalFormatSymbols::getCurrencyPattern ( void  ) const [inline]

Returns that pattern stored in currecy info.

Internal API for use by NumberFormat API.

Internal:
Do not use. This API is for internal use only.

Definition at line 442 of file dcfmtsym.h.

ICU "poor man's RTTI", returns a UClassID for the actual class.

Stable:
ICU 2.2

Implements UObject.

Locale DecimalFormatSymbols::getLocale ( void  ) const [inline]

Returns the locale for which this object was constructed.

Stable:
ICU 2.6

Definition at line 437 of file dcfmtsym.h.

Returns the locale for this object.

Two flavors are available: valid and actual locale.

Stable:
ICU 2.8

Get pattern string for 'CurrencySpacing' that can be applied to currency format.

This API gets the CurrencySpacing data from ResourceBundle. The pattern can be empty if there is no data from current locale and its parent locales.

Parameters:
type: UNUM_CURRENCY_MATCH, UNUM_CURRENCY_SURROUNDING_MATCH or UNUM_CURRENCY_INSERT.
beforeCurrency: true if the pattern is for before currency symbol. false if the pattern is for after currency symbol.
status,:Input/output parameter, set to success or failure code upon return.
Returns:
pattern string for currencyMatch, surroundingMatch or spaceInsert. Return empty string if there is no data for this locale and its parent locales.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

ICU "poor man's RTTI", returns a UClassID for this class.

Stable:
ICU 2.2

Get one of the format symbols by its enum constant.

Each symbol is stored as a string so that graphemes (characters with modifier letters) can be used.

Parameters:
symbolConstant to indicate a number format symbol.
Returns:
the format symbols by the param 'symbol'
Stable:
ICU 2.0

Definition at line 392 of file dcfmtsym.h.

References kFormatSymbolCount.

UBool DecimalFormatSymbols::operator!= ( const DecimalFormatSymbols other) const [inline]

Return true if another object is semantically unequal to this one.

Parameters:
otherthe object to be compared with.
Returns:
true if another object is semantically unequal to this one.
Stable:
ICU 2.0

Definition at line 226 of file dcfmtsym.h.

References operator==().

DecimalFormatSymbols& DecimalFormatSymbols::operator= ( const DecimalFormatSymbols )

Assignment operator.

Stable:
ICU 2.0
UBool DecimalFormatSymbols::operator== ( const DecimalFormatSymbols other) const

Return true if another object is semantically equal to this one.

Parameters:
otherthe object to be compared with.
Returns:
true if another object is semantically equal to this one.
Stable:
ICU 2.0
void DecimalFormatSymbols::setPatternForCurrencySpacing ( UCurrencySpacing  type,
UBool  beforeCurrency,
const UnicodeString pattern 
)

Set pattern string for 'CurrencySpacing' that can be applied to currency format.

Parameters:
type: UNUM_CURRENCY_MATCH, UNUM_CURRENCY_SURROUNDING_MATCH or UNUM_CURRENCY_INSERT.
beforeCurrency: true if the pattern is for before currency symbol. false if the pattern is for after currency symbol.
pattern: pattern string to override current setting.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
void DecimalFormatSymbols::setSymbol ( ENumberFormatSymbol  symbol,
const UnicodeString value,
const UBool  propogateDigits = TRUE 
) [inline]

Set one of the format symbols by its enum constant.

Each symbol is stored as a string so that graphemes (characters with modifier letters) can be used.

Parameters:
symbolConstant to indicate a number format symbol.
valuevalue of the format symbol
propogateDigitsIf false, setting the zero digit will not automatically set 1-9. The default behavior is to automatically set 1-9 if zero is being set and the value it is being set to corresponds to a known Unicode zero digit.
Stable:
ICU 2.0

Definition at line 416 of file dcfmtsym.h.

References UnicodeString::char32At(), UnicodeString::countChar32(), kFormatSymbolCount, kOneDigitSymbol, kZeroDigitSymbol, and u_charDigitValue().


The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines