Package com.mongodb

Interface Cursor

All Superinterfaces:
AutoCloseable, Closeable, Iterator<DBObject>
All Known Implementing Classes:
DBCursor

public interface Cursor extends Iterator<DBObject>, Closeable
Interface for providing consistent behaviour between different Cursor implementations.
Since:
2.12
MongoDB documentation
Cursors
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the number of results available locally without blocking, which may be 0.
    void
    Terminates this cursor on the server.
    long
    Gets the server's identifier for this Cursor.
    Gets the address of the server that data is pulled from.

    Methods inherited from interface java.util.Iterator

    forEachRemaining, hasNext, next, remove
  • Method Details

    • available

      int available()
      Gets the number of results available locally without blocking, which may be 0.

      If the cursor is known to be exhausted, returns 0. If the cursor is closed before it's been exhausted, it may return a non-zero value.

      Returns:
      the number of results available locally without blocking
      Since:
      4.5
    • getCursorId

      long getCursorId()
      Gets the server's identifier for this Cursor.
      Returns:
      the cursor's ID, or 0 if there is no active cursor.
    • getServerAddress

      @Nullable ServerAddress getServerAddress()
      Gets the address of the server that data is pulled from. Note that this information may not be available until hasNext() or next() is called.
      Returns:
      the address of the server that data is pulled from, or null if a cursor is no longer established
    • close

      void close()
      Terminates this cursor on the server.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable