@Override public void writeRawBytes(byte[] bufferedName, int off, int length) throws IOException { gen.writeBinary(bufferedName,off,length); }
@Override public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len) throws IOException { delegate.writeBinary(b64variant, data, offset, len); }
@Override public int writeBinary(Base64Variant b64variant, InputStream data, int dataLength) throws IOException { return delegate.writeBinary(b64variant, data, dataLength); }
/** * Convenience method for outputting a field entry ("member") * that contains specified data in base64-encoded form. * Equivalent to: *<pre> * writeFieldName(fieldName); * writeBinary(value); *</pre> */ public final void writeBinaryField(String fieldName, byte[] data) throws IOException { writeFieldName(fieldName); writeBinary(data); }
@Override public int writeBinary(Base64Variant b64variant, InputStream data, int dataLength) throws IOException { if (_checkBinaryWrite()) { return delegate.writeBinary(b64variant, data, dataLength); } return -1; }
@Override public void serialize(final HllSketch sketch, final JsonGenerator jgen, final SerializerProvider provider) throws IOException { jgen.writeBinary(sketch.toCompactByteArray()); }
@Override public void serialize( final ArrayOfDoublesSketch sketch, final JsonGenerator generator, final SerializerProvider provider ) throws IOException { generator.writeBinary(sketch.toByteArray()); }
@Override public void serialize(BloomKFilter bloomKFilter, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeBinary(bloomKFilterToBytes(bloomKFilter)); } }
/** * Similar to {@link #writeBinary(Base64Variant,byte[],int,int)}, * but assumes default to using the Jackson default Base64 variant * (which is {@link Base64Variants#MIME_NO_LINEFEEDS}). Also * assumes that whole byte array is to be output. */ public void writeBinary(byte[] data) throws IOException { writeBinary(Base64Variants.getDefaultVariant(), data, 0, data.length); }
@Override public void serialize(final DoublesSketch sketch, final JsonGenerator generator, final SerializerProvider provider) throws IOException { generator.writeBinary(sketch.toByteArray(true)); }
@Override public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len) throws IOException { if (_checkBinaryWrite()) { delegate.writeBinary(b64variant, data, offset, len); } }
/** * Similar to {@link #writeBinary(Base64Variant,byte[],int,int)}, * but default to using the Jackson default Base64 variant * (which is {@link Base64Variants#MIME_NO_LINEFEEDS}). */ public void writeBinary(byte[] data, int offset, int len) throws IOException { writeBinary(Base64Variants.getDefaultVariant(), data, offset, len); }
@Override public void serialize(ByteBuffer bbuf, JsonGenerator gen, SerializerProvider provider) throws IOException { // first, simple case when wrapping an array... if (bbuf.hasArray()) { gen.writeBinary(bbuf.array(), bbuf.arrayOffset(), bbuf.limit()); return; } // the other case is more complicated however. Best to handle with InputStream wrapper. // But should we rewind it; and/or make a copy? ByteBuffer copy = bbuf.asReadOnlyBuffer(); if (copy.position() > 0) { copy.rewind(); } InputStream in = new ByteBufferBackedInputStream(copy); gen.writeBinary(in, copy.remaining()); in.close(); }
/** * Similar to {@link #writeBinary(Base64Variant,InputStream,int)}, * but assumes default to using the Jackson default Base64 variant * (which is {@link Base64Variants#MIME_NO_LINEFEEDS}). * * @param data InputStream to use for reading binary data to write. * Will not be closed after successful write operation * @param dataLength (optional) number of bytes that will be available; * or -1 to be indicate it is not known. Note that implementations * need not support cases where length is not known in advance; this * depends on underlying data format: JSON output does NOT require length, * other formats may */ public int writeBinary(InputStream data, int dataLength) throws IOException { return writeBinary(Base64Variants.getDefaultVariant(), data, dataLength); }
/** * Method that can be called on backends that support passing opaque datatypes of * non-JSON formats * * @since 2.8 */ public void writeEmbeddedObject(Object object) throws IOException { // 01-Sep-2016, tatu: As per [core#318], handle small number of cases if (object == null) { writeNull(); return; } if (object instanceof byte[]) { writeBinary((byte[]) object); return; } throw new JsonGenerationException("No native support for writing embedded objects of type " +object.getClass().getName(), this); }
@Override public void serialize(SketchHolder sketchHolder, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeBinary(sketchHolder.getSketch().toByteArray()); } }
@Override public void serialize(byte[] value, JsonGenerator g, SerializerProvider provider) throws IOException { g.writeBinary(provider.getConfig().getBase64Variant(), value, 0, value.length); }
@Override public final void serialize(JsonGenerator jg, SerializerProvider provider) throws IOException, JsonProcessingException { jg.writeBinary(provider.getConfig().getBase64Variant(), _data, 0, _data.length); }
@Override public StructuredJsonGenerator writeValue(ByteBuffer bytes) { try { generator.writeBinary(BinaryUtils.copyBytesFrom(bytes)); } catch (IOException e) { throw new JsonGenerationException(e); } return this; }
@Override public void serializeWithType(byte[] value, JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException { // most likely scalar WritableTypeId typeIdDef = typeSer.writeTypePrefix(g, typeSer.typeId(value, JsonToken.VALUE_EMBEDDED_OBJECT)); g.writeBinary(provider.getConfig().getBase64Variant(), value, 0, value.length); typeSer.writeTypeSuffix(g, typeIdDef); /* OLD impl typeSer.writeTypePrefixForScalar(value, g); g.writeBinary(provider.getConfig().getBase64Variant(), value, 0, value.length); typeSer.writeTypeSuffixForScalar(value, g); */ }