Eclipse Platform
Release 3.2

org.eclipse.search.core.text
Class TextSearchRequestor

java.lang.Object
  extended byorg.eclipse.search.core.text.TextSearchRequestor

public abstract class TextSearchRequestor
extends Object

Collects the results from a search engine query. Clients implement a subclass to pass to TextSearchEngine.search(TextSearchScope, TextSearchRequestor, java.util.regex.Pattern, org.eclipse.core.runtime.IProgressMonitor) and implement the acceptPatternMatch(TextSearchMatchAccess) method, and possibly override other life cycle methods.

The search engine calls beginReporting() when a search starts, then calls acceptFile(IFile) for a file visited followed by acceptPatternMatch(TextSearchMatchAccess) for each pattern match found in this file. The end of the search is signaled with a call to endReporting(). Note that acceptFile(IFile) is called for all files in the search scope, even if no match can be found.

The order of the search results is unspecified and may vary from request to request; when displaying results, clients should not rely on the order but should instead arrange the results in an order that would be more meaningful to the user.

Since:
3.2
See Also:
TextSearchEngine

Constructor Summary
TextSearchRequestor()
           
 
Method Summary
 boolean acceptFile(IFile file)
          Notification sent before search starts in the given file.
 boolean acceptFile(IResourceProxy fileProxy)
          Deprecated. This API will be removed before M5. Use acceptFile(IFile) instead.
 boolean acceptPatternMatch(TextSearchMatchAccess matchAccess)
          Accepts the given search match.
 void beginReporting()
          Notification sent before starting the search action.
 void endReporting()
          Notification sent after having completed the search action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextSearchRequestor

public TextSearchRequestor()
Method Detail

beginReporting

public void beginReporting()
Notification sent before starting the search action. Typically, this would tell a search requestor to clear previously recorded search results.

The default implementation of this method does nothing. Subclasses may override.


endReporting

public void endReporting()
Notification sent after having completed the search action. Typically, this would tell a search requestor collector that no more results will be forthcoming in this search.

The default implementation of this method does nothing. Subclasses may override.


acceptFile

public boolean acceptFile(IResourceProxy fileProxy)
                   throws CoreException
Deprecated. This API will be removed before M5. Use acceptFile(IFile) instead.

Notification sent before search starts in the given file. This method is called for all files that are contained in the search scope. The fileProxy is guaranteed to be of type IResource.FILE Implementors can decide if the file content should be searched for search matches or not.

Parameters:
fileProxy - proxy of a file resource to be searched.
Returns:
If false, no pattern matches will be reported for the content of this file.
Throws:
CoreException - implementors can throw a CoreException if accessing the resource fails or another problem prevented the processing of the search match.

acceptFile

public boolean acceptFile(IFile file)
                   throws CoreException
Notification sent before search starts in the given file. This method is called for all files that are contained in the search scope. The fileProxy is guaranteed to be of type IResource.FILE Implementors can decide if the file content should be searched for search matches or not.

Parameters:
file - the file resource to be searched.
Returns:
If false, no pattern matches will be reported for the content of this file.
Throws:
CoreException - implementors can throw a CoreException if accessing the resource fails or another problem prevented the processing of the search match.

acceptPatternMatch

public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess)
                           throws CoreException
Accepts the given search match.

Parameters:
matchAccess - gives access to information of the match found. The matchAccess is not a value object. Its value might change after this method is finished, and the element might be reused.
Returns:
If false is returned no further matches will be reported for this file.
Throws:
CoreException - implementors can throw a CoreException if accessing the resource fails or another problem prevented the processing of the search match.

Eclipse Platform
Release 3.2

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.