|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.jonathan.resources.api.Chunk
A chunk represents a part of an array of bytes. Chunks are linked to form
messages that may be sent from an adress space to another. Their use avoids
unnecessarily copying arrays of bytes, and helps recovering these arrays
without resorting to garbage collection (thanks to
chunk factories
).
Chunks should not be used concurrently.
Field Summary | |
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 Summary | |
Chunk(byte[] data,
int offset,
int top)
Constructs a new chunk with the specified data and offsets. |
Method Summary | |
Chunk |
duplicate()
Duplicates the whole chunk. |
Chunk |
duplicate(int offset,
int top)
Partially duplicates this chunk. |
void |
release()
Releases the chunk. |
String |
toString()
Returns a string representation of the target chunk. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public byte[] data
public int top
public int offset
public Chunk next
Constructor Detail |
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.Method Detail |
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.
public String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |