net.sf.jabb.util.exp
Class CompareExpression

java.lang.Object
  extended by net.sf.jabb.util.exp.BooleanExpression
      extended by net.sf.jabb.util.exp.CompareExpression
All Implemented Interfaces:
CompareOperation
Direct Known Subclasses:
NumberCompareExpression

public abstract class CompareExpression
extends BooleanExpression
implements CompareOperation

用于得到比较结果

Author:
Zhengmao HU (James)

Field Summary
protected  Object leftOperand
           
protected  int operation
           
protected  Object rightOperand
           
 
Fields inherited from class net.sf.jabb.util.exp.BooleanExpression
children, FALSE, OPERAND, OPERATOR_AND, OPERATOR_NOT, OPERATOR_OR, operatorType, TRUE
 
Fields inherited from interface net.sf.jabb.util.exp.CompareOperation
EQ, GE, GT, LE, LT, NE
 
Constructor Summary
CompareExpression(Object leftOperand, int operation, Object rightOperand)
           
 
Method Summary
 void addOperand(BooleanExpression... operands)
          给表达式增加运算数
 void addOperand(BooleanExpression operand)
          给表达式增加运算数
protected abstract  boolean compare(Object context)
          子类应该实现这个方法,利用leftOperand, operation, rightOperand、以及context来 作具体的比较运算,返回确切的结果。
 boolean evaluate(Object context)
          获得表达式的结果。子类可以重载这个方法。
 String toString()
          转成字符串表示。子类可以重载这个方法。
 
Methods inherited from class net.sf.jabb.util.exp.BooleanExpression
addOperand, AND, AND, evaluate, HAS, NOT, OR, OR
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

leftOperand

protected Object leftOperand

rightOperand

protected Object rightOperand

operation

protected int operation
Constructor Detail

CompareExpression

public CompareExpression(Object leftOperand,
                         int operation,
                         Object rightOperand)
Method Detail

addOperand

public void addOperand(BooleanExpression operand)
Description copied from class: BooleanExpression
给表达式增加运算数

Overrides:
addOperand in class BooleanExpression

addOperand

public void addOperand(BooleanExpression... operands)
Description copied from class: BooleanExpression
给表达式增加运算数

Overrides:
addOperand in class BooleanExpression

evaluate

public boolean evaluate(Object context)
Description copied from class: BooleanExpression
获得表达式的结果。子类可以重载这个方法。

Overrides:
evaluate in class BooleanExpression
Returns:
result

compare

protected abstract boolean compare(Object context)
子类应该实现这个方法,利用leftOperand, operation, rightOperand、以及context来 作具体的比较运算,返回确切的结果。

Returns:
the result

toString

public String toString()
Description copied from class: BooleanExpression
转成字符串表示。子类可以重载这个方法。

Overrides:
toString in class BooleanExpression


Copyright © 2012. All Rights Reserved.