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: /**
14: * A unary operation.
15: */
16: public class UnaryOpNode extends UnaryNode {
17:
18: public static final int OP_MINUS = 1;
19: public static final int OP_PLUS = 2;
20: public static final int OP_TILDE = 3;
21: public static final int OP_BANG = 4;
22:
23: /**
24: * The operation.
25: */
26: public int op;
27:
28: public UnaryOpNode(Node child, int op) {
29: super (child);
30: this .op = op;
31: }
32:
33: public Object accept(NodeVisitor visitor, Object[] results) {
34: return visitor.visitUnaryOpNode(this , results);
35: }
36:
37: public String toString() {
38: return super .toString() + " " + toOpString(op);
39: }
40:
41: public static String toOpString(int op) {
42: switch (op) {
43: case OP_MINUS:
44: return "-";
45: case OP_PLUS:
46: return "+";
47: case OP_TILDE:
48: return "~";
49: case OP_BANG:
50: return "!";
51: }
52: return "Unknown(" + op + ")";
53: }
54:
55: public Field visit(MemVisitor visitor, Object obj) {
56: return visitor.visitUnaryOpNode(this , obj);
57: }
58:
59: public Object arrive(NodeVisitor v, Object msg) {
60: return v.arriveUnaryOpNode(this, msg);
61: }
62: }
|