## php.java.script
Class PhpScriptEngine

    java.lang.Object
      javax.script.AbstractScriptEngine
          php.java.script.PhpScriptEngine

All Implemented Interfaces:
  Invocable, ScriptEngine

Direct Known Subclasses:
  PhpFacesScriptEngine

    public class PhpScriptEngine

extends AbstractScriptEngine
implements Invocable

This class implements the ScriptEngine.

Example:

`ScriptEngine e = new PhpScriptEngine();
e.eval(new URLReader(new URL("http://localhost/foo.php"));
System.out.println(((Invocable)e).invoke("java_get_server_name", new Object[]{}));
e.release();
`

Author:
  jostb

Field Summary

Fields inherited from interface javax.script.ScriptEngine
`ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME`

Constructor Summary
`PhpScriptEngine()` Create a new ScriptEngine.

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 bindings)` 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 bindings)` Evaluates a piece of script using the specified namespace as its SCRIPT_SCOPE.
`java.lang.Object` `eval(java.lang.String script, ScriptContext context)` Evaluates a script using the namespaces in the specifed ScriptContext.
`ScriptEngineFactory` `getFactory()` Retrieves a ScriptEngineFactory for the class to which describes the underlying ScriptEngine.
`java.lang.Object` `getInterface(java.lang.Class clasz)` Retrieves an instance of java class whose methods are impelemented using procedures in script which are in the intermediate code repository in the underlying interpreter.
`java.lang.Object` `getInterface(java.lang.Object thiz, java.lang.Class clasz)` Retrieves an instance of java class whose methods are impelemented using procedures in script which are in the intermediate code repository in the underlying interpreter.
`java.lang.Object` `invoke(java.lang.Object thiz, java.lang.String methodName, java.lang.Object[] args)` Invokes a procedure on an object which already defined in the script using the array of objects as its arguments set.
`java.lang.Object` `invoke(java.lang.String methodName, java.lang.Object[] args)` Invokes a scripting procedure with the given name using the array of objects as its arguments set.
`void` `release()` Release the continuation

Methods inherited from class javax.script.AbstractScriptEngine
`get, getBindings, getContext, put, setBindings, setContext`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PhpScriptEngine

    public PhpScriptEngine()

  Create a new ScriptEngine.

Method Detail

### invoke

    public java.lang.Object invoke(java.lang.String methodName,
                                   java.lang.Object[] args)
                            throws ScriptException

  Description copied from interface: `Invocable`
  Invokes a scripting procedure with the given name using the array of objects as its arguments set.

  Specified by:
    `invoke` in interface `Invocable`
  Parameters:
    `methodName` - name of the scripting procedure
    `args` - arguments set for the scripting procedure
  Returns:
    resultant object after the execution of the procedure
  Throws:
    `ScriptException` - if the invocation of the scripting procedure fails

### invoke

    public java.lang.Object invoke(java.lang.Object thiz,
                                   java.lang.String methodName,
                                   java.lang.Object[] args)
                            throws ScriptException,
                                   java.lang.RuntimeException

  Description copied from interface: `Invocable`
  Invokes a procedure on an object which already defined in the script using the array of objects as its arguments set.

  Specified by:
    `invoke` in interface `Invocable`
  Parameters:
    `thiz` - object on which the procedure is called
    `methodName` - name of the procedure to be invoked
    `args` - arguments set for the procedure
  Returns:
    resultant object after the execution of the procedure
  Throws:
    `ScriptException` - if the invocation of the procedure fails
    `java.lang.RuntimeException`

### getInterface

    public java.lang.Object getInterface(java.lang.Class clasz)

  Description copied from interface: `Invocable`
  Retrieves an instance of java class whose methods are impelemented using procedures in script which are in the intermediate code repository in the underlying interpreter.

  Specified by:
    `getInterface` in interface `Invocable`
  Parameters:
    `clasz` - an interface which the returned class must implement
  Returns:
    an instance of the class which implement the specified interface

### getInterface

    public java.lang.Object getInterface(java.lang.Object thiz,
                                         java.lang.Class clasz)

  Description copied from interface: `Invocable`
  Retrieves an instance of java class whose methods are impelemented using procedures in script which are in the intermediate code repository in the underlying interpreter.

  Specified by:
    `getInterface` in interface `Invocable`
  Parameters:
    `thiz` - object on which the procedure is called
    `clasz` - an interface which the returned class must implement
  Returns:
    an instance of the class which implement the specified interface

### eval

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

  Description copied from interface: `ScriptEngine`
  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

  Specified by:
    `eval` in interface `ScriptEngine`
  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

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

  Description copied from interface: `ScriptEngine`
  Evaluates a script using the namespaces in the specifed ScriptContext. Return null for non-returning scripts.

  Specified by:
    `eval` in interface `ScriptEngine`
  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

### getFactory

    public ScriptEngineFactory getFactory()

  Description copied from interface: `ScriptEngine`
  Retrieves a ScriptEngineFactory for the class to which describes the underlying ScriptEngine.

  Specified by:
    `getFactory` in interface `ScriptEngine`
  Returns:
    an instance of ScriptEngineFactory which describes the underlying ScriptEngine

### release

    public void release()

  Release the continuation

### createBindings

    public Bindings createBindings()

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

  Specified by:
    `createBindings` in interface `ScriptEngine`
  Returns:
    an initialzed namespace which can be used to repalce the state of the ScriptEngine

### eval

    public java.lang.Object eval(java.io.Reader reader,
                                 Bindings bindings)
                          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.

  Specified by:
    `eval` in interface `ScriptEngine`
  Overrides:
    `eval` in class `AbstractScriptEngine`
  Parameters:
    `reader` - the reader from which the script is obtained
    `bindings` - the namespace to be used as SCRIPT_SCOPE
  Returns:
    the value of the evaluated script
  Throws:
    `ScriptException` - if an error occurs

### eval

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

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

  Specified by:
    `eval` in interface `ScriptEngine`
  Overrides:
    `eval` in class `AbstractScriptEngine`
  Parameters:
    `script` - the String representation of the script
    `bindings` - the namespace to be used as the SCRIPT_SCOPE
  Returns:
    the value of the evaluated script
  Throws:
    `ScriptException` - if an error occurs

### eval

    public 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.

  Specified by:
    `eval` in interface `ScriptEngine`
  Overrides:
    `eval` in class `AbstractScriptEngine`
  Parameters:
    `reader` - the reader form which the script is obtained
  Returns:
    the value of the evaluated script
  Throws:
    `ScriptException` - if an error occurs

### eval

    public 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.

  Specified by:
    `eval` in interface `ScriptEngine`
  Overrides:
    `eval` in class `AbstractScriptEngine`
  Parameters:
    `script` - the String representation of the script
  Returns:
    the value of the evaluated script
  Throws:
    `ScriptException` - if an error occurs