KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
15  * A unary operation.
16  */

17 public class UnaryOpNode extends UnaryNode {
18
19     public static final int OP_MINUS = 1;
20     public static final int OP_PLUS = 2;
21     public static final int OP_TILDE = 3;
22     public static final int OP_BANG = 4;
23
24     /**
25      * The operation.
26      */

27     public int op;
28
29     public UnaryOpNode(Node child, int op) {
30         super(child);
31         this.op = op;
32     }
33
34     public Object JavaDoc accept(NodeVisitor visitor, Object JavaDoc[] results) {
35       return visitor.visitUnaryOpNode(this, results);
36     }
37
38     public String JavaDoc toString() {
39         return super.toString() + " " + toOpString(op);
40     }
41
42     public static String JavaDoc toOpString(int op) {
43         switch (op) {
44             case OP_MINUS:
45                 return "-";
46             case OP_PLUS:
47                 return "+";
48             case OP_TILDE:
49                 return "~";
50             case OP_BANG:
51                 return "!";
52         }
53         return "Unknown(" + op + ")";
54     }
55
56     public Field visit(MemVisitor visitor, Object JavaDoc obj) {
57         return visitor.visitUnaryOpNode(this, obj);
58     }
59
60     public Object JavaDoc arrive(NodeVisitor v, Object JavaDoc msg) {
61         return v.arriveUnaryOpNode(this, msg);
62     }
63 }
64
65
Popular Tags