Package adams.flow.core
Class AbstractModelLoader<T>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.core.AbstractModelLoader<T>
-
- Type Parameters:
T- the type of model
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,ModelFileHandler,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,FlowContextHandler,ModelLoaderSupporter,Serializable
- Direct Known Subclasses:
WekaClassifierModelLoader,WekaClustererModelLoader,WekaFilterModelLoader
public abstract class AbstractModelLoader<T> extends AbstractOptionHandler implements FlowContextHandler, ModelLoaderSupporter
Ancestor for model loaders.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractModelLoader.ModelLoadingTypeThe enumeration for the loading type.
-
Field Summary
Fields Modifier and Type Field Description protected Actorm_FlowContextthe flow context.protected CallableActorHelperm_Helperfor locating callable actors.protected Tm_Modelthe model.protected CallableActorReferencem_ModelActorthe model actor.protected PlaceholderFilem_ModelFilethe mode file.protected AbstractModelLoader.ModelLoadingTypem_ModelLoadingTypethe loading type.protected StorageNamem_ModelStoragethe model storage.-
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 AbstractModelLoader()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringautomaticOrderInfo()Returns information how the model is loaded in case ofAbstractModelLoader.ModelLoadingType.AUTO.voiddefineOptions()Adds options to the internal list of options.protected ObjectdeserializeFile(MessageCollection errors)Deserializes the model file.ActorgetFlowContext()Returns the flow context, if any.TgetModel(MessageCollection errors)Obtains the model, loads it if necessary.CallableActorReferencegetModelActor()Returns the callable actor to obtain the model from.PlaceholderFilegetModelFile()Returns the file to load the model from.protected abstract TgetModelFromContainer(AbstractContainer cont, MessageCollection errors)Retrieves the model from the container.AbstractModelLoader.ModelLoadingTypegetModelLoadingType()Returns the loading type.StorageNamegetModelStorage()Returns the storage item name to get the model from.StringgetQuickInfo(OptionHandler handler)Generates the quick info string.StringgetQuickInfo(OptionHandler handler, String current)Generates the quick info string.protected voidinitialize()Initializes the members.protected TloadAutomatically(MessageCollection errors)Loads the model automatically from file/callable actor/storage.protected TloadFromCallableActor(MessageCollection errors)Loads the model from the callable actor.protected TloadFromFile(MessageCollection errors)Loads the model from the specified file.protected TloadFromStorage(MessageCollection errors)Loads the model from the storage item.StringmodelActorTipText()Returns the tip text for this property.StringmodelFileTipText()Returns the tip text for this property.StringmodelLoadingTypeTipText()Returns the tip text for this property.StringmodelStorageTipText()Returns the tip text for this property.voidreset()Resets the scheme.voidsetFlowContext(Actor value)Sets the flow context.voidsetModelActor(CallableActorReference value)Sets the callable actor to obtain the model from.voidsetModelFile(PlaceholderFile value)Sets the file to load the model from.voidsetModelLoadingType(AbstractModelLoader.ModelLoadingType value)Sets the loading type.voidsetModelStorage(StorageName value)Sets the storage item name to get the model from.protected voidunhandledContainer(AbstractContainer cont, MessageCollection errors)Adds an "unhandled container type" error message.protected TunwrapModel(Object obj, MessageCollection errors)Unwraps the model if necessary.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, 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
-
-
-
-
Field Detail
-
m_FlowContext
protected Actor m_FlowContext
the flow context.
-
m_ModelLoadingType
protected AbstractModelLoader.ModelLoadingType m_ModelLoadingType
the loading type.
-
m_ModelFile
protected PlaceholderFile m_ModelFile
the mode file.
-
m_ModelActor
protected CallableActorReference m_ModelActor
the model actor.
-
m_ModelStorage
protected StorageName m_ModelStorage
the model storage.
-
m_Model
protected T m_Model
the model.
-
m_Helper
protected CallableActorHelper m_Helper
for locating callable actors.
-
-
Method Detail
-
automaticOrderInfo
public String automaticOrderInfo()
Returns information how the model is loaded in case ofAbstractModelLoader.ModelLoadingType.AUTO.- Returns:
- the description
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractOptionHandler
-
reset
public void reset()
Resets the scheme.- Overrides:
resetin classAbstractOptionHandler
-
setFlowContext
public void setFlowContext(Actor value)
Sets the flow context.- Specified by:
setFlowContextin interfaceFlowContextHandler- Parameters:
value- the actor
-
getFlowContext
public Actor getFlowContext()
Returns the flow context, if any.- Specified by:
getFlowContextin interfaceFlowContextHandler- Returns:
- the actor, null if none available
-
setModelLoadingType
public void setModelLoadingType(AbstractModelLoader.ModelLoadingType value)
Sets the loading type. In case ofAbstractModelLoader.ModelLoadingType.AUTO, first file, then callable actor, then storage.- Specified by:
setModelLoadingTypein interfaceModelLoaderSupporter- Parameters:
value- the type
-
getModelLoadingType
public AbstractModelLoader.ModelLoadingType getModelLoadingType()
Returns the loading type. In case ofAbstractModelLoader.ModelLoadingType.AUTO, first file, then callable actor, then storage.- Specified by:
getModelLoadingTypein interfaceModelLoaderSupporter- Returns:
- the type
-
modelLoadingTypeTipText
public String modelLoadingTypeTipText()
Returns the tip text for this property.- Specified by:
modelLoadingTypeTipTextin interfaceModelLoaderSupporter- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setModelFile
public void setModelFile(PlaceholderFile value)
Sets the file to load the model from.- Specified by:
setModelFilein interfaceModelFileHandler- Specified by:
setModelFilein interfaceModelLoaderSupporter- Parameters:
value- the model file
-
getModelFile
public PlaceholderFile getModelFile()
Returns the file to load the model from.- Specified by:
getModelFilein interfaceModelFileHandler- Specified by:
getModelFilein interfaceModelLoaderSupporter- Returns:
- the model file
-
modelFileTipText
public String modelFileTipText()
Returns the tip text for this property.- Specified by:
modelFileTipTextin interfaceModelFileHandler- Specified by:
modelFileTipTextin interfaceModelLoaderSupporter- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setModelActor
public void setModelActor(CallableActorReference value)
Sets the callable actor to obtain the model from.- Specified by:
setModelActorin interfaceModelLoaderSupporter- Parameters:
value- the actor reference
-
getModelActor
public CallableActorReference getModelActor()
Returns the callable actor to obtain the model from.- Specified by:
getModelActorin interfaceModelLoaderSupporter- Returns:
- the actor reference
-
modelActorTipText
public String modelActorTipText()
Returns the tip text for this property.- Specified by:
modelActorTipTextin interfaceModelLoaderSupporter- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setModelStorage
public void setModelStorage(StorageName value)
Sets the storage item name to get the model from.- Specified by:
setModelStoragein interfaceModelLoaderSupporter- Parameters:
value- the storage name
-
getModelStorage
public StorageName getModelStorage()
Returns the storage item name to get the model from.- Specified by:
getModelStoragein interfaceModelLoaderSupporter- Returns:
- the storage name
-
modelStorageTipText
public String modelStorageTipText()
Returns the tip text for this property.- Specified by:
modelStorageTipTextin interfaceModelLoaderSupporter- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
unhandledContainer
protected void unhandledContainer(AbstractContainer cont, MessageCollection errors)
Adds an "unhandled container type" error message.- Parameters:
cont- the unhandled container typeerrors- the errors to update
-
getModelFromContainer
protected abstract T getModelFromContainer(AbstractContainer cont, MessageCollection errors)
Retrieves the model from the container.- Parameters:
cont- the container to get the model fromerrors- for collecting errors- Returns:
- the model, null if not in container
-
unwrapModel
protected T unwrapModel(Object obj, MessageCollection errors)
Unwraps the model if necessary.- Parameters:
obj- the model to processerrors- for collecting errors- Returns:
- the unwrapped model, null if failed or input was null
-
deserializeFile
protected Object deserializeFile(MessageCollection errors)
Deserializes the model file.- Parameters:
errors- for collecting errors- Returns:
- the object read from the file, null if failed
-
loadFromFile
protected T loadFromFile(MessageCollection errors)
Loads the model from the specified file.- Parameters:
errors- for collecting errors- Returns:
- the model, null if failed to load
-
loadFromCallableActor
protected T loadFromCallableActor(MessageCollection errors)
Loads the model from the callable actor.- Parameters:
errors- for collecting errors- Returns:
- the model, null if failed to load
-
loadFromStorage
protected T loadFromStorage(MessageCollection errors)
Loads the model from the storage item.- Parameters:
errors- for collecting errors- Returns:
- the model, null if failed to load
-
loadAutomatically
protected T loadAutomatically(MessageCollection errors)
Loads the model automatically from file/callable actor/storage.- Parameters:
errors- for collecting errors- Returns:
- the model, null if failed
-
getModel
public T getModel(MessageCollection errors)
Obtains the model, loads it if necessary.- Parameters:
errors- for collecting errors- Returns:
- the model, null if failed to load
-
getQuickInfo
public String getQuickInfo(OptionHandler handler)
Generates the quick info string.- Parameters:
handler- the ModelLoaderSupporter to generate the quick info for- Returns:
- the generated quick info
-
getQuickInfo
public String getQuickInfo(OptionHandler handler, String current)
Generates the quick info string.- Parameters:
handler- the ModelLoaderSupporter to generate the quick info forcurrent- the current info string, can be empty/null- Returns:
- the generated quick info
-
-