public abstract class DefaultFormatterFactory
extends java.lang.Object
This factory is called by FormattedText
when a value is setted
and no formatter has been provided by constructor or setFormatter()
.
The default formatter is based on the class of the value. The cache is
searched first for the exact value's class. If no formatter is found, then
it is searched for any class that is an ancestor of the value's class.
The cache is a HashMap
and the order of search cannot be
garanteed. The first valid ancestor found is returned.
Default formatters provided by the factory are:
DateFormatter
for Date
valuesNumberFormatter
for Number
valuesregister()
method. Each
formatter class must implement ITextFormatter
and must have a
default constructor.This class is not intended to be instanciated.
Modifier and Type | Method and Description |
---|---|
static ITextFormatter |
createFormatter(java.lang.Class<? extends java.lang.Object> c)
Creates a new default formatter for the given class.
|
static ITextFormatter |
createFormatter(java.lang.Object value)
Creates a new default formatter for the given value.
|
static void |
register(java.lang.Class<?> c,
java.lang.Class<?> f)
Registers a new formatter class for a given class of values.
|
public static ITextFormatter createFormatter(java.lang.Object value)
value
- Value for which to create a formatterpublic static ITextFormatter createFormatter(java.lang.Class<? extends java.lang.Object> c)
c
- Class for which to create a formatterpublic static void register(java.lang.Class<?> c, java.lang.Class<?> f)
ITextFormatter
interface.c
- Class of valuesf
- Class of the formatter