KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > search > VersionedIdentifiersFilter


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.update.search;
12
13 import java.util.ArrayList JavaDoc;
14
15 import org.eclipse.core.runtime.*;
16 import org.eclipse.update.core.*;
17
18
19 /**
20  * This class can be added to the update search request
21  * to filter out features that are not part of the specified set.
22  *
23  * <p>
24  * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to
25  * change significantly before reaching stability. It is being made available at this early stage to solicit feedback
26  * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
27  * (repeatedly) as the API evolves.
28  * </p>
29  * @see UpdateSearchRequest
30  * @see IUpdateSearchFilter
31  * @since 3.0
32  */

33 public class VersionedIdentifiersFilter extends BaseFilter {
34     private ArrayList JavaDoc vids;
35     
36     public VersionedIdentifiersFilter() {
37         this(new VersionedIdentifier[0]);
38     }
39     
40     public VersionedIdentifiersFilter(VersionedIdentifier[] vids) {
41         this.vids = new ArrayList JavaDoc(vids.length);
42         for (int i=0; i<vids.length; i++)
43             this.vids.add(vids[i]);
44     }
45     
46     public void add(VersionedIdentifier vid) {
47         vids.add(vid);
48     }
49     
50     public boolean accept(IFeatureReference match) {
51         try {
52             for (int i=0; i<vids.size(); i++) {
53                 VersionedIdentifier vid = (VersionedIdentifier)vids.get(i);
54                 // installed version is the same as the match - accept
55
if (vid.equals(match.getVersionedIdentifier()))
56                     return true;
57             }
58             return false;
59         } catch (CoreException e) {
60             return false;
61         }
62     }
63 }
64
Popular Tags