org.apache.jackrabbit.jcr2spi
Class LazyItemIterator

java.lang.Object
  extended by 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 the Items 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 by getSize() always returns -1.


Constructor Summary
LazyItemIterator(ItemManager itemMgr, HierarchyManager hierarchyMgr, Iterator<? extends ItemId> itemIds)
          Creates a new LazyItemIterator instance.
LazyItemIterator(ItemManager itemMgr, Iterator<? extends HierarchyEntry> hierarchyEntryIterator)
          Creates a new LazyItemIterator instance.
 
Method Summary
 long getPosition()
          
 long getSize()
          Returns the number of Items 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
 

Constructor Detail

LazyItemIterator

public LazyItemIterator(ItemManager itemMgr,
                        Iterator<? extends HierarchyEntry> hierarchyEntryIterator)
Creates a new LazyItemIterator instance.

Parameters:
itemMgr - item manager
hierarchyEntryIterator - Iterator over HierarchyEntries

LazyItemIterator

public LazyItemIterator(ItemManager itemMgr,
                        HierarchyManager hierarchyMgr,
                        Iterator<? extends ItemId> itemIds)
                 throws ItemNotFoundException,
                        RepositoryException
Creates a new LazyItemIterator instance.

Parameters:
itemMgr -
hierarchyMgr -
itemIds -
Throws:
ItemNotFoundException
RepositoryException
Method Detail

nextNode

public Node nextNode()

Specified by:
nextNode in interface NodeIterator
See Also:
NodeIterator.nextNode()

nextProperty

public Property nextProperty()

Specified by:
nextProperty in interface PropertyIterator
See Also:
PropertyIterator.nextProperty()

nextVersion

public Version nextVersion()

Specified by:
nextVersion in interface VersionIterator
See Also:
VersionIterator.nextVersion()

getPosition

public long getPosition()

Specified by:
getPosition in interface RangeIterator
See Also:
RangeIterator.getPosition()

getSize

public long getSize()
Returns the number of Items 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 invalid Item is detected, the size of this iterator is adjusted.

Specified by:
getSize in interface RangeIterator
Returns:
the number of Items in this iterator.
See Also:
RangeIterator.getSize()

skip

public void skip(long skipNum)

Specified by:
skip in interface RangeIterator
See Also:
RangeIterator.skip(long)

hasNext

public boolean hasNext()

Specified by:
hasNext in interface Iterator
See Also:
Iterator.hasNext()

next

public Object next()

Specified by:
next in interface Iterator
See Also:
Iterator.next()

remove

public void remove()

Specified by:
remove in interface Iterator
Throws:
UnsupportedOperationException - always since removal is not implemented.
See Also:
Iterator.remove()


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.