protected int handleNext(){
  CharacterIterator text=getText();
  if (text.getIndex() == text.getEndIndex()) {
    return BreakIterator.DONE;
  }
  int result=getNextIndex();
  int lookaheadResult=0;
  int state=START_STATE;
  int category;
  int c=getCurrent();
  while (c != CharacterIterator.DONE && state != STOP_STATE) {
    category=lookupCategory(c);
    if (category != IGNORE) {
      state=lookupState(state,category);
    }
    if (lookaheadStates[state]) {
      if (endStates[state]) {
        result=lookaheadResult;
      }
 else {
        lookaheadResult=getNextIndex();
      }
    }
 else {
      if (endStates[state]) {
        result=getNextIndex();
      }
    }
    c=getNext();
  }
  if (c == CharacterIterator.DONE && lookaheadResult == text.getEndIndex()) {
    result=lookaheadResult;
  }
  text.setIndex(result);
  return result;
}

protected int handleNext ( ) { CharacterIterator text = getText ( ) ; if ( text . getIndex ( ) == text . getEndIndex ( ) ) { return BreakIterator . DONE ; } int result = getNextIndex ( ) ; int lookaheadResult = 0 ; int state = START_STATE ; int category ; int c = getCurrent ( ) ; while ( c != CharacterIterator . DONE && state != STOP_STATE ) { category = lookupCategory ( c ) ; if ( category != IGNORE ) { state = lookupState ( state , category ) ; } if ( lookaheadStates [ state ] ) { if ( endStates [ state ] ) { result = lookaheadResult ; } else { lookaheadResult = getNextIndex ( ) ; } } else { if ( endStates [ state ] ) { result = getNextIndex ( ) ; } } c = getNext ( ) ; } if ( c == CharacterIterator . DONE && lookaheadResult == text . getEndIndex ( ) ) { result = lookaheadResult ; } text . setIndex ( result ) ; return result ; }
this method is the actual implementation of the next ( ) method . all iteration vectors through here . this method initializes the state machine to state 1 and advances through the text character by character until we reach the end of the text or the state machine transitions to state 0 . we update our return value every time the state machine passes through a possible end state .
