condor.classad
Class SelectExpr

Object
  extended bycondor.classad.Expr
      extended bycondor.classad.SelectExpr

public class SelectExpr
extends Expr

An internal (non-leaf) node of an expression tree, representing a selection of component of a record. It has the form from a class ad in the form

    <expr> . <identifier>.
 

Version:
2.1
Author:
Marvin Solomon
See Also:
Expr

Nested Class Summary
 
Nested classes inherited from class condor.classad.Expr
Expr.Env
 
Field Summary
 Expr base
          The left argument (base expression) of the selection operator.
 AttrName selector
          The right argument (identifier) 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
SelectExpr(Expr base, AttrName selector)
          Create a new SelectExpr corresponding to base.selector.
SelectExpr(Expr base, String selector)
          Create a new SelectExpr corresponding to base.selector.
 
Method Summary
protected  Expr eval1(Expr.Env env)
          Evaluate this Expr.
 int prec()
          The precedence of the operator in this expression node.
static Expr select(Expr base, String[] sel)
          A convenience function for creating a SelectExpression corresponding to "base.a.b.c".
 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, 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 selection operator.


selector

public final AttrName selector
The right argument (identifier) of the selection operator.

Constructor Detail

SelectExpr

public SelectExpr(Expr base,
                  String selector)
Create a new SelectExpr corresponding to base.selector.

Parameters:
base - the left argument (base expression).
selector - the right argument (identifier).

SelectExpr

public SelectExpr(Expr base,
                  AttrName selector)
Create a new SelectExpr corresponding to base.selector.

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

select

public static Expr select(Expr base,
                          String[] sel)
A convenience function for creating a SelectExpression corresponding to "base.a.b.c".

Parameters:
base - the base Expr.
sel - the sequence of selectors {"a", "b", "c"}
Returns:
a new SelectExpr or base if sel is empty.

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

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(Expr.Env env)
Evaluate this Expr. This is the internal method used to implement Expr.eval(). The base is evaluated to yield a record or list. In the case of a record, the selector is used to choose the appropriate component, and the record is added to the environment. In the case of a list, the selection is distributed across the list. In all other cases, the result is the ERROR constant.

Specified by:
eval1 in class Expr
Parameters:
env - an environment used to evaluate the base. If the base evaluates to a RecordExpr, it is added to the env (as the first (innermost) scope) before returning.
Returns:
the result of the selection.