@Override protected String doReadJavaScriptWithScope() { return currentValue.asJavaScriptWithScope().getCode(); }
@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; }
@Override protected void doReadStartDocument() { BsonDocument document; if (currentValue.getBsonType() == BsonType.JAVASCRIPT_WITH_SCOPE) { document = currentValue.asJavaScriptWithScope().getScope(); } else { document = currentValue.asDocument(); } setContext(new Context(getContext(), BsonContextType.DOCUMENT, document)); }
Struct jsScopeStruct = new Struct( schema.field(keyvalueforStruct.getKey()).schema().field("scope").schema()); jsStruct.put("code", keyvalueforStruct.getValue().asJavaScriptWithScope().getCode()); BsonDocument jwsDoc = keyvalueforStruct.getValue().asJavaScriptWithScope().getScope().asDocument();
@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; } }
jswithscope.field("code", Schema.OPTIONAL_STRING_SCHEMA); SchemaBuilder scope = SchemaBuilder.struct().name(jswithscope.name() + ".scope").optional(); BsonDocument jwsDocument = keyValuesforSchema.getValue().asJavaScriptWithScope().getScope().asDocument();
break; case JAVASCRIPT_WITH_SCOPE: pipeJavascriptWithScope(value.asJavaScriptWithScope()); break; case INT32:
BsonJavaScriptWithScope casted = value.asJavaScriptWithScope(); return new DefaultBsonJavaScriptWithCode(casted.getCode(), translate(casted.getScope()));
value.asDecimal128().decimal128Value().getLow()); case JAVASCRIPT_WITH_SCOPE: { BsonJavaScriptWithScope casted = value.asJavaScriptWithScope(); return new DefaultBsonJavaScriptWithCode(casted.getCode(), translate(casted.getScope()));