Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2012-01-06 16:23:29 -0500
committerThomas Watson2012-01-06 16:23:29 -0500
commit80cf0452e3b3c7c425f334a1ee1e361a809008d2 (patch)
tree65032e7f7b39f4d21e780d8df125a6808244646e
parentf039d4612d71a3b662a4da9c64f5277c179c3338 (diff)
downloadrt.equinox.framework-80cf0452e3b3c7c425f334a1ee1e361a809008d2.tar.gz
rt.equinox.framework-80cf0452e3b3c7c425f334a1ee1e361a809008d2.tar.xz
rt.equinox.framework-80cf0452e3b3c7c425f334a1ee1e361a809008d2.zip
Update VersionRange OSGi API to not use fully qualified versions unless required.
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/Version.java26
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/VersionRange.java16
2 files changed, 26 insertions, 16 deletions
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/Version.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/Version.java
index 270c519d3..2e5d0c45c 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/Version.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/Version.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) OSGi Alliance (2004, 2011). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2004, 2012). 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.
@@ -425,21 +425,31 @@ public class Version implements Comparable<Version> {
/**
* Package private method to append the version string to the specified
- * string buffer. The version string includes a trailing dot for empty
- * release qualifiers.
- *
+ * string buffer.
+ *
* @param buf The string buffer to receive the version string.
+ * @param emptyQualifier Append empty qualifier if true, otherwise do not
+ * append empty qualifier.
*/
- void appendTo(StringBuffer buf) {
+ void appendTo(StringBuffer buf, boolean emptyQualifier) {
buf.append(toString0());
- if (release && (qualifier.length() == 0)) {
- buf.append(DOT_SEPARATOR);
+ if ((qualifier.length() == 0)) {
+ if (emptyQualifier) {
+ if (release) {
+ buf.append(DOT_SEPARATOR); // add trailing dot
+ }
+ }
+ else {
+ if (!release) {
+ buf.setLength(buf.length() - 1); // strip off trailing dash
+ }
+ }
}
}
/**
* Returns a hash code value for the object.
- *
+ *
* @return An integer which is a hash code value for this object.
*/
public int hashCode() {
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/VersionRange.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/VersionRange.java
index f821cbd7c..2c9be7251 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/VersionRange.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/VersionRange.java
@@ -32,7 +32,7 @@ import java.util.StringTokenizer;
*
* @since 1.7
* @Immutable
- * @version $Id: 9afdb1cfae10edae6484aee798b206fe139b220a $
+ * @version $Id$
*/
public class VersionRange {
@@ -372,16 +372,16 @@ public class VersionRange {
String leftVersion = left.toString();
if (right == null) {
StringBuffer result = new StringBuffer(leftVersion.length() + 1);
- left.appendTo(result);
+ left.appendTo(result, !(leftClosed ^ left.isReleaseVersion()));
return versionRangeString = result.toString();
}
String rightVerion = right.toString();
StringBuffer result = new StringBuffer(leftVersion.length()
+ rightVerion.length() + 5);
result.append(leftClosed ? LEFT_CLOSED : LEFT_OPEN);
- left.appendTo(result);
+ left.appendTo(result, !(leftClosed ^ left.isReleaseVersion()));
result.append(ENDPOINT_DELIMITER);
- right.appendTo(result);
+ right.appendTo(result, rightClosed ^ right.isReleaseVersion());
result.append(rightClosed ? RIGHT_CLOSED : RIGHT_OPEN);
return versionRangeString = result.toString();
}
@@ -473,14 +473,14 @@ public class VersionRange {
result.append('(');
result.append(attributeName);
result.append(">=");
- left.appendTo(result);
+ left.appendTo(result, true);
result.append(')');
}
else {
result.append("(!(");
result.append(attributeName);
result.append("<=");
- left.appendTo(result);
+ left.appendTo(result, true);
result.append("))");
}
if (right != null) {
@@ -488,14 +488,14 @@ public class VersionRange {
result.append('(');
result.append(attributeName);
result.append("<=");
- right.appendTo(result);
+ right.appendTo(result, true);
result.append(')');
}
else {
result.append("(!(");
result.append(attributeName);
result.append(">=");
- right.appendTo(result);
+ right.appendTo(result, true);
result.append("))");
}
result.append(')');

Back to the top