public int execute() throws Exception { if (QueryInfo.get__dbInfo() == null) { throw new Exception("No choosed database"); } String tableName = tree.getChild(2).getText(); tableInfo = DictCenterManager.findTableWithName(QueryInfo.get__dbInfo(), tableName); int ret = 0; if (!chooseAll) { table = DataTableManager.loadTable(tableInfo); int len = table.getRecords().size(); for (cur = 0; cur < len; cur++) { visitor.visitTree((sqlParser.ExprContext) tree.getChild(3).getChild(1)); if (((ValueTree) tree.getChild(3).getChild(1)).getValue().getValue().equals(true)) { ret++; } else { resTable.getRecords().add(table.getRecords().get(cur)); } } table.setRecords(resTable.getRecords()); } else { ret = table.getRecords().size(); table.getRecords().clear(); } DataTableManager.storeTable(table); return ret; }
/** * Applies the TreeVisitor to to all trees in the Treebank. * * @param tv A class that can process trees. */ public void apply(TreeVisitor tv) { for (Tree t : tb) { if (VERBOSE) System.out.println("TfTbApply transforming " + t); Tree tmpT = t.deeperCopy(); if (transformer != null) { tmpT = transformer.transformTree(tmpT); } if (VERBOSE) System.out.println(" to " + tmpT); tv.visitTree(tmpT); } }
/** * Apply the TreeVisitor tp to all trees in the Treebank. * * @param tp A class that implements the TreeVisitor interface */ @Override public void apply(TreeVisitor tp) { for (int i = 0, size = parseTrees.size(); i < size; i++) { tp.visitTree(parseTrees.get(i)); } // or could do as Iterator but slower // Iterator iter = parseTrees.iterator(); // while (iter.hasNext()) { // tp.visitTree((Tree) iter.next()); // } }
/* applies a TreeVisitor to all projections (including the node itself) of a node in a Tree. * Does nothing if head is not in root. * @return the maximal projection of head in root. */ public static Tree applyToProjections(TreeVisitor v, Tree head, Tree root, HeadFinder hf) { Tree projection = head; Tree parent = projection.parent(root); if (parent == null && projection != root) { return null; } v.visitTree(projection); if (projection == root) { return root; } while (hf.determineHead(parent) == projection) { projection = parent; v.visitTree(projection); if (projection == root) { return root; } parent = projection.parent(root); } return projection; }
@Override public void apply(TreeVisitor tp) { for (Tree tree : this) { tp.visitTree(tree); } }