/** * Returns whether the end sequence was detected. * The rule acquires the rest of the word, using the * provided word detector, and tests to determine if * it ends with the end sequence. * * @param scanner the scanner to be used * @return <code>true</code> if the word ends on the given end sequence */ @Override protected boolean endSequenceDetected(ICharacterScanner scanner) { fBuffer.setLength(0); int c= scanner.read(); while (fDetector.isWordPart((char) c)) { fBuffer.append((char) c); c= scanner.read(); } scanner.unread(); if (fBuffer.length() >= fEndSequence.length) { for (int i=fEndSequence.length - 1, j= fBuffer.length() - 1; i >= 0; i--, j--) { if (fEndSequence[i] != fBuffer.charAt(j)) { unreadBuffer(scanner); return false; } } return true; } unreadBuffer(scanner); return false; }
/** * Returns whether the end sequence was detected. * The rule acquires the rest of the word, using the * provided word detector, and tests to determine if * it ends with the end sequence. * * @param scanner the scanner to be used * @return <code>true</code> if the word ends on the given end sequence */ @Override protected boolean endSequenceDetected(ICharacterScanner scanner) { fBuffer.setLength(0); int c= scanner.read(); while (fDetector.isWordPart((char) c)) { fBuffer.append((char) c); c= scanner.read(); } scanner.unread(); if (fBuffer.length() >= fEndSequence.length) { for (int i=fEndSequence.length - 1, j= fBuffer.length() - 1; i >= 0; i--, j--) { if (fEndSequence[i] != fBuffer.charAt(j)) { unreadBuffer(scanner); return false; } } return true; } unreadBuffer(scanner); return false; }