Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit fbf1895

Browse files
authored
Merge pull request #509 from cloudant/javadoc-v2-fixes
Fixes to javadoc during v2 review
2 parents b43132d + 0119916 commit fbf1895

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+178
-128
lines changed

cloudant-sync-datastore-android-encryption/src/main/java/com/cloudant/sync/datastore/encryption/AndroidKeyProvider.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
/**
2525
* This class implements the interface {@link KeyProvider} and it can be used to create an
26-
* encrypted datastore.
26+
* encrypted DocumentStore.
2727
*
2828
* Given an user-provided password and an identifier, it generates a strong key and store it safely
2929
* in the application's {@link android.content.SharedPreferences}, so the same key can be retrieved
@@ -32,7 +32,7 @@
3232
* The password is used to protect the key before saving it to the {@link android.content
3333
* .SharedPreferences}. The identifier is an
3434
* easy way to have more than one encryption key in the same app, the only condition is to provide
35-
* different ids for each of them.
35+
* different IDs for each of them.
3636
*
3737
* @see KeyProvider
3838
* @see KeyManager

cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/Attachment.java

+7
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ public enum Encoding {
8989
Gzip
9090
}
9191

92+
/**
93+
* <p>
94+
* Returns the {@link #encoding} encoding using the string in the attachment's JSON metadata.
95+
* </p>
96+
* @param encodingString the string containing the attachment's {@link #encoding} encoding.
97+
* @return the attachment's {@link #encoding} encoding.
98+
*/
9299
public static Encoding getEncodingFromString(String encodingString){
93100
if(encodingString == null || encodingString.isEmpty() || encodingString.equalsIgnoreCase("Plain")){
94101
return Encoding.Plain;

cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/Changes.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public interface Changes {
2222
* <p>This number isn't necessarily the same as the sequence number of the
2323
* last {@code DocumentRevision} in the list of changes.</p>
2424
*
25-
* @return last sequence number of the changes set
25+
* @return last sequence number of the changes set.
2626
*/
2727
long getLastSequence();
2828

cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/ConflictResolver.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public interface ConflictResolver {
4545
* @param docId ID of the {@link DocumentRevision} with conflicts
4646
* @param conflicts list of conflicted {@link DocumentRevision}s, including
4747
* current winner
48-
* @return resolved {@link DocumentRevision}
48+
* @return the resolved {@link DocumentRevision}.
4949
*
5050
* @see Database#resolveConflicts(String, ConflictResolver)
5151
*/

cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/Database.java

+19-19
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* relational model. The Database exposes a simple key-value model where the key
3535
* is the document ID combined with a (sometimes optional) revision ID.</p>
3636
*
37-
* <p>For a more advanced way of querying the Datastore, see the
37+
* <p>For a more advanced way of querying the DocumentStore, see the
3838
* {@link Query} class</p>
3939
*
4040
* <p>Each document consists of a set of revisions, hence most methods within
@@ -91,7 +91,7 @@ DocumentRevision read(String documentId) throws DocumentNotFoundException,
9191
* <p>Retrieves a given revision of a document.</p>
9292
*
9393
* <p>This method gets the revision of a document with a given ID. As the
94-
* datastore prunes the content of old revisions to conserve space, this
94+
* DocumentStore prunes the content of old revisions to conserve space, this
9595
* revision may contain the metadata but not content of the revision.</p>
9696
*
9797
* <p>Previously deleted documents can be retrieved
@@ -108,35 +108,35 @@ DocumentRevision read(String documentId, String revisionId) throws
108108
DocumentNotFoundException, DocumentStoreException;
109109

110110
/**
111-
* <p>Returns whether this datastore contains a particular revision of
111+
* <p>Returns whether this DocumentStore contains a particular revision of
112112
* a document.</p>
113113
*
114114
* <p>{@code true} will still be returned if the document is deleted.</p>
115115
*
116116
* @param documentId ID of the document
117117
* @param revisionId revision of the document
118118
* @return {@code true} if specified document's particular revision exists
119-
* in the datastore, {@code false} otherwise.
119+
* in the DocumentStore, {@code false} otherwise.
120120
* @throws DocumentStoreException if there was an error reading from the database
121121
*/
122122
boolean contains(String documentId, String revisionId) throws DocumentStoreException;
123123

124124
/**
125-
* <p>Returns whether this datastore contains any revisions of a document.
125+
* <p>Returns whether this DocumentStore contains any revisions of a document.
126126
* </p>
127127
*
128128
* <p>{@code true} will still be returned if the document is deleted.</p>
129129
*
130130
* @param documentId ID of the document
131131
* @return {@code true} if specified document exists
132-
* in the datastore, {@code false} otherwise.
132+
* in the DocumentStore, {@code false} otherwise.
133133
* @throws DocumentStoreException if there was an error reading from the database
134134
*/
135135
boolean contains(String documentId) throws DocumentStoreException;
136136

137137
/**
138138
* <p>Enumerates the current winning revision for all documents in the
139-
* datastore.</p>
139+
* DocumentStore.</p>
140140
*
141141
* <p>Logically, this method takes all the documents sorted by internal ID,
142142
* in either ascending
@@ -155,7 +155,7 @@ DocumentRevision read(String documentId, String revisionId) throws
155155

156156
/**
157157
* <p>Enumerates the current winning revision for all documents in the
158-
* datastore and return a list of their document IDs.</p>
158+
* DocumentStore and return a list of their document IDs.</p>
159159
*
160160
* @return list of document IDs
161161
* @throws DocumentStoreException if there was an error reading from the database
@@ -166,7 +166,7 @@ DocumentRevision read(String documentId, String revisionId) throws
166166
* <p>Returns the current winning revisions for a set of documents.</p>
167167
*
168168
* <p>If the {@code documentIds} list contains document IDs not present
169-
* in the datastore, they will be skipped and there will be no entry for
169+
* in the DocumentStore, they will be skipped and there will be no entry for
170170
* them in the returned list.</p>
171171
*
172172
* @param documentIds list of document IDs.
@@ -180,7 +180,7 @@ DocumentRevision read(String documentId, String revisionId) throws
180180
*
181181
* <p>The sequence number is incremented every time the
182182
* content of the Database is changed. Each document revision within the
183-
* datastore has an associated sequence number, describing when the change
183+
* DocumentStore has an associated sequence number, describing when the change
184184
* took place.</p>
185185
*
186186
* <p>The sequence number is particularly useful to find out the changes
@@ -194,9 +194,9 @@ DocumentRevision read(String documentId, String revisionId) throws
194194
long getLastSequence() throws DocumentStoreException;
195195

196196
/**
197-
* <p>Return the number of documents in the datastore</p>
197+
* <p>Return the number of documents in the DocumentStore</p>
198198
*
199-
* @return number of non-deleted documents in datastore
199+
* @return number of non-deleted documents in DocumentStore
200200
* @throws DocumentStoreException if there was an error reading from the database.
201201
*/
202202
int getDocumentCount() throws DocumentStoreException;
@@ -216,15 +216,15 @@ DocumentRevision read(String documentId, String revisionId) throws
216216
Changes changes(long since, int limit) throws DocumentStoreException;
217217

218218
/**
219-
* <p>Return {@code @Iterable<String>} over ids to all the Documents with
219+
* <p>Return {@code @Iterable<String>} over IDs to all the Documents with
220220
* conflicted revisions.</p>
221221
*
222222
* <p>Document is modeled as a tree. If a document has at least two leaf
223223
* revisions that not deleted, those leaf revisions considered
224224
* conflicted revisions of the document.
225225
* </p>
226226
*
227-
* @return Iterable of String over ids of all Documents with
227+
* @return Iterable of String over IDs of all Documents with
228228
* conflicted revisions
229229
*
230230
* @see <a target="_blank" href="http://wiki.apache.org/couchdb/Replication_and_conflicts">Replication and conflicts</a>
@@ -234,8 +234,8 @@ DocumentRevision read(String documentId, String revisionId) throws
234234

235235
/**
236236
* <p>
237-
* Resolve conflicts for specified Document using the
238-
* given {@code ConflictResolver}
237+
* Resolve conflicts for a specified Document using the
238+
* given {@code ConflictResolver}.
239239
* </p>
240240
*
241241
* @param docId ID of Document to resolve conflicts
@@ -274,7 +274,7 @@ DocumentRevision create(DocumentRevision rev) throws AttachmentException,
274274
InvalidDocumentException, ConflictException, DocumentStoreException;
275275

276276
/**
277-
* <p>Updates a document that exists in the datastore with with body and attachments
277+
* <p>Updates a document that exists in the DocumentStore with with body and attachments
278278
* from <code>rev</code>.
279279
* </p>
280280
*
@@ -296,7 +296,7 @@ DocumentRevision update(DocumentRevision rev) throws ConflictException,
296296
AttachmentException, DocumentStoreException, DocumentNotFoundException;
297297

298298
/**
299-
* <p>Deletes a document from the datastore.</p>
299+
* <p>Deletes a document from the DocumentStore.</p>
300300
*
301301
* <p>This operation leaves a "tombstone" for the deleted document, so that
302302
* future replication operations can successfully replicate the deletion.
@@ -347,7 +347,7 @@ DocumentRevision delete(DocumentRevision rev) throws ConflictException, Document
347347
void compact() throws DocumentStoreException;
348348

349349
/**
350-
* <p>Returns the EventBus which this Datastore posts
350+
* <p>Returns the EventBus which this DocumentStore posts
351351
* {@link com.cloudant.sync.event.notifications.DocumentModified Document Notification Events} to.</p>
352352
* @return the EventBus
353353
*

cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/DocumentRevision.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323

2424

2525
/**
26-
* <p>A single revision of a document within a datastore.</p>
26+
* <p>A single revision of a document within a DocumentStore.</p>
2727
*
28-
* <p>Documents within the datastore are in fact trees of document revisions,
28+
* <p>Documents within the DocumentStore are in fact trees of document revisions,
2929
* with one document marked as the current winner at any point. Branches in
3030
* the tree are caused when a document is edited in more than one place before
31-
* being replicated between datastores. The consuming application is responsible
31+
* being replicated between DocumentStores. The consuming application is responsible
3232
* for finding active branches (also called conflicts), and marking the leaf
3333
* nodes of all branches but one deleted (thereby resolving the conflict).</p>
3434
*
@@ -66,7 +66,7 @@ public class DocumentRevision {
6666
protected DocumentBody body;
6767

6868
public DocumentRevision() {
69-
// BasicDatastore#create will assign an ID
69+
// DatabaseImpl#create will assign an ID
7070
this(null);
7171
}
7272

@@ -155,7 +155,7 @@ public boolean isFullRevision(){
155155
* {@link QueryImpl#find(Map, long, long, List, List)} using the
156156
* {@code fields} option to limit the fields returned, a revision will be missing data so it
157157
* cannot be regarded as a full revision. If the document is a full revision, this method will
158-
* only attempt to load the full revision from the datastore if {@link InternalDocumentRevision#isFullRevision()}
158+
* only attempt to load the full revision from the DocumentStore if {@link InternalDocumentRevision#isFullRevision()}
159159
* returns false.
160160
*
161161
* @return A "Full" document revision.

cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/DocumentStore.java

+24-8
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@
5757
* </p>
5858
*
5959
* <p>
60-
* In most cases, users are advised to open store instances and use them for the entire lifetime of
61-
* their application. This is more efficient than opening and closing instances for the same
62-
* underlying file system location multiple times throughout the lifetime of the application.
60+
* In most cases, users are advised to obtain a single store instance via
61+
* {@link DocumentStore#getInstance} and use it for the entire lifetime of their application.
62+
* This is more efficient than opening and closing instances for the same underlying file system
63+
* location multiple times throughout the lifetime of the application.
6364
* Users should call {@link #close()} after using a store to shut down in an orderly manner and free
6465
* up resources.
6566
* </p>
@@ -74,7 +75,7 @@ public class DocumentStore {
7475
private final File location; // needed for close/delete
7576
private final File extensionsLocation; // for extensions: currently attachments and indexes
7677

77-
/* This map should only be accessed inside synchronized(openDatastores) blocks */
78+
/* This map should only be accessed inside synchronized(documentStores) blocks */
7879
private static final Map<File, DocumentStore> documentStores = new HashMap<File, DocumentStore>();
7980

8081
private static EventBus eventBus = new EventBus();
@@ -215,6 +216,13 @@ public Query query() {
215216
return query;
216217
}
217218

219+
/**
220+
* <p>
221+
* Closes the DocumentStore instance.
222+
* If multiple references are held to the {@link DocumentStore} instance, then this method
223+
* should only be called when all objects are finished using the instance.
224+
* </p>
225+
*/
218226
@SuppressWarnings("unchecked")
219227
public void close() {
220228
synchronized (documentStores) {
@@ -230,22 +238,30 @@ public void close() {
230238
eventBus.post(new DocumentStoreClosed(databaseName));
231239
}
232240

241+
/**
242+
* <p>
243+
* Deletes the DocumentStore instance.
244+
* </p>
245+
*
246+
* @throws DocumentStoreNotDeletedException if the DocumentStore doesn't exist on disk or
247+
* if there was an error deleting the DocumentStore directory.
248+
*/
233249
public void delete() throws DocumentStoreNotDeletedException {
234250
try {
235251
this.close();
236252
} catch (Exception e) {
237-
// caught exception could be something benign like datastore already closed, so just log
253+
// caught exception could be something benign like DocumentStore already closed, so just log
238254
logger.log(Level.WARNING, "Caught exception whilst closing DocumentStore in delete()", e);
239255
}
240256
if (!location.exists()) {
241-
String msg = String.format("Datastore %s doesn't exist on disk", location);
257+
String msg = String.format("DocumentStore %s doesn't exist on disk", location);
242258
logger.warning(msg);
243259
throw new DocumentStoreNotDeletedException(msg);
244260
} else {
245261
try {
246262
FileUtils.deleteDirectory(location);
247263
} catch (IOException ioe) {
248-
String msg = String.format("Datastore %s not deleted", location);
264+
String msg = String.format("DocumentStore %s not deleted", location);
249265
logger.log(Level.WARNING, msg, ioe);
250266
throw new DocumentStoreNotDeletedException(msg, ioe);
251267
}
@@ -254,7 +270,7 @@ public void delete() throws DocumentStoreNotDeletedException {
254270
}
255271

256272
/**
257-
* <p>Returns the EventBus which this Datastore posts
273+
* <p>Returns the EventBus which this DocumentStore posts
258274
* {@link DocumentStoreModified Database Notification Events} to.</p>
259275
* @return the DocumentStore's EventBus
260276
*

cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/encryption/CachingKeyProvider.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
/**
2020
* Given a user-provided {@link KeyProvider}, it provides an in-memory cache for retrieving an
21-
* {@link EncryptionKey}. This improves performance when multiple encrypted datastores are used.
21+
* {@link EncryptionKey}. This improves performance when multiple encrypted DocumentStores are used.
2222
*
2323
* This class implements the interface {@link KeyProvider} and it can be used to create an
24-
* encrypted datastore.
24+
* encrypted DocumentStore.
2525
*
2626
* @see KeyProvider
2727
*/
@@ -36,7 +36,7 @@ public class CachingKeyProvider implements KeyProvider {
3636
* Creates a {@link CachingKeyProvider} containing a {@link KeyProvider} whose {@link
3737
* EncryptionKey} can be cached
3838
*
39-
* @param keyProvider The {@link KeyProvider} to use for encrypting a datastore
39+
* @param keyProvider The {@link KeyProvider} to use for encrypting a DocumentStore
4040
*/
4141
public CachingKeyProvider(KeyProvider keyProvider) {
4242
if (keyProvider == null) {

cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/encryption/EncryptionKey.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818

1919
/**
2020
* Class to enforce restrictions on encryption keys used
21-
* with the datastore.
21+
* with the DocumentStore.
2222
*
23-
* SQLCipher requires a 32-byte/256-bit key. This class
24-
* enforces that.
23+
* Note: SQLCipher requires a 32-byte/256-bit key.
2524
*/
2625
public class EncryptionKey {
2726

cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/encryption/KeyProvider.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,14 @@
1313
*/
1414

1515
package com.cloudant.sync.documentstore.encryption;
16-
1716
/**
1817
* Classes implementing this interface provide encryption
19-
* keys used by the datastore when encryption is enabled.
20-
*
21-
* Created by Mike Rhodes on 11/05/15.
18+
* keys used by the DocumentStore when encryption is enabled.
2219
*/
2320
public interface KeyProvider {
2421

2522
/**
26-
* @return the encryption key used to encrypt datastore data
23+
* @return the encryption key used to encrypt DocumentStore data
2724
*/
2825
EncryptionKey getEncryptionKey();
2926
}

cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/encryption/SimpleKeyProvider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* SimpleKeyProvider simply takes raw key bytes in its
2020
* constructor and uses these to provide that key to
21-
* datastore methods.
21+
* DocumentStore methods.
2222
*/
2323
public class SimpleKeyProvider implements KeyProvider {
2424

0 commit comments

Comments
 (0)