KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > ejb > query > Node


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.ejb.query;
13
14 /**
15  * An expression. Has a next pointer so these can be easily chained together
16  * into lists.
17  */

18 public abstract class Node {
19
20     private Node next;
21
22     public Node() {
23     }
24
25     public Node getNext() {
26         return next;
27     }
28
29     public void setNext(Node next) {
30         this.next = next;
31     }
32
33     public void appendList(StringBuffer JavaDoc s) {
34         appendList(s, ", ");
35     }
36
37     public void appendList(StringBuffer JavaDoc s, String JavaDoc separator) {
38         s.append(this);
39         if (next != null) {
40             for (Node i = next; i != null; i = i.next) {
41                 s.append(separator);
42                 s.append(i);
43             }
44         }
45     }
46
47     public String JavaDoc toString() {
48         String JavaDoc s = getClass().getName();
49         int i = s.lastIndexOf('.') + 1;
50         int j = s.lastIndexOf("Node");
51         StringBuffer JavaDoc b = new StringBuffer JavaDoc();
52         b.append('{');
53         if (j >= 0) {
54             b.append(s.substring(i, j));
55         } else {
56             b.append(s.substring(i));
57         }
58         b.append(' ');
59         b.append(toStringImp());
60         b.append('}');
61         return b.toString();
62     }
63
64     public abstract String JavaDoc toStringImp();
65
66     /**
67      * Attach type information to the Nodes using rc.
68      */

69     public void resolve(ResolveContext rc) {
70     }
71
72     /**
73      * Call resolve on each node in list. NOP if list is null.
74      */

75     protected static void resolve(Node list, ResolveContext rc) {
76         for (; list != null; list = list.next) {
77             list.resolve(rc);
78         }
79     }
80
81     /**
82      * Invoke v's arriveXXX method for the node.
83      */

84     public abstract Object JavaDoc arrive(NodeVisitor v, Object JavaDoc msg);
85
86 }
87
88
Popular Tags