org.fife.ui.rtextarea

## Class SearchContext

- java.lang.Object
- - org.fife.ui.rtextarea.SearchContext

    public class SearchContext
    extends Object

Contains information about a find/replace operation. Applications can keep an instance of this class around and use it to maintain the user's selection for options such as "match case," "regular expression," etc., between search operations. They can then pass the instance as a parameter to the public `SearchEngine` methods to do the actual searching.

Version:
  1.0
Author:
  Robert Futrell
See Also:
  `SearchEngine`

### Constructor Summary

Constructors
Constructor and Description
`SearchContext()` Creates a new search context.
`SearchContext(String searchFor)` Creates a new search context.
`SearchContext(String searchFor, boolean matchCase)` Creates a new search context.

### Method Summary

Methods
`boolean` `getMatchCase()` Returns whether case should be honored while searching.
`String` `getReplaceWith()` Returns the text to replace with, if doing a replace operation.
`String` `getSearchFor()` Returns the text to search for.
`boolean` `getSearchForward()` Returns whether the search should be forward through the text (vs.
`boolean` `getSearchSelectionOnly()` Returns whether the search should only be done in the selected text.
`boolean` `getWholeWord()` Returns whether only "whole word" matches should be returned.
`boolean` `isRegularExpression()` Returns whether a regular expression search should be done.
`void` `setMatchCase(boolean matchCase)` Sets whether case should be honored while searching.
`void` `setRegularExpression(boolean regex)` Sets whether a regular expression search should be done.
`void` `setReplaceWith(String replaceWith)` Sets the text to replace with, if doing a replace operation.
`void` `setSearchFor(String searchFor)` Sets the text to search for.
`void` `setSearchForward(boolean forward)` Sets whether the search should be forward through the text (vs.
`void` `setSearchSelectionOnly(boolean selectionOnly)` Sets whether only the selected text should be searched.
`void` `setWholeWord(boolean wholeWord)` Sets whether only "whole word" matches should be returned.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SearchContext

    public SearchContext()

Creates a new search context. Specifies a forward search, case-insensitive, not whole-word, not a regular expression.

#### SearchContext

    public SearchContext(String searchFor)

Creates a new search context. Specifies a forward search, case-insensitive, not whole-word, not a regular expression.

Parameters:
  `searchFor` - The text to search for.

#### SearchContext

    public SearchContext(String searchFor,
                 boolean matchCase)

Creates a new search context. Specifies a forward search, not whole-word, not a regular expression.

Parameters:
  `searchFor` - The text to search for.
  `matchCase` - Whether to do a case-sensitive search.

### Method Detail

#### getMatchCase

    public boolean getMatchCase()

Returns whether case should be honored while searching.

Returns:
  Whether case should be honored.
See Also:
  `setMatchCase(boolean)`

#### getReplaceWith

    public String getReplaceWith()

Returns the text to replace with, if doing a replace operation.

Returns:
  The text to replace with.
See Also:
  `setReplaceWith(String)`, `getSearchFor()`

#### getSearchFor

    public String getSearchFor()

Returns the text to search for.

Returns:
  The text to search for.
See Also:
  `setSearchFor(String)`, `getReplaceWith()`

#### getSearchForward

    public boolean getSearchForward()

Returns whether the search should be forward through the text (vs. backwards).

Returns:
  Whether we should search forwards.
See Also:
  `setSearchForward(boolean)`

#### getSearchSelectionOnly

    public boolean getSearchSelectionOnly()

Returns whether the search should only be done in the selected text. This flag is currently not supported.

Returns:
  Whether only the selected text should be searched.
See Also:
  `setSearchSelectionOnly(boolean)`

#### getWholeWord

    public boolean getWholeWord()

Returns whether only "whole word" matches should be returned. A match is considered to be "whole word" if the character on either side of the matched text is a non-word character, or if there is no character on one side of the word, such as when it's at the beginning or end of a line.

Returns:
  Whether only "whole word" matches should be returned.
See Also:
  `setWholeWord(boolean)`

#### isRegularExpression

    public boolean isRegularExpression()

Returns whether a regular expression search should be done.

Returns:
  Whether a regular expression search should be done.
See Also:
  `setRegularExpression(boolean)`

#### setMatchCase

    public void setMatchCase(boolean matchCase)

Sets whether case should be honored while searching.

Parameters:
  `matchCase` - Whether case should be honored.
See Also:
  `getMatchCase()`

#### setRegularExpression

    public void setRegularExpression(boolean regex)

Sets whether a regular expression search should be done.

Parameters:
  `regex` - Whether a regular expression search should be done.
See Also:
  `isRegularExpression()`

#### setReplaceWith

    public void setReplaceWith(String replaceWith)

Sets the text to replace with, if doing a replace operation.

Parameters:
  `replaceWith` - The text to replace with.
See Also:
  `getReplaceWith()`, `setSearchFor(String)`

#### setSearchFor

    public void setSearchFor(String searchFor)

Sets the text to search for.

Parameters:
  `searchFor` - The text to search for.
See Also:
  `getSearchFor()`, `setReplaceWith(String)`

#### setSearchForward

    public void setSearchForward(boolean forward)

Sets whether the search should be forward through the text (vs. backwards).

Parameters:
  `forward` - Whether we should search forwards.
See Also:
  `getSearchForward()`

#### setSearchSelectionOnly

    public void setSearchSelectionOnly(boolean selectionOnly)

Sets whether only the selected text should be searched. This flag is currently not supported.

Parameters:
  `selectionOnly` - Whether only selected text should be searched.
See Also:
  `getSearchSelectionOnly()`

#### setWholeWord

    public void setWholeWord(boolean wholeWord)

Sets whether only "whole word" matches should be returned. A match is considered to be "whole word" if the character on either side of the matched text is a non-word character, or if there is no character on one side of the word, such as when it's at the beginning or end of a line.

Parameters:
  `wholeWord` - Whether only "whole word" matches should be returned.
See Also:
  `getWholeWord()`