KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ejb > deployment > ejbql > SimpleNode


1 /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
2
3 package org.objectweb.jonas_ejb.deployment.ejbql;
4
5
6 import java.util.ArrayList JavaDoc;
7 import java.util.Iterator JavaDoc;
8
9 /**
10 * Initialy generated by JJTree, this class was modified to hold specific fields used by Visitors
11 * @author Christophe Ney [cney@batisseurs.com]: Initial developper
12 * @author Helene Joanin: contributeur
13 **/

14
15 public class SimpleNode implements Node {
16   protected Node parent;
17   protected Node[] children;
18   protected int id;
19   protected EJBQL parser;
20   
21   // added by cney
22
public ArrayList JavaDoc ops=new ArrayList JavaDoc(); //operators
23
public Object JavaDoc value = null;
24   public boolean distinct = false;
25   public boolean not = false;
26   public boolean third = false; // added by hjoanin: third operand of like and locate
27
public int eltnum = 0; // added by hjoanin: to count the number of string_literal in the in_expression
28
public boolean asc = true; // added by hjoanin: orderby clause
29
// end added
30

31   public SimpleNode(int i) {
32     id = i;
33   }
34
35   public SimpleNode(EJBQL p, int i) {
36     this(i);
37     parser = p;
38   }
39
40   public void jjtOpen() {
41   }
42
43   public void jjtClose() {
44   }
45   
46   public void jjtSetParent(Node n) { parent = n; }
47   public Node jjtGetParent() { return parent; }
48
49   public void jjtAddChild(Node n, int i) {
50     if (children == null) {
51       children = new Node[i + 1];
52     } else if (i >= children.length) {
53       Node c[] = new Node[i + 1];
54       System.arraycopy(children, 0, c, 0, children.length);
55       children = c;
56     }
57     children[i] = n;
58   }
59
60   public Node jjtGetChild(int i) {
61     return children[i];
62   }
63
64   public int jjtGetNumChildren() {
65     return (children == null) ? 0 : children.length;
66   }
67
68   /** Accept the visitor. **/
69   public Object JavaDoc jjtAccept(EJBQLVisitor visitor, Object JavaDoc data) {
70     return visitor.visit(this, data);
71   }
72
73   /** Accept the visitor. **/
74   public Object JavaDoc childrenAccept(EJBQLVisitor visitor, Object JavaDoc data) {
75     if (children != null) {
76       for (int i = 0; i < children.length; ++i) {
77         children[i].jjtAccept(visitor, data);
78       }
79     }
80     return data;
81   }
82
83   /* You can override these two methods in subclasses of SimpleNode to
84      customize the way the node appears when the tree is dumped. If
85      your output uses more than one line you should override
86      toString(String), otherwise overriding toString() is probably all
87      you need to do. */

88
89   // begin of ObjectWeb changes
90
//public String toString() { return EJBQLTreeConstants.jjtNodeName[id]; }
91
public String JavaDoc toString() {
92       String JavaDoc ret = "";
93       if (not) ret+="NOT ";
94       if (distinct) ret+="DISTINCT ";
95       if (asc) {
96           ret+="ASC ";
97       } else {
98           ret+="DESC ";
99       }
100
101       if (ops.size()!=0) {
102           ret+="(";
103           for (Iterator JavaDoc i = ops.iterator(); i.hasNext();) {
104               String JavaDoc token=EJBQLConstants.tokenImage[((Integer JavaDoc)i.next()).intValue()];
105               ret+=token.substring(1,token.length()-1)+",";
106           }
107           ret = ret.substring(0,ret.length()-1);
108       }
109       if (value!=null) ret+=value;
110       if (ops.size()!=0) ret+=")";
111       return EJBQLTreeConstants.jjtNodeName[id]+" "+ret;
112   }
113   // end of ObjectWeb changes
114
public String JavaDoc toString(String JavaDoc prefix) { return prefix + toString(); }
115
116   /* Override this method if you want to customize how the node dumps
117      out its children. */

118
119   public void dump(String JavaDoc prefix) {
120     System.out.println(toString(prefix));
121     if (children != null) {
122       for (int i = 0; i < children.length; ++i) {
123     SimpleNode n = (SimpleNode)children[i];
124     if (n != null) {
125       n.dump(prefix + " ");
126     }
127       }
128     }
129   }
130 }
131
132
Popular Tags