Skip to content

Commit e94d6b1

Browse files
committed
Updated Javadoc for Mongo, reducing warnings from the Javadoc gradle target - much of this was ported from 3.x
1 parent 6a72648 commit e94d6b1

4 files changed

Lines changed: 73 additions & 55 deletions

File tree

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ javadoc {
9898
options.links 'http://docs.oracle.com/javase/7/docs/api/'
9999
options.tagletPath project.sourceSets.util.output.classesDir
100100
options.taglets 'ManualTaglet'
101+
options.taglets 'DochubTaglet'
101102
}
102103

103104
task testAll(dependsOn: tasks.withType(Test))

src/main/com/mongodb/DB.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -979,19 +979,14 @@ public int getOptions(){
979979
return _options.get();
980980
}
981981

982-
/**
983-
* Returns true if the database name is not empty and does not contain any spaces.
984-
* @param dbname
985-
* @return
986-
*/
987982
private boolean isValidName(String dbname){
988983
return dbname.length() != 0 && !dbname.contains(" ");
989984
}
990985

991986
/**
992987
* Forcefully kills any cursors leaked by neglecting to call {@code DBCursor.close}
993-
* @param force
994988
*
989+
* @param force true if should clean regardless of number of dead cursors
995990
* @see com.mongodb.DBCursor#close()
996991
* @deprecated Clients should ensure that {@code DBCursor.close} is called.
997992
*/

src/main/com/mongodb/Mongo.java

Lines changed: 70 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ public static int getMinorVersion() {
124124
}
125125

126126
/**
127-
* returns a database object
128-
* @param addr the database address
129-
* @return
130-
* @throws MongoException
127+
* Connect to the MongoDB instance at the given address, select and return the {@code DB} specified in the {@code DBAddress} parameter.
131128
*
129+
* @param addr The details of the server and database to connect to
130+
* @return the DB requested in the addr parameter.
131+
* @throws MongoException
132132
* @deprecated Please use {@link MongoClient#getDB(String)} instead.
133133
*/
134134
@Deprecated
@@ -249,8 +249,9 @@ public Mongo( ServerAddress left , ServerAddress right ) {
249249
* @see com.mongodb.ServerAddress
250250
* @param left left side of the pair
251251
* @param right right side of the pair
252-
* @param options
252+
* @param options the optional settings for the Mongo instance
253253
* @throws MongoException
254+
* @deprecated Please use {@link MongoClient#MongoClient(java.util.List, MongoClientOptions)} instead.
254255
*/
255256
@Deprecated
256257
public Mongo( ServerAddress left , ServerAddress right , MongoOptions options ) {
@@ -309,12 +310,11 @@ public Mongo( List<ServerAddress> seeds , MongoOptions options ) {
309310
* If only one address is used it will only connect to that node, otherwise it will discover all nodes.
310311
* If the URI contains database credentials, the database will be authenticated lazily on first use
311312
* with those credentials.
312-
* @param uri
313-
* @see MongoURI
314-
* <p>examples:
313+
* @param uri the URI to connect to.
314+
* <p>examples:<ul>
315315
* <li>mongodb://localhost</li>
316316
* <li>mongodb://fred:foobar@localhost/</li>
317-
* </p>
317+
* </ul></p>
318318
* @throws MongoException
319319
* @throws UnknownHostException
320320
* @dochub connections
@@ -353,9 +353,10 @@ public Mongo( MongoURI uri ) throws UnknownHostException {
353353
}
354354

355355
/**
356-
* gets a database object
357-
* @param dbname the database name
358-
* @return
356+
* Gets a database object from this MongoDB instance.
357+
*
358+
* @param dbname the name of the database to retrieve
359+
* @return a DB representing the specified database
359360
*/
360361
public DB getDB( String dbname ){
361362

@@ -371,17 +372,19 @@ public DB getDB( String dbname ){
371372
}
372373

373374
/**
374-
* gets a collection of DBs used by the driver since this Mongo instance was created.
375-
* This may include DBs that exist in the client but not yet on the server.
376-
* @return
375+
* Returns the list of databases used by the driver since this Mongo instance was created. This may include DBs that exist in the client
376+
* but not yet on the server.
377+
*
378+
* @return a collection of database objects
377379
*/
378380
public Collection<DB> getUsedDatabases(){
379381
return _dbs.values();
380382
}
381383

382384
/**
383-
* gets a list of all database names present on the server
384-
* @return
385+
* Gets a list of the names of all databases on the connected server.
386+
*
387+
* @return list of database names
385388
* @throws MongoException
386389
*/
387390
public List<String> getDatabaseNames(){
@@ -423,9 +426,9 @@ public String getVersion(){
423426
}
424427

425428
/**
426-
* returns a string representing the hosts used in this Mongo instance
427-
* @return
429+
* Get a String for debug purposes.
428430
*
431+
* @return a string representing the hosts used in this Mongo instance
429432
* @deprecated This method is NOT a part of public API and will be dropped in 3.x versions.
430433
*/
431434
@Deprecated
@@ -434,16 +437,18 @@ public String debugString(){
434437
}
435438

436439
/**
437-
* Gets the current master's hostname
438-
* @return
440+
* Gets a {@code String} representation of current connection point, i.e. master.
441+
*
442+
* @return server address in a host:port form
439443
*/
440444
public String getConnectPoint(){
441445
return _connector.getConnectPoint();
442446
}
443447

444448
/**
445449
* Gets the underlying TCP connector
446-
* @return
450+
*
451+
* @return A DBTCPConnector representing the connection to MongoDB
447452
* @deprecated {@link DBTCPConnector} is NOT part of the public API. It will be dropped in 3.x releases.
448453
*/
449454
@Deprecated
@@ -452,8 +457,9 @@ public DBTCPConnector getConnector() {
452457
}
453458

454459
/**
455-
* Gets the replica set status object
456-
* @return
460+
* Get the status of the replica set cluster.
461+
*
462+
* @return replica set status information
457463
*/
458464
public ReplicaSetStatus getReplicaSetStatus() {
459465
return _connector.getReplicaSetStatus();
@@ -469,7 +475,9 @@ public ServerAddress getAddress(){
469475

470476
/**
471477
* Gets a list of all server addresses used when this Mongo was created
472-
* @return
478+
*
479+
* @return list of server addresses
480+
* @throws MongoException
473481
*/
474482
public List<ServerAddress> getAllAddress() {
475483
List<ServerAddress> result = _connector.getAllAddress();
@@ -480,17 +488,17 @@ public List<ServerAddress> getAllAddress() {
480488
}
481489

482490
/**
483-
* Gets the list of server addresses currently seen by the connector.
484-
* This includes addresses auto-discovered from a replica set.
485-
* @return
491+
* Gets the list of server addresses currently seen by this client. This includes addresses auto-discovered from a replica set.
492+
*
493+
* @return list of server addresses
486494
* @throws MongoException
487495
*/
488496
public List<ServerAddress> getServerAddressList() {
489497
return _connector.getServerAddressList();
490498
}
491499

492500
/**
493-
* closes the underlying connector, which in turn closes all open connections.
501+
* Closes the underlying connector, which in turn closes all open connections.
494502
* Once called, this Mongo instance can no longer be used.
495503
*/
496504
public void close(){
@@ -523,7 +531,8 @@ public void setWriteConcern( WriteConcern concern ){
523531

524532
/**
525533
* Gets the default write concern
526-
* @return
534+
*
535+
* @return the default write concern
527536
*/
528537
public WriteConcern getWriteConcern(){
529538
return _concern;
@@ -542,7 +551,8 @@ public void setReadPreference( ReadPreference preference ){
542551

543552
/**
544553
* Gets the default read preference
545-
* @return
554+
*
555+
* @return the default read preference
546556
*/
547557
public ReadPreference getReadPreference(){
548558
return _readPref;
@@ -560,31 +570,34 @@ public void slaveOk(){
560570
}
561571

562572
/**
563-
* adds a default query option
564-
* @param option
573+
* Add a default query option keeping any previously added options.
574+
*
575+
* @param option value to be added to current options
565576
*/
566577
public void addOption( int option ){
567578
_netOptions.add( option );
568579
}
569580

570581
/**
571-
* sets the default query options
572-
* @param options
582+
* Set the default query options. Overrides any existing options.
583+
*
584+
* @param options value to be set
573585
*/
574586
public void setOptions( int options ){
575587
_netOptions.set( options );
576588
}
577589

578590
/**
579-
* reset the default query options
591+
* Reset the default query options
580592
*/
581593
public void resetOptions(){
582594
_netOptions.reset();
583595
}
584596

585597
/**
586-
* gets the default query options
587-
* @return
598+
* Gets the default query options
599+
*
600+
* @return an int representing the options to be used by queries
588601
*/
589602
public int getOptions(){
590603
return _netOptions.get();
@@ -610,6 +623,7 @@ void _applyMongoOptions() {
610623
*
611624
* @deprecated Please use {@link MongoClient}
612625
* and corresponding {@link com.mongodb.MongoClient#getMongoClientOptions()}
626+
* @return A {@link com.mongodb.MongoOptions} containing the settings for this MongoDB instance.
613627
*/
614628
@Deprecated
615629
public MongoOptions getMongoOptions() {
@@ -663,11 +677,13 @@ protected PoolOutputBuffer createNew(){
663677
};
664678

665679
/**
666-
* Forces the master server to fsync the RAM data to disk
667-
* This is done automatically by the server at intervals, but can be forced for better reliability.
680+
* Forces the master server to fsync the RAM data to disk This is done automatically by the server at intervals, but can be forced for
681+
* better reliability.
682+
*
668683
* @param async if true, the fsync will be done asynchronously on the server.
669-
* @return
684+
* @return result of the command execution
670685
* @throws MongoException
686+
* @mongodb.driver.manual reference/command/fsync/ fsync command
671687
*/
672688
public CommandResult fsync(boolean async) {
673689
DBObject cmd = new BasicDBObject("fsync", 1);
@@ -678,10 +694,12 @@ public CommandResult fsync(boolean async) {
678694
}
679695

680696
/**
681-
* Forces the master server to fsync the RAM data to disk, then lock all writes.
682-
* The database will be read-only after this command returns.
683-
* @return
697+
* Forces the master server to fsync the RAM data to disk, then lock all writes. The database will be read-only after this command
698+
* returns.
699+
*
700+
* @return result of the command execution
684701
* @throws MongoException
702+
* @mongodb.driver.manual reference/command/fsync/ fsync command
685703
*/
686704
public CommandResult fsyncAndLock() {
687705
DBObject cmd = new BasicDBObject("fsync", 1);
@@ -690,10 +708,12 @@ public CommandResult fsyncAndLock() {
690708
}
691709

692710
/**
693-
* Unlocks the database, allowing the write operations to go through.
694-
* This command may be asynchronous on the server, which means there may be a small delay before the database becomes writable.
695-
* @return
711+
* Unlocks the database, allowing the write operations to go through. This command may be asynchronous on the server, which means there
712+
* may be a small delay before the database becomes writable.
713+
*
714+
* @return {@code DBObject} in the following form {@code {"ok": 1,"info": "unlock completed"}}
696715
* @throws MongoException
716+
* @mongodb.driver.manual reference/command/fsync/ fsync command
697717
*/
698718
public DBObject unlock() {
699719
DB db = getDB(ADMIN_DATABASE_NAME);
@@ -703,8 +723,10 @@ public DBObject unlock() {
703723

704724
/**
705725
* Returns true if the database is locked (read-only), false otherwise.
706-
* @return
726+
*
727+
* @return result of the command execution
707728
* @throws MongoException
729+
* @mongodb.driver.manual reference/command/fsync/ fsync command
708730
*/
709731
public boolean isLocked() {
710732
DB db = getDB(ADMIN_DATABASE_NAME);

src/test/com/mongodb/DBTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public void shouldThrowAnExceptionWhenDBNameContainsSpaces() {
306306
}
307307

308308
@Test(expected = IllegalArgumentException.class)
309-
public void shouldThrowAnExceptionwhenDBNameIsEmpty() {
309+
public void shouldThrowAnExceptionWhenDBNameIsEmpty() {
310310
cleanupMongo.getDB("");
311311
}
312312

0 commit comments

Comments
 (0)