001: /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
002:
003: package org.objectweb.jonas_ejb.deployment.ejbql;
004:
005: import java.util.ArrayList;
006: import java.util.Iterator;
007:
008: /**
009: * Initialy generated by JJTree, this class was modified to hold specific fields used by Visitors
010: * @author Christophe Ney [cney@batisseurs.com]: Initial developper
011: * @author Helene Joanin: contributeur
012: **/
013:
014: public class SimpleNode implements Node {
015: protected Node parent;
016: protected Node[] children;
017: protected int id;
018: protected EJBQL parser;
019:
020: // added by cney
021: public ArrayList ops = new ArrayList(); //operators
022: public Object value = null;
023: public boolean distinct = false;
024: public boolean not = false;
025: public boolean third = false; // added by hjoanin: third operand of like and locate
026: public int eltnum = 0; // added by hjoanin: to count the number of string_literal in the in_expression
027: public boolean asc = true; // added by hjoanin: orderby clause
028:
029: // end added
030:
031: public SimpleNode(int i) {
032: id = i;
033: }
034:
035: public SimpleNode(EJBQL p, int i) {
036: this (i);
037: parser = p;
038: }
039:
040: public void jjtOpen() {
041: }
042:
043: public void jjtClose() {
044: }
045:
046: public void jjtSetParent(Node n) {
047: parent = n;
048: }
049:
050: public Node jjtGetParent() {
051: return parent;
052: }
053:
054: public void jjtAddChild(Node n, int i) {
055: if (children == null) {
056: children = new Node[i + 1];
057: } else if (i >= children.length) {
058: Node c[] = new Node[i + 1];
059: System.arraycopy(children, 0, c, 0, children.length);
060: children = c;
061: }
062: children[i] = n;
063: }
064:
065: public Node jjtGetChild(int i) {
066: return children[i];
067: }
068:
069: public int jjtGetNumChildren() {
070: return (children == null) ? 0 : children.length;
071: }
072:
073: /** Accept the visitor. **/
074: public Object jjtAccept(EJBQLVisitor visitor, Object data) {
075: return visitor.visit(this , data);
076: }
077:
078: /** Accept the visitor. **/
079: public Object childrenAccept(EJBQLVisitor visitor, Object data) {
080: if (children != null) {
081: for (int i = 0; i < children.length; ++i) {
082: children[i].jjtAccept(visitor, data);
083: }
084: }
085: return data;
086: }
087:
088: /* You can override these two methods in subclasses of SimpleNode to
089: customize the way the node appears when the tree is dumped. If
090: your output uses more than one line you should override
091: toString(String), otherwise overriding toString() is probably all
092: you need to do. */
093:
094: // begin of ObjectWeb changes
095: //public String toString() { return EJBQLTreeConstants.jjtNodeName[id]; }
096: public String toString() {
097: String ret = "";
098: if (not)
099: ret += "NOT ";
100: if (distinct)
101: ret += "DISTINCT ";
102: if (asc) {
103: ret += "ASC ";
104: } else {
105: ret += "DESC ";
106: }
107:
108: if (ops.size() != 0) {
109: ret += "(";
110: for (Iterator i = ops.iterator(); i.hasNext();) {
111: String token = EJBQLConstants.tokenImage[((Integer) i
112: .next()).intValue()];
113: ret += token.substring(1, token.length() - 1) + ",";
114: }
115: ret = ret.substring(0, ret.length() - 1);
116: }
117: if (value != null)
118: ret += value;
119: if (ops.size() != 0)
120: ret += ")";
121: return EJBQLTreeConstants.jjtNodeName[id] + " " + ret;
122: }
123:
124: // end of ObjectWeb changes
125: public String toString(String prefix) {
126: return prefix + toString();
127: }
128:
129: /* Override this method if you want to customize how the node dumps
130: out its children. */
131:
132: public void dump(String prefix) {
133: System.out.println(toString(prefix));
134: if (children != null) {
135: for (int i = 0; i < children.length; ++i) {
136: SimpleNode n = (SimpleNode) children[i];
137: if (n != null) {
138: n.dump(prefix + " ");
139: }
140: }
141: }
142: }
143: }
|