Package org.apache.mina.util.byteaccess
Interface ByteArray
-
- All Superinterfaces:
IoAbsoluteReader,IoAbsoluteWriter
- All Known Implementing Classes:
AbstractByteArray,BufferByteArray,ByteArrayPool.DirectBufferByteArray,CompositeByteArray
public interface ByteArray extends IoAbsoluteReader, IoAbsoluteWriter
Represents a sequence of bytes that can be read or written directly or through a cursor.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceByteArray.CursorProvides relocatable, relative access to the underlying array.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ByteArray.Cursorcursor()ByteArray.Cursorcursor(int index)booleanequals(java.lang.Object other)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.intfirst()voidfree()Remove any resources associated with this object.java.lang.Iterable<IoBuffer>getIoBuffers()IoBuffergetSingleIoBuffer()intlast()java.nio.ByteOrderorder()voidorder(java.nio.ByteOrder order)Set the byte order of the array.
-
-
-
Method Detail
-
first
int first()
- Returns:
- the index of the first byte that can be accessed.
-
last
int last()
- Returns:
- the index after the last byte that can be accessed.
-
order
java.nio.ByteOrder order()
- Returns:
- the order of the bytes.
-
order
void order(java.nio.ByteOrder 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
java.lang.Iterable<IoBuffer> getIoBuffers()
- Returns:
- the sequence of
IoBuffers that back this array. Compared togetSingleIoBuffer(), this method should be relatively efficient for all implementations.
-
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
boolean equals(java.lang.Object other)
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.- Overrides:
equalsin classjava.lang.Object- Parameters:
other- The ByteArray we want to compare with- Returns:
trueif both ByteArray are equals
-
cursor
ByteArray.Cursor cursor()
- Returns:
- a cursor starting at index 0 (which may not be the start of the array).
-
cursor
ByteArray.Cursor cursor(int index)
- Parameters:
index- The starting point- Returns:
- a cursor starting at the given index.
-
-