@Override protected BsonTimestamp doReadTimestamp() { return currentValue.asTimestamp(); }
/** * Gets the value of the key if it is a BsonTimestamp, or throws if not. * * @param key the key * @return the value of the key as a BsonTimestamp * @throws org.bson.BsonInvalidOperationException if the document does not contain the key or the value is not of the expected type */ public BsonTimestamp getTimestamp(final Object key) { throwIfKeyAbsent(key); return get(key).asTimestamp(); }
/** * If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a * BsonTimestamp. * * @param key the key * @param defaultValue the default value * @return the value of the key as a BsonTimestamp * @throws org.bson.BsonInvalidOperationException if the document contains the key but the value is not of the expected type */ public BsonTimestamp getTimestamp(final Object key, final BsonTimestamp defaultValue) { if (!containsKey(key)) { return defaultValue; } return get(key).asTimestamp(); }
static BsonTimestamp getOperationTime(final ResponseBuffers responseBuffers) { try { BsonValue operationTime = getField(createBsonReader(responseBuffers), "operationTime"); if (operationTime == null) { return null; } return operationTime.asTimestamp(); } finally { responseBuffers.reset(); } }
colValue = keyvalueforStruct.getValue().asTimestamp().getTime(); break;
break; case TIMESTAMP: writeTimestamp(value.asTimestamp()); break; case INT64:
static BsonTimestamp getOperationTime(final ResponseBuffers responseBuffers) { try { BsonValue operationTime = getField(createBsonReader(responseBuffers), "operationTime"); if (operationTime == null) { return null; } return operationTime.asTimestamp(); } finally { responseBuffers.reset(); } }
private static JsonValue mapBsonValueToJsonValue(@Nullable final BsonValue bsonValue, final Function<String, String> jsonKeyNameReviser) { final JsonValue result; if (bsonValue == null || bsonValue.isNull()) { result = JsonFactory.nullLiteral(); } else if (bsonValue.isString()) { result = JsonFactory.newValue(bsonValue.asString().getValue()); } else if (bsonValue.isNumber()) { result = mapBsonNumberToJsonNumber(bsonValue.asNumber()); } else if (bsonValue.isDocument()) { result = mapBsonDocumentToJsonObject(bsonValue.asDocument(), jsonKeyNameReviser); } else if (bsonValue.isArray()) { result = mapBsonArrayToJsonArray(bsonValue.asArray(), jsonKeyNameReviser); } else if (bsonValue.isBoolean()) { result = JsonFactory.newValue(bsonValue.asBoolean().getValue()); } else if (bsonValue.isTimestamp()) { final Instant instant = Instant.ofEpochSecond(bsonValue.asTimestamp().getTime()); result = JsonFactory.newValue(instant.toString()); } else { result = JsonFactory.nullLiteral(); } return result; }
return new StringBsonString(value.asString().getValue()); case TIMESTAMP: { BsonTimestamp casted = value.asTimestamp(); return new DefaultBsonTimestamp(casted.getTime(), casted.getInc());
return new StringBsonString(value.asString().getValue()); case TIMESTAMP: { BsonTimestamp casted = value.asTimestamp(); return new DefaultBsonTimestamp(casted.getTime(), casted.getInc());