private Object readResolve() { return new BsonDocumentCodec().decode(new BsonBinaryReader(ByteBuffer.wrap(bytes) .order(ByteOrder.LITTLE_ENDIAN)), DecoderContext.builder().build()); } }
/** * Parses a string in MongoDB Extended JSON format to a {@code BsonDocument} * * @param json the JSON string * @return a corresponding {@code BsonDocument} object * @see org.bson.json.JsonReader * @mongodb.driver.manual reference/mongodb-extended-json/ MongoDB Extended JSON */ public static BsonDocument parse(final String json) { return new BsonDocumentCodec().decode(new JsonReader(json), DecoderContext.builder().build()); }
private BsonDocument toBsonDocument() { BsonBinaryReader bsonReader = createReader(); try { return new BsonDocumentCodec().decode(bsonReader, DecoderContext.builder().build()); } finally { bsonReader.close(); } }
static BsonDocument toBson(JsonObject gson) throws IOException { return new BsonDocumentCodec().decode(asBsonReader(gson), DecoderContext.builder().build()); }
BsonDocument toBsonDocument() { ByteBuf duplicateByteBuf = byteBuf.duplicate(); BsonBinaryReader bsonReader = new BsonBinaryReader(new ByteBufferBsonInput(duplicateByteBuf)); try { return new BsonDocumentCodec().decode(bsonReader, DecoderContext.builder().build()); } finally { duplicateByteBuf.release(); bsonReader.close(); } }
public RemoteInsertManyResult decode( final BsonReader reader, final DecoderContext decoderContext ) { final BsonDocument document = (new BsonDocumentCodec()).decode(reader, decoderContext); keyPresent(Fields.INSERTED_IDS_FIELD, document); final BsonArray arr = document.getArray(Fields.INSERTED_IDS_FIELD); final Map<Long, BsonValue> insertedIds = new HashMap<>(); for (int i = 0; i < arr.size(); i++) { insertedIds.put((long) i, arr.get(i)); } return new RemoteInsertManyResult(insertedIds); }
public RemoteInsertOneResult decode( final BsonReader reader, final DecoderContext decoderContext ) { final BsonDocument document = (new BsonDocumentCodec()).decode(reader, decoderContext); keyPresent(Fields.INSERTED_ID_FIELD, document); return new RemoteInsertOneResult(document.get(Fields.INSERTED_ID_FIELD)); }
public RemoteDeleteResult decode(final BsonReader reader, final DecoderContext decoderContext) { final BsonDocument document = (new BsonDocumentCodec()).decode(reader, decoderContext); keyPresent(Fields.DELETED_COUNT_FIELD, document); return new RemoteDeleteResult(document.getNumber(Fields.DELETED_COUNT_FIELD).longValue()); }
BsonDocument toBsonDocument() { ByteBuf duplicateByteBuf = byteBuf.duplicate(); BsonBinaryReader bsonReader = new BsonBinaryReader(new ByteBufferBsonInput(duplicateByteBuf)); try { return new BsonDocumentCodec().decode(bsonReader, DecoderContext.builder().build()); } finally { duplicateByteBuf.release(); bsonReader.close(); } }
public RemoteUpdateResult decode(final BsonReader reader, final DecoderContext decoderContext) { final BsonDocument document = (new BsonDocumentCodec()).decode(reader, decoderContext); keyPresent(Fields.MATCHED_COUNT_FIELD, document); keyPresent(Fields.MODIFIED_COUNT_FIELD, document); final long matchedCount = document.getNumber(Fields.MATCHED_COUNT_FIELD).longValue(); final long modifiedCount = document.getNumber(Fields.MODIFIED_COUNT_FIELD).longValue(); if (!document.containsKey(Fields.UPSERTED_ID_FIELD)) { return new RemoteUpdateResult(matchedCount, modifiedCount, null); } return new RemoteUpdateResult( matchedCount, modifiedCount, document.get(Fields.UPSERTED_ID_FIELD)); }
final DecoderContext decoderContext ) { final BsonDocument document = (new BsonDocumentCodec()).decode(reader, decoderContext); keyPresent(Fields.SUCCESSES_FIELD, document); keyPresent(Fields.FAILURES_FIELD, document);