Collecting all documents and all unprocessed documents using Java™
Use getAllDocuments of Database to get a DocumentCollection object that contains all the data documents in a database. Use getUnprocessedDocuments in AgentContext to get documents that depend on the specifications of the current agent, for example, those documents that are selected or those documents modified since the agent last ran. Use getModifiedDocuments in Database to get documents modified since a specified time.
The DocumentCollection class has the following properties and methods for accessing documents:
- getFirstDocument and getNextDocument, which can be used to get the first and next document in a loop until the next document is null.
- getLastDocument and getPrevDocument, which can be used to get the last and previous document in a loop until the previous document is null.
- getCount to get the number of documents in the collection, and getNthDocument, which can be used to get a particular document in the sequence.
- getDocument locates a specified document in the current document collection.
In loops, use the getNextDocument and getPrevDocument methods that do not take a parameter. These methods provide better performance than the methods that take a Document parameter; in particular, the methods that take a parameter invalidate the cache for remote (IIOP) operations. Do not use getCount and getNthDocument for loops for performance reasons.
The documents in a document collection are ordered only if the collection is the result of a search. Otherwise, you cannot depend on the documents to be a particular sequence.
Use addDocument and deleteDocument to adjust a DocumentCollection object after you create it.
When you use an agent to work on unprocessed documents, you must mark those documents as updated so that they are recognized as old documents in subsequent runs. Use either updateAll of NotesDocumentCollection or updateProcessedDoc of AgentContext.
The DocumentCollection class contains the following properties:
- getCount returns an int value containing the number of documents in the collection.
- isSorted returns true if the document collection is sorted.
- getParent returns a Database object representing the database that contains the collection.
- getQuery returns a String value that contains the text of the query that created the collection.
- getUntilTime returns
a DateTime object representing the database end time for a collection
made through getModifiedDocuments in
Database.