Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hallgren2010-02-19 12:13:19 +0000
committerThomas Hallgren2010-02-19 12:13:19 +0000
commit3a4abd5c6deca5395ea24bb742ab53fa21427f85 (patch)
tree9eb424ba5b281990970f584088d4ceef5bf05111 /bundles/org.eclipse.equinox.p2.engine
parent273e205c6904675b1b1314b6f4df5f9e962735b5 (diff)
downloadrt.equinox.p2-3a4abd5c6deca5395ea24bb742ab53fa21427f85.tar.gz
rt.equinox.p2-3a4abd5c6deca5395ea24bb742ab53fa21427f85.tar.xz
rt.equinox.p2-3a4abd5c6deca5395ea24bb742ab53fa21427f85.zip
302201 : Unify the two query approaches used in p2
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.engine')
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/query/IUProfilePropertyQuery.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/query/UserVisibleRootQuery.java5
2 files changed, 16 insertions, 10 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/query/IUProfilePropertyQuery.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/query/IUProfilePropertyQuery.java
index 84437a6f6..7f2a32150 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/query/IUProfilePropertyQuery.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/query/IUProfilePropertyQuery.java
@@ -10,16 +10,20 @@
*******************************************************************************/
package org.eclipse.equinox.p2.engine.query;
-import org.eclipse.equinox.internal.p2.metadata.query.IUPropertyQuery;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.MatchQuery;
/**
* A query that searches for {@link IInstallableUnit} instances that have
* a property associated with the specified profile, whose value matches the provided value.
* @since 2.0
*/
-public class IUProfilePropertyQuery extends IUPropertyQuery {
+public class IUProfilePropertyQuery extends MatchQuery<IInstallableUnit> {
+ public static final String ANY = "*"; //$NON-NLS-1$
+
+ private final String propertyName;
+ private final String propertyValue;
private IProfile profile;
/**
@@ -34,14 +38,19 @@ public class IUProfilePropertyQuery extends IUPropertyQuery {
* Because the queryable for this query is typically the profile
* instance, we use a reference to the profile rather than the
* profile id for performance reasons.
+ * @param propertyName The name of the property to match
+ * @param propertyValue The value to compare to. A value of &quot;*&quot; means any value.
*/
public IUProfilePropertyQuery(String propertyName, String propertyValue) {
- super(propertyName, propertyValue);
+ this.propertyName = propertyName;
+ this.propertyValue = propertyValue;
}
- protected String getProperty(IInstallableUnit iu, String name) {
+ @Override
+ public boolean isMatch(IInstallableUnit candidate) {
if (profile == null)
- return null;
- return profile.getInstallableUnitProperty(iu, name);
+ return false;
+ String foundValue = profile.getInstallableUnitProperty(candidate, propertyName);
+ return foundValue == null ? propertyValue == null : (ANY.equals(propertyValue) || foundValue.equals(propertyValue));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/query/UserVisibleRootQuery.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/query/UserVisibleRootQuery.java
index 20ea0d011..d2c3318ad 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/query/UserVisibleRootQuery.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/query/UserVisibleRootQuery.java
@@ -13,7 +13,6 @@ package org.eclipse.equinox.p2.engine.query;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-
/**
* A query matching all the {@link IInstallableUnit}s that are marked visible to the user.
* @since 2.0
@@ -32,8 +31,6 @@ public class UserVisibleRootQuery extends IUProfilePropertyQuery {
*/
public static boolean isUserVisible(IInstallableUnit iu, IProfile profile) {
String value = profile.getInstallableUnitProperty(iu, IProfile.PROP_PROFILE_ROOT_IU);
- if (value != null && (value.equals(Boolean.TRUE.toString())))
- return true;
- return false;
+ return Boolean.valueOf(value).booleanValue();
}
}

Back to the top