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
-
GLOBAL_SCOPE
- Declarations within script are kept after
script execution such that they are available
to scripts executed later.
-
SCRIPT_SCOPE
- Declarations within script are discarded
after script execution such that they are
not available to scripts executed later.
-
IavaRuntime()
-
-
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.
-
addImportListener(ImportListener)
- Adds a listener for import declarations.
-
addMethodCallListener(MethodCallListener)
- Adds a listener for method calls.
-
addMethodDeclListener(MethodDeclListener)
- Adds a listener for method declarations.
-
addSymbolDeclListener(SymbolDeclListener)
- Adds a listener for symbol declarations.
-
callIavaMethod(String)
- Call a method with the supplied name and no args declared within
a script.
-
callIavaMethod(String, Object[])
- Call a method with the supplied name and args declared within
a script.
-
getDeclaredMethods()
- Returns all public methods declared by Iava scripts within this
runtime object.
-
getMethods()
- Returns all private and public methods declared by Iava scripts
within this runtime.
-
getMethodScope()
- Get the scoping rule for methods declared within a script.
-
getSharedFieldValue(String)
- Retrieve the value of a shared field (that was probably changed
during script execution).
-
getVariableScope()
- Get the scoping rule for variables declared within a script.
-
isReturned()
- This method returns true if a script executed within
this runtime has finished execution.
-
removeImportListener(ImportListener)
- Removes the specified listener for import declarations.
-
removeMethodCallListener(MethodCallListener)
- Removes the specified listener for method calls.
-
removeMethodDeclListener(MethodDeclListener)
- Removes the specified listener for method declarations.
-
removeSymbolDeclListener(SymbolDeclListener)
- Removes the specified listener for symbol declarations.
-
returnedObject()
- If a return type was declared for script(s) executed within
this runtime, this method retrieves the returned value.
-
setArgument(String, Class, Object, boolean)
- Pass an argument to the script(s) executed by this IavaRuntime.
-
setMethodScope(int)
- Set the scoping rule for methods declared within a script.
-
setVariableScope(int)
- Set the scoping rule for variables declared within a script.
-
shareField(String, Class, Object, boolean)
- Share a field with the script(s) executed by this IavaRuntime.
-
updateSharedField(String, Object)
- Update the value of a shared field such that the new value
is available to script(s) exeucted within this IavaRuntime.
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
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
IavaRuntime
public IavaRuntime()
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.
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.
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.
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.
removeSymbolDeclListener
public synchronized void removeSymbolDeclListener(SymbolDeclListener listener)
- Removes the specified listener for symbol declarations.
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.
removeImportListener
public synchronized void removeImportListener(ImportListener listener)
- Removes the specified listener for import declarations.
addMethodDeclListener
public synchronized void addMethodDeclListener(MethodDeclListener listener)
- Adds a listener for method declarations. Each time, a new
method is declared, the listener is notified.
removeMethodDeclListener
public synchronized void removeMethodDeclListener(MethodDeclListener listener)
- Removes the specified listener for method declarations.
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.
removeMethodCallListener
public synchronized void removeMethodCallListener(MethodCallListener listener)
- Removes the specified listener for method calls.
setVariableScope
public void setVariableScope(int scope)
- Set the scoping rule for variables declared within a script.
- See Also:
- GLOBAL_SCOPE, SCRIPT_SCOPE
getVariableScope
public int getVariableScope()
- Get the scoping rule for variables declared within a script.
- See Also:
- GLOBAL_SCOPE, SCRIPT_SCOPE
getMethodScope
public int getMethodScope()
- Get the scoping rule for methods declared within a script.
- See Also:
- GLOBAL_SCOPE, SCRIPT_SCOPE
setMethodScope
public void setMethodScope(int scope)
- Set the scoping rule for methods declared within a script.
- See Also:
- GLOBAL_SCOPE, SCRIPT_SCOPE
getMethods
public Vector getMethods()
- Returns all private and public methods declared by Iava scripts
within this runtime.
getDeclaredMethods
public IavaMethod[] getDeclaredMethods()
- Returns all public methods declared by Iava scripts within this
runtime object.
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.
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.
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.
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.
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.
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