org.omegahat.Environment.Interpreter
Class UserClassEvaluator

java.lang.Object
  |
  +--org.omegahat.Environment.Interpreter.BasicEvaluator
        |
        +--org.omegahat.Environment.Interpreter.UtilityEvaluator
              |
              +--org.omegahat.Environment.Interpreter.UserClassEvaluator
All Implemented Interfaces:
DatabaseCustomer, Evaluator, ManagedEvaluatorInt, java.lang.Runnable, java.io.Serializable
Direct Known Subclasses:
InteractiveEvaluator, SignallableEvaluator, TaskQueueEvaluator

public class UserClassEvaluator
extends UtilityEvaluator

This evaluator provides initial support for user-level interpreted classes org.omegahat.Environment.Language.UserClasses. These support fields, methods as functions and multiple inheritance. This is very experimental and unfinished. Most of the ideas have been worked out except the ability to define an interpreted Omegahat class that extends a compiled Java class. The methods remain unimplemented here but are relatively simple invocation of methods in other classes.

See Also:
Serialized Form

Field Summary
protected  UserClassManager classManager
          A table managing the different classes that have been defined in the context of this evaluator.
 
Fields inherited from class org.omegahat.Environment.Interpreter.BasicEvaluator
allowUnrestrictedAccess, class_lists, currentExpression, data, databases, debugger, DefaultAttachIndex, defaultDatabase, dynamicClassLoader, errorHandler, evaluationEvent, evaluationListeners, initialized, internalFunctionTables, internalPrimitiveClassNames, internalPrimitiveClassTable, lexer, localClasses, manager, options, output, parser, primitive_classes, primitiveClasses, PrimitiveClassNames, primitiveTypeNames, primitiveTypes, reversePrimitiveTypes, ShowMultipleClasses, sourceStack, stderr, stdout, SubEvaluationListeners, taskHistory, toplevelExpression, warningMessages
 
Fields inherited from interface org.omegahat.Environment.Interpreter.Evaluator
ThisVariableName
 
Constructor Summary
UserClassEvaluator()
           
UserClassEvaluator(Evaluator src)
           
UserClassEvaluator(EvaluatorManager manager)
           
UserClassEvaluator(Options opts)
           
 
Method Summary
 boolean addMethod(Method method, Name name)
          Add an interpreted method (function) to the user-level class identified by the given name relative to the entries in the classManager.
 UserClassManager classManager()
          Returns the {@UserClassManger} object containing all the user-level classes defined at this point in the evaluator.
 UserClassManager classManager(UserClassManager mgr)
          Set the table of defined classes.
 UserClassInstance createInstance(Name name)
          Create an instance of the user-level class identified by the sequence of elements in the Name object which identifies it by package and name in the classManager.
 UserClassInstance createInstance(java.lang.String name)
          Instantiate an object from the user-level class identified by the name.
 UserClassInstance createInstance(UserClass Class)
          Create an instance of the specified user-level class.
 AbstractUserClass defineClass(AbstractUserClass cl)
          Register the user-level/interpreted class in the classManager table.
 AbstractUserClass defineClass(java.lang.String name)
          Define a simple class that does not inherit from any class.
 AbstractUserClass defineClass(java.lang.String name, boolean defineAndLoad)
           
 AbstractUserClass defineClass(java.lang.String name, java.lang.String superClass)
           
 AbstractUserClass defineClass(java.lang.String name, java.util.Vector superClasses)
          Define a new class with the given name and the collection of base classes from which it inherits.
 AbstractUserClass defineClass(java.lang.String name, java.util.Vector superClasses, boolean isAbstract)
          Define a class with the given name and base classes from which it inherits and also indicate whether it is considered an abstract class.
 java.lang.Object DefineUserClass(java.lang.String name)
           
 java.lang.Object DefineUserClass(java.lang.String name, boolean compileAndLoad)
           
 java.lang.Object DefineUserClass(java.lang.String name, boolean compileAndLoad, boolean localInitialization)
           
 AbstractUserClass findUserClass(Name name)
          Return a reference to the class definition identified by the elements in the Name object.
 AbstractUserClass findUserClass(java.lang.String name)
          Return a reference to the class definition identified by the given name in the classManager object.
 java.lang.Object parseClass(java.lang.String file)
           
 omegaJavaGrammar parser(antlr.Tokenizer lexer)
          Local version of the parser object constructor which sets whether we handle single quotes as identifying Character objects or Strings.
 
Methods inherited from class org.omegahat.Environment.Interpreter.UtilityEvaluator
evaluator, exec, exec, findFile, getEvaluator, setProperty, setProperty
 
Methods inherited from class org.omegahat.Environment.Interpreter.BasicEvaluator
addEvaluationListener, addFunctionTable, addFunctionTable, addSourceInput, addToHistory, allowUnrestrictedAccess, allowUnrestrictedAccess, asObject, asObject, asObject, asObjectName, asPrimitiveClass, assign, assign, assign, asWriter, attach, attach, attach, attach, attach, attach, attach, classInit, classLists, classLists, classPath, classPath, commandLine, convertPrimitive, copy, copy, copyByConstructor, copyBySerialization, createClassLists, currentExpression, currentExpression, data, data, database, database, database, Debug, Debug, Debug, Debug, Debug, debugger, debugger, defaultDatabase, defaultDatabase, defaultDatabase, defaultErrorHandler, detach, detach, displayTask, displayTask, displayWarnings, displayWarnings, dynamicClassLoader, dynamicClassLoader, endSource, endSource, endSource, endTaskEvaluation, error, error, errorHandler, errorHandler, evaluate, evaluate, evaluate, evaluate, evaluationError, evaluationListeners, evaluationListeners, evaluationListeners, exists, exit, exit, expandClassName, expandedClassPathElement, find, findAsField, findClass, findClass, findClass, findClass, findFunction, findFunctionOrMethod, functionTableList, get, get, get, get, get, get, get, get, get, getBaseURL, getEvaluationEvent, getEvaluationListeners, getField, getSubEvaluationListeners, help, Import, Import, Import, init, initialize, initTaskEvaluation, internalFunctionTables, isPrimitive, isPrimitive, javaVersion, lexer, lexer, lexer, localClasses, localClasses, manager, manager, newDatabase, newDatabase, notifyListeners, notifyListeners, objects, objects, objects, options, options, output, output, output, parse, parse, parse, parse, primitiveClass, q, q, remove, remove, remove, removeFunctionTable, run, same, searchForClass, searchPath, searchPath, searchPath, searchPath, setEvaluationEvent, setEvaluationListeners, setSubEvaluationListeners, show, show, show, source, source, source, source, source, source, source, source, source, sourceStack, stderr, stderr, stdout, stdout, taskHistory, taskHistory, toplevelExpression, toplevelExpression, useLazyEvaluation, warning, warning, warning, warnings, warnings, where, which, which
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classManager

protected UserClassManager classManager
A table managing the different classes that have been defined in the context of this evaluator. This should be able to handle different name spaces resulting from different packages.
Constructor Detail

UserClassEvaluator

public UserClassEvaluator()

UserClassEvaluator

public UserClassEvaluator(Evaluator src)

UserClassEvaluator

public UserClassEvaluator(Options opts)

UserClassEvaluator

public UserClassEvaluator(EvaluatorManager manager)
Method Detail

classManager

public UserClassManager classManager()
Returns the {@UserClassManger} object containing all the user-level classes defined at this point in the evaluator.

classManager

public UserClassManager classManager(UserClassManager mgr)
Set the table of defined classes. This is normally done when we de-serialize an object containing this information as we construct this evaluator.

parser

public omegaJavaGrammar parser(antlr.Tokenizer lexer)
Local version of the parser object constructor which sets whether we handle single quotes as identifying Character objects or Strings.
Overrides:
parser in class BasicEvaluator

defineClass

public AbstractUserClass defineClass(java.lang.String name,
                                     java.util.Vector superClasses)
                              throws java.lang.ClassNotFoundException
Define a new class with the given name and the collection of base classes from which it inherits.

defineClass

public AbstractUserClass defineClass(java.lang.String name,
                                     java.lang.String superClass)
                              throws java.lang.ClassNotFoundException

defineClass

public AbstractUserClass defineClass(java.lang.String name)
                              throws java.lang.ClassNotFoundException,
                                     java.lang.Throwable
Define a simple class that does not inherit from any class.

defineClass

public AbstractUserClass defineClass(java.lang.String name,
                                     boolean defineAndLoad)
                              throws java.lang.ClassNotFoundException,
                                     java.lang.Throwable
Parameters:
name - the name of a file, URL, etc. resolved by the EvaluatorManager's findFile(String) containing or alternatively the name of the new class.
defineAndLoad - flag indicating whether to actually compile the resulting Java class and load it via the dynamic class loader

DefineUserClass

public java.lang.Object DefineUserClass(java.lang.String name)
                                 throws java.lang.Throwable

DefineUserClass

public java.lang.Object DefineUserClass(java.lang.String name,
                                        boolean compileAndLoad)
                                 throws java.lang.Throwable

DefineUserClass

public java.lang.Object DefineUserClass(java.lang.String name,
                                        boolean compileAndLoad,
                                        boolean localInitialization)
                                 throws java.lang.Throwable
See Also:
OmegahatUserClassHelper

defineClass

public AbstractUserClass defineClass(java.lang.String name,
                                     java.util.Vector superClasses,
                                     boolean isAbstract)
                              throws java.lang.ClassNotFoundException
Define a class with the given name and base classes from which it inherits and also indicate whether it is considered an abstract class.

defineClass

public AbstractUserClass defineClass(AbstractUserClass cl)
Register the user-level/interpreted class in the classManager table.

createInstance

public UserClassInstance createInstance(java.lang.String name)
Instantiate an object from the user-level class identified by the name.

createInstance

public UserClassInstance createInstance(Name name)
Create an instance of the user-level class identified by the sequence of elements in the Name object which identifies it by package and name in the classManager.

createInstance

public UserClassInstance createInstance(UserClass Class)
Create an instance of the specified user-level class.

findUserClass

public AbstractUserClass findUserClass(java.lang.String name)
                                throws java.lang.ClassNotFoundException
Return a reference to the class definition identified by the given name in the classManager object.

findUserClass

public AbstractUserClass findUserClass(Name name)
                                throws java.lang.ClassNotFoundException
Return a reference to the class definition identified by the elements in the Name object.

addMethod

public boolean addMethod(Method method,
                         Name name)
Add an interpreted method (function) to the user-level class identified by the given name relative to the entries in the classManager.
Overrides:
addMethod in class BasicEvaluator

parseClass

public java.lang.Object parseClass(java.lang.String file)