Package adams.data.conversion
Class Groovy
-
- All Implemented Interfaces:
AdditionalInformationHandler,CleanUpHandler,Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,QuickInfoSupporter,FileBasedScripting,FileBasedScriptingWithOptions,ShallowCopySupporter<AbstractConversion>,SizeOfHandler,Stoppable,Conversion,ConversionWithInitialization,Serializable
public class Groovy extends AbstractScriptedConversion
A conversion that uses a Groovy script for processing the data.
Valid options are:
-D <int> (property: debugLevel) The greater the number the more additional info the scheme may output to the console (0 = off). default: 0 minimum: 0
-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 Groovy 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 Groovy actor. default:-inline-script <adams.core.scripting.GroovyScript> (property: inlineScript) The inline script, if not using an external script file. default:
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractConversionm_ConversionObjectthe loaded script object.protected GroovyScriptm_InlineScriptthe inline script.-
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 Groovy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Classaccepts()Returns the class that is accepted as input.protected booleancanSetUpScript()Method for checking whether we can setUp the script.protected StringcheckScriptObject()Checks the script object.voiddefineOptions()Adds options to the internal list of options.voiddestroy()Frees up memory in a "destructive" non-reversible way.protected ObjectdoConvert()Performs the actual conversion.Classgenerates()Returns the class that is generated as output.protected GroovyScriptgetDefaultInlineScript()Returns the default inline script.GroovyScriptgetInlineScript()Gets the inline script to use instead of the external script file.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.StringglobalInfo()Returns a string describing the object.protected StringinitScriptObject()Tries to initialize the scripts object, sets its options and performs some checks.StringinlineScriptTipText()Returns the tip text for this property.protected StringloadScriptObject()Loads the scripts object and sets its options.StringscriptOptionsTipText()Returns the tip text for this property.voidsetInlineScript(GroovyScript value)Sets the inline script to use instead of the external script file.-
Methods inherited from class adams.data.conversion.AbstractScriptedConversion
getScriptFile, getScriptOptions, requiresSetUp, reset, scriptFileTipText, setScriptFile, setScriptOptions, setUp
-
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_InlineScript
protected GroovyScript m_InlineScript
the inline script.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractScriptedConversion
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfoin interfaceQuickInfoSupporter- Overrides:
getQuickInfoin classAbstractScriptedConversion- Returns:
- null if no info available, otherwise short string
-
scriptOptionsTipText
public String scriptOptionsTipText()
Returns the tip text for this property.- Specified by:
scriptOptionsTipTextin interfaceFileBasedScriptingWithOptions- Overrides:
scriptOptionsTipTextin classAbstractScriptedConversion- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getDefaultInlineScript
protected GroovyScript getDefaultInlineScript()
Returns the default inline script.- Returns:
- the default script
-
setInlineScript
public void setInlineScript(GroovyScript value)
Sets the inline script to use instead of the external script file.- Parameters:
value- the inline script
-
getInlineScript
public GroovyScript getInlineScript()
Gets the inline script to use instead of the external script file.- Returns:
- the inline script
-
inlineScriptTipText
public String inlineScriptTipText()
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:
acceptsin interfaceConversion- Specified by:
acceptsin classAbstractConversion- Returns:
- Object.class, since
-
generates
public Class generates()
Returns the class that is generated as output.- Specified by:
generatesin interfaceConversion- Specified by:
generatesin classAbstractConversion- Returns:
- the class
-
loadScriptObject
protected String loadScriptObject()
Loads the scripts object and sets its options.- Specified by:
loadScriptObjectin classAbstractScriptedConversion- Returns:
- null if OK, otherwise the error message
-
checkScriptObject
protected String checkScriptObject()
Checks the script object.- Specified by:
checkScriptObjectin classAbstractScriptedConversion- Returns:
- null if OK, otherwise the error message
-
canSetUpScript
protected boolean canSetUpScript()
Method for checking whether we can setUp the script.- Overrides:
canSetUpScriptin classAbstractScriptedConversion- Returns:
- true if it can be setUp
-
initScriptObject
protected String initScriptObject()
Tries to initialize the scripts object, sets its options and performs some checks.- Overrides:
initScriptObjectin classAbstractScriptedConversion- Returns:
- null if OK, otherwise the error message
-
doConvert
protected Object doConvert() throws Exception
Performs the actual conversion.- Specified by:
doConvertin 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:
destroyin interfaceDestroyable- Overrides:
destroyin classAbstractScriptedConversion- See Also:
AbstractOptionHandler.cleanUpOptions()
-
-