private boolean checkMultiReadBuffer ( ) throws IOException { //first check existing buffer if ( null != this . buffer ) { if ( this . buffer . hasRemaining ( ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "checkMultiReadBuffer, remaining ->" + this ) ; } return true ; } if ( firstReadCompleteforMulti ) { // multiRead enabled and subsequent read if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "checkMultiReadBuffer, buffer is completely read, ready this buffer for the subsequent read ->" + this ) ; } postDataBuffer . get ( postDataIndex ) . flip ( ) ; // make position 0 , to read it again from start postDataIndex ++ ; } else { this . buffer . release ( ) ; } this . buffer = null ; } // no buffer read from store or first read of buffer if ( firstReadCompleteforMulti ) { // first read from what we have stored, if need more than go to channel if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "checkMultiReadBuffer ,index ->" + postDataIndex + " ,storage.size ->" + postDataBuffer . size ( ) ) ; } if ( postDataBuffer . size ( ) <= postDataIndex ) { //get remaining from channel now as read needs more than the stored readRemainingFromChannel ( ) ; } if ( postDataBuffer . size ( ) > postDataIndex ) { this . buffer = postDataBuffer . get ( postDataIndex ) ; } if ( null != this . buffer ) { // record the new amount of data read from the store this . bytesReadFromStore += this . buffer . remaining ( ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "checkMultiReadBuffer ->" + this ) ; } return true ; } } else { // multiRead enabled and first read if ( getBufferFromChannel ( ) ) { // store the channel buffer postDataBuffer . add ( postDataIndex , this . buffer . duplicate ( ) ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "checkMultiReadBuffer, buffer ->" + postDataBuffer . get ( postDataIndex ) + " ,buffersize ->" + postDataBuffer . size ( ) + " ,index ->" + postDataIndex ) ; } postDataIndex ++ ; // record the new amount of data read from the channel this . bytesRead += this . buffer . remaining ( ) ; return true ; } } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "checkMultiReadBuffer: no more buffer ->" + this ) ; } return false ; }
Check the input buffer for data . If necessary attempt a read for a new buffer and store it .