Package adams.data.spreadsheet
Class AbstractObjectHandler<T>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.spreadsheet.AbstractObjectHandler<T>
-
- Type Parameters:
T
- the type of object to handle
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,Serializable
- Direct Known Subclasses:
JsonObjectHandler
,StringObjectHandler
public abstract class AbstractObjectHandler<T> extends AbstractOptionHandler
Ancestor for handlers that manage theCell.ContentType.OBJECT
type of cells.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static HashMap<Class,Class>
m_Handlers
the cache for object class/object handler relation.protected static HashSet<Class>
m_NoHandlers
the cache for object classes without object handlers.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractObjectHandler()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract String
format(T obj)
Turns the given object back into a string.static AbstractObjectHandler
getHandler(Class cls)
Returns the handler for the specific object class.static AbstractObjectHandler
getHandler(Object obj)
Returns the handler for the specific object.static String[]
getHandlers()
Returns a list with classnames of handlers.abstract boolean
handles(Class cls)
Checks whether the handler can process the given class.boolean
handles(Object obj)
Checks whether the handler can process the given object.abstract T
parse(String s)
Parses the given string.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Method Detail
-
handles
public boolean handles(Object obj)
Checks whether the handler can process the given object.- Parameters:
obj
- the object to check- Returns:
- true if handler can process the object
- See Also:
handles(Class)
-
handles
public abstract boolean handles(Class cls)
Checks whether the handler can process the given class.- Parameters:
cls
- the class to check- Returns:
- true if handler can process the class
-
parse
public abstract T parse(String s)
Parses the given string.- Parameters:
s
- the string- Returns:
- the generated object, null if failed to convert
-
format
public abstract String format(T obj)
Turns the given object back into a string.- Parameters:
obj
- the object to convert into a string- Returns:
- the string representation
-
getHandler
public static AbstractObjectHandler getHandler(Object obj)
Returns the handler for the specific object.- Parameters:
obj
- the object to get the handler for- Returns:
- the handler class or null if none available
-
getHandler
public static AbstractObjectHandler getHandler(Class cls)
Returns the handler for the specific object class.- Parameters:
cls
- the class to get the handler for- Returns:
- the handler or null if none available
-
getHandlers
public static String[] getHandlers()
Returns a list with classnames of handlers.- Returns:
- the handler classnames
-
-