1 21 22 23 package org.apache.derby.impl.sql.compile; 24 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 org.apache.derby.iapi.util.JBitSet; 31 32 37 public class ReferencedTablesVisitor implements Visitor 38 { 39 private JBitSet tableMap; 40 41 public ReferencedTablesVisitor(JBitSet tableMap) 42 { 43 this.tableMap = tableMap; 44 } 45 46 47 53 63 public Visitable visit(Visitable node) 64 throws StandardException 65 { 66 if (node instanceof ColumnReference) 67 { 68 ((ColumnReference)node).getTablesReferenced(tableMap); 69 } 70 else if (node instanceof Predicate) 71 { 72 Predicate pred = (Predicate) node; 73 tableMap.or(pred.getReferencedSet()); 74 } 75 else if (node instanceof ResultSetNode) 76 { 77 ResultSetNode rs = (ResultSetNode) node; 78 tableMap.or(rs.getReferencedTableMap()); 79 } 80 81 return node; 82 } 83 84 89 public boolean skipChildren(Visitable node) 90 { 91 return (node instanceof Predicate || 92 node instanceof ResultSetNode); 93 } 94 95 public boolean stopTraversal() 96 { 97 return false; 98 } 99 JBitSet getTableMap() 105 { 106 return tableMap; 107 } 108 } 109 | Popular Tags |