driver-legacy/src/main/com/mongodb/MapReduceCommand.java
public DBObject toDBObject() {
        BasicDBObject cmd = new BasicDBObject();

        cmd.put("mapreduce", mapReduce);
        cmd.put("map", map);
        cmd.put("reduce", reduce);

        if (verbose != null) {
            cmd.put("verbose", verbose);
        }

        BasicDBObject out = new BasicDBObject();
        switch (outputType) {
            case INLINE:
                out.put("inline", 1);
                break;
            case REPLACE:
                out.put("replace", outputCollection);
                break;
            case MERGE:
                out.put("merge", outputCollection);
                break;
            case REDUCE:
                out.put("reduce", outputCollection);
                break;
            default:
                throw new IllegalArgumentException("Unexpected output type");
        }
        if (outputDB != null) {
            out.put("db", outputDB);
        }
        cmd.put("out", out);

        if (query != null) {
            cmd.put("query", query);
        }

        if (finalize != null) {
            cmd.put("finalize", finalize);
        }

        if (sort != null) {
            cmd.put("sort", sort);
        }

        if (limit > 0) {
            cmd.put("limit", limit);
        }

        if (scope != null) {
            cmd.put("scope", scope);
        }

        if (jsMode != null) {
            cmd.put("jsMode", jsMode);
        }

        if (maxTimeMS != 0) {
            cmd.put("maxTimeMS", maxTimeMS);
        }

        return cmd;
    }
public DBObject toDBObject() {
        BasicDBObject cmd = new BasicDBObject();

        cmd.put("mapreduce", mapReduce);
        cmd.put("map", map);
        cmd.put("reduce", reduce);

        if (verbose != null) {
            cmd.put("verbose", verbose);
        }

        BasicDBObject out = new BasicDBObject();
        switch (outputType) {
            case INLINE:
                out.put("inline", 1);
                break;
            case REPLACE:
                out.put("replace", outputCollection);
                break;
            case MERGE:
                out.put("merge", outputCollection);
                break;
            case REDUCE:
                out.put("reduce", outputCollection);
                break;
            default:
                throw new IllegalArgumentException("Unexpected output type");
        }
        if (outputDB != null) {
            out.put("db", outputDB);
        }
        cmd.put("out", out);

        if (query != null) {
            cmd.put("query", query);
        }

        if (finalize != null) {
            cmd.put("finalize", finalize);
        }

        if (sort != null) {
            cmd.put("sort", sort);
        }

        if (limit > 0) {
            cmd.put("limit", limit);
        }

        if (scope != null) {
            cmd.put("scope", scope);
        }

        if (jsMode != null) {
            cmd.put("jsMode", jsMode);
        }

        if (maxTimeMS != 0) {
            cmd.put("maxTimeMS", maxTimeMS);
        }

        return cmd;
    }
public DBObject toDBObject ( ) { BasicDBObject cmd = new BasicDBObject ( ) ; cmd . put ( "mapreduce" , mapReduce ) ; cmd . put ( "map" , map ) ; cmd . put ( "reduce" , reduce ) ; if ( verbose != null ) { cmd . put ( "verbose" , verbose ) ; } BasicDBObject out = new BasicDBObject ( ) ; switch ( outputType ) { case INLINE : out . put ( "inline" , 1 ) ; break ; case REPLACE : out . put ( "replace" , outputCollection ) ; break ; case MERGE : out . put ( "merge" , outputCollection ) ; break ; case REDUCE : out . put ( "reduce" , outputCollection ) ; break ; default : throw new IllegalArgumentException ( "Unexpected output type" ) ; } if ( outputDB != null ) { out . put ( "db" , outputDB ) ; } cmd . put ( "out" , out ) ; if ( query != null ) { cmd . put ( "query" , query ) ; } if ( finalize != null ) { cmd . put ( "finalize" , finalize ) ; } if ( sort != null ) { cmd . put ( "sort" , sort ) ; } if ( limit > 0 ) { cmd . put ( "limit" , limit ) ; } if ( scope != null ) { cmd . put ( "scope" , scope ) ; } if ( jsMode != null ) { cmd . put ( "jsMode" , jsMode ) ; } if ( maxTimeMS != 0 ) { cmd . put ( "maxTimeMS" , maxTimeMS ) ; } return cmd ; }
Turns this command into a DBObject representation of this map reduce command.

@return a DBObject that contains the MongoDB document representation of this command.
Turns this command into a DBObject representation of this map reduce command .