@@ -220,7 +220,9 @@ public void remove() {
220
220
* @return {@code this} so calls can be chained
221
221
* @see Bytes
222
222
* @mongodb.driver.manual ../meta-driver/latest/legacy/mongodb-wire-protocol/#op-query Query Flags
223
+ * @deprecated Prefer per-option methods, e.g. {@link #cursorType(CursorType)}, {@link #noCursorTimeout(boolean)}, etc.
223
224
*/
225
+ @ Deprecated
224
226
public DBCursor addOption (final int option ) {
225
227
setOptions (this .options |= option );
226
228
return this ;
@@ -234,6 +236,7 @@ public DBCursor addOption(final int option) {
234
236
* @see Bytes
235
237
* @mongodb.driver.manual ../meta-driver/latest/legacy/mongodb-wire-protocol/#op-query Query Flags
236
238
*/
239
+ @ Deprecated
237
240
public DBCursor setOptions (final int options ) {
238
241
if ((options & Bytes .QUERYOPTION_EXHAUST ) != 0 ) {
239
242
throw new UnsupportedOperationException ("exhaust query option is not supported" );
@@ -248,6 +251,7 @@ public DBCursor setOptions(final int options) {
248
251
* @return {@code this} so calls can be chained
249
252
* @mongodb.driver.manual ../meta-driver/latest/legacy/mongodb-wire-protocol/#op-query Query Flags
250
253
*/
254
+ @ Deprecated
251
255
public DBCursor resetOptions () {
252
256
this .options = 0 ;
253
257
return this ;
@@ -259,6 +263,7 @@ public DBCursor resetOptions() {
259
263
* @return the bitmask of options
260
264
* @mongodb.driver.manual ../meta-driver/latest/legacy/mongodb-wire-protocol/#op-query Query Flags
261
265
*/
266
+ @ Deprecated
262
267
public int getOptions () {
263
268
return options ;
264
269
}
@@ -493,6 +498,55 @@ public DBObject explain() {
493
498
getReadPreference (), getReadConcern ()));
494
499
}
495
500
501
+ /**
502
+ * Sets the cursor type.
503
+ *
504
+ * @param cursorType the cursor type, which may not be null
505
+ * @return this
506
+ * @since 3.9
507
+ */
508
+ public DBCursor cursorType (final CursorType cursorType ) {
509
+ findOptions .cursorType (cursorType );
510
+ return this ;
511
+ }
512
+
513
+ /**
514
+ * Users should not set this under normal circumstances.
515
+ *
516
+ * @param oplogReplay if oplog replay is enabled
517
+ * @return this
518
+ * @since 3.9
519
+ */
520
+ public DBCursor oplogReplay (final boolean oplogReplay ) {
521
+ findOptions .oplogReplay (oplogReplay );
522
+ return this ;
523
+ }
524
+
525
+ /**
526
+ * The server normally times out idle cursors after an inactivity period (10 minutes)
527
+ * to prevent excess memory use. Set this option to prevent that.
528
+ *
529
+ * @param noCursorTimeout true if cursor timeout is disabled
530
+ * @return this
531
+ * @since 3.9
532
+ */
533
+ public DBCursor noCursorTimeout (final boolean noCursorTimeout ) {
534
+ findOptions .noCursorTimeout (noCursorTimeout );
535
+ return this ;
536
+ }
537
+
538
+ /**
539
+ * Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
540
+ *
541
+ * @param partial if partial results for sharded clusters is enabled
542
+ * @return this
543
+ * @since 3.9
544
+ */
545
+ public DBCursor partial (final boolean partial ) {
546
+ findOptions .partial (partial );
547
+ return this ;
548
+ }
549
+
496
550
@ SuppressWarnings ("deprecation" )
497
551
private FindOperation <DBObject > getQueryOperation (final Decoder <DBObject > decoder ) {
498
552
FindOperation <DBObject > operation = new FindOperation <DBObject >(collection .getNamespace (), decoder )
0 commit comments