Class DynamicSliceOutput

All Implemented Interfaces:
Closeable, DataOutput, Flushable, AutoCloseable

public class DynamicSliceOutput extends SliceOutput
  • Constructor Summary

    Constructors
    Constructor
    Description
    DynamicSliceOutput(int estimatedSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    appendByte(int value)
     
    appendBytes(byte[] source)
     
    appendBytes(byte[] source, int sourceIndex, int length)
     
     
    appendDouble(double value)
     
    appendInt(int value)
     
    appendLong(long value)
     
    appendShort(int value)
     
     
    long
    Approximate number of bytes retained by this.
    Returns the raw underlying slice of this output stream.
    boolean
    Returns true if and only if (this.capacity - this.writerIndex) is greater than 0.
    void
    Resets this stream to the initial position.
    void
    reset(int position)
    Resets this stream to the specified position.
    int
    Returns the writerIndex of this buffer.
    Returns a slice of this buffer's readable bytes.
     
    toString(Charset charset)
    Decodes this buffer's readable bytes into a string with the specified character set name.
    int
    Returns the number of writable bytes which is equal to (this.capacity - this.writerIndex).
    void
    writeByte(int value)
    Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer.
    void
    writeBytes(byte[] source)
    Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= source.length).
    void
    writeBytes(byte[] source, int sourceIndex, int length)
    Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
    void
    writeBytes(Slice source)
    Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer becomes unreadable, and increases the writerIndex by the number of the transferred bytes.
    void
    writeBytes(Slice source, int sourceIndex, int length)
    Transfers the specified source buffer's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
    void
    writeBytes(InputStream in, int length)
    Transfers the content of the specified stream to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes.
    void
    writeDouble(double value)
    Sets the specified 64-bit double at the current writerIndex and increases the writerIndex by 8 in this buffer.
    void
    writeDoubles(double[] source, int sourceIndex, int length)
    Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred doubles.
    void
    writeFloat(float value)
    Sets the specified 32-bit float at the current writerIndex and increases the writerIndex by 4 in this buffer.
    void
    writeFloats(float[] source, int sourceIndex, int length)
    Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred floats.
    void
    writeInt(int value)
    Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.
    void
    writeInts(int[] source, int sourceIndex, int length)
    Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred ints.
    void
    writeLong(long value)
    Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.
    void
    writeLongs(long[] source, int sourceIndex, int length)
    Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred longs.
    void
    writeShort(int value)
    Sets the specified 16-bit short integer at the current writerIndex and increases the writerIndex by 2 in this buffer.
    void
    writeShorts(short[] source, int sourceIndex, int length)
    Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred shorts.
    void
    writeZero(int length)
    Fills this buffer with NUL (0x00) starting at the current writerIndex and increases the writerIndex by the specified length.

    Methods inherited from class java.io.OutputStream

    close, flush, nullOutputStream

    Methods inherited from class java.lang.Object

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

    • DynamicSliceOutput

      public DynamicSliceOutput(int estimatedSize)
  • Method Details

    • reset

      public void reset()
      Description copied from class: SliceOutput
      Resets this stream to the initial position.
      Specified by:
      reset in class SliceOutput
    • reset

      public void reset(int position)
      Description copied from class: SliceOutput
      Resets this stream to the specified position.
      Specified by:
      reset in class SliceOutput
    • size

      public int size()
      Description copied from class: SliceOutput
      Returns the writerIndex of this buffer.
      Specified by:
      size in class SliceOutput
    • getRetainedSize

      public long getRetainedSize()
      Description copied from class: SliceOutput
      Approximate number of bytes retained by this.
      Specified by:
      getRetainedSize in class SliceOutput
    • isWritable

      public boolean isWritable()
      Description copied from class: SliceOutput
      Returns true if and only if (this.capacity - this.writerIndex) is greater than 0.
      Specified by:
      isWritable in class SliceOutput
    • writableBytes

      public int writableBytes()
      Description copied from class: SliceOutput
      Returns the number of writable bytes which is equal to (this.capacity - this.writerIndex).
      Specified by:
      writableBytes in class SliceOutput
    • writeByte

      public void writeByte(int value)
      Description copied from class: SliceOutput
      Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer. The 24 high-order bits of the specified value are ignored.
      Specified by:
      writeByte in interface DataOutput
      Specified by:
      writeByte in class SliceOutput
    • writeShort

      public void writeShort(int value)
      Description copied from class: SliceOutput
      Sets the specified 16-bit short integer at the current writerIndex and increases the writerIndex by 2 in this buffer. The 16 high-order bits of the specified value are ignored.
      Specified by:
      writeShort in interface DataOutput
      Specified by:
      writeShort in class SliceOutput
    • writeInt

      public void writeInt(int value)
      Description copied from class: SliceOutput
      Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.
      Specified by:
      writeInt in interface DataOutput
      Specified by:
      writeInt in class SliceOutput
    • writeLong

      public void writeLong(long value)
      Description copied from class: SliceOutput
      Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.
      Specified by:
      writeLong in interface DataOutput
      Specified by:
      writeLong in class SliceOutput
    • writeFloat

      public void writeFloat(float value)
      Description copied from class: SliceOutput
      Sets the specified 32-bit float at the current writerIndex and increases the writerIndex by 4 in this buffer.
      Specified by:
      writeFloat in interface DataOutput
      Specified by:
      writeFloat in class SliceOutput
    • writeDouble

      public void writeDouble(double value)
      Description copied from class: SliceOutput
      Sets the specified 64-bit double at the current writerIndex and increases the writerIndex by 8 in this buffer.
      Specified by:
      writeDouble in interface DataOutput
      Specified by:
      writeDouble in class SliceOutput
    • writeBytes

      public void writeBytes(byte[] source)
      Description copied from class: SliceOutput
      Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= source.length).
      Specified by:
      writeBytes in class SliceOutput
    • writeBytes

      public void writeBytes(byte[] source, int sourceIndex, int length)
      Description copied from class: SliceOutput
      Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
      Specified by:
      writeBytes in class SliceOutput
      sourceIndex - the first index of the source
      length - the number of bytes to transfer
    • writeShorts

      public void writeShorts(short[] source, int sourceIndex, int length)
      Description copied from class: SliceOutput
      Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred shorts.
      Specified by:
      writeShorts in class SliceOutput
      sourceIndex - the first index of the source
      length - the number of shorts to transfer
    • writeInts

      public void writeInts(int[] source, int sourceIndex, int length)
      Description copied from class: SliceOutput
      Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred ints.
      Specified by:
      writeInts in class SliceOutput
      sourceIndex - the first index of the source
      length - the number of ints to transfer
    • writeLongs

      public void writeLongs(long[] source, int sourceIndex, int length)
      Description copied from class: SliceOutput
      Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred longs.
      Specified by:
      writeLongs in class SliceOutput
      sourceIndex - the first index of the source
      length - the number of longs to transfer
    • writeFloats

      public void writeFloats(float[] source, int sourceIndex, int length)
      Description copied from class: SliceOutput
      Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred floats.
      Specified by:
      writeFloats in class SliceOutput
      sourceIndex - the first index of the source
      length - the number of floats to transfer
    • writeDoubles

      public void writeDoubles(double[] source, int sourceIndex, int length)
      Description copied from class: SliceOutput
      Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred doubles.
      Specified by:
      writeDoubles in class SliceOutput
      sourceIndex - the first index of the source
      length - the number of doubles to transfer
    • writeBytes

      public void writeBytes(Slice source)
      Description copied from class: SliceOutput
      Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer becomes unreadable, and increases the writerIndex by the number of the transferred bytes. This method is basically same with SliceOutput.writeBytes(Slice, int, int), except that this method increases the readerIndex of the source buffer by the number of the transferred bytes while SliceOutput.writeBytes(Slice, int, int) does not.
      Specified by:
      writeBytes in class SliceOutput
    • writeBytes

      public void writeBytes(Slice source, int sourceIndex, int length)
      Description copied from class: SliceOutput
      Transfers the specified source buffer's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
      Specified by:
      writeBytes in class SliceOutput
      sourceIndex - the first index of the source
      length - the number of bytes to transfer
    • writeBytes

      public void writeBytes(InputStream in, int length) throws IOException
      Description copied from class: SliceOutput
      Transfers the content of the specified stream to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes.
      Specified by:
      writeBytes in class SliceOutput
      length - the number of bytes to transfer
      Throws:
      IOException - if the specified stream threw an exception during I/O
    • writeZero

      public void writeZero(int length)
      Description copied from class: SliceOutput
      Fills this buffer with NUL (0x00) starting at the current writerIndex and increases the writerIndex by the specified length.
      Overrides:
      writeZero in class SliceOutput
      Parameters:
      length - the number of NULs to write to the buffer
    • appendLong

      public DynamicSliceOutput appendLong(long value)
      Specified by:
      appendLong in class SliceOutput
    • appendDouble

      public DynamicSliceOutput appendDouble(double value)
      Specified by:
      appendDouble in class SliceOutput
    • appendInt

      public DynamicSliceOutput appendInt(int value)
      Specified by:
      appendInt in class SliceOutput
    • appendShort

      public DynamicSliceOutput appendShort(int value)
      Specified by:
      appendShort in class SliceOutput
    • appendByte

      public DynamicSliceOutput appendByte(int value)
      Specified by:
      appendByte in class SliceOutput
    • appendBytes

      public DynamicSliceOutput appendBytes(byte[] source, int sourceIndex, int length)
      Specified by:
      appendBytes in class SliceOutput
    • appendBytes

      public DynamicSliceOutput appendBytes(byte[] source)
      Specified by:
      appendBytes in class SliceOutput
    • appendBytes

      public DynamicSliceOutput appendBytes(Slice slice)
      Specified by:
      appendBytes in class SliceOutput
    • slice

      public Slice slice()
      Description copied from class: SliceOutput
      Returns a slice of this buffer's readable bytes. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method is identical to buf.slice(buf.readerIndex(), buf.readableBytes()). This method does not modify readerIndex or writerIndex of this buffer.
      Specified by:
      slice in class SliceOutput
    • copySlice

      public Slice copySlice()
    • getUnderlyingSlice

      public Slice getUnderlyingSlice()
      Description copied from class: SliceOutput
      Returns the raw underlying slice of this output stream. The slice may be larger than the size of this stream.
      Specified by:
      getUnderlyingSlice in class SliceOutput
    • toString

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

      public String toString(Charset charset)
      Description copied from class: SliceOutput
      Decodes this buffer's readable bytes into a string with the specified character set name. This method is identical to buf.toString(buf.readerIndex(), buf.readableBytes(), charsetName). This method does not modify readerIndex or writerIndex of this buffer.
      Specified by:
      toString in class SliceOutput