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 classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MFFunctionRegistryprivate final MFDataModel.Messageprivate static final MFFunctionRegistryprivate final Localeprivate final MFFunctionRegistry -
Constructor Summary
ConstructorsConstructorDescriptionMFDataModelFormatter(MFDataModel.Message dm, Locale locale, MFFunctionRegistry customFunctionRegistry) -
Method Summary
Modifier and TypeMethodDescriptionconvertOptions(Map<String, MFDataModel.Option> options, Map<String, Object> localVars, Map<String, Object> arguments) private MFDataModel.PatternfindBestMatchingPattern(MFDataModel.SelectMessage sm, Map<String, Object> variables, Map<String, Object> arguments) (package private) Stringprivate FormattedPlaceholderformatExpression(MFDataModel.Expression expression, Map<String, Object> variables, Map<String, Object> arguments) Formats an expression.private static voidformattingError(String message) private FormatterFactorygetFormattingFunctionFactoryByName(Object toFormat, String functionName) spec: The method MatchSelectorKeys is determined by the implementation.resolveDeclarations(List<MFDataModel.Declaration> declarations, Map<String, Object> arguments) private static ObjectresolveLiteralOrVariable(MFDataModel.LiteralOrVariableRef value, Map<String, Object> localVars, Map<String, Object> arguments) private static int
-
Field Details
-
locale
-
dm
-
standardFunctions
-
customFunctions
-
EMPTY_REGISTY
-
-
Constructor Details
-
MFDataModelFormatter
MFDataModelFormatter(MFDataModel.Message dm, Locale locale, 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. -
formattingError
-
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
-