question: int checkIfSargableAndRemoveEscapeChars ( ExecutionContext context , StringBuffer buffer ) { int len = buffer . length ( ) ; int wildcardPosition = - 1 ; for ( int i = 0 ; i < len ; ++ i ) { char ch = buffer . charAt ( i ) ; if ( ch == UNDERSCORE ) { context . cachePut ( wildcardTypeKey , WILDCARD_UNDERSCORE ) ; wildcardPosition = i ; break ; } else if ( ch == PERCENT ) { context . cachePut ( wildcardTypeKey , WILDCARD_PERCENT ) ; wildcardPosition = i ; break ; } else if ( ch == BACKSLASH ) { if ( i + 1 < len ) { if ( buffer . charAt ( i + 1 ) == PERCENT || buffer . charAt ( i + 1 ) == UNDERSCORE ) { wildcardPosition = - 1 ; } buffer . deleteCharAt ( i ) ; len -- ; } } } return wildcardPosition ; }
target:  Checks if index can be used for Strings with wildcards. Two wild cards are supported % and _. The wildcard could be at any index position of the string.