Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Kaegi2008-12-20 22:29:40 +0000
committerSimon Kaegi2008-12-20 22:29:40 +0000
commit49739f5202494bd02e70c8be4f4f430187ac5488 (patch)
treeb9068f18765442bb24f806aff214ecac5717a90e /bundles/org.eclipse.equinox.p2.metadata
parent8d9158363fbce7c114ef59a47962bd05d56e8dcf (diff)
downloadrt.equinox.p2-49739f5202494bd02e70c8be4f4f430187ac5488.tar.gz
rt.equinox.p2-49739f5202494bd02e70c8be4f4f430187ac5488.tar.xz
rt.equinox.p2-49739f5202494bd02e70c8be4f4f430187ac5488.zip
Bug 233699 Add support for version types other than OSGi
rollback to pre_version_2008
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.metadata')
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/UpdateDescriptor.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IArtifactKey.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IInstallableUnit.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/IUpdateDescriptor.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/MetadataFactory.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/ProvidedCapability.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/RequiredCapability.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/RequirementChange.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/TouchpointType.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/Version.java388
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/VersionRange.java186
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/InstallableUnitQuery.java4
15 files changed, 16 insertions, 590 deletions
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 2e0cff40c..1af3c1361 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
@@ -14,7 +14,7 @@ import java.util.ArrayList;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.Assert;
import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import org.osgi.framework.Version;
/**
* The concrete type for representing IArtifactKey's.
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 cfd3cb007..669dad32b 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
@@ -15,7 +15,7 @@ import java.util.ArrayList;
import java.util.Map;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
-import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import org.osgi.framework.Version;
public class InstallableUnit implements IInstallableUnit {
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 3da70b342..1bce84eaa 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
@@ -13,7 +13,7 @@ package org.eclipse.equinox.internal.p2.metadata;
import java.util.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
-import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import org.osgi.framework.Version;
public class ResolvedInstallableUnit implements IInstallableUnit {
private static IInstallableUnit[] NO_IU = new IInstallableUnit[0];
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 c3518df86..e379219fb 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
@@ -10,7 +10,7 @@ package org.eclipse.equinox.internal.p2.metadata;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.metadata.IUpdateDescriptor;
-import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
+import org.eclipse.osgi.service.resolver.VersionRange;
public class UpdateDescriptor implements IUpdateDescriptor {
private String description;
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 41c41ed45..0fac719dc 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
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.metadata;
-import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import org.osgi.framework.Version;
/**
* Provide standardized artifact information to uniquely identify the
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 0ab466361..35cc0d639 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,7 +11,7 @@
package org.eclipse.equinox.internal.provisional.p2.metadata;
import java.util.Map;
-import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import org.osgi.framework.Version;
public interface IInstallableUnit extends Comparable {
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 854ec5690..38b3f4a49 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
@@ -8,7 +8,7 @@
******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.metadata;
-import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
+import org.eclipse.osgi.service.resolver.VersionRange;
public interface IUpdateDescriptor {
public final int NORMAL = 0;
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 58dfe1e3c..30cecdc07 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
@@ -15,8 +15,8 @@ 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.VersionRange;
-import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import org.eclipse.osgi.service.resolver.VersionRange;
+import org.osgi.framework.Version;
/**
* 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/ProvidedCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/ProvidedCapability.java
index ccf55119a..e720196a0 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/ProvidedCapability.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/ProvidedCapability.java
@@ -11,7 +11,7 @@
package org.eclipse.equinox.internal.provisional.p2.metadata;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import org.osgi.framework.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/RequiredCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/RequiredCapability.java
index 3e823d1cd..a30494ebc 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/RequiredCapability.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/RequiredCapability.java
@@ -9,7 +9,7 @@
package org.eclipse.equinox.internal.provisional.p2.metadata;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
+import org.eclipse.osgi.service.resolver.VersionRange;
/**
* A required capability represents some external constraint on an {@link IInstallableUnit}.
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/RequirementChange.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/RequirementChange.java
index 93e5046dd..ffaf8bd53 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/RequirementChange.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/RequirementChange.java
@@ -8,8 +8,8 @@
******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.metadata;
-import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
-import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import org.eclipse.osgi.service.resolver.VersionRange;
+import org.osgi.framework.Version;
public class RequirementChange {
private RequiredCapability applyOn;
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/TouchpointType.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/TouchpointType.java
index 1904760b0..6c9cd126a 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/TouchpointType.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/TouchpointType.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.metadata;
-import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import org.osgi.framework.Version;
/**
* Identifies a particular touchpoint. A touchpoint is identified by an id
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
deleted file mode 100644
index 248088114..000000000
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/Version.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2004, 2008). All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*******************************************************************************
- * Copyright (c) 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.core;
-
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
-
-/**
- * Version identifier for bundles and packages.
- *
- * <p>
- * Version identifiers have four components.
- * <ol>
- * <li>Major version. A non-negative integer.</li>
- * <li>Minor version. A non-negative integer.</li>
- * <li>Micro version. A non-negative integer.</li>
- * <li>Qualifier. A text string. See <code>Version(String)</code> for the
- * format of the qualifier string.</li>
- * </ol>
- *
- * <p>
- * <code>Version</code> objects are immutable.
- *
- * @since 1.3
- * @Immutable
- * @version $Revision: 5962 $
- */
-
-public class Version implements Comparable {
- private final int major;
- private final int minor;
- private final int micro;
- private final String qualifier;
- private static final String SEPARATOR = "."; //$NON-NLS-1$
-
- /**
- * The empty version "0.0.0". Equivalent to calling
- * <code>new Version(0,0,0)</code>.
- */
- public static final Version emptyVersion = new Version(0, 0, 0);
-
- /**
- * Creates a version identifier from the specified numerical components.
- *
- * <p>
- * The qualifier is set to the empty string.
- *
- * @param major Major component of the version identifier.
- * @param minor Minor component of the version identifier.
- * @param micro Micro component of the version identifier.
- * @throws IllegalArgumentException If the numerical components are
- * negative.
- */
- public Version(int major, int minor, int micro) {
- this(major, minor, micro, null);
- }
-
- /**
- * Creates a version identifier from the specified components.
- *
- * @param major Major component of the version identifier.
- * @param minor Minor component of the version identifier.
- * @param micro Micro component of the version identifier.
- * @param qualifier Qualifier component of the version identifier. If
- * <code>null</code> is specified, then the qualifier will be set to
- * the empty string.
- * @throws IllegalArgumentException If the numerical components are negative
- * or the qualifier string is invalid.
- */
- public Version(int major, int minor, int micro, String qualifier) {
- if (qualifier == null) {
- qualifier = ""; //$NON-NLS-1$
- }
-
- this.major = major;
- this.minor = minor;
- this.micro = micro;
- this.qualifier = qualifier;
- validate();
- }
-
- /**
- * Created a version identifier from the specified string.
- *
- * <p>
- * Here is the grammar for version strings.
- *
- * <pre>
- * version ::= major('.'minor('.'micro('.'qualifier)?)?)?
- * major ::= digit+
- * minor ::= digit+
- * micro ::= digit+
- * qualifier ::= (alpha|digit|'_'|'-')+
- * digit ::= [0..9]
- * alpha ::= [a..zA..Z]
- * </pre>
- *
- * There must be no whitespace in version.
- *
- * @param version String representation of the version identifier.
- * @throws IllegalArgumentException If <code>version</code> is improperly
- * formatted.
- */
- public Version(String version) {
- int major = 0;
- int minor = 0;
- int micro = 0;
- String qualifier = ""; //$NON-NLS-1$
-
- try {
- StringTokenizer st = new StringTokenizer(version, SEPARATOR, true);
- major = Integer.parseInt(st.nextToken());
-
- if (st.hasMoreTokens()) {
- st.nextToken(); // consume delimiter
- minor = Integer.parseInt(st.nextToken());
-
- if (st.hasMoreTokens()) {
- st.nextToken(); // consume delimiter
- micro = Integer.parseInt(st.nextToken());
-
- if (st.hasMoreTokens()) {
- st.nextToken(); // consume delimiter
- qualifier = st.nextToken();
-
- if (st.hasMoreTokens()) {
- throw new IllegalArgumentException("invalid format"); //$NON-NLS-1$
- }
- }
- }
- }
- } catch (NoSuchElementException e) {
- throw new IllegalArgumentException("invalid format"); //$NON-NLS-1$
- }
-
- this.major = major;
- this.minor = minor;
- this.micro = micro;
- this.qualifier = qualifier;
- validate();
- }
-
- /**
- * Called by the Version constructors to validate the version components.
- *
- * @throws IllegalArgumentException If the numerical components are negative
- * or the qualifier string is invalid.
- */
- private void validate() {
- if (major < 0) {
- throw new IllegalArgumentException("negative major"); //$NON-NLS-1$
- }
- if (minor < 0) {
- throw new IllegalArgumentException("negative minor"); //$NON-NLS-1$
- }
- if (micro < 0) {
- throw new IllegalArgumentException("negative micro"); //$NON-NLS-1$
- }
- char[] chars = qualifier.toCharArray();
- for (int i = 0, length = chars.length; i < length; i++) {
- char ch = chars[i];
- if (('A' <= ch) && (ch <= 'Z')) {
- continue;
- }
- if (('a' <= ch) && (ch <= 'z')) {
- continue;
- }
- if (('0' <= ch) && (ch <= '9')) {
- continue;
- }
- if ((ch == '_') || (ch == '-')) {
- continue;
- }
- throw new IllegalArgumentException("invalid qualifier: " + qualifier); //$NON-NLS-1$
- }
- }
-
- /**
- * Parses a version identifier from the specified string.
- *
- * <p>
- * See <code>Version(String)</code> for the format of the version string.
- *
- * @param version String representation of the version identifier. Leading
- * and trailing whitespace will be ignored.
- * @return A <code>Version</code> object representing the version
- * identifier. If <code>version</code> is <code>null</code> or
- * the empty string then <code>emptyVersion</code> will be
- * returned.
- * @throws IllegalArgumentException If <code>version</code> is improperly
- * formatted.
- */
- public static Version parseVersion(String version) {
- if (version == null) {
- return emptyVersion;
- }
-
- version = version.trim();
- if (version.length() == 0) {
- return emptyVersion;
- }
-
- return new Version(version);
- }
-
- /**
- * Returns the major component of this version identifier.
- *
- * @return The major component.
- */
- public int getMajor() {
- return major;
- }
-
- /**
- * Returns the minor component of this version identifier.
- *
- * @return The minor component.
- */
- public int getMinor() {
- return minor;
- }
-
- /**
- * Returns the micro component of this version identifier.
- *
- * @return The micro component.
- */
- public int getMicro() {
- return micro;
- }
-
- /**
- * Returns the qualifier component of this version identifier.
- *
- * @return The qualifier component.
- */
- public String getQualifier() {
- return qualifier;
- }
-
- /**
- * Returns the string representation of this version identifier.
- *
- * <p>
- * The format of the version string will be <code>major.minor.micro</code>
- * if qualifier is the empty string or
- * <code>major.minor.micro.qualifier</code> otherwise.
- *
- * @return The string representation of this version identifier.
- */
- public String toString() {
- int q = qualifier.length();
- StringBuffer result = new StringBuffer(20 + q);
- result.append(major);
- result.append(SEPARATOR);
- result.append(minor);
- result.append(SEPARATOR);
- result.append(micro);
- if (q > 0) {
- result.append(SEPARATOR);
- result.append(qualifier);
- }
- return result.toString();
- }
-
- /**
- * Returns a hash code value for the object.
- *
- * @return An integer which is a hash code value for this object.
- */
- public int hashCode() {
- return (major << 24) + (minor << 16) + (micro << 8) + qualifier.hashCode();
- }
-
- /**
- * Compares this <code>Version</code> object to another object.
- *
- * <p>
- * A version is considered to be <b>equal to </b> another version if the
- * major, minor and micro components are equal and the qualifier component
- * is equal (using <code>String.equals</code>).
- *
- * @param object The <code>Version</code> object to be compared.
- * @return <code>true</code> if <code>object</code> is a
- * <code>Version</code> and is equal to this object;
- * <code>false</code> otherwise.
- */
- public boolean equals(Object object) {
- if (object == this) { // quicktest
- return true;
- }
-
- if (!(object instanceof Version)) {
- return false;
- }
-
- Version other = (Version) object;
- return (major == other.major) && (minor == other.minor) && (micro == other.micro) && qualifier.equals(other.qualifier);
- }
-
- /**
- * Compares this <code>Version</code> object to another object.
- *
- * <p>
- * A version is considered to be <b>less than </b> another version if its
- * major component is less than the other version's major component, or the
- * major components are equal and its minor component is less than the other
- * version's minor component, or the major and minor components are equal
- * and its micro component is less than the other version's micro component,
- * or the major, minor and micro components are equal and it's qualifier
- * component is less than the other version's qualifier component (using
- * <code>String.compareTo</code>).
- *
- * <p>
- * A version is considered to be <b>equal to</b> another version if the
- * major, minor and micro components are equal and the qualifier component
- * is equal (using <code>String.compareTo</code>).
- *
- * @param object The <code>Version</code> object to be compared.
- * @return A negative integer, zero, or a positive integer if this object is
- * less than, equal to, or greater than the specified
- * <code>Version</code> object.
- * @throws ClassCastException If the specified object is not a
- * <code>Version</code>.
- */
- public int compareTo(Object object) {
- if (object == this) { // quicktest
- return 0;
- }
-
- Version other = (Version) object;
-
- int result = major - other.major;
- if (result != 0) {
- return result;
- }
-
- result = minor - other.minor;
- if (result != 0) {
- return result;
- }
-
- result = micro - other.micro;
- if (result != 0) {
- return result;
- }
-
- return qualifier.compareTo(other.qualifier);
- }
-
- public static Version fromOSGiVersion(org.osgi.framework.Version version) {
- if (version.equals(org.osgi.framework.Version.emptyVersion))
- return emptyVersion;
- return new Version(version.getMajor(), version.getMinor(), version.getMicro(), version.getQualifier());
- }
-
- public static org.osgi.framework.Version toOSGiVersion(Version version) {
- if (version.equals(emptyVersion))
- return org.osgi.framework.Version.emptyVersion;
- return new org.osgi.framework.Version(version.getMajor(), version.getMinor(), version.getMicro(), version.getQualifier());
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/VersionRange.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/VersionRange.java
deleted file mode 100644
index 8ea40b7d1..000000000
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/VersionRange.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 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.core;
-
-/**
- * This class represents a version range.
- * @since 3.1
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class VersionRange {
- private static final Version versionMax = new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
- /**
- * An empty version
- */
- public static final VersionRange emptyRange = new VersionRange(null);
-
- private final Version minVersion;
- private final boolean includeMin;
- private final Version maxVersion;
- private final boolean includeMax;
-
- /**
- * Constructs a VersionRange with the specified minVersion and maxVersion.
- * @param minVersion the minimum version of the range
- * @param maxVersion the maximum version of the range
- */
- public VersionRange(Version minVersion, boolean includeMin, Version maxVersion, boolean includeMax) {
- this.minVersion = minVersion;
- this.includeMin = includeMin;
- this.maxVersion = maxVersion;
- this.includeMax = includeMax;
- }
-
- /**
- * Constructs a VersionRange from the given versionRange String.
- * @param versionRange a version range String that specifies a range of
- * versions.
- */
- public VersionRange(String versionRange) {
- if (versionRange == null || versionRange.length() == 0) {
- minVersion = Version.emptyVersion;
- includeMin = true;
- maxVersion = VersionRange.versionMax;
- includeMax = true;
- return;
- }
- versionRange = versionRange.trim();
- if (versionRange.charAt(0) == '[' || versionRange.charAt(0) == '(') {
- int comma = versionRange.indexOf(',');
- if (comma < 0)
- throw new IllegalArgumentException();
- char last = versionRange.charAt(versionRange.length() - 1);
- if (last != ']' && last != ')')
- throw new IllegalArgumentException();
-
- minVersion = Version.parseVersion(versionRange.substring(1, comma).trim());
- includeMin = versionRange.charAt(0) == '[';
- maxVersion = Version.parseVersion(versionRange.substring(comma + 1, versionRange.length() - 1).trim());
- includeMax = last == ']';
- } else {
- minVersion = Version.parseVersion(versionRange.trim());
- includeMin = true;
- maxVersion = VersionRange.versionMax;
- includeMax = true;
- }
- }
-
- /**
- * Returns the minimum Version of this VersionRange
- * @return the minimum Version of this VersionRange
- */
- public Version getMinimum() {
- return minVersion;
- }
-
- /**
- * Indicates if the minimum version is included in the version range.
- * @return true if the minimum version is included in the version range;
- * otherwise false is returned
- */
- public boolean getIncludeMinimum() {
- return includeMin;
- }
-
- /**
- * Returns the maximum Version of this VersionRange
- * @return the maximum Version of this VersionRange
- */
- public Version getMaximum() {
- return maxVersion;
- }
-
- /**
- * Indicates if the maximum version is included in the version range.
- * @return true if the maximum version is included in the version range;
- * otherwise false is returned
- */
- public boolean getIncludeMaximum() {
- return includeMax;
- }
-
- /**
- * Returns whether the given version is included in this VersionRange.
- * This will depend on the minimum and maximum versions of this VersionRange
- * and the given version.
- *
- * @param version a version to be tested for inclusion in this VersionRange.
- * (may be <code>null</code>)
- * @return <code>true</code> if the version is include,
- * <code>false</code> otherwise
- */
- public boolean isIncluded(Version version) {
- Version minRequired = getMinimum();
- if (minRequired == null)
- return true;
- if (version == null)
- return false;
- Version maxRequired = getMaximum() == null ? VersionRange.versionMax : getMaximum();
- int minCheck = includeMin ? 0 : 1;
- int maxCheck = includeMax ? 0 : -1;
- return version.compareTo(minRequired) >= minCheck && version.compareTo(maxRequired) <= maxCheck;
-
- }
-
- public boolean equals(Object object) {
- if (!(object instanceof VersionRange))
- return false;
- VersionRange vr = (VersionRange) object;
- if (minVersion != null && vr.getMinimum() != null) {
- if (minVersion.equals(vr.getMinimum()) && includeMin == vr.includeMin)
- if (maxVersion != null && vr.getMaximum() != null) {
- if (maxVersion.equals(vr.getMaximum()) && includeMax == vr.includeMax)
- return true;
- } else
- return maxVersion == vr.getMaximum();
- } else {
- return minVersion == vr.getMinimum();
- }
- return false;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (maxVersion != null ? maxVersion.hashCode() : VersionRange.versionMax.hashCode());
- result = prime * result + (minVersion != null ? minVersion.hashCode() : Version.emptyVersion.hashCode());
- result = prime * result + (includeMax ? 1231 : 1237);
- result = prime * result + (includeMin ? 1231 : 1237);
- return result;
- }
-
- public String toString() {
- if (minVersion == null)
- return Version.emptyVersion.toString();
- if (VersionRange.versionMax.equals(maxVersion))
- return minVersion.toString();
- StringBuffer result = new StringBuffer();
- result.append(includeMin ? '[' : '(');
- result.append(minVersion);
- result.append(',');
- result.append(maxVersion);
- result.append(includeMax ? ']' : ')');
- return result.toString();
- }
-
- public static org.eclipse.osgi.service.resolver.VersionRange toOSGiVersionRange(VersionRange range) {
- if (range.equals(emptyRange))
- return org.eclipse.osgi.service.resolver.VersionRange.emptyRange;
- return new org.eclipse.osgi.service.resolver.VersionRange(Version.toOSGiVersion(range.getMinimum()), range.getIncludeMinimum(), Version.toOSGiVersion(range.getMaximum()), range.getIncludeMinimum());
- }
-
- public static VersionRange fromOSGiVersionRange(org.eclipse.osgi.service.resolver.VersionRange range) {
- if (range.equals(org.eclipse.osgi.service.resolver.VersionRange.emptyRange))
- return emptyRange;
- return new VersionRange(Version.fromOSGiVersion(range.getMinimum()), range.getIncludeMinimum(), Version.fromOSGiVersion(range.getMaximum()), range.getIncludeMinimum());
- }
-
-}
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 9a7183fde..04db9f8a9 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.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.query.Query;
-import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
-import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import org.eclipse.osgi.service.resolver.VersionRange;
+import org.osgi.framework.Version;
/**
* A query that matches on the id and version of an {@link IInstallableUnit}.

Back to the top