directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r953686 - in /directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper: ByteArrayComparator.java IntegerComparator.java LongComparator.java StringComparator.java
Date Fri, 11 Jun 2010 12:35:29 GMT
Author: felixk
Date: Fri Jun 11 12:35:29 2010
New Revision: 953686

URL: http://svn.apache.org/viewvc?rev=953686&view=rev
Log:
Add type safety

Modified:
    directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ByteArrayComparator.java
    directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IntegerComparator.java
    directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LongComparator.java
    directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/StringComparator.java

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ByteArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ByteArrayComparator.java?rev=953686&r1=953685&r2=953686&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ByteArrayComparator.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ByteArrayComparator.java Fri Jun
11 12:35:29 2010
@@ -57,7 +57,7 @@ import org.apache.directory.server.i18n.
  * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
  */
 public final class ByteArrayComparator
-    implements Comparator, Serializable
+    implements Comparator<byte[]>, Serializable
 {
 
     /**
@@ -74,7 +74,7 @@ public final class ByteArrayComparator
      * @return a positive integer if obj1 > obj2, 0 if obj1 == obj2,
      *         and a negative integer if obj1 < obj2
      */
-     public int compare( Object obj1, Object obj2 )
+     public int compare( byte[] obj1, byte[] obj2 )
      {
         if ( obj1 == null ) {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_525 ) );
@@ -84,7 +84,7 @@ public final class ByteArrayComparator
             throw new IllegalArgumentException( I18n.err( I18n.ERR_526 ) );
         }
 
-        return compareByteArray( (byte[]) obj1, (byte[]) obj2 );
+        return compareByteArray( obj1, obj2 );
      }
 
 

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IntegerComparator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IntegerComparator.java?rev=953686&r1=953685&r2=953686&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IntegerComparator.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IntegerComparator.java Fri Jun
11 12:35:29 2010
@@ -57,7 +57,7 @@ import org.apache.directory.server.i18n.
  * @author <a href="mailto:cdaller@iicm.edu">Christof Dallermassl</a>
  */
 public final class IntegerComparator
-    implements Comparator, Serializable
+    implements Comparator<Integer>, Serializable
 {
 
     /**
@@ -74,7 +74,7 @@ public final class IntegerComparator
      * @return a positive integer if obj1 > obj2, 0 if obj1 == obj2,
      *         and a negative integer if obj1 < obj2
      */
-    public int compare( Object obj1, Object obj2 )
+    public int compare( Integer obj1, Integer obj2 )
     {
         if ( obj1 == obj2 ) {
             return 0;
@@ -90,8 +90,8 @@ public final class IntegerComparator
 
         // complicated to avoid usage of Integer.compareTo, as this
         // method is Java 1.2 only!
-        int int1 = ( (Integer) obj1 ).intValue();
-        int int2 = ( (Integer) obj2 ).intValue();
+        int int1 = obj1.intValue();
+        int int2 = obj2.intValue();
         if ( int1 == int2 ) {
             return 0;
         }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LongComparator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LongComparator.java?rev=953686&r1=953685&r2=953686&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LongComparator.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LongComparator.java Fri Jun 11
12:35:29 2010
@@ -57,7 +57,7 @@ import org.apache.directory.server.i18n.
  * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
  */
 public final class LongComparator
-    implements Comparator, Serializable
+    implements Comparator<Long>, Serializable
 {
 
     /**
@@ -74,7 +74,7 @@ public final class LongComparator
      * @return a positive integer if obj1 > obj2, 0 if obj1 == obj2,
      *         and a negative integer if obj1 < obj2
      */
-     public int compare( Object obj1, Object obj2 )
+     public int compare( Long obj1, Long obj2 )
      {
         if ( obj1 == null ) {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_525 ) );
@@ -84,8 +84,8 @@ public final class LongComparator
             throw new IllegalArgumentException( I18n.err( I18n.ERR_526 ) );
         }
 
-        long l1 = ( (Long) obj1 ).longValue();
-        long l2 = ( (Long) obj2 ).longValue();
+        long l1 = obj1.longValue();
+        long l2 = obj2.longValue();
 
         if ( l1 > l2 ) {
             return 1;

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/StringComparator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/StringComparator.java?rev=953686&r1=953685&r2=953686&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/StringComparator.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/StringComparator.java Fri Jun
11 12:35:29 2010
@@ -57,7 +57,7 @@ import org.apache.directory.server.i18n.
  * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
  */
 public final class StringComparator
-    implements Comparator, Serializable
+    implements Comparator<String>, Serializable
 {
 
     /**
@@ -74,7 +74,7 @@ public final class StringComparator
      * @return a positive integer if obj1 > obj2, 0 if obj1 == obj2,
      *         and a negative integer if obj1 < obj2
      */
-     public int compare( Object obj1, Object obj2 )
+     public int compare( String obj1, String obj2 )
      {
         if ( obj1 == null ) {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_525 ) );
@@ -84,7 +84,7 @@ public final class StringComparator
             throw new IllegalArgumentException( I18n.err( I18n.ERR_526 ) );
         }
 
-        return ( (String) obj1 ).compareTo((String) obj2 );
+        return obj1.compareTo( obj2 );
      }
 
 }



Mime
View raw message