Package com.ibm.icu.message2
Class Mf2FunctionRegistry
java.lang.Object
com.ibm.icu.message2.Mf2FunctionRegistry
Deprecated.
This API is for technology preview only.
This class is used to register mappings between various function
names and the factories that can create those functions.
For example to add formatting for a Person
object one would need to:
- write a function (class, lambda, etc.) that does the formatting proper
(implementing
Formatter
) - write a factory that creates such a function
(implementing
FormatterFactory
) - add a mapping from the function name as used in the syntax
(for example
"person"
) to the factory - optionally add a mapping from the class to format (
...Person.class
) to the formatter name ("person"
), so that one can use a placeholder in the message without specifying a function (for example"... {$me} ..."
instead of"... {$me :person} ..."
, if the class of$me
is aninstanceof Person
).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Deprecated.This API is for technology preview only. -
Method Summary
Modifier and TypeMethodDescriptionstatic Mf2FunctionRegistry.Builder
builder()
Deprecated.This API is for technology preview only.getDefaultFormatterNameForType
(Class<?> clazz) Deprecated.This API is for technology preview only.Deprecated.This API is for technology preview only.getFormatter
(String formatterName) Deprecated.This API is for technology preview only.Deprecated.This API is for technology preview only.getSelector
(String selectorName) Deprecated.This API is for technology preview only.Deprecated.This API is for technology preview only.
-
Method Details
-
builder
Deprecated.This API is for technology preview only.Creates a builder.- Returns:
- the Builder.
-
getFormatter
Deprecated.This API is for technology preview only.Returns the formatter factory used to create the formatter for function namedname
.Note: function name here means the name used to refer to the function in the MessageFormat 2 syntax, for example
"... {$exp :datetime} ..."
The function name here is"datetime"
, and does not have to correspond to the name of the methods / classes used to implement the functionality.For example one might write a
PersonFormatterFactory
returning aPersonFormatter
, and map that to the MessageFormat function named"person"
.
The only name visible to the users of MessageFormat syntax will be"person"
.- Parameters:
formatterName
- the function name.- Returns:
- the factory creating formatters for
name
. Returnsnull
if none is registered.
-
getFormatterNames
Deprecated.This API is for technology preview only.Get all know names that have a mappings from name toFormatterFactory
.- Returns:
- a set of all the known formatter names.
-
getDefaultFormatterNameForType
Deprecated.This API is for technology preview only.Returns the name of the formatter used to format an object of typeclazz
.- Parameters:
clazz
- the class of the object to format.- Returns:
- the name of the formatter class, if registered. Returns
null
otherwise.
-
getDefaultFormatterTypes
Deprecated.This API is for technology preview only.Get all know classes that have a mappings from class to function name.- Returns:
- a set of all the known classes that have mapping to function names.
-
getSelector
Deprecated.This API is for technology preview only.Returns the selector factory used to create the selector for function namedname
.Note: the same comments about naming as the ones on
getFormatter
apply.- Parameters:
selectorName
- the selector name.- Returns:
- the factory creating selectors for
name
. Returnsnull
if none is registered. - See Also:
-
getSelectorNames
Deprecated.This API is for technology preview only.Get all know names that have a mappings from name toSelectorFactory
.- Returns:
- a set of all the known selector names.
-