MessageFormat.Parse Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Parse(String) |
Parses text from the beginning of the given string to produce an object array. |
Parse(String, ParsePosition) |
Parses the string. |
Parse(String)
Parses text from the beginning of the given string to produce an object array.
[Android.Runtime.Register("parse", "(Ljava/lang/String;)[Ljava/lang/Object;", "GetParse_Ljava_lang_String_Handler")]
public virtual Java.Lang.Object[]? Parse (string? source);
[<Android.Runtime.Register("parse", "(Ljava/lang/String;)[Ljava/lang/Object;", "GetParse_Ljava_lang_String_Handler")>]
abstract member Parse : string -> Java.Lang.Object[]
override this.Parse : string -> Java.Lang.Object[]
Parameters
- source
- String
A String
whose beginning should be parsed.
Returns
An Object
array parsed from the string.
- Attributes
Exceptions
if an error occurs during parsing.
Remarks
Parses text from the beginning of the given string to produce an object array. The method may not use the entire text of the given string.
See the #parse(String, ParsePosition)
method for more information on message parsing.
Java documentation for java.text.MessageFormat.parse(java.lang.String)
.
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
Parse(String, ParsePosition)
Parses the string.
[Android.Runtime.Register("parse", "(Ljava/lang/String;Ljava/text/ParsePosition;)[Ljava/lang/Object;", "GetParse_Ljava_lang_String_Ljava_text_ParsePosition_Handler")]
public virtual Java.Lang.Object[]? Parse (string? source, Java.Text.ParsePosition? pos);
[<Android.Runtime.Register("parse", "(Ljava/lang/String;Ljava/text/ParsePosition;)[Ljava/lang/Object;", "GetParse_Ljava_lang_String_Ljava_text_ParsePosition_Handler")>]
abstract member Parse : string * Java.Text.ParsePosition -> Java.Lang.Object[]
override this.Parse : string * Java.Text.ParsePosition -> Java.Lang.Object[]
Parameters
- source
- String
the string to parse
- pos
- ParsePosition
the parse position
Returns
an array of parsed objects
- Attributes
Remarks
Parses the string.
Caveats: The parse may fail in a number of circumstances. For example: <ul> <li>If one of the arguments does not occur in the pattern. <li>If the format of an argument loses information, such as with a choice format where a large number formats to "many". <li>Does not yet handle recursion (where the substituted strings contain {n} references.) <li>Will not always find a match (or the correct match) if some part of the parse is ambiguous. For example, if the pattern "{1},{2}" is used with the string arguments {"a,b", "c"}, it will format as "a,b,c". When the result is parsed, it will return {"a", "b,c"}. <li>If a single argument is parsed more than once in the string, then the later parse wins. </ul> When the parse fails, use ParsePosition.getErrorIndex() to find out where in the string the parsing failed. The returned error index is the starting offset of the sub-patterns that the string is comparing with. For example, if the parsing string "AAA {0} BBB" is comparing against the pattern "AAD {0} BBB", the error index is 0. When an error occurs, the call to this method will return null. If the source is null, return an empty array.
Java documentation for java.text.MessageFormat.parse(java.lang.String, java.text.ParsePosition)
.
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.