Class FastByteArrayOutputStream

java.lang.Object
java.io.OutputStream
com.espertech.esper.common.internal.serde.serdeset.builtin.FastByteArrayOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class FastByteArrayOutputStream extends OutputStream
Output on fast byte array output stream.
  • Field Details

    • DEFAULT_INITIAL_SIZE

      public static final int DEFAULT_INITIAL_SIZE
      Buffer initial size.
      See Also:
    • DEFAULT_INCREASE_SIZE

      public static final int DEFAULT_INCREASE_SIZE
      Buffer increase size, zero means double.
      See Also:
  • Constructor Details

    • FastByteArrayOutputStream

      public FastByteArrayOutputStream(byte[] buffer)
      Ctor.
      Parameters:
      buffer - to write
    • FastByteArrayOutputStream

      public FastByteArrayOutputStream(byte[] buffer, int increase)
      Ctor.
      Parameters:
      buffer - to write
      increase - zero for
    • FastByteArrayOutputStream

      public FastByteArrayOutputStream()
      Ctor.
    • FastByteArrayOutputStream

      public FastByteArrayOutputStream(int initialSize)
      Ctor.
      Parameters:
      initialSize - initial size
    • FastByteArrayOutputStream

      public FastByteArrayOutputStream(int initialSize, int increaseSize)
      Ctor.
      Parameters:
      initialSize - initial size
      increaseSize - increase size
  • Method Details

    • size

      public int size()
      Returns buffer size.
      Returns:
      size
    • reset

      public void reset()
      Reset buffer.
    • write

      public void write(int b) throws IOException
      Write byte.
      Specified by:
      write in class OutputStream
      Parameters:
      b - byte to write
      Throws:
      IOException - for io errors
    • write

      public void write(byte[] fromBuf) throws IOException
      Overrides:
      write in class OutputStream
      Throws:
      IOException
    • write

      public void write(byte[] fromBuf, int offset, int length) throws IOException
      Overrides:
      write in class OutputStream
      Throws:
      IOException
    • writeTo

      public void writeTo(OutputStream out) throws IOException
      Write bytes to another stream.
      Parameters:
      out - other stream
      Throws:
      IOException - if a write exception occurs
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(String encoding) throws UnsupportedEncodingException
      Outputs contents.
      Parameters:
      encoding - to use
      Returns:
      contents
      Throws:
      UnsupportedEncodingException - when encoding is not supported
    • getByteArrayWithCopy

      public byte[] getByteArrayWithCopy()
      Returns the byte array.
      Returns:
      byte array
    • getByteArrayFast

      public byte[] getByteArrayFast()
      Fast getter checking if the byte array matches the requested length and returnin the buffer itself if it does.
      Returns:
      byte array without offset
    • writeFast

      public final void writeFast(int b)
      Fast write.
      Parameters:
      b - byte to write
    • writeFast

      public final void writeFast(byte[] fromBuf)
      Fast write.
      Parameters:
      fromBuf - to write
    • writeFast

      public final void writeFast(byte[] fromBuf, int offset, int length)
      Fast write.
      Parameters:
      fromBuf - buffer to write
      offset - offset of write from
      length - length to write
    • getBufferBytes

      public byte[] getBufferBytes()
      Returns the buffer itself.
      Returns:
      buffer
    • getBufferOffset

      public int getBufferOffset()
      Returns the offset, always zero.
      Returns:
      offset
    • getBufferLength

      public int getBufferLength()
      Returns the length.
      Returns:
      length
    • makeSpace

      public void makeSpace(int sizeNeeded)
      Increase buffer size.
      Parameters:
      sizeNeeded - bytes needed.
    • addSize

      public void addSize(int sizeAdded)
      Add number of bytes to size.
      Parameters:
      sizeAdded - to be added