public void setSource ( String newSource ) { source = nfd . normalize ( newSource ) ; done = false ; // catch degenerate case if ( newSource . length ( ) == 0 ) { pieces = new String [ 1 ] [ ] ; current = new int [ 1 ] ; pieces [ 0 ] = new String [ ] { "" } ; return ; } // find the segments List < String > segmentList = new ArrayList < String > ( ) ; int cp ; int start = 0 ; // i should be the end of the first code point // break up the string into segements int i = UTF16 . findOffsetFromCodePoint ( source , 1 ) ; for ( ; i < source . length ( ) ; i += Character . charCount ( cp ) ) { cp = source . codePointAt ( i ) ; if ( nfcImpl . isCanonSegmentStarter ( cp ) ) { segmentList . add ( source . substring ( start , i ) ) ; // add up to i start = i ; } } segmentList . add ( source . substring ( start , i ) ) ; // add last one // allocate the arrays, and find the strings that are CE to each segment pieces = new String [ segmentList . size ( ) ] [ ] ; current = new int [ segmentList . size ( ) ] ; for ( i = 0 ; i < pieces . length ; ++ i ) { if ( PROGRESS ) System . out . println ( "SEGMENT" ) ; pieces [ i ] = getEquivalents ( segmentList . get ( i ) ) ; } }
Set a new source for this iterator . Allows object reuse .