@Override public int previous() { return fIcuBrkItr.previous(); }
@Override public int previous() { return internalPrev(delegate.previous()); }
/** * Sets the iterator's current iteration position to be the last * boundary position preceding the specified position. (Whether the * specified position is itself a boundary position or not doesn't * matter-- this function always moves the iteration position to the * last boundary before the specified position.) If the specified * position is the starting position, returns DONE. * @param offset The character position to start searching from. * @return The position of the last boundary position preceding * "offset" (whether of not "offset" itself is a boundary position), * or DONE if "offset" is the starting offset of the iterator. * @stable ICU 2.0 */ public int preceding(int offset) { // NOTE: This implementation is here solely because we can't add new // abstract methods to an existing class. There is almost ALWAYS a // better, faster way to do this. int pos = following(offset); while (pos >= offset && pos != DONE) pos = previous(); return pos; }
/** * Sets the iterator's current iteration position to be the last * boundary position preceding the specified position. (Whether the * specified position is itself a boundary position or not doesn't * matter-- this function always moves the iteration position to the * last boundary before the specified position.) If the specified * position is the starting position, returns DONE. * @param offset The character position to start searching from. * @return The position of the last boundary position preceding * "offset" (whether of not "offset" itself is a boundary position), * or DONE if "offset" is the starting offset of the iterator. * @stable ICU 2.0 */ public int preceding(int offset) { // NOTE: This implementation is here solely because we can't add new // abstract methods to an existing class. There is almost ALWAYS a // better, faster way to do this. int pos = following(offset); while (pos >= offset && pos != DONE) pos = previous(); return pos; }
/** * Sets the iterator's current iteration position to be the last * boundary position preceding the specified position. (Whether the * specified position is itself a boundary position or not doesn't * matter-- this function always moves the iteration position to the * last boundary before the specified position.) If the specified * position is the starting position, returns DONE. * @param offset The character position to start searching from. * @return The position of the last boundary position preceding * "offset" (whether of not "offset" itself is a boundary position), * or DONE if "offset" is the starting offset of the iterator. * @stable ICU 2.0 */ public int preceding(int offset) { // NOTE: This implementation is here solely because we can't add new // abstract methods to an existing class. There is almost ALWAYS a // better, faster way to do this. int pos = following(offset); while (pos >= offset && pos != DONE) pos = previous(); return pos; }
/** * Given that the delegate has already given its "initial" answer, * find the PREV actual (non-suppressed) break. * @param n initial position from delegate * @return new break position or BreakIterator.DONE */ private final int internalPrev(int n) { if (n == 0 || n == BreakIterator.DONE || // at end or backwardsTrie == null) { // .. no backwards table loaded == no exceptions return n; } resetState(); while (n != BreakIterator.DONE && n != 0) { // outer loop runs once per underlying break (from fDelegate). // loops while 'n' points to an exception. if (breakExceptionAt(n)) { // n points to a break exception n = delegate.previous(); } else { // no exception at this spot return n; } } return n; //hit underlying DONE or break at end of text }