diff options
author | Thomas Hallgren | 2010-02-22 01:10:11 +0000 |
---|---|---|
committer | Thomas Hallgren | 2010-02-22 01:10:11 +0000 |
commit | 8aa5a700fd1df2f75541c1329747668a0eb1716e (patch) | |
tree | 85a71b311400712ede104e6ebc524662633f745f /bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src | |
parent | 9dc753efb1afeb1c6778b8338f01c80919e8b143 (diff) | |
download | rt.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/src')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/OSGiBundleQuery.java | 28 |
1 files changed, 11 insertions, 17 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 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 |