felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject svn commit: r1646527 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
Date Thu, 18 Dec 2014 20:21:16 GMT
Author: bob
Date: Thu Dec 18 20:21:16 2014
New Revision: 1646527

URL: http://svn.apache.org/r1646527
Log:
FELIX-4729 Added ability to perform version range matching for capabilities.

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java?rev=1646527&r1=1646526&r2=1646527&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
Thu Dec 18 20:21:16 2014
@@ -32,9 +32,12 @@ import java.util.Map;
 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 @@ public class CapabilitySet
             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 @@ public class CapabilitySet
             {
                 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.



Mime
View raw message