|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--condor.classad.Expr
A node of an expression tree. An Expr is one of
RecordExpr
[name = expr, ... ]
,
SelectExpr
a.b
,
ListExpr
{ expr1, expr2, ... }
,
SubscriptExpr
a[i]
,
CondExpr
a ? b : c
,
Op
FuncCall
AttrRef
[.]identifier[.identifier]
, or
Constant
RecordExpr
,
SelectExpr
,
ListExpr
,
SubscriptExpr
,
CondExpr
,
Op
,
FuncCall
,
AttrRef
,
Constant
Field Summary | |
static int |
ABSOLUTE_TIME
A type flag indicating that this is an absolute time value |
static int |
AND
Token ID corresponding to the operator && |
static int |
ATTRIBUTE
A type flag indicating that this is an attribute reference |
static int |
BIT_COMPLEMENT
Token ID corresponding to the operator unary ~ |
static int |
BITAND
Token ID corresponding to the operator & |
static int |
BITOR
Token ID corresponding to the operator | |
static int |
BITXOR
Token ID corresponding to the operator ^ |
static int |
BOOLEAN
A type flag indicating that this is a boolean value |
static int |
BRIEF
A combination of option flags for toString() . |
static int |
CALL
A type flag indicating that this is a function call |
static int |
COMPACT
A combination of option flags for toString() . |
static int |
COND
A type flag indicating that this is a conditional expression |
static int |
dblevel
Flag to control level of verbosity of debugging input. |
static int |
DIFFERENT
Token ID corresponding to the operator isnt |
static int |
DIV
Token ID corresponding to the operator / |
static int |
EQUAL
Token ID corresponding to the operator == |
static int |
ERROR
A type flag indicating that this is an error value |
protected static int |
formatFlags
Flags to control the formatting of expressions by toString() . |
static String |
formatIndent
A standing indent for all expressions whose string representation spans multiple lines. |
static int |
GREATER
Token ID corresponding to the operator > |
static int |
GREATER_EQ
Token ID corresponding to the operator >= |
static int |
INTEGER
A type flag indicating that this is an integer value |
static int |
LEFT_SHIFT
Token ID corresponding to the operator << |
static int |
LESS
Token ID corresponding to the operator < |
static int |
LESS_EQ
Token ID corresponding to the operator <= |
static int |
LIST
A type flag indicating that this is a list |
protected static int |
MAXPREC
The maximum precedence in the grammar for ClassAd expressions. |
static int |
MINIMAL_PARENTHESES
An option flag for toString() . |
static int |
MINUS
Token ID corresponding to the operator - |
static int |
MOD
Token ID corresponding to the operator % |
static int |
MULTI_LINE_ADS
An option flag for toString() . |
static int |
MULTI_LINE_LISTS
An option flag for toString() . |
static int |
NO_ESCAPE_STRINGS
An option flag for toString() . |
static int |
NOT
Token ID corresponding to the operator unary ! |
static int |
NOT_EQUAL
Token ID corresponding to the operator != |
static int |
OP
A type flag indicating that this is a unary or binary operator |
static String[] |
opName
A table mapping operator codes to character-string names. |
static int |
OR
Token ID corresponding to the operator || |
static int |
PLUS
Token ID corresponding to the operator + |
static int |
READABLE
A combination of option flags for toString() . |
static int |
REAL
A type flag indicating that this is a real value |
static int |
RECORD
A type flag indicating that this is a record (classad) |
static int |
RELATIVE_TIME
A type flag indicating that this is a relative time value |
static int |
RIGHT_SHIFT
Token ID corresponding to the operator >> |
static int |
SAME
Token ID corresponding to the operator is |
static int |
SELECTION
A type flag indicating that this is a selection (a.b) |
static int |
SHOW_ERROR_DETAIL
An option flag for toString() . |
static int |
SHOW_INSTANCES
An option flag for toString() . |
static int |
STRING
A type flag indicating that this is a string value |
static int |
SUBSCRIPT
A type flag indicating that this is a selection (a.b) |
static int |
TIMES
Token ID corresponding to the operator * |
int |
type
The "type" of this expression. |
static int |
UMINUS
Token ID corresponding to the operator unary - |
static int |
UNDEFINED
A type flag indicating that this is an undefined value |
static int |
UPLUS
Token ID corresponding to the operator unary + |
static int |
URIGHT_SHIFT
Token ID corresponding to the operator >>> |
Method Summary | |
static void |
db(boolean newline,
Object msg)
Debugging print. |
static void |
db(Object msg)
Debugging print. |
static void |
disableFormatFlags(int flags)
Turn off options for converting expressions to strings. |
static void |
enableFormatFlags(int flags)
Turn on options for converting expressions to strings. |
Expr |
eval(Context ctx)
Evaluate this Expr. |
static int |
getFormatFlags()
Get existing options for converting expressions to strings. |
protected boolean |
isConstant()
Indicate whether this is a constant. |
protected boolean |
isNormalForm()
Indicate whether this is a normal-form expression. |
protected String |
mark()
Conditionally return an indication of the unique instance represented by this expression. |
protected String |
mark(boolean on)
Conditionally return an indication of the unique instance represented by this expression. |
protected static String |
mark(Expr expr)
Return an indication of the unique instance of the argument. |
protected abstract int |
prec()
The precedence of the operator in this expression node. |
protected Expr |
reEval(Context ctx)
Evalutate this expression. |
SelectExpr |
select(String selector)
A convenience function for creating a SelectExpression corresponding to ``this.selector'' |
static void |
setFormatFlags(int flags)
Set options for converting expressions to strings. |
abstract String |
toString()
Convert this Expr to a string. |
String |
toString(int flags)
Convert this Expr to a string. |
protected String |
typeName()
Determine the type of this expression (for printing messages). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public final int type
For non-atomic values, the type is one of COND, OP, CALL, SELECTION, SUBSCRIPT, ATTRIBUTE, LIST, or RECORD. Note that these values are all less than zero.
public static final int COND
public static final int OP
public static final int CALL
public static final int SELECTION
public static final int SUBSCRIPT
public static final int ATTRIBUTE
public static final int LIST
public static final int RECORD
public static final int UNDEFINED
public static final int ERROR
public static final int BOOLEAN
public static final int INTEGER
public static final int REAL
public static final int STRING
public static final int ABSOLUTE_TIME
public static final int RELATIVE_TIME
public static String formatIndent
protected static int formatFlags
toString()
. A value of zero creates a representation
that is unambiguous and easy to parse but not very readable. Each bit
turns on a formatting feature that makes the string more readable, but
perhaps more verbose and/or ambiguous.NO_ESCAPE_STRINGS
,
SHOW_ERROR_DETAIL
,
MINIMAL_PARENTHESES
,
MULTI_LINE_ADS
,
MULTI_LINE_LISTS
,
SHOW_INSTANCES
,
BRIEF
,
COMPACT
,
READABLE
public static final int NO_ESCAPE_STRINGS
toString()
.
Don't surround strings with quotes or escape special characters in the
string.
WARNING: Strings created with this flag cannot be parsed to recover the expressions that created them.
formatFlags
public static final int SHOW_ERROR_DETAIL
toString()
.
Print the ERROR value as ``ERROR(reason)'' rather than just ``ERROR''.formatFlags
public static final int MINIMAL_PARENTHESES
toString()
.
Use only as many parentheses are are required to override the default
precendence of operators.formatFlags
public static final int MULTI_LINE_ADS
toString()
.
Display classads with one attribute per line.formatFlags
public static final int MULTI_LINE_LISTS
toString()
.
Display lists with one member per line.formatFlags
public static final int SHOW_INSTANCES
toString()
.
Flag certain kinds of expressions with a marker indicating unique
instances.
This is a temporary debugging feature that may be removed from future
revisions of this package.formatFlags
public static final int BRIEF
toString()
.
Produce a concise version (both MINIMAL_PARENTHESES and
NO_ESCAPE_STRINGS)formatFlags
,
MINIMAL_PARENTHESES
,
NO_ESCAPE_STRINGS
public static final int COMPACT
toString()
.
Produce a compact but parsable version (currently, the same as
MINIMAL_PARENTHESES).formatFlags
,
MINIMAL_PARENTHESES
public static final int READABLE
toString()
.
Produce a maximally-readable version (all flags other than
SHOW_INSTANCES).formatFlags
,
SHOW_INSTANCES
protected static final int MAXPREC
public static int dblevel
public static final String[] opName
opName[NOT_EQUAL] = "!="
.public static final int OR
public static final int AND
public static final int BITOR
public static final int BITXOR
public static final int BITAND
public static final int EQUAL
public static final int NOT_EQUAL
public static final int SAME
public static final int DIFFERENT
public static final int LESS
public static final int GREATER
public static final int LESS_EQ
public static final int GREATER_EQ
public static final int LEFT_SHIFT
public static final int RIGHT_SHIFT
public static final int URIGHT_SHIFT
public static final int PLUS
public static final int MINUS
public static final int TIMES
public static final int DIV
public static final int MOD
public static final int UPLUS
public static final int UMINUS
public static final int BIT_COMPLEMENT
public static final int NOT
Method Detail |
protected String typeName()
protected String mark(boolean on)
on
- indicates whether to indicate the particular instance.on
is true, a string of the form
<nn>, where nn is a decimal integer, otherwise an empty string.protected String mark()
Expr.formatFlags
includes the flag
Expr.SHOW_INSTANCES
, a string of the form
<nn>, where nn is a decimal integer, otherwise an empty string.protected static String mark(Expr expr)
expr
- an expression instance or null
expr==null
, otherwise
expr.mark()
.mark()
public Expr eval(Context ctx)
The Context records a mapping from non-normal-form expressions to their values. It speeds up evaluation and guarentees termination.
Theorem: Evaluation is linear-time in the size of the original Expr.
Proof: When evaluation of an expression is started, the Context maps it to an UndefinedConstant. If the evaluation process recursively requests the value of the same expression, the result is that UndefinedConstant. When the evaluation of a particular subexpression is complete, the Context replaces the UndefinedConstant with a reference to the computed value. This value may be either a sub-expression of the original expression or a newly created Expr value, but in any case, it will be in normal form. Thus a value found in the Context will never require re-evaluation.
In short, a top-level call to eval will never attempt to evaluate any node more than once, and the total number of new nodes created is bounded by the number of nodes in the original expression. QED
ctx
- an evaluation context for evaluating this expressionContext
protected final boolean isNormalForm()
protected final boolean isConstant()
protected Expr reEval(Context ctx)
ctx
- an evaluation context for evaluating this expressioneval(condor.classad.Context)
public SelectExpr select(String selector)
selector
- a selector.public static void setFormatFlags(int flags)
flag
- the new flag values.NO_ESCAPE_STRINGS
,
SHOW_ERROR_DETAIL
,
MINIMAL_PARENTHESES
,
MULTI_LINE_ADS
,
MULTI_LINE_LISTS
,
BRIEF
,
COMPACT
,
READABLE
public static int getFormatFlags()
NO_ESCAPE_STRINGS
,
SHOW_ERROR_DETAIL
,
MINIMAL_PARENTHESES
,
MULTI_LINE_ADS
,
MULTI_LINE_LISTS
,
BRIEF
,
COMPACT
,
READABLE
public static void enableFormatFlags(int flags)
flag
- the flag values to be enabledNO_ESCAPE_STRINGS
,
SHOW_ERROR_DETAIL
,
MINIMAL_PARENTHESES
,
MULTI_LINE_ADS
,
MULTI_LINE_LISTS
,
BRIEF
,
COMPACT
,
READABLE
public static void disableFormatFlags(int flags)
flag
- the flag values to be disabledNO_ESCAPE_STRINGS
,
SHOW_ERROR_DETAIL
,
MINIMAL_PARENTHESES
,
MULTI_LINE_ADS
,
MULTI_LINE_LISTS
,
BRIEF
,
COMPACT
,
READABLE
public abstract String toString()
Expr.formatFlags
and Expr.formatIndent
.
The result may be multiple lines long (it may include embedded newlines
and tabs), but it never ends with a newline.toString
in class Object
formatFlags
,
formatIndent
,
NO_ESCAPE_STRINGS
,
SHOW_ERROR_DETAIL
,
MINIMAL_PARENTHESES
,
MULTI_LINE_ADS
,
MULTI_LINE_LISTS
,
BRIEF
,
COMPACT
,
READABLE
public String toString(int flags)
Expr.formatFlags
for the duration of a single call of the
no-argument version.flags
- the new flags to set.toString()
,
formatFlags
,
formatIndent
,
NO_ESCAPE_STRINGS
,
SHOW_ERROR_DETAIL
,
MINIMAL_PARENTHESES
,
MULTI_LINE_ADS
,
MULTI_LINE_LISTS
,
BRIEF
,
COMPACT
protected abstract int prec()
MINIMAL_PARENTHESES
public static void db(Object msg)
if (dblevel > 1) db("The value of foo is " +foo);
msg
- the message to be printed.dblevel
public static void db(boolean newline, Object msg)
newline
- if true, terminate the message with a newline.msg
- the message to be printed.db(java.lang.Object)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |