All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Iava.IavaRuntime

java.lang.Object
   |
   +----Iava.IavaRuntime

public final class IavaRuntime
extends Object
implements IavaMessages
The class IavaRuntime represents the Iava runtime environment. It is used to provide a script with some context. This context is an object which uses the Iava interpreter to execute a script as if it was a public method. Since a script only has access to the public members of such an embedding context object, the context object can share its non-public fields with the script using the IavaRuntime. Arguments can also be passed to a script via the IavaRuntime. The difference between arguments and a shared fields is that the context object does not have the possibility to retrieve an argument after script execution, while it can retrieve the possibly changed values of shared fields. The embedding object can also invoke private methods declared by a script. The context object can also declare a return type which is mandatory for the script. These mechanisms allows the implementation of classes which declare scripted methods that provide all possibilities of compiled methods of a class. Only if some of the aforementioned interaction is needed between a script and an embedding context object, it makes sense to instantiate a IavaRuntime.
A runtime object follows a scoping policy for variables and methods. The scoping rules for methods and blocks within scripts are the same as in Java. However, the question is what happens with variables and methods declared within a script after the script's execution. The runtime might be used for the execution of further scripts which might want or not want to use methods and/or variables declared by scripts executed before. The default policy is to keep variables as well as method declarations such that subsequent scripts can reference them (GLOBAL_SCOPE). If this is not desired, the runtime provides methods for setting the scope policy for methods and variables separately such that methods and/or variables declared by a script are discarded after script execution (SCRIPT_SCOPE).

See Also:
Iava

Variable Index

 o GLOBAL_SCOPE
Declarations within script are kept after script execution such that they are available to scripts executed later.
 o SCRIPT_SCOPE
Declarations within script are discarded after script execution such that they are not available to scripts executed later.

Constructor Index

 o IavaRuntime()
 o IavaRuntime(Object, Class)
Create a IavaRuntime with context as the embedding object and returnType as mandatory return type of a script executed within this IavaRuntime object.

Method Index

 o addImportListener(ImportListener)
Adds a listener for import declarations.
 o addMethodCallListener(MethodCallListener)
Adds a listener for method calls.
 o addMethodDeclListener(MethodDeclListener)
Adds a listener for method declarations.
 o addSymbolDeclListener(SymbolDeclListener)
Adds a listener for symbol declarations.
 o callIavaMethod(String)
Call a method with the supplied name and no args declared within a script.
 o callIavaMethod(String, Object[])
Call a method with the supplied name and args declared within a script.
 o getDeclaredMethods()
Returns all public methods declared by Iava scripts within this runtime object.
 o getMethods()
Returns all private and public methods declared by Iava scripts within this runtime.
 o getMethodScope()
Get the scoping rule for methods declared within a script.
 o getSharedFieldValue(String)
Retrieve the value of a shared field (that was probably changed during script execution).
 o getVariableScope()
Get the scoping rule for variables declared within a script.
 o isReturned()
This method returns true if a script executed within this runtime has finished execution.
 o removeImportListener(ImportListener)
Removes the specified listener for import declarations.
 o removeMethodCallListener(MethodCallListener)
Removes the specified listener for method calls.
 o removeMethodDeclListener(MethodDeclListener)
Removes the specified listener for method declarations.
 o removeSymbolDeclListener(SymbolDeclListener)
Removes the specified listener for symbol declarations.
 o returnedObject()
If a return type was declared for script(s) executed within this runtime, this method retrieves the returned value.
 o setArgument(String, Class, Object, boolean)
Pass an argument to the script(s) executed by this IavaRuntime.
 o setMethodScope(int)
Set the scoping rule for methods declared within a script.
 o setVariableScope(int)
Set the scoping rule for variables declared within a script.
 o shareField(String, Class, Object, boolean)
Share a field with the script(s) executed by this IavaRuntime.
 o updateSharedField(String, Object)
Update the value of a shared field such that the new value is available to script(s) exeucted within this IavaRuntime.

Variables

 o SCRIPT_SCOPE
 public static final int SCRIPT_SCOPE
Declarations within script are discarded after script execution such that they are not available to scripts executed later.

See Also:
setVariableScope, getVariableScope, setMethodScope, getMethodScope
 o GLOBAL_SCOPE
 public static final int GLOBAL_SCOPE
Declarations within script are kept after script execution such that they are available to scripts executed later.

See Also:
setVariableScope, getVariableScope, setMethodScope, getMethodScope

Constructors

 o IavaRuntime
 public IavaRuntime()
 o IavaRuntime
 public IavaRuntime(Object context,
                    Class returnType)
Create a IavaRuntime with context as the embedding object and returnType as mandatory return type of a script executed within this IavaRuntime object.

Methods

 o callIavaMethod
 public Object callIavaMethod(String name,
                              Object args[])
Call a method with the supplied name and args declared within a script. If the invoked method does not return a value, this method returns null. Primitive types are wrapped by objects of the according classes. The method wich is called must be declared 'public' in the script. If an error or exception is thrown during execution of the scripted method (if they are not caught within the scripted method itself), an IError is thrown by the interpreter. Using the public method IError.original() the original can be retrieved and processed.

 o callIavaMethod
 public Object callIavaMethod(String name)
Call a method with the supplied name and no args declared within a script. If the invoked method does not return a value, this method returns null. Primitive types are wrapped by objects of the according classes. The method called must be declared 'public' in the script.

 o addSymbolDeclListener
 public synchronized void addSymbolDeclListener(SymbolDeclListener listener)
Adds a listener for symbol declarations. The listener is notified by the runtime each time a new symbol is declared, and each time a variable scope is closed.

 o removeSymbolDeclListener
 public synchronized void removeSymbolDeclListener(SymbolDeclListener listener)
Removes the specified listener for symbol declarations.

 o addImportListener
 public synchronized void addImportListener(ImportListener listener)
Adds a listener for import declarations. The listener is notified by the runtime each time a new import is declared.

 o removeImportListener
 public synchronized void removeImportListener(ImportListener listener)
Removes the specified listener for import declarations.

 o addMethodDeclListener
 public synchronized void addMethodDeclListener(MethodDeclListener listener)
Adds a listener for method declarations. Each time, a new method is declared, the listener is notified.

 o removeMethodDeclListener
 public synchronized void removeMethodDeclListener(MethodDeclListener listener)
Removes the specified listener for method declarations.

 o addMethodCallListener
 public synchronized void addMethodCallListener(MethodCallListener listener)
Adds a listener for method calls. Each time, a method is called, the listener is notified prior to the call and afterwards.

 o removeMethodCallListener
 public synchronized void removeMethodCallListener(MethodCallListener listener)
Removes the specified listener for method calls.

 o setVariableScope
 public void setVariableScope(int scope)
Set the scoping rule for variables declared within a script.

See Also:
GLOBAL_SCOPE, SCRIPT_SCOPE
 o getVariableScope
 public int getVariableScope()
Get the scoping rule for variables declared within a script.

See Also:
GLOBAL_SCOPE, SCRIPT_SCOPE
 o getMethodScope
 public int getMethodScope()
Get the scoping rule for methods declared within a script.

See Also:
GLOBAL_SCOPE, SCRIPT_SCOPE
 o setMethodScope
 public void setMethodScope(int scope)
Set the scoping rule for methods declared within a script.

See Also:
GLOBAL_SCOPE, SCRIPT_SCOPE
 o getMethods
 public Vector getMethods()
Returns all private and public methods declared by Iava scripts within this runtime.

 o getDeclaredMethods
 public IavaMethod[] getDeclaredMethods()
Returns all public methods declared by Iava scripts within this runtime object.

 o setArgument
 public void setArgument(String name,
                         Class type,
                         Object value,
                         boolean isFinal)
Pass an argument to the script(s) executed by this IavaRuntime. If the argument represents a primitive data type, it must be wrapped into an object of the according class.

 o shareField
 public synchronized void shareField(String name,
                                     Class type,
                                     Object value,
                                     boolean isFinal)
Share a field with the script(s) executed by this IavaRuntime. If the field represents a primitive data type, it must be wrapped into an object of the according class.

 o getSharedFieldValue
 public synchronized Object getSharedFieldValue(String name)
Retrieve the value of a shared field (that was probably changed during script execution). Primitive data types are wrapped into instances of the according classes.

 o updateSharedField
 public synchronized void updateSharedField(String name,
                                            Object value)
Update the value of a shared field such that the new value is available to script(s) exeucted within this IavaRuntime. Primitive types are wrapped into instances of the according classes.

 o returnedObject
 public Object returnedObject()
If a return type was declared for script(s) executed within this runtime, this method retrieves the returned value. Primitive types are wrapped into instances of the according classes.

 o isReturned
 public boolean isReturned()
This method returns true if a script executed within this runtime has finished execution.


All Packages  Class Hierarchy  This Package  Previous  Next  Index