/** * Encodes any {@code BSONObject}, as a document * * @param name the field name * @param document the value * @return the number of characters in the encoding */ protected int putObject(final String name, final BSONObject document) { putName(name); return putObject(document); }
putIterable(name, (Iterable) value); } else if (value instanceof BSONObject) { putObject(name, (BSONObject) value); } else if (value instanceof Map) { putMap(name, (Map) value);
this.putObjectId(name, (ObjectId)val); } else if(val instanceof BSONObject) { this.putObject(name, (BSONObject)val); } else if(val instanceof Boolean) { this.putBoolean(name, (Boolean)val); temp.put("$ref", ((DBRefBase)val).getRef()); temp.put("$id", ((DBRefBase)val).getId()); this.putObject(name, temp); } else if(val instanceof MinKey) { this.putMinKey(name);
@Override public byte[] encode(final BSONObject document) { OutputBuffer outputBuffer = new BasicOutputBuffer(); set(outputBuffer); putObject(document); done(); return outputBuffer.toByteArray(); }
putObjectId(name, (ObjectId) val); else if (val instanceof BSONObject) putObject(name, (BSONObject) val); else if (val instanceof Boolean) putBoolean(name, (Boolean) val);
/** * Encodes a field to a {@link org.bson.BsonType#JAVASCRIPT_WITH_SCOPE} value. * * @param name the field name * @param codeWScope the value */ protected void putCodeWScope(final String name, final CodeWScope codeWScope) { putName(name); bsonWriter.writeJavaScriptWithScope(codeWScope.getCode()); putObject(codeWScope.getScope()); }
/** * Encodes a <code>BSONObject</code>. This is for the higher level api calls * * @param o * the object to encode * @return the number of characters in the encoding */ //@Override public int putObject(BSONObject o) { return putObject(null, o); }
public int putObject(BSONObject o) { return this.putObject((String)null, o); }
public byte[] encode(BSONObject o) { BasicOutputBuffer buf = new BasicOutputBuffer(); set(buf); putObject(o); done(); return buf.toByteArray(); }
public byte[] encode(BSONObject o) { BasicOutputBuffer buf = new BasicOutputBuffer(); this.set(buf); this.putObject(o); this.done(); return buf.toByteArray(); }
protected void putCodeWScope(String name, CodeWScope code) { _put(CODE_W_SCOPE, name); int temp = _buf.getPosition(); _buf.writeInt(0); _putValueString(code.getCode()); putObject(code.getScope()); _buf.writeInt(temp, _buf.getPosition() - temp); }
protected void putCodeWScope(String name, CodeWScope code) { this._put(15, name); int temp = this._buf.getPosition(); this._buf.writeInt(0); this._putValueString(code.getCode()); this.putObject(code.getScope()); this._buf.writeInt(temp, this._buf.getPosition() - temp); }