/** * Counts the number of objects matching the query this does take limit/skip * into consideration * * @return the number of objects * @throws MongoException * @see #count() */ public int size() { executed(); return cursor.size(); }
/** * Checks if there is another object available * * @return true if there is another object available * @throws MongoException */ @Override public boolean hasNext() throws MongoException { executed(); return cursor.hasNext(); }
/** * Converts this cursor to an array. * * @return an array of elements * @throws MongoException * If an error occurred */ public List<T> toArray() throws MongoException { executed(); return toArray(Integer.MAX_VALUE); }
/** * for testing only! Iterates cursor and counts objects * * @return num objects * @see #count() */ public int itcount() { executed(); return cursor.itcount(); }
/** * Counts the number of objects matching the query This does not take * limit/skip into consideration * * @return the number of objects * @throws MongoException * @see #size() */ public int count() { executed(); return cursor.count(); }
/** * pulls back all items into an array and returns the number of objects. * Note: this can be resource intensive * * @return the number of elements in the array * @throws MongoException * Ig as error occurred * @see #count() * @see #size() */ public int length() throws MongoException { executed(); return cursor.length(); }
/** * Converts this cursor to an array. * * @param max * the maximum number of objects to return * @return an array of objects * @throws MongoException * If an error occurred */ public List<T> toArray(int max) throws MongoException { executed(); if (max > all.size()) { List<DBObject> objects = cursor.toArray(max); for (int i = all.size(); i < objects.size(); i++) { all.add(jacksonDBCollection.convertFromDbObject(objects.get(i))); } } return all; }
/** * Returns the object the cursor is at and moves the cursor ahead by one. * * @return the next element * @throws MongoException */ @Override public T next() throws MongoException { executed(); current = jacksonDBCollection.convertFromDbObject(cursor.next()); return current; }