|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object condor.classad.Expr condor.classad.Constant
A constant (Integer, Real, etc.). The constant is wrapped so that it may be used as a node in an expression tree. To conserve space, there is at most one Constant instance with any given value.
Expr
Field Summary | |
static Constant |
Error
A default error constant. |
static Constant |
FALSE
The unique boolean Constant false. |
static Constant |
TRUE
The unique boolean Constant true. |
static Constant |
Undef
A default undefined constant. |
Object |
value
The actual value of this Constant. |
Fields inherited from class condor.classad.Expr |
ABSOLUTE_TIME, AND, ATTRIBUTE, BIT_COMPLEMENT, BITAND, BITOR, BITXOR, BOOLEAN, CALL, COND, dblevel, DIFFERENT, DIV, EQUAL, ERROR, GREATER, GREATER_EQ, INTEGER, LEFT_SHIFT, LESS, LESS_EQ, LIST, MAXPREC, MINUS, MOD, NOT, NOT_EQUAL, OP, opName, opNameXML, OR, PLUS, REAL, RECORD, RELATIVE_TIME, RIGHT_SHIFT, SAME, SELECTION, STRING, SUBSCRIPT, TIMES, type, UMINUS, UNDEFINED, UPLUS, URIGHT_SHIFT |
Method Summary | |
String |
annotation()
Returns the annotation of an UNDEFINED or ERROR value. |
static Constant |
bool(boolean b)
Convenience function that converts a boolean to Constant.TRUE or Constant.FALSE. |
boolean |
booleanValue()
Gets the boolean value of this Constant if possible. |
(package private) static String |
doubleToString(double d)
Converts a double value to a String. |
boolean |
equals(Object other)
Compares this Constant to another Constant. |
static Constant |
error(String msg)
Convenience function that creates an ERROR constant containing a particular message. |
(package private) static StringBuffer |
escapeString(StringBuffer sb,
String s,
char quote)
Appends to sb a quoted version of string, replacing non-printable values by backslash escapes. |
protected Expr |
eval1(Env env)
Evaluates this Expr. |
static Constant |
getInstance(boolean value)
Returns the boolean constant with value "value", creating one if necessary. |
static Constant |
getInstance(char[] buf,
int start,
int stop)
Creates a String Constant from a character array, processing backslash escapes. |
static Constant |
getInstance(Date date)
Returns the unique absolute time constant corresponding to date "date", in the local timezone, creating one if necessary. |
static Constant |
getInstance(Date date,
int tz)
Returns the unique absolute time constant corresponding to date "date", in the indicated timezone, creating one if necessary. |
static Constant |
getInstance(double value)
Returns the unique real constant with value "value", creating one if necessary. |
static Constant |
getInstance(int value)
Returns the unique integer constant with value "value", creating one if necessary. |
static Constant |
getInstance(long value)
Returns the unique relative time constant with value "value", creating one if necessary. |
static Constant |
getInstance(long t,
int z)
Returns the unique absolute time constant with time "t" and offset "z", creating one if necessary. |
static Constant |
getInstance(String value)
Returns the unique String constant with value "value", creating one if necessary. |
int |
hashCode()
Returns a hash code for this Constant. |
int |
intValue()
Gets the integer value of this Constant if possible. |
boolean |
isTrue()
Convenience function to test whether an expression is the constant TRUE. |
long |
milliseconds()
Converts a time value to milliseconds. |
int |
prec()
The precedence of this expression node (MAXPREC). |
double |
realValue()
Gets the double floating point value of this Constant if possible. |
(package private) static String |
relTimeToString(long t)
Converts a number of milliseconds to a string representation of a relative time. |
boolean |
sameAs(Expr other)
Compare this Expr to another expression to check for "deep structural equality". |
static Constant |
stringToAbsTime(String s)
Parses an absolute time specification. |
(package private) static double |
stringToDouble(String s)
Parses a string representation of a real value. |
static Constant |
stringToRelTime(String s)
Parses a relative time specification. |
String |
stringValue()
Gets the string value of this Constant if possible. |
StringBuffer |
toString(StringBuffer sb)
Converts this Expr to a string, appending the result to the end of "sb". |
static Constant |
undefined(String msg)
Convenience function that creates an UNDEFINED constant containing a particular message. |
(package private) static String |
unquoteString(char[] buf,
int start,
int stop)
Generates a string from an array of characters, processing backslash escapes. |
(package private) static String |
unquoteString(String s)
Process backslash escapes in a string. |
int |
zone()
Returns the time zone of an absolute time value. |
Methods inherited from class condor.classad.Expr |
db, db, eval, eval, is, isConstant, selectExpr, subExpr, toString, typeName |
Methods inherited from class Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final Constant Undef
public static final Constant Error
public static final Constant TRUE
public static final Constant FALSE
public final Object value
Method Detail |
public boolean sameAs(Expr other)
sameAs
in class Expr
other
- the other expression
public static final Constant getInstance(int value)
value
- the value of the Constant.
public static final Constant getInstance(double value)
value
- the value of the Constant.
public static final Constant getInstance(boolean value)
value
- the value (true or false)
bool(boolean)
public static final Constant getInstance(String value)
value
- the value of the Constant, not including any surrounding
quotes.
public static final Constant getInstance(char[] buf, int start, int stop)
buf
- the array of characters.start
- the index preceding the first character to be used.stop
- the index following the last characater to be used.
public static final Constant getInstance(Date date)
date
- the date.
public static final Constant getInstance(Date date, int tz)
date
- the date.tz
- the timezone, as a number of seconds east of
Greenwich.
public static final Constant getInstance(long t, int z)
t
- offset from the epoch, in milliseconds.z
- seconds east of Greenwich, in seconds.
public static final Constant getInstance(long value)
value
- the length of the time interval in milliseconds
public static Constant error(String msg)
msg
- the message.
public static Constant undefined(String msg)
msg
- the message.
public static Constant bool(boolean b)
b
- the boolean value.
getInstance(boolean)
protected Expr eval1(Env env)
Expr.eval()
.
eval1
in class Expr
env
- an environment used to evaluate the operands. It is cleared
to the null environment before return.
public int prec()
prec
in class Expr
ClassAdWriter.MINIMAL_PARENTHESES
public StringBuffer toString(StringBuffer sb)
toString
in class Expr
sb
- a place to put the result.
ClassAdWriter
public int intValue() throws ArithmeticException
intValue
in class Expr
ArithmeticException
- if type != INTEGER.public double realValue() throws ArithmeticException
realValue
in class Expr
ArithmeticException
- if type != INTEGER and type != REAL.public String stringValue() throws ArithmeticException
stringValue
in class Expr
ArithmeticException
- if type != STRING.public boolean booleanValue() throws ArithmeticException
ArithmeticException
- if TYPE != BOOLEAN.isTrue()
public boolean isTrue()
isTrue
in class Expr
booleanValue()
public long milliseconds() throws ArithmeticException
ArithmeticException
- if this Constant is not a time value.public int zone() throws ArithmeticException
ArithmeticException
- if type != ABSOLUTE_TIME.public String annotation() throws ArithmeticException
ArithmeticException
- if type != ERROR and type != UNDEFINED.static final String doubleToString(double d)
Real("INF")
, Real("-INF")
,
Real("NaN")
, "0.0"
, or "-0.0"
or
a normalized "scientific" representation such as
6.020000000000000E+24
, or
-0.000000000000000E+00
, as produced by the C printf format
"%1.15E": an optional leading minus sign, one digit before the decimal
point (which must be non-zero unless the value is plus or minus zero),
15 digits following the decimal point, the letter 'E', a (mandatory)
sign, and exponent of at least two digits.
d
- the value to convert.
static final double stringToDouble(String s)
INF
,
-INF
, or Nan
in any combination of upper
and lower case, or any string that can be handled by Double.parseDouble.
s
- the string to parse.
NumberFormatException
- if s cannot be parsed.static final String unquoteString(char[] buf, int start, int stop)
buf
- the array of characters.start
- the index of the first character to be used.stop
- the index following the last characater to be used.
static final String unquoteString(String s)
s
- the string to be processed.
static StringBuffer escapeString(StringBuffer sb, String s, char quote)
Note that Unicode is not supported: We assume the value of every character is in the range 0..0377.
sb
- a place to put the result.s
- the string to be quoted.quote
- the quote character (' or ").
static final String relTimeToString(long t)
t
- the number to be converted, in milliseconds.
public static Constant stringToRelTime(String s)
The default format is [-]days+hh:mm:ss.fff, where leading components and the fraction .fff are omitted if they are zero. In the default syntax, days is a sequence of digits starting with a non-zero digit, hh, mm, and ss are strings of exactly two digits (padded on the left with zeros if necessary) with values less than 24, 60, and 60, respectively and fff is a string of exactly three digits. In the relaxed syntax,
s
- the string to parse.
public static Constant stringToAbsTime(String s)
The default format is yyyy-mm-ddThh:mm:sszzzzzz where zzzzzz is a time zone in the format +hh:mm or -hh:mm, but variations are allowed.
D* dddd [D* dd [D* dd [D* dd [D* dd [D* dd D*]]]]] [-dd:dd|+dd:dd|z|Z]Where 'd' stands for a digit and 'D' stands for a non-digit.
For example, in the United States central time zone, the date and time 9 am Jan 25, 2003 CST may be written in any of the forms
s
- the string to parse.
public boolean equals(Object other)
other
- another object.
ArithmeticException
- if other is not a Constant of a compatible
type, or if this Constant is ERROR or
UNDEFINED.public int hashCode()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |