org.hava.engine
Class HEngine

java.lang.Object
  extended by org.hava.engine.HEngine

public class HEngine
extends java.lang.Object

Public API for the Hava calculator.


Constructor Summary
HEngine()
          Creates a new engine having no default import address.
HEngine(java.lang.String address)
          Creates a new engine having the given default import address.
 
Method Summary
 void abort()
          Causes run to stop calculating and return.
 HReference createReference(java.lang.String identifier)
          Creates a reference to a simple variable, from which its value may be obtained.
 HReference createReference(java.lang.String identifier, HValue[] a)
          Creates a reference to an indexed variable, from which its value may be obtained.
 HValue createStructValue(java.lang.String identifier, HValue[] a)
          Creates an HValue of type structure (or null, if the given identifier is not defined as a structure).
 HValue createTokenValue(java.lang.String identifier)
          Creates an HValue of type token (or null, if the given identifier is not defined as a token)
 void generateReport(java.io.Writer reportWriter)
          Generates a report, using the default generator.
 int getValueCount()
          Obtains the number of calculated values (for use by progress bar).
 java.util.List<HReference> getVariableReferenceSet()
          Returns the list of non-private variable references for which values have been calculated (for use by custom report generator).
 void load(java.io.Reader sourceReader)
          Loads the given Hava source.
 void load(java.lang.String source)
          Loads the given Hava source.
 void registerFunction(HFunction f)
          Extend Hava to recognize a function written in Java.
 void registerIterator(HIterator t)
          Extend Hava to recognize am iterator written in Java.
 void reset()
          Clears all definitions and values from the engine, while retaining the current default import address.
 void reset(java.lang.String address)
          Clears all definitions and values from the engine, and sets a new default import address.
 void run()
          Evaluates all non-indexed variables of the current Hava program.
 void run(java.io.Writer traceWriter)
          Evaluates all non-indexed variables of the current Hava program, and generates a trace.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HEngine

public HEngine()
Creates a new engine having no default import address.


HEngine

public HEngine(java.lang.String address)
Creates a new engine having the given default import address.

Method Detail

abort

public void abort()
Causes run to stop calculating and return.


createReference

public HReference createReference(java.lang.String identifier)
Creates a reference to a simple variable, from which its value may be obtained. Returns null if the given identifier is not defined as a simple variable.


createReference

public HReference createReference(java.lang.String identifier,
                                  HValue[] a)
Creates a reference to an indexed variable, from which its value may be obtained. Returns null if the given identifier is not defined as an indexed variable with the corresponding number of arguments.


createStructValue

public HValue createStructValue(java.lang.String identifier,
                                HValue[] a)
Creates an HValue of type structure (or null, if the given identifier is not defined as a structure).


createTokenValue

public HValue createTokenValue(java.lang.String identifier)
Creates an HValue of type token (or null, if the given identifier is not defined as a token)


generateReport

public void generateReport(java.io.Writer reportWriter)
                    throws java.io.IOException
Generates a report, using the default generator.

Throws:
java.io.IOException

getValueCount

public int getValueCount()
Obtains the number of calculated values (for use by progress bar).


getVariableReferenceSet

public java.util.List<HReference> getVariableReferenceSet()
Returns the list of non-private variable references for which values have been calculated (for use by custom report generator).


load

public void load(java.io.Reader sourceReader)
          throws HException,
                 java.io.IOException
Loads the given Hava source.

Throws:
HException
java.io.IOException

load

public void load(java.lang.String source)
          throws HException
Loads the given Hava source.

Throws:
HException

registerFunction

public void registerFunction(HFunction f)
Extend Hava to recognize a function written in Java.


registerIterator

public void registerIterator(HIterator t)
Extend Hava to recognize am iterator written in Java.


reset

public void reset()
Clears all definitions and values from the engine, while retaining the current default import address.


reset

public void reset(java.lang.String address)
Clears all definitions and values from the engine, and sets a new default import address.


run

public void run()
         throws HException
Evaluates all non-indexed variables of the current Hava program.

Throws:
HException

run

public void run(java.io.Writer traceWriter)
         throws HException,
                java.io.IOException
Evaluates all non-indexed variables of the current Hava program, and generates a trace.

Throws:
HException
java.io.IOException