Java Reference
In-Depth Information
// Use the result object to get the returned value from
// the script
int returnedValue = result.getValue(); // Will be 101
System.out.println("Returned value is " + returnedValue);
}
}
Returned value is 101
Reserved Keys for Engine Scope Bindings
Typically, a key in the engine scope Bindings represents a script variable. Some keys are
reserved and they have special meanings. Their values may be passed to the engine by the
implementation of the engine. An implementation may define additional reserved keys.
Table 3-1 contains the list of all reserved keys. Those keys are also declared as
constants in the ScriptEngine interface. An implementation of a script engine is not
required to pass all these keys to the engine in the engine scope bindings. As a developer,
you are not supposed to use these keys to pass parameters from a Java application to a
script engine.
Table 3-1. The List of Reserved Keys for Engine Scope Bindings
Key
Constant in ScriptEngine
Interface
Meaning of the Value of the Key
ScriptEngine.ARGV
“javax.script.argv”
Used to pass an array of Object to
pass a set of positional argument
ScriptEngine.ENGINE
“javax.script.engine”
The name of the script engine
ScriptEngine.ENGINE_
VERSION
“javax.script.engine_
version”
The version of the script engine
“javax.script.filename” ScriptEngine.FILENAME
Used to pass the name of the file
or the resource that the source of
the script
“javax.script.language” ScriptEngine.LANGUAGE
The name of the language
supported by the script engine
ScriptEngine.LANGUAGE_
VERSION
“javax.script.
language_version”
The version of the scripting
language supported by the
engine
ScriptEngine.NAME
“javax.script.name”
The short name of the scripting
language
 
 
Search WWH ::




Custom Search