Package org.omegat.core.search
Class Searcher
java.lang.Object
org.omegat.core.search.Searcher
This class implements search functionality. It is non-reentrant: each
searcher instance must be used by a single thread.
THREAD SAFETY: This class is NOT thread-safe for concurrent access. However, it supports the following safe usage pattern:
- Thread A creates Searcher instance and calls search()
- Thread A completes search() execution completely
- Thread B can safely call getSearchResults() and other getter methods after Thread A completes
VISIBILITY: The searchCompleted flag ensures proper visibility of search results between threads.
-
Constructor Summary
ConstructorsConstructorDescriptionSearcher(IProject project, SearchExpression searchExpression) Create new searcher instance. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves a list of matches found during the search operation.Returns list of search results.booleanIndicates whether the search operation has been completed.voidsearch()Search for this.expression and return a list of results.booleansearchString(@Nullable String origText) Looks for an occurrence of the search string(s) in the supplied text string.booleansearchString(@Nullable String origText, boolean collapseResults) voidsearchText(String seg, @Nullable String translation, @Nullable String filename) voidSet cancellation token for checking stop requests.voidsetThread(LongProcessThread thread) Deprecated.
-
Constructor Details
-
Searcher
Create new searcher instance.- Parameters:
project- Current project
-
-
Method Details
-
setCancellationToken
Set cancellation token for checking stop requests. Preferred oversetThread(LongProcessThread). -
setThread
Deprecated.Set thread for checking interruption. -
getExpression
-
getSearchResults
Returns list of search results. -
search
Search for this.expression and return a list of results.- Throws:
IOException- when searching files goes wrong
-
isSearchCompleted
public boolean isSearchCompleted()Indicates whether the search operation has been completed.- Returns:
- true if the search has been completed; false otherwise.
-
searchString
Looks for an occurrence of the search string(s) in the supplied text string.- Parameters:
origText- The text string to search in- Returns:
- True if the text string contains all search strings
-
searchString
-
getFoundMatches
Retrieves a list of matches found during the search operation.- Returns:
- a list of
SearchMatchobjects, where each object provides information about the match's start and end positions, and any associated replacement text.
-
searchText
-