Code example for CharacterIterator

Methods: getBeginIndex, getEndIndex, getIndex, setIndex

0
     * @see #DONE 
     * @stable ICU 2.0 
     */ 
    public int next() 
    { 
        int start = targetText.getIndex();
        if (m_setOffset_ != DONE) {
            start = m_setOffset_;    
            m_setOffset_ = DONE;    
        } 
        if (m_isForwardSearching_) {
            if (!m_reset_ && 
                start + matchLength >= targetText.getEndIndex()) {
                // not enough characters to match 
                matchLength = 0;
                targetText.setIndex(targetText.getEndIndex());
                m_lastMatchStart_ = DONE;
                return DONE; 
            } 
            m_reset_ = false;
        } 
        else { 
            // switching direction.  
            // if matchedIndex == USEARCH_DONE, it means that either a  
            // setIndex has been called or that previous ran off the text 
            // string. the iterator would have been set to offset 0 if a  
            // match is not found. 
            m_isForwardSearching_ = true;
            if (start != DONE) {
                // there's no need to set the collation element iterator 
                // the next call to next will set the offset. 
                return start;
            } 
        } 
         
        if (start == DONE) {
            start = targetText.getBeginIndex();
        } 
        if (matchLength > 0) {
            // if match length is 0 we are at the start of the iteration 
            if (m_isOverlap_) {
                start ++;