com.artenum.rosetta.test
Class FakeGenericInterpreter

java.lang.Object
  extended by com.artenum.rosetta.test.FakeGenericInterpreter
All Implemented Interfaces:
GenericInterpreter

public class FakeGenericInterpreter
extends Object
implements GenericInterpreter

Author:
Sebastien Jourdain (jourdain@artenum.com)

Constructor Summary
FakeGenericInterpreter()
           
 
Method Summary
 Object eval(Reader reader)
          Same as eval(String) except that the source of the script is provided as a Reader
 Object eval(String script)
          Executes the specified script.
 Object get(String key)
          Retrieves a value set in the state of this engine.
 Writer getErrorWriter()
          Returns the Writer used to display error output.
 Reader getReader()
          Returns a Reader to be used by the script to read input.
 Writer getWriter()
          Returns the Writer for scripts to use when displaying output.
 void put(String key, Object value)
          Sets a key/value pair in the state of the ScriptEngine that may either create a Java Language Binding to be used in the execution of scripts or be used in some other way, depending on whether the key is reserved.
 void setErrorWriter(Writer writer)
          Sets the Writer used to display error output.
 void setReader(Reader reader)
          Sets the Reader for scripts to read input .
 void setWriter(Writer writer)
          Sets the Writer for scripts to use when displaying output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FakeGenericInterpreter

public FakeGenericInterpreter()
Method Detail

eval

public Object eval(String script)
            throws ScriptException
Description copied from interface: GenericInterpreter
Executes the specified script. The default ScriptContext for the ScriptEngine is used.

Specified by:
eval in interface GenericInterpreter
Parameters:
script - The script language source to be executed.
Returns:
The value returned from the execution of the script.
Throws:
ScriptException - if error occurrs in script.

eval

public Object eval(Reader reader)
            throws ScriptException
Description copied from interface: GenericInterpreter
Same as eval(String) except that the source of the script is provided as a Reader

Specified by:
eval in interface GenericInterpreter
Parameters:
reader - The source of the script.
Returns:
The value returned by the script.
Throws:
ScriptException - if an error occurrs in script.

get

public Object get(String key)
Description copied from interface: GenericInterpreter
Retrieves a value set in the state of this engine. The value might be one which was set using setValue or some other value in the state of the ScriptEngine, depending on the implementation. Must have the same effect as getBindings(ScriptContext.ENGINE_SCOPE).get

Specified by:
get in interface GenericInterpreter
Parameters:
key - The key whose value is to be returned
Returns:
the value for the given key

getErrorWriter

public Writer getErrorWriter()
Description copied from interface: GenericInterpreter
Returns the Writer used to display error output.

Specified by:
getErrorWriter in interface GenericInterpreter
Returns:
The Writer

getReader

public Reader getReader()
Description copied from interface: GenericInterpreter
Returns a Reader to be used by the script to read input.

Specified by:
getReader in interface GenericInterpreter
Returns:
The Reader.

getWriter

public Writer getWriter()
Description copied from interface: GenericInterpreter
Returns the Writer for scripts to use when displaying output.

Specified by:
getWriter in interface GenericInterpreter
Returns:
The Writer.

put

public void put(String key,
                Object value)
Description copied from interface: GenericInterpreter
Sets a key/value pair in the state of the ScriptEngine that may either create a Java Language Binding to be used in the execution of scripts or be used in some other way, depending on whether the key is reserved. Must have the same effect as getBindings(ScriptContext.ENGINE_SCOPE).put.

Specified by:
put in interface GenericInterpreter
Parameters:
key - The name of named value to add
value - The value of named value to add.

setErrorWriter

public void setErrorWriter(Writer writer)
Description copied from interface: GenericInterpreter
Sets the Writer used to display error output.

Specified by:
setErrorWriter in interface GenericInterpreter
Parameters:
writer - The Writer.

setReader

public void setReader(Reader reader)
Description copied from interface: GenericInterpreter
Sets the Reader for scripts to read input .

Specified by:
setReader in interface GenericInterpreter
Parameters:
reader - The new Reader.

setWriter

public void setWriter(Writer writer)
Description copied from interface: GenericInterpreter
Sets the Writer for scripts to use when displaying output.

Specified by:
setWriter in interface GenericInterpreter
Parameters:
writer - The new Writer.


Copyright © 2007-2011 Artenum. All Rights Reserved.