public synchronized long position ( byte [ ] pattern , long start ) throws SQLException { assertPosition ( start , pattern . length ) ; int position = 1 ; int patternIdx = 0 ; long result = - 1 ; int tmpPosition = 1 ; for ( LOIterator i = new LOIterator ( start - 1 ) ; i . hasNext ( ) ; position ++ ) { byte b = i . next ( ) ; if ( b == pattern [ patternIdx ] ) { if ( patternIdx == 0 ) { tmpPosition = position ; } patternIdx ++ ; if ( patternIdx == pattern . length ) { result = tmpPosition ; break ; } } else { patternIdx = 0 ; } } return result ; }
Iterate over the buffer looking for the specified pattern .