This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Patch: java.io - more merges
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Mon, 24 Mar 2003 16:44:44 +0100
- Subject: FYI: Patch: java.io - more merges
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
I commited the attached patch to trunk to merge some more java.io
stuff with classpath.
Michael
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+fyfsWSOgCCdjSDsRAkT9AKCUQ9KvM+hpOO6cpkpNV06l26HglwCfU8Yc
1//SoWenf9kMmRlLCk/pGmo=
=4ebk
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.1814
diff -u -r1.1814 ChangeLog
--- ChangeLog 24 Mar 2003 14:05:01 -0000 1.1814
+++ ChangeLog 24 Mar 2003 15:38:15 -0000
@@ -1,5 +1,32 @@
2003-03-24 Michael Koch <konqueror at gmx dot de>
+ * java/io/DataOutputStream.java
+ (write): Merged from classpath.
+ * java/io/File.java:
+ Merged copyrigth with classpath.
+ * java/io/FileInputStream.java
+ (getChannel): Made it synchronized instead of using a synchronized
+ block.
+ * java/io/FileOutputStream.java: Reformatted.
+ * java/io/InputStreamReader.java
+ (InputStreamReader): Renamed enc to encoding_name.
+ (close): Merged documentation from classpath.
+ (getEncoding): Merged documentation from classpath.
+ (ready): Merged documentation from classpath.
+ (read): Merged documentation from classpath.
+ * java/io/LineNumberReader.java
+ (lineNumber): Made it private.
+ (LineNumberReader): Use Constant instead of a direct value.
+ * java/io/OutputStreamWriter.java
+ (OutputStreamWriter): Renamed enc to encoding_scheme, merged
+ documentation from classpath.
+ (close): Merged documentation from classpath.
+ (flush): Merged documentation from classpath.
+ (write): Merged documentation from classpath.
+ * java/io/PrintStream.java: Reformatted.
+
+2003-03-24 Michael Koch <konqueror at gmx dot de>
+
* javax/swing/text/ComponentView.java
(getComponent): Must be final.
* javax/swing/tree/DefaultTreeCellRenderer.java:
Index: java/io/DataOutputStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/DataOutputStream.java,v
retrieving revision 1.7
diff -u -r1.7 DataOutputStream.java
--- java/io/DataOutputStream.java 24 Mar 2003 08:27:28 -0000 1.7
+++ java/io/DataOutputStream.java 24 Mar 2003 15:38:15 -0000
@@ -122,10 +122,10 @@
*
* @exception IOException If an error occurs.
*/
- public synchronized void write (byte[] b, int off, int len)
- throws IOException, NullPointerException, IndexOutOfBoundsException
+ public synchronized void write (byte[] buf, int offset, int len)
+ throws IOException
{
- out.write(b, off, len);
+ out.write(buf, offset, len);
written += len;
}
Index: java/io/File.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/File.java,v
retrieving revision 1.28
diff -u -r1.28 File.java
--- java/io/File.java 24 Mar 2003 08:27:28 -0000 1.28
+++ java/io/File.java 24 Mar 2003 15:38:15 -0000
@@ -1,5 +1,5 @@
/* File.java -- Class representing a file on disk
- Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
Index: java/io/FileInputStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/FileInputStream.java,v
retrieving revision 1.13
diff -u -r1.13 FileInputStream.java
--- java/io/FileInputStream.java 24 Mar 2003 08:27:28 -0000 1.13
+++ java/io/FileInputStream.java 24 Mar 2003 15:38:15 -0000
@@ -280,15 +280,12 @@
* A file channel must be created by first creating an instance of
* Input/Output/RandomAccessFile and invoking the getChannel() method on it.
*/
- public FileChannel getChannel ()
+ public synchronized FileChannel getChannel ()
{
- synchronized (this)
- {
- if (ch == null)
- ch = new FileChannelImpl (fd, false, this);
+ if (ch == null)
+ ch = new FileChannelImpl (fd, false, this);
- return ch;
- }
+ return ch;
}
} // class FileInputStream
Index: java/io/FileOutputStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/FileOutputStream.java,v
retrieving revision 1.9
diff -u -r1.9 FileOutputStream.java
--- java/io/FileOutputStream.java 23 Mar 2003 19:11:19 -0000 1.9
+++ java/io/FileOutputStream.java 24 Mar 2003 15:38:16 -0000
@@ -41,18 +41,21 @@
import java.nio.channels.FileChannel;
import gnu.java.nio.FileChannelImpl;
-/**
- * @author Tom Tromey <tromey at cygnus dot com>
- * @date September 24, 1998
- */
-
/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
* "The Java Language Specification", ISBN 0-201-63451-1
* Status: Complete to version 1.1.
*/
+/**
+ * @author Tom Tromey <tromey at cygnus dot com>
+ * @date September 24, 1998
+ */
public class FileOutputStream extends OutputStream
{
+ // Instance variables.
+ private FileDescriptor fd;
+ private FileChannel ch;
+
public FileOutputStream (String path, boolean append)
throws SecurityException, FileNotFoundException
{
@@ -159,7 +162,4 @@
}
}
- // Instance variables.
- private FileDescriptor fd;
- private FileChannel ch;
}
Index: java/io/InputStreamReader.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/InputStreamReader.java,v
retrieving revision 1.12
diff -u -r1.12 InputStreamReader.java
--- java/io/InputStreamReader.java 20 Mar 2003 07:47:01 -0000 1.12
+++ java/io/InputStreamReader.java 24 Mar 2003 15:38:16 -0000
@@ -66,10 +66,10 @@
this(in, BytesToUnicode.getDefaultDecoder());
}
- public InputStreamReader(InputStream in, String enc)
+ public InputStreamReader(InputStream in, String encoding_name)
throws UnsupportedEncodingException
{
- this(in, BytesToUnicode.getDecoder(enc));
+ this(in, BytesToUnicode.getDecoder(encoding_name));
}
private InputStreamReader(InputStream in, BytesToUnicode decoder)
@@ -88,6 +88,12 @@
converter.setInput(this.in.buf, 0, 0);
}
+ /**
+ * This method closes this stream, as well as the underlying
+ * <code>InputStream</code>.
+ *
+ * @exception IOException If an error occurs
+ */
public void close() throws IOException
{
synchronized (lock)
@@ -100,11 +106,29 @@
}
}
+ /**
+ * This method returns the name of the encoding that is currently in use
+ * by this object. If the stream has been closed, this method is allowed
+ * to return <code>null</code>.
+ *
+ * @param The current encoding name
+ */
public String getEncoding()
{
return in != null ? converter.getName() : null;
}
+ /**
+ * This method checks to see if the stream is read to be read. It
+ * will return <code>true</code> if is, or <code>false</code> if it is not.
+ * If the stream is not ready to be read, it could (although is not required
+ * to) block on the next read attempt.
+ *
+ * @return <code>true</code> if the stream is ready to be read,
+ * <code>false</code> otherwise
+ *
+ * @exception IOException If an error occurs
+ */
public boolean ready() throws IOException
{
synchronized (lock)
@@ -149,6 +173,13 @@
}
}
+ /**
+ * This method reads a single character of data from the stream.
+ *
+ * @return The char read, as an int, or -1 if end of stream.
+ *
+ * @exception IOException If an error occurs
+ */
public int read() throws IOException
{
synchronized (lock)
@@ -198,4 +229,6 @@
}
}
}
-}
+
+} // class InputStreamReader
+
Index: java/io/LineNumberReader.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/LineNumberReader.java,v
retrieving revision 1.7
diff -u -r1.7 LineNumberReader.java
--- java/io/LineNumberReader.java 24 Mar 2003 08:27:28 -0000 1.7
+++ java/io/LineNumberReader.java 24 Mar 2003 15:38:16 -0000
@@ -70,7 +70,7 @@
public class LineNumberReader extends BufferedReader
{
/** The current line number. */
- int lineNumber;
+ private int lineNumber;
/**
* Create a new <code>LineNumberReader</code> that reads from the
@@ -81,7 +81,7 @@
*/
public LineNumberReader(Reader in)
{
- super(in, 8192);
+ super(in, DEFAULT_BUFFER_SIZE);
}
/**
Index: java/io/OutputStreamWriter.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/OutputStreamWriter.java,v
retrieving revision 1.13
diff -u -r1.13 OutputStreamWriter.java
--- java/io/OutputStreamWriter.java 24 Mar 2003 08:27:28 -0000 1.13
+++ java/io/OutputStreamWriter.java 24 Mar 2003 15:38:16 -0000
@@ -57,11 +57,6 @@
private char[] work;
private int wcount;
- public String getEncoding()
- {
- return out != null ? converter.getName() : null;
- }
-
private OutputStreamWriter(OutputStream out, UnicodeToBytes encoder)
{
this.out = out instanceof BufferedOutputStream
@@ -72,17 +67,29 @@
this.converter = encoder;
}
- public OutputStreamWriter(OutputStream out, String enc)
+ public OutputStreamWriter(OutputStream out, String encoding_scheme)
throws UnsupportedEncodingException
{
- this(out, UnicodeToBytes.getEncoder(enc));
+ this(out, UnicodeToBytes.getEncoder(encoding_scheme));
}
+ /**
+ * This method initializes a new instance of <code>OutputStreamWriter</code>
+ * to write to the specified stream using the default encoding.
+ *
+ * @param out The <code>OutputStream</code> to write to
+ */
public OutputStreamWriter(OutputStream out)
{
this(out, UnicodeToBytes.getDefaultEncoder());
}
+ /**
+ * This method closes this stream, and the underlying
+ * <code>OutputStream</code>
+ *
+ * @exception IOException If an error occurs
+ */
public void close() throws IOException
{
synchronized (lock)
@@ -97,6 +104,23 @@
}
}
+ /**
+ * This method returns the name of the character encoding scheme currently
+ * in use by this stream. If the stream has been closed, then this method
+ * may return <code>null</code>.
+ *
+ * @return The encoding scheme name
+ */
+ public String getEncoding()
+ {
+ return out != null ? converter.getName() : null;
+ }
+
+ /**
+ * This method flushes any buffered bytes to the underlying output sink.
+ *
+ * @exception IOException If an error occurs
+ */
public void flush() throws IOException
{
synchronized (lock)
@@ -186,6 +210,13 @@
}
}
+ /**
+ * This method writes a single character to the output stream.
+ *
+ * @param c The char to write, passed as an int.
+ *
+ * @exception IOException If an error occurs
+ */
public void write(int ch) throws IOException
{
synchronized (lock)
@@ -203,4 +234,6 @@
work[wcount++] = (char) ch;
}
}
-}
+
+} // class OutputStreamWriter
+
Index: java/io/PrintStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/PrintStream.java,v
retrieving revision 1.12
diff -u -r1.12 PrintStream.java
--- java/io/PrintStream.java 23 Mar 2003 19:11:19 -0000 1.12
+++ java/io/PrintStream.java 24 Mar 2003 15:38:16 -0000
@@ -55,12 +55,30 @@
* This leads to some minor duplication, because neither inherits
* from the other, and we want to maximize performance. */
+ public PrintStream (OutputStream out)
+ {
+ this(out, false);
+ }
+
+ public PrintStream (OutputStream out, boolean auto_flush)
+ {
+ super(out);
+ converter = UnicodeToBytes.getDefaultEncoder();
+ error = false;
+ this.auto_flush = auto_flush;
+ }
+
public boolean checkError ()
{
flush();
return error;
}
+ protected void setError ()
+ {
+ error = true;
+ }
+
public void close ()
{
try
@@ -256,24 +274,6 @@
public void println (char[] charArray)
{
print(charArray, 0, charArray.length, true);
- }
-
- public PrintStream (OutputStream out)
- {
- this(out, false);
- }
-
- public PrintStream (OutputStream out, boolean af)
- {
- super(out);
- converter = UnicodeToBytes.getDefaultEncoder();
- error = false;
- auto_flush = af;
- }
-
- protected void setError ()
- {
- error = true;
}
public void write (int oneByte)