condor.classad
Class Constant

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

public class Constant
extends Expr

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.

Version:
1.2
Author:
Marvin Solomon
See Also:
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
 
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
 
Method Summary
static Constant getInstance(char[] buf, int start, int stop)
          Create a String Constant from a character array, processing backslash escapes.
static Constant getInstance(Date value)
          Create an absolute time Constant.
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 time constant with value "value", creating one if necessary.
static Constant getInstance(String value)
          Returns the unique String constant with value "value", creating one if necessary.
 int intValue()
          Get the integer value of this Constant if possible.
 long milliseconds()
          Convert a time value to milliseconds.
protected  int prec()
          The precedence of this expression node (MAXPREC).
 double realValue()
          Get the double floating point value of this Constant if possible.
 String stringValue()
          Get the string value of this Constant if possible.
 boolean toBoolean()
          Convernience function: Convert to a boolean.
 String toString()
          Convert to a string
 
Methods inherited from class condor.classad.Expr
db, db, disableFormatFlags, enableFormatFlags, eval, getFormatFlags, isConstant, isNormalForm, mark, mark, mark, reEval, select, setFormatFlags, toString, typeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Undef

public static final Constant Undef
A default undefined constant

Error

public static final Constant Error
A default error constant

True

public static final Constant True
The unique boolean constant true

False

public static final Constant False
The unique boolean Constant false
Method Detail

getInstance

public static final Constant getInstance(int value)
Returns the unique integer constant with value "value", creating one if necessary.
Parameters:
value - the value of the Constant.

getInstance

public static final Constant getInstance(double value)
Returns the unique real constant with value "value", creating one if necessary.
Parameters:
value - the value of the Constant.

getInstance

public static final Constant getInstance(String value)
Returns the unique String constant with value "value", creating one if necessary.
Parameters:
value - the value of the Constant.

getInstance

public static final Constant getInstance(char[] buf,
                                         int start,
                                         int stop)
Create a String Constant from a character array, processing backslash escapes.
Parameters:
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.

getInstance

public static final Constant getInstance(Date value)
Create an absolute time Constant.
Parameters:
value - the value of the Constant.

getInstance

public static final Constant getInstance(long value)
Returns the unique time constant with value "value", creating one if necessary.
Parameters:
value - the value of the constant in milliseconds

toString

public String toString()
Convert to a string
Overrides:
toString in class Expr
Returns:
the value of this Constant, converted to a string.

toBoolean

public boolean toBoolean()
Convernience function: Convert to a boolean. Note that unlike realValue, intValue, etc, this method never throws an exception.
Returns:
true if this constant is a BOOLEAN with the value true; false in all other cases.

intValue

public int intValue()
             throws ArithmeticException
Get the integer value of this Constant if possible.
Returns:
the integer value of this IntegerConstant.
Throws:
ArithmeticException - if this Constant is not an integer.

realValue

public double realValue()
                 throws ArithmeticException
Get the double floating point value of this Constant if possible.
Returns:
the real value of this RealConstant or the value of this IntegerConstant converted to double.
Throws:
ArithmeticException - if this Constant is not an instance of IntegerConstant or RealConstant.

stringValue

public String stringValue()
                   throws ArithmeticException
Get the string value of this Constant if possible.
Returns:
the string value of this StringConstant.
Throws:
ArithmeticException - if this Constant is not an instance of StringConstant.

milliseconds

public long milliseconds()
                  throws ArithmeticException
Convert a time value to milliseconds.
Returns:
the number of milliseconds (since 1/1/70 for ABSOLUTE_TIME values).
Throws:
ArithmeticException - if this Constant is not a time value.

prec

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