Package org.apache.mina.util.byteaccess
Interface ByteArray
-
- All Superinterfaces:
IoAbsoluteReader
,IoAbsoluteWriter
- All Known Implementing Classes:
BufferByteArray
,CompositeByteArray
public interface ByteArray extends IoAbsoluteReader, IoAbsoluteWriter
Represents a sequence of bytes that can be read or written directly or through a cursor.- Author:
- Apache MINA Project
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ByteArray.Cursor
Provides relocatable, relative access to the underlying array.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ByteArray.Cursor
cursor()
ByteArray.Cursor
cursor(int index)
boolean
equals(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.int
first()
void
free()
Remove any resources associated with this object.byte
get(int index)
void
get(int index, IoBuffer bb)
Gets enough bytes to fill the IoBuffer from the given index.int
getInt(int index)
Iterable<IoBuffer>
getIoBuffers()
IoBuffer
getSingleIoBuffer()
int
last()
ByteOrder
order()
void
order(ByteOrder order)
Set the byte order of the array.
-
-
-
Method Detail
-
first
int first()
- Specified by:
first
in interfaceIoAbsoluteReader
- Specified by:
first
in interfaceIoAbsoluteWriter
- Returns:
- the index of the first byte that can be accessed.
-
last
int last()
- Specified by:
last
in interfaceIoAbsoluteReader
- Specified by:
last
in interfaceIoAbsoluteWriter
- Returns:
- the index after the last byte that can be accessed.
-
order
ByteOrder order()
- Specified by:
order
in interfaceIoAbsoluteReader
- Specified by:
order
in interfaceIoAbsoluteWriter
- Returns:
- the order of the bytes.
-
order
void order(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
Iterable<IoBuffer> getIoBuffers()
- Returns:
- the sequence of
IoBuffer
s that back this array. Compared togetSingleIoBuffer()
, this method should be relatively efficient for all implementations.
-
getSingleIoBuffer
IoBuffer getSingleIoBuffer()
- Returns:
- a single
IoBuffer
that 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(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.
-
get
byte get(int index)
- Specified by:
get
in interfaceIoAbsoluteReader
- Parameters:
index
- The starting position- Returns:
- a byte from the given index.
-
get
void get(int index, IoBuffer bb)
Gets enough bytes to fill the IoBuffer from the given index.- Specified by:
get
in interfaceIoAbsoluteReader
- Parameters:
index
- The starting positionbb
- The IoBuffer that will be filled with the bytes
-
getInt
int getInt(int index)
- Specified by:
getInt
in interfaceIoAbsoluteReader
- Parameters:
index
- The starting position- Returns:
- an int from the given index.
-
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.
-
-