Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hallgren2010-02-21 20:10:11 -0500
committerThomas Hallgren2010-02-21 20:10:11 -0500
commit8aa5a700fd1df2f75541c1329747668a0eb1716e (patch)
tree85a71b311400712ede104e6ebc524662633f745f /bundles/org.eclipse.equinox.p2.touchpoint.eclipse
parent9dc753efb1afeb1c6778b8338f01c80919e8b143 (diff)
downloadrt.equinox.p2-8aa5a700fd1df2f75541c1329747668a0eb1716e.tar.gz
rt.equinox.p2-8aa5a700fd1df2f75541c1329747668a0eb1716e.tar.xz
rt.equinox.p2-8aa5a700fd1df2f75541c1329747668a0eb1716e.zip
302201 : Unify the two query approaches used in p2, step 3.
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.eclipse')
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/OSGiBundleQuery.java28
2 files changed, 12 insertions, 17 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF
index 8f462754f..f95c89ad5 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF
@@ -20,6 +20,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.p2.engine,
org.eclipse.equinox.p2.engine.spi,
org.eclipse.equinox.p2.metadata,
+ org.eclipse.equinox.p2.metadata.expression,
org.eclipse.equinox.p2.metadata.query,
org.eclipse.equinox.p2.planner,
org.eclipse.equinox.p2.publisher;resolution:=optional,
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
index cd143acde..ef4809413 100644
--- 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
@@ -6,26 +6,26 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Corporation - initial API and implementation
+ * IBM Corporation - initial API and implementation
+ * Cloudsmith Inc. - converted into expression based query
*******************************************************************************/
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;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
+import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
+import org.eclipse.equinox.p2.metadata.query.ExpressionQuery;
/**
* A query matching every {@link IInstallableUnit} that describes an OSGi bundle.
* @since 2.0
*/
-public class OSGiBundleQuery extends MatchQuery<IInstallableUnit> {
+public class OSGiBundleQuery extends ExpressionQuery<IInstallableUnit> {
- /* (non-Javadoc)
- * @see org.eclipse.equinox.p2.query.MatchQuery#isMatch(java.lang.Object)
- */
- public boolean isMatch(IInstallableUnit candidate) {
- return isOSGiBundle(candidate);
+ private static final IMatchExpression<IInstallableUnit> bundleTest = ExpressionUtil.getFactory().matchExpression(ExpressionUtil.parse("providedCapabilities.exists(p | p.namespace == 'osgi.bundle')")); //$NON-NLS-1$
+
+ public OSGiBundleQuery() {
+ super(IInstallableUnit.class, bundleTest);
}
/**
@@ -34,12 +34,6 @@ public class OSGiBundleQuery extends MatchQuery<IInstallableUnit> {
* @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;
+ return bundleTest.isMatch(iu);
}
} \ No newline at end of file

Back to the top