au.com.terabit.jproactor
Class OpRead

java.lang.Object
  extended by au.com.terabit.jproactor.IOOperation
      extended by au.com.terabit.jproactor.OpRead

public class OpRead
extends IOOperation

The read operation implementation.

Version:
$Revision$ $Date$
Author:
Yevgeny Libman

Field Summary
protected  java.nio.ByteBuffer m_buffer
          data buffer
protected  int m_bytesCompleted
          The number of bytes processed by IO operation.
protected  boolean m_flgExactly
          This flag denotes that data needs to be read until buffer is full.
 
Fields inherited from class au.com.terabit.jproactor.IOOperation
m_asynchChannel, m_errorCause
 
Method Summary
protected  boolean execute()
           
 java.nio.ByteBuffer getBuffer()
          Gets operations' data buffer.
 int getBytesCompleted()
           
 void onComplete()
          Called when IO operation has completed - notifies protocol instance that read operation has completed.
 int remaining()
          Tells the difference between a number of requested and processed bytes, by IO operationm, at present time.
 
Methods inherited from class au.com.terabit.jproactor.IOOperation
getChannel, getError, getState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_buffer

protected java.nio.ByteBuffer m_buffer
data buffer


m_bytesCompleted

protected int m_bytesCompleted
The number of bytes processed by IO operation.

-1 if error occured or channel is closed


m_flgExactly

protected boolean m_flgExactly
This flag denotes that data needs to be read until buffer is full.

See Also:
java.nio.ByteBuffer#remaning()
Method Detail

getBytesCompleted

public int getBytesCompleted()
Returns:
a number of bytes available after io operation was completed; -1 if exception or end-of-channel happened

getBuffer

public java.nio.ByteBuffer getBuffer()
Gets operations' data buffer.

Returns:
data buffer

remaining

public int remaining()
Tells the difference between a number of requested and processed bytes, by IO operationm, at present time.

Example 1: Requested to read n bytes, actually read was m, so bytesRemaining is n-m

Example 2: Requested to write n bytes, actually written was m, so bytesRemaining is n-m

See Also:
java.nio.ByteBuffer#remaning()

execute

protected boolean execute()
Specified by:
execute in class IOOperation

onComplete

public void onComplete()
Called when IO operation has completed - notifies protocol instance that read operation has completed.

See Also:
IOOperation.onComplete()