Class InputStreamBuffer

java.lang.Object
org.apache.tinkerpop.gremlin.driver.stream.InputStreamBuffer
All Implemented Interfaces:
Buffer

public class InputStreamBuffer extends Object implements Buffer
A read-only Buffer implementation backed by a blocking InputStream via DataInputStream. Supports only sequential read operations — all write, random-access, and NIO methods throw UnsupportedOperationException.

This allows the existing TypeSerializer implementations (which only use sequential reads) to work unchanged over a streaming HTTP response body.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the number of bytes (octets) this buffer can contain.
    getBytes(int index, byte[] dst)
    Transfers this buffer's data to the specified destination starting at the specified absolute index.
    boolean
    Returns true if and only if this buffer is backed by an NIO direct buffer.
    Marks the current writer index in this buffer.
    Exposes this buffer's readable bytes as a NIO ByteBuffer.
    nioBuffer(int index, int length)
    Exposes this buffer's sub-region as an NIO ByteBuffer.
    int
    Returns the maximum number of NIO ByteBuffers that consist this buffer.
    Exposes this buffer's readable bytes as NIO ByteBuffer's instances.
    nioBuffers(int index, int length)
    Exposes this buffer's readable bytes as NIO ByteBuffer's instances.
    int
    Returns the number of readable bytes.
    boolean
    Gets a boolean and advances the reader index.
    byte
    Gets a byte and advances the reader index.
    readBytes(byte[] destination)
    Transfers this buffer's data to the specified destination starting at the current reader index and advances the reader index.
    readBytes(byte[] destination, int dstIndex, int length)
    Transfers this buffer's data to the specified destination starting at the current reader index and advances the reader index.
    readBytes(OutputStream out, int length)
    Transfers this buffer's data to the specified stream starting at the current reader index and advances the index.
    Transfers this buffer's data to the specified destination starting at the current reader index until the destination's position reaches its limit, and advances the reader index.
    double
    Gets a 64-bit floating point number and advances the reader index.
    int
    Returns the reader index of this buffer.
    readerIndex(int readerIndex)
    Sets the reader index of this buffer.
    float
    Gets a 32-bit floating point number and advances the reader index.
    int
    Gets a 32-bit integer at the current index and advances the reader index.
    long
    Gets a 64-bit integer and advances the reader index.
    short
    Gets a 16-bit short integer and advances the reader index.
    int
    Returns the reference count of this object.
    boolean
    Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.
    Repositions the current writer index to the marked index in this buffer.
    Increases the reference count by 1.
    writeBoolean(boolean value)
    Sets the specified boolean at the current writer index and advances the index.
    writeByte(int value)
    Sets the specified byte at the current writer index and advances the index.
    writeBytes(byte[] src)
    Transfers the specified source array's data to this buffer starting at the current writer index and advances the index.
    writeBytes(byte[] src, int srcIndex, int length)
    Transfers the specified source array's data to this buffer starting at the current writer index and advances the index.
    Transfers the specified source byte data to this buffer starting at the current writer index and advances the index.
    writeDouble(double value)
    Sets the specified 64-bit floating point number at the current writer index and advances the index.
    writeFloat(float value)
    Sets the specified 32-bit floating point number at the current writer index and advances the index.
    writeInt(int value)
    Sets the specified 32-bit integer at the current writer index and advances the index.
    writeLong(long value)
    Sets the specified 64-bit long integer at the current writer index and advances the index.
    int
    Returns the writer index of this buffer.
    writerIndex(int writerIndex)
    Sets the writer index of this buffer.
    writeShort(int value)
    Sets the specified 16-bit short integer at the current writer index and advances the index.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InputStreamBuffer

      public InputStreamBuffer(InputStream inputStream)
  • Method Details

    • readBoolean

      public boolean readBoolean()
      Description copied from interface: Buffer
      Gets a boolean and advances the reader index.
      Specified by:
      readBoolean in interface Buffer
    • readByte

      public byte readByte()
      Description copied from interface: Buffer
      Gets a byte and advances the reader index.
      Specified by:
      readByte in interface Buffer
    • readShort

      public short readShort()
      Description copied from interface: Buffer
      Gets a 16-bit short integer and advances the reader index.
      Specified by:
      readShort in interface Buffer
    • readInt

      public int readInt()
      Description copied from interface: Buffer
      Gets a 32-bit integer at the current index and advances the reader index.
      Specified by:
      readInt in interface Buffer
    • readLong

      public long readLong()
      Description copied from interface: Buffer
      Gets a 64-bit integer and advances the reader index.
      Specified by:
      readLong in interface Buffer
    • readFloat

      public float readFloat()
      Description copied from interface: Buffer
      Gets a 32-bit floating point number and advances the reader index.
      Specified by:
      readFloat in interface Buffer
    • readDouble

      public double readDouble()
      Description copied from interface: Buffer
      Gets a 64-bit floating point number and advances the reader index.
      Specified by:
      readDouble in interface Buffer
    • readBytes

      public Buffer readBytes(byte[] destination)
      Description copied from interface: Buffer
      Transfers this buffer's data to the specified destination starting at the current reader index and advances the reader index.
      Specified by:
      readBytes in interface Buffer
    • readBytes

      public Buffer readBytes(byte[] destination, int dstIndex, int length)
      Description copied from interface: Buffer
      Transfers this buffer's data to the specified destination starting at the current reader index and advances the reader index.
      Specified by:
      readBytes in interface Buffer
      Parameters:
      destination - The destination buffer
      dstIndex - the first index of the destination
      length - the number of bytes to transfer
    • readBytes

      public Buffer readBytes(ByteBuffer dst)
      Description copied from interface: Buffer
      Transfers this buffer's data to the specified destination starting at the current reader index until the destination's position reaches its limit, and advances the reader index.
      Specified by:
      readBytes in interface Buffer
    • readBytes

      public Buffer readBytes(OutputStream out, int length) throws IOException
      Description copied from interface: Buffer
      Transfers this buffer's data to the specified stream starting at the current reader index and advances the index.
      Specified by:
      readBytes in interface Buffer
      length - the number of bytes to transfer
      Throws:
      IOException - if the specified stream threw an exception during I/O
    • readerIndex

      public int readerIndex()
      Description copied from interface: Buffer
      Returns the reader index of this buffer.
      Specified by:
      readerIndex in interface Buffer
    • readableBytes

      public int readableBytes()
      Description copied from interface: Buffer
      Returns the number of readable bytes.
      Specified by:
      readableBytes in interface Buffer
    • readerIndex

      public Buffer readerIndex(int readerIndex)
      Description copied from interface: Buffer
      Sets the reader index of this buffer.
      Specified by:
      readerIndex in interface Buffer
    • writerIndex

      public int writerIndex()
      Description copied from interface: Buffer
      Returns the writer index of this buffer.
      Specified by:
      writerIndex in interface Buffer
    • writerIndex

      public Buffer writerIndex(int writerIndex)
      Description copied from interface: Buffer
      Sets the writer index of this buffer.
      Specified by:
      writerIndex in interface Buffer
    • markWriterIndex

      public Buffer markWriterIndex()
      Description copied from interface: Buffer
      Marks the current writer index in this buffer.
      Specified by:
      markWriterIndex in interface Buffer
    • resetWriterIndex

      public Buffer resetWriterIndex()
      Description copied from interface: Buffer
      Repositions the current writer index to the marked index in this buffer.
      Specified by:
      resetWriterIndex in interface Buffer
    • capacity

      public int capacity()
      Description copied from interface: Buffer
      Returns the number of bytes (octets) this buffer can contain.
      Specified by:
      capacity in interface Buffer
    • isDirect

      public boolean isDirect()
      Description copied from interface: Buffer
      Returns true if and only if this buffer is backed by an NIO direct buffer.
      Specified by:
      isDirect in interface Buffer
    • writeBoolean

      public Buffer writeBoolean(boolean value)
      Description copied from interface: Buffer
      Sets the specified boolean at the current writer index and advances the index.
      Specified by:
      writeBoolean in interface Buffer
    • writeByte

      public Buffer writeByte(int value)
      Description copied from interface: Buffer
      Sets the specified byte at the current writer index and advances the index.
      Specified by:
      writeByte in interface Buffer
    • writeShort

      public Buffer writeShort(int value)
      Description copied from interface: Buffer
      Sets the specified 16-bit short integer at the current writer index and advances the index.
      Specified by:
      writeShort in interface Buffer
    • writeInt

      public Buffer writeInt(int value)
      Description copied from interface: Buffer
      Sets the specified 32-bit integer at the current writer index and advances the index.
      Specified by:
      writeInt in interface Buffer
    • writeLong

      public Buffer writeLong(long value)
      Description copied from interface: Buffer
      Sets the specified 64-bit long integer at the current writer index and advances the index.
      Specified by:
      writeLong in interface Buffer
    • writeFloat

      public Buffer writeFloat(float value)
      Description copied from interface: Buffer
      Sets the specified 32-bit floating point number at the current writer index and advances the index.
      Specified by:
      writeFloat in interface Buffer
    • writeDouble

      public Buffer writeDouble(double value)
      Description copied from interface: Buffer
      Sets the specified 64-bit floating point number at the current writer index and advances the index.
      Specified by:
      writeDouble in interface Buffer
    • writeBytes

      public Buffer writeBytes(byte[] src)
      Description copied from interface: Buffer
      Transfers the specified source array's data to this buffer starting at the current writer index and advances the index.
      Specified by:
      writeBytes in interface Buffer
    • writeBytes

      public Buffer writeBytes(ByteBuffer src)
      Description copied from interface: Buffer
      Transfers the specified source byte data to this buffer starting at the current writer index and advances the index.
      Specified by:
      writeBytes in interface Buffer
    • writeBytes

      public Buffer writeBytes(byte[] src, int srcIndex, int length)
      Description copied from interface: Buffer
      Transfers the specified source array's data to this buffer starting at the current writer index and advances the index.
      Specified by:
      writeBytes in interface Buffer
    • release

      public boolean release()
      Description copied from interface: Buffer
      Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.
      Specified by:
      release in interface Buffer
    • retain

      public Buffer retain()
      Description copied from interface: Buffer
      Increases the reference count by 1.
      Specified by:
      retain in interface Buffer
    • referenceCount

      public int referenceCount()
      Description copied from interface: Buffer
      Returns the reference count of this object.
      Specified by:
      referenceCount in interface Buffer
    • nioBufferCount

      public int nioBufferCount()
      Description copied from interface: Buffer
      Returns the maximum number of NIO ByteBuffers that consist this buffer.
      Specified by:
      nioBufferCount in interface Buffer
    • nioBuffers

      public ByteBuffer[] nioBuffers()
      Description copied from interface: Buffer
      Exposes this buffer's readable bytes as NIO ByteBuffer's instances.
      Specified by:
      nioBuffers in interface Buffer
    • nioBuffers

      public ByteBuffer[] nioBuffers(int index, int length)
      Description copied from interface: Buffer
      Exposes this buffer's readable bytes as NIO ByteBuffer's instances.
      Specified by:
      nioBuffers in interface Buffer
    • nioBuffer

      public ByteBuffer nioBuffer()
      Description copied from interface: Buffer
      Exposes this buffer's readable bytes as a NIO ByteBuffer. The returned buffer either share or contains the copied content of this buffer, while changing the position and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.
      Specified by:
      nioBuffer in interface Buffer
    • nioBuffer

      public ByteBuffer nioBuffer(int index, int length)
      Description copied from interface: Buffer
      Exposes this buffer's sub-region as an NIO ByteBuffer.
      Specified by:
      nioBuffer in interface Buffer
    • getBytes

      public Buffer getBytes(int index, byte[] dst)
      Description copied from interface: Buffer
      Transfers this buffer's data to the specified destination starting at the specified absolute index. This method does not modify reader or writer indexes.
      Specified by:
      getBytes in interface Buffer