condor.classad
Class ClassAd

Object
  extended bycondor.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:
2.1
Author:
Marvin Solomon
See Also:
Expr, RecordExpr

Method Summary
static RecordExpr 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(RecordExpr ad, String attr)
          Evaluate a selection from a ClassAd.
static Expr eval(RecordExpr ad, String[] attrs)
          Evaluate a selection from a ClassAd.
static Expr eval(String name, Expr expr, RecordExpr ad)
          Evaluate an expression in the context of 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 loadJavaLibrary(String className)
          Loads a library of externally defined Java functions.
static int[] match(Expr expr1, Expr expr2)
          Match two ClassAds.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

bind

public static RecordExpr 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 RecordExpr E such that E.Ad1.self is ad1, and E.Ad2.self is ad2.

eval

public static Expr eval(RecordExpr ad,
                        String[] attrs)
Evaluate a selection from a ClassAd.

Parameters:
ad - a ClassAd from which to select.
attrs - a sequence attr1, attr2, ..., attrn of attribute names.
Returns:
the result of evaluating ad.attr1.attr2...attrn.

eval

public static Expr eval(RecordExpr ad,
                        String attr)
Evaluate a selection from a ClassAd.

Parameters:
ad - a ClassAd from which to select.
attr - an attribute name.
Returns:
the result of evaluating ad.attr.

eval

public static Expr eval(String name,
                        Expr expr,
                        RecordExpr ad)
Evaluate an expression in the context of a ClassAd. The expr is evaluated as if it were a the value of an attribute named name in ad.

Note: the RecordExpr ad is modified and then returned to its original state, so this method is not thread-safe.

Parameters:
name - the name of the attribute.
expr - the expression to evaluate.
ad - the context for evaluation.
Returns:
the result of evaluating expr in the context of ad.

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

match

public static int[] match(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.

loadJavaLibrary

public static boolean loadJavaLibrary(String className)
Loads a library of externally defined Java functions.

Parameters:
className - the fully qualified name of the class (e.g. condor.classad.Builtin)
Returns:
false if the load fails.

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.