Class MessageFormatter.Builder
java.lang.Object
com.ibm.icu.message2.MessageFormatter.Builder
- Enclosing class:
MessageFormatter
A
Builder used to build instances of MessageFormatter.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate MessageFormatter.BidiIsolationprivate MFDataModel.Messageprivate MFFunctionRegistryprivate Localeprivate String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds an instance ofMessageFormatter.setBidiIsolation(MessageFormatter.BidiIsolation bidiIsolation) Sets theMessageFormatter.BidiIsolationto introduce bidi control characters / tags as described in the MessageFormat 2 specification.setDataModel(MFDataModel.Message dataModel) Deprecated.This API is for technology preview only.setErrorHandlingBehavior(MessageFormatter.ErrorHandlingBehavior errorHandlingBehavior) Sets theMessageFormatter.ErrorHandlingBehaviorto use when encountering errors at formatting time.setFunctionRegistry(MFFunctionRegistry functionRegistry) Deprecated.This API is for technology preview only.Sets the locale to use for all formatting and selection operations.setPattern(String pattern) Sets the pattern (in MessageFormat 2 syntax) used to create the message.
It conflicts with the data model, so it will reset it (the last call on setter wins).
-
Field Details
-
locale
-
pattern
-
errorHandlingBehavior
-
bidiIsolation
-
functionRegistry
-
dataModel
-
-
Constructor Details
-
Builder
private Builder()
-
-
Method Details
-
setLocale
Sets the locale to use for all formatting and selection operations.- Parameters:
locale- the locale to set.- Returns:
- the builder, for fluent use.
-
setPattern
Sets the pattern (in MessageFormat 2 syntax) used to create the message.
It conflicts with the data model, so it will reset it (the last call on setter wins).- Parameters:
pattern- the pattern to set.- Returns:
- the builder, for fluent use.
-
setErrorHandlingBehavior
public MessageFormatter.Builder setErrorHandlingBehavior(MessageFormatter.ErrorHandlingBehavior errorHandlingBehavior) Sets theMessageFormatter.ErrorHandlingBehaviorto use when encountering errors at formatting time.The default value is
ErrorHandlingBehavior.BEST_EFFORT, trying to fallback.- Parameters:
errorHandlingBehavior- the error handling behavior to use.- Returns:
- the builder, for fluent use.
-
setBidiIsolation
Sets theMessageFormatter.BidiIsolationto introduce bidi control characters / tags as described in the MessageFormat 2 specification.The default value is
BidiIsolation.NONE.- Parameters:
bidiIsolation- the bidi isolation algorithm to use.- Returns:
- the builder, for fluent use.
-
setFunctionRegistry
@Deprecated public MessageFormatter.Builder setFunctionRegistry(MFFunctionRegistry functionRegistry) Deprecated.This API is for technology preview only.Sets an instance ofMFFunctionRegistrythat should register any custom functions used by the message.There is no need to do this in order to use standard functions (for example date / time / number formatting, plural / ordinal / literal selection).
The exact set of standard functions, with the types they format and the options they accept is still TBD.- Parameters:
functionRegistry- the function registry to set.- Returns:
- the builder, for fluent use.
-
setDataModel
Deprecated.This API is for technology preview only.Sets the data model used to create the message.
It conflicts with the pattern, so it will reset it (the last call on setter wins).- Parameters:
dataModel- the pattern to set.- Returns:
- the builder, for fluent use.
-
build
Builds an instance ofMessageFormatter.- Returns:
- the
MessageFormattercreated.
-