condor.classad
Class Builtin
Object
condor.classad.Builtin
- public class Builtin
- extends Object
A library of builtin functions.
All functions are static and public and match the signature restrictions
documented by ClassAd.loadJavaLibrary(String)
.
Functions that violate these restrictions would be silently ignored.
- Version:
- 2.2
- Author:
- Marvin Solomon
- See Also:
FuncCall
,
ClassAd.loadJavaLibrary(java.lang.String)
Method Summary |
static Expr |
absTime(Expr[] args)
Convert to absolute time. |
static Expr |
allcompare(Expr s,
Expr l,
Expr t)
Compares a value to the elements of a list.
|
static Expr |
anycompare(Env env,
Expr s,
Expr l,
Expr t)
Compares a value to the elements of a list.
|
static Expr |
avg(Expr l)
Computes the average of a list of numbers.
|
static Expr |
ceiling(Expr arg)
Returns an integer constant corresponding to the ceiling of the value
of arg. |
static Expr |
floor(Expr arg)
Returns an integer constant corresponding to the floor of the value
of arg. |
static Expr |
formatTime(Expr t,
Expr f)
Formats an AbsTime with strftime-like escapes.
|
static Expr |
glob(Expr str,
Expr pat)
Deprecated. Should be replaced by regexp pattern match. |
static Expr |
gmtTimeString(Expr secs)
Deprecated. Replaced by formatTime(). |
static Expr |
identicalMember(Env env,
Expr expr,
Expr list)
Checks whether "list" is a ListExpr containing a member that
is equal to "expr" in the sense of "IS".
|
static Expr |
iglob(Expr str,
Expr pat)
Deprecated. Should be replaced by regexp pattern match. |
static Expr |
Int(Expr arg)
Convert to integer. |
static Expr |
interval(Expr secs)
Convert a number of seconds into a time interval string of the form
"days+hh:mm:ss". |
static Expr |
isAbstime(Env env,
Expr expr)
Tests whether "expr" evaluates to an absTime constant. |
static Expr |
isBoolean(Env env,
Expr expr)
Tests whether "expr" evaluates to a boolean (TRUE or FALSE). |
static Expr |
isClassad(Env env,
Expr expr)
Tests whether "expr" evaluates to a record expression. |
static Expr |
isError(Env env,
Expr expr)
Tests whether "expr" evaluates to an error. |
static Expr |
isInteger(Env env,
Expr expr)
Tests whether "expr" evaluates to an integer. |
static Expr |
isList(Env env,
Expr expr)
Tests whether "expr" evaluates to a list. |
static Expr |
isReal(Env env,
Expr expr)
Tests whether "expr" evaluates to a real. |
static Expr |
isReltime(Env env,
Expr expr)
Tests whether "expr" evaluates to a relTime constant. |
static Expr |
isString(Env env,
Expr expr)
Tests whether "expr" evaluates to a string. |
static Expr |
isUndefined(Env env,
Expr expr)
Tests whether "expr" evaluates to undefined. |
static Expr |
localTimeString(Expr secs)
Deprecated. Replaced by formatTime(). |
static Expr |
max(Expr l)
Computes the maximum of a list of numbers.
|
static Expr |
member(Env env,
Expr expr,
Expr list)
Checks whether "list" is a ListExpr containing a member that
is equal to "expr" in the sense of "==".
|
static Expr |
min(Expr l)
Computes the minimum of a list of numbers.
|
static Expr |
random(Expr[] args)
Returns a random value.
|
static Expr |
real(Expr arg)
Convert to real. |
static Expr |
regexp(Expr[] args)
Compares a string with a regular expression.
|
static Expr |
regExpMember(Env env,
Expr expr,
Expr list)
Checks whether "list" is a ListExpr containing a member that
matches "expr" in the sense of "regexp".
|
static Expr |
relTime(Expr arg)
Convert to relative time. |
static Expr |
round(Expr arg)
Returns an integer constant corresponding to the value of arg rounded
to the nearest integer. |
static Expr |
size(Expr obj)
Returns the size of an object.
|
static Expr |
splitTime(Expr[] args)
Split a time constant into its components. |
static Expr |
strcat(Expr[] args)
Converts each argument to a string and returns the concatenation
of the values. |
static Expr |
strcmp(Expr s1,
Expr s2)
Compares two strings. |
static Expr |
stricmp(Expr s1,
Expr s2)
Compares two strings ignoring differences in case. |
static Expr |
string(Expr s)
Converts the argument to a string. |
static Expr |
substr(Expr[] args)
Returns a substring of a string.
|
static Expr |
sum(Expr l)
Computes the sum of a list of numbers.
|
static Expr |
time()
Get the current time in seconds since the epoch. |
static Expr |
toLower(Expr expr)
Converts a string to lower case.
|
static Expr |
toUpper(Expr expr)
Converts a string to upper case.
|
Methods inherited from class Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
isUndefined
public static Expr isUndefined(Env env,
Expr expr)
- Tests whether "expr" evaluates to undefined.
- Parameters:
env
- environment for evaluating "expr"expr
- the expression to test
- Returns:
- TRUE if "expr" evaluates to undefined
isError
public static Expr isError(Env env,
Expr expr)
- Tests whether "expr" evaluates to an error.
- Parameters:
env
- environment for evaluating "expr"expr
- the expression to test
- Returns:
- TRUE if "expr" evaluates to an error
isString
public static Expr isString(Env env,
Expr expr)
- Tests whether "expr" evaluates to a string.
- Parameters:
env
- environment for evaluating "expr"expr
- the expression to test
- Returns:
- TRUE if "expr" evaluates to a string
isInteger
public static Expr isInteger(Env env,
Expr expr)
- Tests whether "expr" evaluates to an integer.
- Parameters:
env
- environment for evaluating "expr"expr
- the expression to test
- Returns:
- TRUE if "expr" evaluates to an integer
isReal
public static Expr isReal(Env env,
Expr expr)
- Tests whether "expr" evaluates to a real.
- Parameters:
env
- environment for evaluating "expr"expr
- the expression to test
- Returns:
- TRUE if "expr" evaluates to a real
isList
public static Expr isList(Env env,
Expr expr)
- Tests whether "expr" evaluates to a list.
- Parameters:
env
- environment for evaluating "expr"expr
- the expression to test
- Returns:
- TRUE if "expr" evaluates to a list
isClassad
public static Expr isClassad(Env env,
Expr expr)
- Tests whether "expr" evaluates to a record expression.
- Parameters:
env
- environment for evaluating "expr"expr
- the expression to test
- Returns:
- TRUE if "expr" evaluates to a record expression
isBoolean
public static Expr isBoolean(Env env,
Expr expr)
- Tests whether "expr" evaluates to a boolean (TRUE or FALSE).
- Parameters:
env
- environment for evaluating "expr"expr
- the expression to test
- Returns:
- TRUE if "expr" evaluates to a boolean
isAbstime
public static Expr isAbstime(Env env,
Expr expr)
- Tests whether "expr" evaluates to an absTime constant.
- Parameters:
env
- environment for evaluating "expr"expr
- the expression to test
- Returns:
- TRUE if "expr" evaluates to an absTime constant
isReltime
public static Expr isReltime(Env env,
Expr expr)
- Tests whether "expr" evaluates to a relTime constant.
- Parameters:
env
- environment for evaluating "expr"expr
- the expression to test
- Returns:
- TRUE if "expr" evaluates to a relTime constant
Int
public static Expr Int(Expr arg)
- Convert to integer. The arg is convered to an integer if possible.
Note: This method corresponds to int() in the ClassAd language, because
case is ignored in function names. The name "int" cannot be used
because it is a reserved word in Java.
- Parameters:
arg
- the value to be converted.
- Returns:
- an integer constant corresponding to arg, or ERROR.
real
public static Expr real(Expr arg)
- Convert to real. The arg is convered to a real if possible.
- Parameters:
arg
- the value to be converted.
- Returns:
- a real constant corresponding to arg, or ERROR.
string
public static Expr string(Expr s)
- Converts the argument to a string.
- Parameters:
s
- str the string to convert.
- Returns:
- a string represenation of the Expr
floor
public static Expr floor(Expr arg)
- Returns an integer constant corresponding to the floor of the value
of arg.
- Parameters:
arg
- the input value.
- Returns:
- the floor of arg.
ceiling
public static Expr ceiling(Expr arg)
- Returns an integer constant corresponding to the ceiling of the value
of arg.
- Parameters:
arg
- the input value.
- Returns:
- the ceiling of arg.
round
public static Expr round(Expr arg)
- Returns an integer constant corresponding to the value of arg rounded
to the nearest integer.
- Parameters:
arg
- the input value.
- Returns:
- the rounded arg.
random
public static Expr random(Expr[] args)
- Returns a random value.
The value r is uniformly destributed over the range 0 <= r < x,
where x is the argument. The result is an Integer if x is an Integer,
and a Real if x is a real. An omitted argument is treated like 1.0.
Returns ERROR if the argument is not a positive Intger or positive Real.
- Parameters:
args
- the arguments
- Returns:
- a random value.
strcat
public static Expr strcat(Expr[] args)
- Converts each argument to a string and returns the concatenation
of the values.
- Parameters:
args
- the arguments
- Returns:
- the concatenation of the values.
substr
public static Expr substr(Expr[] args)
- Returns a substring of a string.
This is like the Perl version of substr.
Offset is the start of the substr, negative is from the end:
0: first char of string
-1: last char of string
If length is omitted, it means the rest of the string.
If length is negative, that many characters are dropped.
- Parameters:
args
- the arguments
- Returns:
- the designated substring
strcmp
public static Expr strcmp(Expr s1,
Expr s2)
- Compares two strings. The arguments are first converted to strings
as if by string().
- Parameters:
s1
- the first string.s2
- the second string.
- Returns:
- an Integer expression with a value that is less than zero if
string(s1) < string(s2), greater than zero if string(s1) >
string(s2), and equal to zero if string(s1) &eq; string(s2).
stricmp
public static Expr stricmp(Expr s1,
Expr s2)
- Compares two strings ignoring differences in case. The arguments are
first converted to strings as if by string().
- Parameters:
s1
- the first string.s2
- the second string.
- Returns:
- an Integer expression with a value that is less than zero if
string(s1) < string(s2), greater than zero if string(s1) >
string(s2), and equal to zero if string(s1) &eq; string(s2).
toUpper
public static Expr toUpper(Expr expr)
- Converts a string to upper case.
The argument is converted to a string as if by string(). The
result is a copy of the string in which all lower case letters are
converted to upper case.
- Parameters:
expr
- the expression to be converted
- Returns:
- an upper case string representing "expr".
toLower
public static Expr toLower(Expr expr)
- Converts a string to lower case.
The argument is converted to a string as if by string(). The
result is a copy of the string in which all upper case letters are
converted to lower case.
- Parameters:
expr
- the expression to be converted
- Returns:
- a lower case string representing "expr".
size
public static Expr size(Expr obj)
- Returns the size of an object.
The size of a String is the number of characters.
The size of a List or Record is the number of elements.
For any other type of object, the result is ERROR.
- Parameters:
obj
- the object to be tested.
- Returns:
- and Integer containing its size, or ERROR.
sum
public static Expr sum(Expr l)
- Computes the sum of a list of numbers.
The elements of l are evaluated, producing a list l' of values. If l'
is composed only of numbers, the result is the sum of the values, as a
Real if any value is Real, and as an Integer otherwise. If the list is
empty, the result is 0. In other cases, the result is ERROR.
- Parameters:
l
- a list of expressions.
- Returns:
- the sum of the values.
avg
public static Expr avg(Expr l)
- Computes the average of a list of numbers.
The elements of l are evaluated, producing a list l' of values. If l'
is composed only of numbers, the result is the average of the values, as
a Real. If the list is empty, the result is 0.0. In other cases, the
result is ERROR.
- Parameters:
l
- a list of expressions.
- Returns:
- the average of the values as a Real.
min
public static Expr min(Expr l)
- Computes the minimum of a list of numbers.
The elements of l are evaluated, producing a list l' of values. If l'
is composed only of numbers, the result is the minimum of the values, as
a Real if any value is Real, and as an Integer otherwise. If the list
is empty, the result is UNDEFINED. In other cases, the result is ERROR.
- Parameters:
l
- a list of expressions.
- Returns:
- the minimum of the values.
max
public static Expr max(Expr l)
- Computes the maximum of a list of numbers.
The elements of l are evaluated, producing a list l' of values. If l'
is composed only of numbers, the result is the maximum of the values, as
a Real if any value is Real, and as an Integer otherwise. If the list
is empty, the result is UNDEFINED. In other cases, the result is ERROR.
- Parameters:
l
- a list of expressions.
- Returns:
- the maximum of the values.
member
public static Expr member(Env env,
Expr expr,
Expr list)
- Checks whether "list" is a ListExpr containing a member that
is equal to "expr" in the sense of "==".
If "expr" is not a constant or "list" is not a list, then the result is
an error. Otherwise, the elements of "list" are evaluated and if any of
the values are equal to "expr" in the sense of the "==" operator,
then the result is true, otherwise it is false.
- Parameters:
env
- an environment for evaluating "expr" and the members of "list"expr
- the expression to search forlist
- the list to search for "expr"
- Returns:
- a boolean constant or ERROR.
identicalMember
public static Expr identicalMember(Env env,
Expr expr,
Expr list)
- Checks whether "list" is a ListExpr containing a member that
is equal to "expr" in the sense of "IS".
If "expr" is not a constant or "list" is not a list, then the result is
an error. Otherwise, the elements of "list" are evaluated and if any of
the values are equal to "expr" in the sense of the "IS" operator,
then the result is true, otherwise it is false.
- Parameters:
env
- an environment for evaluating "expr" and the members of "list"expr
- the expression to search forlist
- the list to search for "expr"
- Returns:
- a boolean constant or ERROR.
regExpMember
public static Expr regExpMember(Env env,
Expr expr,
Expr list)
- Checks whether "list" is a ListExpr containing a member that
matches "expr" in the sense of "regexp".
If "expr" is not a constant or "list" is not a list, then the result is
an error. Otherwise, the elements of "list" are evaluated and if any of
them evaluates to anything other than a String, the result is an error.
Otherwise, if any of values in the list matches the pattern according to
the "regexp" function, the result is TRUE. If there is no match, then
the result is FALSE.
- Parameters:
env
- an environment for evaluating "expr" and the members of "list"expr
- the expression to search forlist
- the list to search for "expr"
- Returns:
- a boolean constant or ERROR.
anycompare
public static Expr anycompare(Env env,
Expr s,
Expr l,
Expr t)
- Compares a value to the elements of a list.
If $s$ is not a string equal (ignoring case) to one of "<", "<=",
"==", "!=", ">", ">=", "is", or "isnt", or "l" is not a list, the
result is an error. Otherwise, the elements of "l" are evaluated and
compared to "t" using the ClassAd operator corresponding to "s". If any
of the comparisons evaluate to TRUE the result is TRUE. Otherwise, the
result is FALSE.
- Parameters:
env
- an environment for evaluating "t" and the members of "l"s
- an operatorl
- a listt
- value to compare to members of the list.
- Returns:
- TRUE if the value matches any member of the list.
allcompare
public static Expr allcompare(Expr s,
Expr l,
Expr t)
- Compares a value to the elements of a list.
If $s$ is not a string equal (ignoring case) to one of "<", "<=",
"==", "!=", ">", ">=", "is", or "isnt", or "l" is not a list, the
result is an error. Otherwise, the elements of "l" are evaluated and
compared to "t" using the ClassAd operator corresponding to "s". If all
of the comparisons evaluate to TRUE the result is TRUE. Otherwise, the
result is FALSE.
- Parameters:
s
- an operatorl
- a listt
- value to compare to members of the list.
- Returns:
- TRUE if the value matches all members of the list.
regexp
public static Expr regexp(Expr[] args)
- Compares a string with a regular expression.
Invoked as regexp(pat, str [, options]).
The result is true if pat matches str and false otherwise.
The options argument if present may contain the following characters.
- i or I
- Ignore case.
- m or M
- A carat (^) matches not only the start of the subject string,
but also after each newline. Similarly, dollar ($) matches
before a newline.
- s or S
- Dot (.) matches any character, including newline.
- x or X
- Use "extended" syntax: spaces and comments are allowed inside
the pattern.
All other characters in the options argument are ignored.
- Parameters:
args
- the arguments.
- Returns:
- true if the pattern matches, false if it doesn't
match, or error for invalid invocations (wrong number or
types of arguments, etc.)
glob
public static Expr glob(Expr str,
Expr pat)
- Deprecated. Should be replaced by regexp pattern match.
- Compares a string with a shell-style "glob" pattern.
The pat string may contain instances of * and/or ?. The result is true
if pat matches str and false otherwise. The pattern character ? matches
any character; * matches any sequence of zero or more characters. A
backslash preceding any pattern character removes any special meaning
from that character and makes it match only itself. For example \?
matches a question mark and \\ matches a single backslash. Any other
character matches only itself. Note that case is significant in the
comparison.
- Parameters:
str
- the string to be compared againstpat
- the pattern to match
- Returns:
- a boolean constant with value true if the pattern matches and
false otherwise.
iglob
public static Expr iglob(Expr str,
Expr pat)
- Deprecated. Should be replaced by regexp pattern match.
- Compares a string with a shell-style "glob" pattern, ignoring case.
The pat string may contain instances of * and/or ?. The result is true
if pat matches str and false otherwise. The pattern character ? matches
any character; * matches any sequence of zero or more characters. A
backslash preceding any pattern character removes any special meaning
from that character and makes it match only itself. For example \?
matches a question mark and \\ matches a single backslash. A lower-case
letter mathches the upper or lower case version of that letter. Any
other character (including an upper-case letter) matches only itself.
- Parameters:
str
- the string to be compared againstpat
- the pattern to match
- Returns:
- a boolean constant with value true if the pattern matches and
false otherwise.
time
public static Expr time()
- Get the current time in seconds since the epoch.
- Returns:
- the current time in seconds.
interval
public static Expr interval(Expr secs)
- Convert a number of seconds into a time interval string of the form
"days+hh:mm:ss".
- Parameters:
secs
- the time interval in seconds.
- Returns:
- a string version of the interval.
absTime
public static Expr absTime(Expr[] args)
- Convert to absolute time.
- Parameters:
args
- the arguments. May be either a single string (which is
parsed as an ISO 8601 date spec), or an optional number of seconds
offset from the epoch and optional number of seconds east of
Greenwhich.
- Returns:
- an absolute time or error constant.
relTime
public static Expr relTime(Expr arg)
- Convert to relative time.
- Parameters:
arg
- the value to be converted.
- Returns:
- a relative time or error constant.
splitTime
public static Expr splitTime(Expr[] args)
- Split a time constant into its components.
- Parameters:
args
- the arguments. May be either an AbsTime or a Realtime.
For AbsTime the result is a Record expression with attributes
Type, Year, Month, Day, Hours, Minutes, Seconds, Offset
For RelTime the result is a Record expression with attributes
Type, Days, Hours, Minutes, Seconds.
Type is "RelativeTime" or "AbsoluteTime".
- Returns:
- a Record expression.
formatTime
public static Expr formatTime(Expr t,
Expr f)
- Formats an AbsTime with strftime-like escapes.
Supports the the ANSI C strftime escapes %x, where x is any of the
characters aAbBcdHIjmMpSwxXyYZ%.
- Parameters:
t
- the absolute time to format.f
- the format
- Returns:
- a String constant representing the formatted value.
gmtTimeString
public static Expr gmtTimeString(Expr secs)
- Deprecated. Replaced by formatTime().
- Convert a time constant to a string in "Unix" format, using GMT.
- Parameters:
secs
- the time in seconds from the epoch.
- Returns:
- a string in Unix "ctime" format.
localTimeString
public static Expr localTimeString(Expr secs)
- Deprecated. Replaced by formatTime().
- Convert a time constant to a string in "Unix" format, using the local
time zone.
- Parameters:
secs
- the time in seconds from the epoch.
- Returns:
- a string in Unix "ctime" format.