private static boolean charIsEscaped ( String str , int index ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( tc , "charIsEscaped" , new Object [ ] { str , index } ) ; // precondition, null str or out of range index returns false. if ( str == null || index < 0 || index >= str . length ( ) ) return false ; // A character is escaped if it is preceded by an odd number of '\'s. int nEscape = 0 ; int i = index - 1 ; while ( i >= 0 && str . charAt ( i ) == ' ' ) { nEscape ++ ; i -- ; } boolean result = nEscape % 2 == 1 ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( tc , "charIsEscaped" , result ) ; return result ; }
Test if the specified character is escaped . Checks whether the character at the specified index is preceded by an escape character . The test is non - trivial because it has to check that the escape character is itself non - escaped .