다음을 통해 공유


MessageFormat.Format Method

Definition

Overloads

Format(String, Object[])
Format(String, IDictionary<String,Object>)

Creates a MessageFormat with the given pattern and uses it to format the given arguments.

Format(Object, StringBuffer, FieldPosition)

Formats a map or array of objects and appends the MessageFormat's pattern, with format elements replaced by the formatted objects, to the provided StringBuffer.

Format(Object[], StringBuffer, FieldPosition)

Formats an array of objects and appends the MessageFormat's pattern, with arguments replaced by the formatted objects, to the provided StringBuffer.

Format(IDictionary<String,Object>, StringBuffer, FieldPosition)

Formats a map of objects and appends the MessageFormat's pattern, with arguments replaced by the formatted objects, to the provided StringBuffer.

Format(String, Object[])

[Android.Runtime.Register("format", "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;", "", ApiSince=24)]
public static string? Format (string? pattern, params Java.Lang.Object[]? arguments);
[<Android.Runtime.Register("format", "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;", "", ApiSince=24)>]
static member Format : string * Java.Lang.Object[] -> string

Parameters

pattern
String
arguments
Object[]

Returns

Attributes

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Format(String, IDictionary<String,Object>)

Creates a MessageFormat with the given pattern and uses it to format the given arguments.

[Android.Runtime.Register("format", "(Ljava/lang/String;Ljava/util/Map;)Ljava/lang/String;", "", ApiSince=24)]
public static string? Format (string? pattern, System.Collections.Generic.IDictionary<string,Java.Lang.Object>? arguments);
[<Android.Runtime.Register("format", "(Ljava/lang/String;Ljava/util/Map;)Ljava/lang/String;", "", ApiSince=24)>]
static member Format : string * System.Collections.Generic.IDictionary<string, Java.Lang.Object> -> string

Parameters

pattern
String

Returns

Attributes

Remarks

Creates a MessageFormat with the given pattern and uses it to format the given arguments. The pattern must identifyarguments by name instead of by number.

Java documentation for android.icu.text.MessageFormat.format(java.lang.String, java.util.Map<java.lang.String, java.lang.Object>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Format(Object, StringBuffer, FieldPosition)

Formats a map or array of objects and appends the MessageFormat's pattern, with format elements replaced by the formatted objects, to the provided StringBuffer.

[Android.Runtime.Register("format", "(Ljava/lang/Object;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "", ApiSince=24)]
public override sealed Java.Lang.StringBuffer? Format (Java.Lang.Object? arguments, Java.Lang.StringBuffer? result, Java.Text.FieldPosition? pos);
[<Android.Runtime.Register("format", "(Ljava/lang/Object;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "", ApiSince=24)>]
override this.Format : Java.Lang.Object * Java.Lang.StringBuffer * Java.Text.FieldPosition -> Java.Lang.StringBuffer

Parameters

arguments
Object

a map or array of objects to be formatted

result
StringBuffer

where text is appended

pos
FieldPosition

On input: an alignment field, if desired On output: the offsets of the alignment field

Returns

Attributes

Remarks

Formats a map or array of objects and appends the MessageFormat's pattern, with format elements replaced by the formatted objects, to the provided StringBuffer. This is equivalent to either of <blockquote> {@link #format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition) format}((Object[]) arguments, result, pos){@link #format(java.util.Map, java.lang.StringBuffer, java.text.FieldPosition) format}((Map) arguments, result, pos)</blockquote> A map must be provided if this format uses named arguments, otherwise an IllegalArgumentException will be thrown.

Java documentation for android.icu.text.MessageFormat.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Format(Object[], StringBuffer, FieldPosition)

Formats an array of objects and appends the MessageFormat's pattern, with arguments replaced by the formatted objects, to the provided StringBuffer.

[Android.Runtime.Register("format", "([Ljava/lang/Object;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "", ApiSince=24)]
public Java.Lang.StringBuffer? Format (Java.Lang.Object[]? arguments, Java.Lang.StringBuffer? result, Java.Text.FieldPosition? pos);
[<Android.Runtime.Register("format", "([Ljava/lang/Object;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "", ApiSince=24)>]
override this.Format : Java.Lang.Object[] * Java.Lang.StringBuffer * Java.Text.FieldPosition -> Java.Lang.StringBuffer

Parameters

arguments
Object[]

an array of objects to be formatted and substituted.

result
StringBuffer

where text is appended.

pos
FieldPosition

On input: an alignment field, if desired. On output: the offsets of the alignment field.

Returns

Attributes

Remarks

Formats an array of objects and appends the MessageFormat's pattern, with arguments replaced by the formatted objects, to the provided StringBuffer.

The text substituted for the individual format elements is derived from the current subformat of the format element and the arguments element at the format element's argument index as indicated by the first matching line of the following table. An argument is unavailable if arguments is null or has fewer than argumentIndex+1 elements. When an argument is unavailable no substitution is performed.

<table border=1> <tr> <th>argType or Format <th>value object <th>Formatted Text <tr> <td>any<td>unavailable<td>"{" + argNameOrNumber + "}"<tr> <td>any<td>null<td>"null"<tr> <td>custom Format != null<td>any<td>customFormat.format(argument)<tr> <td>noneArg, or custom Format == null<td>instanceof Number<td>NumberFormat.getInstance(getLocale()).format(argument)<tr> <td>noneArg, or custom Format == null<td>instanceof Date<td>DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, getLocale()).format(argument)<tr> <td>noneArg, or custom Format == null<td>instanceof String<td>argument<tr> <td>noneArg, or custom Format == null<td>any<td>argument.toString()<tr> <td>complexArg <td>any<td>result of recursive formatting of a selected sub-message </table>

If pos is non-null, and refers to Field.ARGUMENT, the location of the first formatted string will be returned.

This method is only supported when the format does not use named arguments, otherwise an IllegalArgumentException is thrown.

Java documentation for android.icu.text.MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Format(IDictionary<String,Object>, StringBuffer, FieldPosition)

Formats a map of objects and appends the MessageFormat's pattern, with arguments replaced by the formatted objects, to the provided StringBuffer.

[Android.Runtime.Register("format", "(Ljava/util/Map;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "", ApiSince=24)]
public Java.Lang.StringBuffer? Format (System.Collections.Generic.IDictionary<string,Java.Lang.Object>? arguments, Java.Lang.StringBuffer? result, Java.Text.FieldPosition? pos);
[<Android.Runtime.Register("format", "(Ljava/util/Map;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;", "", ApiSince=24)>]
override this.Format : System.Collections.Generic.IDictionary<string, Java.Lang.Object> * Java.Lang.StringBuffer * Java.Text.FieldPosition -> Java.Lang.StringBuffer

Parameters

arguments
IDictionary<String,Object>

a map of objects to be formatted and substituted.

result
StringBuffer

where text is appended.

pos
FieldPosition

On input: an alignment field, if desired. On output: the offsets of the alignment field.

Returns

the passed-in StringBuffer

Attributes

Remarks

Formats a map of objects and appends the MessageFormat's pattern, with arguments replaced by the formatted objects, to the provided StringBuffer.

The text substituted for the individual format elements is derived from the current subformat of the format element and the arguments value corresponding to the format element's argument name.

A numbered pattern argument is matched with a map key that contains that number as an ASCII-decimal-digit string (without leading zero).

An argument is unavailable if arguments is null or does not have a value corresponding to an argument name in the pattern. When an argument is unavailable no substitution is performed.

Java documentation for android.icu.text.MessageFormat.format(java.util.Map<java.lang.String, java.lang.Object>, java.lang.StringBuffer, java.text.FieldPosition).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to