jpl.mipl.pgs.utils.upf
Class BeanShellScript

java.lang.Object
  extended by jpl.mipl.pgs.utils.upf.BeanShellScript
All Implemented Interfaces:
Serializable, Runnable, Script

public class BeanShellScript
extends Object
implements Script

An object that represents a UPF bean shell script.

Author:
Raj Patel {rrp@mipl.jpl.nasa.gov}

      Copyright 2006-present, California Institute of Technology.
      ALL RIGHTS RESERVED.
      U.S. Government Sponsorship acknowledge.
  
See Also:
Serialized Form

Field Summary
static long serialVersionUID
           
 
Constructor Summary
BeanShellScript()
          Default constructor.
BeanShellScript(BeanShellScript i, String name)
          A copy constructor.
BeanShellScript(String name)
          Create a BeanShellScript with the given name.
 
Method Summary
 Object eval(String script, Map<String,Object> params)
          Executes the given script with the given parameters.
 Object getResult()
          Returns the result as obtained by executing the script.
 String getScriptName()
           
 void run()
          Executes the script.
 void setParam(String name, Object value, boolean overwrite)
          Set a parameter for this script.
 void setScript(String script)
          Set the bean shell script this interpreter is to execute.
 void setScriptName(String name)
          The this script's name.
 String toString()
          Return the entire script in it's proper XML form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

BeanShellScript

public BeanShellScript()
Default constructor.


BeanShellScript

public BeanShellScript(String name)
Create a BeanShellScript with the given name.

Parameters:
name - The name of this bean shell script.

BeanShellScript

public BeanShellScript(BeanShellScript i,
                       String name)
A copy constructor.
CAUTION: This is NOT a deep copy.

Parameters:
i - the base interpreter to be used for creating this interpreter
name - the name of this new interpreter
Method Detail

setScriptName

public void setScriptName(String name)
The this script's name.

Specified by:
setScriptName in interface Script
Parameters:
name - The name of this bean shell script.

getScriptName

public String getScriptName()
Specified by:
getScriptName in interface Script
Returns:
Name of this script.

setScript

public void setScript(String script)
Set the bean shell script this interpreter is to execute.

Specified by:
setScript in interface Script

setParam

public void setParam(String name,
                     Object value,
                     boolean overwrite)
Set a parameter for this script. Generally called before calling running this script. The script must be using the same name as the name supplied here. For example, if the script uses variable 'xyz', then this method can be used to set value of 'xyz'.

Specified by:
setParam in interface Script
Parameters:
name - The name of the parameter.
value - The value of the parameter.
overwrite - if false and parameter exists, no action is performed.

getResult

public Object getResult()
Returns the result as obtained by executing the script. The caller of this method should know the type of the object returned by this script.

Specified by:
getResult in interface Script

run

public void run()
         throws RuntimeException
Executes the script.

Specified by:
run in interface Runnable
Throws:
RuntimeException
See Also:
Runnable.run()

eval

public Object eval(String script,
                   Map<String,Object> params)
            throws Exception
Executes the given script with the given parameters.

Specified by:
eval in interface Script
Throws:
Exception

toString

public String toString()
Return the entire script in it's proper XML form.

Overrides:
toString in class Object
See Also:
Object.toString()