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