Class DataByteArrayInputStream

java.lang.Object
java.io.InputStream
org.apache.activemq.store.kahadb.disk.util.DataByteArrayInputStream
All Implemented Interfaces:
Closeable, DataInput, AutoCloseable

public final class DataByteArrayInputStream extends InputStream implements DataInput, AutoCloseable
Optimized ByteArrayInputStream that can be used more than once
  • Constructor Details

    • DataByteArrayInputStream

      public DataByteArrayInputStream(byte[] buf)
      Creates a StoreByteArrayInputStream.
      Parameters:
      buf - the input buffer.
    • DataByteArrayInputStream

      public DataByteArrayInputStream(ByteSequence sequence)
      Creates a StoreByteArrayInputStream.
      Parameters:
      sequence - the input buffer.
    • DataByteArrayInputStream

      public DataByteArrayInputStream()
      Creates WireByteArrayInputStream with a minmalist byte array
  • Method Details

    • size

      public int size()
      Returns:
      the size
    • getRawData

      public byte[] getRawData()
      Returns:
      the underlying data array
    • restart

      public void restart(byte[] newBuff)
      reset the StoreByteArrayInputStream to use an new byte array
      Parameters:
      newBuff -
    • restart

      public void restart()
    • restart

      public void restart(ByteSequence sequence)
      reset the StoreByteArrayInputStream to use an new ByteSequence
      Parameters:
      sequence -
    • restart

      public void restart(int size)
      re-start the input stream - reusing the current buffer
      Parameters:
      size -
    • read

      public int read()
      Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.

      This read method cannot block.

      Specified by:
      read in class InputStream
      Returns:
      the next byte of data, or -1 if the end of the stream has been reached.
    • read

      public int read(byte[] b, int off, int len)
      Reads up to len bytes of data into an array of bytes from this input stream.
      Overrides:
      read in class InputStream
      Parameters:
      b - the buffer into which the data is read.
      off - the start offset of the data.
      len - the maximum number of bytes read.
      Returns:
      the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
    • available

      public int available()
      Overrides:
      available in class InputStream
      Returns:
      the number of bytes that can be read from the input stream without blocking.
    • readFully

      public void readFully(byte[] b)
      Specified by:
      readFully in interface DataInput
    • readFully

      public void readFully(byte[] b, int off, int len)
      Specified by:
      readFully in interface DataInput
    • skipBytes

      public int skipBytes(int n)
      Specified by:
      skipBytes in interface DataInput
    • readBoolean

      public boolean readBoolean()
      Specified by:
      readBoolean in interface DataInput
    • readByte

      public byte readByte()
      Specified by:
      readByte in interface DataInput
    • readUnsignedByte

      public int readUnsignedByte()
      Specified by:
      readUnsignedByte in interface DataInput
    • readShort

      public short readShort()
      Specified by:
      readShort in interface DataInput
    • readUnsignedShort

      public int readUnsignedShort()
      Specified by:
      readUnsignedShort in interface DataInput
    • readChar

      public char readChar()
      Specified by:
      readChar in interface DataInput
    • readInt

      public int readInt()
      Specified by:
      readInt in interface DataInput
    • readLong

      public long readLong()
      Specified by:
      readLong in interface DataInput
    • readFloat

      public float readFloat() throws IOException
      Specified by:
      readFloat in interface DataInput
      Throws:
      IOException
    • readDouble

      public double readDouble() throws IOException
      Specified by:
      readDouble in interface DataInput
      Throws:
      IOException
    • readLine

      public String readLine()
      Specified by:
      readLine in interface DataInput
    • readUTF

      public String readUTF() throws IOException
      Specified by:
      readUTF in interface DataInput
      Throws:
      IOException
    • getPos

      public int getPos()
    • setPos

      public void setPos(int pos)
    • getLength

      public int getLength()
    • setLength

      public void setLength(int length)