[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] [generics] Patch: FYI: Closeable, Flushable, more Appendabl
From: |
Tom Tromey |
Subject: |
[cp-patches] [generics] Patch: FYI: Closeable, Flushable, more Appendable |
Date: |
26 Aug 2004 14:53:11 -0600 |
I'm checking this in on the generics branch.
This adds the Closeable and Flushable interfaces, updates a few
classes to implement them, and also changes Writer to implement
Appendable.
Tom
Index: ChangeLog
from Tom Tromey <address@hidden>
* java/io/Writer.java (Writer): Implements Closeable, Flushable,
Appendable.
(append): New methods.
* java/io/OutputStream.java (OutputStream): Implements Closeable,
Flushable.
* java/io/Reader.java (Reader): Implements Closeable.
* java/io/InputStream.java (InputStream): Implements Closeable.
* java/nio/channels/Channel.java (Channel): Extends Closeable.
* java/io/Flushable.java: New file.
* java/io/Closeable.java: New file.
Index: java/io/Closeable.java
===================================================================
RCS file: java/io/Closeable.java
diff -N java/io/Closeable.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ java/io/Closeable.java 26 Aug 2004 21:08:18 -0000
@@ -0,0 +1,43 @@
+/* Closeable.java -- Closeable object
+ Copyright (C) 2004 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.io;
+
+public interface Closeable
+{
+ void close() throws IOException;
+}
Index: java/io/Flushable.java
===================================================================
RCS file: java/io/Flushable.java
diff -N java/io/Flushable.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ java/io/Flushable.java 26 Aug 2004 21:08:18 -0000
@@ -0,0 +1,43 @@
+/* Flushable.java -- flush()-able object
+ Copyright (C) 2004 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.io;
+
+public interface Flushable
+{
+ void flush() throws IOException;
+}
Index: java/io/InputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/InputStream.java,v
retrieving revision 1.8
diff -u -r1.8 InputStream.java
--- java/io/InputStream.java 17 Apr 2004 17:29:18 -0000 1.8
+++ java/io/InputStream.java 26 Aug 2004 21:08:18 -0000
@@ -1,5 +1,5 @@
/* InputStream.java -- Base class for input
- Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2001, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -48,7 +48,7 @@
* @author Aaron M. Renn (address@hidden)
* @author Warren Levy <address@hidden>
*/
-public abstract class InputStream
+public abstract class InputStream implements Closeable
{
/**
* Default, no-arg, public constructor
Index: java/io/OutputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/OutputStream.java,v
retrieving revision 1.6
diff -u -r1.6 OutputStream.java
--- java/io/OutputStream.java 22 Jan 2002 22:26:59 -0000 1.6
+++ java/io/OutputStream.java 26 Aug 2004 21:08:18 -0000
@@ -1,5 +1,5 @@
/* OutputStream.java -- Base class for byte output streams
- Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2001, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -48,7 +48,7 @@
* @author Aaron M. Renn (address@hidden)
* @author Tom Tromey <address@hidden>
*/
-public abstract class OutputStream
+public abstract class OutputStream implements Closeable, Flushable
{
/**
* This is the default no-argument constructor for this class. This method
Index: java/io/Reader.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/Reader.java,v
retrieving revision 1.9
diff -u -r1.9 Reader.java
--- java/io/Reader.java 9 Mar 2003 21:54:30 -0000 1.9
+++ java/io/Reader.java 26 Aug 2004 21:08:24 -0000
@@ -1,5 +1,5 @@
/* Reader.java -- base class of classes that read input as a stream of chars
- Copyright (C) 1998, 1999, 2000, 2003 Free Software Foundation
+ Copyright (C) 1998, 1999, 2000, 2003, 2004 Free Software Foundation
This file is part of GNU Classpath.
@@ -53,7 +53,7 @@
* @date April 21, 1998.
* @author Aaron M. Renn (address@hidden)
*/
-public abstract class Reader
+public abstract class Reader implements Closeable
{
/**
* This is the <code>Object</code> used for synchronizing critical code
Index: java/io/Writer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/Writer.java,v
retrieving revision 1.13
diff -u -r1.13 Writer.java
--- java/io/Writer.java 17 May 2004 22:07:10 -0000 1.13
+++ java/io/Writer.java 26 Aug 2004 21:08:24 -0000
@@ -53,7 +53,7 @@
* @author Aaron M. Renn (address@hidden)
* @author Per Bothner <address@hidden>
*/
-public abstract class Writer
+public abstract class Writer implements Appendable, Closeable, Flushable
{
/**
* This is the object used to synchronize criticial code sections for
@@ -188,5 +188,24 @@
write(buf, 0, len);
}
-} // class Writer
+ /** @since 1.5 */
+ public Writer append(char c) throws IOException
+ {
+ write(c);
+ return this;
+ }
+ /** @since 1.5 */
+ public Writer append(CharSequence cs) throws IOException
+ {
+ write(cs == null ? "null" : cs.toString());
+ return this;
+ }
+
+ /** @since 1.5 */
+ public Writer append(CharSequence cs, int start, int end) throws IOException
+ {
+ write(cs == null ? "null" : cs.subSequence(start, end).toString());
+ return this;
+ }
+}
Index: java/nio/channels/Channel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/channels/Channel.java,v
retrieving revision 1.6
diff -u -r1.6 Channel.java
--- java/nio/channels/Channel.java 8 Apr 2004 20:45:13 -0000 1.6
+++ java/nio/channels/Channel.java 26 Aug 2004 21:08:24 -0000
@@ -1,5 +1,5 @@
/* Channel.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,9 +38,9 @@
package java.nio.channels;
import java.io.IOException;
+import java.io.Closeable;
-
-public interface Channel
+public interface Channel extends Closeable
{
/**
* Tells whether this channel is open or not
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] [generics] Patch: FYI: Closeable, Flushable, more Appendable,
Tom Tromey <=