org.objectweb.jonas_ejb.deployment.ejbql.SimpleNode Maven / Gradle / Ivy
/* Generated By:JJTree: Do not edit this line. SimpleNode.java */
package org.objectweb.jonas_ejb.deployment.ejbql;
import java.util.ArrayList;
import java.util.Iterator;
/**
* Initialy generated by JJTree, this class was modified to hold specific fields used by Visitors
* @author Christophe Ney [[email protected]]: Initial developper
* @author Helene Joanin: contributeur
**/
public class SimpleNode implements Node {
protected Node parent;
protected Node[] children;
protected int id;
protected EJBQL parser;
// added by cney
public ArrayList ops=new ArrayList(); //operators
public Object value = null;
public boolean distinct = false;
public boolean not = false;
public boolean third = false; // added by hjoanin: third operand of like and locate
public int eltnum = 0; // added by hjoanin: to count the number of string_literal in the in_expression
public boolean asc = true; // added by hjoanin: orderby clause
// end added
public SimpleNode(int i) {
id = i;
}
public SimpleNode(EJBQL p, int i) {
this(i);
parser = p;
}
public void jjtOpen() {
}
public void jjtClose() {
}
public void jjtSetParent(Node n) { parent = n; }
public Node jjtGetParent() { return parent; }
public void jjtAddChild(Node n, int i) {
if (children == null) {
children = new Node[i + 1];
} else if (i >= children.length) {
Node c[] = new Node[i + 1];
System.arraycopy(children, 0, c, 0, children.length);
children = c;
}
children[i] = n;
}
public Node jjtGetChild(int i) {
return children[i];
}
public int jjtGetNumChildren() {
return (children == null) ? 0 : children.length;
}
/** Accept the visitor. **/
public Object jjtAccept(EJBQLVisitor visitor, Object data) {
return visitor.visit(this, data);
}
/** Accept the visitor. **/
public Object childrenAccept(EJBQLVisitor visitor, Object data) {
if (children != null) {
for (int i = 0; i < children.length; ++i) {
children[i].jjtAccept(visitor, data);
}
}
return data;
}
/* You can override these two methods in subclasses of SimpleNode to
customize the way the node appears when the tree is dumped. If
your output uses more than one line you should override
toString(String), otherwise overriding toString() is probably all
you need to do. */
// begin of ObjectWeb changes
//public String toString() { return EJBQLTreeConstants.jjtNodeName[id]; }
public String toString() {
String ret = "";
if (not) ret+="NOT ";
if (distinct) ret+="DISTINCT ";
if (asc) {
ret+="ASC ";
} else {
ret+="DESC ";
}
if (ops.size()!=0) {
ret+="(";
for (Iterator i = ops.iterator(); i.hasNext();) {
String token=EJBQLConstants.tokenImage[((Integer)i.next()).intValue()];
ret+=token.substring(1,token.length()-1)+",";
}
ret = ret.substring(0,ret.length()-1);
}
if (value!=null) ret+=value;
if (ops.size()!=0) ret+=")";
return EJBQLTreeConstants.jjtNodeName[id]+" "+ret;
}
// end of ObjectWeb changes
public String toString(String prefix) { return prefix + toString(); }
/* Override this method if you want to customize how the node dumps
out its children. */
public void dump(String prefix) {
System.out.println(toString(prefix));
if (children != null) {
for (int i = 0; i < children.length; ++i) {
SimpleNode n = (SimpleNode)children[i];
if (n != null) {
n.dump(prefix + " ");
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy