relop
Class Predicate

java.lang.Object
  extended by relop.Predicate

public class Predicate
extends java.lang.Object

Internal representation of simple SQL expressions. Operators are referenced by constants in global.AttrOperator, and operands can be constants or field numbers (i.e. if referring to an attribute).


Field Summary
protected  java.lang.Object left
          Left operand.
protected  int ltype
          Type of left operand.
protected  int oper
          The operator.
protected  java.lang.Object right
          Right operand.
protected  int rtype
          Type of right operand.
 
Constructor Summary
Predicate(int oper, int ltype, java.lang.Object left, int rtype, java.lang.Object right)
          Constructs a predicate, given the expression.
 
Method Summary
 boolean evaluate(Tuple tuple)
          Evaluates the predicate on the given tuple and returns true if it passes.
protected  java.lang.String opString(int type, java.lang.Object operand)
          Returns a string representation of an operand.
 java.lang.String toString()
          Returns a string representation of the Predicate.
 boolean validate(Schema schema)
          Validates AttrType.COLNAME operands against the given schema.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

oper

protected int oper
The operator.


ltype

protected int ltype
Type of left operand.


left

protected java.lang.Object left
Left operand.


rtype

protected int rtype
Type of right operand.


right

protected java.lang.Object right
Right operand.

Constructor Detail

Predicate

public Predicate(int oper,
                 int ltype,
                 java.lang.Object left,
                 int rtype,
                 java.lang.Object right)
Constructs a predicate, given the expression.

Parameters:
oper - AttrOperator constant
ltype - AttrType of the field
left - operand value, field number, or column name
rtype - AttrType of the field
right - operand value, field number, or column name
Method Detail

validate

public boolean validate(Schema schema)
Validates AttrType.COLNAME operands against the given schema.

Returns:
true if the predicate is valid, false otherwise

evaluate

public boolean evaluate(Tuple tuple)
Evaluates the predicate on the given tuple and returns true if it passes.

Throws:
java.lang.IllegalStateException - if member data lead to an invalid operation

toString

public java.lang.String toString()
Returns a string representation of the Predicate.

Overrides:
toString in class java.lang.Object

opString

protected java.lang.String opString(int type,
                                    java.lang.Object operand)
Returns a string representation of an operand.