You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ga...@apache.org on 2006/07/06 18:08:03 UTC

svn commit: r419599 - in /webservices/axis/trunk/java: src/org/apache/axis/types/ test/types/

Author: gawor
Date: Thu Jul  6 09:08:03 2006
New Revision: 419599

URL: http://svn.apache.org/viewvc?rev=419599&view=rev
Log:
a fix and tests for AXIS-2327

Modified:
    webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedByte.java
    webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedInt.java
    webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedLong.java
    webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedShort.java
    webservices/axis/trunk/java/test/types/TestUnsignedByte.java
    webservices/axis/trunk/java/test/types/TestUnsignedInt.java
    webservices/axis/trunk/java/test/types/TestUnsignedLong.java
    webservices/axis/trunk/java/test/types/TestUnsignedShort.java

Modified: webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedByte.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedByte.java?rev=419599&r1=419598&r2=419599&view=diff
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedByte.java (original)
+++ webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedByte.java Thu Jul  6 09:08:03 2006
@@ -69,4 +69,8 @@
         return true;
     }
 
+    public int compareTo(Object obj) {
+        return compareTo((UnsignedByte)obj);
+    }
+
 }

Modified: webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedInt.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedInt.java?rev=419599&r1=419598&r2=419599&view=diff
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedInt.java (original)
+++ webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedInt.java Thu Jul  6 09:08:03 2006
@@ -106,13 +106,23 @@
 
     // implement java.lang.comparable interface
     public int compareTo(Object obj) {
-      if (lValue != null)
-        return lValue.compareTo(obj);
-      else
-        if (equals(obj) == true)
-            return 0;  // null == null
-        else
-            return 1;  // object is greater
+        return compareTo((UnsignedInt)obj);
+    }
+
+    public int compareTo(UnsignedInt o) {
+        if (lValue == null) {
+            if (o.lValue == null) {
+                return 0;
+            } else {
+                return -1;
+            }
+        } else {
+            if (o.lValue == null) {
+                return 1;
+            } else {
+                return lValue.compareTo(o.lValue);
+            }
+        }
     }
 
     // Implement java.lang.Number interface

Modified: webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedLong.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedLong.java?rev=419599&r1=419598&r2=419599&view=diff
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedLong.java (original)
+++ webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedLong.java Thu Jul  6 09:08:03 2006
@@ -100,12 +100,23 @@
 
     // implement java.lang.comparable interface
     public int compareTo(Object obj) {
-        if (lValue != null)
-            return lValue.compareTo(obj);
-        else if (equals(obj) == true)
-            return 0;  // null == null
-        else
-            return 1;  // object is greater
+        return compareTo((UnsignedLong)obj);
+    }
+
+    public int compareTo(UnsignedLong o) {
+        if (lValue == null) {
+            if (o.lValue == null) {
+                return 0;
+            } else {
+                return -1;
+            }
+        } else {
+            if (o.lValue == null) {
+                return 1;
+            } else {
+                return lValue.compareTo(o.lValue);
+            }
+        }
     }
 
     // Implement java.lang.Number interface

Modified: webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedShort.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedShort.java?rev=419599&r1=419598&r2=419599&view=diff
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedShort.java (original)
+++ webservices/axis/trunk/java/src/org/apache/axis/types/UnsignedShort.java Thu Jul  6 09:08:03 2006
@@ -67,4 +67,8 @@
         return true;
     }
 
+    public int compareTo(Object obj) {
+        return compareTo((UnsignedShort)obj);
+    }
+
 }

Modified: webservices/axis/trunk/java/test/types/TestUnsignedByte.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/java/test/types/TestUnsignedByte.java?rev=419599&r1=419598&r2=419599&view=diff
==============================================================================
--- webservices/axis/trunk/java/test/types/TestUnsignedByte.java (original)
+++ webservices/axis/trunk/java/test/types/TestUnsignedByte.java Thu Jul  6 09:08:03 2006
@@ -92,4 +92,24 @@
     public void testMinExclusive() throws Exception {
        runPassTest(0L);
     }
+
+    public void testCompareTo() throws Exception {
+        UnsignedByte v1, v2;
+
+        v1 = new UnsignedByte(100);
+        v2 = new UnsignedByte(200);
+
+        assertTrue(v1.compareTo(v2) < 0);
+        assertTrue(v2.compareTo(v1) > 0);
+
+        v2 = new UnsignedByte(100);
+
+        assertTrue(v1.compareTo(v2) == 0);
+        assertTrue(v2.compareTo(v1) == 0);
+
+        v2 = v1;
+
+        assertTrue(v1.compareTo(v2) == 0);
+    }
+
 }

Modified: webservices/axis/trunk/java/test/types/TestUnsignedInt.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/java/test/types/TestUnsignedInt.java?rev=419599&r1=419598&r2=419599&view=diff
==============================================================================
--- webservices/axis/trunk/java/test/types/TestUnsignedInt.java (original)
+++ webservices/axis/trunk/java/test/types/TestUnsignedInt.java Thu Jul  6 09:08:03 2006
@@ -93,4 +93,23 @@
        runPassTest(0L);
     }
 
+    public void testCompareTo() throws Exception {
+        UnsignedInt v1, v2;
+
+        v1 = new UnsignedInt(500);
+        v2 = new UnsignedInt(600);
+
+        assertTrue(v1.compareTo(v2) < 0);
+        assertTrue(v2.compareTo(v1) > 0);
+
+        v2 = new UnsignedInt(500);
+
+        assertTrue(v1.compareTo(v2) == 0);
+        assertTrue(v2.compareTo(v1) == 0);
+
+        v2 = v1;
+
+        assertTrue(v1.compareTo(v2) == 0);
+    }
+
 }

Modified: webservices/axis/trunk/java/test/types/TestUnsignedLong.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/java/test/types/TestUnsignedLong.java?rev=419599&r1=419598&r2=419599&view=diff
==============================================================================
--- webservices/axis/trunk/java/test/types/TestUnsignedLong.java (original)
+++ webservices/axis/trunk/java/test/types/TestUnsignedLong.java Thu Jul  6 09:08:03 2006
@@ -94,4 +94,24 @@
     public void testMinExclusive() throws Exception {
         runPassTest(BigInteger.ZERO, "0");
     }
+
+    public void testCompareTo() throws Exception {
+        UnsignedLong v1, v2;
+
+        v1 = new UnsignedLong(500);
+        v2 = new UnsignedLong(600);
+
+        assertTrue(v1.compareTo(v2) < 0);
+        assertTrue(v2.compareTo(v1) > 0);
+
+        v2 = new UnsignedLong(500);
+
+        assertTrue(v1.compareTo(v2) == 0);
+        assertTrue(v2.compareTo(v1) == 0);
+
+        v2 = v1;
+
+        assertTrue(v1.compareTo(v2) == 0);
+    }
+
 }

Modified: webservices/axis/trunk/java/test/types/TestUnsignedShort.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/java/test/types/TestUnsignedShort.java?rev=419599&r1=419598&r2=419599&view=diff
==============================================================================
--- webservices/axis/trunk/java/test/types/TestUnsignedShort.java (original)
+++ webservices/axis/trunk/java/test/types/TestUnsignedShort.java Thu Jul  6 09:08:03 2006
@@ -92,4 +92,24 @@
     public void testMinExclusive() throws Exception {
        runPassTest(0L);
     }
+
+    public void testCompareTo() throws Exception {
+        UnsignedShort v1, v2;
+
+        v1 = new UnsignedShort(500);
+        v2 = new UnsignedShort(600);
+
+        assertTrue(v1.compareTo(v2) < 0);
+        assertTrue(v2.compareTo(v1) > 0);
+
+        v2 = new UnsignedShort(500);
+
+        assertTrue(v1.compareTo(v2) == 0);
+        assertTrue(v2.compareTo(v1) == 0);
+
+        v2 = v1;
+
+        assertTrue(v1.compareTo(v2) == 0);
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org