javax.swing
Class ProgressMonitorInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by javax.swing.ProgressMonitorInputStream
All Implemented Interfaces:
Closeable

public class ProgressMonitorInputStream
extends FilterInputStream

An input stream with a ProgressMonitor.

Since:
1.2

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
ProgressMonitorInputStream(Component component, Object message, InputStream stream)
          Creates a new ProgressMonitorInputStream.
 
Method Summary
 void close()
          Closes the input stream and the associated ProgressMonitor.
 ProgressMonitor getProgressMonitor()
          Returns the ProgressMonitor used by this input stream.
 int read()
          Reads an unsigned byte from the input stream and returns it as an int in the range of 0-255.
 int read(byte[] data)
          Reads bytes from the input stream and stores them in the supplied array, and updates the progress monitor (or closes it if the end of the stream is reached).
 int read(byte[] data, int offset, int length)
          Reads up to length bytes from the input stream and stores them in the supplied array at the given index, and updates the progress monitor (or closes it if the end of the stream is reached).
 void reset()
          Resets the input stream to the point where FilterInputStream.mark(int) was called.
 long skip(long length)
          Skips the specified number of bytes and updates the ProgressMonitor.
 
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgressMonitorInputStream

public ProgressMonitorInputStream(Component component,
                                  Object message,
                                  InputStream stream)
Creates a new ProgressMonitorInputStream.

Parameters:
component - the parent component for the progress monitor dialog.
message - the task description.
stream - the underlying input stream.
Method Detail

reset

public void reset()
           throws IOException
Resets the input stream to the point where FilterInputStream.mark(int) was called.

Overrides:
reset in class FilterInputStream
Throws:
IOException - TODO

read

public int read()
         throws IOException
Reads an unsigned byte from the input stream and returns it as an int in the range of 0-255. Returns -1 if the end of the stream has been reached. The progress monitor is updated.

Overrides:
read in class FilterInputStream
Returns:
int
Throws:
IOException - if there is a problem reading the stream.

read

public int read(byte[] data)
         throws IOException
Reads bytes from the input stream and stores them in the supplied array, and updates the progress monitor (or closes it if the end of the stream is reached).

Overrides:
read in class FilterInputStream
Parameters:
data - the data array for returning bytes read from the stream.
Returns:
The number of bytes read, or -1 if there are no more bytes in the stream.
Throws:
IOException - if there is a problem reading bytes from the stream.

read

public int read(byte[] data,
                int offset,
                int length)
         throws IOException
Reads up to length bytes from the input stream and stores them in the supplied array at the given index, and updates the progress monitor (or closes it if the end of the stream is reached).

Overrides:
read in class FilterInputStream
Parameters:
data - the data array for returning bytes read from the stream.
offset - the offset into the array where the bytes should be written.
length - the maximum number of bytes to read from the stream.
Returns:
The number of bytes read, or -1 if there are no more bytes in the stream.
Throws:
IOException - if there is a problem reading bytes from the stream.

skip

public long skip(long length)
          throws IOException
Skips the specified number of bytes and updates the ProgressMonitor.

Overrides:
skip in class FilterInputStream
Parameters:
length - the number of bytes to skip.
Returns:
The actual number of bytes skipped.
Throws:
IOException - if there is a problem skipping bytes in the stream.

close

public void close()
           throws IOException
Closes the input stream and the associated ProgressMonitor.

Specified by:
close in interface Closeable
Overrides:
close in class FilterInputStream
Throws:
IOException - if there is a problem closing the input stream.

getProgressMonitor

public ProgressMonitor getProgressMonitor()
Returns the ProgressMonitor used by this input stream.

Returns:
The progress monitor.