Class SearchAndReplaceQuery

java.lang.Object
ghidra.features.base.replace.SearchAndReplaceQuery

public class SearchAndReplaceQuery extends Object
Immutable class for storing all related query information for performing a search and replace operation. It includes the search pattern, the search pattern text, the search lmiit, and the types of program elements to search.
  • Constructor Details

    • SearchAndReplaceQuery

      public SearchAndReplaceQuery(String searchText, String replacementText, Set<SearchType> searchTypes, boolean isRegEx, boolean isCaseSensitive, boolean isWholeWord, int searchLimit)
      Constructor
      Parameters:
      searchText - the user entered search pattern text. It will be used to generate the actual Pattern based on the various options.
      replacementText - the user entered replacement text.
      searchTypes - the types of program elements to search
      isRegEx - true if the given search text is to be interpreted as a regular expression.
      isCaseSensitive - true if the search text should be case sensitive
      isWholeWord - true, the search text should match the enter element in the case of a rename, or an entire word within a larger sentence in the case of a comment.
      searchLimit - the maximum entries to find before terminating the search.
  • Method Details

    • findAll

      public void findAll(Program program, Accumulator<QuickFix> accumulator, TaskMonitor monitor) throws CancelledException
      Method to initiate the search.
      Parameters:
      program - the program to search
      accumulator - the accumulator to store the generated QuickFixs
      monitor - the TaskMonitor
      Throws:
      CancelledException - if the search is cancelled.
    • getSearchPattern

      public Pattern getSearchPattern()
      Returns the search Pattern used to search program elements.
      Returns:
      the search Pattern used to search program elements
    • containsSearchType

      public boolean containsSearchType(SearchType searchType)
      Returns true if the given SearchType is to be included in the search.
      Parameters:
      searchType - the SearchType to check if it is included in the search
      Returns:
      true if the given SearchType is to be included in the search.
    • getSearchText

      public String getSearchText()
      Returns the search text used to generate the pattern for this query.
      Returns:
      the search text used to generate the pattern for this query
    • getReplacementText

      public String getReplacementText()
      Returns the replacement text that will replace matched elements.
      Returns:
      the replacement text that will replace matched elements
    • getSelectedSearchTypes

      public Set<SearchType> getSelectedSearchTypes()
      Returns a set of all the SearchTypes to be included in this query.
      Returns:
      a set of all the SearchTypes to be included in this query
    • getSearchLimit

      public int getSearchLimit()
      Returns the maximum number of search matches to be found before stopping early.
      Returns:
      the maximum number of search matches to be found before stopping early.