com.artenum.rosetta.interfaces.core
Interface GenericInterpreter

All Known Implementing Classes:
FakeGenericInterpreter

public interface GenericInterpreter

Author:
Sebastien Jourdain (jourdain@artenum.com)

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.
 

Method Detail

eval

Object eval(String script)
            throws ScriptException
Executes the specified script. The default ScriptContext for the ScriptEngine is used.

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.
NullPointerException - if the argument is null.

eval

Object eval(Reader reader)
            throws ScriptException
Same as eval(String) except that the source of the script is provided as a Reader

Parameters:
reader - The source of the script.
Returns:
The value returned by the script.
Throws:
ScriptException - if an error occurrs in script.
NullPointerException - if the argument is null.

put

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. Must have the same effect as getBindings(ScriptContext.ENGINE_SCOPE).put.

Parameters:
key - The name of named value to add
value - The value of named value to add.
Throws:
NullPointerException - if key is null.
IllegalArgumentException - if key is empty.

get

Object get(String key)
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

Parameters:
key - The key whose value is to be returned
Returns:
the value for the given key
Throws:
NullPointerException - if key is null.
IllegalArgumentException - if key is empty.

getWriter

Writer getWriter()
Returns the Writer for scripts to use when displaying output.

Returns:
The Writer.

getErrorWriter

Writer getErrorWriter()
Returns the Writer used to display error output.

Returns:
The Writer

setWriter

void setWriter(Writer writer)
Sets the Writer for scripts to use when displaying output.

Parameters:
writer - The new Writer.

setErrorWriter

void setErrorWriter(Writer writer)
Sets the Writer used to display error output.

Parameters:
writer - The Writer.

getReader

Reader getReader()
Returns a Reader to be used by the script to read input.

Returns:
The Reader.

setReader

void setReader(Reader reader)
Sets the Reader for scripts to read input .

Parameters:
reader - The new Reader.


Copyright © 2007-2011 Artenum. All Rights Reserved.