public abstract class DeltaStream extends InputStream
Implementations must provide a means to access a stream for the base object.
This stream may be accessed multiple times, in order to randomly position it
to match the copy instructions. A DeltaStream
performs an efficient
skip by only moving through the delta stream, making restarts of stacked
deltas reasonably efficient.
Constructor and Description |
---|
DeltaStream(InputStream deltaStream)
Construct a delta application stream, reading instructions.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected abstract long |
getBaseSize() |
long |
getSize() |
protected abstract InputStream |
openBase()
Open the base stream.
|
int |
read() |
int |
read(byte[] buf,
int off,
int len) |
long |
skip(long len) |
available, mark, markSupported, read, reset
public DeltaStream(InputStream deltaStream) throws IOException
deltaStream
- the stream to read delta instructions from.IOException
- the delta instruction stream cannot be read, or is
inconsistent with the the base object information.protected abstract InputStream openBase() throws IOException
The DeltaStream
may close and reopen the base stream multiple
times if copy instructions use offsets out of order. This can occur if a
large block in the file was moved from near the top, to near the bottom.
In such cases the reopened stream is skipped to the target offset, so
skip(long)
should be as efficient as possible.
IOException
- the base object cannot be opened for reading.protected abstract long getBaseSize() throws IOException
IOException
- the length of the base cannot be determined.public long getSize()
public int read() throws IOException
read
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
public long skip(long len) throws IOException
skip
in class InputStream
IOException
public int read(byte[] buf, int off, int len) throws IOException
read
in class InputStream
IOException
Copyright © 2013. All rights reserved.