Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.metadata')
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF4
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/Copyright.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/License.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequirementChange.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointType.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/UpdateDescriptor.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/FormatException.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IArtifactKey.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IInstallableUnit.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IProvidedCapability.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IRequiredCapability.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/ITouchpointType.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IUpdateDescriptor.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/MetadataFactory.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/Version.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/VersionFormat.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/VersionFormatParser.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CapabilityQuery.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/Collector.java138
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompositeQuery.java64
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQuery.java218
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQueryable.java122
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/ContextQuery.java61
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/IMatchQuery.java58
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/IQueryable.java37
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/IUPropertyQuery.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/InstallableUnitQuery.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LatestIUVersionQuery.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/MatchQuery.java105
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/Query.java50
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/QueryHelpers.java51
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/UpdateQuery.java1
37 files changed, 937 insertions, 19 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF
index 0e200e717..15a42fa59 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF
@@ -77,7 +77,9 @@ Export-Package: org.eclipse.equinox.internal.p2.metadata;
org.eclipse.pde.ui,
org.eclipse.equinox.p2.repository.tools,
org.eclipse.pde.core"
-Import-Package: org.osgi.framework;version="1.3.0"
+Import-Package: org.eclipse.osgi.service.localization;version="1.0.0",
+ org.eclipse.osgi.util,
+ org.osgi.framework;version="1.3.0"
Bundle-Activator: org.eclipse.equinox.internal.p2.metadata.MetadataActivator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java
index 8b76db440..a069efbab 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java
@@ -10,10 +10,11 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata;
+import org.eclipse.equinox.internal.provisional.p2.core.Version;
+
import java.util.ArrayList;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.equinox.internal.provisional.p2.core.Version;
import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
/**
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/Copyright.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/Copyright.java
index b29e5f305..9098f377c 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/Copyright.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/Copyright.java
@@ -10,9 +10,8 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata;
-import org.eclipse.equinox.internal.provisional.p2.metadata.ICopyright;
-
import java.net.URI;
+import org.eclipse.equinox.internal.provisional.p2.metadata.ICopyright;
/**
* The <code>Copyright</code> class represents a software copyright. A copyright has
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java
index 7fec1191e..d90657c31 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java
@@ -11,10 +11,11 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata;
+import org.eclipse.equinox.internal.provisional.p2.core.Version;
+
import java.util.ArrayList;
import java.util.Map;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
-import org.eclipse.equinox.internal.provisional.p2.core.Version;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
public class InstallableUnit implements IInstallableUnit {
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/License.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/License.java
index b89285fcf..112956f26 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/License.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/License.java
@@ -11,13 +11,12 @@
******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata;
-import org.eclipse.equinox.internal.provisional.p2.metadata.ILicense;
-
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.net.URI;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import org.eclipse.equinox.internal.provisional.p2.metadata.ILicense;
/**
* The <code>License</code> class represents a software license. A license has required body text
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java
index 4c8b307bd..98db2318d 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java
@@ -11,8 +11,9 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.equinox.internal.provisional.p2.core.Version;
+
+import org.eclipse.core.runtime.Assert;
import org.eclipse.equinox.internal.provisional.p2.metadata.IProvidedCapability;
import org.eclipse.equinox.internal.provisional.p2.metadata.IRequiredCapability;
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java
index a4df5146d..0ccde1070 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java
@@ -11,8 +11,9 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
+
+import org.eclipse.core.runtime.Assert;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.metadata.IRequiredCapability;
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequirementChange.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequirementChange.java
index e1d1fcc1d..16c5de3ca 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequirementChange.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequirementChange.java
@@ -12,6 +12,7 @@ package org.eclipse.equinox.internal.p2.metadata;
import org.eclipse.equinox.internal.provisional.p2.core.Version;
import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
+
import org.eclipse.equinox.internal.provisional.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.metadata.IRequirementChange;
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java
index 1e7cd2040..409fa80cb 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java
@@ -11,8 +11,9 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata;
-import java.util.*;
import org.eclipse.equinox.internal.provisional.p2.core.Version;
+
+import java.util.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
public class ResolvedInstallableUnit implements IInstallableUnit {
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointType.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointType.java
index 7cba96c21..b9dd99539 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointType.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointType.java
@@ -12,6 +12,7 @@
package org.eclipse.equinox.internal.p2.metadata;
import org.eclipse.equinox.internal.provisional.p2.core.Version;
+
import org.eclipse.equinox.internal.provisional.p2.metadata.ITouchpointType;
/**
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/UpdateDescriptor.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/UpdateDescriptor.java
index d8d0a55e8..06afd24ef 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/UpdateDescriptor.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/UpdateDescriptor.java
@@ -9,6 +9,7 @@
package org.eclipse.equinox.internal.p2.metadata;
import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
+
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.metadata.IUpdateDescriptor;
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/FormatException.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/FormatException.java
index d4a555d26..2286568a3 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/FormatException.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/FormatException.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.core;
+
/**
* Exception thrown by the {@link VersionFormatParser}
*
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IArtifactKey.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IArtifactKey.java
index ef26c2540..3e9edcd16 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IArtifactKey.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IArtifactKey.java
@@ -12,6 +12,7 @@ package org.eclipse.equinox.internal.provisional.p2.metadata;
import org.eclipse.equinox.internal.provisional.p2.core.Version;
+
/**
* Provide standardized artifact information to uniquely identify the
* corresponding bytes (perhaps not stored as a file).
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IInstallableUnit.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IInstallableUnit.java
index 2e2d2cd1f..60181d5e6 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IInstallableUnit.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IInstallableUnit.java
@@ -11,9 +11,10 @@
******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.metadata;
-import java.util.Map;
import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import java.util.Map;
+
/**
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IProvidedCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IProvidedCapability.java
index bc43a9b84..91bcc5af7 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IProvidedCapability.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IProvidedCapability.java
@@ -12,6 +12,7 @@ package org.eclipse.equinox.internal.provisional.p2.metadata;
import org.eclipse.equinox.internal.provisional.p2.core.Version;
+
/**
* Describes a capability as exposed or required by an installable unit
*
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IRequiredCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IRequiredCapability.java
index 3c38a0bf5..a94b6f022 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IRequiredCapability.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IRequiredCapability.java
@@ -11,6 +11,7 @@ package org.eclipse.equinox.internal.provisional.p2.metadata;
import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
+
/**
* A required capability represents some external constraint on an {@link IInstallableUnit}.
* Each capability represents something an {@link IInstallableUnit} needs that
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/ITouchpointType.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/ITouchpointType.java
index db36a94d6..b43f11b28 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/ITouchpointType.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/ITouchpointType.java
@@ -11,6 +11,7 @@ package org.eclipse.equinox.internal.provisional.p2.metadata;
import org.eclipse.equinox.internal.provisional.p2.core.Version;
+
/**
* Identifies a particular touchpoint. A touchpoint is identified by an id
* and a version.
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IUpdateDescriptor.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IUpdateDescriptor.java
index 73c0f3b3f..39d024bae 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IUpdateDescriptor.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IUpdateDescriptor.java
@@ -12,6 +12,7 @@ package org.eclipse.equinox.internal.provisional.p2.metadata;
import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
+
/**
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/MetadataFactory.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/MetadataFactory.java
index 67eaded78..325a3d787 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/MetadataFactory.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/MetadataFactory.java
@@ -12,13 +12,14 @@
*******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.metadata;
+import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
+
import java.net.URI;
import java.util.*;
import java.util.Map.Entry;
import org.eclipse.core.runtime.Assert;
import org.eclipse.equinox.internal.p2.metadata.*;
-import org.eclipse.equinox.internal.provisional.p2.core.Version;
-import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
/**
* A factory class for instantiating various p2 metadata objects.
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/Version.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/Version.java
index 7e43425fa..0ef36cff6 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/Version.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/Version.java
@@ -11,6 +11,7 @@
package org.eclipse.equinox.internal.provisional.p2.core;
+
import org.eclipse.osgi.util.NLS;
/**
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/VersionFormat.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/VersionFormat.java
index 603a49d4f..1497406b4 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/VersionFormat.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/VersionFormat.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.core;
+
import java.io.Serializable;
import java.util.*;
import org.eclipse.osgi.util.NLS;
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/VersionFormatParser.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/VersionFormatParser.java
index 4a31345e9..54cc53e56 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/VersionFormatParser.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/VersionFormatParser.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.core;
+
import java.util.ArrayList;
import java.util.List;
import org.eclipse.osgi.util.NLS;
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CapabilityQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CapabilityQuery.java
index 8a7bf23d2..4336989a9 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CapabilityQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CapabilityQuery.java
@@ -12,7 +12,6 @@ package org.eclipse.equinox.internal.provisional.p2.metadata.query;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.metadata.IRequiredCapability;
-import org.eclipse.equinox.internal.provisional.p2.query.MatchQuery;
/**
* A query that searches for {@link IInstallableUnit} instances that provide
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/Collector.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/Collector.java
new file mode 100644
index 000000000..f117b7bf4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/Collector.java
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 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
+ * EclipseSource - ongoing development
+ *******************************************************************************/
+package org.eclipse.equinox.internal.provisional.p2.metadata.query;
+
+
+import org.eclipse.equinox.internal.provisional.p2.core.Messages;
+
+import java.lang.reflect.Array;
+import java.util.*;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+/**
+ * A collector is a generic visitor that collects objects passed to it,
+ * and can then express the result of the visit in various forms. The collector
+ * can also short-circuit a traversal by returning <code>false</code> from
+ * its {@link #accept(Object)} method.
+ * <p>
+ * This default collector just accepts all objects passed to it. Clients may subclass
+ * to perform different processing on the objects passed to it.
+ */
+public class Collector implements IQueryable {
+ private Set collected = null;
+
+ /**
+ * Creates a new collector.
+ */
+ public Collector() {
+ super();
+ }
+
+ /**
+ * Accepts an object.
+ * <p>
+ * This default implementation adds the objects to a list. Clients may
+ * override this method to perform additional filtering, add different objects
+ * to the list, short-circuit the traversal, or process the objects directly without
+ * collecting them.
+ *
+ * @param object the object to collect or visit
+ * @return <code>true</code> if the traversal should continue,
+ * or <code>false</code> to indicate the traversal should stop.
+ */
+ public boolean accept(Object object) {
+ getCollection().add(object);
+ return true;
+ }
+
+ /**
+ * Returns the collection that is being used to collect results. Unlike {@linkplain #toCollection()},
+ * this returns the actual modifiable collection that is being used to store results. The
+ * return value is only intended to be used within subclasses and should not be exposed
+ * outside of a collection class.
+ *
+ * @return the collection being used to collect results.
+ */
+ protected Collection getCollection() {
+ if (collected == null)
+ collected = new HashSet();
+ return collected;
+ }
+
+ /**
+ * Returns whether this collector is empty.
+ * @return <code>true</code> if this collector has accepted any results,
+ * and <code>false</code> otherwise.
+ */
+ public boolean isEmpty() {
+ return collected == null || collected.isEmpty();
+ }
+
+ /**
+ * Returns an iterator on the collected objects.
+ *
+ * @return an iterator of the collected objects.
+ */
+ public Iterator iterator() {
+ return collected == null ? Collections.EMPTY_LIST.iterator() : collected.iterator();
+ }
+
+ /**
+ * Returns the number of collected objects.
+ */
+ public int size() {
+ return collected == null ? 0 : collected.size();
+ }
+
+ /**
+ * Returns the collected objects as an array
+ *
+ * @param clazz The type of array to return
+ * @return The array of results
+ * @throws ArrayStoreException the runtime type of the specified array is
+ * not a supertype of the runtime type of every collected object
+ */
+ public Object[] toArray(Class clazz) {
+ int size = collected == null ? 0 : collected.size();
+ Object[] result = (Object[]) Array.newInstance(clazz, size);
+ if (size != 0)
+ collected.toArray(result);
+ return result;
+ }
+
+ /**
+ * Returns the collected objects as an immutable collection.
+ *
+ * @return An unmodifiable collection of the collected objects
+ */
+ public Collection toCollection() {
+ return collected == null ? Collections.EMPTY_SET : Collections.unmodifiableSet(collected);
+ }
+
+ /**
+ * Performs a query on this results of this collector.
+ */
+ public Collector query(Query query, Collector collector, IProgressMonitor monitor) {
+ Iterator iter = collector == this ? toCollection().iterator() : iterator();
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+ try {
+ monitor.beginTask(Messages.performing_subquery, 1);
+ collector = query.perform(iter, collector);
+ monitor.worked(1);
+ } finally {
+ monitor.done();
+ }
+ return collector;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompositeQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompositeQuery.java
new file mode 100644
index 000000000..a4c88a629
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompositeQuery.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource 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:
+* EclipseSource - initial API and implementation
+******************************************************************************/
+package org.eclipse.equinox.internal.provisional.p2.metadata.query;
+
+
+import java.util.Iterator;
+
+/**
+ * A Composite Query is an aggregate query in which each sub-query
+ * is executed in succession. The results from the ith sub-query
+ * are piped as input into the i+1th sub-query.
+ */
+public class CompositeQuery implements Query {
+ protected Query[] queries;
+
+ public CompositeQuery(Query[] queries) {
+ this.queries = queries;
+ }
+
+ /**
+ * Gets the ID for this Query.
+ */
+ public String getId() {
+ return QueryHelpers.getId(this);
+ }
+
+ /**
+ * Gets a particular property of the query.
+ * @param property The property to retrieve
+ */
+ public Object getProperty(String property) {
+ return QueryHelpers.getProperty(this, property);
+ }
+
+ /**
+ * Set the queries of this composite. This is needed to allow subclasses of
+ * CompsiteQuery to set the queries in a constructor
+ */
+ protected final void setQueries(Query[] queries) {
+ this.queries = queries;
+ }
+
+ public Collector perform(Iterator iterator, Collector result) {
+ Collector collector;
+ Iterator iter = iterator;
+ for (int i = 0; i < queries.length; i++) {
+ // Take the results of the previous query and using them
+ // to drive the next one (i.e. composing queries)
+ collector = queries[i].perform(iter, new Collector());
+ iter = collector.iterator();
+ }
+ boolean gatherResults = true;
+ while (iter.hasNext() && gatherResults)
+ gatherResults = result.accept(iter.next());
+ return result;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQuery.java
new file mode 100644
index 000000000..45cc8b66d
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQuery.java
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 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
+ * EclipseSource - ongoing development
+ *******************************************************************************/
+package org.eclipse.equinox.internal.provisional.p2.metadata.query;
+
+
+import java.util.*;
+
+/**
+ * A query that combines a group of sub-queries.<P>
+ *
+ * In a CompoundQuery each sub-query is executed and the results are combined using
+ * either logical AND or logical OR operations. <P>
+ *
+ * Clients are expected to call {@link CompoundQuery#createCompoundQuery(Query[], boolean)}
+ * to create a concrete instance of a CompoundQuery. If all Queries are instances of
+ * {@link IMatchQuery} then the resulting compound query will be a MatchCompoundQuery, otherwise the
+ * resulting compound query will be a {@link ContextQuery}.
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public abstract class CompoundQuery implements Query {
+ protected Query[] queries;
+ protected boolean and;
+
+ /**
+ * Creates a compound query that combines the given queries. The queries
+ * will be performed by the compound query in the given order. This method
+ * might not perform all queries if it can determine the result of the compound
+ * expression without doing so.
+ *
+ * If all the queries are instances of {@link IMatchQuery} then the resulting
+ * compound query will be an instance of IMatchQuery, otherwise the resulting
+ * compound query will be a context query.
+ *
+ * @param queries The queries to perform
+ * @param and <code>true</code> if this query represents a logical 'and', and
+ * <code>false</code> if this query represents a logical 'or'.
+ */
+ public static CompoundQuery createCompoundQuery(Query[] queries, boolean and) {
+ if (isMatchQueries(queries)) {
+ return new CompoundQuery.MatchCompoundQuery(queries, and);
+ }
+ return new CompoundQuery.ContextCompoundQuery(queries, and);
+ }
+
+ /**
+ * Returns the queries that make up this compound query
+ */
+ public Query[] getQueries() {
+ return queries;
+ }
+
+ /**
+ * Returns whether this compound query combines its queries with a logical
+ * 'and' or 'or'.
+ * @return <code>true</code> if this query represents a logical 'and', and
+ * <code>false</code> if this query represents a logical 'or'.
+ */
+ public boolean isAnd() {
+ return and;
+ }
+
+ protected CompoundQuery(Query[] queries, boolean and) {
+ this.queries = queries;
+ this.and = and;
+ }
+
+ /**
+ * @param queries
+ */
+ private static boolean isMatchQueries(Query[] queries) {
+ for (int i = 0; i < queries.length; i++) {
+ if (!(queries[i] instanceof IMatchQuery)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Gets the ID for this Query.
+ */
+ public String getId() {
+ return QueryHelpers.getId(this);
+ }
+
+ /**
+ * Gets a particular property of the query.
+ * @param property The property to retrieve
+ */
+ public Object getProperty(String property) {
+ return QueryHelpers.getProperty(this, property);
+ }
+
+ /**
+ * The compound query instantiated when all queries are Match Queries.
+ */
+ private static class MatchCompoundQuery extends CompoundQuery implements IMatchQuery {
+
+ protected MatchCompoundQuery(Query[] queries, boolean and) {
+ super(queries, and);
+ }
+
+ public boolean isMatch(Object candidate) {
+ for (int i = 0; i < queries.length; i++) {
+ boolean valid = ((IMatchQuery) queries[i]).isMatch(candidate);
+ // if we are OR'ing then the first time we find a requirement that is met, return success
+ if (valid && !and)
+ return true;
+ // if we are AND'ing then the first time we find a requirement that is NOT met, return failure
+ if (!valid && and)
+ return false;
+ }
+ // if we get past the requirements check and we are AND'ing then return true
+ // since all requirements must have been met. If we are OR'ing then return false
+ // since none of the requirements were met.
+ return and;
+ }
+
+ /**
+ * Performs this query on the given iterator, passing all objects in the iterator
+ * that match the criteria of this query to the given result.
+ */
+ public final Collector perform(Iterator iterator, Collector result) {
+ prePerform();
+ try {
+ while (iterator.hasNext()) {
+ Object candidate = iterator.next();
+ if (isMatch(candidate))
+ if (!result.accept(candidate))
+ break;
+ }
+ } finally {
+ postPerform();
+ }
+ return result;
+ }
+
+ public void prePerform() {
+ for (int i = 0; i < queries.length; i++) {
+ ((IMatchQuery) queries[i]).prePerform();
+ }
+ }
+
+ public void postPerform() {
+ for (int i = 0; i < queries.length; i++) {
+ ((IMatchQuery) queries[i]).postPerform();
+ }
+ }
+ }
+
+ /**
+ * The compound query instantiated when any of the queries are not
+ * match queries.
+ */
+ private static class ContextCompoundQuery extends CompoundQuery {
+
+ protected ContextCompoundQuery(Query[] queries, boolean and) {
+ super(queries, and);
+ }
+
+ /*
+ * A collector that takes the set to puts the elements in.
+ */
+ class SetCollector extends Collector {
+ Set s = null;
+
+ public SetCollector(Set s) {
+ this.s = s;
+ }
+
+ public boolean accept(Object object) {
+ s.add(object);
+ return true;
+ }
+ }
+
+ public Collector perform(Iterator iterator, Collector result) {
+ if (queries.length < 1)
+ return result;
+
+ Collection data = new LinkedList();
+
+ while (iterator.hasNext()) {
+ data.add(iterator.next());
+ }
+
+ Set[] resultSets = new Set[queries.length];
+ for (int i = 0; i < queries.length; i++) {
+ resultSets[i] = new HashSet();
+ queries[i].perform(data.iterator(), new SetCollector(resultSets[i]));
+ }
+
+ Set set = resultSets[0];
+ for (int i = 1; i < resultSets.length; i++) {
+ if (isAnd())
+ set.retainAll(resultSets[i]);
+ else
+ set.addAll(resultSets[i]);
+ }
+
+ Iterator resultIterator = set.iterator();
+ boolean gatherResults = true;
+ while (resultIterator.hasNext() && gatherResults)
+ gatherResults = result.accept(resultIterator.next());
+ return result;
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQueryable.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQueryable.java
new file mode 100644
index 000000000..ff7484c73
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQueryable.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource 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:
+* EclipseSource - initial API and implementation
+******************************************************************************/
+package org.eclipse.equinox.internal.provisional.p2.metadata.query;
+
+import java.lang.reflect.Array;
+import java.util.*;
+import org.eclipse.core.runtime.*;
+
+/**
+ * A queryable that holds a number of other IQueryables and provides
+ * a mechanism for querying the entire set.
+ */
+public class CompoundQueryable implements IQueryable {
+
+ private IQueryable[] queryables;
+
+ public CompoundQueryable(IQueryable[] queryables) {
+ this.queryables = queryables;
+ }
+
+ public Collector query(Query query, Collector collector, IProgressMonitor monitor) {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ boolean isMatchQuery = query instanceof IMatchQuery;
+ Collector results = collector;
+ int totalWork = isMatchQuery ? queryables.length : queryables.length + 1;
+
+ try {
+ SubMonitor subMonitor = SubMonitor.convert(monitor, totalWork * 10);
+ if (!isMatchQuery) {
+ // If it is not a match query, then collect the results
+ // as a list, we will query this list for the final results
+ results = new ListCollector();
+ }
+ for (int i = 0; i < queryables.length; i++) {
+ if (subMonitor.isCanceled())
+ break;
+ results = queryables[i].query(query, results, subMonitor.newChild(10));
+ }
+
+ if (!isMatchQuery) {
+ // If it is not a MatchQuery then we must query the results.
+ collector = results.query(query, collector, subMonitor.newChild(10));
+ } else
+ collector = results;
+ } finally {
+ monitor.done();
+ }
+
+ return collector;
+ }
+
+ /**
+ * A list collector.
+ *
+ * This is a collector backed as a list.
+ *
+ * The list collector is not intended to be used outside of this class. It is only public
+ * for testing purposes.
+ *
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * @noextend This class is not intended to be subclassed by clients.
+ *
+ */
+ public class ListCollector extends Collector {
+ private List collected;
+
+ public ListCollector() {
+ super();
+ }
+
+ protected Collection getCollection() {
+ if (collected == null)
+ collected = new ArrayList();
+ return collected;
+ }
+
+ public boolean isEmpty() {
+ return collected == null || collected.isEmpty();
+ }
+
+ public Object[] toArray(Class clazz) {
+ int size = collected == null ? 0 : collected.size();
+ Object[] result = (Object[]) Array.newInstance(clazz, size);
+ if (size != 0)
+ collected.toArray(result);
+ return result;
+ }
+
+ public boolean accept(Object object) {
+ if (collected == null)
+ collected = new ArrayList();
+ collected.add(object);
+ return true;
+ }
+
+ /**
+ * Returns the collected objects as an immutable collection.
+ *
+ * @return An unmodifiable collection of the collected objects
+ */
+ public Collection toCollection() {
+ return collected == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(collected);
+ }
+
+ public Iterator iterator() {
+ return collected == null ? Collections.EMPTY_LIST.iterator() : collected.iterator();
+ }
+
+ public int size() {
+ return collected == null ? 0 : collected.size();
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/ContextQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/ContextQuery.java
new file mode 100644
index 000000000..532f9e691
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/ContextQuery.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource 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:
+* EclipseSource - initial API and implementation
+******************************************************************************/
+package org.eclipse.equinox.internal.provisional.p2.metadata.query;
+
+
+import java.util.Iterator;
+
+/**
+ * ContextQuery is the abstract superclass for Queries that require the entire
+ * input to evaluate the results. Queries must consider the group of elements before
+ * processing the results. <P>
+ *
+ * ContextQueries must also be transitive. That is, if run on a subset of the
+ * input, the order in which they are executed must not matter. If there is the
+ * need for a non-transitive query, please see:
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=261403
+ * <p>
+ * Users of this query must call {@link #perform(Iterator, Collector)} to compute
+ * the results. <P>
+ * This class may be subclassed by clients. Subclasses should specify the type
+ * of object they support querying on. Subclasses are also encouraged to clearly
+ * specify their match algorithm, and expose the parameters involved in the match
+ * computation, to allow {@link IQueryable} implementations to optimize their
+ * execution of the query. <P>
+ *
+ */
+public abstract class ContextQuery implements Query {
+
+ /**
+ * Evaluates the query for a specific input.
+ *
+ * @param iterator The elements for which to evaluate the query on
+ * @param result A collector to collect the results. For each element accepted
+ * by the query,{@link Collector#accept(Object)} must be called.
+ * @return The results of the query. The collector returned must be
+ * the collector passed in.
+ */
+ public abstract Collector perform(Iterator iterator, Collector result);
+
+ /**
+ * Gets the ID for this Query.
+ */
+ public String getId() {
+ return QueryHelpers.getId(this);
+ }
+
+ /**
+ * Gets a particular property of the query.
+ * @param property The property to retrieve
+ */
+ public Object getProperty(String property) {
+ return QueryHelpers.getProperty(this, property);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/IMatchQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/IMatchQuery.java
new file mode 100644
index 000000000..6a3830611
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/IMatchQuery.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource 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:
+* EclipseSource - initial API and implementation
+******************************************************************************/
+package org.eclipse.equinox.internal.provisional.p2.metadata.query;
+
+/**
+ * A query in which the elements can be evaluated by calling isMatch on. Each
+ * element can be evaluated independently of all other elements. Match queries
+ * can be evaluated in parallel as each call {@link #isMatch(Object)} is mutually
+ * exclusive from all other calls. <P>
+ *
+ * @spi Clients should not implement this interface, but rather extend {@link MatchQuery}.
+ */
+public interface IMatchQuery extends Query {
+
+ /**
+ * Returns whether the given object satisfies the parameters of this query.
+ *
+ * @param candidate The object to perform the query against
+ * @return <code>true</code> if the unit satisfies the parameters
+ * of this query, and <code>false</code> otherwise
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public boolean isMatch(Object candidate);
+
+ /**
+ * Execute any pre-processing that must be done before this query is performed against
+ * a particular iterator. This method may be used by subclasses to do any calculations,
+ * caching, or other preparation for the query.
+ * <p>
+ * This method is internal to the framework. Subclasses may override this method, but
+ * should not call this method.
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public void prePerform();
+
+ /**
+ * Execute any post-processing that must be done after this query has been performed against
+ * a particular iterator. This method may be used by subclasses to clear caches or any other
+ * cleanup that should occur after a query.
+ * <p>
+ * This method will be called even if the query does not complete successfully.
+ * <p>
+ * This method is internal to the framework. Subclasses may override this method, but
+ * should not call this method.
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public void postPerform();
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/IQueryable.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/IQueryable.java
new file mode 100644
index 000000000..3389d5182
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/IQueryable.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 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.internal.provisional.p2.metadata.query;
+
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * An IQueryable contains objects, and is able to perform queries on those objects.
+ * <p>
+ * This interface may be implemented by clients.
+ */
+public interface IQueryable {
+ /**
+ * Performs a query, passing any objects that satisfy the
+ * query to the provided collector.
+ * <p>
+ * This method is long-running; progress and cancellation are provided
+ * by the given progress monitor.
+ * </p>
+ *
+ * @param query The query to perform
+ * @param collector Collects the results of the query
+ * @param monitor a progress monitor, or <code>null</code> if progress
+ * reporting is not desired
+ * @return The collector argument
+ */
+ public Collector query(Query query, Collector collector, IProgressMonitor monitor);
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/IUPropertyQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/IUPropertyQuery.java
index aff90377e..9b43371dc 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/IUPropertyQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/IUPropertyQuery.java
@@ -11,7 +11,6 @@
package org.eclipse.equinox.internal.provisional.p2.metadata.query;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.query.MatchQuery;
/**
* A query that searches for {@link IInstallableUnit} instances that have
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/InstallableUnitQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/InstallableUnitQuery.java
index 92cfe7674..311982ba6 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/InstallableUnitQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/InstallableUnitQuery.java
@@ -12,8 +12,8 @@ package org.eclipse.equinox.internal.provisional.p2.metadata.query;
import org.eclipse.equinox.internal.provisional.p2.core.Version;
import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
+
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.query.MatchQuery;
/**
* A query that matches on the id and version of an {@link IInstallableUnit}.
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LatestIUVersionQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LatestIUVersionQuery.java
index c591a2525..098642d64 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LatestIUVersionQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LatestIUVersionQuery.java
@@ -11,8 +11,6 @@ package org.eclipse.equinox.internal.provisional.p2.metadata.query;
import java.util.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.query.ContextQuery;
/**
* This query returns the latest version for each unique IU Id.
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/MatchQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/MatchQuery.java
new file mode 100644
index 000000000..86b647663
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/MatchQuery.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource 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:
+* EclipseSource - initial API and implementation
+* IBM Corporation - ongoing development
+******************************************************************************/
+package org.eclipse.equinox.internal.provisional.p2.metadata.query;
+
+
+import java.util.Iterator;
+
+/**
+ * This class represents the superclass of most of p2's queries. Every element
+ * in the query can be evaluated by calling isMatch on it. If {@link #isMatch(Object)} returns true,
+ * then the element WILL be included in the query result. If {@link #isMatch(Object)} returns false, then
+ * the element WILL NOT be included in the query result.
+ * <p>
+ * This class may be subclassed by clients. Subclasses should specify the type
+ * of object they support querying on. Subclasses are also encouraged to clearly
+ * specify their match algorithm, and expose the parameters involved in the match
+ * computation, to allow {@link IQueryable} implementations to optimize their
+ * execution of the query.
+ */
+public abstract class MatchQuery implements IMatchQuery {
+
+ /**
+ * Returns whether the given object satisfies the parameters of this query.
+ *
+ * @param candidate The object to perform the query against
+ * @return <code>true</code> if the unit satisfies the parameters
+ * of this query, and <code>false</code> otherwise
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ * Clients should call {@link #perform(Iterator, Collector)}
+ */
+ public abstract boolean isMatch(Object candidate);
+
+ /**
+ * Gets the ID for this Query.
+ */
+ public String getId() {
+ return QueryHelpers.getId(this);
+ }
+
+ /**
+ * Gets a particular property of the query.
+ * @param property The property to retrieve
+ */
+ public Object getProperty(String property) {
+ return QueryHelpers.getProperty(this, property);
+ }
+
+ /**
+ * Performs this query on the given iterator, passing all objects in the iterator
+ * that match the criteria of this query to the given result.
+ */
+ public final Collector perform(Iterator iterator, Collector result) {
+ prePerform();
+ try {
+ while (iterator.hasNext()) {
+ Object candidate = iterator.next();
+ if (isMatch(candidate))
+ if (!result.accept(candidate))
+ break;
+ }
+ } finally {
+ postPerform();
+ }
+ return result;
+ }
+
+ /**
+ * Execute any pre-processing that must be done before this query is performed against
+ * a particular iterator. This method may be used by subclasses to do any calculations,
+ * caching, or other preparation for the query.
+ * <p>
+ * This method is internal to the framework. Subclasses may override this method, but
+ * should not call this method.
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public void prePerform() {
+ // nothing to do by default
+ }
+
+ /**
+ * Execute any post-processing that must be done after this query has been performed against
+ * a particular iterator. This method may be used by subclasses to clear caches or any other
+ * cleanup that should occur after a query.
+ * <p>
+ * This method will be called even if the query does not complete successfully.
+ * <p>
+ * This method is internal to the framework. Subclasses may override this method, but
+ * should not call this method.
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public void postPerform() {
+ // nothing to do by default
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/Query.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/Query.java
new file mode 100644
index 000000000..a9acfdfa2
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/Query.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 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
+ * EclipseSource - ongoing development
+ *******************************************************************************/
+package org.eclipse.equinox.internal.provisional.p2.metadata.query;
+
+
+import java.util.Iterator;
+
+/**
+ * The superclass of all queries that can be performed on an {@link IQueryable}.
+ * <p>
+ *
+ * <B>NOTE: This interface does not follow the proper naming convention. It should
+ * be IQuery, however, for historic reasons it is Query. This is likely to change.</B>
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface Query {
+
+ /**
+ * Evaluates the query for a specific input.
+ *
+ * @param iterator The elements for which to evaluate the query on
+ * @param result A collector to collect the results. For each element accepted
+ * by the query,{@link Collector#accept(Object)} must be called.
+ * @return The results of the query. The collector returned must be
+ * the collector passed in.
+ */
+ public abstract Collector perform(Iterator iterator, Collector result);
+
+ /**
+ * Gets the ID for this Query.
+ */
+ public String getId();
+
+ /**
+ * Gets a particular property of the query.
+ * @param property The property to retrieve
+ */
+ public Object getProperty(String property);
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/QueryHelpers.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/QueryHelpers.java
new file mode 100644
index 000000000..0d0a54d82
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/QueryHelpers.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource 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:
+* EclipseSource - initial API and implementation
+******************************************************************************/
+package org.eclipse.equinox.internal.provisional.p2.metadata.query;
+
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * Static helper methods for the Query API.
+ */
+public class QueryHelpers {
+ /**
+ * Gets the ID for a Query.
+ */
+ public static String getId(Query query) {
+ return query.getClass().getName();
+ }
+
+ /**
+ * Gets a particular property of a query.
+ * @param query The query to retrieve the property from
+ * @param property The property to retrieve
+ */
+ public static Object getProperty(Query query, String property) {
+ Class clazz = query.getClass();
+ Object result = null;
+ try {
+ Method method = clazz.getMethod("get" + property, new Class[0]); //$NON-NLS-1$
+ result = method.invoke(query, new Object[0]);
+ } catch (SecurityException e) {
+ return null;
+ } catch (NoSuchMethodException e) {
+ return null;
+ } catch (IllegalArgumentException e) {
+ return null;
+ } catch (IllegalAccessException e) {
+ return null;
+ } catch (InvocationTargetException e) {
+ return null;
+ }
+ return result;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/UpdateQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/UpdateQuery.java
index 5896d82fb..6774bcbfb 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/UpdateQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/UpdateQuery.java
@@ -11,7 +11,6 @@
package org.eclipse.equinox.internal.provisional.p2.metadata.query;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
-import org.eclipse.equinox.internal.provisional.p2.query.MatchQuery;
public class UpdateQuery extends MatchQuery {
private IInstallableUnit updateFrom;

Back to the top