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.jdo.query;
12:
13: import com.versant.core.common.Debug;
14:
15: /**
16: * An additive expression (multiple nodes separated by '+' or '-').
17: */
18: public class AddNode extends Node {
19:
20: public static final int OP_PLUS = 0;
21: public static final int OP_MINUS = 1;
22:
23: /**
24: * The operators. There will be one less entry here than the nodes.
25: * Example: ops[0] is between nodes[0] and nodes[1].
26: */
27: public int[] ops;
28:
29: public AddNode() {
30: }
31:
32: public Object accept(NodeVisitor visitor, Object[] results) {
33: return visitor.visitAddNode(this , results);
34: }
35:
36: /**
37: * Dump debugging info to System.out.
38: */
39: public void dump(String indent) {
40: dumpThis(indent);
41: indent = indent + " ";
42: int i = 0;
43: for (Node c = childList; c != null; c = c.next, i++) {
44: c.dump(indent);
45: if (i < ops.length) {
46: Debug.OUT.println(indent + toOpString(ops[i]));
47: }
48: }
49: }
50:
51: public static String toOpString(int op) {
52: switch (op) {
53: case OP_PLUS:
54: return "+";
55: case OP_MINUS:
56: return "-";
57: }
58: return "Uknown(" + op + ")";
59: }
60:
61: public Field visit(MemVisitor visitor, Object obj) {
62: return visitor.visitAddNode(this , obj);
63: }
64:
65: public Object arrive(NodeVisitor v, Object msg) {
66: return v.arriveAddNode(this, msg);
67: }
68:
69: }
|