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 40 public class HasNodeVisitor implements Visitor 41 { 42 private boolean hasNode; 43 private Class nodeClass; 44 private Class skipOverClass; 45 51 public HasNodeVisitor(Class nodeClass) 52 { 53 this.nodeClass = nodeClass; 54 } 55 56 64 public HasNodeVisitor(Class nodeClass, Class skipOverClass) 65 { 66 this.nodeClass = nodeClass; 67 this.skipOverClass = skipOverClass; 68 } 69 70 76 83 public Visitable visit(Visitable node) 84 { 85 if (nodeClass.isInstance(node)) 86 { 87 hasNode = true; 88 } 89 return node; 90 } 91 92 97 public boolean stopTraversal() 98 { 99 return hasNode; 100 } 101 102 108 public boolean skipChildren(Visitable node) 109 { 110 return (skipOverClass == null) ? 111 false: 112 skipOverClass.isInstance(node); 113 } 114 115 126 public boolean hasNode() 127 { 128 return hasNode; 129 } 130 131 135 public void reset() 136 { 137 hasNode = false; 138 } 139 } 140 | Popular Tags |