org.eclipse.jgit.internal.storage.pack

## Class DeltaStream

- java.lang.Object
- - java.io.InputStream
  - - org.eclipse.jgit.internal.storage.pack.DeltaStream

All Implemented Interfaces:
  Closeable, AutoCloseable

    public abstract class DeltaStream
    extends InputStream

Inflates a delta in an incremental way.

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 Summary

Constructors
Constructor and Description
`DeltaStream(InputStream deltaStream)` Construct a delta application stream, reading instructions.

### Method Summary

Methods
`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)`

### Methods inherited from class java.io.InputStream

`available, mark, markSupported, read, reset`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### DeltaStream

    public DeltaStream(InputStream deltaStream)
                throws IOException

Construct a delta application stream, reading instructions.

Parameters:
  `deltaStream` - the stream to read delta instructions from.
Throws:
  `IOException` - the delta instruction stream cannot be read, or is inconsistent with the the base object information.

### Method Detail

#### openBase

    protected abstract InputStream openBase()
                                     throws IOException

Open the base stream.

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.

Returns:
  stream to read from the base object. This stream should not be buffered (or should be only minimally buffered), and does not need to support mark/reset.
Throws:
  `IOException` - the base object cannot be opened for reading.

#### getBaseSize

    protected abstract long getBaseSize()
                                 throws IOException

Returns:
  length of the base object, in bytes.
Throws:
  `IOException` - the length of the base cannot be determined.

#### getSize

    public long getSize()

Returns:
  total size of this stream, in bytes.

#### read

    public int read()
             throws IOException

Specified by:
  `read` in class `InputStream`
Throws:
  `IOException`

#### close

    public void close()
               throws IOException

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Overrides:
  `close` in class `InputStream`
Throws:
  `IOException`

#### skip

    public long skip(long len)
              throws IOException

Overrides:
  `skip` in class `InputStream`
Throws:
  `IOException`

#### read

    public int read(byte[] buf,
           int off,
           int len)
             throws IOException

Overrides:
  `read` in class `InputStream`
Throws:
  `IOException`