protected Link nextLink ( Link start , Transaction transaction , long transactionUnlockPoint ) throws ObjectManagerException { if ( Tracing . isAnyTracingEnabled ( ) && trace . isEntryEnabled ( ) ) trace . entry ( this , cclass , "nextLink" , new Object [ ] { start , transaction , new Long ( transactionUnlockPoint ) , head , availableHead } ) ; Token nextToken = null ; Link nextLink = null ; // The link to return. if ( start == null ) { // Start at the head of the list? if ( availableHead == null ) { availableHead = head ; skipToBeDeleted ( ) ; } // if (availableHead == null). nextToken = availableHead ; } else if ( start . state == Link . stateRemoved || start . state == Link . stateDeleted ) { // Start in the body of the list, as long as the start point is not already deleted. // Deleted links are no longer part of the list. if ( Tracing . isAnyTracingEnabled ( ) && trace . isEntryEnabled ( ) ) trace . exit ( this , cclass , "nextLink" , "returns null" + " start link is deleted" ) ; return null ; } else { // if in body but deleted. nextToken = start . next ; } // if (start == null). // Move forward through the ramaining list until we find an element // that is visible to this transaction. searchForward : while ( nextToken != null ) { nextLink = ( Link ) ( nextToken . getManagedObject ( ) ) ; if ( nextLink . state == Link . stateAdded ) if ( ! nextLink . wasLocked ( transactionUnlockPoint ) ) break searchForward ; // Transaction may be null, indicaiting sateToBeAdded links are not eligible. if ( nextLink . state == Link . stateToBeAdded && transaction != null && nextLink . lockedBy ( transaction ) ) break searchForward ; nextToken = nextLink . next ; // Try the folowing link. } // while (nextToken != null ). if ( nextToken == null ) { // At the end of the list? if ( Tracing . isAnyTracingEnabled ( ) && trace . isEntryEnabled ( ) ) trace . exit ( this , cclass , "nextLink" , "returns null" + " empty list" ) ; return null ; } // (nextToken == null). if ( Tracing . isAnyTracingEnabled ( ) && trace . isEntryEnabled ( ) ) trace . exit ( this , cclass , "nextLink" , new Object [ ] { nextLink } ) ; return nextLink ; }
Find the next link after the start link visible to a transaction before the unlockPoint .