Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

MessageFormat Class Reference

A MessageFormat produces concatenated messages in a language-neutral way. More...

#include <msgfmt.h>

Inheritance diagram for MessageFormat::

Format UObject UMemory List of all members.

Public Types

enum  EFormatNumber { kMaxFormat = 10 }
 Enum type for kMaxFormat. More...


Public Methods

 MessageFormat (const UnicodeString &pattern, UErrorCode &status)
 Constructs a new MessageFormat using the given pattern and the default locale. More...

 MessageFormat (const UnicodeString &pattern, const Locale &newLocale, UErrorCode &status)
 Constructs a new MessageFormat using the given pattern and locale. More...

 MessageFormat (const UnicodeString &pattern, const Locale &newLocale, UParseError &parseError, UErrorCode &status)
 Constructs a new MessageFormat using the given pattern and locale. More...

 MessageFormat (const MessageFormat &)
 Constructs a new MessageFormat from an existing one. More...

const MessageFormat & operator= (const MessageFormat &)
 Assignment operator. More...

virtual ~MessageFormat ()
 Destructor. More...

virtual Formatclone (void) const
 Clones this Format object polymorphically. More...

virtual UBool operator== (const Format &other) const
 Returns true if the given Format objects are semantically equal. More...

virtual void setLocale (const Locale &theLocale)
 Sets the locale. More...

virtual const LocalegetLocale (void) const
 Gets the locale. More...

virtual void applyPattern (const UnicodeString &pattern, UErrorCode &status)
 Applies the given pattern string to this message format. More...

virtual void applyPattern (const UnicodeString &pattern, UParseError &parseError, UErrorCode &status)
 Applies the given pattern string to this message format. More...

virtual UnicodeStringtoPattern (UnicodeString &appendTo) const
 Returns a pattern that can be used to recreate this object. More...

virtual void adoptFormats (Format **formatsToAdopt, int32_t count)
 Sets subformats. More...

virtual void setFormats (const Format **newFormats, int32_t cnt)
 Sets subformats. More...

virtual void adoptFormat (int32_t formatNumber, Format *formatToAdopt)
 Sets one subformat. More...

virtual void setFormat (int32_t formatNumber, const Format &format)
 Sets one subformat. More...

virtual const Format ** getFormats (int32_t &count) const
 Gets an array of subformats of this object. More...

UnicodeStringformat (const Formattable *source, int32_t count, UnicodeString &appendTo, FieldPosition &ignore, UErrorCode &status) const
 Formats the given array of arguments into a user-readable string. More...

virtual UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Formats the given array of arguments into a user-readable string. More...

UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
 Formats the given array of arguments into a user-readable string. More...

virtual Formattableparse (const UnicodeString &source, ParsePosition &pos, int32_t &count) const
 Parses the given string into an array of output arguments. More...

virtual Formattableparse (const UnicodeString &source, int32_t &count, UErrorCode &status) const
 Parses the given string into an array of output arguments. More...

virtual void parseObject (const UnicodeString &source, Formattable &result, ParsePosition &pos) const
 Parses the given string into an array of output arguments stored within a single Formattable of type kArray. More...

virtual UClassID getDynamicClassID (void) const
 Returns a unique class ID POLYMORPHICALLY. More...

virtual Locale getLocale (ULocDataLocaleType type, UErrorCode &status) const
 Get the locale for this message format object. More...

virtual const char * getLocaleInternal (ULocDataLocaleType type, UErrorCode &status) const
 Get the locale for this message format object. More...


Static Public Methods

UnicodeStringformat (const UnicodeString &pattern, const Formattable *arguments, int32_t count, UnicodeString &appendTo, UErrorCode &status)
 Formats the given array of arguments into a user-readable string using the given pattern. More...

UClassID getStaticClassID (void)
 Return the class ID for this class. More...


Private Methods

 MessageFormat ()
UBool allocateSubformats (int32_t capacity)
UBool allocateArgTypes (int32_t capacity)
const NumberFormatgetDefaultNumberFormat (UErrorCode &) const
 Method to retrieve default formats (or NULL on failure). More...

const DateFormatgetDefaultDateFormat (UErrorCode &) const
UnicodeStringformat (const Formattable *arguments, int32_t cnt, UnicodeString &appendTo, FieldPosition &status, int32_t recursionProtection, UErrorCode &success) const
 Formats the array of arguments and copies the result into the result buffer, updates the field position. More...

void makeFormat (int32_t offsetNumber, UnicodeString *segments, UParseError &parseError, UErrorCode &success)
NumberFormatcreateIntegerFormat (const Locale &locale, UErrorCode &status) const
 Convenience method that ought to be in NumberFormat. More...

const Formattable::TypegetArgTypeList (int32_t &listCount) const
 Returns array of argument types in the parsed pattern for use in C API. More...


Static Private Methods

int32_t findKeyword (const UnicodeString &s, const UChar *const *list)
 Finds the word s, in the keyword list and returns the located index. More...

void copyAndFixQuotes (const UnicodeString &appendTo, int32_t start, int32_t end, UnicodeString &target)
 Checks the range of the source text to quote the special characters, { and ' and copy to target buffer. More...


Private Attributes

Locale fLocale
UnicodeString fPattern
Format ** formatAliases
int32_t formatAliasesCapacity
Subformatsubformats
 A MessageFormat contains an array of subformats. More...

int32_t subformatCount
int32_t subformatCapacity
Formattable::TypeargTypes
 A MessageFormat formats an array of arguments. More...

int32_t argTypeCount
int32_t argTypeCapacity
NumberFormatdefaultNumberFormat
 Default Format objects used when no format is specified and a numeric or date argument is formatted. More...

DateFormatdefaultDateFormat

Friends

class MessageFormatAdapter

Detailed Description

A MessageFormat produces concatenated messages in a language-neutral way.

It should be used for all string concatenations that are visible to end users.

A MessageFormat contains an array of subformats arranged within a template string. Together, the subformats and template string determine how the MessageFormat will operate during formatting and parsing.

Typically, both the subformats and the template string are specified at once in a pattern. By using different patterns for different locales, messages may be localized.

During formatting, the MessageFormat takes an array of arguments and produces a user-readable string. Each argument is a Formattable object; they may be passed in in an array, or as a single Formattable object which itself contains an array. Each argument is matched up with its corresponding subformat, which then formats it into a string. The resultant strings are then assembled within the string template of the MessageFormat to produce the final output string.

During parsing, an input string is matched against the string template of the MessageFormat to produce an array of Formattable objects. Plain text of the template string is matched directly against intput text. At each position in the template string where a subformat is located, the subformat is called to parse the corresponding segment of input text to produce an output argument. In this way, an array of arguments is created which together constitute the parse result.

Parsing may fail or produce unexpected results in a number of circumstances.

Here are some examples of usage:

Example 1:

 
     UErrorCode success = U_ZERO_ERROR;
     GregorianCalendar cal(success);
     Formattable arguments[] = {
         7L,
         Formattable( (Date) cal.getTime(success), Formattable::kIsDate),
         "a disturbance in the Force"
     };

     UnicodeString result;
     MessageFormat::format(
          "At {1,time} on {1,date}, there was {2} on planet {0,number}.",
          arguments, 3, result, success );

     cout << "result: " << result << endl;
     //<output>: At 4:34:20 PM on 23-Mar-98, there was a disturbance
     //             in the Force on planet 7.
Typically, the message format will come from resources, and the arguments will be dynamically set at runtime.

Example 2:

  
     success = U_ZERO_ERROR;
     Formattable testArgs[] = {3L, "MyDisk"};

     MessageFormat form(
         "The disk \"{1}\" contains {0} file(s).", success );

     UnicodeString string;
     FieldPosition fpos = 0;
     cout << "format: " << form.format(testArgs, 2, string, fpos, success ) << endl;

     // output, with different testArgs:
     // output: The disk "MyDisk" contains 0 file(s).
     // output: The disk "MyDisk" contains 1 file(s).
     // output: The disk "MyDisk" contains 1,273 file(s).

The pattern is of the following form. Legend:

 
       {optional item}
       (group that may be repeated)*
Do not confuse optional items with items inside quotes braces, such as this: "{". Quoted braces are literals.
  
       messageFormatPattern := string ( "{" messageFormatElement "}" string )*

       messageFormatElement := argumentIndex { "," elementFormat }

       elementFormat := "time" { "," datetimeStyle }
                      | "date" { "," datetimeStyle }
                      | "number" { "," numberStyle }
                      | "choice" "," choiceStyle

       datetimeStyle := "short"
                      | "medium"
                      | "long"
                      | "full"
                      | dateFormatPattern

       numberStyle :=   "currency"
                      | "percent"
                      | "integer"
                      | numberFormatPattern

       choiceStyle :=   choiceFormatPattern
If there is no elementFormat, then the argument must be a string, which is substituted. If there is no dateTimeStyle or numberStyle, then the default format is used (e.g. NumberFormat::createInstance(), DateFormat::createTimeInstance(DateFormat::kDefault, ...) or DateFormat::createDateInstance(DateFormat::kDefault, ...). For a ChoiceFormat, the pattern must always be specified, since there is no default.

In strings, single quotes can be used to quote syntax characters. A literal single quote is represented by '', both within and outside of single-quoted segments. Inside a messageFormatElement, quotes are not removed. For example, {1,number,$'#',##} will produce a number format with the pound-sign quoted, with a result such as: "$#31,45".

If a pattern is used, then unquoted braces in the pattern, if any, must match: that is, "ab {0} de" and "ab '}' de" are ok, but "ab {0'}' de" and "ab } de" are not.

The argumentIndex is a non-negative integer, which corresponds to the index of the arguments presented in an array to be formatted. The first argument has argumentIndex 0.

It is acceptable to have unused arguments in the array. With missing arguments or arguments that are not of the right class for the specified format, a failing UErrorCode result is set.

For more sophisticated patterns, you can use a ChoiceFormat to get output:

 
     UErrorCode success = U_ZERO_ERROR;
     MessageFormat* form("The disk \"{1}\" contains {0}.", success);
     double filelimits[] = {0,1,2};
     UnicodeString filepart[] = {"no files","one file","{0,number} files"};
     ChoiceFormat* fileform = new ChoiceFormat(filelimits, filepart, 3);
     form.setFormat(1, *fileform); // NOT zero, see below

     Formattable testArgs[] = {1273L, "MyDisk"};

     UnicodeString string;
     FieldPosition fpos = 0;
     cout << form.format(testArgs, 2, string, fpos, success) << endl;

     // output, with different testArgs
     // output: The disk "MyDisk" contains no files.
     // output: The disk "MyDisk" contains one file.
     // output: The disk "MyDisk" contains 1,273 files.
You can either do this programmatically, as in the above example, or by using a pattern (see ChoiceFormat for more information) as in:
 
    form.applyPattern(
      "There {0,choice,0#are no files|1#is one file|1<are {0,number,integer} files}.");

Note: As we see above, the string produced by a ChoiceFormat in MessageFormat is treated specially; occurences of '{' are used to indicated subformats, and cause recursion. If you create both a MessageFormat and ChoiceFormat programmatically (instead of using the string patterns), then be careful not to produce a format that recurses on itself, which will cause an infinite loop.

Note:Subformats are numbered by their order in the pattern. This is not the same as the argumentIndex.

 
    For example: with "abc{2}def{3}ghi{0}...",

    format0 affects the first variable {2}
    format1 affects the second variable {3}
    format2 affects the second variable {0}

Definition at line 242 of file msgfmt.h.


Member Enumeration Documentation

enum MessageFormat::EFormatNumber
 

Enum type for kMaxFormat.

Obsolete:
ICU 3.0. The 10-argument limit was removed as of ICU 2.6, rendering this enum type obsolete.
Enumeration values:
kMaxFormat  The maximum number of arguments.

Obsolete:
ICU 3.0. The 10-argument limit was removed as of ICU 2.6, rendering this constant obsolete.

Definition at line 249 of file msgfmt.h.


Constructor & Destructor Documentation

MessageFormat::MessageFormat const UnicodeString   pattern,
UErrorCode   status
 

Constructs a new MessageFormat using the given pattern and the default locale.

Parameters:
pattern  Pattern used to construct object.
status  Input/output error code. If the pattern cannot be parsed, set to failure code.
Stable:
ICU 2.0

MessageFormat::MessageFormat const UnicodeString   pattern,
const Locale   newLocale,
UErrorCode   status
 

Constructs a new MessageFormat using the given pattern and locale.

Parameters:
pattern  Pattern used to construct object.
newLocale  The locale to use for formatting dates and numbers.
status  Input/output error code. If the pattern cannot be parsed, set to failure code.
Stable:
ICU 2.0

MessageFormat::MessageFormat const UnicodeString   pattern,
const Locale   newLocale,
UParseError   parseError,
UErrorCode   status
 

Constructs a new MessageFormat using the given pattern and locale.

Parameters:
pattern  Pattern used to construct object.
newLocale  The locale to use for formatting dates and numbers.
parseError  Struct to recieve information on position of error within the pattern.
status  Input/output error code. If the pattern cannot be parsed, set to failure code.
Stable:
ICU 2.0

MessageFormat::MessageFormat const MessageFormat &   
 

Constructs a new MessageFormat from an existing one.

Stable:
ICU 2.0

virtual MessageFormat::~MessageFormat   [virtual]
 

Destructor.

Stable:
ICU 2.0

MessageFormat::MessageFormat   [private]
 


Member Function Documentation

virtual void MessageFormat::adoptFormat int32_t    formatNumber,
Format   formatToAdopt
[virtual]
 

Sets one subformat.

See the class description about format numbering. The caller should not delete the Format object after this call. If the number is over the number of formats already set, the item will be deleted and ignored.

Stable:
ICU 2.0
Parameters:
formatNumber  index of the subformat.
formatToAdopt  the format to be adopted.

virtual void MessageFormat::adoptFormats Format **    formatsToAdopt,
int32_t    count
[virtual]
 

Sets subformats.

See the class description about format numbering. The caller should not delete the Format objects after this call. The array formatsToAdopt is not itself adopted. Its ownership is retained by the caller. If the call fails because memory cannot be allocated, then the formats will be deleted by this method, and this object will remain unchanged.

Stable:
ICU 2.0
Parameters:
formatsToAdopt  the format to be adopted.
count  the size of the array.

UBool MessageFormat::allocateArgTypes int32_t    capacity [private]
 

UBool MessageFormat::allocateSubformats int32_t    capacity [private]
 

virtual void MessageFormat::applyPattern const UnicodeString   pattern,
UParseError   parseError,
UErrorCode   status
[virtual]
 

Applies the given pattern string to this message format.

Parameters:
pattern  The pattern to be applied.
parseError  Struct to recieve information on position of error within pattern.
status  Input/output error code. If the pattern cannot be parsed, set to failure code.
Stable:
ICU 2.0

virtual void MessageFormat::applyPattern const UnicodeString   pattern,
UErrorCode   status
[virtual]
 

Applies the given pattern string to this message format.

Parameters:
pattern  The pattern to be applied.
status  Input/output error code. If the pattern cannot be parsed, set to failure code.
Stable:
ICU 2.0

virtual Format* MessageFormat::clone void    const [virtual]
 

Clones this Format object polymorphically.

The caller owns the result and should delete it when done.

Stable:
ICU 2.0

Reimplemented from Format.

void MessageFormat::copyAndFixQuotes const UnicodeString   appendTo,
int32_t    start,
int32_t    end,
UnicodeString   target
[static, private]
 

Checks the range of the source text to quote the special characters, { and ' and copy to target buffer.

Parameters:
source 
start  the text offset to start the process of in the source string
end  the text offset to end the process of in the source string
appendTo  Output parameter to receive result. Result is appended to existing contents.

NumberFormat* MessageFormat::createIntegerFormat const Locale   locale,
UErrorCode   status
const [private]
 

Convenience method that ought to be in NumberFormat.

int32_t MessageFormat::findKeyword const UnicodeString   s,
const UChar *const *    list
[static, private]
 

Finds the word s, in the keyword list and returns the located index.

Parameters:
s  the keyword to be searched for.
list  the list of keywords to be searched with.
Returns:
the index of the list which matches the keyword s.

UnicodeString& MessageFormat::format const Formattable   arguments,
int32_t    cnt,
UnicodeString   appendTo,
FieldPosition   status,
int32_t    recursionProtection,
UErrorCode   success
const [private]
 

Formats the array of arguments and copies the result into the result buffer, updates the field position.

Parameters:
arguments  The formattable objects array.
cnt  The array count.
appendTo  Output parameter to receive result. Result is appended to existing contents.
status  Field position status.
recursionProtection  Initially zero. Bits 0..9 are used to indicate that a parameter has already been seen, to avoid recursion. Currently unused.
success  The error code status.
Returns:
Reference to 'appendTo' parameter.

UnicodeString & MessageFormat::format const Formattable   obj,
UnicodeString   appendTo,
UErrorCode   status
const [inline]
 

Formats the given array of arguments into a user-readable string.

The array must be stored within a single Formattable object of type kArray. If the Formattable object type is not of type kArray, then returns a failing UErrorCode.

Parameters:
obj  The object to format
appendTo  Output parameter to receive result. Result is appended to existing contents.
status  Input/output error code. If the pattern cannot be parsed, set to failure code.
Returns:
Reference to 'appendTo' parameter.
Stable:
ICU 2.0

Reimplemented from Format.

Definition at line 791 of file msgfmt.h.

virtual UnicodeString& MessageFormat::format const Formattable   obj,
UnicodeString   appendTo,
FieldPosition   pos,
UErrorCode   status
const [virtual]
 

Formats the given array of arguments into a user-readable string.

The array must be stored within a single Formattable object of type kArray. If the Formattable object type is not of type kArray, then returns a failing UErrorCode.

Parameters:
obj  A Formattable of type kArray containing arguments to be formatted.
appendTo  Output parameter to receive result. Result is appended to existing contents.
pos  On input: an alignment field, if desired. On output: the offsets of the alignment field.
status  Input/output error code. If the pattern cannot be parsed, set to failure code.
Returns:
Reference to 'appendTo' parameter.
Stable:
ICU 2.0

Reimplemented from Format.

UnicodeString& MessageFormat::format const UnicodeString   pattern,
const Formattable   arguments,
int32_t    count,
UnicodeString   appendTo,
UErrorCode   status
[static]
 

Formats the given array of arguments into a user-readable string using the given pattern.

Parameters:
pattern  The pattern.
arguments  An array of objects to be formatted.
count  The number of elements of 'source'.
appendTo  Output parameter to receive result. Result is appended to existing contents.
status  Input/output error code. If the pattern cannot be parsed, set to failure code.
Returns:
Reference to 'appendTo' parameter.
Stable:
ICU 2.0

UnicodeString& MessageFormat::format const Formattable   source,
int32_t    count,
UnicodeString   appendTo,
FieldPosition   ignore,
UErrorCode   status
const
 

Formats the given array of arguments into a user-readable string.

Does not take ownership of the Formattable* array or its contents.

Parameters:
source  An array of objects to be formatted.
count  The number of elements of 'source'.
appendTo  Output parameter to receive result. Result is appended to existing contents.
ignore  Not used; inherited from base class API.
status  Input/output error code. If the pattern cannot be parsed, set to failure code.
Returns:
Reference to 'appendTo' parameter.
Stable:
ICU 2.0

const Formattable::Type* MessageFormat::getArgTypeList int32_t &    listCount const [inline, private]
 

Returns array of argument types in the parsed pattern for use in C API.

Only for the use of umsg_vformat(). Not for public consumption.

Parameters:
listCount  Output parameter to receive the size of array
Returns:
The array of formattable types in the pattern
Internal:
For internal use only.

Definition at line 782 of file msgfmt.h.

const DateFormat* MessageFormat::getDefaultDateFormat UErrorCode   const [private]
 

const NumberFormat* MessageFormat::getDefaultNumberFormat UErrorCode   const [private]
 

Method to retrieve default formats (or NULL on failure).

These are semantically const, but may modify *this.

virtual UClassID MessageFormat::getDynamicClassID void    const [virtual]
 

Returns a unique class ID POLYMORPHICALLY.

Pure virtual override. This method is to implement a simple version of RTTI, since not all C++ compilers support genuine RTTI. Polymorphic operator==() and clone() methods call this method.

Returns:
The class ID for this object. All objects of a given class have the same class ID. Objects of other classes have different class IDs.
Stable:
ICU 2.0

Reimplemented from Format.

virtual const Format** MessageFormat::getFormats int32_t &    count const [virtual]
 

Gets an array of subformats of this object.

The returned array should not be deleted by the caller, nor should the pointers within the array. The array and its contents remain valid only until the next call to any method of this class is made with this object. See the class description about format numbering.

Parameters:
count  output parameter to receive the size of the array
Returns:
an array of count Format* objects, or NULL if out of memory. Any or all of the array elements may be NULL.
Stable:
ICU 2.0

virtual Locale MessageFormat::getLocale ULocDataLocaleType    type,
UErrorCode   status
const [virtual]
 

Get the locale for this message format object.

You can choose between valid and actual locale. In the case of message format, both locales are the same as the locale passed during the construction.

Parameters:
type  type of the locale we're looking for (valid or actual)
status  error code for the operation
Returns:
the locale
Draft:
This API has been introduced in ICU 2.8. It is still in draft state and may be modified in a future release.

Reimplemented from Format.

virtual const Locale& MessageFormat::getLocale void    const [virtual]
 

Gets the locale.

This locale is used for fetching default number or date format information.

Returns:
the locale of the object.
Stable:
ICU 2.0

virtual const char* MessageFormat::getLocaleInternal ULocDataLocaleType    type,
UErrorCode   status
const [virtual]
 

Get the locale for this message format object.

You can choose between valid and actual locale. In the case of message format, both locales are the same as the locale passed during the construction.

Parameters:
type  type of the locale we're looking for (valid or actual)
status  error code for the operation
Returns:
the locale
Internal:
For internal use only.

Reimplemented from Format.

UClassID MessageFormat::getStaticClassID void    [static]
 

Return the class ID for this class.

This is useful only for comparing to a return value from getDynamicClassID(). For example:

 .   Base* polymorphic_pointer = createPolymorphicObject();
 .   if (polymorphic_pointer->getDynamicClassID() ==
 .      Derived::getStaticClassID()) ...
 
Returns:
The class ID for all objects of this class.
Stable:
ICU 2.0

void MessageFormat::makeFormat int32_t    offsetNumber,
UnicodeString   segments,
UParseError   parseError,
UErrorCode   success
[private]
 

const MessageFormat& MessageFormat::operator= const MessageFormat &   
 

Assignment operator.

Stable:
ICU 2.0

virtual UBool MessageFormat::operator== const Format   other const [virtual]
 

Returns true if the given Format objects are semantically equal.

Objects of different subclasses are considered unequal.

Parameters:
other  the object to be compared with.
Returns:
true if the given Format objects are semantically equal.
Stable:
ICU 2.0

Reimplemented from Format.

virtual Formattable* MessageFormat::parse const UnicodeString   source,
int32_t &    count,
UErrorCode   status
const [virtual]
 

Parses the given string into an array of output arguments.

Parameters:
source  String to be parsed.
count  Output param to receive size of returned array.
status  Input/output error code. If the pattern cannot be parsed, set to failure code.
Returns:
an array of parsed arguments. The caller owns both the array and its contents.
Stable:
ICU 2.0

virtual Formattable* MessageFormat::parse const UnicodeString   source,
ParsePosition   pos,
int32_t &    count
const [virtual]
 

Parses the given string into an array of output arguments.

Parameters:
source  String to be parsed.
pos  On input, starting position for parse. On output, final position after parse. Unchanged if parse fails.
count  Output parameter to receive the number of arguments parsed.
Returns:
an array of parsed arguments. The caller owns both the array and its contents.
Stable:
ICU 2.0

virtual void MessageFormat::parseObject const UnicodeString   source,
Formattable   result,
ParsePosition   pos
const [virtual]
 

Parses the given string into an array of output arguments stored within a single Formattable of type kArray.

Parameters:
source  The string to be parsed into an object.
result  Formattable to be set to the parse result. If parse fails, return contents are undefined.
pos  On input, starting position for parse. On output, final position after parse. Unchanged if parse fails.
Stable:
ICU 2.0

Reimplemented from Format.

virtual void MessageFormat::setFormat int32_t    formatNumber,
const Format   format
[virtual]
 

Sets one subformat.

See the class description about format numbering. If the number is over the number of formats already set, the item will be ignored.

Parameters:
formatNumber  index of the subformat.
format  the format to be set.
Stable:
ICU 2.0

virtual void MessageFormat::setFormats const Format **    newFormats,
int32_t    cnt
[virtual]
 

Sets subformats.

See the class description about format numbering. Each item in the array is cloned into the internal array. If the call fails because memory cannot be allocated, then this object will remain unchanged.

Stable:
ICU 2.0
Parameters:
newFormats  the new format to be set.
cnt  the size of the array.

virtual void MessageFormat::setLocale const Locale   theLocale [virtual]
 

Sets the locale.

This locale is used for fetching default number or date format information.

Parameters:
theLocale  the new locale value to be set.
Stable:
ICU 2.0

virtual UnicodeString& MessageFormat::toPattern UnicodeString   appendTo const [virtual]
 

Returns a pattern that can be used to recreate this object.

Parameters:
appendTo  Output parameter to receive the pattern. Result is appended to existing contents.
Returns:
Reference to 'appendTo' parameter.
Stable:
ICU 2.0


Friends And Related Function Documentation

friend class MessageFormatAdapter [friend]
 

Definition at line 787 of file msgfmt.h.


Member Data Documentation

int32_t MessageFormat::argTypeCapacity [private]
 

Definition at line 698 of file msgfmt.h.

int32_t MessageFormat::argTypeCount [private]
 

Definition at line 697 of file msgfmt.h.

Formattable::Type* MessageFormat::argTypes [private]
 

A MessageFormat formats an array of arguments.

Each argument has an expected type, based on the pattern. For example, if the pattern contains the subformat "{3,number,integer}", then we expect argument 3 to have type Formattable::kLong. This array needs to grow dynamically if the MessageFormat is modified.

Definition at line 696 of file msgfmt.h.

DateFormat* MessageFormat::defaultDateFormat [private]
 

Definition at line 712 of file msgfmt.h.

NumberFormat* MessageFormat::defaultNumberFormat [private]
 

Default Format objects used when no format is specified and a numeric or date argument is formatted.

These are volatile cache objects maintained only for performance. They do not participate in operator=(), copy constructor(), nor operator==().

Definition at line 711 of file msgfmt.h.

Locale MessageFormat::fLocale [private]
 

Definition at line 620 of file msgfmt.h.

UnicodeString MessageFormat::fPattern [private]
 

Definition at line 621 of file msgfmt.h.

Format** MessageFormat::formatAliases [private]
 

Definition at line 622 of file msgfmt.h.

int32_t MessageFormat::formatAliasesCapacity [private]
 

Definition at line 623 of file msgfmt.h.

int32_t MessageFormat::subformatCapacity [private]
 

Definition at line 686 of file msgfmt.h.

int32_t MessageFormat::subformatCount [private]
 

Definition at line 685 of file msgfmt.h.

Subformat* MessageFormat::subformats [private]
 

A MessageFormat contains an array of subformats.

This array needs to grow dynamically if the MessageFormat is modified.

Definition at line 684 of file msgfmt.h.


The documentation for this class was generated from the following file:
Generated on Mon Nov 24 14:36:39 2003 for ICU 2.8 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001