List of usage examples for org.apache.commons.collections ArrayStack push
public Object push(Object item)
From source file:org.acmsl.undigester.TreeVisitor.java
/** * Retrieves the next node./*from w w w . jav a2 s .c o m*/ * @param start the start node. * @param current the current node. * @param subiterators the subiterators stack. * @param iterator the first-level iterator. * @return such node. * @precondition start != null */ protected TreeNode nextNode(final TreeNode start, final TreeNode current, final ArrayStack subiterators, final Iterator iterator) { TreeNode result = null; if ((subiterators == null) || (subiterators.size() == 0)) { // Browsing a level no deeper than 1. if (current == start) { result = start; } else { Iterator t_Iterator = iterator; if (t_Iterator == null) { // Starting from the left-most first-level child. Collection t_cChildren = start.getChildren(); if (t_cChildren != null) { t_Iterator = t_cChildren.iterator(); setNodeIterator(t_Iterator); } } if ((t_Iterator != null) && (t_Iterator.hasNext())) { result = (TreeNode) iterator.next(); ArrayStack t_asSubiterators = new ArrayStack(); setSubiterators(t_asSubiterators); Collection t_cCollection = result.getChildren(); if (t_cCollection != null) { t_asSubiterators.push(t_cCollection.iterator()); } } } } else { Iterator t_Iterator = (Iterator) subiterators.peek(); if (t_Iterator.hasNext()) { result = (TreeNode) t_Iterator.next(); } else { // Removing exhausted iterator. subiterators.pop(); // Recursion result = nextNode(); } } setCurrentNode(result); return result; }
From source file:org.apache.cocoon.el.impl.objectmodel.ObjectModelImpl.java
public void putAll(Map mapToCopy) { modified = true;//w ww. j ava 2s .c o m if (!localContexts.empty()) { ArrayStack entries = (ArrayStack) localContexts.peek(); for (Iterator keysIterator = mapToCopy.keySet().iterator(); keysIterator.hasNext();) { Object key = keysIterator.next(); entries.push(new DefaultKeyValue(key, mapToCopy.get(key))); } } singleValueMap.putAll(mapToCopy); multiValueMap.putAll(mapToCopy); }
From source file:org.apache.jmeter.services.FileServer.java
/** * Calculates the relative path from {@link #DEFAULT_BASE} to the current base, * which must be the same as or a child of the default. * //w ww .j a v a2s . c o m * @return the relative path, or {@code "."} if the path cannot be determined */ public synchronized File getBaseDirRelative() { // Must first convert to absolute path names to ensure parents are available File parent = new File(DEFAULT_BASE).getAbsoluteFile(); File f = base.getAbsoluteFile(); ArrayStack l = new ArrayStack(); while (f != null) { if (f.equals(parent)) { if (l.isEmpty()) { break; } File rel = new File((String) l.pop()); while (!l.isEmpty()) { rel = new File(rel, (String) l.pop()); } return rel; } l.push(f.getName()); f = f.getParentFile(); } return new File("."); }