KickJava   Java API By Example, From Geeks To Geeks.

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


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.metadata.ClassMetaData;
15
16 import com.versant.core.common.Debug;
17
18 import com.versant.core.common.BindingSupportImpl;
19
20 /**
21  * A node with a single child. This is optimized to treat childList as a
22  * single node and not a list.
23  */

24 public class UnaryNode extends Node {
25
26     public UnaryNode() {
27     }
28
29     public UnaryNode(Node child) {
30         childList = child;
31         child.parent = this;
32     }
33
34     public Object JavaDoc accept(NodeVisitor visitor, Object JavaDoc[] results) {
35       return visitor.visitUnaryNode(this, results);
36     }
37     /**
38      * Resolve field refs and so on relative to the compiler. This must
39      * recursively resolve any child nodes.
40      */

41     public void resolve(QueryParser comp, ClassMetaData cmd, boolean ordering) {
42         if (Debug.DEBUG) System.out.println("### UnaryNode.resolve " + this);
43         childList.resolve(comp, cmd, false);
44     }
45
46     /**
47      * Replace one node with another.
48      */

49     public void replaceChild(Node old, Node nw) {
50         if (childList == old) childList = nw;
51         else throw BindingSupportImpl.getInstance().internal("no such Node: " + old);
52         nw.parent = this;
53         nw.next = null;
54     }
55
56     /**
57      * Simplify this node tree as much as possible.
58      */

59     protected void normalizeImp() {
60         if (childList != null)
61             childList.normalizeImp();
62     }
63
64     public Field visit(MemVisitor visitor, Object JavaDoc obj) {
65         return visitor.visitUnaryNode(this, obj);
66     }
67
68     public Object JavaDoc arrive(NodeVisitor v, Object JavaDoc msg) {
69         return v.arriveUnaryNode(this, msg);
70     }
71
72 }
73
Popular Tags