Class SliceInput

    • Constructor Summary

      Constructors 
      Constructor Description
      SliceInput()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract int available()
      Returns the number of bytes that can be read without blocking.
      void close()  
      abstract long getRetainedSize()
      Approximate number of bytes retained by this instance.
      abstract boolean isReadable()
      Returns true if and only if available() is greater than 0.
      void mark​(int readLimit)  
      boolean markSupported()  
      abstract long position()
      Returns the position of this buffer.
      abstract int read()  
      int read​(byte[] destination)  
      abstract int read​(byte[] destination, int destinationIndex, int length)  
      abstract boolean readBoolean()
      Returns true if the byte at the current position is not 0 and increases the position by 1 in this buffer.
      abstract byte readByte()
      Gets a byte at the current position and increases the position by 1 in this buffer.
      void readBytes​(byte[] destination)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= dst.length).
      abstract void readBytes​(byte[] destination, int destinationIndex, int length)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length).
      void readBytes​(Slice destination)
      Transfers this buffer's data to the specified destination starting at the current position until the destination becomes non-writable, and increases the position by the number of the transferred bytes.
      void readBytes​(Slice destination, int length)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length).
      abstract void readBytes​(Slice destination, int destinationIndex, int length)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length).
      abstract void readBytes​(OutputStream out, int length)
      Transfers this buffer's data to the specified stream starting at the current position.
      char readChar()  
      abstract double readDouble()
      Gets a 64-bit double at the current position and increases the position by 8 in this buffer.
      abstract float readFloat()
      Gets a 32-bit float at the current position and increases the position by 4 in this buffer.
      void readFully​(byte[] destination)  
      void readFully​(byte[] destination, int offset, int length)  
      abstract int readInt()
      Gets a 32-bit integer at the current position and increases the position by 4 in this buffer.
      String readLine()  
      abstract long readLong()
      Gets a 64-bit long at the current position and increases the position by 8 in this buffer.
      abstract short readShort()
      Gets a 16-bit short integer at the current position and increases the position by 2 in this buffer.
      abstract Slice readSlice​(int length)
      Returns a new slice of this buffer's sub-region starting at the current position and increases the position by the size of the new slice (= length).
      abstract int readUnsignedByte()
      Gets an unsigned byte at the current position and increases the position by 1 in this buffer.
      long readUnsignedInt()
      Gets an unsigned 32-bit integer at the current position and increases the position by 4 in this buffer.
      abstract int readUnsignedShort()
      Gets an unsigned 16-bit short integer at the current position and increases the position by 2 in this buffer.
      String readUTF()  
      void reset()  
      abstract void setPosition​(long position)
      Sets the position of this buffer.
      abstract long skip​(long length)  
      abstract int skipBytes​(int length)  
    • Constructor Detail

      • SliceInput

        public SliceInput()
    • Method Detail

      • position

        public abstract long position()
        Returns the position of this buffer.
      • setPosition

        public abstract void setPosition​(long position)
        Sets the position of this buffer.
        Throws:
        IndexOutOfBoundsException - if the specified position is less than 0 or greater than this.writerIndex
      • isReadable

        public abstract boolean isReadable()
        Returns true if and only if available() is greater than 0.
      • available

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

        public abstract int read()
        Specified by:
        read in class InputStream
      • readBoolean

        public abstract boolean readBoolean()
        Returns true if the byte at the current position is not 0 and increases the position by 1 in this buffer.
        Specified by:
        readBoolean in interface DataInput
        Throws:
        IndexOutOfBoundsException - if this.available() is less than 1
      • readByte

        public abstract byte readByte()
        Gets a byte at the current position and increases the position by 1 in this buffer.
        Specified by:
        readByte in interface DataInput
        Throws:
        IndexOutOfBoundsException - if this.available() is less than 1
      • readUnsignedByte

        public abstract int readUnsignedByte()
        Gets an unsigned byte at the current position and increases the position by 1 in this buffer.
        Specified by:
        readUnsignedByte in interface DataInput
        Throws:
        IndexOutOfBoundsException - if this.available() is less than 1
      • readShort

        public abstract short readShort()
        Gets a 16-bit short integer at the current position and increases the position by 2 in this buffer.
        Specified by:
        readShort in interface DataInput
        Throws:
        IndexOutOfBoundsException - if this.available() is less than 2
      • readUnsignedShort

        public abstract int readUnsignedShort()
        Gets an unsigned 16-bit short integer at the current position and increases the position by 2 in this buffer.
        Specified by:
        readUnsignedShort in interface DataInput
        Throws:
        IndexOutOfBoundsException - if this.available() is less than 2
      • readInt

        public abstract int readInt()
        Gets a 32-bit integer at the current position and increases the position by 4 in this buffer.
        Specified by:
        readInt in interface DataInput
        Throws:
        IndexOutOfBoundsException - if this.available() is less than 4
      • readUnsignedInt

        public final long readUnsignedInt()
        Gets an unsigned 32-bit integer at the current position and increases the position by 4 in this buffer.
        Throws:
        IndexOutOfBoundsException - if this.available() is less than 4
      • readLong

        public abstract long readLong()
        Gets a 64-bit long at the current position and increases the position by 8 in this buffer.
        Specified by:
        readLong in interface DataInput
        Throws:
        IndexOutOfBoundsException - if this.available() is less than 8
      • readFloat

        public abstract float readFloat()
        Gets a 32-bit float at the current position and increases the position by 4 in this buffer.
        Specified by:
        readFloat in interface DataInput
        Throws:
        IndexOutOfBoundsException - if this.available() is less than 4
      • readDouble

        public abstract double readDouble()
        Gets a 64-bit double at the current position and increases the position by 8 in this buffer.
        Specified by:
        readDouble in interface DataInput
        Throws:
        IndexOutOfBoundsException - if this.available() is less than 8
      • readSlice

        public abstract Slice readSlice​(int length)
        Returns a new slice of this buffer's sub-region starting at the current position and increases the position by the size of the new slice (= length).
        Parameters:
        length - the size of the new slice
        Returns:
        the newly created slice
        Throws:
        IndexOutOfBoundsException - if length is greater than this.available()
      • readFully

        public final void readFully​(byte[] destination)
        Specified by:
        readFully in interface DataInput
      • read

        public final int read​(byte[] destination)
        Overrides:
        read in class InputStream
      • read

        public abstract int read​(byte[] destination,
                                 int destinationIndex,
                                 int length)
        Overrides:
        read in class InputStream
      • readBytes

        public final void readBytes​(byte[] destination)
        Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= dst.length).
        Throws:
        IndexOutOfBoundsException - if dst.length is greater than this.available()
      • readFully

        public final void readFully​(byte[] destination,
                                    int offset,
                                    int length)
        Specified by:
        readFully in interface DataInput
      • readBytes

        public abstract void readBytes​(byte[] destination,
                                       int destinationIndex,
                                       int length)
        Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length).
        Parameters:
        destinationIndex - the first index of the destination
        length - the number of bytes to transfer
        Throws:
        IndexOutOfBoundsException - if the specified destinationIndex is less than 0, if length is greater than this.available(), or if destinationIndex + length is greater than destination.length
      • readBytes

        public final void readBytes​(Slice destination)
        Transfers this buffer's data to the specified destination starting at the current position until the destination becomes non-writable, and increases the position by the number of the transferred bytes. This method is basically same with readBytes(Slice, int, int), except that this method increases the writerIndex of the destination by the number of the transferred bytes while readBytes(Slice, int, int) does not.
        Throws:
        IndexOutOfBoundsException - if destination.writableBytes is greater than this.available()
      • readBytes

        public final void readBytes​(Slice destination,
                                    int length)
        Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length). This method is basically same with readBytes(Slice, int, int), except that this method increases the writerIndex of the destination by the number of the transferred bytes (= length) while readBytes(Slice, int, int) does not.
        Throws:
        IndexOutOfBoundsException - if length is greater than this.available() or if length is greater than destination.writableBytes
      • readBytes

        public abstract void readBytes​(Slice destination,
                                       int destinationIndex,
                                       int length)
        Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length).
        Parameters:
        destinationIndex - the first index of the destination
        length - the number of bytes to transfer
        Throws:
        IndexOutOfBoundsException - if the specified destinationIndex is less than 0, if length is greater than this.available(), or if destinationIndex + length is greater than destination.capacity
      • readBytes

        public abstract void readBytes​(OutputStream out,
                                       int length)
                                throws IOException
        Transfers this buffer's data to the specified stream starting at the current position.
        Parameters:
        length - the number of bytes to transfer
        Throws:
        IndexOutOfBoundsException - if length is greater than this.available()
        IOException - if the specified stream threw an exception during I/O
      • skip

        public abstract long skip​(long length)
        Overrides:
        skip in class InputStream
      • skipBytes

        public abstract int skipBytes​(int length)
        Specified by:
        skipBytes in interface DataInput
      • getRetainedSize

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

        public final void mark​(int readLimit)
        Overrides:
        mark in class InputStream
      • readChar

        public final char readChar()
        Specified by:
        readChar in interface DataInput