KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > search > ui > ISearchQuery


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.search.ui;
12 import org.eclipse.core.runtime.IProgressMonitor;
13 import org.eclipse.core.runtime.IStatus;
14 import org.eclipse.core.runtime.OperationCanceledException;
15 /**
16  * Represents a particular search query (in a Java example, a query might
17  * be "find all occurrences of 'foo' in workspace"). When it's run method is
18  * called, the query places any results it finds in the
19  * <code>ISearchResult</code> that can be accessed via getSearchResult().
20  * Note that <code>getSearchResult</code> may be called at any time, even
21  * before the <code>run()</code> method has been called. An empty search
22  * result should be returned in that case.
23  * <p>
24  * Clients may implement this interface.
25  * </p>
26  *
27  * @since 3.0
28  */

29 public interface ISearchQuery {
30     /**
31      * This is the method that actually does the work, i.e. finds the results of
32      * the search query.
33      *
34      * @param monitor the progress monitor to be used
35      *
36      * @return the status after completion of the search job.
37      * @throws OperationCanceledException Thrown when the search query has been canceled.
38      */

39     IStatus run(IProgressMonitor monitor) throws OperationCanceledException;
40     /**
41      * Returns a user readable label for this query. This will be used, for
42      * example to set the <code>Job</code> name if this query is executed in
43      * the background. Note that progress notification (for example, the number
44      * of matches found) should be done via the progress monitor passed into the
45      * <code>run(IProgressMonitor)</code> method
46      *
47      * @return the user readable label of this query
48      */

49     String JavaDoc getLabel();
50     /**
51      * Returns whether the query can be run more than once. Some queries may
52      * depend on transient information and return <code>false</code>.
53      *
54      * @return whether this query can be run more than once
55      */

56     boolean canRerun();
57     /**
58      * Returns whether this query can be run in the background. Note that
59      * queries must do proper locking when they are run in the background (e.g.
60      * get the appropriate workspace locks).
61      *
62      * @return whether this query can be run in the background
63      */

64     boolean canRunInBackground();
65     /**
66      * Returns the search result associated with this query. This method can be
67      * called before run is called.
68      *
69      * @return this query's search result
70      */

71     ISearchResult getSearchResult();
72 }
73
Popular Tags