01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: package com.versant.core.ejb.query;
12:
13: /**
14: * Comparision expression.
15: */
16: public class CompNode extends BinaryNode {
17:
18: public static final int EQ = 1; // =
19: public static final int GT = 2; // >
20: public static final int GE = 3; // >=
21: public static final int LT = 4; // <
22: public static final int LE = 5; // <=
23: public static final int NE = 6; // <>
24:
25: private int op;
26:
27: public CompNode(Node left, int op, Node right) {
28: super (left, right);
29: this .op = op;
30: }
31:
32: public int getOp() {
33: return op;
34: }
35:
36: public String getOpStr() {
37: switch (op) {
38: case EQ:
39: return "=";
40: case GT:
41: return ">";
42: case GE:
43: return ">=";
44: case LT:
45: return "<";
46: case LE:
47: return "<=";
48: case NE:
49: return "<>";
50: }
51: return "<? op " + op + " ?>";
52: }
53:
54: public Object arrive(NodeVisitor v, Object msg) {
55: return v.arriveCompNode(this , msg);
56: }
57:
58: public String toStringImp() {
59: StringBuffer s = new StringBuffer();
60: s.append(left);
61: s.append(' ');
62: s.append(getOpStr());
63: s.append(' ');
64: s.append(right);
65: return s.toString();
66: }
67:
68: }
|