Interface GenericInterpreter
-
- All Known Implementing Classes:
FakeGenericInterpreter
public interface GenericInterpreter
-
-
Method Summary
All Methods Instance Methods Abstract 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
java.lang.Object eval(java.lang.String script) throws ScriptExceptionExecutes the specified script. The defaultScriptContextfor theScriptEngineis 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.java.lang.NullPointerException- if the argument is null.
-
eval
java.lang.Object eval(java.io.Reader reader) throws ScriptExceptionSame aseval(String)except that the source of the script is provided as aReader- Parameters:
reader- The source of the script.- Returns:
- The value returned by the script.
- Throws:
ScriptException- if an error occurrs in script.java.lang.NullPointerException- if the argument is null.
-
put
void put(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. Must have the same effect asgetBindings(ScriptContext.ENGINE_SCOPE).put.- Parameters:
key- The name of named value to addvalue- The value of named value to add.- Throws:
java.lang.NullPointerException- if key is null.java.lang.IllegalArgumentException- if key is empty.
-
get
java.lang.Object get(java.lang.String key)
Retrieves 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- Parameters:
key- The key whose value is to be returned- Returns:
- the value for the given key
- Throws:
java.lang.NullPointerException- if key is null.java.lang.IllegalArgumentException- if key is empty.
-
getWriter
java.io.Writer getWriter()
Returns theWriterfor scripts to use when displaying output.- Returns:
- The
Writer.
-
getErrorWriter
java.io.Writer getErrorWriter()
Returns theWriterused to display error output.- Returns:
- The
Writer
-
setWriter
void setWriter(java.io.Writer writer)
Sets theWriterfor scripts to use when displaying output.- Parameters:
writer- The newWriter.
-
setErrorWriter
void setErrorWriter(java.io.Writer writer)
Sets theWriterused to display error output.- Parameters:
writer- TheWriter.
-
getReader
java.io.Reader getReader()
Returns aReaderto be used by the script to read input.- Returns:
- The
Reader.
-
setReader
void setReader(java.io.Reader reader)
Sets theReaderfor scripts to read input .- Parameters:
reader- The newReader.
-
-