1package org.bouncycastle.asn1;
2
3import java.io.InputStream;
4
5abstract class LimitedInputStream
6        extends InputStream
7{
8    protected final InputStream _in;
9    private int _limit;
10
11    LimitedInputStream(
12        InputStream in,
13        int         limit)
14    {
15        this._in = in;
16        this._limit = limit;
17    }
18
19    int getRemaining()
20    {
21        // TODO: maybe one day this can become more accurate
22        return _limit;
23    }
24
25    protected void setParentEofDetect(boolean on)
26    {
27        if (_in instanceof IndefiniteLengthInputStream)
28        {
29            ((IndefiniteLengthInputStream)_in).setEofOn00(on);
30        }
31    }
32}
33