Pattern[] pats = ((PatternNode)node).getPattern();
int count = tl.countMatches(pats);
nodeToCount.put(node, new Integer(count));
// walk upwards, adding count to every parent
Node parent = node;
while ((parent = (Node)parent.getParent()) != currentTopNode){
Integer c = nodeToCount.get(parent);
Integer newCount = new Integer(c.intValue() + count);
nodeToCount.put(parent, newCount);
}
} else {
nodeToCount.put(node, new Integer(0));
}
// recurse
Enumeration<Node> en = node.children();
while (en.hasMoreElements()){
Node n = en.nextElement();
collectPatterns(n, tl);
}
}