All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adgear.anoa.write.ByteBufferWriter Maven / Gradle / Ivy

package com.adgear.anoa.write;

import com.fasterxml.jackson.core.JsonGenerator;

import java.io.IOException;
import java.nio.ByteBuffer;

class ByteBufferWriter extends AbstractWriter {

  @Override
  protected void write(ByteBuffer bb, JsonGenerator jacksonGenerator) throws IOException {
    if (bb.hasArray() && !bb.isReadOnly()) {
      jacksonGenerator.writeBinary(bb.array(), bb.arrayOffset(), bb.remaining());
    } else {
      byte[] bytes = new byte[bb.remaining()];
      bb.get(bytes);
      jacksonGenerator.writeBinary(bytes);
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy