condor.classad
Class SubscriptExpr

Object
  extended bycondor.classad.Expr
      extended bycondor.classad.SubscriptExpr

public class SubscriptExpr
extends Expr

A selection from a list. An internal (non-leaf) node of an expression tree representing a subscript applied to base expression: base[selector]. Two combinations of types are possible: Either the base is a ListExpr and the selector evaluates to an integer, or the base is a RecordExpr and the subscript evaluates to a string. In the latter case, base["x"] is equivalent to base.x except that the "selector" does not have to be a literal string.

Version:
2.2
Author:
Marvin Solomon
See Also:
Expr

Field Summary
 Expr base
          The left argument (base expression) of the subscript operator.
 Expr selector
          The right argument (subscript) of the selection operator.
 
Fields inherited from class condor.classad.Expr
ABSOLUTE_TIME, AND, ATTRIBUTE, BIT_COMPLEMENT, BITAND, BITOR, BITXOR, BOOLEAN, CALL, COND, dblevel, DIFFERENT, DIV, EQUAL, ERROR, GREATER, GREATER_EQ, INTEGER, LEFT_SHIFT, LESS, LESS_EQ, LIST, MAXPREC, MINUS, MOD, NOT, NOT_EQUAL, OP, opName, opNameXML, OR, PLUS, REAL, RECORD, RELATIVE_TIME, RIGHT_SHIFT, SAME, SELECTION, STRING, SUBSCRIPT, TIMES, type, UMINUS, UNDEFINED, UPLUS, URIGHT_SHIFT
 
Constructor Summary
SubscriptExpr(Expr base, Expr selector)
          Create a new SubscriptExpr.
 
Method Summary
protected  Expr eval1(Env env)
          Evaluate this Expr.
 int prec()
          The precedence of the operator in this expression node.
 boolean sameAs(Expr other)
          Compare this Expr to another expression to check for "deep structural equality".
 StringBuffer toString(StringBuffer sb)
          Convert this Expr to a string, appending the result to the end of "sb".
protected  String typeName()
          The type of the expression.
 
Methods inherited from class condor.classad.Expr
db, db, eval, eval, intValue, is, isConstant, isTrue, realValue, selectExpr, stringValue, subExpr, toString
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

base

public final Expr base
The left argument (base expression) of the subscript operator.


selector

public final Expr selector
The right argument (subscript) of the selection operator.

Constructor Detail

SubscriptExpr

public SubscriptExpr(Expr base,
                     Expr selector)
Create a new SubscriptExpr.

Parameters:
base - the left argument (base expression).
selector - the right argument (subscript).
Method Detail

typeName

protected String typeName()
The type of the expression. This should never be called!

Overrides:
typeName in class Expr
Returns:
the string "selection".

toString

public StringBuffer toString(StringBuffer sb)
Convert this Expr to a string, appending the result to the end of "sb". The representation is the "canonical native format": base '[' selector ']', with no extra spaces.

Specified by:
toString in class Expr
Parameters:
sb - a place to put the result.
Returns:
sb.
See Also:
ClassAdWriter

sameAs

public boolean sameAs(Expr other)
Compare this Expr to another expression to check for "deep structural equality".

Specified by:
sameAs in class Expr
Parameters:
other - the other expression
Returns:
true of this and the other expression are isomorphic.

prec

public int prec()
The precedence of the operator in this expression node. Used to print expressions without superfluous parentheses.

Specified by:
prec in class Expr
Returns:
the precendence of this node.
See Also:
ClassAdWriter.MINIMAL_PARENTHESES

eval1

protected Expr eval1(Env env)
Evaluate this Expr. This is the internal method used to implement Expr.eval(). The base and selector should evaluate to a List and an integer or a Record and a string. In the latter case, this SubscriptExpr is semantically equivalent to a SelectExpr. In either case, the appropriate component of the base value is then returned. If the types of the base and selector do not mactch, the result is the ERROR constant.

Specified by:
eval1 in class Expr
Parameters:
env - an environment used to evaluate the base and selector; it is updated to the resulting environment from the evaluation of the base.
Returns:
the result of the subscripting operation.