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
LazyItemIteratoris an id-based iterator that instantiates theItems only when they are requested.Important:
Items 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 newLazyItemIteratorinstance.LazyItemIterator(ItemManager itemMgr, HierarchyManager hierarchyMgr, Iterator<? extends ItemId> itemIds)Creates a newLazyItemIteratorinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetPosition()longgetSize()Returns the number ofItems in this iterator or -1 if the size is unknown.booleanhasNext()Objectnext()NodenextNode()PropertynextProperty()VersionnextVersion()voidremove()voidskip(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 newLazyItemIteratorinstance.- Parameters:
itemMgr- item managerhierarchyEntryIterator- Iterator over HierarchyEntries
-
LazyItemIterator
public LazyItemIterator(ItemManager itemMgr, HierarchyManager hierarchyMgr, Iterator<? extends ItemId> itemIds) throws ItemNotFoundException, RepositoryException
Creates a newLazyItemIteratorinstance.- Parameters:
itemMgr-hierarchyMgr-itemIds-- Throws:
ItemNotFoundExceptionRepositoryException
-
-
Method Detail
-
nextNode
public Node nextNode()
- Specified by:
nextNodein interfaceNodeIterator- See Also:
NodeIterator.nextNode()
-
nextProperty
public Property nextProperty()
- Specified by:
nextPropertyin interfacePropertyIterator- See Also:
PropertyIterator.nextProperty()
-
nextVersion
public Version nextVersion()
- Specified by:
nextVersionin interfaceVersionIterator- See Also:
VersionIterator.nextVersion()
-
getPosition
public long getPosition()
- Specified by:
getPositionin interfaceRangeIterator- See Also:
RangeIterator.getPosition()
-
getSize
public long getSize()
Returns the number ofItems in this iterator or -1 if the size is unknown.Note: The number returned by this method may differ from the number of
Items 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 invalidItemis detected, the size of this iterator is adjusted.- Specified by:
getSizein interfaceRangeIterator- Returns:
- the number of
Items in this iterator. - See Also:
RangeIterator.getSize()
-
skip
public void skip(long skipNum)
- Specified by:
skipin interfaceRangeIterator- See Also:
RangeIterator.skip(long)
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfaceIterator- See Also:
Iterator.hasNext()
-
next
public Object next()
- Specified by:
nextin interfaceIterator- See Also:
Iterator.next()
-
remove
public void remove()
- Specified by:
removein interfaceIterator- Throws:
UnsupportedOperationException- always since removal is not implemented.- See Also:
Iterator.remove()
-
-