MessagePattern Class
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.
Parses and represents ICU MessageFormat patterns.
[Android.Runtime.Register("android/icu/text/MessagePattern", ApiSince=24, DoNotGenerateAcw=true)]
public sealed class MessagePattern : Java.Lang.Object, Android.Icu.Util.IFreezable, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/icu/text/MessagePattern", ApiSince=24, DoNotGenerateAcw=true)>]
type MessagePattern = class
inherit Object
interface IFreezable
interface ICloneable
interface IJavaObject
interface IDisposable
interface IJavaPeerable
- Inheritance
- Attributes
- Implements
Remarks
Parses and represents ICU MessageFormat patterns. Also handles patterns for ChoiceFormat, PluralFormat and SelectFormat. Used in the implementations of those classes as well as in tools for message validation, translation and format conversion.
The parser handles all syntax relevant for identifying message arguments. This includes "complex" arguments whose style strings contain nested MessageFormat pattern substrings. For "simple" arguments (with no nested MessageFormat pattern substrings), the argument style is not parsed any further.
The parser handles named and numbered message arguments and allows both in one message.
Once a pattern has been parsed successfully, iterate through the parsed data with countParts(), getPart() and related methods.
The data logically represents a parse tree, but is stored and accessed as a list of "parts" for fast and simple parsing and to minimize object allocations. Arguments and nested messages are best handled via recursion. For every _START "part", #getLimitPartIndex(int)
efficiently returns the index of the corresponding _LIMIT "part".
List of "parts":
message = MSG_START (SKIP_SYNTAX | INSERT_CHAR | REPLACE_NUMBER | argument)* MSG_LIMIT
argument = noneArg | simpleArg | complexArg
complexArg = choiceArg | pluralArg | selectArg
noneArg = ARG_START.NONE (ARG_NAME | ARG_NUMBER) ARG_LIMIT.NONE
simpleArg = ARG_START.SIMPLE (ARG_NAME | ARG_NUMBER) ARG_TYPE [ARG_STYLE] ARG_LIMIT.SIMPLE
choiceArg = ARG_START.CHOICE (ARG_NAME | ARG_NUMBER) choiceStyle ARG_LIMIT.CHOICE
pluralArg = ARG_START.PLURAL (ARG_NAME | ARG_NUMBER) pluralStyle ARG_LIMIT.PLURAL
selectArg = ARG_START.SELECT (ARG_NAME | ARG_NUMBER) selectStyle ARG_LIMIT.SELECT
choiceStyle = ((ARG_INT | ARG_DOUBLE) ARG_SELECTOR message)+
pluralStyle = [ARG_INT | ARG_DOUBLE] (ARG_SELECTOR [ARG_INT | ARG_DOUBLE] message)+
selectStyle = (ARG_SELECTOR message)+
<ul> <li>Literal output text is not represented directly by "parts" but accessed between parts of a message, from one part's getLimit() to the next part's getIndex(). <li>ARG_START.CHOICE
stands for an ARG_START Part with ArgType CHOICE. <li>In the choiceStyle, the ARG_SELECTOR has the '<', the '#' or the less-than-or-equal-to sign (U+2264). <li>In the pluralStyle, the first, optional numeric Part has the "offset:" value. The optional numeric Part between each (ARG_SELECTOR, message) pair is the value of an explicit-number selector like "=2", otherwise the selector is a non-numeric identifier. <li>The REPLACE_NUMBER Part can occur only in an immediate sub-message of the pluralStyle. </ul>
This class is not intended for public subclassing.
Java documentation for android.icu.text.MessagePattern
.
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.
Constructors
MessagePattern() |
Constructs an empty MessagePattern with default ApostropheMode. |
MessagePattern(MessagePattern+ApostropheMode) | |
MessagePattern(String) |
Constructs a MessagePattern with default ApostropheMode and parses the MessageFormat pattern string. |
Fields
ArgNameNotNumber |
Return value from |
ArgNameNotValid |
Return value from |
NoNumericValue |
Special value that is returned by getNumericValue(Part) when no numeric value is defined for a part. |
Properties
Class |
Returns the runtime class of this |
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
HasNamedArguments |
Does the parsed pattern have named arguments like {first_name}? |
HasNumberedArguments |
Does the parsed pattern have numbered arguments like {2}? |
IsFrozen |
Determines whether this object is frozen (immutable) or not. |
JniIdentityHashCode | (Inherited from Object) |
JniPeerMembers | |
PatternString | |
PeerReference | (Inherited from Object) |
ThresholdClass |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. (Inherited from Object) |
ThresholdType |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. (Inherited from Object) |
Methods
AutoQuoteApostropheDeep() |
Returns a version of the parsed pattern string where each ASCII apostrophe is doubled (escaped) if it is not already, and if it is not interpreted as quoting syntax. |
Clear() |
Clears this MessagePattern. |
ClearPatternAndSetApostropheMode(MessagePattern+ApostropheMode) | |
Clone() |
Creates and returns a copy of this object. |
CloneAsThawed() |
Creates and returns an unfrozen copy of this object. |
CountParts() |
Returns the number of "parts" created by parsing the pattern string. |
Dispose() | (Inherited from Object) |
Dispose(Boolean) | (Inherited from Object) |
Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
Freeze() |
Freezes this object, making it immutable and thread-safe. |
GetApostropheMode() | |
GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
GetLimitPartIndex(Int32) |
Returns the index of the ARG|MSG_LIMIT part corresponding to the ARG|MSG_START at start. |
GetNumericValue(MessagePattern+Part) | |
GetPart(Int32) | |
GetPartType(Int32) | |
GetPatternIndex(Int32) |
Returns the pattern index of the specified pattern "part". |
GetPluralOffset(Int32) |
Returns the "offset:" value of a PluralFormat argument, or 0 if none is specified. |
GetSubstring(MessagePattern+Part) | |
JavaFinalize() |
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. (Inherited from Object) |
Notify() |
Wakes up a single thread that is waiting on this object's monitor. (Inherited from Object) |
NotifyAll() |
Wakes up all threads that are waiting on this object's monitor. (Inherited from Object) |
Parse(String) |
Parses a MessageFormat pattern string. |
ParseChoiceStyle(String) |
Parses a ChoiceFormat pattern string. |
ParsePluralStyle(String) |
Parses a PluralFormat pattern string. |
ParseSelectStyle(String) |
Parses a SelectFormat pattern string. |
PartSubstringMatches(MessagePattern+Part, String) | |
SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
ToArray<T>() | (Inherited from Object) |
ToString() |
Returns a string representation of the object. (Inherited from Object) |
UnregisterFromRuntime() | (Inherited from Object) |
ValidateArgumentName(String) |
Validates and parses an argument name or argument number string. |
Wait() |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>. (Inherited from Object) |
Wait(Int64, Int32) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Wait(Int64) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Explicit Interface Implementations
IFreezable.CloneAsThawed() | |
IFreezable.Freeze() | |
IJavaPeerable.Disposed() | (Inherited from Object) |
IJavaPeerable.DisposeUnlessReferenced() | (Inherited from Object) |
IJavaPeerable.Finalized() | (Inherited from Object) |
IJavaPeerable.JniManagedPeerState | (Inherited from Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from Object) |
Extension Methods
JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
JavaCast<TResult>(IJavaObject) | |
GetJniTypeName(IJavaPeerable) |
Gets the JNI name of the type of the instance |
JavaAs<TResult>(IJavaPeerable) |
Try to coerce |
TryJavaCast<TResult>(IJavaPeerable, TResult) |
Try to coerce |