FELIX-4729 Added ability to perform version range matching for capabilities.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1646527 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java b/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
index 738652e..982957e 100644
--- a/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
+++ b/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
@@ -32,9 +32,12 @@
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
+
import org.apache.felix.framework.util.SecureAction;
import org.apache.felix.framework.util.StringComparator;
+import org.apache.felix.framework.util.VersionRange;
import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.osgi.framework.Version;
import org.osgi.framework.wiring.BundleCapability;
public class CapabilitySet
@@ -385,6 +388,26 @@
return true;
}
+ //Need a special case here when lhs is a Version and rhs is a VersionRange
+ //Version is comparable so we need to check this first
+ if(lhs instanceof Version && op == SimpleFilter.EQ)
+ {
+ Object rhs = null;
+ try
+ {
+ rhs = coerceType(lhs, (String) rhsUnknown);
+ }
+ catch (Exception ex)
+ {
+ //Do nothing will check later if rhs is null
+ }
+
+ if(rhs != null && rhs instanceof VersionRange)
+ {
+ return ((VersionRange)rhs).isInRange((Version)lhs);
+ }
+ }
+
// If the type is comparable, then we can just return the
// result immediately.
if (lhs instanceof Comparable)
@@ -565,6 +588,10 @@
{
rhs = new Character(rhsString.charAt(0));
}
+ else if(lhs instanceof Version && rhsString.indexOf(',') >= 0)
+ {
+ rhs = VersionRange.parse(rhsString);
+ }
else
{
// Spec says we should trim number types.