|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.abstractics.utils.converter.Converter
Singleton that can translate objects into other objects. Conversion is
handled through
com.abstractics.xmlpanel.utils.stringtoobject.ObjectConverter
objects
that can be loaded into this class.
The following classes are supported and pre-loaded into the converter upon
startup:
Method Summary | |
static void |
addConstant(java.lang.Object obj,
java.lang.Class convertInto,
java.lang.Object value)
Gives the ability to have the ConvertObject return "static" values for certain conversion classes and values. |
static java.lang.Object |
convert(java.lang.Object obj,
java.lang.Class convertInto)
Chained method that calls convert(Object, Class, Locale) with
the default locale returned from Locale.getDefault() |
static java.lang.Object |
convert(java.lang.Object obj,
java.lang.Class convertInto,
java.util.Locale locale)
Converts the given object into an instance of the given class, using ObjectConverter s that have been registered. |
static boolean |
convertToBoolean(java.lang.Object obj)
Convenience method to return a primative boolean from conversion |
static double |
convertToDouble(java.lang.Object obj)
Convenience method to return a primative double from conversion |
static int |
convertToInt(java.lang.Object obj)
Convenience method to return a primative int from conversion |
static long |
convertToLong(java.lang.Object obj)
Convenience method to return a primative long from conversion |
static void |
deregister(java.lang.Class forClass)
Any ObjectConverters that are registered to convert into the class given are removed. |
static void |
register(ObjectConverter converter)
Registers the given ObjectConverter |
static void |
registerResourceBaseName(java.lang.String baseName)
Registers the base name for a ResourceBundle that
should be used for String replacement operations. |
static void |
reset()
Resets the state of the converter to have the defaults. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static java.lang.Object convert(java.lang.Object obj, java.lang.Class convertInto) throws ObjectConverterException
convert(Object, Class, Locale)
with
the default locale returned from Locale.getDefault()
obj
- Object to convertconvertInto
- Class to convert into
ObjectConverterException
- Thrown if conversion is not possible
java.lang.IllegalArgumentException
- Thrown if convertInto
is nullpublic static java.lang.Object convert(java.lang.Object obj, java.lang.Class convertInto, java.util.Locale locale) throws ObjectConverterException
ObjectConverter
s that have been registered.
obj
- Object to convertconvertInto
- Class to convert intolocale
- Locale to use for conversion. This locale is used as the basis
for string replacement with any registered resource base
names. The locale is also passed to the ObjectConverter in
case locale specific conversion is necessary
ObjectConverterException
- Thrown if conversion is not possible
java.lang.IllegalArgumentException
- Thrown if convertInto
is nullpublic static boolean convertToBoolean(java.lang.Object obj) throws ObjectConverterException
obj
- Object to convert
false
is returned
ObjectConverterException
- Thrown if conversion is not possiblepublic static int convertToInt(java.lang.Object obj) throws ObjectConverterException
obj
- Object to convert
0
is returned
ObjectConverterException
- Thrown if conversion is not possiblepublic static long convertToLong(java.lang.Object obj) throws ObjectConverterException
obj
- Object to convert
0
is returned
ObjectConverterException
- Thrown if conversion is not possiblepublic static double convertToDouble(java.lang.Object obj) throws ObjectConverterException
obj
- Object to convert
0.0
is returned
ObjectConverterException
- Thrown if conversion is not possiblepublic static void register(ObjectConverter converter)
converter
- Converter to registerpublic static void registerResourceBaseName(java.lang.String baseName)
ResourceBundle
that
should be used for String replacement operations. Strings that are sent
into the converter with $R{resourcekey} text will have that text replaces
according to the Resource.
baseName
- public static void deregister(java.lang.Class forClass)
forClass
- Class to remove ObjectConverters forpublic static void reset()
public static void addConstant(java.lang.Object obj, java.lang.Class convertInto, java.lang.Object value)
addConstant("companyLogo", Icon.class, new ImageIcon("Foo"))
obj
- Object that should trigger use of the constant (in
coordination with the convertInto
class)convertInto
- Class that should trigger use of the constant (in coordination
with the obj
Object)value
- The value that should be returned for this constant
java.lang.IllegalArgumentException
- Thrown if the object or class provided is null
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |