KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > ejb > query > CompNode


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.ejb.query;
13
14 /**
15  * Comparision expression.
16  */

17 public class CompNode extends BinaryNode {
18
19     public static final int EQ = 1; // =
20
public static final int GT = 2; // >
21
public static final int GE = 3; // >=
22
public static final int LT = 4; // <
23
public static final int LE = 5; // <=
24
public static final int NE = 6; // <>
25

26     private int op;
27
28     public CompNode(Node left, int op, Node right) {
29         super(left, right);
30         this.op = op;
31     }
32
33     public int getOp() {
34         return op;
35     }
36
37     public String JavaDoc getOpStr() {
38         switch (op) {
39             case EQ: return "=";
40             case GT: return ">";
41             case GE: return ">=";
42             case LT: return "<";
43             case LE: return "<=";
44             case NE: return "<>";
45         }
46         return "<? op " + op + " ?>";
47     }
48
49     public Object JavaDoc arrive(NodeVisitor v, Object JavaDoc msg) {
50         return v.arriveCompNode(this, msg);
51     }
52
53     public String JavaDoc toStringImp() {
54         StringBuffer JavaDoc s = new StringBuffer JavaDoc();
55         s.append(left);
56         s.append(' ');
57         s.append(getOpStr());
58         s.append(' ');
59         s.append(right);
60         return s.toString();
61     }
62
63 }
64
65
Popular Tags