JTR 5.0 API Documentation

jtr.script.impl
Class AbstractScriptEngine

java.lang.Object
  extended by jtr.script.impl.AbstractScriptEngine
All Implemented Interfaces:
IFactory, IScriptEngine
Direct Known Subclasses:
BshScriptEngine, GroovyScriptEngine

public abstract class AbstractScriptEngine
extends java.lang.Object
implements IScriptEngine

Base abstract script engine useful for writing new ones.

Since:
5.0
Version:
5.0
Author:
frusso

Nested Class Summary
protected static class AbstractScriptEngine.StructuredScript
          Utility class for reorganizing scripts in two main sections: imports body
 
Field Summary
protected static java.lang.String GLOBAL_JTR_CTX_IDENTIFIER
           
protected static org.apache.log4j.Logger logger
           
 
Constructor Summary
AbstractScriptEngine()
           
 
Method Summary
protected  void consolidateLibrary()
          This method puts into the library instance variable all the libary scripts as a single string (actually a StringBuffer instance), organized in a way that all the necessary import statements come before all the library scripts.
protected  java.lang.String defineScript(PScript pScript)
          This method appends the given pScript to the previously reorganized library-scripts, in order to make pScript executable.
protected  PScript findScript(java.lang.String scriptUID)
          Finds the required parameterization-script using its unique name provided as input parameter.
protected  java.lang.String getEndStatementPattern()
          Must return the pattern that represents the end of statement int the supported language.
protected  java.lang.String getImportPattern()
          Must return the pattern that identifies an import in the supported language.
protected  Scripts getScripts()
          Returns the configured scripts, both library scripts and parameterization scripts.
protected  AbstractScriptEngine.StructuredScript restructureScript(Script script)
          Given the input script this method reorganizes it into an instance of StructuredScript.
protected  void setActualParameters(PScript pScript, ScriptParams actualParams)
           
protected abstract  void setBooleanActualParameter(java.lang.String fpName, java.lang.Boolean apValue)
          Method that engine-specific subclasses must implement for setting actual parameters before execution.
protected abstract  void setDoubleActualParameter(java.lang.String fpName, java.lang.Double apValue)
          Method that engine-specific subclasses must implement for setting actual parameters before execution.
protected abstract  void setFloatActualParameter(java.lang.String fpName, java.lang.Float apValue)
          Method that engine-specific subclasses must implement for setting actual parameters before execution.
protected abstract  void setIntegerActualParameter(java.lang.String fpName, java.lang.Integer apValue)
          Method that engine-specific subclasses must implement for setting actual parameters before execution.
protected abstract  void setLongActualParameter(java.lang.String fpName, java.lang.Long apValue)
          Method that engine-specific subclasses must implement for setting actual parameters before execution.
protected abstract  void setObjectActualParameter(java.lang.String fpName, java.lang.Object apValue)
          Method that engine-specific subclasses must implement for setting actual parameters before execution.
 void setScripts(Scripts scripts)
          Sets the configured collection of both l-scripts and p-scripts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jtr.script.IScriptEngine
execute, newInstance
 

Field Detail

GLOBAL_JTR_CTX_IDENTIFIER

protected static final java.lang.String GLOBAL_JTR_CTX_IDENTIFIER
See Also:
Constant Field Values

logger

protected static final org.apache.log4j.Logger logger
Constructor Detail

AbstractScriptEngine

public AbstractScriptEngine()
Method Detail

setBooleanActualParameter

protected abstract void setBooleanActualParameter(java.lang.String fpName,
                                                  java.lang.Boolean apValue)
Method that engine-specific subclasses must implement for setting actual parameters before execution.

Parameters:
fpName -
apValue -

setDoubleActualParameter

protected abstract void setDoubleActualParameter(java.lang.String fpName,
                                                 java.lang.Double apValue)
Method that engine-specific subclasses must implement for setting actual parameters before execution.

Parameters:
fpName -
apValue -

setFloatActualParameter

protected abstract void setFloatActualParameter(java.lang.String fpName,
                                                java.lang.Float apValue)
Method that engine-specific subclasses must implement for setting actual parameters before execution.

Parameters:
fpName -
apValue -

setIntegerActualParameter

protected abstract void setIntegerActualParameter(java.lang.String fpName,
                                                  java.lang.Integer apValue)
Method that engine-specific subclasses must implement for setting actual parameters before execution.

Parameters:
fpName -
apValue -

setLongActualParameter

protected abstract void setLongActualParameter(java.lang.String fpName,
                                               java.lang.Long apValue)
Method that engine-specific subclasses must implement for setting actual parameters before execution.

Parameters:
fpName -
apValue -

setObjectActualParameter

protected abstract void setObjectActualParameter(java.lang.String fpName,
                                                 java.lang.Object apValue)
Method that engine-specific subclasses must implement for setting actual parameters before execution.

Parameters:
fpName -
apValue -

setScripts

public void setScripts(Scripts scripts)
Sets the configured collection of both l-scripts and p-scripts.

Specified by:
setScripts in interface IScriptEngine
Parameters:
scripts -

getScripts

protected Scripts getScripts()
Returns the configured scripts, both library scripts and parameterization scripts.

Returns:

findScript

protected PScript findScript(java.lang.String scriptUID)
Finds the required parameterization-script using its unique name provided as input parameter. Returns null if nothing can be found.

Parameters:
scriptUID -
Returns:

setActualParameters

protected void setActualParameters(PScript pScript,
                                   ScriptParams actualParams)
                            throws ScriptException
Parameters:
interpreter -
pScript -
actualParams -
Throws:
bsh.EvalError
ScriptException

consolidateLibrary

protected void consolidateLibrary()
This method puts into the library instance variable all the libary scripts as a single string (actually a StringBuffer instance), organized in a way that all the necessary import statements come before all the library scripts.


restructureScript

protected AbstractScriptEngine.StructuredScript restructureScript(Script script)
Given the input script this method reorganizes it into an instance of StructuredScript.

Parameters:
script -
Returns:

getImportPattern

protected java.lang.String getImportPattern()
Must return the pattern that identifies an import in the supported language. A null return value means that the language has no import concept.
This method, if not overridden, returns import.

Returns:
The import pattern

getEndStatementPattern

protected java.lang.String getEndStatementPattern()
Must return the pattern that represents the end of statement int the supported language. A null value will be interpreted as ;.
This method, if not overridden returns ;.

Returns:

defineScript

protected java.lang.String defineScript(PScript pScript)
This method appends the given pScript to the previously reorganized library-scripts, in order to make pScript executable.

Parameters:
pScript -
Returns:

The JTR Project is licensed under GPL version 2