condor.classad
Class RecordExpr

java.lang.Object
  |
  +--condor.classad.Expr
        |
        +--condor.classad.RecordExpr

public class RecordExpr
extends Expr

A "record" expression (also known as a "classad"). An internal (non-leaf) node of an expression tree representing a classified ad (a.k.a. property list, record, table, map, etc.)

Version:
1.2
Author:
Marvin Solomon
See Also:
Expr

Fields inherited from class condor.classad.Expr
ABSOLUTE_TIME, AND, ATTRIBUTE, BIT_COMPLEMENT, BITAND, BITOR, BITXOR, BOOLEAN, BRIEF, CALL, COMPACT, COND, dblevel, DIFFERENT, DIV, EQUAL, ERROR, formatFlags, formatIndent, GREATER, GREATER_EQ, INTEGER, LEFT_SHIFT, LESS, LESS_EQ, LIST, MAXPREC, MINIMAL_PARENTHESES, MINUS, MOD, MULTI_LINE_ADS, MULTI_LINE_LISTS, NO_ESCAPE_STRINGS, NOT, NOT_EQUAL, OP, opName, OR, PLUS, READABLE, REAL, RECORD, RELATIVE_TIME, RIGHT_SHIFT, SAME, SELECTION, SHOW_ERROR_DETAIL, SHOW_INSTANCES, STRING, SUBSCRIPT, TIMES, type, UMINUS, UNDEFINED, UPLUS, URIGHT_SHIFT
 
Constructor Summary
RecordExpr()
          Default constructor: a record with no fields
 
Method Summary
 Iterator attributes()
          Enumerate the attribute names.
 RecordExpr insertAttribute(condor.classad.CiString key, Expr expr)
          Add an attribute (replacing previous value if any)
 RecordExpr insertAttribute(Expr expr)
          Add an attribute with a generated name.
 RecordExpr insertAttribute(String name, Expr expr)
          Add an attribute (replacing previous value if any)
 Expr lookup(condor.classad.CiString name)
          Find the attribute with the given name.
 Expr lookup(String name)
          Find the attribute with the given name.
protected  int prec()
          The precedence of the operator in this expression node.
 Expr search(condor.classad.CiString key, Context ctx)
          Find an attribute with the given name in this RecordExpr or a ``containing'' one.
 Expr search(String name, Context ctx)
          Find an attribute with the given name in this RecordExpr or a ``containing'' one.
 int size()
          Count how many attributes.
 String toString()
          Convert this Expr to a string.
 void transmit(DataOutput out)
          Serialize this RecordExpr in the format currently expected by Condor.
protected  String typeName()
          The type of the expression.
 
Methods inherited from class condor.classad.Expr
db, db, disableFormatFlags, enableFormatFlags, eval, getFormatFlags, isConstant, isNormalForm, mark, mark, mark, reEval, select, setFormatFlags, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RecordExpr

public RecordExpr()
Default constructor: a record with no fields
Method Detail

transmit

public void transmit(DataOutput out)
              throws IOException
Serialize this RecordExpr in the format currently expected by Condor. The integer n is serialized by the writeInt method of the output stream and the n+2 strings are serialized by the writeUTF method. Normally, The output stream will be an instance of condor.cedar.CedarOutputStream, which means that n is written as 8 bytes, most significant byte first, and the strings are null-terminated and encoded using Java UTF-8 (which just transmits the low 8 bits of each character provided the string contains only ASCII characters).

To reconstitute a classad from this format, use a ClassAdReader and a ClassAdParser.

Parameters:
out - the stream to which the serialzed data should be written.
Returns:
the byte-array result.
Throws:
InvalidObjectException - if this add does not have MyType and TargetType attributes.
IOException - if an I/O error occurs.
See Also:
ClassAdParser.parse(), ClassAdReader

typeName

protected String typeName()
The type of the expression.
Overrides:
typeName in class Expr
Returns:
the string ``classad''.

lookup

public Expr lookup(String name)
Find the attribute with the given name.
Parameters:
name - the attribute name to look for.
Returns:
the value of the attribute (null if not present).

lookup

public Expr lookup(condor.classad.CiString name)
Find the attribute with the given name.
Parameters:
name - the attribute name to look for.
Returns:
the value of the attribute (null if not present).

search

public Expr search(String name,
                   Context ctx)
Find an attribute with the given name in this RecordExpr or a ``containing'' one. The ``containing'' ad may be the staticly enclosing ad or one found in the context.
Parameters:
ctx - a context for evaluating any ``super'' attribute encountered.
name - the attribute name to look for.
Returns:
the value of the attribute (null if not present).

search

public Expr search(condor.classad.CiString key,
                   Context ctx)
Find an attribute with the given name in this RecordExpr or a ``containing'' one. The ``containing'' ad may be the staticly enclosing ad or one found in the context.
Parameters:
ctx - a context for evaluating any ``super'' attribute encountered.
key - the attribute name to look for.
Returns:
the value of the attribute (null if not present).

insertAttribute

public RecordExpr insertAttribute(String name,
                                  Expr expr)
Add an attribute (replacing previous value if any)
Parameters:
name - the name of the attribute to be added.
expr - the value of the attribute.
Returns:
this RecordExpr.

insertAttribute

public RecordExpr insertAttribute(condor.classad.CiString key,
                                  Expr expr)
Add an attribute (replacing previous value if any)
Parameters:
key - the name of the attribute to be added.
expr - the value of the attribute.
Returns:
this RecordExpr.

insertAttribute

public RecordExpr insertAttribute(Expr expr)
Add an attribute with a generated name. The name has the form $arg<nn>, where nn is a non-negative integer.
Parameters:
expr - the value of the attribute.
Returns:
this RecordExpr.

size

public int size()
Count how many attributes.
Returns:
the number of distinct attributes in this ClassAd.

attributes

public Iterator attributes()
Enumerate the attribute names.
Returns:
an iterator of objects of type String, representing the the attribute names.

toString

public String toString()
Convert this Expr to a string. The exact format of the result is controled by the static fields 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.
Overrides:
toString in class Expr
Returns:
a string representation of the this Context
See Also:
Expr.formatFlags, Expr.formatIndent

prec

protected int prec()
The precedence of the operator in this expression node. Used to print expressions without superfluous parentheses.
Overrides:
prec in class Expr
Returns:
the precendence of this node.
See Also:
Expr.MINIMAL_PARENTHESES