Package adams.flow.condition.bool
Class AbstractScriptedCondition
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.condition.bool.AbstractBooleanCondition
-
- adams.flow.condition.bool.AbstractScriptedCondition
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,QuickInfoSupporter,FileBasedScripting,FileBasedScriptingWithOptions,ShallowCopySupporter<BooleanCondition>,SizeOfHandler,Stoppable,BooleanCondition,Serializable
public abstract class AbstractScriptedCondition extends AbstractBooleanCondition implements FileBasedScriptingWithOptions
Abstract ancestor for actors that execute scripts.- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected PlaceholderFilem_ScriptFilethe Groovy module.protected Objectm_ScriptObjectthe loaded script object.protected Stringm_ScriptOptionsthe options for the Groovy module.-
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 AbstractScriptedCondition()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Class[]accepts()Returns the class that the consumer accepts.protected abstract StringcheckScriptObject()Checks the script object.voiddefineOptions()Adds options to the internal list of options.protected booleandoEvaluate(Actor owner, Token token)Performs the actual evaluation.protected abstract booleandoScriptEvaluate(Actor owner, Token token)Runs the script evaluation.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.PlaceholderFilegetScriptFile()Gets the Groovy module.BaseTextgetScriptOptions()Gets the script options.protected StringinitScriptObject()Tries to initialize the scripts object, sets its options and performs some checks.protected abstract StringloadScriptObject()Loads the scripts object and sets its options.voidreset()Resets the condition.StringscriptFileTipText()Returns the tip text for this property.StringscriptOptionsTipText()Returns the tip text for this property.voidsetScriptFile(PlaceholderFile value)Sets the Groovy module.voidsetScriptOptions(BaseText value)Sets the script options.StringsetUp(Actor owner)Configures the condition.-
Methods inherited from class adams.flow.condition.bool.AbstractBooleanCondition
evaluate, preEvaluate, shallowCopy, shallowCopy, stopExecution
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, 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.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_ScriptFile
protected PlaceholderFile m_ScriptFile
the Groovy module.
-
m_ScriptOptions
protected String m_ScriptOptions
the options for the Groovy module.
-
m_ScriptObject
protected transient Object m_ScriptObject
the loaded script object.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
reset
public void reset()
Resets the condition. Derived classes must call this method in set-methods of parameters to assure the invalidation of previously generated data.- Overrides:
resetin classAbstractOptionHandler
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfoin interfaceBooleanCondition- Specified by:
getQuickInfoin interfaceQuickInfoSupporter- Specified by:
getQuickInfoin classAbstractBooleanCondition- Returns:
- null if no info available, otherwise short string
-
setScriptFile
public void setScriptFile(PlaceholderFile value)
Sets the Groovy module.- Specified by:
setScriptFilein interfaceFileBasedScripting- Parameters:
value- the Groovy module
-
getScriptFile
public PlaceholderFile getScriptFile()
Gets the Groovy module.- Specified by:
getScriptFilein interfaceFileBasedScripting- Returns:
- the Groovy module
-
scriptFileTipText
public String scriptFileTipText()
Returns the tip text for this property.- Specified by:
scriptFileTipTextin interfaceFileBasedScripting- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setScriptOptions
public void setScriptOptions(BaseText value)
Sets the script options.- Specified by:
setScriptOptionsin interfaceFileBasedScriptingWithOptions- Parameters:
value- the options
-
getScriptOptions
public BaseText getScriptOptions()
Gets the script options.- Specified by:
getScriptOptionsin interfaceFileBasedScriptingWithOptions- Returns:
- the options
-
scriptOptionsTipText
public String scriptOptionsTipText()
Returns the tip text for this property.- Specified by:
scriptOptionsTipTextin interfaceFileBasedScriptingWithOptions- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
loadScriptObject
protected abstract String loadScriptObject()
Loads the scripts object and sets its options.- Returns:
- null if OK, otherwise the error message
-
checkScriptObject
protected abstract String checkScriptObject()
Checks the script object.- Returns:
- null if OK, otherwise the error message
-
initScriptObject
protected String initScriptObject()
Tries to initialize the scripts object, sets its options and performs some checks.- Returns:
- null if OK, otherwise the error message
-
accepts
public Class[] accepts()
Returns the class that the consumer accepts.- Specified by:
acceptsin interfaceBooleanCondition- Specified by:
acceptsin classAbstractBooleanCondition- Returns:
- adams.flow.core.Unknown.class
-
setUp
public String setUp(Actor owner)
Configures the condition.- Specified by:
setUpin interfaceBooleanCondition- Overrides:
setUpin classAbstractBooleanCondition- Parameters:
owner- the actor this condition belongs to- Returns:
- null if everything is fine, otherwise error message
-
doScriptEvaluate
protected abstract boolean doScriptEvaluate(Actor owner, Token token)
Runs the script evaluation.- Returns:
- the boolean result of the evaluation
-
doEvaluate
protected boolean doEvaluate(Actor owner, Token token)
Performs the actual evaluation.- Specified by:
doEvaluatein classAbstractBooleanCondition- Parameters:
owner- the owning actortoken- the current token passing through- Returns:
- the result of the evaluation
-
-