Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.script
Interface ScriptEngine

All Known Implementing Classes:
  AbstractScriptEngine, InteractivePhpScriptEngine, InvocablePhpScriptEngine, PhpScriptEngine

    public interface ScriptEngine

The ScriptEngine interfaces contains only the methods which are expected to be fully functional in every Java ScriptEngine.

Author:
  Nandika Jayawardana , Sanka Samaranayake

Field Summary
`static java.lang.String` | `ARGV` Reserved key associated with an object array which is used to pass set of positional parameters to the ScriptEngines.
`static java.lang.String` | `ENGINE` Reserved key associated with the name of the Java ScriptEngine
`static java.lang.String` | `ENGINE_VERSION` Reserved key associated with the version of the Java ScriptEngine
`static java.lang.String` | `FILENAME` Reserved key associated with name of the file which contains the source of the script.
`static java.lang.String` | `LANGUAGE` Reserved key associated with the name of the supported scripting language
`static java.lang.String` | `LANGUAGE_VERSION` Reserved key associated with the version of the supported scripting language
`static java.lang.String` | `NAME` Reserved key associated with the named value which identifies the short name of the supported language

Method Summary
`Bindings` | `createBindings()` Retrieves an uninitailized namespace which can be used as the scope of the ScriptEngine.
`java.lang.Object` | `eval(java.io.Reader reader)` Evaluates a piece of script obtained using the specified reader as the script source.
`java.lang.Object` | `eval(java.io.Reader reader, Bindings namespace)` Evaluates a piece of scripts obtained using a reader as the script source and using the specified namespace as the SCRIPT_SCOPE.
`java.lang.Object` | `eval(java.io.Reader reader, ScriptContext context)` Evaluates a script obtained using the specified reader as the script source and using the namespaces in the specifed ScriptContext.
`java.lang.Object` | `eval(java.lang.String script)` Evaluates a piece of script and returns the resultant object.
`java.lang.Object` | `eval(java.lang.String script, Bindings namespace)` Evaluates a piece of script using the specified namespace as the SCRIPT_SCOPE.
`java.lang.Object` | `eval(java.lang.String script, ScriptContext context)` Evaluates a script using the namespaces in the specifed ScriptContext.
`java.lang.Object` | `get(java.lang.String key)` Retrieves the value which is associated with the specified key in the state of the ScriptEngine.
`Bindings` | `getBindings(int scope)` Retrieves a reference to the associated namespace for the specified level of scope.
`ScriptContext` | `getContext()`
`ScriptEngineFactory` | `getFactory()` Retrieves a ScriptEngineFactory for the class to which describes the underlying ScriptEngine.
`void` | `put(java.lang.String key, java.lang.Object value)` Associates a key and a value in the ScriptEngine namespace.
`void` | `setBindings(Bindings namespace, int scope)` Associates the specified namespace with the specified level of scope.
`void` | `setContext(ScriptContext ctx)` Set the default ScriptContext

Field Detail

### ARGV

    static final java.lang.String ARGV

  Reserved key associated with an object array which is used to pass set of positional parameters to the ScriptEngines.

  See Also:
    Constant Field Values

### FILENAME

    static final java.lang.String FILENAME

  Reserved key associated with name of the file which contains the source of the script.

  See Also:
    Constant Field Values

### ENGINE

    static final java.lang.String ENGINE

  Reserved key associated with the name of the Java ScriptEngine

  See Also:
    Constant Field Values

### ENGINE_VERSION

    static final java.lang.String ENGINE_VERSION

  Reserved key associated with the version of the Java ScriptEngine

  See Also:
    Constant Field Values

### LANGUAGE

    static final java.lang.String LANGUAGE

  Reserved key associated with the name of the supported scripting language

  See Also:
    Constant Field Values

### LANGUAGE_VERSION

    static final java.lang.String LANGUAGE_VERSION

  Reserved key associated with the version of the supported scripting language

  See Also:
    Constant Field Values

### NAME

    static final java.lang.String NAME

  Reserved key associated with the named value which identifies the short name of the supported language

  See Also:
    Constant Field Values

Method Detail

### createBindings

    Bindings createBindings()

  Retrieves an uninitailized namespace which can be used as the scope of the ScriptEngine.

  Returns:
    an initialzed namespace which can be used to repalce the state of the ScriptEngine

### eval

    java.lang.Object eval(java.io.Reader reader)
                          throws ScriptException

  Evaluates a piece of script obtained using the specified reader as the script source. Returns null for non-returning scripts.

  Parameters:
    `reader` - the source of the script
  Returns:
    the value of the evaluated script
  Throws:
    `ScriptException` - if an error occurs

### eval

    java.lang.Object eval(java.io.Reader reader,
                          Bindings namespace)
                          throws ScriptException

  Evaluates a piece of scripts obtained using a reader as the script source and using the specified namespace as the SCRIPT_SCOPE. Returns null for non-returning scripts.

  Parameters:
    `reader` - the script source used to obtained the script
    `namespace` - the namespace to be used as SCRIPT_SCOPE
  Returns:
    the value of the evaluated script
  Throws:
    `ScriptException` - if an error occurs

### eval

    java.lang.Object eval(java.io.Reader reader,
                          ScriptContext context)
                          throws ScriptException

  Evaluates a script obtained using the specified reader as the script source and using the namespaces in the specifed ScriptContext. Returns null for non-returning scripts

  Parameters:
    `reader` - the script source
    `context` - the context contianing different namespace for script evaluation
  Returns:
    the value of the evaluated script
  Throws:
    `ScriptException` - if an error occurs

### eval

    java.lang.Object eval(java.lang.String script)
                          throws ScriptException

  Evaluates a piece of script and returns the resultant object. Returns null for non-returning scripts.

  Parameters:
    `script` - the String representation of the script
  Returns:
    the value of the evaluated script
  Throws:
    `ScriptException` - if an error occurs

### eval

    java.lang.Object eval(java.lang.String script,
                          Bindings namespace)
                          throws ScriptException

  Evaluates a piece of script using the specified namespace as the SCRIPT_SCOPE. Retruns null for non-returning scripts.

  Parameters:
    `script` - the String representation of the script
    `namespace` - the namespace to be used as the SCRIPT_SCOPE
  Returns:
    the value of the evaluated script
  Throws:
    `ScriptException` - if an error occurs

### eval

    java.lang.Object eval(java.lang.String script,
                          ScriptContext context)
                          throws ScriptException

  Evaluates a script using the namespaces in the specifed ScriptContext. Return null for non-returning scripts.

  Parameters:
    `script` - the String representation of the script
    `context` - tbe ScriptContext containing namespaces for the script evaluation
  Returns:
    the value of the evaluated script
  Throws:
    `ScriptException` - if an error occurs

### get

    java.lang.Object get(java.lang.String key)

  Retrieves the value which is associated with the specified key in the state of the ScriptEngine.

  Parameters:
    `key` - the key associated with value.
  Returns:
    an object value which is associated with the key

### getFactory

    ScriptEngineFactory getFactory()

  Retrieves a ScriptEngineFactory for the class to which describes the underlying ScriptEngine.

  Returns:
    an instance of ScriptEngineFactory which describes the underlying ScriptEngine

### getBindings

    Bindings getBindings(int scope)
                         throws java.lang.IllegalArgumentException

  Retrieves a reference to the associated namespace for the specified level of scope. Possible scopes are: GLOBAL_SCOPE : if the ScriptEngine was created by ScriptingEngineManager then GLOBAL_SCOPE of it is returned (or null if there is no GLOBAL_SCOPE stored in the ScriptEngine). ENGINE_SCOPE : the set of key-value pairs stored in the ScriptEngine is returned.

  Parameters:
    `scope` - the specified level of scope
  Returns:
    associated namespace for the specified level of scope
  Throws:
    `java.lang.IllegalArgumentException` - if the scope is invalid

### put

    void put(java.lang.String key,
             java.lang.Object value)
             throws java.lang.IllegalArgumentException

  Associates a key and a value in the ScriptEngine namespace.

  Parameters:
    `key` - the specified key associated with the value
    `value` - value which is to be associated with the specified key
  Throws:
    `java.lang.IllegalArgumentException` - if the key is null

### setBindings

    void setBindings(Bindings namespace,
                     int scope)
                     throws java.lang.IllegalArgumentException

  Associates the specified namespace with the specified level of scope.

  Parameters:
    `namespace` - namespace to be associated with the specified level of scope
    `scope` - level of scope for which the namespace should be associated with
  Throws:
    `if` - the scope is invalid
    `java.lang.IllegalArgumentException`

### getContext

    ScriptContext getContext()

  Returns:
    the default ScriptContext.

### setContext

    void setContext(ScriptContext ctx)

  Set the default ScriptContext

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD