|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nl.openedge.baritus.ConverterRegistry
Global registry for converters. This serves as the alternative for ConvertUtils. We use this instead of ConvertUtils for the following reasons:
Method Summary | |
void |
clear()
clear all registrations |
void |
deregister(java.lang.Class clazz)
Remove any registered Converter for the specified destination
Class . |
void |
deregister(java.lang.Class clazz,
java.util.Locale locale)
Remove any registered Converter for the specified destination
Class and Locale . |
void |
deregister(LocaleConverter converter)
Remove the instances of registered LocaleConverter |
void |
deregister(java.lang.String key)
Remove any registered Formatter for the specified key |
void |
deregister(java.lang.String key,
java.util.Locale locale)
deregister a global formatter with the given key and locale |
void |
deregisterByConverterClass(java.lang.Class clazz)
Remove all instances registered Converter by class of converter |
static ConverterRegistry |
getInstance()
access to singleton |
static boolean |
isReturnNoopConverterWhenNotFound()
Whether to return a noopConverter as a fallback. |
Converter |
lookup(java.lang.Class clazz)
Look up and return any registered Converter for the specified
destination class. |
Converter |
lookup(java.lang.Class clazz,
java.util.Locale locale)
Look up and return any registered Converter for the specified
destination class and locale. |
Formatter |
lookup(java.lang.String key)
lookup a globally registered formatter |
Formatter |
lookup(java.lang.String key,
java.util.Locale locale)
Look up and return any registered Formatter for the specified
destination key and locale; if there is no registered Formatter, return
null .
|
void |
register(Converter converter,
java.lang.Class clazz)
Register a custom Converter for the specified destination
Class , replacing any previously registered Converter. |
void |
register(Formatter formatter,
java.lang.String key)
register a global formatter with the given key |
void |
register(LocaleConverter converter,
java.lang.Class clazz)
Register a custom LocaleConverter for the specified destination
Class , replacing any previously registered Converter. |
void |
register(LocaleConverter converter,
java.lang.Class clazz,
java.util.Locale locale)
Register a custom LocaleConverter for the specified destination
Class , replacing any previously registered Converter. |
void |
register(LocaleFormatter formatter,
java.lang.String key)
register a global locale aware formatter with the given key |
void |
register(LocaleFormatter formatter,
java.lang.String key,
java.util.Locale locale)
register a global locale aware formatter with the given key and locale |
static void |
setReturnNoopConverterWhenNotFound(boolean b)
Whether to return a noopConverter as a fallback. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static ConverterRegistry getInstance()
public void register(Converter converter, java.lang.Class clazz)
Converter
for the specified destination
Class
, replacing any previously registered Converter.
converter
- Converter to be registeredclazz
- Destination class for conversions performed by this Converterpublic void register(LocaleConverter converter, java.lang.Class clazz)
LocaleConverter
for the specified destination
Class
, replacing any previously registered Converter.
converter
- LocaleConverter to be registeredclazz
- Destination class for conversions performed by this Converterpublic void register(LocaleConverter converter, java.lang.Class clazz, java.util.Locale locale)
LocaleConverter
for the specified destination
Class
, replacing any previously registered Converter.
converter
- LocaleConverter to be registeredclazz
- Destination class for conversions performed by this Converterlocale
- Locale classpublic void register(Formatter formatter, java.lang.String key)
formatter
- the formatterkey
- the key to register the instance of Formatter withpublic void register(LocaleFormatter formatter, java.lang.String key, java.util.Locale locale)
formatter
- the formatterkey
- the key to register the instance of Formatter withlocale
- the localepublic void register(LocaleFormatter formatter, java.lang.String key)
formatter
- the formatterkey
- the key to register the instance of Formatter withpublic void deregister(java.lang.Class clazz, java.util.Locale locale)
Converter
for the specified destination
Class
and Locale
.
clazz
- Class for which to remove a registered Converterpublic void deregister(java.lang.Class clazz)
Converter
for the specified destination
Class
.
clazz
- Class for which to remove a registered Converterpublic void deregisterByConverterClass(java.lang.Class clazz)
Converter
by class of converter
clazz
- Class of converter to remove. Removes all subclasses as well.public void deregister(LocaleConverter converter)
LocaleConverter
converter
- instance of converter to removepublic void deregister(java.lang.String key)
Formatter
for the specified key
key
- key for which to remove a registered Formatterpublic void deregister(java.lang.String key, java.util.Locale locale)
key
- the key of the formatterlocale
- the localepublic void clear()
public Formatter lookup(java.lang.String key)
key
- key of formatter
public Converter lookup(java.lang.Class clazz) throws java.lang.NoSuchMethodException, java.lang.IllegalArgumentException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Converter
for the specified
destination class. If there is no registered Converter, return an
instance of NoopConverter if returnNoopConverterWhenNotFound == true or
else null
.
clazz
- Class for which to return a registered Converter
java.lang.NoSuchMethodException
java.lang.IllegalArgumentException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public Converter lookup(java.lang.Class clazz, java.util.Locale locale) throws java.lang.NoSuchMethodException, java.lang.IllegalArgumentException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Converter
for the specified
destination class and locale. If there is no registered Converter, return an
instance of NoopConverter if returnNoopConverterWhenNotFound == true or
else null
.
Precedence: if a locale is given the first search is for a converter that was
registered for the given type and locale. If it is not found, the second
search is for any converter of the type LocaleConverter that was registered
for the given type. If it is found, a new instance will be created for the
given locale, the pattern will be copied if possible and the newly
instantiated converter will be registered for the given type and locale
(and thus will be found at the first search next time). If it is not found,
the search is the same as when no locale was given (locale == null):
the 'normal', not localized registry will be searched for an entry with
the given type. If still no Converter is found after this, and
returnNoopConverterWhenNotFound is true an instance of NoopConverter is returned,
so that clients allways get a valid converter. If returnNoopConverterWhenNotFound
is false, null will be returned.
clazz
- Class for which to return a registered Converterlocale
- The Locale
java.lang.NoSuchMethodException
java.lang.IllegalArgumentException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public Formatter lookup(java.lang.String key, java.util.Locale locale) throws java.lang.NoSuchMethodException, java.lang.IllegalArgumentException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Formatter
for the specified
destination key and locale; if there is no registered Formatter, return
null
.
Precedence: if a locale is given the first search is for a formatter that was
registered for the given type and locale. If it is not found, the second
search is for any formatter of the type LocaleFormatter that was registered
for the given key. If it is found, a new instance will be created for the
given locale and the newly instantiated formatter will be registered for
the given key and locale
(and thus will be found at the first search next time). If it is not found,
the search is the same as when no locale was given (locale == null):
the 'normal', not localized registry will be searched for an entry with
the given key. If this is not found either, null will be returned.
key
- key that the formatter was registered withlocale
- the Locale
java.lang.NoSuchMethodException
java.lang.IllegalArgumentException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public static boolean isReturnNoopConverterWhenNotFound()
public static void setReturnNoopConverterWhenNotFound(boolean b)
b
- when true, a noopConverter is returned as a fallback. When
false, null is returned
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |