Package org.eclipse.search.ui.text
Class AbstractTextSearchResult
java.lang.Object
org.eclipse.search.ui.text.AbstractTextSearchResult
- All Implemented Interfaces:
ISearchResult
An abstract base implementation for text-match based search results. This search
result implementation consists of a list of
matches.
No assumptions are made about the kind of elements these matches are reported against.- Since:
- 3.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a newAbstractTextSearchResult -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds aISearchResultListener.voidAdds aMatchto this search result.voidaddMatches(Match[] matches) Adds a number of Matches to this search result.protected voidSend the givenSearchResultEventto all registered search result listeners.Returns the active match filters for this result.Returns all applicable filters for this result or null if match filters are not supported.abstract IEditorMatchAdapterReturns an implementation ofIEditorMatchAdapterappropriate for this search result.Object[]Returns an array containing the set of all elements that matches are reported against in this search result.abstract IFileMatchAdapterReturns an implementation ofIFileMatchAdapterappropriate for this search result.intReturns the total number of matches contained in this search result.intgetMatchCount(Object element) Returns the number of matches reported against a given element.Match[]getMatches(Object element) Returns an array with all matches reported against the given element.getMatchSet(Object element) Returns an Enumeration of all matches reported against the given element.voidRemoves all matches from this search result.voidRemoves aISearchResultChangedListener.voidremoveMatch(Match match) Removes the given match from this search result.voidremoveMatches(Match[] matches) Removes the given matches from this search result.voidsetActiveMatchFilters(MatchFilter[] filters) Sets the active match filters for this result.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.search.ui.ISearchResult
getImageDescriptor, getLabel, getQuery, getTooltip
-
Constructor Details
-
AbstractTextSearchResult
protected AbstractTextSearchResult()Constructs a newAbstractTextSearchResult
-
-
Method Details
-
getMatches
Returns an array with all matches reported against the given element. Note that all matches of the given element are returned. The filter state of the matches is not relevant. The matches are reported sorted per offset and length. The order may be important for example stepping between matches (see bug 58417). For calculating just a match count the order is not needed and the fastergetMatchSet(Object)should be used instead. The order of reported matches found (with equal offset and length) is not preserved (Does not make sense during parallel search).- Parameters:
element- the element to report matches for- Returns:
- all matches reported for this element
- See Also:
-
getMatchSet
Returns an Enumeration of all matches reported against the given element. Note that all matches of the given element are returned. The filter state of the matches is not relevant. LikegetMatches(Object)but unordered result.- Parameters:
element- the element to report matches for- Returns:
- all matches reported for this element
- Since:
- 3.14
- See Also:
-
addMatch
Adds aMatchto this search result. This method does nothing if the match is already present.Subclasses may extend this method.
- Parameters:
match- the match to add
-
addMatches
Adds a number of Matches to this search result. This method does nothing for matches that are already present.Subclasses may extend this method.
- Parameters:
matches- the matches to add
-
removeAll
public void removeAll()Removes all matches from this search result.Subclasses may extend this method.
-
removeMatch
Removes the given match from this search result. This method has no effect if the match is not found.Subclasses may extend this method.
- Parameters:
match- the match to remove
-
removeMatches
Removes the given matches from this search result. This method has no effect for matches that are not foundSubclasses may extend this method.
- Parameters:
matches- the matches to remove
-
addListener
Description copied from interface:ISearchResultAdds aISearchResultListener. Has no effect when the listener has already been added.- Specified by:
addListenerin interfaceISearchResult- Parameters:
l- the listener to be added
-
removeListener
Description copied from interface:ISearchResultRemoves aISearchResultChangedListener. Has no effect when the listener hasn't previously been added.- Specified by:
removeListenerin interfaceISearchResult- Parameters:
l- the listener to be removed
-
fireChange
Send the givenSearchResultEventto all registered search result listeners.- Parameters:
e- the event to be sent- See Also:
-
getMatchCount
public int getMatchCount()Returns the total number of matches contained in this search result. The filter state of the matches is not relevant when counting matches. All matches are counted.- Returns:
- total number of matches
-
getMatchCount
Returns the number of matches reported against a given element. This is equivalent to callinggetMatches(element).lengthThe filter state of the matches is not relevant when counting matches. All matches are counted.- Parameters:
element- the element to get the match count for- Returns:
- the number of matches reported against the element
-
getElements
Returns an array containing the set of all elements that matches are reported against in this search result. Note that all elements that contain matches are returned. The filter state of the matches is not relevant.- Returns:
- the set of elements in this search result
-
setActiveMatchFilters
Sets the active match filters for this result. If set to non-null, the match filters will be used to update the filter state (Match.isFiltered()of matches and theAbstractTextSearchViewPagewill only show non-filtered matches. Ifnullis set the filter state of the match is ignored by theAbstractTextSearchViewPageand all matches are shown. Note the model contains all matches, regardless if the filter state of a match.- Parameters:
filters- the match filters to set ornullif the filter state of the match should be ignored.- Since:
- 3.3
-
getActiveMatchFilters
Returns the active match filters for this result. If not null is returned, the match filters will be used to update the filter state (Match.isFiltered()of matches and theAbstractTextSearchViewPagewill only show non-filtered matches. Ifnullis set the filter state of the match is ignored by theAbstractTextSearchViewPageand all matches are shown.- Returns:
- the match filters to be used or
nullif the filter state of the match should be ignored. - Since:
- 3.3
-
getAllMatchFilters
Returns all applicable filters for this result or null if match filters are not supported. If match filters are returned, theAbstractTextSearchViewPagewill contain menu entries in the view menu.- Returns:
- all applicable filters for this result.
- Since:
- 3.3
-
getEditorMatchAdapter
Returns an implementation ofIEditorMatchAdapterappropriate for this search result.- Returns:
- an appropriate adapter or
nullif none has been implemented - See Also:
-
getFileMatchAdapter
Returns an implementation ofIFileMatchAdapterappropriate for this search result.- Returns:
- an appropriate adapter or
nullif none has been implemented - See Also:
-