diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/PatchQuery.java')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/PatchQuery.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/PatchQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/PatchQuery.java new file mode 100644 index 000000000..d066db376 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/PatchQuery.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 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.metadata.query; + +import org.eclipse.equinox.internal.p2.metadata.query.IUPropertyQuery; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.query.MatchQuery; + +/** + * A query matching every {@link IInstallableUnit} that is a patch. + * @since 2.0 + */ +public final class PatchQuery extends MatchQuery<IInstallableUnit> { + private static final String PROP_TYPE_PATCH = "org.eclipse.equinox.p2.type.patch"; //$NON-NLS-1$ + private IUPropertyQuery query; + + public PatchQuery() { + query = new IUPropertyQuery(PROP_TYPE_PATCH, Boolean.TRUE.toString()); + } + + public boolean isMatch(IInstallableUnit candidate) { + return query.isMatch(candidate); + } + + /** + * Test if the {@link IInstallableUnit} is a patch. + * @param iu the element being tested. + * @return <tt>true</tt> if the parameter is a patch. + */ + public static boolean isPatch(IInstallableUnit iu) { + String value = iu.getProperty(PROP_TYPE_PATCH); + if (value != null && (value.equals(Boolean.TRUE.toString()))) + return true; + return false; + } +} |