condor.classad
Class Context

java.lang.Object
  |
  +--condor.classad.Context

public class Context
extends Object

A context for evaluating ClassAd expressions. It consists of a pointer to the outermost classad of the ``top-level'' expression being evaluated and two hash tables.

The first table maps subexpressions to the results of evaluating them. It serves not only to ``memoize'' computed results as a shortcut to speed up evaluation but also (perhaps more importantly) to detect circular references.

The second table maps classad expressions to their parent scopes. The parent scope of a classad is normally the classad that immediately encloses statically, but may be any classad expression in special cases. In particular, this flexibility is used by ClassAd.bind to create a Context in which each of two RecordExprs is the parent of the other.

Eventually, other transient state may be added to this class to allow iteration through a set of results, etc.

See Also:
ClassAd.bind(condor.classad.RecordExpr, condor.classad.RecordExpr)

Field Summary
 RecordExpr root
          The outermost classad of the expression being evaluated.
 
Constructor Summary
Context(RecordExpr root)
          Create a new context.
 
Method Summary
 RecordExpr getParent(RecordExpr expr)
          Look for a cached parent binding.
 Expr getValue(Expr expr)
          Look for a cached evaluation.
 Context setParent(RecordExpr expr, RecordExpr value)
          Record the parent RecordExpr of a given node
 Context setValue(Expr expr, Expr value)
          Record the computed value of a given node.
 String toString()
          Convert this Context to a string, for debugging purposes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

root

public final RecordExpr root
The outermost classad of the expression being evaluated. There must always be a unique outermost classad when an expression is evaluated. This field is used to evaluate absolute attribute references of the form ``.name''.
Constructor Detail

Context

public Context(RecordExpr root)
Create a new context.
Parameters:
root - the outermost classad in the expression being evaluated.
Method Detail

getValue

public Expr getValue(Expr expr)
Look for a cached evaluation. If none is found, return null, but mark the transalation as ``in progress''.
Parameters:
expr - the Expr node.
Returns:
the translation, or null if none found

setValue

public Context setValue(Expr expr,
                        Expr value)
Record the computed value of a given node.
Parameters:
expr - the given Expr node.
value - the corresponding value.
Returns:
this Context

getParent

public RecordExpr getParent(RecordExpr expr)
Look for a cached parent binding.
Parameters:
expr - a RecordExpr node.
Returns:
the translation, or null if none found

setParent

public Context setParent(RecordExpr expr,
                         RecordExpr value)
Record the parent RecordExpr of a given node
Parameters:
expr - the given RecordExpr node.
value - the enclosing RecordExpr.
Returns:
this Context.

toString

public String toString()
Convert this Context to a string, for debugging purposes.
Overrides:
toString in class Object
Returns:
a string representation of the this Context