public void setTarget ( CharacterIterator text ) { if ( text == null || text . getEndIndex ( ) == text . getIndex ( ) ) { throw new IllegalArgumentException ( "Illegal null or empty text" ) ; } text . setIndex ( text . getBeginIndex ( ) ) ; search_ . setTarget ( text ) ; search_ . matchedIndex_ = DONE ; search_ . setMatchedLength ( 0 ) ; search_ . reset_ = true ; search_ . isForwardSearching_ = true ; if ( search_ . breakIter ( ) != null ) { // Create a clone of CharacterItearator, so it won't // affect the position currently held by search_.text() search_ . breakIter ( ) . setText ( ( CharacterIterator ) text . clone ( ) ) ; } if ( search_ . internalBreakIter_ != null ) { search_ . internalBreakIter_ . setText ( ( CharacterIterator ) text . clone ( ) ) ; } }
Set the target text to be searched . Text iteration will then begin at the start of the text string . This method is useful if you want to reuse an iterator to search within a different body of text .