SearchContext
Date: 2017-02-11

org.fife.ui.rtextarea

## Class SearchContext

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

- All Implemented Interfaces:
    java.lang.Cloneable

      public class SearchContext
      extends java.lang.Object
      implements java.lang.Cloneable

  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.
  See Also:
    `SearchEngine`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `PROPERTY_MARK_ALL` Fired when the user toggles the "Mark All" property.
    `static java.lang.String` | `PROPERTY_MATCH_CASE` Fired when the "match case" property is toggled.
    `static java.lang.String` | `PROPERTY_MATCH_WHOLE_WORD` Fired when the "whole word" property is toggled.
    `static java.lang.String` | `PROPERTY_REPLACE_WITH` Fired when the "replace with" property is modified.
    `static java.lang.String` | `PROPERTY_SEARCH_FOR` Fired when the "search for" property is modified.
    `static java.lang.String` | `PROPERTY_SEARCH_FORWARD` Fired when search direction is toggled.
    `static java.lang.String` | `PROPERTY_SELECTION_ONLY` Fired when "search in selection" is toggled (not currently supported).
    `static java.lang.String` | `PROPERTY_USE_REGEX` Fired when "use regular expressions" is toggled.

  - ### Constructor Summary

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

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addPropertyChangeListener(java.beans.PropertyChangeListener l)` Adds a property change listener to this context.
    `SearchContext` | `clone()`
    `protected void` | `firePropertyChange(java.lang.String property, boolean oldValue, boolean newValue)`
    `protected void` | `firePropertyChange(java.lang.String property, java.lang.String oldValue, java.lang.String newValue)`
    `boolean` | `getMarkAll()` Returns whether "mark all" should be selected or enabled.
    `boolean` | `getMatchCase()` Returns whether case should be honored while searching.
    `java.lang.String` | `getReplaceWith()` Returns the text to replace with, if doing a replace operation.
    `java.lang.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` | `removePropertyChangeListener(java.beans.PropertyChangeListener l)` Removes a property change listener from this context.
    `void` | `setMarkAll(boolean markAll)` Sets whether "mark all" should be selected or enabled.
    `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.This method fires a property change event of type `PROPERTY_USE_REGEX`
    `void` | `setReplaceWith(java.lang.String replaceWith)` Sets the text to replace with, if doing a replace operation.
    `void` | `setSearchFor(java.lang.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.
    `java.lang.String` | `toString()`

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

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

- - ### Field Detail

    - #### PROPERTY_SEARCH_FOR

          public static final java.lang.String PROPERTY_SEARCH_FOR

      Fired when the "search for" property is modified.
      See Also:
        Constant Field Values

    - #### PROPERTY_REPLACE_WITH

          public static final java.lang.String PROPERTY_REPLACE_WITH

      Fired when the "replace with" property is modified.
      See Also:
        Constant Field Values

    - #### PROPERTY_MATCH_CASE

          public static final java.lang.String PROPERTY_MATCH_CASE

      Fired when the "match case" property is toggled.
      See Also:
        Constant Field Values

    - #### PROPERTY_MATCH_WHOLE_WORD

          public static final java.lang.String PROPERTY_MATCH_WHOLE_WORD

      Fired when the "whole word" property is toggled.
      See Also:
        Constant Field Values

    - #### PROPERTY_SEARCH_FORWARD

          public static final java.lang.String PROPERTY_SEARCH_FORWARD

      Fired when search direction is toggled.
      See Also:
        Constant Field Values

    - #### PROPERTY_SELECTION_ONLY

          public static final java.lang.String PROPERTY_SELECTION_ONLY

      Fired when "search in selection" is toggled (not currently supported).
      See Also:
        Constant Field Values

    - #### PROPERTY_USE_REGEX

          public static final java.lang.String PROPERTY_USE_REGEX

      Fired when "use regular expressions" is toggled.
      See Also:
        Constant Field Values

    - #### PROPERTY_MARK_ALL

          public static final java.lang.String PROPERTY_MARK_ALL

      Fired when the user toggles the "Mark All" property.
      See Also:
        Constant Field Values

  - ### 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(java.lang.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(java.lang.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

    - #### addPropertyChangeListener

          public void addPropertyChangeListener(java.beans.PropertyChangeListener l)

      Adds a property change listener to this context.
      Parameters:
        `l` - The new listener.
      See Also:
        `removePropertyChangeListener(PropertyChangeListener)`

    - #### clone

          public SearchContext clone()

      Overrides:
        `clone` in class `java.lang.Object`

    - #### firePropertyChange

          protected void firePropertyChange(java.lang.String property,
                                boolean oldValue,
                                boolean newValue)

    - #### firePropertyChange

          protected void firePropertyChange(java.lang.String property,
                                java.lang.String oldValue,
                                java.lang.String newValue)

    - #### getMarkAll

          public boolean getMarkAll()

      Returns whether "mark all" should be selected or enabled.
      Returns:
        Whether "mark all" should be enabled.
      See Also:
        `setMarkAll(boolean)`

    - #### getMatchCase

          public boolean getMatchCase()

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

    - #### getReplaceWith

          public java.lang.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 java.lang.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)`

    - #### removePropertyChangeListener

          public void removePropertyChangeListener(java.beans.PropertyChangeListener l)

      Removes a property change listener from this context.
      Parameters:
        `l` - The listener to remove.
      See Also:
        `addPropertyChangeListener(PropertyChangeListener)`

    - #### setMarkAll

          public void setMarkAll(boolean markAll)

      Sets whether "mark all" should be selected or enabled. This method fires property change events of type `PROPERTY_MARK_ALL`.
      Parameters:
        `markAll` - Whether "mark all" should be enabled.
      See Also:
        `getMarkAll()`

    - #### setMatchCase

          public void setMatchCase(boolean matchCase)

      Sets whether case should be honored while searching. This method fires a property change event of type `PROPERTY_MATCH_CASE`.
      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.This method fires a property change event of type `PROPERTY_USE_REGEX`
      Parameters:
        `regex` - Whether a regular expression search should be done.
      See Also:
        `isRegularExpression()`

    - #### setReplaceWith

          public void setReplaceWith(java.lang.String replaceWith)

      Sets the text to replace with, if doing a replace operation. This method fires a property change event of type `PROPERTY_REPLACE_WITH`.
      Parameters:
        `replaceWith` - The text to replace with.
      See Also:
        `getReplaceWith()`, `setSearchFor(String)`

    - #### setSearchFor

          public void setSearchFor(java.lang.String searchFor)

      Sets the text to search for. This method fires a property change event of type `PROPERTY_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). This method fires a property change event of type `PROPERTY_SEARCH_FORWARD`.
      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 method fires a property change event of type `PROPERTY_SELECTION_ONLY`.

      This flag is currently not supported. Calling this method will throw an `UnsupportedOperationException` until it is implemented.

      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.This method fires a property change event of type `PROPERTY_MATCH_WHOLE_WORD`.
      Parameters:
        `wholeWord` - Whether only "whole word" matches should be returned.
      See Also:
        `getWholeWord()`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`