1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.services.sanity.SanityManager; 25 import org.apache.derby.iapi.sql.compile.Visitable; 26 import org.apache.derby.iapi.sql.compile.Visitor; 27 28 import org.apache.derby.iapi.error.StandardException; 29 30 import java.util.Vector ; 31 32 42 public class CollectNodesVisitor implements Visitor 43 { 44 private Vector nodeList; 45 private Class nodeClass; 46 private Class skipOverClass; 47 53 public CollectNodesVisitor(Class nodeClass) 54 { 55 this.nodeClass = nodeClass; 56 nodeList = new Vector (); 57 } 58 59 67 public CollectNodesVisitor(Class nodeClass, Class skipOverClass) 68 { 69 this(nodeClass); 70 this.skipOverClass = skipOverClass; 71 } 72 73 public boolean stopTraversal() 74 { 75 return false; 76 } 77 83 90 public Visitable visit(Visitable node) 91 { 92 if (nodeClass.isInstance(node)) 93 { 94 nodeList.addElement(node); 95 } 96 return node; 97 } 98 99 105 public boolean skipChildren(Visitable node) 106 { 107 return (skipOverClass == null) ? 108 false: 109 skipOverClass.isInstance(node); 110 } 111 112 121 public Vector getList() 122 { 123 return nodeList; 124 } 125 } 126 | Popular Tags |