public interface Interpreter
It is easier to implement by extending
from GenericInterpreter
.
Modifier and Type | Method and Description |
---|---|
boolean |
containsVariable(java.lang.String name)
Tests whether the variable is defined in this interpreter.
|
void |
destroy()
Called when the interpreter is about to be destroyed.
|
java.lang.Class<?> |
getClass(java.lang.String clsnm)
Returns the class defined in this interpreter, or null if not found.
|
Function |
getFunction(java.lang.String name,
java.lang.Class[] argTypes)
Returns the method of the specified name defined in this interpreter,
or null if not defined.
|
java.lang.String |
getLanguage()
Returns the scripting language this interpreter is associated with.
|
java.lang.Object |
getNativeInterpreter()
Returns the native interpreter, or null if not available.
|
Page |
getOwner()
Returns the owner of this interpreter.
|
java.lang.Object |
getVariable(java.lang.String name)
Returns the value of a variable defined in this interpreter.
|
void |
init(Page owner,
java.lang.String zslang)
Initializes the interpreter.
|
void |
interpret(java.lang.String script,
Scope scope)
Evaluates the script against the specified scope.
|
void |
setVariable(java.lang.String name,
java.lang.Object value)
Sets the value of a variable to this interpreter, as if
they are defined in the interpreter.
|
void |
unsetVariable(java.lang.String name)
Removes the value of a variable defined in this interpreter.
|
void init(Page owner, java.lang.String zslang)
zslang
- the language this interpreter is associated withvoid destroy()
Page getOwner()
java.lang.String getLanguage()
java.lang.Object getNativeInterpreter()
void interpret(java.lang.String script, Scope scope)
Implementation Note:
LanguageDefinition.getEachTimeScript(java.lang.String)
if not null.Scopes.getCurrent(org.zkoss.zk.ui.Page)
to retrieve the current namespace if the comp argument is null.scope
- the scope as the context to interpret the script.
If null, the current scope is assumed.
The current scope is Scopes.getCurrent(org.zkoss.zk.ui.Page)
, which
is the event target's scope, if the thread is processing an event.
The event target is Event.getTarget()
.
Otherwise, the current scope is the owner page (getOwner()
.java.lang.Class<?> getClass(java.lang.String clsnm)
Function getFunction(java.lang.String name, java.lang.Class[] argTypes)
argTypes
- the list of argument (a.k.a., parameter) types.
If null, Class[0] is assumed.boolean containsVariable(java.lang.String name)
Scope
).java.lang.Object getVariable(java.lang.String name)
Scope
).void setVariable(java.lang.String name, java.lang.Object value)
Note: it is not part of any namespace and it has higher priority if its name conflicts with any variable defined in the namespaces.
void unsetVariable(java.lang.String name)
Copyright © 2005-2023 Potix Corporation. All Rights Reserved.