Class ByteBufEaglercraftImpl

  • All Implemented Interfaces:
    java.lang.Comparable<ByteBuf>

    public class ByteBufEaglercraftImpl
    extends AbstractByteBuf
    Copyright (c) 2022-2023 LAX1DUDE. All Rights Reserved. WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR. NOT FOR COMMERCIAL OR MALICIOUS USE (please read the 'LICENSE' file this repo's root directory for more info)
    • Constructor Detail

      • ByteBufEaglercraftImpl

        public ByteBufEaglercraftImpl​(java.nio.ByteBuffer internal,
                                      int maxCapacity)
    • Method Detail

      • _setInt

        protected void _setInt​(int index,
                               int value)
        Specified by:
        _setInt in class AbstractByteBuf
      • capacity

        public int capacity()
        Description copied from class: ByteBuf
        Returns the number of bytes (octets) this buffer can contain.
        Specified by:
        capacity in class ByteBuf
      • capacity

        public ByteBuf capacity​(int newCapacity)
        Description copied from class: ByteBuf
        Adjusts the capacity of this buffer. If the newCapacity is less than the current capacity, the content of this buffer is truncated. If the newCapacity is greater than the current capacity, the buffer is appended with unspecified data whose length is (newCapacity - currentCapacity).
        Specified by:
        capacity in class ByteBuf
      • order

        public java.nio.ByteOrder order()
        Description copied from class: ByteBuf
        Returns the endianness of this buffer.
        Specified by:
        order in class ByteBuf
      • order

        public ByteBuf order​(java.nio.ByteOrder endianness)
        Description copied from class: ByteBuf
        Returns a buffer with the specified endianness which shares the whole region, indexes, and marks of this buffer. Modifying the content, the indexes, or the marks of the returned buffer or this buffer affects each other's content, indexes, and marks. If the specified endianness is identical to this buffer's byte order, this method can return this. This method does not modify readerIndex or writerIndex of this buffer.
        Overrides:
        order in class AbstractByteBuf
      • unwrap

        public ByteBuf unwrap()
        Description copied from class: ByteBuf
        Return the underlying buffer instance if this buffer is a wrapper of another buffer.
        Specified by:
        unwrap in class ByteBuf
        Returns:
        null if this buffer is not a wrapper
      • isDirect

        public boolean isDirect()
        Description copied from class: ByteBuf
        Returns true if and only if this buffer is backed by an NIO direct buffer.
        Specified by:
        isDirect in class ByteBuf
      • getBytes

        public ByteBuf getBytes​(int index,
                                ByteBuf dst,
                                int dstIndex,
                                int length)
        Description copied from class: ByteBuf
        Transfers this buffer's data to the specified destination starting at the specified absolute index. This method does not modify readerIndex or writerIndex of both the source (i.e. this) and the destination.
        Specified by:
        getBytes in class ByteBuf
        dstIndex - the first index of the destination
        length - the number of bytes to transfer
      • getBytes

        public ByteBuf getBytes​(int index,
                                byte[] dst,
                                int dstIndex,
                                int length)
        Description copied from class: ByteBuf
        Transfers this buffer's data to the specified destination starting at the specified absolute index. This method does not modify readerIndex or writerIndex of this buffer.
        Specified by:
        getBytes in class ByteBuf
        dstIndex - the first index of the destination
        length - the number of bytes to transfer
      • getBytes

        public ByteBuf getBytes​(int index,
                                java.nio.ByteBuffer dst)
        Description copied from class: ByteBuf
        Transfers this buffer's data to the specified destination starting at the specified absolute index until the destination's position reaches its limit. This method does not modify readerIndex or writerIndex of this buffer while the destination's position will be increased.
        Specified by:
        getBytes in class ByteBuf
      • getBytes

        public ByteBuf getBytes​(int index,
                                java.io.OutputStream out,
                                int length)
                         throws java.io.IOException
        Description copied from class: ByteBuf
        Transfers this buffer's data to the specified stream starting at the specified absolute index. This method does not modify readerIndex or writerIndex of this buffer.
        Specified by:
        getBytes in class ByteBuf
        length - the number of bytes to transfer
        Throws:
        java.io.IOException - if the specified stream threw an exception during I/O
      • setBytes

        public ByteBuf setBytes​(int index,
                                ByteBuf src,
                                int srcIndex,
                                int length)
        Description copied from class: ByteBuf
        Transfers the specified source buffer's data to this buffer starting at the specified absolute index. This method does not modify readerIndex or writerIndex of both the source (i.e. this) and the destination.
        Specified by:
        setBytes in class ByteBuf
        srcIndex - the first index of the source
        length - the number of bytes to transfer
      • setBytes

        public ByteBuf setBytes​(int index,
                                byte[] src,
                                int srcIndex,
                                int length)
        Description copied from class: ByteBuf
        Transfers the specified source array's data to this buffer starting at the specified absolute index. This method does not modify readerIndex or writerIndex of this buffer.
        Specified by:
        setBytes in class ByteBuf
      • setBytes

        public ByteBuf setBytes​(int index,
                                java.nio.ByteBuffer src)
        Description copied from class: ByteBuf
        Transfers the specified source buffer's data to this buffer starting at the specified absolute index until the source buffer's position reaches its limit. This method does not modify readerIndex or writerIndex of this buffer.
        Specified by:
        setBytes in class ByteBuf
      • setBytes

        public int setBytes​(int index,
                            java.io.InputStream in,
                            int length)
                     throws java.io.IOException
        Description copied from class: ByteBuf
        Transfers the content of the specified source stream to this buffer starting at the specified absolute index. This method does not modify readerIndex or writerIndex of this buffer.
        Specified by:
        setBytes in class ByteBuf
        length - the number of bytes to transfer
        Returns:
        the actual number of bytes read in from the specified channel. -1 if the specified channel is closed.
        Throws:
        java.io.IOException - if the specified stream threw an exception during I/O
      • copy

        public ByteBuf copy​(int index,
                            int length)
        Description copied from class: ByteBuf
        Returns a copy of this buffer's sub-region. Modifying the content of the returned buffer or this buffer does not affect each other at all. This method does not modify readerIndex or writerIndex of this buffer.
        Specified by:
        copy in class ByteBuf
      • nioBuffer

        public java.nio.ByteBuffer nioBuffer​(int index,
                                             int length)
        Description copied from class: ByteBuf
        Exposes this buffer's sub-region as an NIO ByteBuffer. The returned buffer either share or contains the copied content of this buffer, while changing the position and limit of the returned NIO buffer does not affect the indexes and marks of this buffer. This method does not modify readerIndex or writerIndex of this buffer. Please note that the returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic buffer and it adjusted its capacity.
        Specified by:
        nioBuffer in class ByteBuf
        See Also:
        ByteBuf.nioBufferCount(), ByteBuf.nioBuffers(), ByteBuf.nioBuffers(int, int)
      • internalNioBuffer

        public java.nio.ByteBuffer internalNioBuffer​(int index,
                                                     int length)
        Description copied from class: ByteBuf
        Internal use only: Exposes the internal NIO buffer.
        Specified by:
        internalNioBuffer in class ByteBuf
      • nioBuffers

        public java.nio.ByteBuffer[] nioBuffers​(int index,
                                                int length)
        Description copied from class: ByteBuf
        Exposes this buffer's bytes as an NIO ByteBuffer's for the specified index and length The returned buffer either share or contains the copied content of this buffer, while changing the position and limit of the returned NIO buffer does not affect the indexes and marks of this buffer. This method does not modify readerIndex or writerIndex of this buffer. Please note that the returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic buffer and it adjusted its capacity.
        Specified by:
        nioBuffers in class ByteBuf
        See Also:
        ByteBuf.nioBufferCount(), ByteBuf.nioBuffer(), ByteBuf.nioBuffer(int, int)
      • array

        public byte[] array()
        Description copied from class: ByteBuf
        Returns the backing byte array of this buffer.
        Specified by:
        array in class ByteBuf
      • arrayOffset

        public int arrayOffset()
        Description copied from class: ByteBuf
        Returns the offset of the first byte within the backing byte array of this buffer.
        Specified by:
        arrayOffset in class ByteBuf
      • hasMemoryAddress

        public boolean hasMemoryAddress()
        Description copied from class: ByteBuf
        Returns true if and only if this buffer has a reference to the low-level memory address that points to the backing data.
        Specified by:
        hasMemoryAddress in class ByteBuf
      • memoryAddress

        public long memoryAddress()
        Description copied from class: ByteBuf
        Returns the low-level memory address that point to the first byte of ths backing data.
        Specified by:
        memoryAddress in class ByteBuf
      • slice

        public ByteBuf slice​(int index,
                             int length)
        Description copied from class: ByteBuf
        Returns a slice of this buffer's sub-region. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method does not modify readerIndex or writerIndex of this buffer.

        Also be aware that this method will NOT call #retain() and so the reference count will NOT be increased.

        Specified by:
        slice in class ByteBuf
      • duplicate

        public ByteBuf duplicate()
        Description copied from class: ByteBuf
        Returns a buffer which shares the whole region of this buffer. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method does not modify readerIndex or writerIndex of this buffer.

        The reader and writer marks will not be duplicated. Also be aware that this method will NOT call #retain() and so the reference count will NOT be increased.

        Specified by:
        duplicate in class ByteBuf
        Returns:
        A buffer whose readable content is equivalent to the buffer returned by ByteBuf.slice(). However this buffer will share the capacity of the underlying buffer, and therefore allows access to all of the underlying content if necessary.