Class ExpansibleByteBuffer
java.lang.Object
org.apache.directory.api.util.ExpansibleByteBuffer
A dynamically growing byte[].
- Author:
- Apache Directory Project
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a default ExpansibleByteBuffer capable of holding 10 bytesExpansibleByteBuffer(int initialSize) Creates a ExpansibleByteBuffer which has an initialze size -
Method Summary
Modifier and TypeMethodDescriptionfinal voidappend(byte b) Appends a byte to this buffer.final voidappend(byte[] bytes) Appends the bytes to this buffer.final voidappend(int val) Appends an int to this buffer.final byte[]buffer()Get's the bytes, the backing store for this buffer.final intcapacity()Capacity of the bufferfinal voidclear()Reset the Buffer position to 0.final byte[]Get's a copy of the bytes used.final byteget(int i) Returns the byte at a given position.final intposition()Position of the last byte in the bufferfinal voidposition(int pos) Set the position to a specific value
-
Constructor Details
-
ExpansibleByteBuffer
public ExpansibleByteBuffer()Create a default ExpansibleByteBuffer capable of holding 10 bytes -
ExpansibleByteBuffer
public ExpansibleByteBuffer(int initialSize) Creates a ExpansibleByteBuffer which has an initialze size- Parameters:
initialSize- The initial buffer size
-
-
Method Details
-
clear
public final void clear()Reset the Buffer position to 0. Every new added byte will be put on position 0. Note that whatever this buffer contained before a call to the clear() method will not be removed. -
position
public final int position()Position of the last byte in the buffer- Returns:
- The position of the last byte in the buffer
-
position
public final void position(int pos) Set the position to a specific value- Parameters:
pos- the new position
-
capacity
public final int capacity()Capacity of the buffer- Returns:
- The number of bytes that can be added into this buffer
-
get
public final byte get(int i) Returns the byte at a given position. Note that no control is done on the position validity.- Parameters:
i- The position- Returns:
- The byte at the given position in the buffer
-
buffer
public final byte[] buffer()Get's the bytes, the backing store for this buffer. Note that you need to use the position index to determine where to stop reading from this buffer.- Returns:
- The interned Byte[]
-
copyOfUsedBytes
public final byte[] copyOfUsedBytes()Get's a copy of the bytes used.- Returns:
- A copy of the interned Byte[]
-
append
public final void append(byte[] bytes) Appends the bytes to this buffer.- Parameters:
bytes- The byte[] to append to the buffer
-
append
public final void append(byte b) Appends a byte to this buffer.- Parameters:
b- The byte to append to the buffer
-
append
public final void append(int val) Appends an int to this buffer. WARNING: the int is truncated to a byte value.- Parameters:
val- The integer to append to the buffer
-