Class OutputStreamSliceOutput

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      SliceOutput appendByte​(int value)  
      SliceOutput appendBytes​(byte[] source)  
      SliceOutput appendBytes​(byte[] source, int sourceIndex, int length)  
      SliceOutput appendBytes​(Slice slice)  
      SliceOutput appendDouble​(double value)  
      SliceOutput appendInt​(int value)  
      SliceOutput appendLong​(long value)  
      SliceOutput appendShort​(int value)  
      void close()  
      void flush()  
      long getRetainedSize()
      Approximate number of bytes retained by this.
      Slice getUnderlyingSlice()
      Returns the raw underlying slice of this output stream.
      boolean isWritable()
      Returns true if and only if (this.capacity - this.writerIndex) is greater than 0.
      long longSize()  
      void reset()
      Resets this stream to the initial position.
      void reset​(int position)
      Resets this stream to the specified position.
      int size()
      Returns the writerIndex of this buffer.
      Slice slice()
      Returns a slice of this buffer's readable bytes.
      String toString()  
      String toString​(Charset charset)
      Decodes this buffer's readable bytes into a string with the specified character set name.
      int writableBytes()
      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 writeFloat​(float value)
      Sets the specified 32-bit float at the current writerIndex and increases the writerIndex by 4 in this buffer.
      void writeInt​(int value)
      Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.
      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 writeShort​(int value)
      Sets the specified 16-bit short integer at the current writerIndex and increases the writerIndex by 2 in this buffer.
      void writeZero​(int length)
      Fills this buffer with NUL (0x00) starting at the current writerIndex and increases the writerIndex by the specified length.
    • Constructor Detail

      • OutputStreamSliceOutput

        public OutputStreamSliceOutput​(OutputStream inputStream)
      • OutputStreamSliceOutput

        public OutputStreamSliceOutput​(OutputStream outputStream,
                                       int bufferSize)
    • Method Detail

      • 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
      • longSize

        public long longSize()
      • getRetainedSize

        public long getRetainedSize()
        Description copied from class: SliceOutput
        Approximate number of bytes retained by this.
        Specified by:
        getRetainedSize 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
      • 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
      • 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​(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​(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
      • 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
      • 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
      • 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​(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