|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimtools.util.StreamMemoryBuffer.StreamReader
public class StreamMemoryBuffer.StreamReader
A buffer reader
Field Summary | |
---|---|
protected long |
mark
The mark used to perform the writing of the buffer into a channel or into packet buffers |
protected java.nio.ByteBuffer |
readBuffer
The read buffer : an independent view on the write buffer |
Constructor Summary | |
---|---|
protected |
StreamMemoryBuffer.StreamReader()
Create a reader |
Method Summary | |
---|---|
long |
bufferize(PacketBufferFactory factory,
long timeout)
Bufferize the buffer content from the mark to packet buffer |
int |
getLength(int readIndex)
Get the packet length |
long |
getMinIndex()
Get the oldest packet index |
long |
getNextReadIndex(long timeout,
long lastReadIndex)
Wait for the next writing on the buffer and return the index of this packet. |
long |
getReadIndex()
Get the last packet index |
int |
read(long readIndex,
int readOffset,
int readLength,
byte[] b,
int offset)
Read a packet |
void |
resetMark()
Set the mark location equal to the last received packet |
void |
resetMark(int margin)
Set the mark location wrt the oldest packet to read The mark is initialized with last available index at reader creation time. |
long |
save(java.nio.channels.ByteChannel channel,
long timeout)
Save the buffer content from the mark to the last written packet |
protected void |
validationErrorControl(PacketBufferValidationError e)
Default managment of a packet validation error is to send the exception at upper level |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final java.nio.ByteBuffer readBuffer
protected long mark
Constructor Detail |
---|
protected StreamMemoryBuffer.StreamReader()
Method Detail |
---|
public long getNextReadIndex(long timeout, long lastReadIndex)
timeout
- the wait timeout
public void resetMark()
public void resetMark(int margin)
margin
- the mark location relative to the oldest available packetpublic long bufferize(PacketBufferFactory factory, long timeout) throws java.io.IOException, PacketBufferValidationError
a
- packet factory to address the right buffers according
to the key read from the packettimeout
- the timeout to wait
java.io.IOException
PacketBufferValidationError
protected void validationErrorControl(PacketBufferValidationError e) throws PacketBufferValidationError
e
- the validation error
PacketBufferValidationError
public long save(java.nio.channels.ByteChannel channel, long timeout) throws java.io.IOException
channel
- the channel to write intotimeout
- the timeout to wait
java.io.IOException
public int read(long readIndex, int readOffset, int readLength, byte[] b, int offset)
readIndex
- the index of the packet to readreadOffset
- the offset inside this packetreadLength
- the number of bytes to read or
-1 if it is up to the packet endb
- the array to which bytes are to be writtenoffset
- the offset within the array of the first byte to be written
public int getLength(int readIndex)
readIndex
- the index of the packet
public long getReadIndex()
public long getMinIndex()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |