public interface DocumentRecord
Each DocumentRecord represents one document, its uri, format, mime-type and possibly its metadata (collections, properties, quality, and permissions). Whether metadata is included depends on whether it was requested in the call sent to the server. For example, to request collections metadata:
JSONDocumentManager docMgr = databaseClient.newJSONDocumentManager();
docMgr.setNonDocumentFormat(Format.XML);
docMgr.setMetadataCategories(Metadata.COLLECTIONS);
DocumentPage documents = docMgr.read("doc1.json", "doc2.json");
try {
for ( DocumentRecord record : documents ) {
String uri = record.getUri();
JacksonHandle content = record.getContent(new JacksonHandle());
DocumentMetadataHandle metadata = record.getMetadata(new DocumentMetadataHandle());
DocumentCollections collections = metadata.getCollections();
// ... do something ...
} } finally { documents.close(); } | Modifier and Type | Method and Description |
|---|---|
<T extends AbstractReadHandle> |
getContent(T contentHandle)
Given a handle, populates the handle with the document contents directly from the server (or the transformed contents if a ServerTransform was used).
|
<T> T |
getContentAs(Class<T> as)
Reads the document content from the multipart response into the representation specified by the IO class.
|
Format |
getFormat()
Returns the format of the document in the server
|
<T extends DocumentMetadataReadHandle> |
getMetadata(T metadataHandle)
Given a handle, populates the handle with the structured metadata directly from the REST API.
|
<T> T |
getMetadataAs(Class<T> as)
Reads the metadata from the multipart response into the representation specified by the IO class.
|
String |
getMimetype()
Returns the mime-type (“Content-Type” header) of the document as specified by the server (uses the server’s mime-type mapping for file extensions)
|
String |
getUri()
Returns the uri (unique identifier) of the document in the server
|
String getUri()
Returns the uri (unique identifier) of the document in the server
Format getFormat()
Returns the format of the document in the server
String getMimetype()
Returns the mime-type (“Content-Type” header) of the document as specified by the server (uses the server’s mime-type mapping for file extensions)
<T extends DocumentMetadataReadHandle> T getMetadata(T metadataHandle)
Given a handle, populates the handle with the structured metadata directly from the REST API. Depending on the nonDocumentFormat set on the DocumentManager, this will be XML or JSON format. If the nonDocumentFormat is XML, you can use DocumentMetadataHandle which offers convenient metadata access methods.
T - the type of DocumentMetadataReadHandle to returnmetadataHandle - the handle to populate with the metadata<T> T getMetadataAs(Class<T> as)
Reads the metadata from the multipart response into the representation specified by the IO class.
The IO class must have been registered before creating the database client. By default, the provided handles that implement ContentHandle are registered.
T - the type of object that will be returned by the handle registered for itas - the Class which a handle should instantiate, populate and return<T extends AbstractReadHandle> T getContent(T contentHandle)
Given a handle, populates the handle with the document contents directly from the server (or the transformed contents if a ServerTransform was used). Use a handle that is appropriate for the format of this document.
T - the type of AbstractReadHandle to returncontentHandle - the handle to populate with the contents<T> T getContentAs(Class<T> as)
Reads the document content from the multipart response into the representation specified by the IO class.
The IO class must have been registered before creating the database client. By default, the provided handles that implement ContentHandle are registered.
T - the type of object that will be returned by the handle registered for itas - the Class which a handle should instantiate, populate and returnCopyright © 2013-2017 MarkLogic Corporation.