condor.classad
Class ClassAd

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

public class ClassAd
extends Object

A library of handy methods for manipulating classad expressions. The class contains only static methods for performing various operations on classified advertisements. See Expr and its various subclasses, especially RecordExpr for the actual objects that are manipulated.

Version:
1.2
Author:
Marvin Solomon
See Also:
Expr, RecordExpr

Method Summary
static Context bind(RecordExpr ad1, RecordExpr ad2)
          Wrap a pair of ads in an environment and context such that inside ad1, self refers to ad1, other refers to ad2, and any other attribute is searched for first in ad1 and then in ad2 (and similarly, with ad1 and ad2 interchanged).
static Constant constant(double x)
          Create a constant expression from a real value.
static Constant constant(int i)
          Create a constant expression from an integer value.
static Constant constant(String s)
          Create a constant expression from a String value.
static Expr eval(Context ctx, String[] attrs)
          Evaluate a selection from a ClassAd in a given evaluation context.
static Expr eval(RecordExpr ad, String[] attrs)
          Evaluate a selection from a ClassAd.
static Expr eval(String attr, RecordExpr ad1, RecordExpr ad2)
          Evaluate an attribute of a ClassAd in an environment consisting of a pair of ads.
static boolean oneWayMatch(Expr expr1, Expr expr2)
          Match two ClassAds.
static int[] twoWayMatch(Expr expr1, Expr expr2)
          Match two ClassAds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

bind

public static Context bind(RecordExpr ad1,
                           RecordExpr ad2)
Wrap a pair of ads in an environment and context such that inside ad1, self refers to ad1, other refers to ad2, and any other attribute is searched for first in ad1 and then in ad2 (and similarly, with ad1 and ad2 interchanged).
Parameters:
ad1 - the first ClassAd.
ad2 - the second ClassAd.
Returns:
a Context ctx such that E.Ad1.self is ad1, and E.Ad2.self is ad2, where E = ctx.root

eval

public static Expr eval(RecordExpr ad,
                        String[] attrs)
Evaluate a selection from a ClassAd.
Parameters:
ad - a ClassAd from which to select.
Returns:
the result of evaluating ad.attr1.attr2...attrn in a context in which absolute attribute reference (ones starting with `.') are evaluated relative to ad.

eval

public static Expr eval(Context ctx,
                        String[] attrs)
Evaluate a selection from a ClassAd in a given evaluation context.
Parameters:
ctx - a Context for the evaluation.
Returns:
the result of evaluating ad.attr1.attr2...attrn in a context ctx, where ad = ctx.root.

eval

public static Expr eval(String attr,
                        RecordExpr ad1,
                        RecordExpr ad2)
Evaluate an attribute of a ClassAd in an environment consisting of a pair of ads. The call ClassAd.eval(attr, ad1, ad2) evaluates ad1.attr an environment such that inside ad1, self refers to ad1, other refers to ad2, and any other attribute is searched for first in ad1 and then in ad2 (and similarly, with ad1 and ad2 interchanged).
Parameters:
attr - the name of the attribute used to initiate the evaluation
ad1 - the ClassAd used to initiate the evaluation
ad2 - the other ClassAd
Returns:
the result of the evaluation

twoWayMatch

public static int[] twoWayMatch(Expr expr1,
                                Expr expr2)
Match two ClassAds. If each expr is a RecordExpr with a Requirements attribute that evaluates to true in the context of the other expr and each expr has a Rank attribute that evaluates to an integer, the result is two-element array containing the Rank values. In all other cases, the result is null.
Parameters:
expr1 - the first expression.
expr2 - the second expression.
Returns:
the result of the match, either a pair of integers or null.

oneWayMatch

public static boolean oneWayMatch(Expr expr1,
                                  Expr expr2)
Match two ClassAds. If expr1 is a RecordExpr with a Requirements attribute that evaluates to true in the context of expr2, then return true. Otherwise return false.
Parameters:
expr1 - the first expression.
expr2 - the second expression.
Returns:
the result of the match.

constant

public static Constant constant(int i)
Create a constant expression from an integer value.
Parameters:
i - the value.
Returns:
the resulting Constant object.

constant

public static Constant constant(double x)
Create a constant expression from a real value.
Parameters:
x - the value.
Returns:
the resulting Constant object.

constant

public static Constant constant(String s)
Create a constant expression from a String value.
Parameters:
s - the value.
Returns:
the resulting Constant object.