net.sf.jabb.util.exp
Class BooleanExpression

java.lang.Object
  extended by net.sf.jabb.util.exp.BooleanExpression
Direct Known Subclasses:
CompareExpression

public class BooleanExpression
extends Object

Logical expression that results in true or false.
产生true或false结果的逻辑表达式。

Author:
Zhengmao HU (James)

Field Summary
protected  List<BooleanExpression> children
           
static BooleanExpression FALSE
           
protected static int OPERAND
           
protected static int OPERATOR_AND
           
protected static int OPERATOR_NOT
           
protected static int OPERATOR_OR
           
protected  int operatorType
           
static BooleanExpression TRUE
           
 
Constructor Summary
protected BooleanExpression(int operatorType)
          创建一个实例
 
Method Summary
 void addOperand(BooleanExpression... operands)
          给表达式增加运算数
 void addOperand(BooleanExpression operand)
          给表达式增加运算数
 void addOperand(Collection<? extends BooleanExpression> operands)
          给表达式增加运算数
static BooleanExpression AND(BooleanExpression... operands)
          创建用AND连接的表达式
static BooleanExpression AND(Collection<? extends BooleanExpression> operands)
          创建用AND连接的表达式
 boolean evaluate()
          用null作为context获得表达式的结果。子类不必重载这个方法。
 boolean evaluate(Object context)
          获得表达式的结果。子类可以重载这个方法。
static BooleanExpression HAS(Object obj)
           
static BooleanExpression NOT(BooleanExpression operand)
          创建用NOT修饰的表达式
static BooleanExpression OR(BooleanExpression... operands)
          创建用OR连接的表达式
static BooleanExpression OR(Collection<? extends BooleanExpression> operands)
          创建用OR连接的表达式
 String toString()
          转成字符串表示。子类可以重载这个方法。
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OPERATOR_AND

protected static final int OPERATOR_AND
See Also:
Constant Field Values

OPERATOR_OR

protected static final int OPERATOR_OR
See Also:
Constant Field Values

OPERATOR_NOT

protected static final int OPERATOR_NOT
See Also:
Constant Field Values

OPERAND

protected static final int OPERAND
See Also:
Constant Field Values

TRUE

public static final BooleanExpression TRUE

FALSE

public static final BooleanExpression FALSE

operatorType

protected int operatorType

children

protected List<BooleanExpression> children
Constructor Detail

BooleanExpression

protected BooleanExpression(int operatorType)
创建一个实例

Parameters:
operatorType -
Method Detail

AND

public static BooleanExpression AND(BooleanExpression... operands)
创建用AND连接的表达式

Parameters:
operands -
Returns:
用AND连接之后的表达式

AND

public static BooleanExpression AND(Collection<? extends BooleanExpression> operands)
创建用AND连接的表达式

Parameters:
operands -
Returns:
用AND连接之后的表达式

OR

public static BooleanExpression OR(BooleanExpression... operands)
创建用OR连接的表达式

Parameters:
operands -
Returns:
用OR连接之后的表达式

OR

public static BooleanExpression OR(Collection<? extends BooleanExpression> operands)
创建用OR连接的表达式

Parameters:
operands -
Returns:
用OR连接之后的表达式

NOT

public static BooleanExpression NOT(BooleanExpression operand)
创建用NOT修饰的表达式

Parameters:
operand -
Returns:
用NOT修饰之后的表达式

HAS

public static BooleanExpression HAS(Object obj)

addOperand

public void addOperand(BooleanExpression operand)
给表达式增加运算数

Parameters:
operand -

addOperand

public void addOperand(BooleanExpression... operands)
给表达式增加运算数

Parameters:
operands -

addOperand

public void addOperand(Collection<? extends BooleanExpression> operands)
给表达式增加运算数

Parameters:
operands -

evaluate

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

Parameters:
context -
Returns:
result

evaluate

public boolean evaluate()
用null作为context获得表达式的结果。子类不必重载这个方法。

Returns:
evaluate(null)

toString

public String toString()
转成字符串表示。子类可以重载这个方法。

Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.