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).


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.
 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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