[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] [generics] Patch: FYI: Comparable fixes
From: |
Tom Tromey |
Subject: |
[cp-patches] [generics] Patch: FYI: Comparable fixes |
Date: |
27 Sep 2005 10:52:33 -0600 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
I'm checking this in on the generics branch.
This fixes Comparable instantiations in several places.
Tom
Index: ChangeLog
from Tom Tromey <address@hidden>
* java/sql/Timestamp.java (compareTo(Date)): Changed argument type
from Object.
* javax/naming/Name.java (Name): Implements Comparable<Object>.
* java/util/Date.java (Date): Implements Comparable<Date>.
(compareTo(Object)): Removed.
* java/text/CollationKey.java (CollationKey): Implements
Comparable<CollationKey>.
(compareTo(Object)): Removed.
* java/net/URI.java (URI): Implements Comparable<URI>.
(compareTo): Updated argument type.
* java/math/BigDecimal.java (BigInteger): Implements
Comparable<BigDecimal>.
(compareTo(Object)): Removed.
* java/math/BigInteger.java (BigInteger): Implements
Comparable<BigInteger>.
(compareTo(Object)): Removed.
* java/io/File.java (File): Implements Comparable<File>.
(compareTo(Object)): Removed.
Index: java/io/File.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/File.java,v
retrieving revision 1.49.2.5
diff -u -r1.49.2.5 File.java
--- java/io/File.java 2 Aug 2005 20:12:16 -0000 1.49.2.5
+++ java/io/File.java 27 Sep 2005 16:41:36 -0000
@@ -60,7 +60,7 @@
* @author Aaron M. Renn (address@hidden)
* @author Tom Tromey (address@hidden)
*/
-public class File implements Serializable, Comparable
+public class File implements Serializable, Comparable<File>
{
private static final long serialVersionUID = 301077366599181567L;
@@ -1223,32 +1223,6 @@
return path.compareTo (other.path);
else
return path.compareToIgnoreCase (other.path);
- }
-
- /**
- * This method compares the specified <code>Object</code> to this one
- * to test for equality. It does this by comparing the canonical path names
- * of the files. This method is identical to <code>compareTo(File)</code>
- * except that if the <code>Object</code> passed to it is not a
- * <code>File</code>, it throws a <code>ClassCastException</code>
- * <p>
- * The canonical paths of the files are determined by calling the
- * <code>getCanonicalPath</code> method on each object.
- * <p>
- * This method returns a 0 if the specified <code>Object</code> is equal
- * to this one, a negative value if it is less than this one
- * a positive value if it is greater than this one.
- *
- * @return An integer as described above
- *
- * @exception ClassCastException If the passed <code>Object</code> is
- * not a <code>File</code>
- *
- * @since 1.2
- */
- public int compareTo(Object obj)
- {
- return compareTo((File) obj);
}
/**
Index: java/math/BigDecimal.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/math/BigDecimal.java,v
retrieving revision 1.17.2.3
diff -u -r1.17.2.3 BigDecimal.java
--- java/math/BigDecimal.java 2 Aug 2005 20:12:23 -0000 1.17.2.3
+++ java/math/BigDecimal.java 27 Sep 2005 16:41:38 -0000
@@ -37,7 +37,7 @@
package java.math;
-public class BigDecimal extends Number implements Comparable
+public class BigDecimal extends Number implements Comparable<BigDecimal>
{
private BigInteger intVal;
private int scale;
@@ -369,11 +369,6 @@
// and compare them
return thisParts[1].compareTo (valParts[1]);
- }
-
- public int compareTo (Object val)
- {
- return(compareTo((BigDecimal)val));
}
public boolean equals (Object o)
Index: java/math/BigInteger.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/math/BigInteger.java,v
retrieving revision 1.22.2.4
diff -u -r1.22.2.4 BigInteger.java
--- java/math/BigInteger.java 2 Aug 2005 20:12:23 -0000 1.22.2.4
+++ java/math/BigInteger.java 27 Sep 2005 16:41:38 -0000
@@ -57,7 +57,7 @@
* @date December 20, 1999.
* @status believed complete and correct.
*/
-public class BigInteger extends Number implements Comparable
+public class BigInteger extends Number implements Comparable<BigInteger>
{
/** All integers are stored in 2's-complement form.
* If words == null, the ival is the value of this BigInteger.
@@ -368,14 +368,7 @@
return MPN.cmp(x.words, y.words, x_len);
}
- // JDK1.2
- public int compareTo(Object obj)
- {
- if (obj instanceof BigInteger)
- return compareTo(this, (BigInteger) obj);
- throw new ClassCastException();
- }
-
+ /** @since 1.2 */
public int compareTo(BigInteger val)
{
return compareTo(this, val);
Index: java/net/URI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/URI.java,v
retrieving revision 1.6.2.9
diff -u -r1.6.2.9 URI.java
--- java/net/URI.java 2 Aug 2005 20:12:23 -0000 1.6.2.9
+++ java/net/URI.java 27 Sep 2005 16:41:38 -0000
@@ -156,7 +156,7 @@
* @since 1.4
*/
public final class URI
- implements Comparable, Serializable
+ implements Comparable<URI>, Serializable
{
/**
* For serialization compatability.
@@ -1224,7 +1224,7 @@
}
/**
- * Compare the URI with another object that must also be a URI.
+ * Compare the URI with another URI.
* Undefined components are taken to be less than any other component.
* The following criteria are observed:
* </p>
@@ -1260,16 +1260,14 @@
* </ul>
* </ul>
*
- * @param obj This object to compare this URI with
+ * @param uri The other URI to compare this URI with
* @return a negative integer, zero or a positive integer depending
* on whether this URI is less than, equal to or greater
* than that supplied, respectively.
- * @throws ClassCastException if the given object is not a URI
*/
- public int compareTo(Object obj)
+ public int compareTo(URI uri)
throws ClassCastException
{
- URI uri = (URI) obj;
if (scheme == null && uri.getScheme() != null)
return -1;
if (scheme != null)
Index: java/sql/Timestamp.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/sql/Timestamp.java,v
retrieving revision 1.14.2.2
diff -u -r1.14.2.2 Timestamp.java
--- java/sql/Timestamp.java 2 Aug 2005 20:12:26 -0000 1.14.2.2
+++ java/sql/Timestamp.java 27 Sep 2005 16:41:38 -0000
@@ -1,5 +1,5 @@
/* Time.java -- Wrapper around java.util.Date
- Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -308,7 +308,7 @@
* @exception ClassCastException if obj is not of type Timestamp.
* @since 1.2
*/
- public int compareTo(Object obj)
+ public int compareTo(java.util.Date obj)
{
return compareTo((Timestamp) obj);
}
Index: java/text/CollationKey.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/CollationKey.java,v
retrieving revision 1.12.2.2
diff -u -r1.12.2.2 CollationKey.java
--- java/text/CollationKey.java 2 Aug 2005 20:12:26 -0000 1.12.2.2
+++ java/text/CollationKey.java 27 Sep 2005 16:41:38 -0000
@@ -65,7 +65,7 @@
* @author Tom Tromey (address@hidden)
* @date March 25, 1999
*/
-public final class CollationKey implements Comparable
+public final class CollationKey implements Comparable<CollationKey>
{
/**
* This is the <code>Collator</code> this object was created from.
@@ -109,21 +109,6 @@
}
return key.length - ck.key.length;
- }
-
- /**
- * This method compares the specified object to this one. The specified
- * object must be an instance of <code>CollationKey</code> or an exception
- * will be thrown. An integer is returned which indicates whether the
- * specified object is less than, greater than, or equal to this object.
- *
- * @param obj The <code>Object</code> to compare against this one.
- *
- * @return A negative integer if this object is less than the specified
object, 0 if it is equal or a positive integer if it is greater than the
specified object.
- */
- public int compareTo (Object obj)
- {
- return compareTo ((CollationKey) obj);
}
/**
Index: java/util/Date.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Date.java,v
retrieving revision 1.17.2.3
diff -u -r1.17.2.3 Date.java
--- java/util/Date.java 2 Aug 2005 20:12:29 -0000 1.17.2.3
+++ java/util/Date.java 27 Sep 2005 16:41:38 -0000
@@ -108,7 +108,7 @@
* @author Andrew John Hughes (address@hidden)
*/
public class Date
- implements Cloneable, Comparable, Serializable
+ implements Cloneable, Comparable<Date>, Serializable
{
/**
* This is the serialization UID for this class
@@ -351,24 +351,6 @@
public int compareTo(Date when)
{
return (time < when.time) ? -1 : (time == when.time) ? 0 : 1;
- }
-
- /**
- * Compares this Date to another object. This behaves like
- * <code>compareTo(Date)</code>, but it takes a generic object
- * and throws a <code>ClassCastException</code> if obj is
- * not a <code>Date</code>.
- *
- * @param obj the other date.
- * @return 0, if the date represented
- * by obj is exactly the same as the time represented by this
- * object, a negative if this Date is before the other Date, and
- * a positive value otherwise.
- * @exception ClassCastException if obj is not of type Date.
- */
- public int compareTo(Object obj)
- {
- return compareTo((Date) obj);
}
/**
Index: javax/naming/Name.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/naming/Name.java,v
retrieving revision 1.5.2.2
diff -u -r1.5.2.2 Name.java
--- javax/naming/Name.java 20 Sep 2005 18:46:30 -0000 1.5.2.2
+++ javax/naming/Name.java 27 Sep 2005 16:41:39 -0000
@@ -60,7 +60,7 @@
* @author Anthony Green (address@hidden)
* @author Mark Wielaard (address@hidden)
*/
-public interface Name extends Cloneable, Serializable, Comparable
+public interface Name extends Cloneable, Serializable, Comparable<Object>
{
long serialVersionUID = -3617482732056931635L;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] [generics] Patch: FYI: Comparable fixes,
Tom Tromey <=