Class SliceOutput

    • Constructor Summary

      Constructors 
      Constructor Description
      SliceOutput()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract SliceOutput appendByte​(int value)  
      abstract SliceOutput appendBytes​(byte[] source)  
      abstract SliceOutput appendBytes​(byte[] source, int sourceIndex, int length)  
      abstract SliceOutput appendBytes​(Slice slice)  
      abstract SliceOutput appendDouble​(double value)  
      abstract SliceOutput appendInt​(int value)  
      abstract SliceOutput appendLong​(long value)  
      abstract SliceOutput appendShort​(int value)  
      abstract long getRetainedSize()
      Approximate number of bytes retained by this.
      abstract Slice getUnderlyingSlice()
      Returns the raw underlying slice of this output stream.
      abstract boolean isWritable()
      Returns true if and only if (this.capacity - this.writerIndex) is greater than 0.
      abstract void reset()
      Resets this stream to the initial position.
      abstract void reset​(int position)
      Resets this stream to the specified position.
      abstract int size()
      Returns the writerIndex of this buffer.
      abstract Slice slice()
      Returns a slice of this buffer's readable bytes.
      abstract String toString​(Charset charset)
      Decodes this buffer's readable bytes into a string with the specified character set name.
      abstract int writableBytes()
      Returns the number of writable bytes which is equal to (this.capacity - this.writerIndex).
      void write​(byte[] source)  
      void write​(byte[] source, int sourceIndex, int length)  
      void write​(int value)  
      void writeBoolean​(boolean value)  
      abstract void writeByte​(int value)
      Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer.
      abstract 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).
      abstract 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).
      abstract 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.
      abstract 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).
      abstract 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 writeBytes​(String s)
      Unsupported operation
      void writeChar​(int value)
      Unsupported operation
      void writeChars​(String s)
      Unsupported operation
      abstract void writeDouble​(double value)
      Sets the specified 64-bit double at the current writerIndex and increases the writerIndex by 8 in this buffer.
      abstract void writeFloat​(float v)
      Sets the specified 32-bit float at the current writerIndex and increases the writerIndex by 4 in this buffer.
      abstract void writeInt​(int value)
      Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.
      abstract void writeLong​(long value)
      Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.
      abstract 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 writeUTF​(String s)
      Unsupported operation
      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

      • SliceOutput

        public SliceOutput()
    • Method Detail

      • reset

        public abstract void reset()
        Resets this stream to the initial position.
      • reset

        public abstract void reset​(int position)
        Resets this stream to the specified position.
      • size

        public abstract int size()
        Returns the writerIndex of this buffer.
      • getRetainedSize

        public abstract long getRetainedSize()
        Approximate number of bytes retained by this.
      • writableBytes

        public abstract int writableBytes()
        Returns the number of writable bytes which is equal to (this.capacity - this.writerIndex).
      • isWritable

        public abstract boolean isWritable()
        Returns true if and only if (this.capacity - this.writerIndex) is greater than 0.
      • writeBoolean

        public final void writeBoolean​(boolean value)
        Specified by:
        writeBoolean in interface DataOutput
      • writeByte

        public abstract void writeByte​(int value)
        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
        Throws:
        IndexOutOfBoundsException - if this.writableBytes is less than 1
      • writeShort

        public abstract void writeShort​(int value)
        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
        Throws:
        IndexOutOfBoundsException - if this.writableBytes is less than 2
      • writeInt

        public abstract void writeInt​(int value)
        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
        Throws:
        IndexOutOfBoundsException - if this.writableBytes is less than 4
      • writeLong

        public abstract void writeLong​(long value)
        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
        Throws:
        IndexOutOfBoundsException - if this.writableBytes is less than 8
      • writeFloat

        public abstract void writeFloat​(float v)
        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
        Throws:
        IndexOutOfBoundsException - if this.writableBytes is less than 4
      • writeDouble

        public abstract void writeDouble​(double value)
        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
        Throws:
        IndexOutOfBoundsException - if this.writableBytes is less than 8
      • writeBytes

        public abstract 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. This method is basically same with writeBytes(Slice, int, int), except that this method increases the readerIndex of the source buffer by the number of the transferred bytes while writeBytes(Slice, int, int) does not.
        Throws:
        IndexOutOfBoundsException - if source.readableBytes is greater than this.writableBytes
      • writeBytes

        public abstract 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).
        Parameters:
        sourceIndex - the first index of the source
        length - the number of bytes to transfer
        Throws:
        IndexOutOfBoundsException - if the specified sourceIndex is less than 0, if sourceIndex + length is greater than source.capacity, or if length is greater than this.writableBytes
      • writeBytes

        public abstract 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).
        Throws:
        IndexOutOfBoundsException - if source.length is greater than this.writableBytes
      • write

        public final void write​(byte[] source,
                                int sourceIndex,
                                int length)
        Specified by:
        write in interface DataOutput
        Overrides:
        write in class OutputStream
      • writeBytes

        public abstract 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).
        Parameters:
        sourceIndex - the first index of the source
        length - the number of bytes to transfer
        Throws:
        IndexOutOfBoundsException - if the specified sourceIndex is less than 0, if sourceIndex + length is greater than source.length, or if length is greater than this.writableBytes
      • writeBytes

        public abstract void writeBytes​(InputStream in,
                                        int length)
                                 throws IOException
        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.
        Parameters:
        length - the number of bytes to transfer
        Throws:
        IndexOutOfBoundsException - if length is greater than this.writableBytes
        IOException - if the specified stream threw an exception during I/O
      • writeZero

        public void writeZero​(int length)
        Fills this buffer with NUL (0x00) starting at the current writerIndex and increases the writerIndex by the specified length.
        Parameters:
        length - the number of NULs to write to the buffer
        Throws:
        IndexOutOfBoundsException - if length is greater than this.writableBytes
      • slice

        public abstract Slice slice()
        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.
      • getUnderlyingSlice

        public abstract Slice getUnderlyingSlice()
        Returns the raw underlying slice of this output stream. The slice may be larger than the size of this stream.
      • toString

        public abstract String toString​(Charset charset)
        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.
      • appendLong

        public abstract SliceOutput appendLong​(long value)
      • appendDouble

        public abstract SliceOutput appendDouble​(double value)
      • appendInt

        public abstract SliceOutput appendInt​(int value)
      • appendShort

        public abstract SliceOutput appendShort​(int value)
      • appendByte

        public abstract SliceOutput appendByte​(int value)
      • appendBytes

        public abstract SliceOutput appendBytes​(byte[] source,
                                                int sourceIndex,
                                                int length)
      • appendBytes

        public abstract SliceOutput appendBytes​(byte[] source)