Find logic

In a design that separates functionality from user interface another class would have been needed for the logic such as FindReplaceLogic for instance. Instead the following methods of FindReplaceDialog have the main logic

Method | Purpose
findNext | find the next occurrence of a given phrase from start or end of a given document either in upwards or downwards direction.
findWholeWords | Find the next whole word occurrence of the searched phrase from a given position.
isSeparator | determine whether or not a character is a word separator with the help of character array WORD_SEPARATORS.

In addition methods initFind, doFind and find are used on top of the above methods to

- initiate a find process ( initFind)
- manage multi document processing, if applicable ( find) and
- handle results of findNext (doFind )

Above methods are called by FindReplaceDialog when either the 'find next' button is pressed or when the next occurrence of a phrase to be replaced is searched during a replace operation.

See the next topic to find out more about how the replace logic works.