@ Override public int previous ( ) { int result ; int startPos ; CharacterIterator text = getText ( ) ; fLastStatusIndexValid = false ; // if we have cached break positions and we're still in the range // covered by them, just move one step backward in the cache if ( fCachedBreakPositions != null ) { if ( fPositionInCache > 0 ) { -- fPositionInCache ; // If we're at the beginning of the cache, need to reevaluate the // rule status if ( fPositionInCache <= 0 ) { fLastStatusIndexValid = false ; } int pos = fCachedBreakPositions [ fPositionInCache ] ; text . setIndex ( pos ) ; return pos ; } else { reset ( ) ; } } // if we're already sitting at the beginning of the text, return DONE startPos = current ( ) ; if ( fText == null || startPos == fText . getBeginIndex ( ) ) { fLastRuleStatusIndex = 0 ; fLastStatusIndexValid = true ; return BreakIterator . DONE ; } // Rules with an exact reverse table are handled here. if ( fRData . fSRTable != null || fRData . fSFTable != null ) { result = handlePrevious ( fRData . fRTable ) ; if ( fDictionaryCharCount > 0 ) { result = checkDictionary ( result , startPos , true ) ; } return result ; } // old rule syntax // set things up. handlePrevious() will back us up to some valid // break position before the current position (we back our internal // iterator up one step to prevent handlePrevious() from returning // the current position), but not necessarily the last one before // where we started int start = current ( ) ; previous32 ( fText ) ; int lastResult = handlePrevious ( fRData . fRTable ) ; if ( lastResult == BreakIterator . DONE ) { lastResult = fText . getBeginIndex ( ) ; fText . setIndex ( lastResult ) ; } result = lastResult ; int lastTag = 0 ; boolean breakTagValid = false ; // iterate forward from the known break position until we pass our // starting point. The last break position before the starting // point is our return value for ( ; ; ) { result = next ( ) ; if ( result == BreakIterator . DONE || result >= start ) { break ; } lastResult = result ; lastTag = fLastRuleStatusIndex ; breakTagValid = true ; } // fLastBreakTag wants to have the value for section of text preceding // the result position that we are to return (in lastResult.) If // the backwards rules overshot and the above loop had to do two or more // handleNext()s to move up to the desired return position, we will have a valid // tag value. But, if handlePrevious() took us to exactly the correct result position, // we wont have a tag value for that position, which is only set by handleNext(). // Set the current iteration position to be the last break position // before where we started, and then return that value. fText . setIndex ( lastResult ) ; fLastRuleStatusIndex = lastTag ; // for use by getRuleStatus() fLastStatusIndexValid = breakTagValid ; return lastResult ; }
Moves the iterator backwards to the last boundary preceding this one .