adams.flow.condition.test
Class Jython

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

public class Jython
extends adams.flow.condition.test.AbstractScriptCondition

A condition that uses the condition defined in an external Jython script.

Valid options are:

-D (property: debug)
    If set to true, scheme may output additional info to the console.
 
-script <adams.core.io.PlaceholderFile> (property: scriptFile)
    The script file to load and execute.
    default: .
 
-options <java.lang.String> (property: scriptOptions)
    The options for the Jython script; must consist of 'key=value' pairs separated
    by blanks; the value of 'key' can be accessed via the 'getAdditionalOption
    (String)' in the Jython actor.
    default:
 

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

Field Summary
protected  Hashtable<String,String> m_AdditionalOptions
          for storing the additional options.
protected  adams.flow.condition.test.AbstractCondition m_ConditionObject
          the loaded script object.
protected  JythonScript m_InlineScript
          the inline script.
 
Fields inherited from class adams.flow.condition.test.AbstractScriptCondition
m_ScriptFile, m_ScriptObject, m_ScriptOptions
 
Fields inherited from class adams.flow.condition.test.AbstractCondition
m_Tested, m_TestResult
 
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.
 String getAdditionalOption(String name, String defValue)
          Returns the value associated with the (additional) option.
protected  JythonScript getDefaultInlineScript()
          Returns the default inline script.
 JythonScript getInlineScript()
          Gets the inline script to use instead of the external script file.
 String globalInfo()
          Returns a string describing the object.
protected  void initialize()
          Initializes the members.
 String inlineScriptTipText()
          Returns the tip text for this property.
protected  String loadScriptObject()
          Loads the scripts object and sets its options.
protected  String performScriptTest()
          Runs the script test.
 String scriptOptionsTipText()
          Returns the tip text for this property.
 void setAdditionalOptions(Hashtable<String,String> options)
          Sets the additional options.
 void setInlineScript(JythonScript value)
          Sets the inline script to use instead of the external script file.
 
Methods inherited from class adams.flow.condition.test.AbstractScriptCondition
getScriptFile, getScriptOptions, initScriptObject, performTest, reset, scriptFileTipText, setScriptFile, setScriptOptions
 
Methods inherited from class adams.flow.condition.test.AbstractCondition
compareTo, equals, forCommandLine, forName, getConditions, getTestResult, shallowCopy, shallowCopy
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debug, debugLevelTipText, destroy, finishInit, getDebugLevel, getOptionManager, isDebugOn, newOptionManager, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut, sizeOf
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_ConditionObject

protected transient adams.flow.condition.test.AbstractCondition m_ConditionObject
the loaded script object.


m_InlineScript

protected JythonScript m_InlineScript
the inline script.


m_AdditionalOptions

protected Hashtable<String,String> m_AdditionalOptions
for storing the additional options.

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

initialize

protected void initialize()
Initializes the members.

Overrides:
initialize in class adams.flow.condition.test.AbstractCondition

defineOptions

public void defineOptions()
Adds options to the internal list of options.

Specified by:
defineOptions in interface OptionHandler
Overrides:
defineOptions in class adams.flow.condition.test.AbstractScriptCondition

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

scriptOptionsTipText

public String scriptOptionsTipText()
Returns the tip text for this property.

Overrides:
scriptOptionsTipText in class adams.flow.condition.test.AbstractScriptCondition
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 adams.flow.condition.test.AbstractScriptCondition
Returns:
null if OK, otherwise the error message

checkScriptObject

protected String checkScriptObject()
Checks the script object.

Specified by:
checkScriptObject in class adams.flow.condition.test.AbstractScriptCondition
Returns:
always null, i.e., OK

performScriptTest

protected String performScriptTest()
Runs the script test.

Specified by:
performScriptTest in class adams.flow.condition.test.AbstractScriptCondition
Returns:
the test result, null if everything OK, otherwise the error message

setAdditionalOptions

public void setAdditionalOptions(Hashtable<String,String> options)
Sets the additional options.

Parameters:
options - the options (name <->value relation)

getAdditionalOption

public String getAdditionalOption(String name,
                                  String defValue)
Returns the value associated with the (additional) option.

Parameters:
name - the name of the additional option to retrieve
defValue - the default value
Returns:
the value or null if not available


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