Skip to content

Commit 12892e7

Browse files
committed
add javadocs
1 parent 743688a commit 12892e7

File tree

3 files changed

+118
-1
lines changed

3 files changed

+118
-1
lines changed

src/main/java/com/marklogic/client/document/DocumentRecord.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,49 @@
1919
import com.marklogic.client.io.marker.AbstractReadHandle;
2020
import com.marklogic.client.io.marker.DocumentMetadataReadHandle;
2121

22+
/** Each DocumentRecord represents one document, its uri, format, mime-type
23+
* and possibly its metadata (collections, properties, quality, and permissions).
24+
* Whether metadata is included depends on whether it was requested in the call
25+
* sent to the server. For example, to request collections metadata:
26+
* <pre>{@code
27+
*JSONDocumentManager docMgr = databaseClient.newJSONDocumentManager();
28+
*docMgr.setNonDocumentFormat(Format.XML);
29+
*docMgr.setMetadataCategories(Metadata.COLLECTIONS);
30+
*DocumentPage documents = docMgr.read("doc1.json", "doc2.json");
31+
*for ( DocumentRecord record : documents ) {
32+
* String uri = record.getUri();
33+
* JacksonHandle content = record.getContent(new JacksonHandle());
34+
* DocumentMetadataHandle metadata = record.getMetadata(new DocumentMetadataHandle());
35+
* DocumentCollections collections = metadata.getCollections();
36+
* // ... do something ...
37+
*}
38+
* }</pre>
39+
*/
2240
public interface DocumentRecord {
41+
/** Returns the uri (unique identifier) of the document in the server */
2342
public String getUri();
2443

44+
/** Returns the format of the document in the server */
2545
public Format getFormat();
2646

47+
/** Returns the mime-type ("Content-Type" header) of the document as specified by
48+
* the server (uses the server's mime-type mapping for file extensions) */
2749
public String getMimetype();
2850

51+
/**
52+
* Given a handle, populates the handle with the structured metadata directly from
53+
* the REST API. Depending on the nonDocumentFormat set on the DocumentManager,
54+
* this will be XML or JSON format. If the nonDocumentFormat is XML, you can use
55+
* DocumentMetadataHandle which offers convenient metadata access methods.
56+
* @see <a href="http://docs.marklogic.com/guide/rest-dev/documents#id_63117">
57+
* REST API Dev Guide -&gt; Working with Metadata</a>
58+
*/
2959
public <T extends DocumentMetadataReadHandle> T getMetadata(T metadataHandle);
60+
61+
/**
62+
* Given a handle, populates the handle with the document contents directly from
63+
* the server (or the transformed contents if a ServerTransform was used). Use
64+
* a handle that is appropriate for the {@link #getFormat format} of this document.
65+
*/
3066
public <T extends AbstractReadHandle> T getContent(T contentHandle);
3167
}

src/main/java/com/marklogic/client/document/DocumentWriteOperation.java

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,60 @@
1818
import com.marklogic.client.io.marker.AbstractWriteHandle;
1919
import com.marklogic.client.io.marker.DocumentMetadataWriteHandle;
2020

21+
/** A reflection of the write operations queued by calls to add,
22+
* {@link DocumentWriteSet#add add}, {@link DocumentWriteSet#addDefault addDefault}, or
23+
* {@link DocumentWriteSet#disableDefault disableDefault}.
24+
*/
2125
public interface DocumentWriteOperation {
22-
public enum OperationType { METADATA_DEFAULT, DISABLE_METADATA_DEFAULT, DOCUMENT_WRITE };
26+
public enum OperationType {
27+
/** This write operation (REST API mime part) sets the defaults for the
28+
* rest of the request.
29+
* @see <a href="http://docs.marklogic.com/guide/rest-dev/bulk#id_56498">
30+
* REST API Guide -&gt; Constructing a Metadata Part</a>
31+
*/
32+
METADATA_DEFAULT,
33+
/** This write operation (REST API mime part) clears the defaults for the
34+
* rest of the request. While this removes defaults set previously on the
35+
* request, this does not completely restore server-side defaults. For
36+
* more information see the
37+
* <a href="http://docs.marklogic.com/guide/rest-dev/bulk#id_54554">
38+
* REST API Guide -&gt; Example: Reverting to System Default Metadata</a>
39+
*/
40+
DISABLE_METADATA_DEFAULT,
41+
/** This write operation (REST API mime part) creates or overwrites
42+
* one document and/or document metadata.
43+
* @see <a href="http://docs.marklogic.com/guide/rest-dev/bulk#id_33756">
44+
* REST API Guide -&gt; Constructing a Content Part</a>
45+
* @see <a href="http://docs.marklogic.com/guide/rest-dev/bulk#id_56498">
46+
* REST API Guide -&gt; Constructing a Metadata Part</a>
47+
* @see <a href="http://docs.marklogic.com/guide/rest-dev/bulk#id_89876">
48+
* REST API Guide -&gt; Understanding When Metadata is Preserved or Replaced</a>
49+
*/
50+
DOCUMENT_WRITE
51+
};
2352

53+
/** Returns the {@link DocumentWriteOperation.OperationType} set implicitly by your call to
54+
* {@link DocumentWriteSet#add add}, {@link DocumentWriteSet#addDefault addDefault}, or
55+
* {@link DocumentWriteSet#disableDefault disableDefault}.
56+
*/
2457
public OperationType getOperationType();
2558

59+
// The uri for this document, whether set explicitly or received from the
60+
// server after a write with a DocumentDescriptor.
61+
/** The uri for this document if set explicitly by your call to
62+
* {@link DocumentWriteSet#add(String, AbstractWriteHandle) add(String, ...)}
63+
*/
2664
public String getUri();
2765

66+
/** The handle with the metadata as set by your call to
67+
* {@link DocumentWriteSet#add(String, DocumentMetadataWriteHandle, AbstractWriteHandle) add} or
68+
* {@link DocumentWriteSet#add(DocumentDescriptor, DocumentMetadataWriteHandle, AbstractWriteHandle) add}.
69+
*/
2870
public DocumentMetadataWriteHandle getMetadata();
2971

72+
/** The handle with the content as set by your call to
73+
* {@link DocumentWriteSet#add(String, AbstractWriteHandle) add} or
74+
* {@link DocumentWriteSet#add(DocumentDescriptor, AbstractWriteHandle) add}.
75+
*/
3076
public AbstractWriteHandle getContent();
3177
}

src/main/java/com/marklogic/client/document/DocumentWriteSet.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,52 @@
2020

2121
import java.util.Set;
2222

23+
/**
24+
* Builds a set of {@link DocumentWriteOperation DocumentWriteOperations} to be sent
25+
* to the server through the REST API as a bulk write request.
26+
* @see DocumentManager#write(DocumentWriteSet)
27+
* @see <a href="http://docs.marklogic.com/guide/rest-dev/bulk#id_54649">
28+
* REST API Guide -&gt; Writing Multiple Documents</a>
29+
*/
2330
public interface DocumentWriteSet extends Set<DocumentWriteOperation> {
31+
/** Sets the default metadata for this write set for all documents added after this call */
2432
public DocumentWriteSet addDefault(DocumentMetadataWriteHandle metadataHandle);
2533

34+
/** Removes the default metadata for this write set for all documents added after this call */
2635
public DocumentWriteSet disableDefault();
2736

37+
/**
38+
* Adds to this write set a document with the given docId (server uri)
39+
* and contents provided by the handle
40+
* @param docId the URI identifier for the document
41+
* @param contentHandle a handle for writing the content of the document
42+
*/
2843
public DocumentWriteSet add(String docId, AbstractWriteHandle contentHandle);
2944

45+
/**
46+
* Adds to this write set a document with the given docId (server uri),
47+
* metadata, and contents provided by the handle
48+
* @param docId the URI identifier for the document
49+
* @param metadataHandle a handle for writing the metadata of the document
50+
* @param contentHandle a handle for writing the content of the document
51+
*/
3052
public DocumentWriteSet add(String docId, DocumentMetadataWriteHandle metadataHandle, AbstractWriteHandle contentHandle);
3153

54+
/**
55+
* Adds to this write set a document with the given uri template, and
56+
* contents provided by the handle
57+
* @param desc a descriptor for the URI identifier, format, and mimetype of the document
58+
* @param contentHandle a handle for writing the content of the document
59+
*/
3260
public DocumentWriteSet add(DocumentDescriptor desc, AbstractWriteHandle contentHandle);
3361

62+
/**
63+
* Adds to this write set a document with the given uri template, metadata,
64+
* and contents provided by the handle
65+
* @param desc a descriptor for the URI identifier, format, and mimetype of the document
66+
* @param metadataHandle a handle for writing the metadata of the document
67+
* @param contentHandle a handle for writing the content of the document
68+
*/
3469
public DocumentWriteSet add(DocumentDescriptor desc, DocumentMetadataWriteHandle metadataHandle, AbstractWriteHandle contentHandle);
3570
}
3671

0 commit comments

Comments
 (0)