org.omegahat.Environment.Interpreter
Class UtilityEvaluator

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

public class UtilityEvaluator
extends BasicEvaluator

This provides some simple utility methods which act like functions for the interactive user due to the implicit this in the Omegahat language. These are all syntactic sugar that simplify the access to other objects that are available via the evaluator, but akwardly so. The utilities are

See Also:
Serialized Form

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
UtilityEvaluator()
           
UtilityEvaluator(Evaluator parent)
          Creation of the evaluator by copying the settings from the parent evaluator.
UtilityEvaluator(EvaluatorManager manager)
          Creation using the default evaluator from the manager and registering as a responsibility of the manager for use in its endeavors (e.g.
UtilityEvaluator(Options opts)
          Construction of the evaluator with the specified settings in the Options object.
 
Method Summary
 Evaluator evaluator()
          The current evaluator.
 java.lang.Object exec(java.lang.String cmd)
          Executes the specified command as a sub-process and the lines of output resutling from the command.
 java.lang.Object exec(java.lang.String cmd, boolean display)
          Execute the specified shell command and return optionally the resulting Process object, or a Vector of the output lines displayed by executing the command, depending on whether display is false or true.
 java.lang.Object findFile(java.lang.String name)
          Locate a file using the standard lookup mechanism available from the EvaluatorManager's findFile() method.
 Evaluator getEvaluator()
          The current evaluator object.
 java.lang.String setProperty(java.lang.String name, java.lang.String value)
          Set the system-level property using the given name and value.
 java.lang.String setProperty(java.lang.String name, java.lang.String value, boolean append)
          Optionally overwrite or append the value to the specified system property.
 
Methods inherited from class org.omegahat.Environment.Interpreter.BasicEvaluator
addEvaluationListener, addFunctionTable, addFunctionTable, addMethod, 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, parser, 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
 

Constructor Detail

UtilityEvaluator

public UtilityEvaluator()

UtilityEvaluator

public UtilityEvaluator(Options opts)
Construction of the evaluator with the specified settings in the Options object.

UtilityEvaluator

public UtilityEvaluator(Evaluator parent)
Creation of the evaluator by copying the settings from the parent evaluator.

UtilityEvaluator

public UtilityEvaluator(EvaluatorManager manager)
Creation using the default evaluator from the manager and registering as a responsibility of the manager for use in its endeavors (e.g. scheduling tasks across evaluators, etc.)
Method Detail

findFile

public java.lang.Object findFile(java.lang.String name)
Locate a file using the standard lookup mechanism available from the EvaluatorManager's findFile() method.
Parameters:
name - the name of the file to be found.

setProperty

public java.lang.String setProperty(java.lang.String name,
                                    java.lang.String value)
Set the system-level property using the given name and value. This overwrites any existing value.
Parameters:
name - the name of the property being modified.
value - the value to which the property is to be set.

setProperty

public java.lang.String setProperty(java.lang.String name,
                                    java.lang.String value,
                                    boolean append)
Optionally overwrite or append the value to the specified system property.
Parameters:
name - the name of the property of interest
append - whether to append or overwrite the current value, if any, of the specified property.

getEvaluator

public Evaluator getEvaluator()
The current evaluator object.

Provides as a property the the underlying this object inherent in the evaluation model.


evaluator

public Evaluator evaluator()
The current evaluator.

For consistency with JavaBeans conventions, use getEvaluator() instead of this method.


exec

public java.lang.Object exec(java.lang.String cmd)
                      throws java.io.IOException
Executes the specified command as a sub-process and the lines of output resutling from the command.
Parameters:
cmd - the shell command
See Also:
exec(java.lang.String, boolean)

exec

public java.lang.Object exec(java.lang.String cmd,
                             boolean display)
                      throws java.io.IOException
Execute the specified shell command and return optionally the resulting Process object, or a Vector of the output lines displayed by executing the command, depending on whether display is false or true.
Parameters:
cmd - the shell command to execute
display - whether to return the lines of output as Vector or the Process object.
Returns:
a Process giving access to the resulting process, or Vector object containing the lines of output from the command.