public class ProgressBarFilterInputStream extends FilterInputStream
Modifier and Type | Field and Description |
---|---|
protected boolean |
interrupted
Set this to interrupt the reading and throw an exception
|
protected DefaultBoundedRangeModel |
model
The model for the progress bar
|
protected int |
nread
The number of bytes read so far
|
protected ProgressBarUtil |
progressBar
The progress bar to use
|
protected int |
size
The size of the data in bytes, if known, otherwise 0
|
protected long |
updateTime
Time in ms of last update (used to slow down text field updates)
|
in
Constructor and Description |
---|
ProgressBarFilterInputStream(ProgressBarUtil progressBar,
JTextField statusField,
InputStream in,
int size)
Constructs an object to monitor the progress of an input stream
using a given progress bar and text field.
|
ProgressBarFilterInputStream(ProgressBarUtil progressBar,
JTextField statusField,
URL url)
Constructs an object to monitor the progress of an input stream
using a given progress bar and text field.
|
ProgressBarFilterInputStream(StatusPanel statusPanel,
URL url)
Constructs an object to monitor the progress of an input stream
using a given StatusPanel object.
|
Modifier and Type | Method and Description |
---|---|
void |
checkForInterrupt()
Throw an exception if interrupt() was called on this stream.
|
void |
clear()
Reset the progress bar to the idle state
|
void |
close()
Overrides
FilterInputStream.close
to close the progress bar as well as the stream. |
int |
getSize()
Return the size of the data to read
|
void |
interrupt()
Interrupt the reading (causes the next read() to throw an exception).
|
boolean |
isInterrupted()
Return true if reading was interrupted
|
static void |
main(String[] args)
Test main
|
int |
read()
Overrides
FilterInputStream.read
to update the progress bar after the read. |
int |
read(byte[] b,
int off,
int len)
Overrides
FilterInputStream.read
to update the progress bar after the read. |
void |
reset()
Overrides
FilterInputStream.reset
to reset the progress bar as well as the stream. |
protected void |
setNumBytesRead(int n)
Set the number of bytes that have been read, update the display (but not
too often) and check for interrupt requests.
|
void |
setSize(int size)
Set the size of the data to read
|
long |
skip(long n)
Overrides
FilterInputStream.skip
to update the progress bar after the skip. |
available, mark, markSupported, read
protected ProgressBarUtil progressBar
protected DefaultBoundedRangeModel model
protected int nread
protected int size
protected long updateTime
protected boolean interrupted
public ProgressBarFilterInputStream(ProgressBarUtil progressBar, JTextField statusField, InputStream in, int size)
progressBar
- the progress bar to usestatusField
- text field used to display status informationin
- the input stream to be monitoredsize
- the size in bytes of the date to be read, or 0 if not knownpublic ProgressBarFilterInputStream(ProgressBarUtil progressBar, JTextField statusField, URL url)
progressBar
- the progress bar to usestatusField
- text field used to display status informationurl
- the URL to readpublic ProgressBarFilterInputStream(StatusPanel statusPanel, URL url)
statusPanel
- used to display status informationurl
- the URL to readpublic void interrupt()
public boolean isInterrupted()
public void checkForInterrupt() throws IOException
IOException
public void setSize(int size)
protected void setNumBytesRead(int n)
public void clear()
public int getSize()
public int read() throws IOException
FilterInputStream.read
to update the progress bar after the read.read
in class FilterInputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
FilterInputStream.read
to update the progress bar after the read.read
in class FilterInputStream
IOException
public long skip(long n) throws IOException
FilterInputStream.skip
to update the progress bar after the skip.skip
in class FilterInputStream
IOException
public void close() throws IOException
FilterInputStream.close
to close the progress bar as well as the stream.close
in interface Closeable
close
in interface AutoCloseable
close
in class FilterInputStream
IOException
public void reset() throws IOException
FilterInputStream.reset
to reset the progress bar as well as the stream.reset
in class FilterInputStream
IOException
public static void main(String[] args)
Copyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.