@Override protected BsonBinary doReadBinaryData() { return currentValue.asBinary(); }
@Override protected byte doPeekBinarySubType() { return currentValue.asBinary().getType(); }
@Override protected int doPeekBinarySize() { return currentValue.asBinary().getData().length; }
/** * Gets the value of the key if it is a BsonBinary, or throws if not. * * @param key the key * @return the value of the key as a BsonBinary * @throws org.bson.BsonInvalidOperationException if the document does not contain the key or the value is not of the expected type */ public BsonBinary getBinary(final Object key) { throwIfKeyAbsent(key); return get(key).asBinary(); }
/** * If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a * BsonBinary. * * @param key the key * @param defaultValue the default value * @return the value of the key as a BsonBinary * @throws org.bson.BsonInvalidOperationException if the document contains the key but the value is not of the expected type */ public BsonBinary getBinary(final Object key, final BsonBinary defaultValue) { if (!containsKey(key)) { return defaultValue; } return get(key).asBinary(); }
@Override public BsonDocument clone() { BsonDocument to = new BsonDocument(); for (Entry<String, BsonValue> cur : entrySet()) { switch (cur.getValue().getBsonType()) { case DOCUMENT: to.put(cur.getKey(), cur.getValue().asDocument().clone()); break; case ARRAY: to.put(cur.getKey(), cur.getValue().asArray().clone()); break; case BINARY: to.put(cur.getKey(), BsonBinary.clone(cur.getValue().asBinary())); break; case JAVASCRIPT_WITH_SCOPE: to.put(cur.getKey(), BsonJavaScriptWithScope.clone(cur.getValue().asJavaScriptWithScope())); break; default: to.put(cur.getKey(), cur.getValue()); } } return to; }
colValue = keyvalueforStruct.getValue().asBinary().getData(); break; list.add(temp); } else if (arrValue.getBsonType() == BsonType.BINARY && valueType == BsonType.BINARY) { byte[] temp = arrValue.asBinary().getData(); list.add(temp); } else if (arrValue.getBsonType() == BsonType.INT32 && valueType == BsonType.INT32) {
@Override public BsonArray clone() { BsonArray to = new BsonArray(); for (BsonValue cur : this) { switch (cur.getBsonType()) { case DOCUMENT: to.add(cur.asDocument().clone()); break; case ARRAY: to.add(cur.asArray().clone()); break; case BINARY: to.add(BsonBinary.clone(cur.asBinary())); break; case JAVASCRIPT_WITH_SCOPE: to.add(BsonJavaScriptWithScope.clone(cur.asJavaScriptWithScope())); break; default: to.add(cur); } } return to; } }
return new DBRef(value.asDBPointer().getNamespace(), value.asDBPointer().getId()); case BINARY: return value.asBinary().getData(); case DATE_TIME: return new Date(value.asDateTime().getValue());
break; case BINARY: writeBinaryData(value.asBinary()); break; case UNDEFINED:
return new DBRef(value.asDBPointer().getNamespace(), value.asDBPointer().getId()); case BINARY: return value.asBinary().getData(); case DATE_TIME: return new Date(value.asDateTime().getValue());
BsonBinary casted = value.asBinary(); return new ByteArrayBsonBinary( getBinarySubtype(casted.getType()),
BsonBinary casted = value.asBinary(); return new ByteArrayBsonBinary( getBinarySubtype(casted.getType()), casted.getType(), casted.getData());