public class Chunk extends Object
chunk factories
).
Chunks should not be used concurrently.
Modifier and Type | Field and Description |
---|---|
byte[] |
data
The associated array of bytes.
|
Chunk |
next
The next chunk in the chain
|
int |
offset
The index of the first valid (written) byte in this chunk.
|
int |
top
Index of the last valid (written) byte in this chunk + 1.
|
Constructor and Description |
---|
Chunk(byte[] data,
int offset,
int top)
Constructs a new chunk with the specified data and offsets.
|
public byte[] data
public int top
public int offset
public Chunk next
public Chunk(byte[] data, int offset, int top)
data
- the byte array containing the data.offset
- the offset of the first valid byte in the chunk.top
- offset + the number of valid bytes in the chunk.public Chunk duplicate() throws org.objectweb.jonathan.apis.kernel.JonathanException
The default implementation copies the buffer, and creates a new chunk with it.
org.objectweb.jonathan.exceptions.JonathanException
- if an IO error
occurs.org.objectweb.jonathan.apis.kernel.JonathanException
public Chunk duplicate(int offset, int top) throws org.objectweb.jonathan.apis.kernel.JonathanException
The default implementation copies the appropriate portion of the buffer, and creates a new chunk with it.
offset
- the offset of the chunk copy.top
- the top of the chunk copy.org.objectweb.jonathan.exceptions.JonathanException
- if an error occurs.org.objectweb.jonathan.apis.kernel.JonathanException
public void release()
The default implementation resets offset and top to 0.