| /******************************************************************************* |
| * Copyright (c) 2007 Innoopract Informationssysteme GmbH |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Innoopract - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.epp.packaging.core.download; |
| |
| import java.util.ArrayList; |
| import java.util.Collections; |
| import java.util.List; |
| |
| import org.eclipse.update.core.IFeature; |
| import org.eclipse.update.core.VersionedIdentifier; |
| import org.eclipse.update.search.IUpdateSearchResultCollector; |
| |
| /**UpdateSearchResultCollector comparing features found with a base set of features to find.*/ |
| public class FeatureVerifyingSearchCollector |
| implements IUpdateSearchResultCollector |
| { |
| |
| private final List<VersionedIdentifier> featuresToFind = new ArrayList<VersionedIdentifier>(); |
| |
| public FeatureVerifyingSearchCollector( final VersionedIdentifier[] listedFeatures ) |
| { |
| Collections.addAll( featuresToFind, listedFeatures ); |
| } |
| |
| public void accept( final IFeature feature ) { |
| featuresToFind.remove( feature.getVersionedIdentifier() ); |
| } |
| |
| /**@return true if all the configured features are found, false otherwise.*/ |
| public boolean allFeaturesFound() { |
| return featuresToFind.isEmpty(); |
| } |
| |
| /**Returns the list of missing features*/ |
| public VersionedIdentifier[] getMissingFeatures() { |
| return featuresToFind.toArray( new VersionedIdentifier[ featuresToFind.size() ] ); |
| } |
| } |