Class Iterators
- java.lang.Object
-
- org.apache.jackrabbit.spi.commons.iterator.Iterators
-
public final class Iterators extends java.lang.Object
Utility class containing type safe adapters for some of the iterators of commons-collections.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.util.Iterator<T>
arrayIterator(T[] values, int from, int to)
Returns an iterator for elements of an array ofvalues
.static <T> java.util.Iterator<T>
empty()
Returns an empty iterator of typeT
.static <T> java.util.Iterator<T>
filterIterator(java.util.Iterator<? extends T> iterator, Predicate<? super T> predicate)
Returns an iterator with elements from an originaliterator
where the givenpredicate
matches removed.static <T> java.util.Iterator<T>
iteratorChain(java.util.Collection<? extends T> iterators)
Returns an iterator for the concatenation of all the giveniterators
.static <T> java.util.Iterator<T>
iteratorChain(java.util.Iterator<? extends T>[] iterators)
Returns an iterator for the concatenation of all the giveniterators
.static <T> java.util.Iterator<T>
iteratorChain(java.util.Iterator<? extends T> iterator1, java.util.Iterator<? extends T> iterator2)
Returns an iterator for the concatenation ofiterator1
anditerator2
.static java.util.Iterator<Node>
nodes(NodeIterator nodeIterator)
Returns an iterator ofNode
from aNodeIterator
.static java.util.Iterator<Property>
properties(PropertyIterator propertyIterator)
Returns an iterator ofProperty
from aPropertyIterator
.static <T> java.util.Iterator<T>
singleton(T element)
Returns an iterator containing the single elementelement
of typeT
.static <T,R,S extends T>
java.util.Iterator<R>transformIterator(java.util.Iterator<? extends T> iterator, Transformer<S,? super R> transformer)
Returns an iterator with elements of an originaliterator
transformed by atransformer
.
-
-
-
Method Detail
-
singleton
public static <T> java.util.Iterator<T> singleton(T element)
Returns an iterator containing the single elementelement
of typeT
.- Type Parameters:
T
-- Parameters:
element
-- Returns:
-
empty
public static <T> java.util.Iterator<T> empty()
Returns an empty iterator of typeT
.- Type Parameters:
T
-- Returns:
-
iteratorChain
public static <T> java.util.Iterator<T> iteratorChain(java.util.Iterator<? extends T> iterator1, java.util.Iterator<? extends T> iterator2)
Returns an iterator for the concatenation ofiterator1
anditerator2
.- Type Parameters:
T
-- Parameters:
iterator1
-iterator2
-- Returns:
-
iteratorChain
public static <T> java.util.Iterator<T> iteratorChain(java.util.Iterator<? extends T>[] iterators)
Returns an iterator for the concatenation of all the giveniterators
.- Type Parameters:
T
-- Parameters:
iterators
-- Returns:
-
iteratorChain
public static <T> java.util.Iterator<T> iteratorChain(java.util.Collection<? extends T> iterators)
Returns an iterator for the concatenation of all the giveniterators
.- Type Parameters:
T
-- Parameters:
iterators
-- Returns:
-
arrayIterator
public static <T> java.util.Iterator<T> arrayIterator(T[] values, int from, int to)
Returns an iterator for elements of an array ofvalues
.- Type Parameters:
T
-- Parameters:
values
- the array to iterate over.from
- the index to start iterating at.to
- the index to finish iterating at.- Returns:
-
filterIterator
public static <T> java.util.Iterator<T> filterIterator(java.util.Iterator<? extends T> iterator, Predicate<? super T> predicate)
Returns an iterator with elements from an originaliterator
where the givenpredicate
matches removed.- Type Parameters:
T
-- Parameters:
iterator
-predicate
-- Returns:
-
transformIterator
public static <T,R,S extends T> java.util.Iterator<R> transformIterator(java.util.Iterator<? extends T> iterator, Transformer<S,? super R> transformer)
Returns an iterator with elements of an originaliterator
transformed by atransformer
.- Type Parameters:
T
-R
-S
-- Parameters:
iterator
-transformer
-- Returns:
-
properties
public static java.util.Iterator<Property> properties(PropertyIterator propertyIterator)
Returns an iterator ofProperty
from aPropertyIterator
.- Parameters:
propertyIterator
-- Returns:
-
nodes
public static java.util.Iterator<Node> nodes(NodeIterator nodeIterator)
Returns an iterator ofNode
from aNodeIterator
.- Parameters:
nodeIterator
-- Returns:
-
-