diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query')
2 files changed, 60 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/OSGiBundleQuery.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/OSGiBundleQuery.java new file mode 100644 index 000000000..8cdb7c0d1 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/OSGiBundleQuery.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2008, 2009 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.touchpoint.eclipse.query; + +import java.util.Collection; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IProvidedCapability; +import org.eclipse.equinox.p2.query.MatchQuery; + +/** + * A query matching every {@link IInstallableUnit} that describes an OSGi bundle. + * @since 2.0 + */ +public class OSGiBundleQuery extends MatchQuery<IInstallableUnit> { + + public boolean isMatch(IInstallableUnit candidate) { + return isOSGiBundle(candidate); + } + + /** + * Test if the {@link IInstallableUnit} describes an OSGi bundle. + * @param iu the element being tested. + * @return <tt>true</tt> if the parameter describes an OSGi bundle. + */ + public static boolean isOSGiBundle(IInstallableUnit iu) { + Collection<IProvidedCapability> provided = iu.getProvidedCapabilities(); + for (IProvidedCapability capability : provided) { + if (capability.getNamespace().equals("osgi.bundle")) { //$NON-NLS-1$ + return true; + } + } + return false; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/package.html b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/package.html new file mode 100644 index 000000000..1af2a8419 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/package.html @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <title>Package-level Javadoc</title> +</head> +<body> +Provides query utilities specific to provisioning of OSGi bundles +<h2> +Package Specification</h2> +<p> +This package specifies API for querying and manipulating provisioning metadata that +is specific to OSGi bundles or Eclipse-specific constructs such as features. +<p> +@since 2.0 +<p> +</body> +</html> |