package hiro.yoshioka.ast.sql.oracle.util;

import hiro.yoshioka.ast.sql.oracle.SimpleNode;
import hiro.yoshioka.ast.sql.oracle.WolfSQLParserTreeConstants;

public class FoldingSQLNodeVisitor extends DefaultSQLNodeVisitor {

	public Object doJob(SimpleNode node, Object data) {
		SimpleNode n;
		for (int ord = 0; ord < node.jjtGetNumChildren(); ord++) {
			n = (SimpleNode) node.jjtGetChild(ord);
			n.jjtAccept(this, data);
		}
		switch (node.getID()) {
		case WolfSQLParserTreeConstants.JJTSUBQUERY:
		case WolfSQLParserTreeConstants.JJTSELECTCOLUMNS:
		case WolfSQLParserTreeConstants.JJTFROM:
		case WolfSQLParserTreeConstants.JJTWHERECLAUSE:
		case WolfSQLParserTreeConstants.JJTORDERBYCLAUSE:
		case WolfSQLParserTreeConstants.JJTGROUPBYCLAUSE:
			v.add(node);
			break;

		default:
			break;
		}
		return v;
	}

}
