Package com.ibm.icu.message2
Class MFDataModelFormatter
java.lang.Object
com.ibm.icu.message2.MFDataModelFormatter
Takes an
MFDataModel
and formats it to a String
(and later on we will also implement formatting to a FormattedMessage
).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
(package private) static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MFFunctionRegistry
private final MFDataModel.Message
private static final MFFunctionRegistry
private final MessageFormatter.ErrorHandlingBehavior
private final Locale
private final MFFunctionRegistry
-
Constructor Summary
ConstructorsConstructorDescriptionMFDataModelFormatter
(MFDataModel.Message dm, Locale locale, MessageFormatter.ErrorHandlingBehavior errorHandlingBehavior, MFFunctionRegistry customFunctionRegistry) -
Method Summary
Modifier and TypeMethodDescriptionconvertOptions
(Map<String, MFDataModel.Option> options, Map<String, Object> localVars, Map<String, Object> arguments) private static void
fatalFormattingError
(String message) private MFDataModel.Pattern
findBestMatchingPattern
(MFDataModel.SelectMessage sm, Map<String, Object> variables, Map<String, Object> arguments) (package private) String
private FormattedPlaceholder
formatExpression
(MFDataModel.Expression expression, Map<String, Object> variables, Map<String, Object> arguments) Formats an expression.private FormatterFactory
getFormattingFunctionFactoryByName
(Object toFormat, String functionName) spec: The method MatchSelectorKeys is determined by the implementation.resolveDeclarations
(List<MFDataModel.Declaration> declarations, Map<String, Object> arguments) private static Object
resolveLiteralOrVariable
(MFDataModel.LiteralOrVariableRef value, Map<String, Object> localVars, Map<String, Object> arguments) private static int
-
Field Details
-
locale
-
errorHandlingBehavior
-
dm
-
standardFunctions
-
customFunctions
-
EMPTY_REGISTY
-
-
Constructor Details
-
MFDataModelFormatter
MFDataModelFormatter(MFDataModel.Message dm, Locale locale, MessageFormatter.ErrorHandlingBehavior errorHandlingBehavior, MFFunctionRegistry customFunctionRegistry)
-
-
Method Details
-
format
-
findBestMatchingPattern
private MFDataModel.Pattern findBestMatchingPattern(MFDataModel.SelectMessage sm, Map<String, Object> variables, Map<String, Object> arguments) -
sortVariants
private static int sortVariants(MFDataModelFormatter.IntVarTuple o1, MFDataModelFormatter.IntVarTuple o2) -
matchSelectorKeys
spec: The method MatchSelectorKeys is determined by the implementation. It takes as arguments a resolved _selector_ value `rv` and a list of string keys `keys`, and returns a list of string keys in preferential order. The returned list MUST contain only unique elements of the input list `keys`. The returned list MAY be empty. The most-preferred key is first, with each successive key appearing in order by decreasing preference. -
fatalFormattingError
- Throws:
IllegalArgumentException
-
getFormattingFunctionFactoryByName
-
resolveLiteralOrVariable
-
convertOptions
-
formatExpression
private FormattedPlaceholder formatExpression(MFDataModel.Expression expression, Map<String, Object> variables, Map<String, Object> arguments) Formats an expression.- Parameters:
expression
- the expression to formatvariables
- local variables, created from declarations (`.input` and `.local`)arguments
- the arguments passed at runtime to be formatted (`mf.format(arguments)`)
-
resolveDeclarations
-