KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > search > ui > text > TextSearchQueryProvider


1 /*******************************************************************************
2  * Copyright (c) 2006 Wind River Systems 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  * Markus Schorn - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.search.ui.text;
13
14 import org.eclipse.core.runtime.CoreException;
15
16 import org.eclipse.core.resources.IResource;
17
18 import org.eclipse.ui.IWorkingSet;
19
20 import org.eclipse.search.ui.ISearchQuery;
21
22 import org.eclipse.search.internal.ui.SearchPlugin;
23
24 /**
25  * Abstract base class for text search query providers supplied via the <code>org.eclipse.search.textSearchQueryProvider</code>
26  * extension point. The plug-in preference <code>org.eclipse.search.textSearchQueryProvider<code> defines the preferred
27  * query provider. It is intended that only products choose a preferred query provider.
28  *
29  * @since 3.2
30  */

31 public abstract class TextSearchQueryProvider {
32
33     /**
34      * Specified the input for a search query.
35      * <p>
36      * Clients may instantiate this class.
37      * </p>
38      */

39     public static abstract class TextSearchInput {
40         
41         /**
42          * Returns the search text to search for.
43          *
44          * @return the search text, depending on {@link #isRegExSearch()} the search text represents a regular expression
45          * or a pattern using '*' and '?' as wildcards. The empty search text signals a file name search.
46          */

47         public abstract String JavaDoc getSearchText();
48         
49         /**
50          * Returns whether the search is a case sensitive search or not.
51          *
52          * @return whether the pattern is to be used case sensitive or not.
53          */

54         public abstract boolean isCaseSensitiveSearch();
55         
56         /**
57          * Returns whether the search text denotes a regular expression or not.
58          *
59          * @return whether the pattern denotes a regular expression.
60          */

61         public abstract boolean isRegExSearch();
62         
63         /**
64          * Returns the scope for the search
65          *
66          * @return the scope for the search
67          */

68         public abstract FileTextSearchScope getScope();
69
70     }
71     
72     /**
73      * Returns the preferred query provider. The preferred query provider is typically configured by the product
74      * and defined by the search plug-in preference 'org.eclipse.search.textSearchQueryProvider'.
75      * It is not intended that query providers change at runtime, but clients should always use this method to access
76      * the query provider.
77      *
78      * @return the preferred {@link TextSearchQueryProvider}.
79      */

80     public static TextSearchQueryProvider getPreferred() {
81         return SearchPlugin.getDefault().getTextSearchQueryProviderRegistry().getPreferred();
82     }
83
84     /**
85      * Create a query for the input with the given information.
86      *
87      * @param textSearchInput the search input
88      * @return returns the created search query
89      * @throws CoreException a {@link CoreException} can be thrown when the query provider can not
90      * create a query for the given input.
91      */

92     public abstract ISearchQuery createQuery(TextSearchInput textSearchInput) throws CoreException;
93     
94     /**
95      * Create a query to search for the selected text in the workspace.
96      *
97      * @param selectedText the text to search for
98      * @return returns the created search query
99      * @throws CoreException a {@link CoreException} can be thrown when the query provider can not
100      * create a query for the given input.
101      */

102     public abstract ISearchQuery createQuery(String JavaDoc selectedText) throws CoreException;
103
104     /**
105      * Create a query to search for the selected text in the given resources.
106      *
107      * @param selectedText the text to search for
108      * @param resources the resources to search in
109      * @return returns the created search query
110      * @throws CoreException a {@link CoreException} can be thrown when the query provider can not
111      * create a query for the given input.
112      */

113     public abstract ISearchQuery createQuery(String JavaDoc selectedText, IResource[] resources) throws CoreException;
114         
115     /**
116      * Create a query to search for the selected text in the given working sets.
117      *
118      * @param selectedText the text to search for
119      * @param ws the working sets to search in
120      * @return returns the created search query
121      * @throws CoreException a {@link CoreException} can be thrown when the query provider can not
122      * create a query for the given input.
123      */

124     public abstract ISearchQuery createQuery(String JavaDoc selectedText, IWorkingSet[] ws) throws CoreException;
125 }
126
Popular Tags