Commit f4f5d1d6 by Michael Koch Committed by Michael Koch

BufferedReader.java, [...]: Merged from classpath.

2003-03-18  Michael Koch  <konqueror@gmx.de>

	* java/io/BufferedReader.java,
	java/io/BufferedWriter.java,
	java/io/ByteArrayOutputStream.java,
	java/io/FileFilter.java,
	java/io/FilePermission.java,
	java/io/FileReader.java,
	java/io/FileWriter.java,
	java/io/FilenameFilter.java,
	java/io/FilterInputStream.java,
	java/io/FilterOutputStream.java,
	java/io/FilterReader.java,
	java/io/FilterWriter.java,
	java/io/ObjectInput.java,
	java/io/ObjectInputValidation.java,
	java/io/ObjectOutput.java,
	java/io/ObjectStreamField.java,
	java/io/PipedInputStream.java,
	java/io/PipedReader.java,
	java/io/PrintWriter.java,
	java/io/PushbackReader.java,
	java/io/Reader.java,
	java/io/SerializablePermission.java,
	java/io/StringReader.java,
	java/io/Writer.java:
	Merged from classpath.

From-SVN: r64525
parent 61f1ed59
2003-03-18 Michael Koch <konqueror@gmx.de>
* java/io/BufferedReader.java,
java/io/BufferedWriter.java,
java/io/ByteArrayOutputStream.java,
java/io/FileFilter.java,
java/io/FilePermission.java,
java/io/FileReader.java,
java/io/FileWriter.java,
java/io/FilenameFilter.java,
java/io/FilterInputStream.java,
java/io/FilterOutputStream.java,
java/io/FilterReader.java,
java/io/FilterWriter.java,
java/io/ObjectInput.java,
java/io/ObjectInputValidation.java,
java/io/ObjectOutput.java,
java/io/ObjectStreamField.java,
java/io/PipedInputStream.java,
java/io/PipedReader.java,
java/io/PrintWriter.java,
java/io/PushbackReader.java,
java/io/Reader.java,
java/io/SerializablePermission.java,
java/io/StringReader.java,
java/io/Writer.java:
Merged from classpath.
2003-03-17 Michael Koch <konqueror@gmx.de>
* java/awt/ScrollPaneAdjustable.java:
......
......@@ -243,7 +243,8 @@ public class BufferedReader extends Reader
* This method returns <code>false</code> then this stream could (but is
* not guaranteed to) block on the next read attempt.
*
* @return <code>true</code> if this stream is ready to be read, <code>false</code> otherwise
* @return <code>true</code> if this stream is ready to be read,
* <code>false</code> otherwise
*
* @exception IOException If an error occurs
*/
......@@ -258,7 +259,8 @@ public class BufferedReader extends Reader
/**
* This method read chars from a stream and stores them into a caller
* supplied buffer. It starts storing the data at index <code>offset</code> into
* supplied buffer. It starts storing the data at index
* <code>offset</code> into
* the buffer and attempts to read <code>len</code> chars. This method can
* return before reading the number of chars requested. The actual number
* of chars read is returned as an int. A -1 is returned to indicate the
......@@ -473,7 +475,8 @@ public class BufferedReader extends Reader
* requested amount.
* <p>
* This method first discards chars in the buffer, then calls the
* <code>skip</code> method on the underlying stream to skip the remaining chars.
* <code>skip</code> method on the underlying stream to skip the
* remaining chars.
*
* @param num_chars The requested number of chars to skip
*
......
......@@ -51,8 +51,6 @@ package java.io;
* efficient mechanism for writing versus doing numerous small unbuffered
* writes.
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Tom Tromey <tromey@cygnus.com>
* @date September 25, 1998
......
......@@ -65,8 +65,6 @@ package java.io;
* application specified character encoding. Thus it can handle
* multibyte character encodings.
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Tom Tromey <tromey@cygnus.com>
* @date September 24, 1998
......
......@@ -46,23 +46,21 @@ package java.io;
* The method in this interface determines if a particular pathname should
* or should not be included in the pathname listing.
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public interface FileFilter
{
/**
/**
* This method determines whether or not a given pathname should be included
* in a pathname listing.
*
* @param pathname The pathname to test
*
* @return <code>true</code> if the path should be included in the list, <code>false</code> otherwise.
* @return <code>true</code> if the path should be included in the list,
* <code>false</code> otherwise.
*/
public abstract boolean
accept(File pathname);
public abstract boolean accept(File pathname);
} // interface FileFilter
/* java.lang.FilePermission
Copyright (C) 1998, 2000 Free Software Foundation, Inc.
Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -45,7 +45,8 @@ public final class FilePermission extends Permission implements Serializable
{
static final long serialVersionUID = 7930732926638008763L;
private static final String CURRENT_DIRECTORY = System.getProperty("user.dir");
private static final String CURRENT_DIRECTORY =
System.getProperty("user.dir");
private boolean usingPerms = false;
private boolean readPerm = false;
private boolean writePerm = false;
......@@ -53,13 +54,15 @@ public final class FilePermission extends Permission implements Serializable
private boolean deletePerm = false;
private String actionsString;
private void cachePerms() {
private void cachePerms()
{
// While race conditions could occur, they don't matter at all.
String action;
int i = actionsString.indexOf(',');
int startI = 0;
while(i != -1) {
while(i != -1)
{
action = actionsString.substring(startI,i);
if(action.equals("read"))
readPerm = true;
......@@ -101,17 +104,21 @@ public final class FilePermission extends Permission implements Serializable
/** Get the actions this FilePermission supports.
** @return the String representing the actions this FilePermission supports.
**/
public String getActions() {
public String getActions()
{
return actionsString;
}
/** Get the hash code for this Object.<P>
** FilePermission's hash code is calculated as the exclusive or of the target
** FilePermission's hash code is calculated as the exclusive or of the
** target
** String's hash code and the action String's hash code.
** @specnote Sun did not specify how to calculate the hash code; I made this up.
** @specnote Sun did not specify how to calculate the hash code;
** I made this up.
** @return the hash code for this Object.
**/
public int hashCode() {
public int hashCode()
{
return getName().hashCode() ^ actionsString.hashCode();
}
......@@ -121,7 +128,8 @@ public final class FilePermission extends Permission implements Serializable
** @param o the Object to compare to.
** @return whether the Objects are semantically equivalent.
**/
public boolean equals(Object o) {
public boolean equals(Object o)
{
if(!(o instanceof FilePermission))
return false;
FilePermission p = (FilePermission)o;
......@@ -136,19 +144,28 @@ public final class FilePermission extends Permission implements Serializable
/* Compare names, taking into account if they refer to a
* directory and one has a separator and the other does not.
*/
if(f1.charAt(f1.length()) == File.separatorChar) {
if(f2.charAt(f2.length()) == File.separatorChar) {
if(f1.charAt(f1.length()) == File.separatorChar)
{
if(f2.charAt(f2.length()) == File.separatorChar)
{
if(!f2.equals(f1))
return false;
} else {
}
else
{
if(!f2.equals(f1.substring(0,f1.length()-1)))
return false;
}
} else {
if(f2.charAt(f2.length()) == File.separatorChar) {
}
else
{
if(f2.charAt(f2.length()) == File.separatorChar)
{
if(!f1.equals(f2.substring(0,f2.length()-1)))
return false;
} else {
}
else
{
if(!f1.equals(f2))
return false;
}
......@@ -160,13 +177,15 @@ public final class FilePermission extends Permission implements Serializable
** Permission A implies permission B if these things are all true:
** <OL>
** <LI>A and B are both FilePermissions.</LI>
** <LI>All possible files in B are included in A (possibly more are in A).</LI>
** <LI>All possible files in B are included in A
** (possibly more are in A).</LI>
** <LI>All actions B supports, A also supports.</LI>
** </OL>
** @param p the Permission to compare against.
** @return whether this Permission implies p
**/
public boolean implies(Permission p) {
public boolean implies(Permission p)
{
FilePermission fp;
if(!(p instanceof FilePermission))
return false;
......@@ -174,32 +193,44 @@ public final class FilePermission extends Permission implements Serializable
String f1 = getName();
String f2 = fp.getName();
if(f1.charAt(0) != File.separatorChar) {
if(f1.charAt(0) != File.separatorChar)
{
f1 = CURRENT_DIRECTORY + f1;
}
if(f2.charAt(0) != File.separatorChar) {
if(f2.charAt(0) != File.separatorChar)
{
f2 = CURRENT_DIRECTORY + f2;
}
String sub1, sub2a, sub2b;
switch(f1.charAt(f1.length() - 1)) {
switch(f1.charAt(f1.length() - 1))
{
case '*':
sub1 = f1.substring(0,f1.length() - 1); // chop off "*"
if(f2.length() <= sub1.length()) {
/* If it's smaller, there is no way it could be part of this directory.
* If it's the same (or length - 1), it could be the same directory but
if(f2.length() <= sub1.length())
{
/* If it's smaller, there is no way it could be part of this
* directory.
* If it's the same (or length - 1), it could be the same
* directory but
* specifies access to the directory rather than the files in it.
*/
return false;
} else if(f2.charAt(sub1.length() - 1) == File.separatorChar) {
}
else if(f2.charAt(sub1.length() - 1) == File.separatorChar)
{
/* Make sure the part before the "/" is the same */
if(!f2.substring(0,sub1.length()).equals(sub1))
return false;
/* Make sure there are no subdirectories specified underneath this one */
/* Make sure there are no subdirectories specified
underneath this one */
String sub2 = f2.substring(sub1.length()+1);
if(f2.substring(sub1.length()+1).indexOf(File.separatorChar) != -1)
if(f2.substring(sub1.length()+1).indexOf(File.separatorChar)
!= -1)
return false;
} else {
}
else
{
/* Obviously not equal: f2 is either not a directory or is not
* the same directory (its name continues further than we want)
*/
......@@ -208,12 +239,19 @@ public final class FilePermission extends Permission implements Serializable
break;
case '-':
sub1 = f1.substring(0,f1.length() - 2); // chop off "/-"
if(f2.length() < sub1.length()) {
/* If it's smaller, there is no way it could be part of this directory. */
if(f2.length() < sub1.length())
{
/* If it's smaller, there is no way it could be part of
* this directory. */
return false;
} else if(f2.length() > sub1.length() && f2.charAt(sub1.length()) != File.separatorChar) {
}
else if(f2.length() > sub1.length() && f2.charAt(sub1.length())
!= File.separatorChar)
{
return false;
} else if(!f2.substring(0,sub1.length()).equals(sub1))
}
else if(!f2.substring(0,sub1.length()).equals(sub1))
return false;
break;
/* Looks redundant with default case and won't compile anyway - arenn
......@@ -228,10 +266,13 @@ public final class FilePermission extends Permission implements Serializable
break;
*/
default:
if(f2.charAt(f2.length()) == File.separatorChar) {
if(f2.charAt(f2.length()) == File.separatorChar)
{
if(!f1.equals(f2.substring(0,f2.length()-1)))
return false;
} else {
}
else
{
if(!f1.equals(f2))
return false;
}
......@@ -254,4 +295,5 @@ public final class FilePermission extends Permission implements Serializable
return true;
}
}
} // class FilePermission
/* FileReader.java -- Convenience class for reading characters from a file
Copyright (C) 1998, 2000 Free Software Foundation, Inc.
Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -46,8 +46,6 @@ package java.io;
* to read from files using the default character encoding. Use
* <code>InputStreamReader</code> directly to use a non-default encoding.
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public class FileReader extends InputStreamReader
......@@ -90,4 +88,5 @@ public class FileReader extends InputStreamReader
{
super(new FileInputStream(name));
}
}
} // class FileReader
......@@ -54,13 +54,13 @@ package java.io;
public class FileWriter extends OutputStreamWriter
{
/*************************************************************************/
/*************************************************************************/
/*
/*
* Constructors
*/
/**
/**
* This method initializes a new <code>FileWriter</code> object to write
* to the specified <code>File</code> object.
*
......@@ -70,15 +70,14 @@ public class FileWriter extends OutputStreamWriter
* <code>SecurityManager</code>.
* @param IOException If any other error occurs
*/
public
FileWriter(File file) throws SecurityException, IOException
{
public FileWriter(File file) throws SecurityException, IOException
{
super(new FileOutputStream(file));
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method initializes a new <code>FileWriter</code> object to write
* to the specified <code>FileDescriptor</code> object.
*
......@@ -87,16 +86,16 @@ FileWriter(File file) throws SecurityException, IOException
* @param SecurityException If writing to this file is forbidden by the
* <code>SecurityManager</code>.
*/
public
FileWriter(FileDescriptor fd) throws SecurityException
{
public FileWriter(FileDescriptor fd) throws SecurityException
{
super(new FileOutputStream(fd));
}
}
/*************************************************************************/
/*************************************************************************/
/**
* This method intializes a new <code>FileWriter</code> object to write to the
/**
* This method intializes a new <code>FileWriter</code> object to
* write to the
* specified named file.
*
* @param name The name of the file to write to
......@@ -105,16 +104,16 @@ FileWriter(FileDescriptor fd) throws SecurityException
* <code>SecurityManager</code>.
* @param IOException If any other error occurs
*/
public
FileWriter(String name) throws IOException
{
public FileWriter(String name) throws IOException
{
super(new FileOutputStream(name));
}
}
/*************************************************************************/
/*************************************************************************/
/**
* This method intializes a new <code>FileWriter</code> object to write to the
/**
* This method intializes a new <code>FileWriter</code> object to
* write to the
* specified named file. This form of the constructor allows the caller
* to determin whether data should be written starting at the beginning or
* the end of the file.
......@@ -127,11 +126,10 @@ FileWriter(String name) throws IOException
* <code>SecurityManager</code>.
* @param IOException If any other error occurs
*/
public
FileWriter(String name, boolean append) throws IOException
{
public FileWriter(String name, boolean append) throws IOException
{
super(new FileOutputStream(name, append));
}
}
} // class FileWriter
......@@ -57,7 +57,7 @@ package java.io;
public interface FilenameFilter
{
/**
/**
* This method determines whether or not a given file should be included
* in a directory listing.
*
......@@ -67,7 +67,7 @@ public interface FilenameFilter
* @return <code>true</code> if the file should be included in the list,
* <code>false</code> otherwise.
*/
boolean
accept(File dir, String name);
boolean accept(File dir, String name);
} // interface FilenameFilter
......@@ -70,131 +70,125 @@ package java.io;
public class FilterInputStream extends InputStream
{
/*************************************************************************/
/*************************************************************************/
/*
/*
* Instance Variables
*/
/**
/**
* This is the subordinate <code>InputStream</code> to which method calls
* are redirected
*/
protected InputStream in;
protected InputStream in;
/*************************************************************************/
/*************************************************************************/
/*
/*
* Constructors
*/
/**
/**
* Create a <code>FilterInputStream</code> with the specified subordinate
* <code>InputStream</code>.
*
* @param in The subordinate <code>InputStream</code>
*/
protected
FilterInputStream(InputStream in)
{
protected FilterInputStream(InputStream in)
{
this.in = in;
}
}
/*************************************************************************/
/*************************************************************************/
/*
/*
* Instance Methods
*/
/**
/**
* Calls the <code>in.mark(int)</code> method.
*
* @param readlimit The parameter passed to <code>in.mark(int)</code>
*/
public void
mark(int readlimit)
{
public void mark(int readlimit)
{
in.mark(readlimit);
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* Calls the <code>in.markSupported()</code> method.
*
* @return <code>true</code> if mark/reset is supported, <code>false</code>
* otherwise
*/
public boolean
markSupported()
{
public boolean markSupported()
{
return(in.markSupported());
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* Calls the <code>in.reset()</code> method.
*
* @exception IOException If an error occurs
*/
public void
reset() throws IOException
{
public void reset() throws IOException
{
in.reset();
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* Calls the <code>in.available()</code> method.
*
* @return The value returned from <code>in.available()</code>
*
* @exception IOException If an error occurs
*/
public int
available() throws IOException
{
public int available() throws IOException
{
return(in.available());
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* Calls the <code>in.skip(long)</code> method
*
* @param The requested number of bytes to skip.
* @param numBytes The requested number of bytes to skip.
*
* @return The value returned from <code>in.skip(long)</code>
*
* @exception IOException If an error occurs
*/
public long
skip(long num_bytes) throws IOException
{
public long skip(long num_bytes) throws IOException
{
return(in.skip(num_bytes));
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* Calls the <code>in.read()</code> method
*
* @return The value returned from <code>in.read()</code>
*
* @exception IOException If an error occurs
*/
public int
read() throws IOException
{
public int read() throws IOException
{
return(in.read());
}
}
/*************************************************************************/
/*************************************************************************/
/**
* Calls the <code>read(byte[], int, int)</code> overloaded method. Note that
/**
* Calls the <code>read(byte[], int, int)</code> overloaded method.
* Note that
* this method does not redirect its call directly to a corresponding
* method in <code>in</code>. This allows subclasses to override only the
* three argument version of <code>read</code>.
......@@ -205,15 +199,14 @@ read() throws IOException
*
* @exception IOException If an error occurs
*/
public int
read(byte[] buf) throws IOException
{
public int read(byte[] buf) throws IOException
{
return(read(buf, 0, buf.length));
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* Calls the <code>in.read(byte[], int, int)</code> method.
*
* @param buf The buffer to read bytes into
......@@ -224,25 +217,24 @@ read(byte[] buf) throws IOException
*
* @exception IOException If an error occurs
*/
public int
read(byte[] buf, int offset, int len) throws IOException
{
public int read(byte[] buf, int offset, int len) throws IOException
{
return(in.read(buf, offset, len));
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method closes the input stream by closing the input stream that
* this object is filtering. Future attempts to access this stream may
* throw an exception.
*
* @exception IOException If an error occurs
*/
public void
close() throws IOException
{
public void close() throws IOException
{
in.close();
}
}
} // class FilterInputStream
/* FilterOutputStream.java -- Parent class for output streams that filter
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -57,72 +57,69 @@ package java.io;
public class FilterOutputStream extends OutputStream
{
/*************************************************************************/
/*************************************************************************/
/*
/*
* Instance Variables
*/
/**
/**
* This is the subordinate <code>OutputStream</code> that this class
* redirects its method calls to.
*/
protected OutputStream out;
protected OutputStream out;
/*************************************************************************/
/*************************************************************************/
/*
/*
* Constructors
*/
/**
/**
* This method initializes an instance of <code>FilterOutputStream</code>
* to write to the specified subordinate <code>OutputStream</code>.
*
* @param out The <code>OutputStream</code> to write to
*/
public
FilterOutputStream(OutputStream out)
{
public FilterOutputStream(OutputStream out)
{
this.out = out;
}
}
/*************************************************************************/
/*************************************************************************/
/*
/*
* Instance Methods
*/
/**
/**
* This method closes the underlying <code>OutputStream</code>. Any
* further attempts to write to this stream may throw an exception.
*
* @exception IOException If an error occurs
*/
public void
close() throws IOException
{
public void close() throws IOException
{
flush();
out.close();
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method attempt to flush all buffered output to be written to the
* underlying output sink.
*
* @exception IOException If an error occurs
*/
public void
flush() throws IOException
{
public void flush() throws IOException
{
out.flush();
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method writes a single byte of output to the underlying
* <code>OutputStream</code>.
*
......@@ -130,15 +127,14 @@ flush() throws IOException
*
* @exception IOException If an error occurs
*/
public void
write(int b) throws IOException
{
public void write(int b) throws IOException
{
out.write(b);
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method writes all the bytes in the specified array to the underlying
* <code>OutputStream</code>. It does this by calling the three parameter
* version of this method - <code>write(byte[], int, int)</code> in this
......@@ -149,16 +145,15 @@ write(int b) throws IOException
*
* @exception IOException If an error occurs
*/
public void
write(byte[] buf) throws IOException
{
public void write(byte[] buf) throws IOException
{
// Don't do checking here, per Java Lang Spec.
write(buf, 0, buf.length);
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method calls the <code>write(int)</code> method <code>len</code>
* times for all bytes from the array <code>buf</code> starting at index
* <code>offset</code>. Subclasses should overwrite this method to get a
......@@ -170,13 +165,13 @@ write(byte[] buf) throws IOException
*
* @exception IOException If an error occurs
*/
public void
write(byte[] buf, int offset, int len) throws IOException
{
public void write(byte[] buf, int offset, int len) throws IOException
{
// Don't do checking here, per Java Lang Spec.
for (int i=0; i < len; i++)
write(buf[offset + i]);
}
}
} // class FilterOutputStream
/* FilterReader.java -- Base class for char stream classes that filter input
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -63,26 +63,23 @@ package java.io;
*/
public abstract class FilterReader extends Reader
{
/*************************************************************************/
/*
/*
* Instance Variables
*/
/**
/**
* This is the subordinate <code>Reader</code> to which method calls
* are redirected
*/
protected Reader in;
protected Reader in;
/*************************************************************************/
/*************************************************************************/
/*
/*
* Constructors
*/
/**
/**
* Create a <code>FilterReader</code> with the specified subordinate
* <code>Reader</code>.
* The <code>lock</code> of the new <code>FilterReader</code> will be set
......@@ -90,108 +87,102 @@ protected Reader in;
*
* @param in The subordinate <code>Reader</code>
*/
protected
FilterReader(Reader in)
{
protected FilterReader(Reader in)
{
super(in.lock);
this.in = in;
}
}
/*************************************************************************/
/*************************************************************************/
/*
/*
* Instance Methods
*/
/**
/**
* Calls the <code>in.mark(int)</code> method.
*
* @param readlimit The parameter passed to <code>in.mark(int)</code>
*
* @exception IOException If an error occurs
*/
public void
mark(int readlimit) throws IOException
{
public void mark(int readlimit) throws IOException
{
in.mark(readlimit);
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* Calls the <code>in.markSupported()</code> method.
*
* @return <code>true</code> if mark/reset is supported, <code>false</code> otherwise
* @return <code>true</code> if mark/reset is supported,
* <code>false</code> otherwise
*/
public boolean
markSupported()
{
public boolean markSupported()
{
return(in.markSupported());
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* Calls the <code>in.reset()</code> method.
*
* @exception IOException If an error occurs
*/
public void
reset() throws IOException
{
public void reset() throws IOException
{
in.reset();
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* Calls the <code>in.read()</code> method.
*
* @return The value returned from <code>in.available()</code>
*
* @exception IOException If an error occurs
*/
public boolean
ready() throws IOException
{
public boolean ready() throws IOException
{
return(in.ready());
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* Calls the <code>in.skip(long)</code> method
*
* @param The requested number of chars to skip.
* @param numBytes The requested number of chars to skip.
*
* @return The value returned from <code>in.skip(long)</code>
*
* @exception IOException If an error occurs
*/
public long
skip(long num_chars) throws IOException
{
public long skip(long num_chars) throws IOException
{
return(in.skip(num_chars));
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* Calls the <code>in.read()</code> method
*
* @return The value returned from <code>in.read()</code>
*
* @exception IOException If an error occurs
*/
public int
read() throws IOException
{
public int read() throws IOException
{
return(in.read());
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* Calls the <code>in.read(char[], int, int)</code> method.
*
* @param buf The buffer to read chars into
......@@ -202,24 +193,23 @@ read() throws IOException
*
* @exception IOException If an error occurs
*/
public int
read(char[] buf, int offset, int len) throws IOException
{
public int read(char[] buf, int offset, int len) throws IOException
{
return(in.read(buf, offset, len));
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method closes the stream by calling the <code>close()</code> method
* of the underlying stream.
*
* @exception IOException If an error occurs
*/
public void
close() throws IOException
{
public void close() throws IOException
{
in.close();
}
}
} // class FilterReader
/* FilterWriter.java -- Parent class for output streams that filter
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -56,26 +56,23 @@ package java.io;
*/
public abstract class FilterWriter extends Writer
{
/*************************************************************************/
/*
/*
* Instance Variables
*/
/**
/**
* This is the subordinate <code>Writer</code> that this class
* redirects its method calls to.
*/
protected Writer out;
protected Writer out;
/*************************************************************************/
/*************************************************************************/
/*
/*
* Constructors
*/
/**
/**
* This method initializes an instance of <code>FilterWriter</code>
* to write to the specified subordinate <code>Writer</code>.
* The given <code>Writer</code> will be used as <code>lock</code> for
......@@ -83,48 +80,45 @@ protected Writer out;
*
* @param out The <code>Writer</code> to write to
*/
protected
FilterWriter(Writer out)
{
protected FilterWriter(Writer out)
{
super(out);
this.out = out;
}
}
/*************************************************************************/
/*************************************************************************/
/*
/*
* Instance Methods
*/
/**
/**
* This method closes the underlying <code>Writer</code>. Any
* further attempts to write to this stream may throw an exception.
*
* @exception IOException If an error occurs
*/
public void
close() throws IOException
{
public void close() throws IOException
{
out.close();
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method attempt to flush all buffered output to be written to the
* underlying output sink.
*
* @exception IOException If an error occurs
*/
public void
flush() throws IOException
{
public void flush() throws IOException
{
out.flush();
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method writes a single char of output to the underlying
* <code>Writer</code>.
*
......@@ -132,15 +126,14 @@ flush() throws IOException
*
* @exception IOException If an error occurs
*/
public void
write(int b) throws IOException
{
public void write(int b) throws IOException
{
out.write(b);
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method writes <code>len</code> chars from the array <code>buf</code>
* starting at index <code>offset</code> to the underlying
* <code>Writer</code>.
......@@ -151,29 +144,28 @@ write(int b) throws IOException
*
* @exception IOException If an error occurs
*/
public void
write(char[] buf, int offset, int len) throws IOException
{
public void write(char[] buf, int offset, int len) throws IOException
{
out.write(buf, offset, len);
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method writes <code>len</code> chars from the <code>String</code>
* starting at position <code>offset</code>.
*
* @param str The <code>String</code> that is to be written
* @param offset The character offset into the <code>String</code> to start writing from
* @param offset The character offset into the <code>String</code>
* to start writing from
* @param len The number of chars to write
*
* @exception IOException If an error occurs
*/
public void
write(String str, int offset, int len) throws IOException
{
public void write(String str, int offset, int len) throws IOException
{
out.write(str, offset, len);
}
}
} // class FilterWriter
/* ObjectInput.java -- Read object data from a stream
Copyright (C) 1998 Free Software Foundation, Inc.
Copyright (C) 1998,2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -44,14 +44,11 @@ package java.io;
* also has methods that allow input to be done in a manner similar to
* <code>InputStream</code>
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public interface ObjectInput extends DataInput
{
/**
/**
* This method returns the number of bytes that can be read without
* blocking.
*
......@@ -59,12 +56,11 @@ public interface ObjectInput extends DataInput
*
* @exception IOException If an error occurs
*/
public abstract int
available() throws IOException;
public abstract int available() throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method reading a byte of data from a stream. It returns that byte
* as an int. This method blocks if no data is available to be read.
*
......@@ -72,12 +68,11 @@ available() throws IOException;
*
* @exception IOException If an error occurs
*/
public abstract int
read() throws IOException;
public abstract int read() throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method reads raw bytes and stores them them a byte array buffer.
* Note that this method will block if no data is available. However,
* it will not necessarily block until it fills the entire buffer. That is,
......@@ -89,14 +84,14 @@ read() throws IOException;
*
* @exception IOException If an error occurs
*/
public abstract int
read(byte[] buf) throws IOException;
public abstract int read(byte[] buf) throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method reads raw bytes and stores them in a byte array buffer
* <code>buf</code> starting at position <code>offset</code> into the buffer. A
* <code>buf</code> starting at position <code>offset</code> into the
* buffer. A
* maximum of <code>len</code> bytes will be read. Note that this method
* blocks if no data is available, but will not necessarily block until
* it can read <code>len</code> bytes of data. That is, a "short count" is
......@@ -110,49 +105,47 @@ read(byte[] buf) throws IOException;
*
* @exception IOException If an error occurs
*/
public abstract int
read(byte[] buf, int offset, int len) throws IOException;
public abstract int read(byte[] buf, int offset, int len) throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
/**
* Reads an object instance and returns it. If the class for the object
* being read cannot be found, then a ClassNotFoundException will
* be thrown.
*
* @return The object instance that was read
*
* @exception ClassNotFoundException If a class for the object cannot be found
* @exception ClassNotFoundException If a class for the object cannot be
* found
* @exception IOException If an error occurs
*/
public abstract Object
readObject() throws ClassNotFoundException, IOException;
public abstract Object readObject()
throws ClassNotFoundException, IOException;
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method causes the specified number of bytes to be read and
* discarded. It is possible that fewer than the requested number of bytes
* will actually be skipped.
*
* @param num_bytes The number of bytes to skip
* @param numBytes The number of bytes to skip
*
* @return The actual number of bytes skipped
*
* @exception IOException If an error occurs
*/
public abstract long
skip(long num_bytes) throws IOException;
public abstract long skip(long num_bytes) throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method closes the input source
*
* @exception IOException If an error occurs
*/
public abstract void
close() throws IOException;
public abstract void close() throws IOException;
} // interface ObjectInput
/* ObjectInputValidation.java -- Validate an object
Copyright (C) 1998 Free Software Foundation, Inc.
Copyright (C) 1998, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -41,21 +41,18 @@ package java.io;
/**
* What does this interface really do?
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public interface ObjectInputValidation
{
/**
/**
* This method is called to validate an object. If the object is invalid
* an exception is thrown.
*
* @exception InvalidObjectException If the object is invalid
*/
public abstract void
validateObject() throws InvalidObjectException;
public abstract void validateObject() throws InvalidObjectException;
} // interface ObjectInputValidation
/* ObjectOutput.java -- Interface for writing objects to a stream
Copyright (C) 1998 Free Software Foundation, Inc.
Copyright (C) 1998, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -41,29 +41,26 @@ package java.io;
/**
* This interface extends <code>DataOutput</code> to provide the additional
* facility of writing object instances to a stream. It also adds some
* additional methods to make the interface more <code>OutputStream</code> like.
*
* @version 0.0
* additional methods to make the interface more
* <code>OutputStream</code> like.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public interface ObjectOutput extends DataOutput
{
/**
/**
* This method writes the specified byte to the output stream.
*
* @param b The byte to write.
*
* @exception IOException If an error occurs.
*/
public abstract void
write(int b) throws IOException;
public abstract void write(int b) throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method writes all the bytes in the specified byte array to the
* output stream.
*
......@@ -71,12 +68,11 @@ write(int b) throws IOException;
*
* @exception IOException If an error occurs.
*/
public abstract void
write(byte[] buf) throws IOException;
public abstract void write(byte[] buf) throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method writes <code>len</code> bytes from the specified array
* starting at index <code>offset</code> into that array.
*
......@@ -86,12 +82,12 @@ write(byte[] buf) throws IOException;
*
* @exception IOException If an error occurs.
*/
public abstract void
write(byte[] buf, int offset, int len) throws IOException;
public abstract void write(byte[] buf, int offset, int len)
throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method writes a object instance to a stream. The format of the
* data written is determined by the actual implementation of this method
*
......@@ -99,29 +95,26 @@ write(byte[] buf, int offset, int len) throws IOException;
*
* @exception IOException If an error occurs
*/
public abstract void
writeObject(Object obj) throws IOException;
public abstract void writeObject(Object obj) throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method causes any buffered data to be flushed out to the underlying
* stream
*
* @exception IOException If an error occurs
*/
public abstract void
flush() throws IOException;
public abstract void flush() throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method closes the underlying stream.
*
* @exception IOException If an error occurs
*/
public abstract void
close() throws IOException;
public abstract void close() throws IOException;
} // interface ObjectOutput
/* ObjectStreamField.java -- Class used to store name and class of fields
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -51,16 +51,20 @@ public class ObjectStreamField implements java.lang.Comparable
}
/**
* There're many cases you can't get java.lang.Class from typename if your context
* There're many cases you can't get java.lang.Class from typename
* if your context
* class loader can't load it, then use typename to construct the field
*/
ObjectStreamField (String name, String typename){
this.name = name;
this.typename = typename;
try{
try
{
type = TypeSignature.getClassForEncoding(typename);
}catch(ClassNotFoundException e){
type = Object.class; //??
}
catch(ClassNotFoundException e)
{
type = Object.class; //FIXME: ???
}
}
......@@ -125,3 +129,4 @@ public class ObjectStreamField implements java.lang.Comparable
private String typename;
private int offset = -1; // XXX make sure this is correct
}
/* PipedInputStream.java -- Read portion of piped streams.
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -46,7 +46,8 @@ package java.io;
* to which it is connected.
* <p>
* Data is read and written to an internal buffer. It is highly recommended
* that the <code>PipedInputStream</code> and connected <code>PipedOutputStream</code>
* that the <code>PipedInputStream</code> and connected
* <code>PipedOutputStream</code>
* be part of different threads. If they are not, the read and write
* operations could deadlock their thread.
*
......@@ -113,7 +114,8 @@ public class PipedInputStream extends InputStream
* it to the passed in <code>PipedOutputStream</code>. The stream is then
* ready for reading.
*
* @param source The <code>PipedOutputStream</code> to connect this stream to
* @param source The <code>PipedOutputStream</code> to connect this
* stream to
*
* @exception IOException If <code>source</code> is already connected.
*/
......@@ -123,7 +125,8 @@ public class PipedInputStream extends InputStream
}
/**
* This method connects this stream to the passed in <code>PipedOutputStream</code>.
* This method connects this stream to the passed in
* <code>PipedOutputStream</code>.
* This stream is then ready for reading. If this stream is already
* connected or has been previously closed, then an exception is thrown
*
......@@ -224,9 +227,12 @@ public class PipedInputStream extends InputStream
/**
* This method reads bytes from the stream into a caller supplied buffer.
* It starts storing bytes at position <code>offset</code> into the buffer and
* reads a maximum of <code>len</code> bytes. Note that this method can actually
* read fewer than <code>len</code> bytes. The actual number of bytes read is
* It starts storing bytes at position <code>offset</code> into the
* buffer and
* reads a maximum of <code>len</code> bytes. Note that this method
* can actually
* read fewer than <code>len</code> bytes. The actual number of bytes
* read is
* returned. A -1 is returned to indicated that no bytes can be read
* because the end of the stream was reached. If the stream is already
* closed, a -1 will again be returned to indicate the end of the stream.
......@@ -255,9 +261,12 @@ public class PipedInputStream extends InputStream
/**
* This method reads bytes from the stream into a caller supplied buffer.
* It starts storing bytes at position <code>offset</code> into the buffer and
* reads a maximum of <code>len</code> bytes. Note that this method can actually
* read fewer than <code>len</code> bytes. The actual number of bytes read is
* It starts storing bytes at position <code>offset</code> into the
* buffer and
* reads a maximum of <code>len</code> bytes. Note that this method
* can actually
* read fewer than <code>len</code> bytes. The actual number of bytes
* read is
* returned. A -1 is returned to indicated that no bytes can be read
* because the end of the stream was reached - ie close() was called on the
* connected PipedOutputStream.
......@@ -371,3 +380,4 @@ public class PipedInputStream extends InputStream
notifyAll();
}
}
......@@ -118,7 +118,8 @@ public class PipedReader extends Reader
}
/**
* This method connects this stream to the passed in <code>PipedWriter</code>.
* This method connects this stream to the passed in
* <code>PipedWriter</code>.
* This stream is then ready for reading. If this stream is already
* connected or has been previously closed, then an exception is thrown
*
......@@ -207,9 +208,12 @@ public class PipedReader extends Reader
/**
* This method reads chars from the stream into a caller supplied buffer.
* It starts storing chars at position <code>offset</code> into the buffer and
* reads a maximum of <code>len</code> chars. Note that this method can actually
* read fewer than <code>len</code> chars. The actual number of chars read is
* It starts storing chars at position <code>offset</code> into the
* buffer and
* reads a maximum of <code>len</code> chars. Note that this method
* can actually
* read fewer than <code>len</code> chars. The actual number of chars
* read is
* returned. A -1 is returned to indicated that no chars can be read
* because the end of the stream was reached. If the stream is already
* closed, a -1 will again be returned to indicate the end of the stream.
......@@ -237,10 +241,11 @@ public class PipedReader extends Reader
}
/**
* This method reads characters from the stream into a caller supplied buffer.
* It starts storing chars at position <code>offset</code> into the buffer and
* reads a maximum of <code>len</code> chars. Note that this method can actually
* read fewer than <code>len</code> chars. The actual number of chars read is
* This method reads characters from the stream into a caller supplied
* buffer. It starts storing chars at position <code>offset</code> into
* the buffer and reads a maximum of <code>len</code> chars. Note that
* this method can actually read fewer than <code>len</code> chars.
* The actual number of chars read is
* returned. A -1 is returned to indicated that no chars can be read
* because the end of the stream was reached - ie close() was called on the
* connected PipedWriter.
......@@ -361,3 +366,4 @@ public class PipedReader extends Reader
}
}
}
......@@ -48,8 +48,6 @@ package java.io;
* class which also auto-flushes when it encounters a newline character
* in the chars written).
*
* @version 0.0
*
* @author Per Bothner <bothner@cygnus.com>
* @author Aaron M. Renn (arenn@urbanophile.com)
* @date April 17, 1998.
......@@ -99,7 +97,8 @@ public class PrintWriter extends Writer
* every line is terminated or newline character is written.
*
* @param wr The <code>Writer</code> to write to.
* @param autoflush <code>true</code> to flush the stream after every line, <code>false</code> otherwise
* @param autoflush <code>true</code> to flush the stream after every
* line, <code>false</code> otherwise
*/
public PrintWriter(Writer wr, boolean autoflush)
{
......@@ -130,7 +129,8 @@ public class PrintWriter extends Writer
* constructor allows auto-flush functionality to be enabled if desired
*
* @param out The <code>OutputStream</code> to write to
* @param autoflush <code>true</code> to flush the stream after every <code>println</code> call, <code>false</code> otherwise.
* @param autoflush <code>true</code> to flush the stream after every
* <code>println</code> call, <code>false</code> otherwise.
*/
public PrintWriter(OutputStream out, boolean autoflush)
{
......@@ -153,7 +153,8 @@ public class PrintWriter extends Writer
* <code>true</code> forever for this stream. Before checking for an
* error condition, this method flushes the stream.
*
* @return <code>true</code> if an error has occurred, <code>false</code> otherwise
* @return <code>true</code> if an error has occurred,
* <code>false</code> otherwise
*/
public boolean checkError()
{
......@@ -567,3 +568,4 @@ public class PrintWriter extends Writer
write(str, 0, str.length());
}
}
/* PushbackReader.java -- An character stream that can unread chars
Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc.
Copyright (C) 1998, 2000, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -48,8 +48,6 @@ package java.io;
* The default pushback buffer size one char, but this can be overridden
* by the creator of the stream.
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Warren Levy <warrenl@cygnus.com>
*/
......@@ -136,7 +134,8 @@ public class PushbackReader extends FilterReader
* This method returns <code>false</code> to indicate that it does not support
* mark/reset functionality.
*
* @return This method returns <code>false</code> to indicate that this class does not support mark/reset functionality
* @return This method returns <code>false</code> to indicate that this
* class does not support mark/reset functionality
*
*/
public boolean markSupported()
......@@ -165,7 +164,8 @@ public class PushbackReader extends FilterReader
* read in the pushback buffer or if the underlying stream is ready to
* be read.
*
* @return <code>true</code> if this stream is ready to be read, <code>false</code> otherwise
* @return <code>true</code> if this stream is ready to be read,
* <code>false</code> otherwise
*
* @exception IOException If an error occurs
*/
......@@ -252,7 +252,8 @@ public class PushbackReader extends FilterReader
/**
* This method read chars from a stream and stores them into a caller
* supplied buffer. It starts storing the data at index <code>offset</code> into
* supplied buffer. It starts storing the data at index <code>offset</code>
* into
* the buffer and attempts to read <code>len</code> chars. This method can
* return before reading the number of chars requested. The actual number
* of chars read is returned as an int. A -1 is returned to indicate the
......@@ -302,8 +303,8 @@ public class PushbackReader extends FilterReader
* <p>
* If the pushback buffer is full, this method throws an exception.
* <p>
* The argument to this method is an <code>int</code>. Only the low eight bits
* of this value are pushed back.
* The argument to this method is an <code>int</code>. Only the low eight
* bits of this value are pushed back.
*
* @param b The char to be pushed back, passed as an int
*
......@@ -343,7 +344,8 @@ public class PushbackReader extends FilterReader
/**
* This method pushed back chars from the passed in array into the pushback
* buffer. The chars from <code>buf[offset]</code> to <code>buf[offset + len]</code>
* buffer. The chars from <code>buf[offset]</code> to
* <code>buf[offset + len]</code>
* are pushed in reverse order so that the next char read from the stream
* after this operation will be <code>buf[offset]</code> followed by
* <code>buf[offset + 1]</code>, etc.
......@@ -378,3 +380,4 @@ public class PushbackReader extends FilterReader
}
}
}
/* Reader.java -- base class of classes that read input as a stream of chars
Copyright (C) 1998, 1999, 2000 Free Software Foundation
Copyright (C) 1998, 1999, 2000, 2003 Free Software Foundation
This file is part of GNU Classpath.
......@@ -222,7 +222,8 @@ public abstract class Reader
* <p>
* This method always returns <code>false</code> in this class
*
* @return <code>true</code> if the stream is ready to be read, <code>false</code> otherwise.
* @return <code>true</code> if the stream is ready to be read,
* <code>false</code> otherwise.
*
* @exception IOException If an error occurs
*/
......
/* SerializablePermission.java -- Basic permissions related to serialization.
Copyright (C) 1998, 2000 Free Software Foundation, Inc.
Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -55,55 +55,55 @@ import java.security.BasicPermission;
*
* @see java.security.BasicPermission
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public final class SerializablePermission extends BasicPermission
{
static final long serialVersionUID = 8537212141160296410L;
/*
/*
* Class Variables
*/
private static final String[] legal_names = { "enableSubclassImplementation",
private static final String[] legal_names = { "enableSubclassImplementation",
"enableSubstitution" };
/*************************************************************************/
/*************************************************************************/
/*
/*
* Constructors
*/
/**
* This method initializes a new instance of <code>SerializablePermission</code>
/**
* This method initializes a new instance of
* <code>SerializablePermission</code>
* that has the specified name.
*
* @param name The name of the permission.
*
* @exception IllegalArgumentException If the name is not valid for this class.
* @exception IllegalArgumentException If the name is not valid for
* this class.
*/
public
SerializablePermission(String name)
{
public SerializablePermission(String name)
{
this(name, null);
}
}
/*************************************************************************/
/*************************************************************************/
/**
* This method initializes a new instance of <code>SerializablePermission</code>
/**
* This method initializes a new instance of
* <code>SerializablePermission</code>
* that has the specified name and action list. Note that the action list
* is unused in this class.
*
* @param name The name of the permission.
* @param actions The action list (unused).
*
* @exception IllegalArgumentException If the name is not valid for this class.
* @exception IllegalArgumentException If the name is not valid for
* this class.
*/
public
SerializablePermission(String name, String actions)
{
public SerializablePermission(String name, String actions)
{
super(name, actions);
for (int i = 0; i < legal_names.length; i++)
......@@ -111,8 +111,7 @@ SerializablePermission(String name, String actions)
return;
throw new IllegalArgumentException("Bad permission name: " + name);
}
}
} // class SerializablePermission
/* StringReader.java -- permits a String to be read as a character input stream
Copyright (C) 1998, 1999, 2000 Free Software Foundation
Copyright (C) 1998, 1999, 2000, 2003 Free Software Foundation
This file is part of GNU Classpath.
......@@ -51,8 +51,6 @@ package java.io;
* normal. If no mark has been set, then calling the <code>reset()</code>
* method rewinds the read pointer to the beginning of the <code>String</code>.
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Warren Levy <warrenl@cygnus.com>
* @date October 19, 1998.
......@@ -73,8 +71,8 @@ public class StringReader extends Reader
/**
* Create a new <code>StringReader</code> that will read chars from the
* passed in <code>String</code>. This stream will read from the beginning to the
* end of the <code>String</code>.
* passed in <code>String</code>. This stream will read from the beginning
* to the end of the <code>String</code>.
*
* @param s The <code>String</code> this stream will read from.
*/
......@@ -208,3 +206,4 @@ public class StringReader extends Reader
}
}
}
/* Writer.java -- Base class for character output streams
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -55,54 +55,49 @@ package java.io;
*/
public abstract class Writer
{
/*************************************************************************/
/**
/**
* This is the object used to synchronize criticial code sections for
* thread safety. Subclasses should use this field instead of using
* synchronized methods or explicity synchronizations on <code>this</code>
*/
protected Object lock;
protected Object lock;
/*************************************************************************/
/*************************************************************************/
/*
/*
* Constructors
*/
/**
/**
* This is the default no-argument constructor for this class. This method
* will set up the class to synchronize criticial sections on itself.
*/
protected
Writer()
{
protected Writer()
{
lock = this;
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method initializes a <code>Writer</code> that will synchronize
* on the specified <code>Object</code>.
*
* @param obj The <code>Object</code> to use for synchronizing critical
* sections
*/
protected
Writer(Object lock)
{
protected Writer(Object lock)
{
this.lock = lock;
}
}
/*************************************************************************/
/*************************************************************************/
/*
/*
* Instance Methods
*/
/**
/**
* This method forces any data that may have been buffered to be written
* to the underlying output device. Please note that the host environment
* might perform its own buffering unbeknowst to Java. In that case, a
......@@ -111,13 +106,13 @@ Writer(Object lock)
*
* @exception IOException If an error occurs
*/
public abstract void
flush() throws IOException;
public abstract void flush() throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
* This method closes the stream. Any internal or native resources associated
/**
* This method closes the stream. Any internal or native resources
* associated
* with this stream are freed. Any subsequent attempt to access the stream
* might throw an exception.
* <p>
......@@ -125,47 +120,45 @@ flush() throws IOException;
*
* @exception IOException If an error occurs
*/
public abstract void
close() throws IOException;
public abstract void close() throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method writes a single char to the output stream.
*
* @param b The char to be written to the output stream, passed as an int
*
* @exception IOException If an error occurs
*/
public void
write(int b) throws IOException
{
public void write(int b) throws IOException
{
char[] buf = new char[1];
buf[0] = (char)b;
write(buf, 0, buf.length);
}
}
/*************************************************************************/
/*************************************************************************/
/**
* This method all the writes char from the passed array to the output stream.
* This method is equivalent to <code>write(buf, 0, buf.length)</code> which
/**
* This method all the writes char from the passed array to the output
* stream. This method is equivalent to
* <code>write(buf, 0, buf.length)</code> which
* is exactly how it is implemented in this class.
*
* @param buf The array of char to write
*
* @exception IOException If an error occurs
*/
public void
write(char[] buf) throws IOException
{
public void write(char[] buf) throws IOException
{
write(buf, 0, buf.length);
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method writes <code>len</code> char from the specified array
* <code>buf</code> starting at index <code>offset</code> into the array.
* <p>
......@@ -177,12 +170,12 @@ write(char[] buf) throws IOException
*
* @exception IOException If an error occurs
*/
public abstract void
write(char[] buf, int offset, int len) throws IOException;
public abstract void write(char[] buf, int offset, int len)
throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method writes all the characters in a <code>String</code> to the
* output.
*
......@@ -190,15 +183,14 @@ write(char[] buf, int offset, int len) throws IOException;
*
* @param IOException If an error occurs
*/
public void
write(String str) throws IOException
{
public void write(String str) throws IOException
{
write(str, 0, str.length());
}
}
/*************************************************************************/
/*************************************************************************/
/**
/**
* This method writes <code>len</code> chars from the <code>String</code>
* starting at position <code>offset</code>.
*
......@@ -209,14 +201,15 @@ write(String str) throws IOException
*
* @exception IOException If an error occurs
*/
public void
write(String str, int offset, int len) throws IOException
{
// FIXME - for libgcj re-write using native code to not require copied buffer.
public void write(String str, int offset, int len) throws IOException
{
// FIXME - for libgcj re-write using native code to not require
// copied buffer.
char[] buf = new char[len];
str.getChars(offset, offset + len, buf, 0);
write(buf, 0, len);
}
}
} // class Writer
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment