Author: hboutemy
Date: Sun Dec 14 12:43:49 2008
New Revision: 726528

URL: http://svn.apache.org/viewvc?rev=726528&view=rev
Log:
[MARTIFACT-18]  Use BigInteger for version parsing.
(merged from maven-artifact r661417)

Modified:
    
maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/version/ComparableVersion.java

Modified: 
maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/version/ComparableVersion.java
URL: 
http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/version/ComparableVersion.java?rev=726528&r1=726527&r2=726528&view=diff
==============================================================================
--- 
maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/version/ComparableVersion.java
 (original)
+++ 
maven/mercury/trunk/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/version/ComparableVersion.java
 Sun Dec 14 12:43:49 2008
@@ -15,6 +15,7 @@
  * the License.
  */
 
+import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
@@ -63,11 +64,20 @@
     private static class IntegerItem
         implements Item
     {
-        private Integer value;
+       private static final BigInteger BigInteger_ZERO = new BigInteger( "0" );
 
-        public IntegerItem( Integer i )
+        private final BigInteger value;
+
+        public static final IntegerItem ZERO = new IntegerItem();
+
+        private IntegerItem()
+        {
+               this.value = BigInteger_ZERO;
+        }
+
+        public IntegerItem( String str )
         {
-            this.value = i;
+            this.value = new BigInteger( str );
         }
 
         public int getType()
@@ -77,14 +87,14 @@
 
         public boolean isNull()
         {
-            return ( value == 0 );
+            return BigInteger_ZERO.equals( value );
         }
 
         public int compareTo( Item item )
         {
             if ( item == null )
             {
-                return value == 0 ? 0 : 1; // 1.0 == 1, 1.1 > 1
+                return BigInteger_ZERO.equals( value ) ? 0 : 1; // 1.0 == 1, 
1.1 > 1
             }
 
             switch ( item.getType() )
@@ -340,7 +350,7 @@
             {
                 if ( i == startIndex )
                 {
-                    list.add( new IntegerItem( 0 ) );
+                    list.add( IntegerItem.ZERO );
                 }
                 else
                 {
@@ -352,7 +362,7 @@
             {
                 if ( i == startIndex )
                 {
-                    list.add( new IntegerItem( 0 ) );
+                    list.add( IntegerItem.ZERO );
                 }
                 else
                 {
@@ -412,7 +422,7 @@
 
     private static Item parseItem( boolean isDigit, String buf )
     {
-        return isDigit ? new IntegerItem( new Integer( buf ) ) : new 
StringItem( buf, false );
+        return isDigit ? new IntegerItem( buf ) : new StringItem( buf, false );
     }
 
     public int compareTo( Object o )


Reply via email to