Package org.apache.jackrabbit.jcr2spi
Class LazyItemIterator
- java.lang.Object
-
- org.apache.jackrabbit.jcr2spi.LazyItemIterator
-
- All Implemented Interfaces:
Iterator
,NodeIterator
,PropertyIterator
,RangeIterator
,VersionIterator
public class LazyItemIterator extends Object implements NodeIterator, PropertyIterator, VersionIterator
LazyItemIterator
is an id-based iterator that instantiates theItem
s only when they are requested.Important:
Item
s that appear to be nonexistent for some reason (e.g. because of insufficient access rights or because they have been removed since the iterator has been retrieved) are silently skipped. As a result the size of the iterator as reported bygetSize()
always returns -1.
-
-
Constructor Summary
Constructors Constructor Description LazyItemIterator(ItemManager itemMgr, Iterator<? extends HierarchyEntry> hierarchyEntryIterator)
Creates a newLazyItemIterator
instance.LazyItemIterator(ItemManager itemMgr, HierarchyManager hierarchyMgr, Iterator<? extends ItemId> itemIds)
Creates a newLazyItemIterator
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getPosition()
long
getSize()
Returns the number ofItem
s in this iterator or -1 if the size is unknown.boolean
hasNext()
Object
next()
Node
nextNode()
Property
nextProperty()
Version
nextVersion()
void
remove()
void
skip(long skipNum)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
LazyItemIterator
public LazyItemIterator(ItemManager itemMgr, Iterator<? extends HierarchyEntry> hierarchyEntryIterator)
Creates a newLazyItemIterator
instance.- Parameters:
itemMgr
- item managerhierarchyEntryIterator
- Iterator over HierarchyEntries
-
LazyItemIterator
public LazyItemIterator(ItemManager itemMgr, HierarchyManager hierarchyMgr, Iterator<? extends ItemId> itemIds) throws ItemNotFoundException, RepositoryException
Creates a newLazyItemIterator
instance.- Parameters:
itemMgr
-hierarchyMgr
-itemIds
-- Throws:
ItemNotFoundException
RepositoryException
-
-
Method Detail
-
nextNode
public Node nextNode()
- Specified by:
nextNode
in interfaceNodeIterator
- See Also:
NodeIterator.nextNode()
-
nextProperty
public Property nextProperty()
- Specified by:
nextProperty
in interfacePropertyIterator
- See Also:
PropertyIterator.nextProperty()
-
nextVersion
public Version nextVersion()
- Specified by:
nextVersion
in interfaceVersionIterator
- See Also:
VersionIterator.nextVersion()
-
getPosition
public long getPosition()
- Specified by:
getPosition
in interfaceRangeIterator
- See Also:
RangeIterator.getPosition()
-
getSize
public long getSize()
Returns the number ofItem
s in this iterator or -1 if the size is unknown.Note: The number returned by this method may differ from the number of
Item
s actually returned by calls to hasNext() / getNextNode(). This is caused by the lazy instantiation behaviour of this iterator, that may detect only upon iteration that an Item has been invalidated or removed in the mean time. As soon as an invalidItem
is detected, the size of this iterator is adjusted.- Specified by:
getSize
in interfaceRangeIterator
- Returns:
- the number of
Item
s in this iterator. - See Also:
RangeIterator.getSize()
-
skip
public void skip(long skipNum)
- Specified by:
skip
in interfaceRangeIterator
- See Also:
RangeIterator.skip(long)
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfaceIterator
- See Also:
Iterator.hasNext()
-
next
public Object next()
- Specified by:
next
in interfaceIterator
- See Also:
Iterator.next()
-
remove
public void remove()
- Specified by:
remove
in interfaceIterator
- Throws:
UnsupportedOperationException
- always since removal is not implemented.- See Also:
Iterator.remove()
-
-