SimpleNode.java

00001 /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
00002 
00003 package org.objectweb.jonas_ejb.deployment.ejbql;
00004 
00005 
00006 import java.util.ArrayList;
00007 import java.util.Iterator;
00008 
00015 public class SimpleNode implements Node {
00016   protected Node parent;
00017   protected Node[] children;
00018   protected int id;
00019   protected EJBQL parser;
00020   
00021   // added by cney
00022   public ArrayList ops=new ArrayList(); //operators
00023   public Object value = null;
00024   public boolean distinct = false;
00025   public boolean not = false;
00026   public boolean third = false;   // added by hjoanin: third operand of like and locate
00027   public int eltnum = 0; // added by hjoanin: to count the number of string_literal in the in_expression
00028   public boolean asc = true; // added by hjoanin: orderby clause
00029   // end added
00030 
00031   public SimpleNode(int i) {
00032     id = i;
00033   }
00034 
00035   public SimpleNode(EJBQL p, int i) {
00036     this(i);
00037     parser = p;
00038   }
00039 
00040   public void jjtOpen() {
00041   }
00042 
00043   public void jjtClose() {
00044   }
00045   
00046   public void jjtSetParent(Node n) { parent = n; }
00047   public Node jjtGetParent() { return parent; }
00048 
00049   public void jjtAddChild(Node n, int i) {
00050     if (children == null) {
00051       children = new Node[i + 1];
00052     } else if (i >= children.length) {
00053       Node c[] = new Node[i + 1];
00054       System.arraycopy(children, 0, c, 0, children.length);
00055       children = c;
00056     }
00057     children[i] = n;
00058   }
00059 
00060   public Node jjtGetChild(int i) {
00061     return children[i];
00062   }
00063 
00064   public int jjtGetNumChildren() {
00065     return (children == null) ? 0 : children.length;
00066   }
00067 
00069   public Object jjtAccept(EJBQLVisitor visitor, Object data) {
00070     return visitor.visit(this, data);
00071   }
00072 
00074   public Object childrenAccept(EJBQLVisitor visitor, Object data) {
00075     if (children != null) {
00076       for (int i = 0; i < children.length; ++i) {
00077         children[i].jjtAccept(visitor, data);
00078       }
00079     }
00080     return data;
00081   }
00082 
00083   /* You can override these two methods in subclasses of SimpleNode to
00084      customize the way the node appears when the tree is dumped.  If
00085      your output uses more than one line you should override
00086      toString(String), otherwise overriding toString() is probably all
00087      you need to do. */
00088 
00089   // begin of ObjectWeb changes
00090   //public String toString() { return EJBQLTreeConstants.jjtNodeName[id]; }
00091   public String toString() {
00092       String ret = "";
00093       if (not) ret+="NOT ";
00094       if (distinct) ret+="DISTINCT ";
00095       if (asc) {
00096           ret+="ASC ";
00097       } else {
00098           ret+="DESC ";
00099       }
00100 
00101       if (ops.size()!=0) {
00102           ret+="(";
00103           for (Iterator i = ops.iterator(); i.hasNext();) {
00104               String token=EJBQLConstants.tokenImage[((Integer)i.next()).intValue()];
00105               ret+=token.substring(1,token.length()-1)+",";
00106           }
00107           ret = ret.substring(0,ret.length()-1);
00108       }
00109       if (value!=null) ret+=value;
00110       if (ops.size()!=0) ret+=")";
00111       return EJBQLTreeConstants.jjtNodeName[id]+" "+ret;
00112   }
00113   // end of ObjectWeb changes
00114   public String toString(String prefix) { return prefix + toString(); }
00115 
00116   /* Override this method if you want to customize how the node dumps
00117      out its children. */
00118 
00119   public void dump(String prefix) {
00120     System.out.println(toString(prefix));
00121     if (children != null) {
00122       for (int i = 0; i < children.length; ++i) {
00123         SimpleNode n = (SimpleNode)children[i];
00124         if (n != null) {
00125           n.dump(prefix + " ");
00126         }
00127       }
00128     }
00129   }
00130 }
00131 

Generated on Tue Feb 15 15:05:46 2005 for JOnAS by  doxygen 1.3.9.1