@SuppressWarnings("unchecked") public List<String> getResourcePaths(String path) { List<String> result = CollectionFactory.newList(); Stack<String> queue = CollectionFactory.newStack(); queue.push(path); while (!queue.isEmpty()) { String current = queue.pop(); Set<String> matches = servletContext.getResourcePaths(current); // Tomcat 5.5.20 inside JBoss 4.0.2 has been observed to do this! // Perhaps other servers do as well. if (matches == null) continue; for (String match : matches) { // Folders are queued up for further expansion. if (match.endsWith("/")) queue.push(match); else result.add(match); } } Collections.sort(result); return result; }
/** * Depth-first visitor traversal of this Element and its Element children. The traversal order is the same as render * order. * * @param visitor * callback * @since 5.1.0.0 */ public void visit(Visitor visitor) { Stack<Element> queue = CollectionFactory.newStack(); queue.push(this); while (!queue.isEmpty()) { Element e = queue.pop(); visitor.visit(e); e.queueChildren(queue); } }
Stack<TemplateToken> queue = CollectionFactory.newStack();
public List<Stuff> getSelectedObjects() { List<Stuff> result = CollectionFactory.newList(); Stack<TreeNode<Stuff>> queue = CollectionFactory.newStack(); TreeModel<Stuff> model = getStuffModel(); TreeSelectionModel<Stuff> selectionModel = getSelectionModel(); for (TreeNode<Stuff> root : model.getRootNodes()) { queue.push(root); } while (!queue.isEmpty()) { TreeNode<Stuff> current = queue.pop(); if (selectionModel.isSelected(current)) { result.add(current.getValue()); } for (TreeNode<Stuff> child : current.getChildren()) { queue.push(child); } } return result; }