sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r612038 - in /incubator/sling/trunk/osgi/assembly/src/main/java/org/apache/sling/osgi/assembly: installer/VersionRange.java internal/InstallerImpl.java
Date Tue, 15 Jan 2008 08:46:22 GMT
Author: fmeschbe
Date: Tue Jan 15 00:46:11 2008
New Revision: 612038

URL: http://svn.apache.org/viewvc?rev=612038&view=rev
Log:
SLING-153: Implement VersionRange.equals method and do not set an
   equality version, if the VersionRange equals the default version
   range 0.0.0.

Modified:
    incubator/sling/trunk/osgi/assembly/src/main/java/org/apache/sling/osgi/assembly/installer/VersionRange.java
    incubator/sling/trunk/osgi/assembly/src/main/java/org/apache/sling/osgi/assembly/internal/InstallerImpl.java

Modified: incubator/sling/trunk/osgi/assembly/src/main/java/org/apache/sling/osgi/assembly/installer/VersionRange.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/assembly/src/main/java/org/apache/sling/osgi/assembly/installer/VersionRange.java?rev=612038&r1=612037&r2=612038&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/assembly/src/main/java/org/apache/sling/osgi/assembly/installer/VersionRange.java
(original)
+++ incubator/sling/trunk/osgi/assembly/src/main/java/org/apache/sling/osgi/assembly/installer/VersionRange.java
Tue Jan 15 00:46:11 2008
@@ -18,6 +18,8 @@
 
 import org.osgi.framework.Version;
 
+import sun.security.action.GetLongAction;
+
 public class VersionRange {
 
     /**
@@ -184,9 +186,63 @@
         return "(&(version" + op + "=" + v + ")(!(version=" + v + ")))";
     }
 
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        } else if (!(obj instanceof VersionRange)) {
+            return false;
+        }
+        
+        VersionRange other = (VersionRange) obj;
+        
+        if (!getLow().equals(other.getLow())) {
+            return false;
+        }
+        
+        if (isLowInclusive() != other.isLowInclusive()) {
+            return false;
+        }
+        
+        if (getHigh() == null) {
+            if (other.getHigh() != null) {
+                return false;
+            }
+        } else {
+            if (!getHigh().equals(other.getHigh())) {
+                return false;
+            }
+        }
+        
+        if (isHighInclusive() != other.isHighInclusive()) {
+            return false;
+        }
+        
+        // if all checks succeeded, the ranges are equal
+        return true;
+    }
+    
+    @Override
+    public int hashCode() {
+        int code = 17 * getLow().hashCode();
+        if (isLowInclusive()) {
+            code += 33;
+        }
+        
+        if (getHigh() != null) {
+            code += 41 * getHigh().hashCode();
+            if (isHighInclusive()) {
+                code += 11;
+            }
+        }
+        
+        return code;
+    }
+    
     /**
      * Returns a string representation of this version range.
      */
+    @Override
     public String toString() {
         // return single version if there is no upper bound
         if (this.getHigh() == null) {

Modified: incubator/sling/trunk/osgi/assembly/src/main/java/org/apache/sling/osgi/assembly/internal/InstallerImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/assembly/src/main/java/org/apache/sling/osgi/assembly/internal/InstallerImpl.java?rev=612038&r1=612037&r2=612038&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/assembly/src/main/java/org/apache/sling/osgi/assembly/internal/InstallerImpl.java
(original)
+++ incubator/sling/trunk/osgi/assembly/src/main/java/org/apache/sling/osgi/assembly/internal/InstallerImpl.java
Tue Jan 15 00:46:11 2008
@@ -392,7 +392,9 @@
              * version range <em>[a.b.c,a.b.d)</em> is returned where
              * <em>d = c + 1</em>.
              */
-            if (versionRange != null && versionRange.getHigh() == null) {
+            if (versionRange != null && versionRange.getHigh() == null
+                && !VersionRange.DEFAULT.equals(versionRange)) {
+                
                 Version low = versionRange.getLow();
                 Version high = new Version(low.getMajor(), low.getMinor(),
                     low.getMicro() + 1);



Mime
View raw message