@Override public void doWriteObjectId(final ObjectId value) { bsonOutput.writeByte(BsonType.OBJECT_ID.getValue()); writeCurrentName(); bsonOutput.writeBytes(value.toByteArray()); }
@Override protected void doWriteMinKey() { bsonOutput.writeByte(BsonType.MIN_KEY.getValue()); writeCurrentName(); }
@Override protected void doWriteDBPointer(final BsonDbPointer value) { bsonOutput.writeByte(BsonType.DB_POINTER.getValue()); writeCurrentName(); bsonOutput.writeString(value.getNamespace()); bsonOutput.writeBytes(value.getId().toByteArray()); }
@Override protected void doWriteMaxKey() { bsonOutput.writeByte(BsonType.MAX_KEY.getValue()); writeCurrentName(); }
@Override public void doWriteNull() { bsonOutput.writeByte(BsonType.NULL.getValue()); writeCurrentName(); }
@Override public void doWriteUndefined() { bsonOutput.writeByte(BsonType.UNDEFINED.getValue()); writeCurrentName(); }
@Override protected void doWriteInt32(final int value) { bsonOutput.writeByte(BsonType.INT32.getValue()); writeCurrentName(); bsonOutput.writeInt32(value); }
@Override protected void doWriteInt64(final long value) { bsonOutput.writeByte(BsonType.INT64.getValue()); writeCurrentName(); bsonOutput.writeInt64(value); }
@Override protected void doWriteDateTime(final long value) { bsonOutput.writeByte(BsonType.DATE_TIME.getValue()); writeCurrentName(); bsonOutput.writeInt64(value); }
@Override public void doWriteString(final String value) { bsonOutput.writeByte(BsonType.STRING.getValue()); writeCurrentName(); bsonOutput.writeString(value); }
@Override protected void doWriteDouble(final double value) { bsonOutput.writeByte(BsonType.DOUBLE.getValue()); writeCurrentName(); bsonOutput.writeDouble(value); }
@Override protected void doWriteJavaScript(final String value) { bsonOutput.writeByte(BsonType.JAVASCRIPT.getValue()); writeCurrentName(); bsonOutput.writeString(value); }
@Override protected void doWriteEndArray() { bsonOutput.writeByte(0); backpatchSize(); // size of document setContext(getContext().getParentContext()); }
@Override public void doWriteTimestamp(final BsonTimestamp value) { bsonOutput.writeByte(BsonType.TIMESTAMP.getValue()); writeCurrentName(); bsonOutput.writeInt64(value.getValue()); }
@Override protected void doWriteDecimal128(final Decimal128 value) { bsonOutput.writeByte(BsonType.DECIMAL128.getValue()); writeCurrentName(); bsonOutput.writeInt64(value.getLow()); bsonOutput.writeInt64(value.getHigh()); }
@Override public void doWriteRegularExpression(final BsonRegularExpression value) { bsonOutput.writeByte(BsonType.REGULAR_EXPRESSION.getValue()); writeCurrentName(); bsonOutput.writeCString(value.getPattern()); bsonOutput.writeCString(value.getOptions()); }
@Override protected void doWriteStartArray() { bsonOutput.writeByte(BsonType.ARRAY.getValue()); writeCurrentName(); setContext(new Context(getContext(), BsonContextType.ARRAY, bsonOutput.getPosition())); bsonOutput.writeInt32(0); // reserve space for size }
@Override protected void doWriteEndDocument() { bsonOutput.writeByte(0); backpatchSize(); // size of document setContext(getContext().getParentContext()); if (getContext() != null && getContext().getContextType() == BsonContextType.JAVASCRIPT_WITH_SCOPE) { backpatchSize(); // size of the JavaScript with scope value setContext(getContext().getParentContext()); } }
@Override protected EncodingMetadata encodeMessageBodyWithMetadata(final BsonOutput bsonOutput, final SessionContext sessionContext) { bsonOutput.writeInt32(wrappedOpcode.getValue()); bsonOutput.writeInt32(getWrappedMessageSize(wrappedMessageBuffers) - MESSAGE_HEADER_LENGTH); bsonOutput.writeByte(compressor.getId()); getFirstWrappedMessageBuffer(wrappedMessageBuffers) .position(getFirstWrappedMessageBuffer(wrappedMessageBuffers).position() + MESSAGE_HEADER_LENGTH); compressor.compress(wrappedMessageBuffers, bsonOutput); return new EncodingMetadata(0); }