Class ByteBufEaglercraftImpl
- java.lang.Object
-
- net.lax1dude.eaglercraft.v1_8.netty.ByteBuf
-
- net.lax1dude.eaglercraft.v1_8.netty.AbstractByteBuf
-
- net.lax1dude.eaglercraft.v1_8.netty.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 Summary
Constructors Constructor Description ByteBufEaglercraftImpl(java.nio.ByteBuffer internal, int maxCapacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte_getByte(int index)protected int_getInt(int index)protected long_getLong(int index)protected short_getShort(int index)protected int_getUnsignedMedium(int index)protected void_setByte(int index, int value)protected void_setInt(int index, int value)protected void_setLong(int index, long value)protected void_setMedium(int index, int value)protected void_setShort(int index, int value)byte[]array()Returns the backing byte array of this buffer.intarrayOffset()Returns the offset of the first byte within the backing byte array of this buffer.intcapacity()Returns the number of bytes (octets) this buffer can contain.ByteBufcapacity(int newCapacity)Adjusts the capacity of this buffer.ByteBufcopy(int index, int length)Returns a copy of this buffer's sub-region.ByteBufduplicate()Returns a buffer which shares the whole region of this buffer.ByteBufgetBytes(int index, byte[] dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the specified absoluteindex.ByteBufgetBytes(int index, java.io.OutputStream out, int length)Transfers this buffer's data to the specified stream starting at the specified absoluteindex.ByteBufgetBytes(int index, java.nio.ByteBuffer dst)Transfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination's position reaches its limit.ByteBufgetBytes(int index, ByteBuf dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the specified absoluteindex.booleanhasArray()Returnstrueif and only if this buffer has a backing byte array.booleanhasMemoryAddress()Returnstrueif and only if this buffer has a reference to the low-level memory address that points to the backing data.java.nio.ByteBufferinternalNioBuffer(int index, int length)Internal use only: Exposes the internal NIO buffer.booleanisDirect()Returnstrueif and only if this buffer is backed by an NIO direct buffer.longmemoryAddress()Returns the low-level memory address that point to the first byte of ths backing data.java.nio.ByteBuffernioBuffer(int index, int length)Exposes this buffer's sub-region as an NIOByteBuffer.intnioBufferCount()Returns the maximum number of NIOByteBuffers that consist this buffer.java.nio.ByteBuffer[]nioBuffers(int index, int length)Exposes this buffer's bytes as an NIOByteBuffer'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.java.nio.ByteOrderorder()Returns the endianness of this buffer.ByteBuforder(java.nio.ByteOrder endianness)Returns a buffer with the specifiedendiannesswhich shares the whole region, indexes, and marks of this buffer.ByteBufsetBytes(int index, byte[] src, int srcIndex, int length)Transfers the specified source array's data to this buffer starting at the specified absoluteindex.intsetBytes(int index, java.io.InputStream in, int length)Transfers the content of the specified source stream to this buffer starting at the specified absoluteindex.ByteBufsetBytes(int index, java.nio.ByteBuffer src)Transfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the source buffer's position reaches its limit.ByteBufsetBytes(int index, ByteBuf src, int srcIndex, int length)Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex.ByteBufslice(int index, int length)Returns a slice of this buffer's sub-region.ByteBufunwrap()Return the underlying buffer instance if this buffer is a wrapper of another buffer.-
Methods inherited from class net.lax1dude.eaglercraft.v1_8.netty.AbstractByteBuf
adjustMarkers, bytesBefore, bytesBefore, bytesBefore, checkDstIndex, checkIndex, checkIndex, checkNewCapacity, checkReadableBytes, checkSrcIndex, clear, compareTo, copy, discardReadBytes, discardSomeReadBytes, ensureWritable, ensureWritable, equals, getBoolean, getByte, getBytes, getBytes, getBytes, getChar, getDouble, getFloat, getInt, getLong, getMedium, getShort, getUnsignedByte, getUnsignedInt, getUnsignedMedium, getUnsignedShort, hashCode, indexOf, isReadable, isReadable, isWritable, isWritable, markReaderIndex, markWriterIndex, maxCapacity, maxCapacity, maxWritableBytes, newSwappedByteBuf, nioBuffer, nioBuffers, readableBytes, readBoolean, readByte, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readChar, readDouble, readerIndex, readerIndex, readFloat, readInt, readLong, readMedium, readShort, readSlice, readUnsignedByte, readUnsignedInt, readUnsignedMedium, readUnsignedShort, resetReaderIndex, resetWriterIndex, setBoolean, setByte, setBytes, setBytes, setBytes, setChar, setDouble, setFloat, setIndex, setInt, setLong, setMedium, setShort, setZero, skipBytes, slice, toString, toString, toString, writableBytes, writeBoolean, writeByte, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeChar, writeDouble, writeFloat, writeInt, writeLong, writeMedium, writerIndex, writerIndex, writeShort, writeZero
-
-
-
-
Method Detail
-
_getByte
protected byte _getByte(int index)
- Specified by:
_getBytein classAbstractByteBuf
-
_getShort
protected short _getShort(int index)
- Specified by:
_getShortin classAbstractByteBuf
-
_getUnsignedMedium
protected int _getUnsignedMedium(int index)
- Specified by:
_getUnsignedMediumin classAbstractByteBuf
-
_getInt
protected int _getInt(int index)
- Specified by:
_getIntin classAbstractByteBuf
-
_getLong
protected long _getLong(int index)
- Specified by:
_getLongin classAbstractByteBuf
-
_setByte
protected void _setByte(int index, int value)- Specified by:
_setBytein classAbstractByteBuf
-
_setShort
protected void _setShort(int index, int value)- Specified by:
_setShortin classAbstractByteBuf
-
_setMedium
protected void _setMedium(int index, int value)- Specified by:
_setMediumin classAbstractByteBuf
-
_setInt
protected void _setInt(int index, int value)- Specified by:
_setIntin classAbstractByteBuf
-
_setLong
protected void _setLong(int index, long value)- Specified by:
_setLongin classAbstractByteBuf
-
capacity
public int capacity()
Description copied from class:ByteBufReturns the number of bytes (octets) this buffer can contain.
-
capacity
public ByteBuf capacity(int newCapacity)
Description copied from class:ByteBufAdjusts the capacity of this buffer. If thenewCapacityis less than the current capacity, the content of this buffer is truncated. If thenewCapacityis greater than the current capacity, the buffer is appended with unspecified data whose length is(newCapacity - currentCapacity).
-
order
public java.nio.ByteOrder order()
Description copied from class:ByteBufReturns the endianness of this buffer.
-
order
public ByteBuf order(java.nio.ByteOrder endianness)
Description copied from class:ByteBufReturns a buffer with the specifiedendiannesswhich 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 specifiedendiannessis identical to this buffer's byte order, this method can returnthis. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
orderin classAbstractByteBuf
-
unwrap
public ByteBuf unwrap()
Description copied from class:ByteBufReturn the underlying buffer instance if this buffer is a wrapper of another buffer.
-
isDirect
public boolean isDirect()
Description copied from class:ByteBufReturnstrueif and only if this buffer is backed by an NIO direct buffer.
-
getBytes
public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof both the source (i.e.this) and the destination.
-
getBytes
public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getBytes
public ByteBuf getBytes(int index, java.nio.ByteBuffer dst)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination's position reaches its limit. This method does not modifyreaderIndexorwriterIndexof this buffer while the destination'spositionwill be increased.
-
getBytes
public ByteBuf getBytes(int index, java.io.OutputStream out, int length) throws java.io.IOException
Description copied from class:ByteBufTransfers this buffer's data to the specified stream starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length)
Description copied from class:ByteBufTransfers the specified source buffer's data to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof both the source (i.e.this) and the destination.
-
setBytes
public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length)
Description copied from class:ByteBufTransfers the specified source array's data to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public ByteBuf setBytes(int index, java.nio.ByteBuffer src)
Description copied from class:ByteBufTransfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the source buffer's position reaches its limit. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public int setBytes(int index, java.io.InputStream in, int length) throws java.io.IOExceptionDescription copied from class:ByteBufTransfers the content of the specified source stream to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
copy
public ByteBuf copy(int index, int length)
Description copied from class:ByteBufReturns 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 modifyreaderIndexorwriterIndexof this buffer.
-
nioBufferCount
public int nioBufferCount()
Description copied from class:ByteBufReturns the maximum number of NIOByteBuffers that consist this buffer. Note thatByteBuf.nioBuffers()orByteBuf.nioBuffers(int, int)might return a less number ofByteBuffers.- Specified by:
nioBufferCountin classByteBuf- Returns:
-1if this buffer has no underlyingByteBuffer. the number of the underlyingByteBuffers if this buffer has at least one underlyingByteBuffer. Note that this method does not return0to avoid confusion.- See Also:
ByteBuf.nioBuffer(),ByteBuf.nioBuffer(int, int),ByteBuf.nioBuffers(),ByteBuf.nioBuffers(int, int)
-
nioBuffer
public java.nio.ByteBuffer nioBuffer(int index, int length)Description copied from class:ByteBufExposes this buffer's sub-region as an NIOByteBuffer. 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 modifyreaderIndexorwriterIndexof 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:
nioBufferin classByteBuf- See Also:
ByteBuf.nioBufferCount(),ByteBuf.nioBuffers(),ByteBuf.nioBuffers(int, int)
-
internalNioBuffer
public java.nio.ByteBuffer internalNioBuffer(int index, int length)Description copied from class:ByteBufInternal use only: Exposes the internal NIO buffer.- Specified by:
internalNioBufferin classByteBuf
-
nioBuffers
public java.nio.ByteBuffer[] nioBuffers(int index, int length)Description copied from class:ByteBufExposes this buffer's bytes as an NIOByteBuffer'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 modifyreaderIndexorwriterIndexof 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:
nioBuffersin classByteBuf- See Also:
ByteBuf.nioBufferCount(),ByteBuf.nioBuffer(),ByteBuf.nioBuffer(int, int)
-
hasArray
public boolean hasArray()
Description copied from class:ByteBufReturnstrueif and only if this buffer has a backing byte array. If this method returns true, you can safely callByteBuf.array()andByteBuf.arrayOffset().
-
array
public byte[] array()
Description copied from class:ByteBufReturns the backing byte array of this buffer.
-
arrayOffset
public int arrayOffset()
Description copied from class:ByteBufReturns the offset of the first byte within the backing byte array of this buffer.- Specified by:
arrayOffsetin classByteBuf
-
hasMemoryAddress
public boolean hasMemoryAddress()
Description copied from class:ByteBufReturnstrueif and only if this buffer has a reference to the low-level memory address that points to the backing data.- Specified by:
hasMemoryAddressin classByteBuf
-
memoryAddress
public long memoryAddress()
Description copied from class:ByteBufReturns the low-level memory address that point to the first byte of ths backing data.- Specified by:
memoryAddressin classByteBuf
-
slice
public ByteBuf slice(int index, int length)
Description copied from class:ByteBufReturns 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 modifyreaderIndexorwriterIndexof this buffer.Also be aware that this method will NOT call
#retain()and so the reference count will NOT be increased.
-
duplicate
public ByteBuf duplicate()
Description copied from class:ByteBufReturns 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 modifyreaderIndexorwriterIndexof 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:
duplicatein classByteBuf- 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.
-
-