|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgroovy.lang.GroovyObjectSupport
org.norther.tammi.core.scripter.groovy.GroovyInterpreter
public class GroovyInterpreter
A Groovy interpreter.
| Field Summary |
|---|
| Fields inherited from interface org.norther.tammi.core.scripter.lang.Interpreter |
|---|
JAVA_LANGUAGE |
| Constructor Summary | |
|---|---|
GroovyInterpreter()
Constructs a new interpreter. |
|
GroovyInterpreter(Binding context)
Constructs a new interpreter with a context. |
|
GroovyInterpreter(ClassLoader loader)
Constructs a new interpreter with a class loader. |
|
GroovyInterpreter(ClassLoader loader,
Binding context)
Constructs a new interpreter with a class loader and context. |
|
GroovyInterpreter(GroovyInterpreter interpreter)
Constructs a new child interpreter. |
|
| Method Summary | |
|---|---|
void |
addClassPath(String path)
Adds a class search path. |
void |
addClassURL(URL url)
Adds a class search URL. |
Class<?> |
defineClass(String name,
byte[] code)
Converts an array of bytes into a class. |
void |
defineVariable(String name,
Object value)
Defines a variable in the interpreter environment. |
void |
defineVariable(String name,
Object value,
Class<?> c)
Defines a variable of the specified class. |
ClassLoader |
getClassLoader()
Gets the class loader. |
Set<String> |
getClassNames()
Gets the defined class names. |
Binding |
getContext()
Gets the context. |
String |
getEncoding()
Gets the encoding. |
Object |
getVariable(String name)
Gets the value of a variable. |
Class<?> |
getVariableClass(String name)
Gets the class of a variable. |
Set<String> |
getVariableNames()
Gets the defined variable names. |
Object |
interpret(File file)
Interprets a file. |
Object |
interpret(GroovyObject object)
Interprets a groovy object. |
Object |
interpret(InputStream in,
String fname)
Interprets an input stream. |
Object |
interpret(Reader r,
String fname)
Interprets a reader. |
Object |
interpret(String s,
String fname)
Interprets a string. |
Object |
interpret(URL url)
Interprets a URL. |
boolean |
isDefined(String name)
Checks whether a variable is defined. |
Class<?> |
loadClass(String name)
Loads an interpreted class. |
GroovyObject |
parseGroovyObject(File file)
Parses a groovy object from a file. |
GroovyObject |
parseGroovyObject(InputStream in,
String fname)
Parses a groovy object from a stream. |
GroovyObject |
parseGroovyObject(URL url)
Parses a groovy object from a URL. |
void |
reset()
Resets this interpreter. |
void |
setVariable(String name,
Object value)
Sets the value of a variable. |
| Methods inherited from class groovy.lang.GroovyObjectSupport |
|---|
getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GroovyInterpreter()
public GroovyInterpreter(Binding context)
context - the context.public GroovyInterpreter(ClassLoader loader)
loader - the parent class loader.
public GroovyInterpreter(ClassLoader loader,
Binding context)
loader - the class loader.context - the context.public GroovyInterpreter(GroovyInterpreter interpreter)
interpreter - the parent interpreter.| Method Detail |
|---|
public Object interpret(String s,
String fname)
Interpreter
interpret in interface Interpreters - the string from which the statements are read.fname - the name of the parsed string.
public Object interpret(InputStream in,
String fname)
Interpreter
interpret in interface Interpreterin - the input stream from which the statements are read.fname - the name of the parsed stream.
public Object interpret(Reader r,
String fname)
Interpreter
interpret in interface Interpreterr - the reader.fname - the name of the parsed stream.
public Object interpret(File file)
throws IOException
Interpreter
interpret in interface Interpreterfile - the file to interpret.
IOException - on I/O errors.
public Object interpret(URL url)
throws IOException
Interpreter
interpret in interface Interpreterurl - the url to interpret.
IOException - on I/O errors.
public void defineVariable(String name,
Object value)
Interpreter
defineVariable in interface Interpretername - the variable's name.value - the initial value of the variable.
public void defineVariable(String name,
Object value,
Class<?> c)
Interpreter
defineVariable in interface Interpretername - the name.value - the value.c - the class.public boolean isDefined(String name)
Interpreter
isDefined in interface Interpretername - the name.
public Object getVariable(String name)
Interpreter
getVariable in interface Interpretername - the variable name.
public void setVariable(String name,
Object value)
Interpreter
setVariable in interface Interpretername - the variable name.value - the value of the variable.public Class<?> getVariableClass(String name)
Interpreter
getVariableClass in interface Interpretername - the variable name.
public Set<String> getVariableNames()
Interpreter
getVariableNames in interface Interpreterpublic void reset()
Interpreter
reset in interface Interpreterpublic void addClassPath(String path)
Interpreter
addClassPath in interface Interpreterpath - the path to add.public void addClassURL(URL url)
Interpreter
addClassURL in interface Interpreterurl - the url to add.
public Class<?> loadClass(String name)
throws ClassNotFoundException
Interpreter
loadClass in interface Interpretername - the fully qualified name of the class to load.
ClassNotFoundException - if the class cannot be find.
public Class<?> defineClass(String name,
byte[] code)
Interpreter
defineClass in interface Interpretername - the fully qualified name of the class to load.code - the byte code of the class.
public Set<String> getClassNames()
Interpreter
getClassNames in interface Interpreterpublic ClassLoader getClassLoader()
Interpreter
getClassLoader in interface Interpreterpublic Object interpret(GroovyObject object)
object - the parsed object.
Error - if interpretation fails.public Binding getContext()
public String getEncoding()
public GroovyObject parseGroovyObject(File file)
throws IllegalAccessException,
InstantiationException,
PrivilegedActionException
file - the file.
IllegalAccessException - if no default constructor.
InstantiationException - if instantiation fails.
PrivilegedActionException - if file not found.
public GroovyObject parseGroovyObject(URL url)
throws IllegalAccessException,
InstantiationException,
PrivilegedActionException
url - the URL.
IllegalAccessException - if no default constructor.
InstantiationException - if instantiation fails.
PrivilegedActionException - if URL not available.
public GroovyObject parseGroovyObject(InputStream in,
String fname)
throws IllegalAccessException,
InstantiationException
in - the input stream.fname - the file name.
IllegalAccessException - if no default constructor.
InstantiationException - if instantiation fails.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||