Interface ByteArray
- All Superinterfaces:
IoAbsoluteReader, IoAbsoluteWriter
- All Known Implementing Classes:
AbstractByteArray, BufferByteArray, ByteArrayPool.DirectBufferByteArray, CompositeByteArray
Represents a sequence of bytes that can be read or written directly or
through a cursor.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceProvides relocatable, relative access to the underlying array. -
Method Summary
Modifier and TypeMethodDescriptioncursor()cursor(int index) booleanA ByteArray is equal to another ByteArray if they start and end at the same index, have the same byte order, and contain the same bytes at each index.intfirst()voidfree()Remove any resources associated with this object.byteget(int index) voidGets enough bytes to fill theIoBufferfrom the given index.intgetInt(int index) intlast()order()voidSet the byte order of the array.
-
Method Details
-
first
int first()- Specified by:
firstin interfaceIoAbsoluteReader- Specified by:
firstin interfaceIoAbsoluteWriter- Returns:
- the index of the first byte that can be accessed.
-
last
int last()- Specified by:
lastin interfaceIoAbsoluteReader- Specified by:
lastin interfaceIoAbsoluteWriter- Returns:
- the index after the last byte that can be accessed.
-
order
ByteOrder order()- Specified by:
orderin interfaceIoAbsoluteReader- Specified by:
orderin interfaceIoAbsoluteWriter- Returns:
- the order of the bytes.
-
order
Set the byte order of the array.- Parameters:
order- The ByteOrder to use
-
free
void free()Remove any resources associated with this object. Using the object after this method is called may result in undefined behaviour. -
getIoBuffers
-
getSingleIoBuffer
IoBuffer getSingleIoBuffer()- Returns:
- a single
IoBufferthat backs this array. Some implementations may initially have data split across multiple buffers, so calling this method may require a new buffer to be allocated and populated.
-
equals
A ByteArray is equal to another ByteArray if they start and end at the same index, have the same byte order, and contain the same bytes at each index. -
get
byte get(int index) - Specified by:
getin interfaceIoAbsoluteReader- Parameters:
index- The starting position- Returns:
- a
bytefrom the given index.
-
get
Gets enough bytes to fill theIoBufferfrom the given index.- Specified by:
getin interfaceIoAbsoluteReader- Parameters:
index- The starting positionbb- The IoBuffer that will be filled with the bytes
-
getInt
int getInt(int index) - Specified by:
getIntin interfaceIoAbsoluteReader- Parameters:
index- The starting position- Returns:
- an
intfrom the given index.
-
cursor
ByteArray.Cursor cursor()- Returns:
- a cursor starting at index 0 (which may not be the start of the array).
-
cursor
- Parameters:
index- The starting point- Returns:
- a cursor starting at the given index.
-