@Override public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len) throws IOException { /* 31-Dec-2009, tatu: can do this using multiple alternatives; but for * now, let's try to limit number of conversions. * The only (?) tricky thing is that of whether to preserve variant, * seems pointless, so let's not worry about it unless there's some * compelling reason to. */ byte[] copy = new byte[len]; System.arraycopy(data, offset, copy, 0, len); writeObject(copy); }
buf.writeObject(rawId);
break; case VALUE_EMBEDDED_OBJECT: writeObject(p.getEmbeddedObject()); break; default:
@Override public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len) throws IOException { /* 31-Dec-2009, tatu: can do this using multiple alternatives; but for * now, let's try to limit number of conversions. * The only (?) tricky thing is that of whether to preserve variant, * seems pointless, so let's not worry about it unless there's some * compelling reason to. */ byte[] copy = new byte[len]; System.arraycopy(data, offset, copy, 0, len); writeObject(copy); }
@Override public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len) throws IOException { /* 31-Dec-2009, tatu: can do this using multiple alternatives; but for * now, let's try to limit number of conversions. * The only (?) tricky thing is that of whether to preserve variant, * seems pointless, so let's not worry about it unless there's some * compelling reason to. */ byte[] copy = new byte[len]; System.arraycopy(data, offset, copy, 0, len); writeObject(copy); }
@Override public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len) throws IOException, JsonGenerationException { /* 31-Dec-2009, tatu: can do this using multiple alternatives; but for * now, let's try to limit number of conversions. * The only (?) tricky thing is that of whether to preserve variant, * seems pointless, so let's not worry about it unless there's some * compelling reason to. */ byte[] copy = new byte[len]; System.arraycopy(data, offset, copy, 0, len); writeObject(copy); }
protected void writeEmbeddedObject(T value, JsonGenerator jgen) throws IOException { if (jgen instanceof BsonObjectGenerator || jgen instanceof DBEncoderBsonGenerator || jgen instanceof DocumentObjectGenerator) { jgen.writeObject(value); } else if (jgen instanceof TokenBuffer) { TokenBuffer buffer = (TokenBuffer) jgen; ObjectCodec codec = buffer.getCodec(); buffer.setCodec(null); buffer.writeObject(value); buffer.setCodec(codec); } else { String message = "JsonGenerator of type " + jgen.getClass().getName() + " not supported: " + getClass().getName() + " is designed for use only with " + BsonObjectGenerator.class.getName() + " or " + DBEncoderBsonGenerator.class.getName() + " or " + TokenBuffer.class.getName(); throw new IllegalArgumentException(message); } }
private static class MongoDateSerializer extends JsonSerializer<Date> { public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider) throws IOException { TokenBuffer buffer = (TokenBuffer) jgen; ObjectCodec codec = buffer.getCodec(); buffer.setCodec(null); buffer.writeObject(value); buffer.setCodec(codec); } }
/** * Helper method we need to do necessary conversion from whatever native object id * type is, into declared type that Jackson internals expect. This may be * simple cast (for String ids), or something more complicated; in latter * case we may need to create bogus content buffer to allow use of * id deserializer. * * @since 2.3 */ @SuppressWarnings("resource") // TokenBuffers don't need close, nor parser thereof protected Object _convertObjectId(JsonParser jp, DeserializationContext ctxt, Object rawId, JsonDeserializer<Object> idDeser) throws IOException { TokenBuffer buf = new TokenBuffer(jp); if (rawId instanceof String) { buf.writeString((String) rawId); } else if (rawId instanceof Long) { buf.writeNumber(((Long) rawId).longValue()); } else if (rawId instanceof Integer) { buf.writeNumber(((Integer) rawId).intValue()); } else { // should we worry about UUIDs? They should be fine, right? // 07-Aug-2014, tatu: Maybe, but not necessarily; had issues with // Smile format; [Smile#19], possibly related. buf.writeObject(rawId); } JsonParser bufParser = buf.asParser(); bufParser.nextToken(); return idDeser.deserialize(bufParser, ctxt); }
/** * Helper method we need to do necessary conversion from whatever native object id * type is, into declared type that Jackson internals expect. This may be * simple cast (for String ids), or something more complicated; in latter * case we may need to create bogus content buffer to allow use of * id deserializer. * * @since 2.3 */ @SuppressWarnings("resource") // TokenBuffers don't need close, nor parser thereof protected Object _convertObjectId(JsonParser jp, DeserializationContext ctxt, Object rawId, JsonDeserializer<Object> idDeser) throws IOException { TokenBuffer buf = new TokenBuffer(jp); if (rawId instanceof String) { buf.writeString((String) rawId); } else if (rawId instanceof Long) { buf.writeNumber(((Long) rawId).longValue()); } else if (rawId instanceof Integer) { buf.writeNumber(((Integer) rawId).intValue()); } else { // should we worry about UUIDs? They should be fine, right? // 07-Aug-2014, tatu: Maybe, but not necessarily; had issues with // Smile format; [Smile#19], possibly related. buf.writeObject(rawId); } JsonParser bufParser = buf.asParser(); bufParser.nextToken(); return idDeser.deserialize(bufParser, ctxt); }
buf.writeObject(rawId);
break; case VALUE_EMBEDDED_OBJECT: writeObject(jp.getEmbeddedObject()); break; default:
break; case VALUE_EMBEDDED_OBJECT: writeObject(jp.getEmbeddedObject()); break; default:
break; case VALUE_EMBEDDED_OBJECT: writeObject(jp.getEmbeddedObject()); break; default:
break; case VALUE_EMBEDDED_OBJECT: writeObject(jp.getEmbeddedObject()); break; default:
break; case VALUE_EMBEDDED_OBJECT: writeObject(p.getEmbeddedObject()); break; default:
break; case VALUE_EMBEDDED_OBJECT: writeObject(p.getEmbeddedObject()); break; default: