/** * <p> * Sets the position in the target text at which the next search will start. * This method clears any previous match. * </p> * @param position position from which to start the next search * @exception IndexOutOfBoundsException thrown if argument position is out * of the target text range. * @see #getIndex * @stable ICU 2.8 */ public void setIndex(int position) { if (position < search_.beginIndex() || position > search_.endIndex()) { throw new IndexOutOfBoundsException( "setIndex(int) expected position to be between " + search_.beginIndex() + " and " + search_.endIndex()); } search_.reset_ = false; search_.setMatchedLength(0); search_.matchedIndex_ = DONE; }
|| startIdx > search_.endIndex()) { throw new IllegalArgumentException("searchBackwards(" + startIdx + ", m) - expected position to be between " + search_.beginIndex() + " and " + search_.endIndex()); if (startIdx < search_.endIndex()) { BreakIterator bi = search_.internalBreakIter_; int next = bi.following(startIdx);
search_.reset_ = false; if (search_.isForwardSearching_) { int endIdx = search_.endIndex(); if (index == endIdx || matchindex == endIdx || (matchindex != DONE &&
int index; // offset in ICU4C if (search_.reset_) { index = search_.endIndex(); // m_search_->textLength in ICU4C search_.isForwardSearching_ = false; search_.reset_ = false;
/** * Returns the last index in the target text at which it matches the * search pattern. The iterator is adjusted so that its current index * (as returned by {@link #getIndex}) is the match position if one was * found. * If a match is not found, {@link #DONE} will be returned and * the iterator will be adjusted to the index {@link #DONE}. * * @return The index of the first match, or {@link #DONE} if * there are no matches. * @see #getIndex * @stable ICU 2.0 */ public final int last() { int endIdx = search_.endIndex(); setIndex(endIdx); return handlePrevious(endIdx); }
/** * {@inheritDoc} * @stable ICU 2.8 */ @Override public int getIndex() { int result = textIter_.getOffset(); if (isOutOfBounds(search_.beginIndex(), search_.endIndex(), result)) { return DONE; } return result; }