Skip to content

Commit 6a50a6f

Browse files
committed
added useful toString() for DBCursor
1 parent 9421b50 commit 6a50a6f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/main/com/mongodb/DBCursor.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,22 @@ public DBCollection getCollection(){
645645
return _collection;
646646
}
647647

648+
@Override
649+
public String toString() {
650+
StringBuilder sb = new StringBuilder();
651+
sb.append("Cursor id=").append(getCursorId());
652+
sb.append(", ns=").append(getCollection().getFullName());
653+
sb.append(", query=").append(getQuery());
654+
if (getKeysWanted() != null)
655+
sb.append(", fields=").append(getKeysWanted());
656+
sb.append(", numIterated=").append(_num);
657+
if (_numWanted > 0)
658+
sb.append(", numWanted=").append(_numWanted);
659+
if (_skip > 0)
660+
sb.append(", skip=").append(_skip);
661+
return sb.toString();
662+
}
663+
648664
// ---- query setup ----
649665
private final DBCollection _collection;
650666
private final DBObject _query;

0 commit comments

Comments
 (0)