Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mongodb/mongo-java-driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Dirolf committed Sep 4, 2009
2 parents a7b9286 + 40d41fd commit ce4d831
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/main/com/mongodb/DBCursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* </pre></blockquote>
*
*/
public class DBCursor implements Iterator<DBObject> {
public class DBCursor implements Iterator<DBObject> , Iterable<DBObject> {

/**
* Initializes a new database cursor
Expand Down Expand Up @@ -83,6 +83,10 @@ public DBCursor copy() {
return c;
}

public Iterator<DBObject> iterator(){
return this.copy();
}

// ---- querty modifiers --------

/**
Expand Down
4 changes: 1 addition & 3 deletions src/main/com/mongodb/gridfs/CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,10 @@ public static void main(String[] args) throws Exception {

if ( s.equals( "list" ) ){
GridFS fs = getGridFS();
DBCursor cur = fs.getFileList();

System.out.printf("%-60s %-10s\n", "Filename", "Length");

while(cur.hasNext()) {
DBObject o = cur.next();
for ( DBObject o : fs.getFileList() ){
System.out.printf("%-60s %-10d\n", o.get("filename"), ((Number) o.get("length")).longValue());
}
return;
Expand Down
7 changes: 7 additions & 0 deletions src/main/com/mongodb/gridfs/GridFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ public GridFSInputFile createFile( InputStream in , String filename ){
// ------ members -------
// --------------------------

public String getBucketName(){
return _bucketName;
}

public Mongo getMongo(){
return _mongo;
}

protected final Mongo _mongo;
protected final String _bucketName;
Expand Down

0 comments on commit ce4d831

Please sign in to comment.