FileDocCategorySizeDatePackage
BetweenQueryExp.javaAPI DocJava SE 5 API3278Fri Aug 26 14:57:32 BST 2005javax.management

BetweenQueryExp

public class BetweenQueryExp extends QueryEval implements QueryExp
This class is used by the query-building mechanism to represent binary relations.
serial
include
since
1.5

Fields Summary
private static final long
serialVersionUID
private ValueExp
exp1
private ValueExp
exp2
private ValueExp
exp3
Constructors Summary
public BetweenQueryExp()
Basic Constructor.

    
    
           
       
    
public BetweenQueryExp(ValueExp v1, ValueExp v2, ValueExp v3)
Creates a new BetweenQueryExp with v1 checked value, v2 lower bound and v3 upper bound values.

 
	exp1  = v1;
	exp2  = v2;
	exp3  = v3;
    
Methods Summary
public booleanapply(javax.management.ObjectName name)
Applies the BetweenQueryExp on an MBean.

param
name The name of the MBean on which the BetweenQueryExp will be applied.
return
True if the query was successfully applied to the MBean, false otherwise.
exception
BadStringOperationException
exception
BadBinaryOpValueExpException
exception
BadAttributeValueExpException
exception
InvalidApplicationException

 
	ValueExp val1 = exp1.apply(name);
	ValueExp val2 = exp2.apply(name);
	ValueExp val3 = exp3.apply(name);
	String sval1;
	String sval2;
	String sval3;
	double dval1;
	double dval2;
	double dval3;
	long lval1;
	long lval2;
	long lval3;
	boolean numeric = val1 instanceof NumericValueExp;
	
	if (numeric) {
	    if (((NumericValueExp)val1).isLong()) {
		lval1 = ((NumericValueExp)val1).longValue();
		lval2 = ((NumericValueExp)val2).longValue();
		lval3 = ((NumericValueExp)val3).longValue();
		return lval2 <= lval1 && lval1 <= lval3;
	    } else {
		dval1 = ((NumericValueExp)val1).doubleValue();
		dval2 = ((NumericValueExp)val2).doubleValue();
		dval3 = ((NumericValueExp)val3).doubleValue();
		return dval2 <= dval1 && dval1 <= dval3;
	    }
	    
	} else {
	    sval1 = ((StringValueExp)val1).toString();
	    sval2 = ((StringValueExp)val2).toString();
	    sval3 = ((StringValueExp)val3).toString();
	    return sval2.compareTo(sval1) <= 0 && sval1.compareTo(sval3) <= 0;
	}
    
public javax.management.ValueExpgetCheckedValue()
Returns the checked value of the query.

 
	return exp1;
    
public javax.management.ValueExpgetLowerBound()
Returns the lower bound value of the query.

 
	return exp2;
    
public javax.management.ValueExpgetUpperBound()
Returns the upper bound value of the query.

 
	return exp3;
    
public java.lang.StringtoString()
Returns the string representing the object.

 
	return "(" + exp1 + ") between (" + exp2 + ") and (" + exp3 + ")";