1 2 12 package com.versant.core.jdo.query; 13 14 import com.versant.core.common.BindingSupportImpl; 15 16 19 public class CompareOpNode extends BinaryNode { 20 21 public static final int GT = 1; 22 public static final int LT = 2; 23 public static final int GE = 3; 24 public static final int LE = 4; 25 26 29 public int op; 30 31 public CompareOpNode(Node left, Node right, int op) { 32 super(left, right); 33 this.op = op; 34 } 35 36 public Object accept(NodeVisitor visitor, Object [] results) { 37 return visitor.visitCompareOpNode(this, results); 38 } 39 40 public String toString() { 41 return super.toString() + " " + toOpString(op); 42 } 43 44 public static String toOpString(int op) { 45 switch (op) { 46 case GT: return ">"; 47 case LT: return "<"; 48 case GE: return ">="; 49 case LE: return "<="; 50 } 51 return "Unknown(" + op + ")"; 52 } 53 54 57 protected void swapLeftAndRight() { 58 super.swapLeftAndRight(); 59 switch (op) { 60 case GT: op = LT; break; 61 case LT: op = GT; break; 62 case GE: op = LE; break; 63 case LE: op = GE; break; 64 default: 65 throw BindingSupportImpl.getInstance().internal("Unknown op: " + 66 toOpString(op)); 67 } 68 } 69 70 public Field visit(MemVisitor visitor, Object obj) { 71 return visitor.visitCompareOpNode(this, obj); 72 } 73 74 public Object arrive(NodeVisitor v, Object msg) { 75 return v.arriveCompareOpNode(this, msg); 76 } 77 78 } 79 80 | Popular Tags |