|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jidesoft.converter.ObjectConverterManager
public class ObjectConverterManager
ObjectConverterManager
is a center place to register ObjectConverters with a data type and an optional
ConverterContext. The ConverterContext is a switch when you need several different converters for the same data type.
If you only use one ObjectConverter for a particular data type, you can use null as the ConverterContext.
ObjectConverterManager
is used in many places in JIDE products, especially in JIDE Grids where
ContextSensitiveTableModel
adds getCellClassAt (the data type) and getConverterContextAt for each cell
in a table model. We use both values as the key to look up for the ObjectConverter
from
ObjectConverterManager
.
Constructor Summary | |
---|---|
ObjectConverterManager()
|
Method Summary | |
---|---|
static void |
addRegistrationListener(RegistrationListener l)
Adds a listener to the list that's notified each time a change to the manager occurs. |
static void |
clear()
|
static Object |
fromString(String string,
Class<?> clazz)
Converts from a string to an object with type class. |
static Object |
fromString(String string,
Class<?> clazz,
ConverterContext context)
Converts from a string to an object with type class using the converter context. |
static ObjectConverter |
getConverter(Class<?> clazz)
Gets the converter associated with the type. |
static ObjectConverter |
getConverter(Class<?> clazz,
ConverterContext context)
Gets the registered converter associated with class and context. |
static ConverterContext[] |
getConverterContexts(Class<?> clazz)
Gets the available ConverterContexts registered with the class. |
static RegistrationListener[] |
getRegistrationListeners()
Returns an array of all the registration listeners registered on this manager. |
static void |
initDefaultConverter()
Initialize default converters. |
static boolean |
isAutoInit()
Checks the value of autoInit. |
static void |
registerConverter(Class<?> clazz,
ObjectConverter converter)
Registers as the default converter with type specified as clazz. |
static void |
registerConverter(Class<?> clazz,
ObjectConverter converter,
ConverterContext context)
Registers a converter with the type specified as class and a converter context specified as context. |
static void |
removeRegistrationListener(RegistrationListener l)
Removes a listener from the list that's notified each time a change to the manager occurs. |
static void |
resetInit()
If initDefaultConverter() is called once, calling it again will have no effect because an internal flag
is set. |
static void |
setAutoInit(boolean autoInit)
Sets autoInit to true or false. |
static String |
toString(Object object)
Converts an object to string using default converter context. |
static String |
toString(Object object,
Class<?> clazz)
Converts an object to string using default converter context. |
static String |
toString(Object object,
Class<?> clazz,
ConverterContext context)
Converts an object to string using converter context specified. |
static void |
unregisterAllConverters()
Unregisters all the converters which registered before. |
static void |
unregisterAllConverters(Class<?> clazz)
Unregisters all converters associated with the class. |
static void |
unregisterConverter(Class<?> clazz)
Unregisters converter associated with the class. |
static void |
unregisterConverter(Class<?> clazz,
ConverterContext context)
Unregisters converter associated with clazz and context. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ObjectConverterManager()
Method Detail |
---|
public static void registerConverter(Class<?> clazz, ObjectConverter converter, ConverterContext context)
clazz
- the type of which the converter will registered.converter
- the converter to be registeredcontext
- the converter context.public static void registerConverter(Class<?> clazz, ObjectConverter converter)
clazz
- the type of which the converter will be registered.converter
- the converter to be registeredpublic static void unregisterConverter(Class<?> clazz, ConverterContext context)
clazz
- the type of which the converter will be unregistered.context
- the converter context.public static void unregisterConverter(Class<?> clazz)
clazz
- the type of which the converter will be unregistered.public static void unregisterAllConverters(Class<?> clazz)
clazz
- the type of which the converter will be unregistered.public static void unregisterAllConverters()
public static ObjectConverter getConverter(Class<?> clazz, ConverterContext context)
clazz
- the type of which the converter will be registered.context
- the converter context.
public static ObjectConverter getConverter(Class<?> clazz)
clazz
- type
public static String toString(Object object)
object
- object to be converted.
public static String toString(Object object, Class<?> clazz)
object
- object to be converted.clazz
- type of the object
public static String toString(Object object, Class<?> clazz, ConverterContext context)
object
- object to be converted.clazz
- type of the objectcontext
- converter context
public static Object fromString(String string, Class<?> clazz)
string
- the string to be convertedclazz
- the type to be converted to
public static Object fromString(String string, Class<?> clazz, ConverterContext context)
string
- the string to be convertedclazz
- the type to be converted tocontext
- converter context to be used
public static boolean isAutoInit()
setAutoInit(boolean)
public static void setAutoInit(boolean autoInit)
initDefaultConverter()
will be called if it has never be called. By default, autoInit is
true.
This might affect the behavior if users provide their own converters and want to overwrite default converters. In
this case, instead of depending on autoInit to initialize default converters, you should call initDefaultConverter()
first, then call registerConverter to add your own converters.
autoInit
- true or false.public static void addRegistrationListener(RegistrationListener l)
l
- the RegistrationListenerpublic static void removeRegistrationListener(RegistrationListener l)
l
- the RegistrationListenerpublic static RegistrationListener[] getRegistrationListeners()
RegistrationListener
s or an empty array if no registration
listeners are currently registeredaddRegistrationListener(com.jidesoft.utils.RegistrationListener)
,
removeRegistrationListener(com.jidesoft.utils.RegistrationListener)
public static ConverterContext[] getConverterContexts(Class<?> clazz)
clazz
- the class.
public static void initDefaultConverter()
public static void resetInit()
initDefaultConverter()
is called once, calling it again will have no effect because an internal flag
is set. This method will reset the internal flag so that you can call initDefaultConverter()
in case
you unregister all converters using unregisterAllConverters()
.
public static void clear()
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |