/* 
 * Constraint - applies constraints to a SELECT statement 
 */
public class Constraint {

  String column; // The column to constrain.
  int op;        // The operator (see constants below)
  String value;  // The value to compare the column to.

  static final int EQ = 0;   // Equality.
  static final int NE = 1;   // Inequality.
  static final int GT = 2;   // Greater than.
  static final int GE = 3;   // Greater than or equal to.
  static final int LT = 4;   // Less than.
  static final int LE = 5;   // Less than or equal to.
  static final int LIKE = 6; // SQL LIKE operator.

  public String opAsString() {
    switch(op) {
      case Constraint.EQ:
        return "=";
      case Constraint.NE:
        return "<>";
      case Constraint.GT:
        return ">";
      case Constraint.GE:
        return ">=";
      case Constraint.LT:
        return "<";
      case Constraint.LE:
        return "<=";
      case Constraint.LIKE:
        return "LIKE";
      default:
        System.err.println("Error: Unknown operator " 
                           + op);
        return "";
    }
  }
}