KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > search > PathCollector


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.jdt.internal.core.search;
12
13 import java.util.HashSet JavaDoc;
14 import java.util.Iterator JavaDoc;
15
16 import org.eclipse.jdt.core.search.SearchParticipant;
17 import org.eclipse.jdt.core.search.SearchPattern;
18 import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
19
20 /**
21  * Collects the resource paths reported by a client to this search requestor.
22  */

23 public class PathCollector extends IndexQueryRequestor {
24     
25     /* a set of resource paths */
26     public HashSet JavaDoc paths = new HashSet JavaDoc(5);
27     
28     /* (non-Javadoc)
29      * @seeIndexQueryRequestor#acceptIndexMatch(IndexRecord, SearchParticipant, SearchPattern)
30      */

31     public boolean acceptIndexMatch(String JavaDoc documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) {
32         paths.add(documentPath);
33         return true;
34     }
35
36     /**
37      * Returns the paths that have been collected.
38      */

39     public String JavaDoc[] getPaths() {
40         String JavaDoc[] result = new String JavaDoc[this.paths.size()];
41         int i = 0;
42         for (Iterator JavaDoc iter = this.paths.iterator(); iter.hasNext();) {
43             result[i++] = (String JavaDoc)iter.next();
44         }
45         return result;
46     }
47 }
48
Popular Tags