Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2013-10-03 06:11:51 -0400
committerMikaƫl Barbero2013-10-03 08:02:33 -0400
commite7d42794195d6c67101a026d624a32616df554ed (patch)
treec482b642d8fc3c8d0b85092efa64a1fe886f96f7 /plugins/org.eclipse.emf.compare.ide.ui/src
parent35f30158008b2a1505077f69bbf0221ab79f7015 (diff)
downloadorg.eclipse.emf.compare-e7d42794195d6c67101a026d624a32616df554ed.tar.gz
org.eclipse.emf.compare-e7d42794195d6c67101a026d624a32616df554ed.tar.xz
org.eclipse.emf.compare-e7d42794195d6c67101a026d624a32616df554ed.zip
[412075] Restore binary compatibility with Helios.
Compatible implementation of the org.osgi.framework.Version.compareTo(Version) method to avoid binary incompatibility with OSGi frameworks before they were compiled with Java 5. Bug: 412075 Change-Id: Ife2793de783d4baba8e0a3cb3aa835ae76e79f1a
Diffstat (limited to 'plugins/org.eclipse.emf.compare.ide.ui/src')
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/accessor/AccessorAdapter.java5
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/util/OSGIVersionUtil.java46
2 files changed, 49 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/accessor/AccessorAdapter.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/accessor/AccessorAdapter.java
index ba03ee09d..abb983116 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/accessor/AccessorAdapter.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/accessor/AccessorAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Obeo.
+ * Copyright (c) 2012, 2013 Obeo.
* 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
@@ -17,6 +17,7 @@ import org.eclipse.compare.IStreamContentAccessor;
import org.eclipse.compare.ITypedElement;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.util.OSGIVersionUtil;
import org.eclipse.swt.graphics.Image;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;
@@ -66,7 +67,7 @@ public final class AccessorAdapter implements ITypedElement, IStreamContentAcces
*/
Bundle compareBundle = Platform.getBundle("org.eclipse.compare"); //$NON-NLS-1$
Version compareBundleVersion = compareBundle.getVersion();
- if (compareBundleVersion.compareTo(BUG_293926_VERSION) < 0) {
+ if (OSGIVersionUtil.compare(compareBundleVersion, BUG_293926_VERSION) < 0) {
// workaround for before before indigo SR1 - 3.7.1
return new ByteArrayInputStream(new byte[] {' ' });
} else {
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/util/OSGIVersionUtil.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/util/OSGIVersionUtil.java
new file mode 100644
index 000000000..6d321e324
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/util/OSGIVersionUtil.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.util;
+
+import org.osgi.framework.Version;
+
+/**
+ * Avoid using org.osgi.framework.Version.compareTo(Version) method to avoid binary incompatibility with OSGi
+ * frameworks before they were compiled with Java 5.
+ *
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ */
+public class OSGIVersionUtil {
+
+ /**
+ * Same contract as {@link Version#compareTo(Version)}
+ *
+ * @param that
+ * The {@code Version} object to be compared.
+ * @param other
+ * The {@code Version} object to be compared.
+ * @return A negative integer, zero, or a positive integer if {@code that} version is less than, equal to,
+ * or greater than the specified {@code other} version.
+ */
+ public static int compare(Version that, Version other) {
+ if (other == that) {
+ return 0;
+ } else if (that.getMajor() != other.getMajor()) {
+ return that.getMajor() - other.getMajor();
+ } else if (that.getMinor() != other.getMinor()) {
+ return that.getMinor() - other.getMinor();
+ } else if (that.getMicro() != other.getMicro()) {
+ return that.getMicro() - other.getMicro();
+ } else {
+ return that.getQualifier().compareTo(other.getQualifier());
+ }
+ }
+}

Back to the top