RangeInputByteStream.java 1.77 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.internal.io.stream;

import com.adobe.internal.io.stream.ChainedInputByteStream;
import com.adobe.internal.io.stream.InputByteStream;
import com.adobe.internal.io.stream.InputByteStreamImpl;
import java.io.IOException;

public class RangeInputByteStream
extends InputByteStreamImpl {
    private ChainedInputByteStream chainedIBS;
    private long[] ranges;

    public RangeInputByteStream(InputByteStream ibs, long[] ranges) throws IOException {
        InputByteStream[] ibsArray = new InputByteStream[]{ibs.slice(ranges[0], ranges[1]), ibs.slice(ranges[2], ranges[3])};
        this.chainedIBS = new ChainedInputByteStream(ibsArray);
        this.ranges = ranges;
    }

    @Override
    public void close() throws IOException {
        this.chainedIBS.close();
        this.chainedIBS = null;
    }

    @Override
    public long getPosition() throws IOException {
        return this.chainedIBS.getPosition();
    }

    @Override
    public long length() throws IOException {
        return this.chainedIBS.length();
    }

    @Override
    public int read() throws IOException {
        return this.chainedIBS.read();
    }

    @Override
    public int read(byte[] bytes, int position, int length) throws IOException {
        return this.chainedIBS.read(bytes, position, length);
    }

    @Override
    public InputByteStream seek(long position) throws IOException {
        this.chainedIBS.seek(position);
        return this;
    }

    @Override
    public InputByteStream slice(long begin, long length) throws IOException {
        return this.chainedIBS.slice(begin, length);
    }

    public ChainedInputByteStream getChainedIBS() {
        return this.chainedIBS;
    }

    public long[] getRanges() {
        return this.ranges;
    }
}