KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdo > query > AddNode


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.jdo.query;
13
14 import com.versant.core.common.Debug;
15
16 /**
17  * An additive expression (multiple nodes separated by '+' or '-').
18  */

19 public class AddNode extends Node {
20
21     public static final int OP_PLUS = 0;
22     public static final int OP_MINUS = 1;
23
24     /**
25      * The operators. There will be one less entry here than the nodes.
26      * Example: ops[0] is between nodes[0] and nodes[1].
27      */

28     public int[] ops;
29
30     public AddNode() {
31     }
32
33     public Object JavaDoc accept(NodeVisitor visitor, Object JavaDoc[] results) {
34       return visitor.visitAddNode(this, results);
35     }
36
37     /**
38      * Dump debugging info to System.out.
39      */

40     public void dump(String JavaDoc indent) {
41         dumpThis(indent);
42         indent = indent + " ";
43         int i = 0;
44         for (Node c = childList; c != null; c = c.next, i++) {
45             c.dump(indent);
46             if (i < ops.length) {
47                 Debug.OUT.println(indent + toOpString(ops[i]));
48             }
49         }
50     }
51
52     public static String JavaDoc toOpString(int op) {
53         switch (op) {
54             case OP_PLUS: return "+";
55             case OP_MINUS: return "-";
56         }
57         return "Uknown(" + op + ")";
58     }
59
60     public Field visit(MemVisitor visitor, Object JavaDoc obj) {
61         return visitor.visitAddNode(this,obj);
62     }
63
64     public Object JavaDoc arrive(NodeVisitor v, Object JavaDoc msg) {
65         return v.arriveAddNode(this, msg);
66     }
67
68 }
69
Popular Tags