question: void deleteTokens ( int startIndex , int endIndex ) throws Exception { ArrayList updatedRawTokens = new ArrayList ( ) ; updatedRawTokens . addAll ( getRawTokens ( ) ) ; Iterator it = updatedRawTokens . iterator ( ) ; boolean delete = false ; int deleteCount = 0 ; Token lastToken = null ; while ( it . hasNext ( ) ) { Token nextToken = ( Token ) it . next ( ) ; if ( ! delete ) { if ( nextToken . getTokenIndex ( ) == startIndex ) { if ( lastToken != null && lastToken instanceof WhiteSpaceToken ) { lastToken . markDeleted ( ) ; } nextToken . markDeleted ( ) ; deleteCount ++ ; if ( startIndex != endIndex ) { delete = true ; } } } else { deleteCount ++ ; nextToken . markDeleted ( ) ; if ( nextToken . getTokenIndex ( ) == endIndex ) { delete = false ; break ; } } lastToken = nextToken ; } if ( delete == true ) { throw new Exception ( "Failed to find last token: index " + endIndex ) ; } if ( startIndex != endIndex && deleteCount < 2 ) { throw new Exception ( "Failed to delete tokens for range: " + startIndex + "-" + endIndex ) ; } if ( startIndex == endIndex && deleteCount != 1 ) { throw new Exception ( "Failed to delete token at index: " + startIndex + ", delete count: " + deleteCount ) ; } setRawTokens ( updatedRawTokens ) ; }
target:  Deletes the tokens from the token whoes index matches with startIndex upto the token whoes index matches with endIndex. Both these tokens are included in the deletion as well.