koala.dynamicjava.interpreter
Interface Interpreter

All Known Implementing Classes:
TreeInterpreter

public interface Interpreter

The classes that implements this interface represent the objects that holds the objects needed for interpretation.


Method Summary
 void addClassPath(java.lang.String path)
          Adds a class search path
 void addClassURL(java.net.URL url)
          Adds a class search URL
 void addLibraryPath(java.lang.String path)
          Adds a library search path
 void addLibrarySuffix(java.lang.String s)
          Adds a library file suffix
 java.lang.Class defineClass(java.lang.String name, byte[] code)
          Converts an array of bytes into an instance of class Class
 void defineVariable(java.lang.String name, java.lang.Object value)
          Defines a variable in the interpreter environment
 boolean getAccessible()
          Observe the state of calls to setAccessible()
 java.lang.ClassLoader getClassLoader()
          Gets the class loader
 java.util.Set getClassNames()
          Returns the defined class names
 LibraryFinder getLibraryFinder()
          Gets the library finder
 ParserFactory getParserFactory()
          Gets the parser factory
 java.lang.Object getVariable(java.lang.String name)
          Gets the value of a variable
 java.lang.Class getVariableClass(java.lang.String name)
          Gets the class of a variable
 java.util.Set getVariableNames()
          Returns the defined variable names
 java.lang.Object interpret(java.io.InputStream is, java.lang.String fname)
          Runs the interpreter
 java.lang.Object interpret(java.io.Reader r, java.lang.String fname)
          Runs the interpreter
 java.lang.Object interpret(java.lang.String fname)
          Runs the interpreter
 java.lang.Class loadClass(java.lang.String name)
          Loads an interpreted class
 void setAccessible(boolean accessible)
          Set the interpreter contexts to override public/protected/private access restrictions on the methods and fields it handles.
 void setVariable(java.lang.String name, java.lang.Object value)
          Sets the value a variable
 

Method Detail

interpret

public java.lang.Object interpret(java.io.InputStream is,
                                  java.lang.String fname)
                           throws InterpreterException
Runs the interpreter

Parameters:
is - the input stream from which the statements are read
fname - the name of the parsed stream
Returns:
the result of the evaluation of the last statement
Throws:
InterpreterException

interpret

public java.lang.Object interpret(java.io.Reader r,
                                  java.lang.String fname)
                           throws InterpreterException
Runs the interpreter

Parameters:
r - the reader
fname - the name of the parsed stream
Returns:
the result of the evaluation of the last statement
Throws:
InterpreterException

interpret

public java.lang.Object interpret(java.lang.String fname)
                           throws InterpreterException,
                                  java.io.IOException
Runs the interpreter

Parameters:
fname - the name of a file to interpret
Returns:
the result of the evaluation of the last statement
Throws:
InterpreterException
java.io.IOException

defineVariable

public void defineVariable(java.lang.String name,
                           java.lang.Object value)
Defines a variable in the interpreter environment

Parameters:
name - the variable's name
value - the initial value of the variable
Throws:
java.lang.IllegalStateException - if name is already defined

setVariable

public void setVariable(java.lang.String name,
                        java.lang.Object value)
Sets the value a variable

Parameters:
name - the variable's name
value - the value of the variable
Throws:
java.lang.IllegalStateException - if the assignment is invalid

getVariable

public java.lang.Object getVariable(java.lang.String name)
Gets the value of a variable

Parameters:
name - the variable's name
Throws:
java.lang.IllegalStateException - if the variable do not exist

getVariableClass

public java.lang.Class getVariableClass(java.lang.String name)
Gets the class of a variable

Parameters:
name - the variable's name
Throws:
java.lang.IllegalStateException - if the variable do not exist

getVariableNames

public java.util.Set getVariableNames()
Returns the defined variable names

Returns:
a set of strings

getClassNames

public java.util.Set getClassNames()
Returns the defined class names

Returns:
a set of strings

setAccessible

public void setAccessible(boolean accessible)
Set the interpreter contexts to override public/protected/private access restrictions on the methods and fields it handles. Default should be false, i.e. enforce Java access. Setting to true should override this and allow access to all fields.


getAccessible

public boolean getAccessible()
Observe the state of calls to setAccessible()


addClassPath

public void addClassPath(java.lang.String path)
Adds a class search path

Parameters:
path - the path to add

addClassURL

public void addClassURL(java.net.URL url)
Adds a class search URL

Parameters:
url - the url to add

addLibraryPath

public void addLibraryPath(java.lang.String path)
Adds a library search path

Parameters:
path - the path to add

addLibrarySuffix

public void addLibrarySuffix(java.lang.String s)
Adds a library file suffix

Parameters:
s - the suffix to add

loadClass

public java.lang.Class loadClass(java.lang.String name)
                          throws java.lang.ClassNotFoundException
Loads an interpreted class

Throws:
java.lang.ClassNotFoundException - if the class cannot be find

defineClass

public java.lang.Class defineClass(java.lang.String name,
                                   byte[] code)
Converts an array of bytes into an instance of class Class

Throws:
java.lang.ClassFormatError - if the class could not be defined

getClassLoader

public java.lang.ClassLoader getClassLoader()
Gets the class loader


getLibraryFinder

public LibraryFinder getLibraryFinder()
Gets the library finder


getParserFactory

public ParserFactory getParserFactory()
Gets the parser factory



Copyright © 2001 Stephane Hillion. All Rights Reserved.