Class ByteArrayBinaryData

java.lang.Object
org.opensearch.client.util.ByteArrayBinaryData
All Implemented Interfaces:
JsonpSerializable, BinaryData

@JsonpDeserializable public class ByteArrayBinaryData extends Object implements BinaryData
  • Field Details

  • Constructor Details

    • ByteArrayBinaryData

      public ByteArrayBinaryData(byte[] bytes, int offset, int length, String contentType)
    • ByteArrayBinaryData

      public ByteArrayBinaryData(byte[] bytes, String contentType)
    • ByteArrayBinaryData

      public ByteArrayBinaryData(BinaryData data) throws IOException
      Copy another BinaryData. Typically used to make a replayable BinaryData from a non-replayable one.
      Throws:
      IOException
  • Method Details

    • contentType

      public String contentType()
      Get the content type of this binary data.
      Specified by:
      contentType in interface BinaryData
      Returns:
      the content type (e.g., "application/json")
    • writeTo

      public void writeTo(OutputStream out) throws IOException
      Write this data to an output stream.
      Specified by:
      writeTo in interface BinaryData
      Throws:
      IOException
    • size

      public long size()
      Get the estimated size in bytes of the data.
      Specified by:
      size in interface BinaryData
      Returns:
      the estimated size, or -1 if the value cannot be estimated or if the data has already been consumed.
    • asByteBuffer

      public ByteBuffer asByteBuffer()
      Return this data as a ByteBuffer.
      Specified by:
      asByteBuffer in interface BinaryData
    • asInputStream

      public InputStream asInputStream()
      Return this data as an InputStream.
      Specified by:
      asInputStream in interface BinaryData
    • isRepeatable

      public boolean isRepeatable()
      Can this object be consumed several times?
      Specified by:
      isRepeatable in interface BinaryData
    • serialize

      public void serialize(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper)
      Specified by:
      serialize in interface JsonpSerializable