类 DefaultDataBuffer

    • 方法详细资料

      • indexOf

        public int indexOf​(IntPredicate predicate,
                           int fromIndex)
        从接口复制的说明: DataBuffer
        Return the index of the first byte in this buffer that matches the given predicate.
        指定者:
        indexOf 在接口中 DataBuffer
        参数:
        predicate - the predicate to match
        fromIndex - the index to start the search from
        返回:
        the index of the first byte that matches predicate; or -1 if none match
      • lastIndexOf

        public int lastIndexOf​(IntPredicate predicate,
                               int fromIndex)
        从接口复制的说明: DataBuffer
        Return the index of the last byte in this buffer that matches the given predicate.
        指定者:
        lastIndexOf 在接口中 DataBuffer
        参数:
        predicate - the predicate to match
        fromIndex - the index to start the search from
        返回:
        the index of the last byte that matches predicate; or -1 if none match
      • capacity

        public int capacity()
        从接口复制的说明: DataBuffer
        Return the number of bytes that this buffer can contain.
        指定者:
        capacity 在接口中 DataBuffer
        返回:
        the capacity
      • capacity

        public DefaultDataBuffer capacity​(int newCapacity)
        从接口复制的说明: DataBuffer
        Set the number of bytes that this buffer can contain.

        If the new capacity is lower than the current capacity, the contents of this buffer will be truncated. If the new capacity is higher than the current capacity, it will be expanded.

        指定者:
        capacity 在接口中 DataBuffer
        参数:
        newCapacity - the new capacity
        返回:
        this buffer
      • getByte

        public byte getByte​(int index)
        从接口复制的说明: DataBuffer
        Read a single byte at the given index from this data buffer.
        指定者:
        getByte 在接口中 DataBuffer
        参数:
        index - the index at which the byte will be read
        返回:
        the byte at the given index
      • read

        public byte read()
        从接口复制的说明: DataBuffer
        Read a single byte from the current reading position from this data buffer.
        指定者:
        read 在接口中 DataBuffer
        返回:
        the byte at this buffer's current reading position
      • read

        public DefaultDataBuffer read​(byte[] destination)
        从接口复制的说明: DataBuffer
        Read this buffer's data into the specified destination, starting at the current reading position of this buffer.
        指定者:
        read 在接口中 DataBuffer
        参数:
        destination - the array into which the bytes are to be written
        返回:
        this buffer
      • read

        public DefaultDataBuffer read​(byte[] destination,
                                      int offset,
                                      int length)
        从接口复制的说明: DataBuffer
        Read at most length bytes of this buffer into the specified destination, starting at the current reading position of this buffer.
        指定者:
        read 在接口中 DataBuffer
        参数:
        destination - the array into which the bytes are to be written
        offset - the index within destination of the first byte to be written
        length - the maximum number of bytes to be written in destination
        返回:
        this buffer
      • write

        public DefaultDataBuffer write​(byte b)
        从接口复制的说明: DataBuffer
        Write a single byte into this buffer at the current writing position.
        指定者:
        write 在接口中 DataBuffer
        参数:
        b - the byte to be written
        返回:
        this buffer
      • write

        public DefaultDataBuffer write​(byte[] source)
        从接口复制的说明: DataBuffer
        Write the given source into this buffer, starting at the current writing position of this buffer.
        指定者:
        write 在接口中 DataBuffer
        参数:
        source - the bytes to be written into this buffer
        返回:
        this buffer
      • write

        public DefaultDataBuffer write​(byte[] source,
                                       int offset,
                                       int length)
        从接口复制的说明: DataBuffer
        Write at most length bytes of the given source into this buffer, starting at the current writing position of this buffer.
        指定者:
        write 在接口中 DataBuffer
        参数:
        source - the bytes to be written into this buffer
        offset - the index within source to start writing from
        length - the maximum number of bytes to be written from source
        返回:
        this buffer
      • write

        public DefaultDataBuffer write​(DataBuffer... buffers)
        从接口复制的说明: DataBuffer
        Write one or more DataBuffers to this buffer, starting at the current writing position. It is the responsibility of the caller to release the given data buffers.
        指定者:
        write 在接口中 DataBuffer
        参数:
        buffers - the byte buffers to write into this buffer
        返回:
        this buffer
      • slice

        public DefaultDataBuffer slice​(int index,
                                       int length)
        从接口复制的说明: DataBuffer
        Create a new DataBuffer whose contents is a shared subsequence of this data buffer's content. Data between this data buffer and the returned buffer is shared; though changes in the returned buffer's position will not be reflected in the reading nor writing position of this data buffer.

        Note that this method will not call DataBufferUtils.retain(DataBuffer) on the resulting slice: the reference count will not be increased.

        指定者:
        slice 在接口中 DataBuffer
        参数:
        index - the index at which to start the slice
        length - the length of the slice
        返回:
        the specified slice of this data buffer
      • asByteBuffer

        public ByteBuffer asByteBuffer()
        从接口复制的说明: DataBuffer
        Expose this buffer's bytes as a ByteBuffer. Data between this DataBuffer and the returned ByteBuffer is shared; though changes in the returned buffer's position will not be reflected in the reading nor writing position of this data buffer.
        指定者:
        asByteBuffer 在接口中 DataBuffer
        返回:
        this data buffer as a byte buffer
      • asByteBuffer

        public ByteBuffer asByteBuffer​(int index,
                                       int length)
        从接口复制的说明: DataBuffer
        Expose a subsequence of this buffer's bytes as a ByteBuffer. Data between this DataBuffer and the returned ByteBuffer is shared; though changes in the returned buffer's position will not be reflected in the reading nor writing position of this data buffer.
        指定者:
        asByteBuffer 在接口中 DataBuffer
        参数:
        index - the index at which to start the byte buffer
        length - the length of the returned byte buffer
        返回:
        this data buffer as a byte buffer
      • asInputStream

        public InputStream asInputStream​(boolean releaseOnClose)
        从接口复制的说明: DataBuffer
        Expose this buffer's data as an InputStream. Both data and read position are shared between the returned stream and this data buffer.
        指定者:
        asInputStream 在接口中 DataBuffer
        参数:
        releaseOnClose - whether the underlying buffer will be released when the input stream is closed.
        返回:
        this data buffer as an input stream
      • toString

        public String toString​(int index,
                               int length,
                               Charset charset)
        从接口复制的说明: DataBuffer
        Return a part of this buffer's data as a String using the specified charset.
        指定者:
        toString 在接口中 DataBuffer
        参数:
        index - the index at which to start the string
        length - the number of bytes to use for the string
        charset - the charset to use
        返回:
        a string representation of a part of this buffers data