Package adams.data.conversion
Class Scripted
-
- All Implemented Interfaces:
AdditionalInformationHandler
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,FileBasedScripting
,FileBasedScriptingWithOptions
,ShallowCopySupporter<AbstractConversion>
,SizeOfHandler
,Stoppable
,Conversion
,ConversionWithInitialization
,Serializable
public class Scripted extends AbstractScriptedConversion
A conversion that uses any scripting handler for processing the data with a script located in the specified file.
Valid options are:
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-script <adams.core.io.PlaceholderFile> (property: scriptFile) The script file to load and execute. default: ${CWD}
-options <java.lang.String> (property: scriptOptions) The options for the script; must consist of 'key=value' pairs separated by blanks; the value of 'key' can be accessed via the 'getAdditionalOptions ().getXYZ("key")' method in the script actor. default:
-handler <adams.core.scripting.AbstractScriptingHandler> (property: handler) The handler to use for scripting. default: adams.core.scripting.Dummy
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractConversion
m_ConversionObject
the loaded script object.protected AbstractScriptingHandler
m_Handler
the scripting handler to use.-
Fields inherited from class adams.data.conversion.AbstractScriptedConversion
m_ScriptFile, m_ScriptObject, m_ScriptOptions
-
Fields inherited from class adams.data.conversion.AbstractConversion
m_Input, m_Output, m_Owner, m_Stopped
-
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 Scripted()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class
accepts()
Returns the class that is accepted as input.protected String
checkScriptObject()
Checks the script object.void
defineOptions()
Adds options to the internal list of options.void
destroy()
Frees up memory in a "destructive" non-reversible way.protected Object
doConvert()
Performs the actual conversion.Class
generates()
Returns the class that is generated as output.AbstractScriptingHandler
getHandler()
Gets the handler to use for scripting.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.String
globalInfo()
Returns a string describing the object.String
handlerTipText()
Returns the tip text for this property.protected String
loadScriptObject()
Loads the scripts object and sets its options.String
scriptOptionsTipText()
Returns the tip text for this property.void
setHandler(AbstractScriptingHandler value)
Sets the handler to use for scripting.String
setUp()
Initializes the item for flow execution.-
Methods inherited from class adams.data.conversion.AbstractScriptedConversion
canSetUpScript, getScriptFile, getScriptOptions, initScriptObject, requiresSetUp, reset, scriptFileTipText, setScriptFile, setScriptOptions
-
Methods inherited from class adams.data.conversion.AbstractConversion
checkData, cleanUp, convert, getAdditionalInformation, getInput, getInput, getOutput, getOutput, getOwner, setInput, setOwner, shallowCopy, shallowCopy, stopExecution
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, 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.CleanUpHandler
cleanUp
-
Methods inherited from interface adams.data.conversion.Conversion
convert, getInput, getInput, getOutput, getOutput, getOwner, setInput, setOwner
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.Stoppable
stopExecution
-
-
-
-
Field Detail
-
m_ConversionObject
protected transient AbstractConversion m_ConversionObject
the loaded script object.
-
m_Handler
protected AbstractScriptingHandler m_Handler
the scripting handler to use.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractScriptedConversion
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractScriptedConversion
- Returns:
- null if no info available, otherwise short string
-
scriptOptionsTipText
public String scriptOptionsTipText()
Returns the tip text for this property.- Specified by:
scriptOptionsTipText
in interfaceFileBasedScriptingWithOptions
- Overrides:
scriptOptionsTipText
in classAbstractScriptedConversion
- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setHandler
public void setHandler(AbstractScriptingHandler value)
Sets the handler to use for scripting.- Parameters:
value
- the handler
-
getHandler
public AbstractScriptingHandler getHandler()
Gets the handler to use for scripting.- Returns:
- the handler
-
handlerTipText
public String handlerTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
accepts
public Class accepts()
Returns the class that is accepted as input.- Specified by:
accepts
in interfaceConversion
- Specified by:
accepts
in classAbstractConversion
- Returns:
- Object.class, since
-
generates
public Class generates()
Returns the class that is generated as output.- Specified by:
generates
in interfaceConversion
- Specified by:
generates
in classAbstractConversion
- Returns:
- the class
-
loadScriptObject
protected String loadScriptObject()
Loads the scripts object and sets its options.- Specified by:
loadScriptObject
in classAbstractScriptedConversion
- Returns:
- null if OK, otherwise the error message
-
checkScriptObject
protected String checkScriptObject()
Checks the script object.- Specified by:
checkScriptObject
in classAbstractScriptedConversion
- Returns:
- null if OK, otherwise the error message
-
setUp
public String setUp()
Initializes the item for flow execution.- Specified by:
setUp
in interfaceConversionWithInitialization
- Overrides:
setUp
in classAbstractScriptedConversion
- Returns:
- null if everything is fine, otherwise error message
-
doConvert
protected Object doConvert() throws Exception
Performs the actual conversion.- Specified by:
doConvert
in classAbstractConversion
- Returns:
- the converted data
- Throws:
Exception
- if something goes wrong with the conversion
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.- Specified by:
destroy
in interfaceDestroyable
- Overrides:
destroy
in classAbstractScriptedConversion
- See Also:
AbstractOptionHandler.cleanUpOptions()
-
-