Package org.nuxeo.ecm.core.api
Class DocumentTreeIterator
- java.lang.Object
-
- org.nuxeo.ecm.core.api.DocumentTreeIterator
-
- All Implemented Interfaces:
Iterator<DocumentModel>
public class DocumentTreeIterator extends Object implements Iterator<DocumentModel>
An iterator over a tree of documentsThe tree is traversed from top to bottom and left to right.
TODO: move this in an utility package
- Author:
- Bogdan Stefanescu
-
-
Field Summary
Fields Modifier and Type Field Description protected Queue<Iterator<DocumentModel>>
queue
The sequence queue.protected DocumentModel
root
Root document.protected Iterator<DocumentModel>
sequence
The current sequence.protected CoreSession
session
The document manager session.
-
Constructor Summary
Constructors Constructor Description DocumentTreeIterator(CoreSession session, DocumentModel root)
Creates the iterator given the tree root.DocumentTreeIterator(CoreSession session, DocumentModel root, boolean excludeRoot)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Iterator<DocumentModel>
getNextNonEmptySequence()
Gets next non empty sequence from queue.boolean
hasNext()
DocumentModel
next()
void
remove()
void
reset()
Resets the iterator back to the tree root and clear any cached data.-
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
-
-
-
-
Field Detail
-
session
protected final CoreSession session
The document manager session.
-
root
protected final DocumentModel root
Root document.
-
sequence
protected Iterator<DocumentModel> sequence
The current sequence.
-
queue
protected final Queue<Iterator<DocumentModel>> queue
The sequence queue.
-
-
Constructor Detail
-
DocumentTreeIterator
public DocumentTreeIterator(CoreSession session, DocumentModel root)
Creates the iterator given the tree root.
-
DocumentTreeIterator
public DocumentTreeIterator(CoreSession session, DocumentModel root, boolean excludeRoot)
-
-
Method Detail
-
getNextNonEmptySequence
protected Iterator<DocumentModel> getNextNonEmptySequence()
Gets next non empty sequence from queue.This will remove from the queue all traversed sequences (the empty ones and the first not empty sequence found).
- Returns:
- the first non empty sequence or null if no one was found
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfaceIterator<DocumentModel>
-
next
public DocumentModel next()
- Specified by:
next
in interfaceIterator<DocumentModel>
-
remove
public void remove()
- Specified by:
remove
in interfaceIterator<DocumentModel>
-
reset
public void reset()
Resets the iterator back to the tree root and clear any cached data.
-
-