adams.flow.condition.bool
Class Jython

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.flow.condition.bool.AbstractBooleanCondition
              extended by adams.flow.condition.bool.AbstractScriptCondition
                  extended by adams.flow.condition.bool.Jython
All Implemented Interfaces:
adams.core.Debuggable, adams.core.Destroyable, OptionHandler, adams.core.ShallowCopySupporter<BooleanCondition>, adams.core.SizeOfHandler, BooleanCondition, Serializable

public class Jython
extends AbstractScriptCondition

A boolean condition that uses the condition defined in a Jython script.

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 script.
    default: 
 
-inline-script <adams.core.scripting.JythonScript> (property: inlineScript)
    The inline script, if not using an external script file.
    default: 
 

Version:
$Revision: 5660 $
Author:
FracPete (fracpete at waikato dot ac dot nz)
See Also:
Jython, Serialized Form

Field Summary
protected  BooleanCondition m_ConditionObject
          the loaded script object.
protected  JythonScript m_InlineScript
          the inline script.
 
Fields inherited from class adams.flow.condition.bool.AbstractScriptCondition
m_ScriptFile, m_ScriptObject, m_ScriptOptions
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Constructor Summary
Jython()
           
 
Method Summary
protected  String checkScriptObject()
          Checks the script object.
 void defineOptions()
          Adds options to the internal list of options.
protected  boolean doScriptEvaluate(AbstractActor owner, Token token)
          Runs the script evaluation.
protected  JythonScript getDefaultInlineScript()
          Returns the default inline script.
 JythonScript getInlineScript()
          Gets the inline script to use instead of the external script file.
 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 inlineScriptTipText()
          Returns the tip text for this property.
protected  String loadScriptObject()
          Loads the scripts object and sets its options.
 void setInlineScript(JythonScript value)
          Sets the inline script to use instead of the external script file.
 
Methods inherited from class adams.flow.condition.bool.AbstractScriptCondition
accepts, doEvaluate, getScriptFile, getScriptOptions, initScriptObject, reset, scriptFileTipText, scriptOptionsTipText, setScriptFile, setScriptOptions, setUp
 
Methods inherited from class adams.flow.condition.bool.AbstractBooleanCondition
evaluate, preEvaluate, shallowCopy, shallowCopy
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debug, debugLevelTipText, destroy, finishInit, getDebugLevel, getOptionManager, initialize, isDebugOn, newOptionManager, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut, sizeOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_ConditionObject

protected transient BooleanCondition m_ConditionObject
the loaded script object.


m_InlineScript

protected JythonScript m_InlineScript
the inline script.

Constructor Detail

Jython

public Jython()
Method Detail

globalInfo

public String globalInfo()
Returns a string describing the object.

Specified by:
globalInfo in class AbstractOptionHandler
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 interface OptionHandler
Overrides:
defineOptions in class AbstractScriptCondition

getQuickInfo

public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.

Specified by:
getQuickInfo in interface BooleanCondition
Overrides:
getQuickInfo in class AbstractScriptCondition
Returns:
null if no info available, otherwise short string

getDefaultInlineScript

protected JythonScript getDefaultInlineScript()
Returns the default inline script.

Returns:
the default script

setInlineScript

public void setInlineScript(JythonScript value)
Sets the inline script to use instead of the external script file.

Parameters:
value - the inline script

getInlineScript

public JythonScript 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

loadScriptObject

protected String loadScriptObject()
Loads the scripts object and sets its options.

Specified by:
loadScriptObject in class AbstractScriptCondition
Returns:
null if OK, otherwise the error message

checkScriptObject

protected String checkScriptObject()
Checks the script object.

Specified by:
checkScriptObject in class AbstractScriptCondition
Returns:
always null, i.e., OK

doScriptEvaluate

protected boolean doScriptEvaluate(AbstractActor owner,
                                   Token token)
Runs the script evaluation.

Specified by:
doScriptEvaluate in class AbstractScriptCondition
Returns:
the boolean result of the evaluation


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.