cmlenz 2002/08/04 09:07:00
Modified: src/taglib/common/org/apache/slide/taglib/util
Iterators.java
Log:
- Add a new iterator that iterates over the list of ancestors of a node,
starting at the root node
- More Javadoc comments
Revision Changes Path
1.3 +54 -0
jakarta-slide/src/taglib/common/org/apache/slide/taglib/util/Iterators.java
Index: Iterators.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/taglib/common/org/apache/slide/taglib/util/Iterators.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Iterators.java 1 Aug 2002 14:38:14 -0000 1.2
+++ Iterators.java 4 Aug 2002 16:07:00 -0000 1.3
@@ -63,7 +63,10 @@
package org.apache.slide.taglib.util;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import org.apache.slide.taglib.bean.NodeBean;
@@ -92,7 +95,30 @@
/**
+ * Returns a special Iterator that iterates over the ancestors on a node,
+ * starting at the root node.
*
+ * @param node the node the ancestors of which should be iterated over
+ * @return an Iterator over the ancestors on the node
+ */
+ public static Iterator ancestorsIterator(NodeBean node) {
+
+ List ancestors = new ArrayList();
+ while (node.getParent() != null) {
+ node = node.getParent();
+ ancestors.add(node);
+ }
+ Collections.reverse(ancestors);
+
+ return ancestors.iterator();
+ }
+
+
+ /**
+ * Returns a special Iterator that iterates over the locks on a node.
+ *
+ * @param node the node the locks of which should be iterated over
+ * @return an Iterator over the locks on the node
*/
public static Iterator locksIterator(NodeBean node) {
@@ -101,7 +127,12 @@
/**
+ * Returns a special Iterator that iterates over the locks on a node and
+ * indirect or direct members of that node, down to a specifiable depth.
*
+ * @param node the node the locks of which should be iterated over
+ * @param depth the recursion depth of the Iterator
+ * @return an Iterator over the locks on the node and its members
*/
public static Iterator locksIterator(NodeBean node, int depth) {
@@ -110,7 +141,10 @@
/**
+ * Returns a special Iterator that iterates over the children of a node.
*
+ * @param node the node the children of which should be iterated over
+ * @return an Iterator over the children of the node
*/
public static Iterator membersIterator(NodeBean node) {
@@ -119,7 +153,12 @@
/**
+ * Returns a special Iterator that recursively iterates over the direct and
+ * indirect members of a node, with a specifiable depth.
*
+ * @param node the node the children of which should be iterated over
+ * @param depth the maximum depth of the recursion
+ * @return an Iterator over the children of the node
*/
public static Iterator membersIterator(NodeBean node, int depth) {
@@ -128,7 +167,22 @@
/**
+ * Returns a special Iterator that recursively iterates over the direct and
+ * indirect members of a node, with a specifiable depth, and with optional
+ * rules for excluding and/or including nodes of particular types and/or
+ * roles.
*
+ * @param node the node the children of which should be iterated over
+ * @param depth the maximum depth of the recursion
+ * @param excludeRoles the set of roles, each a string, to exclude from the
+ * iteration
+ * @param includeRoles the set of roles, each a string, to include in the
+ * iteration
+ * @param excludeTypes the set of types, each a string, to exclude from the
+ * iteration
+ * @param includeTypes the set of types, each a string, to include in the
+ * iteration
+ * @return an Iterator over the children of the node
*/
public static Iterator membersIterator(NodeBean node, int depth,
Set excludeRoles, Set includeRoles,
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>