public class GridByteArrayList extends Object implements Message, Externalizable
DIRECT_TYPE_SIZE
Constructor and Description |
---|
GridByteArrayList()
No-op constructor that creates uninitialized list.
|
GridByteArrayList(byte[] data)
Wraps existing array into byte array list.
|
GridByteArrayList(byte[] data,
int size)
Wraps existing array into byte array list.
|
GridByteArrayList(int cap)
Creates empty list with the specified initial capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
add(byte b)
Appends byte element to the list.
|
void |
add(byte[] bytes,
int off,
int len) |
void |
add(ByteBuffer buf,
int len)
Adds data from byte buffer into array.
|
void |
add(int i)
Appends integer to the next 4 bytes of list.
|
void |
add(long l)
Appends long to the next 8 bytes of list.
|
void |
add(short i)
Appends short to the next 2 bytes of the list.
|
void |
allocate(int cnt)
Pre-allocates internal array for specified byte number only
if it currently is smaller than desired number.
|
byte[] |
array()
Gets copy of internal array.
|
int |
capacity()
Gets initial capacity of the list.
|
short |
directType()
Gets message type.
|
byte[] |
entireArray()
Returns internal array if it represents the whole length,
otherwise returns the result of
array() . |
byte |
fieldsCount()
Gets fields count.
|
byte |
get(int i)
Gets the element (byte) at the specified position in the list.
|
int |
getInt(int i)
Gets 4 bytes from byte list as an integer.
|
InputStream |
inputStream() |
byte[] |
internalArray()
Returns the underlying array.
|
void |
onAckReceived()
Method called when ack message received.
|
OutputStream |
outputStream() |
void |
readAll(InputStream in)
Reads all data from input stream until the end into this byte list.
|
void |
readExternal(ObjectInput in) |
boolean |
readFrom(ByteBuffer buf,
MessageReader reader)
Reads this message from provided byte buffer.
|
void |
reset()
Resets byte array to empty.
|
void |
set(int pos,
byte b)
Sets a byte at specified position.
|
void |
set(int pos,
int i)
Sets integer at specified position.
|
void |
set(int pos,
long l)
Sets long at specified position.
|
void |
set(int pos,
short i)
Sets short at specified position.
|
int |
size()
Gets number of bytes in the list.
|
String |
toString() |
void |
writeExternal(ObjectOutput out) |
boolean |
writeTo(ByteBuffer buf,
MessageWriter writer)
Writes this message to provided byte buffer.
|
public GridByteArrayList()
Externalizable
interface.public GridByteArrayList(int cap)
cap
- Initial capacity.public GridByteArrayList(byte[] data, int size)
data
- Array to wrap.size
- Size of data inside of array.public GridByteArrayList(byte[] data)
data
- Array to wrap.public void reset()
public byte[] internalArray()
public byte[] array()
public byte[] entireArray()
array()
.public int capacity()
public int size()
public void allocate(int cnt)
cnt
- Byte number to preallocate.public void add(byte b)
b
- Byte value to append.public void set(int pos, byte b)
pos
- Specified position.b
- Byte to set.public void add(int i)
i
- Integer to append.public void add(short i)
i
- Short to append.public void set(int pos, short i)
pos
- Specified position.i
- Short to set.public void set(int pos, int i)
pos
- Specified position.i
- Integer to set.public void add(long l)
l
- Long to append.public void set(int pos, long l)
pos
- Specified position.l
- Long to set.public void add(byte[] bytes, int off, int len)
bytes
- Byte to add.off
- Offset at which to add.len
- Number of bytes to add.public void add(ByteBuffer buf, int len)
buf
- Buffer to read bytes from.len
- Number of bytes to add.public byte get(int i)
i
- Index of element to return.public int getInt(int i)
i
- Index into the byte list.public void readAll(InputStream in) throws IOException
in
- Input stream to read from.IOException
- Thrown if any I/O error occurred.public OutputStream outputStream()
public InputStream inputStream()
public void onAckReceived()
onAckReceived
in interface Message
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public boolean writeTo(ByteBuffer buf, MessageWriter writer)
public boolean readFrom(ByteBuffer buf, MessageReader reader)
public short directType()
directType
in interface Message
public byte fieldsCount()
fieldsCount
in interface Message
Follow @ApacheIgnite
Ignite Fabric : ver. 2.0.0 Release Date : April 30 2017