getNextDocument (DocumentCollection - Java™)
Gets the document immediately following the current document or a specified document in a collection.
Defined in
Syntax
public Document getNextDocument()
throws NotesException
public Document getNextDocument(Document doc)
throws NotesException
Parameters
Document doc
Any document in the collection. Cannot be null.
Return value
Document
If no parameter, the document following the current document. If a parameter, the document following the specified document. If there is no next document, returns null.
Usage
In remote (IIOP) operations, getNextDocument(Document doc) invalidates the cache and is therefore discouraged.
The preferred loop structure is getFirstDocument() followed by getNextDocument() until it returns null. For performance reasons, you should avoid using getNthDocument(int n) in a loop.
In loops you should recycle the Document object on each iteration. Use a temporary Document object to save and restore the object.
When processing documents in a loop, do not delete the document, or modify it in a way that causes it to disappear from the view or for its position to change. In that situation, GetNextDocument method may not return a useful result because the document that was the next document, is now at a different position in the view. The most common symptom of this problem is that documents are skipped when you loop through them.
To address this issue, change your logic so that you call GetNextDocument before making any change to the document. Or, use NotesView.AutoUpdate (= False) to prevent re-indexing of the view while you're using it.