Package com.artenum.rosetta.test
Class FakeGenericInterpreter
- java.lang.Object
-
- com.artenum.rosetta.test.FakeGenericInterpreter
-
- All Implemented Interfaces:
GenericInterpreter
public class FakeGenericInterpreter extends java.lang.Object implements GenericInterpreter
-
-
Constructor Summary
Constructors Constructor Description FakeGenericInterpreter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objecteval(java.io.Reader reader)Same aseval(String)except that the source of the script is provided as aReaderjava.lang.Objecteval(java.lang.String script)Executes the specified script.java.lang.Objectget(java.lang.String key)Retrieves a value set in the state of this engine.java.io.WritergetErrorWriter()Returns theWriterused to display error output.java.io.ReadergetReader()Returns aReaderto be used by the script to read input.java.io.WritergetWriter()Returns theWriterfor scripts to use when displaying output.voidput(java.lang.String key, java.lang.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.voidsetErrorWriter(java.io.Writer writer)Sets theWriterused to display error output.voidsetReader(java.io.Reader reader)Sets theReaderfor scripts to read input .voidsetWriter(java.io.Writer writer)Sets theWriterfor scripts to use when displaying output.
-
-
-
Method Detail
-
eval
public java.lang.Object eval(java.lang.String script) throws ScriptExceptionDescription copied from interface:GenericInterpreterExecutes the specified script. The defaultScriptContextfor theScriptEngineis used.- Specified by:
evalin interfaceGenericInterpreter- 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 java.lang.Object eval(java.io.Reader reader) throws ScriptExceptionDescription copied from interface:GenericInterpreterSame aseval(String)except that the source of the script is provided as aReader- Specified by:
evalin interfaceGenericInterpreter- Parameters:
reader- The source of the script.- Returns:
- The value returned by the script.
- Throws:
ScriptException- if an error occurrs in script.
-
get
public java.lang.Object get(java.lang.String key)
Description copied from interface:GenericInterpreterRetrieves a value set in the state of this engine. The value might be one which was set usingsetValueor some other value in the state of theScriptEngine, depending on the implementation. Must have the same effect asgetBindings(ScriptContext.ENGINE_SCOPE).get- Specified by:
getin interfaceGenericInterpreter- Parameters:
key- The key whose value is to be returned- Returns:
- the value for the given key
-
getErrorWriter
public java.io.Writer getErrorWriter()
Description copied from interface:GenericInterpreterReturns theWriterused to display error output.- Specified by:
getErrorWriterin interfaceGenericInterpreter- Returns:
- The
Writer
-
getReader
public java.io.Reader getReader()
Description copied from interface:GenericInterpreterReturns aReaderto be used by the script to read input.- Specified by:
getReaderin interfaceGenericInterpreter- Returns:
- The
Reader.
-
getWriter
public java.io.Writer getWriter()
Description copied from interface:GenericInterpreterReturns theWriterfor scripts to use when displaying output.- Specified by:
getWriterin interfaceGenericInterpreter- Returns:
- The
Writer.
-
put
public void put(java.lang.String key, java.lang.Object value)Description copied from interface:GenericInterpreterSets 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 asgetBindings(ScriptContext.ENGINE_SCOPE).put.- Specified by:
putin interfaceGenericInterpreter- Parameters:
key- The name of named value to addvalue- The value of named value to add.
-
setErrorWriter
public void setErrorWriter(java.io.Writer writer)
Description copied from interface:GenericInterpreterSets theWriterused to display error output.- Specified by:
setErrorWriterin interfaceGenericInterpreter- Parameters:
writer- TheWriter.
-
setReader
public void setReader(java.io.Reader reader)
Description copied from interface:GenericInterpreterSets theReaderfor scripts to read input .- Specified by:
setReaderin interfaceGenericInterpreter- Parameters:
reader- The newReader.
-
setWriter
public void setWriter(java.io.Writer writer)
Description copied from interface:GenericInterpreterSets theWriterfor scripts to use when displaying output.- Specified by:
setWriterin interfaceGenericInterpreter- Parameters:
writer- The newWriter.
-
-