List of usage examples for org.apache.commons.collections ArrayStack ArrayStack
public ArrayStack()
ArrayStack
. From source file:com.liferay.ide.layouttpl.core.util.LayoutTplUtil.java
private static void createLayoutTplContext(ITemplateOperation op, LayoutTplElement layouttpl) { final ITemplateContext ctx = op.getContext(); ctx.put("root", layouttpl); ctx.put("stack", new ArrayStack()); }
From source file:de.topicmapslab.kuria.runtime.util.TypeUtilTest.java
@SuppressWarnings("unchecked") @Test//from ww w . j a v a 2 s . co m public void testGetContainerType() { String[] tmp3 = new String[10]; assertEquals("Check String array: ", String.class, TypeUtil.getContainerType(tmp3.getClass())); String tmp4[] = new String[10]; assertEquals("Check String array: ", String.class, TypeUtil.getContainerType(tmp4.getClass())); try { Field field = TypeUtilTest.class.getDeclaredField("stringList"); assertEquals("Check List: ", String.class, TypeUtil.getContainerType(field.getGenericType())); assertTrue("Check Vector: ", TypeUtil.isList(field.getGenericType())); field = TypeUtilTest.class.getDeclaredField("stringList2"); assertEquals("Check ArrayListV: ", String.class, TypeUtil.getContainerType(field.getGenericType())); assertTrue("Check Vector: ", TypeUtil.isList(field.getGenericType())); field = TypeUtilTest.class.getDeclaredField("stringList3"); assertEquals("Check Vector: ", String.class, TypeUtil.getContainerType(field.getGenericType())); assertTrue("Check Vector: ", TypeUtil.isList(field.getGenericType())); field = TypeUtilTest.class.getDeclaredField("stack"); assertEquals("Check Stack: ", Object.class, TypeUtil.getContainerType(field.getGenericType())); field = TypeUtilTest.class.getDeclaredField("set1"); assertEquals("Check Sets Parameter: ", Integer.class, TypeUtil.getContainerType(field.getGenericType())); assertTrue("Check Set: ", TypeUtil.isSet(field.getGenericType())); field = TypeUtilTest.class.getDeclaredField("set2"); assertEquals("Check HashSet: ", Integer.class, TypeUtil.getContainerType(field.getGenericType())); assertTrue("Check HashSet: ", TypeUtil.isSet(field.getGenericType())); field = TypeUtilTest.class.getDeclaredField("set3"); assertEquals("Check untyped Set: ", Object.class, TypeUtil.getContainerType(field.getGenericType())); } catch (Exception e) { throw new RuntimeException(e); } // expecting object because no real reflection possible on var types. List<String> tmp = new ArrayList<String>(); assertEquals("Check ArrayList: ", Object.class, TypeUtil.getContainerType(tmp.getClass())); tmp = new ArrayStack(); assertEquals("Check ArrayList: ", Object.class, TypeUtil.getContainerType(tmp.getClass())); tmp = new Vector<String>(); assertEquals("Check ArrayList: ", Object.class, TypeUtil.getContainerType(tmp.getClass())); Set<Integer> tmp2 = new HashSet<Integer>(); assertEquals("Check HashSet: ", Object.class, TypeUtil.getContainerType(tmp2.getClass())); try { TypeUtil.getContainerType(String.class); } catch (IllegalArgumentException e) { return; } fail("No exception thrown"); }
From source file:org.acmsl.undigester.TreeVisitor.java
/** * Retrieves the next node./*from w ww . j ava 2 s .c om*/ * @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.atlas.discovery.DataSetLineageServiceTest.java
private void createTable(String tableName, int numCols, boolean createLineage) throws Exception { String dbId = getEntityId(DATABASE_TYPE, "name", "Sales"); Id salesDB = new Id(dbId, 0, DATABASE_TYPE); //Create the entity again and schema should return the new schema List<Referenceable> columns = new ArrayStack(); for (int i = 0; i < numCols; i++) { columns.add(column("col" + random(), "int", "column descr")); }//from w w w. j ava 2s . c o m Referenceable sd = storageDescriptor("hdfs://host:8000/apps/warehouse/sales", "TextInputFormat", "TextOutputFormat", true, ImmutableList.of(column("time_id", "int", "time id"))); Id table = table(tableName, "test table", salesDB, sd, "fetl", "External", columns); if (createLineage) { Id inTable = table("table" + random(), "test table", salesDB, sd, "fetl", "External", columns); Id outTable = table("table" + random(), "test table", salesDB, sd, "fetl", "External", columns); loadProcess("process" + random(), "hive query for monthly summary", "Tim ETL", ImmutableList.of(inTable), ImmutableList.of(table), "create table as select ", "plan", "id", "graph", "ETL"); loadProcess("process" + random(), "hive query for monthly summary", "Tim ETL", ImmutableList.of(table), ImmutableList.of(outTable), "create table as select ", "plan", "id", "graph", "ETL"); } }
From source file:org.apache.cayenne.ashwood.graph.DepthFirstSearch.java
public DepthFirstSearch(DigraphIteration<E, ?> factory, E firstVertex) { this.stack = new ArrayStack(); this.seen = new HashSet<>(); this.factory = factory; this.firstVertex = firstVertex; stack.push(factory.outgoingIterator(firstVertex)); seen.add(firstVertex);/*from w w w.j a v a 2s.c om*/ }
From source file:org.apache.cayenne.ashwood.graph.StrongConnection.java
public StrongConnection(DigraphIteration<E, V> digraph) { this.dfsStack = new ArrayStack(); this.reverseDFSFilter = new DFSSeenVerticesPredicate(); this.digraph = digraph; this.filteredDigraph = new FilterIteration<>(digraph, new NotSeenPredicate(), TruePredicate.INSTANCE); this.reverseDigraph = new FilterIteration<>(new ReversedIteration<>(digraph), reverseDFSFilter, TruePredicate.INSTANCE);/*from ww w.j av a 2 s . co m*/ this.vertexIterator = filteredDigraph.vertexIterator(); runDirectDFS(); }
From source file:org.apache.cocoon.el.impl.objectmodel.ObjectModelImpl.java
public ObjectModelImpl() { singleValueMap = new HashMap(); //FIXME: Not sure if this makes sense //super.map = UnmodifiableMap.decorate(singleValueMap); super.map = singleValueMap; localContexts = new ArrayStack(); multiValueMap = MultiValueMap.decorate(new HashMap(), StackReversedIteration.class); multiValueMapForLocated = MultiValueMap.decorate(new HashMap(), StackReversedIteration.class); }
From source file:org.apache.cocoon.el.impl.objectmodel.ObjectModelImpl.java
public void markLocalContext() { localContexts.push(new ArrayStack()); }
From source file:org.apache.directory.server.xdbm.search.cursor.DescendantCursor.java
/** * Creates a Cursor over entries satisfying one level scope criteria. * * @param partitionTxn The transaction to use * @param db the entry store/*w w w. j ava 2 s . c o m*/ * @param baseId The base ID * @param parentId The parent ID * @param cursor The wrapped cursor * @param topLevel If we are at the top level */ public DescendantCursor(PartitionTxn partitionTxn, Store db, String baseId, String parentId, Cursor<IndexEntry<ParentIdAndRdn, String>> cursor, boolean topLevel) { this.db = db; currentParentId = parentId; currentCursor = cursor; cursorStack = new ArrayStack(); parentIdStack = new ArrayStack(); this.baseId = baseId; this.topLevel = topLevel; this.partitionTxn = partitionTxn; if (IS_DEBUG) { LOG_CURSOR.debug("Creating ChildrenCursor {}", this); } }
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. * //from w w w .j a v a2 s . co 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("."); }