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
This commit is contained in:
Michael Koch 2003-03-18 06:00:25 +00:00 committed by Michael Koch
parent 61f1ed592c
commit f4f5d1d621
25 changed files with 1138 additions and 1104 deletions

View File

@ -1,3 +1,31 @@
2003-03-18 Michael Koch <konqueror@gmx.de>
* java/io/BufferedReader.java,
java/io/BufferedWriter.java,
java/io/ByteArrayOutputStream.java,
java/io/FileFilter.java,
java/io/FilePermission.java,
java/io/FileReader.java,
java/io/FileWriter.java,
java/io/FilenameFilter.java,
java/io/FilterInputStream.java,
java/io/FilterOutputStream.java,
java/io/FilterReader.java,
java/io/FilterWriter.java,
java/io/ObjectInput.java,
java/io/ObjectInputValidation.java,
java/io/ObjectOutput.java,
java/io/ObjectStreamField.java,
java/io/PipedInputStream.java,
java/io/PipedReader.java,
java/io/PrintWriter.java,
java/io/PushbackReader.java,
java/io/Reader.java,
java/io/SerializablePermission.java,
java/io/StringReader.java,
java/io/Writer.java:
Merged from classpath.
2003-03-17 Michael Koch <konqueror@gmx.de>
* java/awt/ScrollPaneAdjustable.java:

View File

@ -243,7 +243,8 @@ public class BufferedReader extends Reader
* This method returns <code>false</code> then this stream could (but is
* not guaranteed to) block on the next read attempt.
*
* @return <code>true</code> if this stream is ready to be read, <code>false</code> otherwise
* @return <code>true</code> if this stream is ready to be read,
* <code>false</code> otherwise
*
* @exception IOException If an error occurs
*/
@ -258,7 +259,8 @@ public class BufferedReader extends Reader
/**
* This method read chars from a stream and stores them into a caller
* supplied buffer. It starts storing the data at index <code>offset</code> into
* supplied buffer. It starts storing the data at index
* <code>offset</code> into
* the buffer and attempts to read <code>len</code> chars. This method can
* return before reading the number of chars requested. The actual number
* of chars read is returned as an int. A -1 is returned to indicate the
@ -473,7 +475,8 @@ public class BufferedReader extends Reader
* requested amount.
* <p>
* This method first discards chars in the buffer, then calls the
* <code>skip</code> method on the underlying stream to skip the remaining chars.
* <code>skip</code> method on the underlying stream to skip the
* remaining chars.
*
* @param num_chars The requested number of chars to skip
*

View File

@ -51,8 +51,6 @@ package java.io;
* efficient mechanism for writing versus doing numerous small unbuffered
* writes.
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Tom Tromey <tromey@cygnus.com>
* @date September 25, 1998

View File

@ -65,8 +65,6 @@ package java.io;
* application specified character encoding. Thus it can handle
* multibyte character encodings.
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Tom Tromey <tromey@cygnus.com>
* @date September 24, 1998

View File

@ -46,23 +46,21 @@ package java.io;
* The method in this interface determines if a particular pathname should
* or should not be included in the pathname listing.
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public interface FileFilter
{
/**
* This method determines whether or not a given pathname should be included
* in a pathname listing.
*
* @param pathname The pathname to test
*
* @return <code>true</code> if the path should be included in the list, <code>false</code> otherwise.
*/
public abstract boolean
accept(File pathname);
/**
* This method determines whether or not a given pathname should be included
* in a pathname listing.
*
* @param pathname The pathname to test
*
* @return <code>true</code> if the path should be included in the list,
* <code>false</code> otherwise.
*/
public abstract boolean accept(File pathname);
} // interface FileFilter

View File

@ -1,5 +1,5 @@
/* java.lang.FilePermission
Copyright (C) 1998, 2000 Free Software Foundation, Inc.
Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -45,7 +45,8 @@ public final class FilePermission extends Permission implements Serializable
{
static final long serialVersionUID = 7930732926638008763L;
private static final String CURRENT_DIRECTORY = System.getProperty("user.dir");
private static final String CURRENT_DIRECTORY =
System.getProperty("user.dir");
private boolean usingPerms = false;
private boolean readPerm = false;
private boolean writePerm = false;
@ -53,26 +54,28 @@ public final class FilePermission extends Permission implements Serializable
private boolean deletePerm = false;
private String actionsString;
private void cachePerms() {
private void cachePerms()
{
// While race conditions could occur, they don't matter at all.
String action;
int i = actionsString.indexOf(',');
int startI = 0;
while(i != -1) {
action = actionsString.substring(startI,i);
if(action.equals("read"))
readPerm = true;
else if(action.equals("write"))
writePerm = true;
else if(action.equals("execute"))
executePerm = true;
else if(action.equals("delete"))
deletePerm = true;
while(i != -1)
{
action = actionsString.substring(startI,i);
if(action.equals("read"))
readPerm = true;
else if(action.equals("write"))
writePerm = true;
else if(action.equals("execute"))
executePerm = true;
else if(action.equals("delete"))
deletePerm = true;
startI = i+1;
i = actionsString.indexOf(',',startI);
}
startI = i+1;
i = actionsString.indexOf(',',startI);
}
action = actionsString.substring(startI);
if(action.equals("read"))
@ -93,25 +96,29 @@ public final class FilePermission extends Permission implements Serializable
** @XXX what to do when the file string is malformed?
**/
public FilePermission(String pathExpression, String actionsString)
{
super(pathExpression);
this.actionsString = actionsString;
}
{
super(pathExpression);
this.actionsString = actionsString;
}
/** Get the actions this FilePermission supports.
** @return the String representing the actions this FilePermission supports.
**/
public String getActions() {
public String getActions()
{
return actionsString;
}
/** Get the hash code for this Object.<P>
** FilePermission's hash code is calculated as the exclusive or of the target
** FilePermission's hash code is calculated as the exclusive or of the
** target
** String's hash code and the action String's hash code.
** @specnote Sun did not specify how to calculate the hash code; I made this up.
** @specnote Sun did not specify how to calculate the hash code;
** I made this up.
** @return the hash code for this Object.
**/
public int hashCode() {
public int hashCode()
{
return getName().hashCode() ^ actionsString.hashCode();
}
@ -121,7 +128,8 @@ public final class FilePermission extends Permission implements Serializable
** @param o the Object to compare to.
** @return whether the Objects are semantically equivalent.
**/
public boolean equals(Object o) {
public boolean equals(Object o)
{
if(!(o instanceof FilePermission))
return false;
FilePermission p = (FilePermission)o;
@ -136,23 +144,32 @@ public final class FilePermission extends Permission implements Serializable
/* Compare names, taking into account if they refer to a
* directory and one has a separator and the other does not.
*/
if(f1.charAt(f1.length()) == File.separatorChar) {
if(f2.charAt(f2.length()) == File.separatorChar) {
if(!f2.equals(f1))
return false;
} else {
if(!f2.equals(f1.substring(0,f1.length()-1)))
return false;
}
} else {
if(f2.charAt(f2.length()) == File.separatorChar) {
if(!f1.equals(f2.substring(0,f2.length()-1)))
return false;
} else {
if(!f1.equals(f2))
return false;
}
}
if(f1.charAt(f1.length()) == File.separatorChar)
{
if(f2.charAt(f2.length()) == File.separatorChar)
{
if(!f2.equals(f1))
return false;
}
else
{
if(!f2.equals(f1.substring(0,f1.length()-1)))
return false;
}
}
else
{
if(f2.charAt(f2.length()) == File.separatorChar)
{
if(!f1.equals(f2.substring(0,f2.length()-1)))
return false;
}
else
{
if(!f1.equals(f2))
return false;
}
}
return readPerm == p.readPerm && writePerm == p.writePerm && executePerm == p.executePerm && deletePerm == p.deletePerm;
}
@ -160,13 +177,15 @@ public final class FilePermission extends Permission implements Serializable
** Permission A implies permission B if these things are all true:
** <OL>
** <LI>A and B are both FilePermissions.</LI>
** <LI>All possible files in B are included in A (possibly more are in A).</LI>
** <LI>All possible files in B are included in A
** (possibly more are in A).</LI>
** <LI>All actions B supports, A also supports.</LI>
** </OL>
** @param p the Permission to compare against.
** @return whether this Permission implies p
**/
public boolean implies(Permission p) {
public boolean implies(Permission p)
{
FilePermission fp;
if(!(p instanceof FilePermission))
return false;
@ -174,48 +193,67 @@ public final class FilePermission extends Permission implements Serializable
String f1 = getName();
String f2 = fp.getName();
if(f1.charAt(0) != File.separatorChar) {
f1 = CURRENT_DIRECTORY + f1;
}
if(f2.charAt(0) != File.separatorChar) {
f2 = CURRENT_DIRECTORY + f2;
}
if(f1.charAt(0) != File.separatorChar)
{
f1 = CURRENT_DIRECTORY + f1;
}
if(f2.charAt(0) != File.separatorChar)
{
f2 = CURRENT_DIRECTORY + f2;
}
String sub1, sub2a, sub2b;
switch(f1.charAt(f1.length() - 1)) {
case '*':
sub1 = f1.substring(0,f1.length() - 1); // chop off "*"
if(f2.length() <= sub1.length()) {
/* If it's smaller, there is no way it could be part of this directory.
* If it's the same (or length - 1), it could be the same directory but
* specifies access to the directory rather than the files in it.
*/
return false;
} else if(f2.charAt(sub1.length() - 1) == File.separatorChar) {
/* Make sure the part before the "/" is the same */
if(!f2.substring(0,sub1.length()).equals(sub1))
return false;
/* Make sure there are no subdirectories specified underneath this one */
String sub2 = f2.substring(sub1.length()+1);
if(f2.substring(sub1.length()+1).indexOf(File.separatorChar) != -1)
return false;
} else {
/* Obviously not equal: f2 is either not a directory or is not
* the same directory (its name continues further than we want)
*/
return false;
}
break;
case '-':
sub1 = f1.substring(0,f1.length() - 2); // chop off "/-"
if(f2.length() < sub1.length()) {
/* If it's smaller, there is no way it could be part of this directory. */
return false;
} else if(f2.length() > sub1.length() && f2.charAt(sub1.length()) != File.separatorChar) {
return false;
} else if(!f2.substring(0,sub1.length()).equals(sub1))
return false;
break;
switch(f1.charAt(f1.length() - 1))
{
case '*':
sub1 = f1.substring(0,f1.length() - 1); // chop off "*"
if(f2.length() <= sub1.length())
{
/* If it's smaller, there is no way it could be part of this
* directory.
* If it's the same (or length - 1), it could be the same
* directory but
* specifies access to the directory rather than the files in it.
*/
return false;
}
else if(f2.charAt(sub1.length() - 1) == File.separatorChar)
{
/* Make sure the part before the "/" is the same */
if(!f2.substring(0,sub1.length()).equals(sub1))
return false;
/* Make sure there are no subdirectories specified
underneath this one */
String sub2 = f2.substring(sub1.length()+1);
if(f2.substring(sub1.length()+1).indexOf(File.separatorChar)
!= -1)
return false;
}
else
{
/* Obviously not equal: f2 is either not a directory or is not
* the same directory (its name continues further than we want)
*/
return false;
}
break;
case '-':
sub1 = f1.substring(0,f1.length() - 2); // chop off "/-"
if(f2.length() < sub1.length())
{
/* If it's smaller, there is no way it could be part of
* this directory. */
return false;
}
else if(f2.length() > sub1.length() && f2.charAt(sub1.length())
!= File.separatorChar)
{
return false;
}
else if(!f2.substring(0,sub1.length()).equals(sub1))
return false;
break;
/* Looks redundant with default case and won't compile anyway - arenn
case File.separatorChar:
if(f2.charAt(f2.length()) == File.separatorChar) {
@ -227,16 +265,19 @@ public final class FilePermission extends Permission implements Serializable
}
break;
*/
default:
if(f2.charAt(f2.length()) == File.separatorChar) {
if(!f1.equals(f2.substring(0,f2.length()-1)))
return false;
} else {
if(!f1.equals(f2))
return false;
default:
if(f2.charAt(f2.length()) == File.separatorChar)
{
if(!f1.equals(f2.substring(0,f2.length()-1)))
return false;
}
else
{
if(!f1.equals(f2))
return false;
}
break;
}
break;
}
if(!usingPerms)
cachePerms();
@ -254,4 +295,5 @@ public final class FilePermission extends Permission implements Serializable
return true;
}
}
} // class FilePermission

View File

@ -1,5 +1,5 @@
/* FileReader.java -- Convenience class for reading characters from a file
Copyright (C) 1998, 2000 Free Software Foundation, Inc.
Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -46,8 +46,6 @@ package java.io;
* to read from files using the default character encoding. Use
* <code>InputStreamReader</code> directly to use a non-default encoding.
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public class FileReader extends InputStreamReader
@ -90,4 +88,5 @@ public class FileReader extends InputStreamReader
{
super(new FileInputStream(name));
}
}
} // class FileReader

View File

@ -54,84 +54,82 @@ package java.io;
public class FileWriter extends OutputStreamWriter
{
/*************************************************************************/
/*************************************************************************/
/*
* Constructors
*/
/**
* This method initializes a new <code>FileWriter</code> object to write
* to the specified <code>File</code> object.
*
* @param file The <code>File</code> object to write to.
*
* @param SecurityException If writing to this file is forbidden by the
* <code>SecurityManager</code>.
* @param IOException If any other error occurs
*/
public
FileWriter(File file) throws SecurityException, IOException
{
super(new FileOutputStream(file));
}
/*
* Constructors
*/
/**
* This method initializes a new <code>FileWriter</code> object to write
* to the specified <code>File</code> object.
*
* @param file The <code>File</code> object to write to.
*
* @param SecurityException If writing to this file is forbidden by the
* <code>SecurityManager</code>.
* @param IOException If any other error occurs
*/
public FileWriter(File file) throws SecurityException, IOException
{
super(new FileOutputStream(file));
}
/*************************************************************************/
/*************************************************************************/
/**
* This method initializes a new <code>FileWriter</code> object to write
* to the specified <code>FileDescriptor</code> object.
*
* @param fd The <code>FileDescriptor</code> object to write to
*
* @param SecurityException If writing to this file is forbidden by the
* <code>SecurityManager</code>.
*/
public
FileWriter(FileDescriptor fd) throws SecurityException
{
super(new FileOutputStream(fd));
}
/**
* This method initializes a new <code>FileWriter</code> object to write
* to the specified <code>FileDescriptor</code> object.
*
* @param fd The <code>FileDescriptor</code> object to write to
*
* @param SecurityException If writing to this file is forbidden by the
* <code>SecurityManager</code>.
*/
public FileWriter(FileDescriptor fd) throws SecurityException
{
super(new FileOutputStream(fd));
}
/*************************************************************************/
/*************************************************************************/
/**
* This method intializes a new <code>FileWriter</code> object to write to the
* specified named file.
*
* @param name The name of the file to write to
*
* @param SecurityException If writing to this file is forbidden by the
* <code>SecurityManager</code>.
* @param IOException If any other error occurs
*/
public
FileWriter(String name) throws IOException
{
super(new FileOutputStream(name));
}
/**
* This method intializes a new <code>FileWriter</code> object to
* write to the
* specified named file.
*
* @param name The name of the file to write to
*
* @param SecurityException If writing to this file is forbidden by the
* <code>SecurityManager</code>.
* @param IOException If any other error occurs
*/
public FileWriter(String name) throws IOException
{
super(new FileOutputStream(name));
}
/*************************************************************************/
/*************************************************************************/
/**
* This method intializes a new <code>FileWriter</code> object to write to the
* specified named file. This form of the constructor allows the caller
* to determin whether data should be written starting at the beginning or
* the end of the file.
*
* @param name The name of the file to write to
* @param append <code>true</code> to start adding data at the end of the
* file, <code>false</code> otherwise.
*
* @param SecurityException If writing to this file is forbidden by the
* <code>SecurityManager</code>.
* @param IOException If any other error occurs
*/
public
FileWriter(String name, boolean append) throws IOException
{
super(new FileOutputStream(name, append));
}
/**
* This method intializes a new <code>FileWriter</code> object to
* write to the
* specified named file. This form of the constructor allows the caller
* to determin whether data should be written starting at the beginning or
* the end of the file.
*
* @param name The name of the file to write to
* @param append <code>true</code> to start adding data at the end of the
* file, <code>false</code> otherwise.
*
* @param SecurityException If writing to this file is forbidden by the
* <code>SecurityManager</code>.
* @param IOException If any other error occurs
*/
public FileWriter(String name, boolean append) throws IOException
{
super(new FileOutputStream(name, append));
}
} // class FileWriter

View File

@ -57,17 +57,17 @@ package java.io;
public interface FilenameFilter
{
/**
* This method determines whether or not a given file should be included
* in a directory listing.
*
* @param dir The <code>File</code> instance for the directory being read
* @param name The name of the file to test
*
* @return <code>true</code> if the file should be included in the list,
* <code>false</code> otherwise.
*/
boolean
accept(File dir, String name);
/**
* This method determines whether or not a given file should be included
* in a directory listing.
*
* @param dir The <code>File</code> instance for the directory being read
* @param name The name of the file to test
*
* @return <code>true</code> if the file should be included in the list,
* <code>false</code> otherwise.
*/
boolean accept(File dir, String name);
} // interface FilenameFilter

View File

@ -70,179 +70,171 @@ package java.io;
public class FilterInputStream extends InputStream
{
/*************************************************************************/
/*************************************************************************/
/*
* Instance Variables
*/
/*
* Instance Variables
*/
/**
* This is the subordinate <code>InputStream</code> to which method calls
* are redirected
*/
protected InputStream in;
/**
* This is the subordinate <code>InputStream</code> to which method calls
* are redirected
*/
protected InputStream in;
/*************************************************************************/
/*************************************************************************/
/*
* Constructors
*/
/*
* Constructors
*/
/**
* Create a <code>FilterInputStream</code> with the specified subordinate
* <code>InputStream</code>.
*
* @param in The subordinate <code>InputStream</code>
*/
protected
FilterInputStream(InputStream in)
{
this.in = in;
}
/**
* Create a <code>FilterInputStream</code> with the specified subordinate
* <code>InputStream</code>.
*
* @param in The subordinate <code>InputStream</code>
*/
protected FilterInputStream(InputStream in)
{
this.in = in;
}
/*************************************************************************/
/*************************************************************************/
/*
* Instance Methods
*/
/*
* Instance Methods
*/
/**
* Calls the <code>in.mark(int)</code> method.
*
* @param readlimit The parameter passed to <code>in.mark(int)</code>
*/
public void
mark(int readlimit)
{
in.mark(readlimit);
}
/**
* Calls the <code>in.mark(int)</code> method.
*
* @param readlimit The parameter passed to <code>in.mark(int)</code>
*/
public void mark(int readlimit)
{
in.mark(readlimit);
}
/*************************************************************************/
/*************************************************************************/
/**
* Calls the <code>in.markSupported()</code> method.
*
* @return <code>true</code> if mark/reset is supported, <code>false</code>
* otherwise
*/
public boolean
markSupported()
{
return(in.markSupported());
}
/**
* Calls the <code>in.markSupported()</code> method.
*
* @return <code>true</code> if mark/reset is supported, <code>false</code>
* otherwise
*/
public boolean markSupported()
{
return(in.markSupported());
}
/*************************************************************************/
/*************************************************************************/
/**
* Calls the <code>in.reset()</code> method.
*
* @exception IOException If an error occurs
*/
public void
reset() throws IOException
{
in.reset();
}
/**
* Calls the <code>in.reset()</code> method.
*
* @exception IOException If an error occurs
*/
public void reset() throws IOException
{
in.reset();
}
/*************************************************************************/
/*************************************************************************/
/**
* Calls the <code>in.available()</code> method.
*
* @return The value returned from <code>in.available()</code>
*
* @exception IOException If an error occurs
*/
public int
available() throws IOException
{
return(in.available());
}
/**
* Calls the <code>in.available()</code> method.
*
* @return The value returned from <code>in.available()</code>
*
* @exception IOException If an error occurs
*/
public int available() throws IOException
{
return(in.available());
}
/*************************************************************************/
/*************************************************************************/
/**
* Calls the <code>in.skip(long)</code> method
*
* @param The requested number of bytes to skip.
*
* @return The value returned from <code>in.skip(long)</code>
*
* @exception IOException If an error occurs
*/
public long
skip(long num_bytes) throws IOException
{
return(in.skip(num_bytes));
}
/**
* Calls the <code>in.skip(long)</code> method
*
* @param numBytes The requested number of bytes to skip.
*
* @return The value returned from <code>in.skip(long)</code>
*
* @exception IOException If an error occurs
*/
public long skip(long num_bytes) throws IOException
{
return(in.skip(num_bytes));
}
/*************************************************************************/
/*************************************************************************/
/**
* Calls the <code>in.read()</code> method
*
* @return The value returned from <code>in.read()</code>
*
* @exception IOException If an error occurs
*/
public int
read() throws IOException
{
return(in.read());
}
/**
* Calls the <code>in.read()</code> method
*
* @return The value returned from <code>in.read()</code>
*
* @exception IOException If an error occurs
*/
public int read() throws IOException
{
return(in.read());
}
/*************************************************************************/
/*************************************************************************/
/**
* Calls the <code>read(byte[], int, int)</code> overloaded method. Note that
* this method does not redirect its call directly to a corresponding
* method in <code>in</code>. This allows subclasses to override only the
* three argument version of <code>read</code>.
*
* @param buf The buffer to read bytes into
*
* @return The value retured from <code>in.read(byte[], int, int)</code>
*
* @exception IOException If an error occurs
*/
public int
read(byte[] buf) throws IOException
{
return(read(buf, 0, buf.length));
}
/**
* Calls the <code>read(byte[], int, int)</code> overloaded method.
* Note that
* this method does not redirect its call directly to a corresponding
* method in <code>in</code>. This allows subclasses to override only the
* three argument version of <code>read</code>.
*
* @param buf The buffer to read bytes into
*
* @return The value retured from <code>in.read(byte[], int, int)</code>
*
* @exception IOException If an error occurs
*/
public int read(byte[] buf) throws IOException
{
return(read(buf, 0, buf.length));
}
/*************************************************************************/
/*************************************************************************/
/**
* Calls the <code>in.read(byte[], int, int)</code> method.
*
* @param buf The buffer to read bytes into
* @param offset The index into the buffer to start storing bytes
* @param len The maximum number of bytes to read.
*
* @return The value retured from <code>in.read(byte[], int, int)</code>
*
* @exception IOException If an error occurs
*/
public int
read(byte[] buf, int offset, int len) throws IOException
{
return(in.read(buf, offset, len));
}
/**
* Calls the <code>in.read(byte[], int, int)</code> method.
*
* @param buf The buffer to read bytes into
* @param offset The index into the buffer to start storing bytes
* @param len The maximum number of bytes to read.
*
* @return The value retured from <code>in.read(byte[], int, int)</code>
*
* @exception IOException If an error occurs
*/
public int read(byte[] buf, int offset, int len) throws IOException
{
return(in.read(buf, offset, len));
}
/*************************************************************************/
/*************************************************************************/
/**
* This method closes the input stream by closing the input stream that
* this object is filtering. Future attempts to access this stream may
* throw an exception.
*
* @exception IOException If an error occurs
*/
public void
close() throws IOException
{
in.close();
}
/**
* This method closes the input stream by closing the input stream that
* this object is filtering. Future attempts to access this stream may
* throw an exception.
*
* @exception IOException If an error occurs
*/
public void close() throws IOException
{
in.close();
}
} // class FilterInputStream

View File

@ -1,5 +1,5 @@
/* FilterOutputStream.java -- Parent class for output streams that filter
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -57,126 +57,121 @@ package java.io;
public class FilterOutputStream extends OutputStream
{
/*************************************************************************/
/*************************************************************************/
/*
* Instance Variables
*/
/*
* Instance Variables
*/
/**
* This is the subordinate <code>OutputStream</code> that this class
* redirects its method calls to.
*/
protected OutputStream out;
/**
* This is the subordinate <code>OutputStream</code> that this class
* redirects its method calls to.
*/
protected OutputStream out;
/*************************************************************************/
/*************************************************************************/
/*
* Constructors
*/
/*
* Constructors
*/
/**
* This method initializes an instance of <code>FilterOutputStream</code>
* to write to the specified subordinate <code>OutputStream</code>.
*
* @param out The <code>OutputStream</code> to write to
*/
public
FilterOutputStream(OutputStream out)
{
this.out = out;
}
/**
* This method initializes an instance of <code>FilterOutputStream</code>
* to write to the specified subordinate <code>OutputStream</code>.
*
* @param out The <code>OutputStream</code> to write to
*/
public FilterOutputStream(OutputStream out)
{
this.out = out;
}
/*************************************************************************/
/*************************************************************************/
/*
* Instance Methods
*/
/*
* Instance Methods
*/
/**
* This method closes the underlying <code>OutputStream</code>. Any
* further attempts to write to this stream may throw an exception.
*
* @exception IOException If an error occurs
*/
public void
close() throws IOException
{
flush();
out.close();
}
/**
* This method closes the underlying <code>OutputStream</code>. Any
* further attempts to write to this stream may throw an exception.
*
* @exception IOException If an error occurs
*/
public void close() throws IOException
{
flush();
out.close();
}
/*************************************************************************/
/*************************************************************************/
/**
* This method attempt to flush all buffered output to be written to the
* underlying output sink.
*
* @exception IOException If an error occurs
*/
public void
flush() throws IOException
{
out.flush();
}
/**
* This method attempt to flush all buffered output to be written to the
* underlying output sink.
*
* @exception IOException If an error occurs
*/
public void flush() throws IOException
{
out.flush();
}
/*************************************************************************/
/*************************************************************************/
/**
* This method writes a single byte of output to the underlying
* <code>OutputStream</code>.
*
* @param b The byte to write, passed as an int.
*
* @exception IOException If an error occurs
*/
public void
write(int b) throws IOException
{
out.write(b);
}
/**
* This method writes a single byte of output to the underlying
* <code>OutputStream</code>.
*
* @param b The byte to write, passed as an int.
*
* @exception IOException If an error occurs
*/
public void write(int b) throws IOException
{
out.write(b);
}
/*************************************************************************/
/*************************************************************************/
/**
* This method writes all the bytes in the specified array to the underlying
* <code>OutputStream</code>. It does this by calling the three parameter
* version of this method - <code>write(byte[], int, int)</code> in this
* class instead of writing to the underlying <code>OutputStream</code>
* directly. This allows most subclasses to avoid overriding this method.
*
* @param buf The byte array to write bytes from
*
* @exception IOException If an error occurs
*/
public void
write(byte[] buf) throws IOException
{
// Don't do checking here, per Java Lang Spec.
write(buf, 0, buf.length);
}
/**
* This method writes all the bytes in the specified array to the underlying
* <code>OutputStream</code>. It does this by calling the three parameter
* version of this method - <code>write(byte[], int, int)</code> in this
* class instead of writing to the underlying <code>OutputStream</code>
* directly. This allows most subclasses to avoid overriding this method.
*
* @param buf The byte array to write bytes from
*
* @exception IOException If an error occurs
*/
public void write(byte[] buf) throws IOException
{
// Don't do checking here, per Java Lang Spec.
write(buf, 0, buf.length);
}
/*************************************************************************/
/*************************************************************************/
/**
* This method calls the <code>write(int)</code> method <code>len</code>
* times for all bytes from the array <code>buf</code> starting at index
* <code>offset</code>. Subclasses should overwrite this method to get a
* more efficient implementation.
*
* @param buf The byte array to write bytes from
* @param offset The index into the array to start writing bytes from
* @param len The number of bytes to write
*
* @exception IOException If an error occurs
*/
public void
write(byte[] buf, int offset, int len) throws IOException
{
// Don't do checking here, per Java Lang Spec.
for (int i=0; i < len; i++)
write(buf[offset + i]);
/**
* This method calls the <code>write(int)</code> method <code>len</code>
* times for all bytes from the array <code>buf</code> starting at index
* <code>offset</code>. Subclasses should overwrite this method to get a
* more efficient implementation.
*
* @param buf The byte array to write bytes from
* @param offset The index into the array to start writing bytes from
* @param len The number of bytes to write
*
* @exception IOException If an error occurs
*/
public void write(byte[] buf, int offset, int len) throws IOException
{
// Don't do checking here, per Java Lang Spec.
for (int i=0; i < len; i++)
write(buf[offset + i]);
}
}
} // class FilterOutputStream

View File

@ -1,5 +1,5 @@
/* FilterReader.java -- Base class for char stream classes that filter input
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -63,163 +63,153 @@ package java.io;
*/
public abstract class FilterReader extends Reader
{
/*
* Instance Variables
*/
/*************************************************************************/
/**
* This is the subordinate <code>Reader</code> to which method calls
* are redirected
*/
protected Reader in;
/*
* Instance Variables
*/
/*************************************************************************/
/**
* This is the subordinate <code>Reader</code> to which method calls
* are redirected
*/
protected Reader in;
/*
* Constructors
*/
/*************************************************************************/
/**
* Create a <code>FilterReader</code> with the specified subordinate
* <code>Reader</code>.
* The <code>lock</code> of the new <code>FilterReader</code> will be set
* to <code>in.lock</code>.
*
* @param in The subordinate <code>Reader</code>
*/
protected FilterReader(Reader in)
{
super(in.lock);
this.in = in;
}
/*
* Constructors
*/
/*************************************************************************/
/**
* Create a <code>FilterReader</code> with the specified subordinate
* <code>Reader</code>.
* The <code>lock</code> of the new <code>FilterReader</code> will be set
* to <code>in.lock</code>.
*
* @param in The subordinate <code>Reader</code>
*/
protected
FilterReader(Reader in)
{
super(in.lock);
this.in = in;
}
/*
* Instance Methods
*/
/*************************************************************************/
/**
* Calls the <code>in.mark(int)</code> method.
*
* @param readlimit The parameter passed to <code>in.mark(int)</code>
*
* @exception IOException If an error occurs
*/
public void mark(int readlimit) throws IOException
{
in.mark(readlimit);
}
/*
* Instance Methods
*/
/*************************************************************************/
/**
* Calls the <code>in.mark(int)</code> method.
*
* @param readlimit The parameter passed to <code>in.mark(int)</code>
*
* @exception IOException If an error occurs
*/
public void
mark(int readlimit) throws IOException
{
in.mark(readlimit);
}
/**
* Calls the <code>in.markSupported()</code> method.
*
* @return <code>true</code> if mark/reset is supported,
* <code>false</code> otherwise
*/
public boolean markSupported()
{
return(in.markSupported());
}
/*************************************************************************/
/*************************************************************************/
/**
* Calls the <code>in.markSupported()</code> method.
*
* @return <code>true</code> if mark/reset is supported, <code>false</code> otherwise
*/
public boolean
markSupported()
{
return(in.markSupported());
}
/**
* Calls the <code>in.reset()</code> method.
*
* @exception IOException If an error occurs
*/
public void reset() throws IOException
{
in.reset();
}
/*************************************************************************/
/*************************************************************************/
/**
* Calls the <code>in.reset()</code> method.
*
* @exception IOException If an error occurs
*/
public void
reset() throws IOException
{
in.reset();
}
/**
* Calls the <code>in.read()</code> method.
*
* @return The value returned from <code>in.available()</code>
*
* @exception IOException If an error occurs
*/
public boolean ready() throws IOException
{
return(in.ready());
}
/*************************************************************************/
/*************************************************************************/
/**
* Calls the <code>in.read()</code> method.
*
* @return The value returned from <code>in.available()</code>
*
* @exception IOException If an error occurs
*/
public boolean
ready() throws IOException
{
return(in.ready());
}
/**
* Calls the <code>in.skip(long)</code> method
*
* @param numBytes The requested number of chars to skip.
*
* @return The value returned from <code>in.skip(long)</code>
*
* @exception IOException If an error occurs
*/
public long skip(long num_chars) throws IOException
{
return(in.skip(num_chars));
}
/*************************************************************************/
/*************************************************************************/
/**
* Calls the <code>in.skip(long)</code> method
*
* @param The requested number of chars to skip.
*
* @return The value returned from <code>in.skip(long)</code>
*
* @exception IOException If an error occurs
*/
public long
skip(long num_chars) throws IOException
{
return(in.skip(num_chars));
}
/**
* Calls the <code>in.read()</code> method
*
* @return The value returned from <code>in.read()</code>
*
* @exception IOException If an error occurs
*/
public int read() throws IOException
{
return(in.read());
}
/*************************************************************************/
/*************************************************************************/
/**
* Calls the <code>in.read()</code> method
*
* @return The value returned from <code>in.read()</code>
*
* @exception IOException If an error occurs
*/
public int
read() throws IOException
{
return(in.read());
}
/**
* Calls the <code>in.read(char[], int, int)</code> method.
*
* @param buf The buffer to read chars into
* @param offset The index into the buffer to start storing chars
* @param len The maximum number of chars to read.
*
* @return The value retured from <code>in.read(char[], int, int)</code>
*
* @exception IOException If an error occurs
*/
public int read(char[] buf, int offset, int len) throws IOException
{
return(in.read(buf, offset, len));
}
/*************************************************************************/
/*************************************************************************/
/**
* Calls the <code>in.read(char[], int, int)</code> method.
*
* @param buf The buffer to read chars into
* @param offset The index into the buffer to start storing chars
* @param len The maximum number of chars to read.
*
* @return The value retured from <code>in.read(char[], int, int)</code>
*
* @exception IOException If an error occurs
*/
public int
read(char[] buf, int offset, int len) throws IOException
{
return(in.read(buf, offset, len));
}
/*************************************************************************/
/**
* This method closes the stream by calling the <code>close()</code> method
* of the underlying stream.
*
* @exception IOException If an error occurs
*/
public void
close() throws IOException
{
in.close();
}
/**
* This method closes the stream by calling the <code>close()</code> method
* of the underlying stream.
*
* @exception IOException If an error occurs
*/
public void close() throws IOException
{
in.close();
}
} // class FilterReader

View File

@ -1,5 +1,5 @@
/* 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.
@ -52,128 +52,120 @@ package java.io;
* underlying stream. Subclasses provide actual filtering.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Tom Tromey <tromey@cygnus.com>
* @author Tom Tromey <tromey@cygnus.com>
*/
public abstract class FilterWriter extends Writer
{
/*
* Instance Variables
*/
/*************************************************************************/
/**
* This is the subordinate <code>Writer</code> that this class
* redirects its method calls to.
*/
protected Writer out;
/*
* Instance Variables
*/
/*************************************************************************/
/**
* This is the subordinate <code>Writer</code> that this class
* redirects its method calls to.
*/
protected Writer out;
/*
* Constructors
*/
/*************************************************************************/
/**
* This method initializes an instance of <code>FilterWriter</code>
* to write to the specified subordinate <code>Writer</code>.
* The given <code>Writer</code> will be used as <code>lock</code> for
* the newly created <code>FilterWriter</code>.
*
* @param out The <code>Writer</code> to write to
*/
protected FilterWriter(Writer out)
{
super(out);
this.out = out;
}
/*
* Constructors
*/
/*************************************************************************/
/**
* This method initializes an instance of <code>FilterWriter</code>
* to write to the specified subordinate <code>Writer</code>.
* The given <code>Writer</code> will be used as <code>lock</code> for
* the newly created <code>FilterWriter</code>.
*
* @param out The <code>Writer</code> to write to
*/
protected
FilterWriter(Writer out)
{
super(out);
this.out = out;
}
/*
* Instance Methods
*/
/*************************************************************************/
/**
* This method closes the underlying <code>Writer</code>. Any
* further attempts to write to this stream may throw an exception.
*
* @exception IOException If an error occurs
*/
public void close() throws IOException
{
out.close();
}
/*
* Instance Methods
*/
/*************************************************************************/
/**
* This method closes the underlying <code>Writer</code>. Any
* further attempts to write to this stream may throw an exception.
*
* @exception IOException If an error occurs
*/
public void
close() throws IOException
{
out.close();
}
/**
* This method attempt to flush all buffered output to be written to the
* underlying output sink.
*
* @exception IOException If an error occurs
*/
public void flush() throws IOException
{
out.flush();
}
/*************************************************************************/
/*************************************************************************/
/**
* This method attempt to flush all buffered output to be written to the
* underlying output sink.
*
* @exception IOException If an error occurs
*/
public void
flush() throws IOException
{
out.flush();
}
/**
* This method writes a single char of output to the underlying
* <code>Writer</code>.
*
* @param b The char to write, passed as an int.
*
* @exception IOException If an error occurs
*/
public void write(int b) throws IOException
{
out.write(b);
}
/*************************************************************************/
/*************************************************************************/
/**
* This method writes a single char of output to the underlying
* <code>Writer</code>.
*
* @param b The char to write, passed as an int.
*
* @exception IOException If an error occurs
*/
public void
write(int b) throws IOException
{
out.write(b);
}
/**
* This method writes <code>len</code> chars from the array <code>buf</code>
* starting at index <code>offset</code> to the underlying
* <code>Writer</code>.
*
* @param buf The char array to write chars from
* @param offset The index into the array to start writing chars from
* @param len The number of chars to write
*
* @exception IOException If an error occurs
*/
public void write(char[] buf, int offset, int len) throws IOException
{
out.write(buf, offset, len);
}
/*************************************************************************/
/*************************************************************************/
/**
* This method writes <code>len</code> chars from the array <code>buf</code>
* starting at index <code>offset</code> to the underlying
* <code>Writer</code>.
*
* @param buf The char array to write chars from
* @param offset The index into the array to start writing chars from
* @param len The number of chars to write
*
* @exception IOException If an error occurs
*/
public void
write(char[] buf, int offset, int len) throws IOException
{
out.write(buf, offset, len);
}
/*************************************************************************/
/**
* This method writes <code>len</code> chars from the <code>String</code>
* starting at position <code>offset</code>.
*
* @param str The <code>String</code> that is to be written
* @param offset The character offset into the <code>String</code> to start writing from
* @param len The number of chars to write
*
* @exception IOException If an error occurs
*/
public void
write(String str, int offset, int len) throws IOException
{
out.write(str, offset, len);
}
/**
* This method writes <code>len</code> chars from the <code>String</code>
* starting at position <code>offset</code>.
*
* @param str The <code>String</code> that is to be written
* @param offset The character offset into the <code>String</code>
* to start writing from
* @param len The number of chars to write
*
* @exception IOException If an error occurs
*/
public void write(String str, int offset, int len) throws IOException
{
out.write(str, offset, len);
}
} // class FilterWriter

View File

@ -1,5 +1,5 @@
/* ObjectInput.java -- Read object data from a stream
Copyright (C) 1998 Free Software Foundation, Inc.
Copyright (C) 1998,2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -44,115 +44,108 @@ package java.io;
* also has methods that allow input to be done in a manner similar to
* <code>InputStream</code>
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public interface ObjectInput extends DataInput
{
/**
* This method returns the number of bytes that can be read without
* blocking.
*
* @return The number of bytes available before blocking
*
* @exception IOException If an error occurs
*/
public abstract int available() throws IOException;
/**
* This method returns the number of bytes that can be read without
* blocking.
*
* @return The number of bytes available before blocking
*
* @exception IOException If an error occurs
*/
public abstract int
available() throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
* This method reading a byte of data from a stream. It returns that byte
* as an int. This method blocks if no data is available to be read.
*
* @return The byte of data read
*
* @exception IOException If an error occurs
*/
public abstract int read() throws IOException;
/**
* This method reading a byte of data from a stream. It returns that byte
* as an int. This method blocks if no data is available to be read.
*
* @return The byte of data read
*
* @exception IOException If an error occurs
*/
public abstract int
read() throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
* This method reads raw bytes and stores them them a byte array buffer.
* Note that this method will block if no data is available. However,
* it will not necessarily block until it fills the entire buffer. That is,
* a "short count" is possible.
*
* @param buf The byte array to receive the data read
*
* @return The actual number fo bytes read or -1 if end of stream
*
* @exception IOException If an error occurs
*/
public abstract int read(byte[] buf) throws IOException;
/**
* This method reads raw bytes and stores them them a byte array buffer.
* Note that this method will block if no data is available. However,
* it will not necessarily block until it fills the entire buffer. That is,
* a "short count" is possible.
*
* @param buf The byte array to receive the data read
*
* @return The actual number fo bytes read or -1 if end of stream
*
* @exception IOException If an error occurs
*/
public abstract int
read(byte[] buf) throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
* This method reads raw bytes and stores them in a byte array buffer
* <code>buf</code> starting at position <code>offset</code> into the
* buffer. A
* maximum of <code>len</code> bytes will be read. Note that this method
* blocks if no data is available, but will not necessarily block until
* it can read <code>len</code> bytes of data. That is, a "short count" is
* possible.
*
* @param buf The byte array to receive the data read
* @param offset The offset into @code{buf} to start storing data
* @param len The maximum number of bytes to read
*
* @return The actual number fo bytes read or -1 if end of stream
*
* @exception IOException If an error occurs
*/
public abstract int read(byte[] buf, int offset, int len) throws IOException;
/**
* This method reads raw bytes and stores them in a byte array buffer
* <code>buf</code> starting at position <code>offset</code> into the buffer. A
* maximum of <code>len</code> bytes will be read. Note that this method
* blocks if no data is available, but will not necessarily block until
* it can read <code>len</code> bytes of data. That is, a "short count" is
* possible.
*
* @param buf The byte array to receive the data read
* @param offset The offset into @code{buf} to start storing data
* @param len The maximum number of bytes to read
*
* @return The actual number fo bytes read or -1 if end of stream
*
* @exception IOException If an error occurs
*/
public abstract int
read(byte[] buf, int offset, int len) throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
* Reads an object instance and returns it. If the class for the object
* being read cannot be found, then a ClassNotFoundException will
* be thrown.
*
* @return The object instance that was read
*
* @exception ClassNotFoundException If a class for the object cannot be
* found
* @exception IOException If an error occurs
*/
public abstract Object readObject()
throws ClassNotFoundException, IOException;
/**
* Reads an object instance and returns it. If the class for the object
* being read cannot be found, then a ClassNotFoundException will
* be thrown.
*
* @return The object instance that was read
*
* @exception ClassNotFoundException If a class for the object cannot be found
* @exception IOException If an error occurs
*/
public abstract Object
readObject() throws ClassNotFoundException, IOException;
/*************************************************************************/
/*************************************************************************/
/**
* This method causes the specified number of bytes to be read and
* discarded. It is possible that fewer than the requested number of bytes
* will actually be skipped.
*
* @param numBytes The number of bytes to skip
*
* @return The actual number of bytes skipped
*
* @exception IOException If an error occurs
*/
public abstract long skip(long num_bytes) throws IOException;
/**
* This method causes the specified number of bytes to be read and
* discarded. It is possible that fewer than the requested number of bytes
* will actually be skipped.
*
* @param num_bytes The number of bytes to skip
*
* @return The actual number of bytes skipped
*
* @exception IOException If an error occurs
*/
public abstract long
skip(long num_bytes) throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
* This method closes the input source
*
* @exception IOException If an error occurs
*/
public abstract void
close() throws IOException;
/**
* This method closes the input source
*
* @exception IOException If an error occurs
*/
public abstract void close() throws IOException;
} // interface ObjectInput

View File

@ -1,5 +1,5 @@
/* ObjectInputValidation.java -- Validate an object
Copyright (C) 1998 Free Software Foundation, Inc.
Copyright (C) 1998, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -41,21 +41,18 @@ package java.io;
/**
* What does this interface really do?
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public interface ObjectInputValidation
{
/**
* This method is called to validate an object. If the object is invalid
* an exception is thrown.
*
* @exception InvalidObjectException If the object is invalid
*/
public abstract void
validateObject() throws InvalidObjectException;
/**
* This method is called to validate an object. If the object is invalid
* an exception is thrown.
*
* @exception InvalidObjectException If the object is invalid
*/
public abstract void validateObject() throws InvalidObjectException;
} // interface ObjectInputValidation

View File

@ -1,5 +1,5 @@
/* ObjectOutput.java -- Interface for writing objects to a stream
Copyright (C) 1998 Free Software Foundation, Inc.
Copyright (C) 1998, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -41,87 +41,80 @@ package java.io;
/**
* This interface extends <code>DataOutput</code> to provide the additional
* facility of writing object instances to a stream. It also adds some
* additional methods to make the interface more <code>OutputStream</code> like.
*
* @version 0.0
* additional methods to make the interface more
* <code>OutputStream</code> like.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public interface ObjectOutput extends DataOutput
{
/**
* This method writes the specified byte to the output stream.
*
* @param b The byte to write.
*
* @exception IOException If an error occurs.
*/
public abstract void write(int b) throws IOException;
/**
* This method writes the specified byte to the output stream.
*
* @param b The byte to write.
*
* @exception IOException If an error occurs.
*/
public abstract void
write(int b) throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
* This method writes all the bytes in the specified byte array to the
* output stream.
*
* @param buf The array of bytes to write.
*
* @exception IOException If an error occurs.
*/
public abstract void write(byte[] buf) throws IOException;
/**
* This method writes all the bytes in the specified byte array to the
* output stream.
*
* @param buf The array of bytes to write.
*
* @exception IOException If an error occurs.
*/
public abstract void
write(byte[] buf) throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
* This method writes <code>len</code> bytes from the specified array
* starting at index <code>offset</code> into that array.
*
* @param buf The byte array to write from.
* @param offset The index into the byte array to start writing from.
* @param len The number of bytes to write.
*
* @exception IOException If an error occurs.
*/
public abstract void write(byte[] buf, int offset, int len)
throws IOException;
/**
* This method writes <code>len</code> bytes from the specified array
* starting at index <code>offset</code> into that array.
*
* @param buf The byte array to write from.
* @param offset The index into the byte array to start writing from.
* @param len The number of bytes to write.
*
* @exception IOException If an error occurs.
*/
public abstract void
write(byte[] buf, int offset, int len) throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
* This method writes a object instance to a stream. The format of the
* data written is determined by the actual implementation of this method
*
* @param obj The object to write
*
* @exception IOException If an error occurs
*/
public abstract void writeObject(Object obj) throws IOException;
/**
* This method writes a object instance to a stream. The format of the
* data written is determined by the actual implementation of this method
*
* @param obj The object to write
*
* @exception IOException If an error occurs
*/
public abstract void
writeObject(Object obj) throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
* This method causes any buffered data to be flushed out to the underlying
* stream
*
* @exception IOException If an error occurs
*/
public abstract void flush() throws IOException;
/**
* This method causes any buffered data to be flushed out to the underlying
* stream
*
* @exception IOException If an error occurs
*/
public abstract void
flush() throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
* This method closes the underlying stream.
*
* @exception IOException If an error occurs
*/
public abstract void
close() throws IOException;
/**
* This method closes the underlying stream.
*
* @exception IOException If an error occurs
*/
public abstract void close() throws IOException;
} // interface ObjectOutput

View File

@ -1,5 +1,5 @@
/* ObjectStreamField.java -- Class used to store name and class of fields
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -51,17 +51,21 @@ public class ObjectStreamField implements java.lang.Comparable
}
/**
* There're many cases you can't get java.lang.Class from typename if your context
* There're many cases you can't get java.lang.Class from typename
* if your context
* class loader can't load it, then use typename to construct the field
*/
ObjectStreamField (String name, String typename){
this.name = name;
this.typename = typename;
try{
type = TypeSignature.getClassForEncoding(typename);
}catch(ClassNotFoundException e){
type = Object.class; //??
}
try
{
type = TypeSignature.getClassForEncoding(typename);
}
catch(ClassNotFoundException e)
{
type = Object.class; //FIXME: ???
}
}
public String getName ()
@ -125,3 +129,4 @@ public class ObjectStreamField implements java.lang.Comparable
private String typename;
private int offset = -1; // XXX make sure this is correct
}

View File

@ -1,5 +1,5 @@
/* PipedInputStream.java -- Read portion of piped streams.
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -46,7 +46,8 @@ package java.io;
* to which it is connected.
* <p>
* Data is read and written to an internal buffer. It is highly recommended
* that the <code>PipedInputStream</code> and connected <code>PipedOutputStream</code>
* that the <code>PipedInputStream</code> and connected
* <code>PipedOutputStream</code>
* be part of different threads. If they are not, the read and write
* operations could deadlock their thread.
*
@ -113,7 +114,8 @@ public class PipedInputStream extends InputStream
* it to the passed in <code>PipedOutputStream</code>. The stream is then
* ready for reading.
*
* @param source The <code>PipedOutputStream</code> to connect this stream to
* @param source The <code>PipedOutputStream</code> to connect this
* stream to
*
* @exception IOException If <code>source</code> is already connected.
*/
@ -123,7 +125,8 @@ public class PipedInputStream extends InputStream
}
/**
* This method connects this stream to the passed in <code>PipedOutputStream</code>.
* This method connects this stream to the passed in
* <code>PipedOutputStream</code>.
* This stream is then ready for reading. If this stream is already
* connected or has been previously closed, then an exception is thrown
*
@ -224,9 +227,12 @@ public class PipedInputStream extends InputStream
/**
* This method reads bytes from the stream into a caller supplied buffer.
* It starts storing bytes at position <code>offset</code> into the buffer and
* reads a maximum of <code>len</code> bytes. Note that this method can actually
* read fewer than <code>len</code> bytes. The actual number of bytes read is
* It starts storing bytes at position <code>offset</code> into the
* buffer and
* reads a maximum of <code>len</code> bytes. Note that this method
* can actually
* read fewer than <code>len</code> bytes. The actual number of bytes
* read is
* returned. A -1 is returned to indicated that no bytes can be read
* because the end of the stream was reached. If the stream is already
* closed, a -1 will again be returned to indicate the end of the stream.
@ -255,9 +261,12 @@ public class PipedInputStream extends InputStream
/**
* This method reads bytes from the stream into a caller supplied buffer.
* It starts storing bytes at position <code>offset</code> into the buffer and
* reads a maximum of <code>len</code> bytes. Note that this method can actually
* read fewer than <code>len</code> bytes. The actual number of bytes read is
* It starts storing bytes at position <code>offset</code> into the
* buffer and
* reads a maximum of <code>len</code> bytes. Note that this method
* can actually
* read fewer than <code>len</code> bytes. The actual number of bytes
* read is
* returned. A -1 is returned to indicated that no bytes can be read
* because the end of the stream was reached - ie close() was called on the
* connected PipedOutputStream.
@ -371,3 +380,4 @@ public class PipedInputStream extends InputStream
notifyAll();
}
}

View File

@ -118,7 +118,8 @@ public class PipedReader extends Reader
}
/**
* This method connects this stream to the passed in <code>PipedWriter</code>.
* This method connects this stream to the passed in
* <code>PipedWriter</code>.
* This stream is then ready for reading. If this stream is already
* connected or has been previously closed, then an exception is thrown
*
@ -207,9 +208,12 @@ public class PipedReader extends Reader
/**
* This method reads chars from the stream into a caller supplied buffer.
* It starts storing chars at position <code>offset</code> into the buffer and
* reads a maximum of <code>len</code> chars. Note that this method can actually
* read fewer than <code>len</code> chars. The actual number of chars read is
* It starts storing chars at position <code>offset</code> into the
* buffer and
* reads a maximum of <code>len</code> chars. Note that this method
* can actually
* read fewer than <code>len</code> chars. The actual number of chars
* read is
* returned. A -1 is returned to indicated that no chars can be read
* because the end of the stream was reached. If the stream is already
* closed, a -1 will again be returned to indicate the end of the stream.
@ -237,10 +241,11 @@ public class PipedReader extends Reader
}
/**
* This method reads characters from the stream into a caller supplied buffer.
* It starts storing chars at position <code>offset</code> into the buffer and
* reads a maximum of <code>len</code> chars. Note that this method can actually
* read fewer than <code>len</code> chars. The actual number of chars read is
* This method reads characters from the stream into a caller supplied
* buffer. It starts storing chars at position <code>offset</code> into
* the buffer and reads a maximum of <code>len</code> chars. Note that
* this method can actually read fewer than <code>len</code> chars.
* The actual number of chars read is
* returned. A -1 is returned to indicated that no chars can be read
* because the end of the stream was reached - ie close() was called on the
* connected PipedWriter.
@ -361,3 +366,4 @@ public class PipedReader extends Reader
}
}
}

View File

@ -48,8 +48,6 @@ package java.io;
* class which also auto-flushes when it encounters a newline character
* in the chars written).
*
* @version 0.0
*
* @author Per Bothner <bothner@cygnus.com>
* @author Aaron M. Renn (arenn@urbanophile.com)
* @date April 17, 1998.
@ -99,7 +97,8 @@ public class PrintWriter extends Writer
* every line is terminated or newline character is written.
*
* @param wr The <code>Writer</code> to write to.
* @param autoflush <code>true</code> to flush the stream after every line, <code>false</code> otherwise
* @param autoflush <code>true</code> to flush the stream after every
* line, <code>false</code> otherwise
*/
public PrintWriter(Writer wr, boolean autoflush)
{
@ -130,7 +129,8 @@ public class PrintWriter extends Writer
* constructor allows auto-flush functionality to be enabled if desired
*
* @param out The <code>OutputStream</code> to write to
* @param autoflush <code>true</code> to flush the stream after every <code>println</code> call, <code>false</code> otherwise.
* @param autoflush <code>true</code> to flush the stream after every
* <code>println</code> call, <code>false</code> otherwise.
*/
public PrintWriter(OutputStream out, boolean autoflush)
{
@ -153,7 +153,8 @@ public class PrintWriter extends Writer
* <code>true</code> forever for this stream. Before checking for an
* error condition, this method flushes the stream.
*
* @return <code>true</code> if an error has occurred, <code>false</code> otherwise
* @return <code>true</code> if an error has occurred,
* <code>false</code> otherwise
*/
public boolean checkError()
{
@ -309,7 +310,7 @@ public class PrintWriter extends Writer
* This is the system dependent line separator
*/
private static final char[] line_separator
= System.getProperty("line.separator").toCharArray();
= System.getProperty("line.separator").toCharArray();
/**
* This method prints a line separator sequence to the stream. The value
@ -567,3 +568,4 @@ public class PrintWriter extends Writer
write(str, 0, str.length());
}
}

View File

@ -1,5 +1,5 @@
/* PushbackReader.java -- An character stream that can unread chars
Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc.
Copyright (C) 1998, 2000, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -48,8 +48,6 @@ package java.io;
* The default pushback buffer size one char, but this can be overridden
* by the creator of the stream.
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Warren Levy <warrenl@cygnus.com>
*/
@ -136,7 +134,8 @@ public class PushbackReader extends FilterReader
* This method returns <code>false</code> to indicate that it does not support
* mark/reset functionality.
*
* @return This method returns <code>false</code> to indicate that this class does not support mark/reset functionality
* @return This method returns <code>false</code> to indicate that this
* class does not support mark/reset functionality
*
*/
public boolean markSupported()
@ -165,7 +164,8 @@ public class PushbackReader extends FilterReader
* read in the pushback buffer or if the underlying stream is ready to
* be read.
*
* @return <code>true</code> if this stream is ready to be read, <code>false</code> otherwise
* @return <code>true</code> if this stream is ready to be read,
* <code>false</code> otherwise
*
* @exception IOException If an error occurs
*/
@ -252,7 +252,8 @@ public class PushbackReader extends FilterReader
/**
* This method read chars from a stream and stores them into a caller
* supplied buffer. It starts storing the data at index <code>offset</code> into
* supplied buffer. It starts storing the data at index <code>offset</code>
* into
* the buffer and attempts to read <code>len</code> chars. This method can
* return before reading the number of chars requested. The actual number
* of chars read is returned as an int. A -1 is returned to indicate the
@ -302,8 +303,8 @@ public class PushbackReader extends FilterReader
* <p>
* If the pushback buffer is full, this method throws an exception.
* <p>
* The argument to this method is an <code>int</code>. Only the low eight bits
* of this value are pushed back.
* The argument to this method is an <code>int</code>. Only the low eight
* bits of this value are pushed back.
*
* @param b The char to be pushed back, passed as an int
*
@ -343,7 +344,8 @@ public class PushbackReader extends FilterReader
/**
* This method pushed back chars from the passed in array into the pushback
* buffer. The chars from <code>buf[offset]</code> to <code>buf[offset + len]</code>
* buffer. The chars from <code>buf[offset]</code> to
* <code>buf[offset + len]</code>
* are pushed in reverse order so that the next char read from the stream
* after this operation will be <code>buf[offset]</code> followed by
* <code>buf[offset + 1]</code>, etc.
@ -378,3 +380,4 @@ public class PushbackReader extends FilterReader
}
}
}

View File

@ -1,5 +1,5 @@
/* Reader.java -- base class of classes that read input as a stream of chars
Copyright (C) 1998, 1999, 2000 Free Software Foundation
Copyright (C) 1998, 1999, 2000, 2003 Free Software Foundation
This file is part of GNU Classpath.
@ -222,7 +222,8 @@ public abstract class Reader
* <p>
* This method always returns <code>false</code> in this class
*
* @return <code>true</code> if the stream is ready to be read, <code>false</code> otherwise.
* @return <code>true</code> if the stream is ready to be read,
* <code>false</code> otherwise.
*
* @exception IOException If an error occurs
*/

View File

@ -1,5 +1,5 @@
/* SerializablePermission.java -- Basic permissions related to serialization.
Copyright (C) 1998, 2000 Free Software Foundation, Inc.
Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -55,64 +55,63 @@ import java.security.BasicPermission;
*
* @see java.security.BasicPermission
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public final class SerializablePermission extends BasicPermission
{
static final long serialVersionUID = 8537212141160296410L;
/*
* Class Variables
*/
/*
* Class Variables
*/
private static final String[] legal_names = { "enableSubclassImplementation",
"enableSubstitution" };
/*************************************************************************/
private static final String[] legal_names = { "enableSubclassImplementation",
"enableSubstitution" };
/*************************************************************************/
/*
* Constructors
*/
/*
* Constructors
*/
/**
* This method initializes a new instance of <code>SerializablePermission</code>
* that has the specified name.
*
* @param name The name of the permission.
*
* @exception IllegalArgumentException If the name is not valid for this class.
*/
public
SerializablePermission(String name)
{
this(name, null);
}
/**
* This method initializes a new instance of
* <code>SerializablePermission</code>
* that has the specified name.
*
* @param name The name of the permission.
*
* @exception IllegalArgumentException If the name is not valid for
* this class.
*/
public SerializablePermission(String name)
{
this(name, null);
}
/*************************************************************************/
/*************************************************************************/
/**
* This method initializes a new instance of <code>SerializablePermission</code>
* that has the specified name and action list. Note that the action list
* is unused in this class.
*
* @param name The name of the permission.
* @param actions The action list (unused).
*
* @exception IllegalArgumentException If the name is not valid for this class.
*/
public
SerializablePermission(String name, String actions)
{
super(name, actions);
/**
* This method initializes a new instance of
* <code>SerializablePermission</code>
* that has the specified name and action list. Note that the action list
* is unused in this class.
*
* @param name The name of the permission.
* @param actions The action list (unused).
*
* @exception IllegalArgumentException If the name is not valid for
* this class.
*/
public SerializablePermission(String name, String actions)
{
super(name, actions);
for (int i = 0; i < legal_names.length; i++)
if (legal_names[i].equals(name))
return;
throw new IllegalArgumentException("Bad permission name: " + name);
}
for (int i = 0; i < legal_names.length; i++)
if (legal_names[i].equals(name))
return;
throw new IllegalArgumentException("Bad permission name: " + name);
}
} // class SerializablePermission

View File

@ -1,5 +1,5 @@
/* StringReader.java -- permits a String to be read as a character input stream
Copyright (C) 1998, 1999, 2000 Free Software Foundation
Copyright (C) 1998, 1999, 2000, 2003 Free Software Foundation
This file is part of GNU Classpath.
@ -51,8 +51,6 @@ package java.io;
* normal. If no mark has been set, then calling the <code>reset()</code>
* method rewinds the read pointer to the beginning of the <code>String</code>.
*
* @version 0.0
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Warren Levy <warrenl@cygnus.com>
* @date October 19, 1998.
@ -73,8 +71,8 @@ public class StringReader extends Reader
/**
* Create a new <code>StringReader</code> that will read chars from the
* passed in <code>String</code>. This stream will read from the beginning to the
* end of the <code>String</code>.
* passed in <code>String</code>. This stream will read from the beginning
* to the end of the <code>String</code>.
*
* @param s The <code>String</code> this stream will read from.
*/
@ -208,3 +206,4 @@ public class StringReader extends Reader
}
}
}

View File

@ -1,5 +1,5 @@
/* Writer.java -- Base class for character output streams
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -55,168 +55,161 @@ package java.io;
*/
public abstract class Writer
{
/**
* This is the object used to synchronize criticial code sections for
* thread safety. Subclasses should use this field instead of using
* synchronized methods or explicity synchronizations on <code>this</code>
*/
protected Object lock;
/*************************************************************************/
/*************************************************************************/
/**
* This is the object used to synchronize criticial code sections for
* thread safety. Subclasses should use this field instead of using
* synchronized methods or explicity synchronizations on <code>this</code>
*/
protected Object lock;
/*
* Constructors
*/
/*************************************************************************/
/**
* This is the default no-argument constructor for this class. This method
* will set up the class to synchronize criticial sections on itself.
*/
protected Writer()
{
lock = this;
}
/*
* Constructors
*/
/*************************************************************************/
/**
* This is the default no-argument constructor for this class. This method
* will set up the class to synchronize criticial sections on itself.
*/
protected
Writer()
{
lock = this;
}
/**
* This method initializes a <code>Writer</code> that will synchronize
* on the specified <code>Object</code>.
*
* @param obj The <code>Object</code> to use for synchronizing critical
* sections
*/
protected Writer(Object lock)
{
this.lock = lock;
}
/*************************************************************************/
/*************************************************************************/
/**
* This method initializes a <code>Writer</code> that will synchronize
* on the specified <code>Object</code>.
*
* @param obj The <code>Object</code> to use for synchronizing critical
* sections
*/
protected
Writer(Object lock)
{
this.lock = lock;
}
/*
* Instance Methods
*/
/*************************************************************************/
/**
* This method forces any data that may have been buffered to be written
* to the underlying output device. Please note that the host environment
* might perform its own buffering unbeknowst to Java. In that case, a
* write made (for example, to a disk drive) might be cached in OS
* buffers instead of actually being written to disk.
*
* @exception IOException If an error occurs
*/
public abstract void flush() throws IOException;
/*
* Instance Methods
*/
/*************************************************************************/
/**
* This method forces any data that may have been buffered to be written
* to the underlying output device. Please note that the host environment
* might perform its own buffering unbeknowst to Java. In that case, a
* write made (for example, to a disk drive) might be cached in OS
* buffers instead of actually being written to disk.
*
* @exception IOException If an error occurs
*/
public abstract void
flush() throws IOException;
/**
* This method closes the stream. Any internal or native resources
* associated
* with this stream are freed. Any subsequent attempt to access the stream
* might throw an exception.
* <p>
* This method in this class does nothing.
*
* @exception IOException If an error occurs
*/
public abstract void close() throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
* This method closes the stream. Any internal or native resources associated
* with this stream are freed. Any subsequent attempt to access the stream
* might throw an exception.
* <p>
* This method in this class does nothing.
*
* @exception IOException If an error occurs
*/
public abstract void
close() throws IOException;
/**
* This method writes a single char to the output stream.
*
* @param b The char to be written to the output stream, passed as an int
*
* @exception IOException If an error occurs
*/
public void write(int b) throws IOException
{
char[] buf = new char[1];
/*************************************************************************/
buf[0] = (char)b;
write(buf, 0, buf.length);
}
/**
* This method writes a single char to the output stream.
*
* @param b The char to be written to the output stream, passed as an int
*
* @exception IOException If an error occurs
*/
public void
write(int b) throws IOException
{
char[] buf = new char[1];
/*************************************************************************/
buf[0] = (char)b;
write(buf, 0, buf.length);
}
/**
* This method all the writes char from the passed array to the output
* stream. This method is equivalent to
* <code>write(buf, 0, buf.length)</code> which
* is exactly how it is implemented in this class.
*
* @param buf The array of char to write
*
* @exception IOException If an error occurs
*/
public void write(char[] buf) throws IOException
{
write(buf, 0, buf.length);
}
/*************************************************************************/
/*************************************************************************/
/**
* This method all the writes char from the passed array to the output stream.
* This method is equivalent to <code>write(buf, 0, buf.length)</code> which
* is exactly how it is implemented in this class.
*
* @param buf The array of char to write
*
* @exception IOException If an error occurs
*/
public void
write(char[] buf) throws IOException
{
write(buf, 0, buf.length);
}
/**
* This method writes <code>len</code> char from the specified array
* <code>buf</code> starting at index <code>offset</code> into the array.
* <p>
* Subclasses must provide an implementation of this abstract method.
*
* @param buf The array of char to write from
* @param offset The index into the array to start writing from
* @param len The number of char to write
*
* @exception IOException If an error occurs
*/
public abstract void write(char[] buf, int offset, int len)
throws IOException;
/*************************************************************************/
/*************************************************************************/
/**
* This method writes <code>len</code> char from the specified array
* <code>buf</code> starting at index <code>offset</code> into the array.
* <p>
* Subclasses must provide an implementation of this abstract method.
*
* @param buf The array of char to write from
* @param offset The index into the array to start writing from
* @param len The number of char to write
*
* @exception IOException If an error occurs
*/
public abstract void
write(char[] buf, int offset, int len) throws IOException;
/**
* This method writes all the characters in a <code>String</code> to the
* output.
*
* @param str The <code>String</code> whose chars are to be written.
*
* @param IOException If an error occurs
*/
public void write(String str) throws IOException
{
write(str, 0, str.length());
}
/*************************************************************************/
/*************************************************************************/
/**
* This method writes all the characters in a <code>String</code> to the
* output.
*
* @param str The <code>String</code> whose chars are to be written.
*
* @param IOException If an error occurs
*/
public void
write(String str) throws IOException
{
write(str, 0, str.length());
}
/**
* This method writes <code>len</code> chars from the <code>String</code>
* starting at position <code>offset</code>.
*
* @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 len The number of chars to write
*
* @exception IOException If an error occurs
*/
public void write(String str, int offset, int len) throws IOException
{
// FIXME - for libgcj re-write using native code to not require
// copied buffer.
char[] buf = new char[len];
/*************************************************************************/
/**
* This method writes <code>len</code> chars from the <code>String</code>
* starting at position <code>offset</code>.
*
* @param str The <code>String</code> that is to be written
* @param offset The character offset into the <code>String</code> to start
* writing from
* @param len The number of chars to write
*
* @exception IOException If an error occurs
*/
public void
write(String str, int offset, int len) throws IOException
{
// FIXME - for libgcj re-write using native code to not require copied buffer.
char[] buf = new char[len];
str.getChars(offset, offset + len, buf, 0);
write(buf, 0, len);
}
str.getChars(offset, offset + len, buf, 0);
write(buf, 0, len);
}
} // class Writer