Class HttpInput.Content

    • Field Detail

      • _content

        protected final java.nio.ByteBuffer _content
    • Constructor Detail

      • Content

        public Content​(java.nio.ByteBuffer content)
    • Method Detail

      • getByteBuffer

        public java.nio.ByteBuffer getByteBuffer()
        Get the wrapped byte buffer. Throws IllegalStateException if the content is special.
        Returns:
        the wrapped byte buffer.
      • get

        public int get​(byte[] buffer,
                       int offset,
                       int length)
        Read the wrapped byte buffer. Throws IllegalStateException if the content is special.
        Parameters:
        buffer - The array into which bytes are to be written.
        offset - The offset within the array of the first byte to be written.
        length - The maximum number of bytes to be written to the given array.
        Returns:
        The amount of bytes read from the buffer.
      • skip

        public int skip​(int length)
        Skip some bytes from the buffer. Has no effect on a special content.
        Parameters:
        length - How many bytes to skip.
        Returns:
        How many bytes were skipped.
      • hasContent

        public boolean hasContent()
        Check if there is at least one byte left in the buffer. Always false on a special content.
        Returns:
        true if there is at least one byte left in the buffer.
      • remaining

        public int remaining()
        Get the number of bytes remaining in the buffer. Always 0 on a special content.
        Returns:
        the number of bytes remaining in the buffer.
      • isEmpty

        public boolean isEmpty()
        Check if the buffer is empty. Always true on a special content.
        Returns:
        true if there is 0 byte left in the buffer.
      • isSpecial

        public boolean isSpecial()
        Check if the content is special. A content is deemed special if it does not hold bytes but rather conveys a special event, like when EOF has been reached or an error has occurred.
        Returns:
        true if the content is special, false otherwise.
      • isEof

        public boolean isEof()
        Check if EOF was reached. Both special and non-special content can have this flag set to true but in the case of non-special content, this can be interpreted as a hint as it is always going to be followed by another content that is both special and EOF.
        Returns:
        true if EOF was reached, false otherwise.
      • getError

        public java.lang.Throwable getError()
        Get the reported error. Only special contents can have an error.
        Returns:
        the error or null if there is none.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object