Verified Owner
Top Description Fields Constructors Methods
org.jabref.logic.net

public Class ProgressInputStream

extends FilterInputStream
Class Inheritance
Imports
java.io.FilterInputStream, .IOException, .InputStream, javafx.beans.property.LongProperty, .SimpleLongProperty

An input stream that keeps track of the amount of bytes already read. Code based on http://stackoverflow.com/a/1339589/873661, but converted to use JavaFX properties instead of listeners

Field Summary

Modifier and TypeField and Description
private final long
private final LongProperty
private final LongProperty
Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
public
ProgressInputStream(InputStream in, long maxNumBytes)

Method Summary

Modifier and TypeMethod and Description
public long
public long
public long
public void
mark(int readlimit)

Overrides java.io.FilterInputStream.mark.

Marks the current position in this input stream.

public boolean
markSupported()

Overrides java.io.FilterInputStream.markSupported.

Tests if this input stream supports the mark and reset methods.

public LongProperty
public int
read()

Overrides java.io.FilterInputStream.read.

Reads the next byte of data from the input stream.

public int
read(byte[] b, int off, int len)

Overrides java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.

public void
reset()

Overrides java.io.FilterInputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

public long
skip(long n)

Overrides java.io.FilterInputStream.skip.

Skips over and discards n bytes of data from the input stream.

public LongProperty
private long
updateProgress(long numBytesRead)

Inherited from java.io.FilterInputStream:
availablecloseread

Field Detail

maxNumBytesback to summary
private final long maxNumBytes
progressback to summary
private final LongProperty progress
totalNumBytesReadback to summary
private final LongProperty totalNumBytesRead

Constructor Detail

ProgressInputStreamback to summary
public ProgressInputStream(InputStream in, long maxNumBytes)

Method Detail

getMaxNumBytesback to summary
public long getMaxNumBytes()
getProgressback to summary
public long getProgress()
getTotalNumBytesReadback to summary
public long getTotalNumBytesRead()
markback to summary
public void mark(int readlimit)

Overrides java.io.FilterInputStream.mark.

Doc from java.io.FilterInputStream.mark.

Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.

The readlimit argument tells this input stream to allow that many bytes to be read before the mark position gets invalidated.

Annotations
@Override
markSupportedback to summary
public boolean markSupported()

Overrides java.io.FilterInputStream.markSupported.

Doc from java.io.FilterInputStream.markSupported.

Tests if this input stream supports the mark and reset methods.

Annotations
@Override
progressPropertyback to summary
public LongProperty progressProperty()
readback to summary
public int read() throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
resetback to summary
public void reset() throws IOException

Overrides java.io.FilterInputStream.reset.

Doc from java.io.FilterInputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

Stream marks are intended to be used in situations where you need to read ahead a little to see what's in the stream. Often this is most easily done by invoking some general parser. If the stream is of the type handled by the parse, it just chugs along happily. If the stream is not of that type, the parser should toss an exception when it fails. If this happens within readlimit bytes, it allows the outer code to reset the stream and try another parser.

Annotations
@Override
Exceptions
IOException:
if this stream has not been marked or if the mark has been invalidated.
skipback to summary
public long skip(long n) throws IOException

Overrides java.io.FilterInputStream.skip.

Doc from java.io.FilterInputStream.skip.

Skips over and discards n bytes of data from the input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.

Annotations
@Override
Exceptions
IOException:
if in.skip(n) throws an IOException.
totalNumBytesReadPropertyback to summary
public LongProperty totalNumBytesReadProperty()
updateProgressback to summary
private long updateProgress(long numBytesRead)