protected ORecord readCurrentRecord ( ORecord iRecord , final int iMovement ) { if ( limit > - 1 && browsedRecords >= limit ) // LIMIT REACHED return null ; do { final boolean moveResult ; switch ( iMovement ) { case 1 : moveResult = nextPosition ( ) ; break ; case - 1 : moveResult = prevPosition ( ) ; break ; case 0 : moveResult = checkCurrentPosition ( ) ; break ; default : throw new IllegalStateException ( "Invalid movement value : " + iMovement ) ; } if ( ! moveResult ) return null ; try { if ( iRecord != null ) { ORecordInternal . setIdentity ( iRecord , new ORecordId ( current . getClusterId ( ) , current . getClusterPosition ( ) ) ) ; iRecord = database . load ( iRecord , fetchPlan , false ) ; } else iRecord = database . load ( current , fetchPlan , false ) ; } catch ( ODatabaseException e ) { if ( Thread . interrupted ( ) || database . isClosed ( ) ) // THREAD INTERRUPTED: RETURN throw e ; if ( e . getCause ( ) instanceof OSecurityException ) throw e ; brokenRIDs . add ( current . copy ( ) ) ; OLogManager . instance ( ) . error ( this , "Error on fetching record during browsing. The record has been skipped" , e ) ; } if ( iRecord != null ) { browsedRecords ++ ; return iRecord ; } } while ( iMovement != 0 ) ; return null ; }
Read the current record and increment the counter if the record was found .