[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] [generics] Patch: FYI: java.nio fixes
From: |
Tom Tromey |
Subject: |
[cp-patches] [generics] Patch: FYI: java.nio fixes |
Date: |
20 Apr 2005 14:27:15 -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 some java.nio buglets found by japi.
Tom
2005-04-19 Tom Tromey <address@hidden>
* java/nio/charset/Charset.java (compareTo): Changed argument
type.
* java/nio/ShortBuffer.java (compareTo): Changed argument type.
* java/nio/LongBuffer.java (compareTo): Changed argument type.
* java/nio/IntBuffer.java (compareTo): Changed argument type.
* java/nio/FloatBuffer.java (compareTo): Changed argument type.
* java/nio/DoubleBuffer.java (compareTo): Changed argument type.
* java/nio/ByteBuffer.java (compareTo): Changed argument type.
* java/nio/CharBuffer.java (CharBuffer): Implements Readable,
Appendable.
(append): New methods.
(compareTo): Changed argument type.
(read): New method.
Index: java/nio/ByteBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/ByteBuffer.java,v
retrieving revision 1.21.2.3
diff -u -r1.21.2.3 ByteBuffer.java
--- java/nio/ByteBuffer.java 15 Jan 2005 17:01:56 -0000 1.21.2.3
+++ java/nio/ByteBuffer.java 20 Apr 2005 20:15:30 -0000
@@ -1,5 +1,5 @@
/* ByteBuffer.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,7 +42,7 @@
* @since 1.4
*/
public abstract class ByteBuffer extends Buffer
- implements Comparable
+ implements Comparable<ByteBuffer>
{
ByteOrder endian = ByteOrder.BIG_ENDIAN;
@@ -290,7 +290,7 @@
{
if (obj instanceof ByteBuffer)
{
- return compareTo (obj) == 0;
+ return compareTo ((ByteBuffer) obj) == 0;
}
return false;
@@ -302,10 +302,8 @@
* @exception ClassCastException If obj is not an object derived from
* <code>ByteBuffer</code>.
*/
- public int compareTo (Object obj)
+ public int compareTo (ByteBuffer other)
{
- ByteBuffer other = (ByteBuffer) obj;
-
int num = Math.min(remaining(), other.remaining());
int pos_this = position();
int pos_other = other.position();
Index: java/nio/CharBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/CharBuffer.java,v
retrieving revision 1.21.2.3
diff -u -r1.21.2.3 CharBuffer.java
--- java/nio/CharBuffer.java 15 Jan 2005 17:01:57 -0000 1.21.2.3
+++ java/nio/CharBuffer.java 20 Apr 2005 20:15:30 -0000
@@ -1,5 +1,5 @@
/* CharBuffer.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,11 +38,13 @@
package java.nio;
+import java.io.IOException;
+
/**
* @since 1.4
*/
public abstract class CharBuffer extends Buffer
- implements Comparable, CharSequence
+ implements Comparable<CharBuffer>, CharSequence, Readable, Appendable
{
int array_offset;
char[] backing_buffer;
@@ -165,6 +167,18 @@
return this;
}
+ /** @since 1.5 */
+ public int read(CharBuffer buffer) throws IOException
+ {
+ // We want to call put(), so we don't manipulate the CharBuffer
+ // directly.
+ int rem = Math.min(buffer.remaining(), remaining());
+ char[] buf = new char[rem];
+ get(buf);
+ buffer.put(buf);
+ return rem;
+ }
+
/**
* This method transfers <code>char</code>s from this buffer into the given
* destination array.
@@ -325,7 +339,7 @@
{
if (obj instanceof CharBuffer)
{
- return compareTo (obj) == 0;
+ return compareTo ((CharBuffer) obj) == 0;
}
return false;
@@ -337,10 +351,8 @@
* @exception ClassCastException If obj is not an object derived from
* <code>CharBuffer</code>.
*/
- public int compareTo (Object obj)
+ public int compareTo (CharBuffer other)
{
- CharBuffer other = (CharBuffer) obj;
-
int num = Math.min(remaining(), other.remaining());
int pos_this = position();
int pos_other = other.position();
@@ -505,4 +517,25 @@
return get (position () + index);
}
+
+ /** @since 1.5 */
+ public CharBuffer append(char c)
+ {
+ put(c);
+ return this;
+ }
+
+ /** @since 1.5 */
+ public CharBuffer append(CharSequence cs)
+ {
+ put(cs == null ? "null" : cs.toString());
+ return this;
+ }
+
+ /** @since 1.5 */
+ public CharBuffer append(CharSequence cs, int start, int end)
+ {
+ put(cs == null ? "null" : cs.subSequence(start, end).toString());
+ return this;
+ }
}
Index: java/nio/DoubleBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/DoubleBuffer.java,v
retrieving revision 1.16.2.3
diff -u -r1.16.2.3 DoubleBuffer.java
--- java/nio/DoubleBuffer.java 15 Jan 2005 17:01:57 -0000 1.16.2.3
+++ java/nio/DoubleBuffer.java 20 Apr 2005 20:15:30 -0000
@@ -1,5 +1,5 @@
/* DoubleBuffer.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,7 +42,7 @@
* @since 1.4
*/
public abstract class DoubleBuffer extends Buffer
- implements Comparable
+ implements Comparable<DoubleBuffer>
{
int array_offset;
double[] backing_buffer;
@@ -273,7 +273,7 @@
{
if (obj instanceof DoubleBuffer)
{
- return compareTo (obj) == 0;
+ return compareTo ((DoubleBuffer) obj) == 0;
}
return false;
@@ -285,10 +285,8 @@
* @exception ClassCastException If obj is not an object derived from
* <code>DoubleBuffer</code>.
*/
- public int compareTo (Object obj)
+ public int compareTo (DoubleBuffer other)
{
- DoubleBuffer other = (DoubleBuffer) obj;
-
int num = Math.min(remaining(), other.remaining());
int pos_this = position();
int pos_other = other.position();
Index: java/nio/FloatBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/FloatBuffer.java,v
retrieving revision 1.16.2.3
diff -u -r1.16.2.3 FloatBuffer.java
--- java/nio/FloatBuffer.java 15 Jan 2005 17:01:57 -0000 1.16.2.3
+++ java/nio/FloatBuffer.java 20 Apr 2005 20:15:30 -0000
@@ -1,5 +1,5 @@
/* FloatBuffer.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,7 +42,7 @@
* @since 1.4
*/
public abstract class FloatBuffer extends Buffer
- implements Comparable
+ implements Comparable<FloatBuffer>
{
int array_offset;
float[] backing_buffer;
@@ -273,7 +273,7 @@
{
if (obj instanceof FloatBuffer)
{
- return compareTo (obj) == 0;
+ return compareTo ((FloatBuffer) obj) == 0;
}
return false;
@@ -285,10 +285,8 @@
* @exception ClassCastException If obj is not an object derived from
* <code>FloatBuffer</code>.
*/
- public int compareTo (Object obj)
+ public int compareTo (FloatBuffer other)
{
- FloatBuffer other = (FloatBuffer) obj;
-
int num = Math.min(remaining(), other.remaining());
int pos_this = position();
int pos_other = other.position();
Index: java/nio/IntBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/IntBuffer.java,v
retrieving revision 1.16.2.3
diff -u -r1.16.2.3 IntBuffer.java
--- java/nio/IntBuffer.java 15 Jan 2005 17:01:57 -0000 1.16.2.3
+++ java/nio/IntBuffer.java 20 Apr 2005 20:15:30 -0000
@@ -1,5 +1,5 @@
/* IntBuffer.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,7 +42,7 @@
* @since 1.4
*/
public abstract class IntBuffer extends Buffer
- implements Comparable
+ implements Comparable<IntBuffer>
{
int array_offset;
int[] backing_buffer;
@@ -273,7 +273,7 @@
{
if (obj instanceof IntBuffer)
{
- return compareTo (obj) == 0;
+ return compareTo ((IntBuffer) obj) == 0;
}
return false;
@@ -285,10 +285,8 @@
* @exception ClassCastException If obj is not an object derived from
* <code>IntBuffer</code>.
*/
- public int compareTo (Object obj)
+ public int compareTo (IntBuffer other)
{
- IntBuffer other = (IntBuffer) obj;
-
int num = Math.min(remaining(), other.remaining());
int pos_this = position();
int pos_other = other.position();
Index: java/nio/LongBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/LongBuffer.java,v
retrieving revision 1.16.2.3
diff -u -r1.16.2.3 LongBuffer.java
--- java/nio/LongBuffer.java 15 Jan 2005 17:01:57 -0000 1.16.2.3
+++ java/nio/LongBuffer.java 20 Apr 2005 20:15:30 -0000
@@ -1,5 +1,5 @@
/* LongBuffer.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,7 +42,7 @@
* @since 1.4
*/
public abstract class LongBuffer extends Buffer
- implements Comparable
+ implements Comparable<LongBuffer>
{
int array_offset;
long[] backing_buffer;
@@ -273,7 +273,7 @@
{
if (obj instanceof LongBuffer)
{
- return compareTo (obj) == 0;
+ return compareTo ((LongBuffer) obj) == 0;
}
return false;
@@ -285,10 +285,8 @@
* @exception ClassCastException If obj is not an object derived from
* <code>LongBuffer</code>.
*/
- public int compareTo (Object obj)
+ public int compareTo (LongBuffer other)
{
- LongBuffer other = (LongBuffer) obj;
-
int num = Math.min(remaining(), other.remaining());
int pos_this = position();
int pos_other = other.position();
Index: java/nio/ShortBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/ShortBuffer.java,v
retrieving revision 1.17.2.3
diff -u -r1.17.2.3 ShortBuffer.java
--- java/nio/ShortBuffer.java 15 Jan 2005 17:01:57 -0000 1.17.2.3
+++ java/nio/ShortBuffer.java 20 Apr 2005 20:15:30 -0000
@@ -1,5 +1,5 @@
/* ShortBuffer.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,7 +42,7 @@
* @since 1.4
*/
public abstract class ShortBuffer extends Buffer
- implements Comparable
+ implements Comparable<ShortBuffer>
{
int array_offset;
short[] backing_buffer;
@@ -273,7 +273,7 @@
{
if (obj instanceof ShortBuffer)
{
- return compareTo (obj) == 0;
+ return compareTo ((ShortBuffer) obj) == 0;
}
return false;
@@ -285,10 +285,8 @@
* @exception ClassCastException If obj is not an object derived from
* <code>ShortBuffer</code>.
*/
- public int compareTo (Object obj)
+ public int compareTo (ShortBuffer other)
{
- ShortBuffer other = (ShortBuffer) obj;
-
int num = Math.min(remaining(), other.remaining());
int pos_this = position();
int pos_other = other.position();
Index: java/nio/charset/Charset.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/charset/Charset.java,v
retrieving revision 1.11.2.4
diff -u -r1.11.2.4 Charset.java
--- java/nio/charset/Charset.java 18 Apr 2005 01:37:38 -0000 1.11.2.4
+++ java/nio/charset/Charset.java 20 Apr 2005 20:15:30 -0000
@@ -60,7 +60,7 @@
* @author Jesse Rosenstock
* @since 1.4
*/
-public abstract class Charset implements Comparable
+public abstract class Charset implements Comparable<Charset>
{
private CharsetEncoder cachedEncoder;
private CharsetDecoder cachedDecoder;
@@ -332,9 +332,9 @@
}
}
- public final int compareTo (Object ob)
+ public final int compareTo (Charset other)
{
- return canonicalName.compareToIgnoreCase (((Charset) ob).canonicalName);
+ return canonicalName.compareToIgnoreCase (other.canonicalName);
}
public final int hashCode ()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] [generics] Patch: FYI: java.nio fixes,
Tom Tromey <=