OverviewSingleDeprecatedPropertiesEventsXSL Parameters

jsx3.util

class MessageFormat

Object
->jsx3.lang.Object
  ->jsx3.util.MessageFormat

class MessageFormat
extends jsx3.lang.Object
Constructs messages from a pattern and parameters. A message format takes a list of arguments, formats them, and inserts them into the pattern at specific places.

Replacement tokens are delimited with curly braces. Tokens begin with an integer, which determines the format parameter that is inserted in place of the token. The following tokens are supported where n is the zero-based parameter index: The formatting of date, time, datetime, and number tokens depends on the locale of the message format. The formats used to format such tokens inherit their locale from the message format. If no locale is passed to the message format constructor, the default system locale is used.

Within a format, single quotes (') delimit quoted sequences that are not parsed for tokens. Therefore, in order to insert a curly bracket in a message format, it should be surrounded by single quotes: new MessageFormat("A curly bracket: '{'"). To insert a single quote character, use two single quotes in succession: new MessageFormat("A single quote: ''").

Since:

3.2

See Also:

jsx3.util.NumberFormat, jsx3.util.DateFormat

Constructor Summary
void
init(strFormat : String, objLocale : jsx3.util.Locale)
The instance initializer.
Method Summary
String
format(args : Object... | Array<Object>)
Formats a collection of objects according to this message format.
jsx3.util.Locale
Returns the locale of this message format.
void
Sets the locale of this message format.
String
Methods Inherited From jsx3.lang.Object
clone, equals, eval, getClass, getInstanceOf, getInstanceOfClass, getInstanceOfPackage, instanceOf, isInstanceOf, isSubclassOf, jsxmix, jsxsuper, jsxsupermix, setInstanceOf
Constructor Detail

init

void init(strFormat : String, objLocale : jsx3.util.Locale)
The instance initializer.

Parameters:

strFormatthe format pattern.
objLocalethe locale of the format. The locale affects how numbers and dates are formatted. If this parameter is omitted, the system locale is used.

Throws:

{jsx3.lang.Exception}if strFormat cannot be parsed.
Method Detail

format

String format(args : Object... | Array<Object>)
Formats a collection of objects according to this message format.

Parameters:

argsthe argument objects. Replacement tokens of the pattern of this format will be replaced by these arguments.

Returns:

the string resulting from the pattern and arguments.  

getLocale

jsx3.util.Locale getLocale()
Returns the locale of this message format.

Returns:

 

setLocale

void setLocale(objLocale : jsx3.util.Locale)
Sets the locale of this message format.

Parameters:

objLocale

toString

String toString()

Returns:

 

Overrides:

toString in jsx3.lang.Object