001package org.apache.commons.ssl.org.bouncycastle.asn1;
002
003import java.io.InputStream;
004
005abstract class LimitedInputStream
006        extends InputStream
007{
008    protected final InputStream _in;
009    private int _limit;
010
011    LimitedInputStream(
012        InputStream in,
013        int         limit)
014    {
015        this._in = in;
016        this._limit = limit;
017    }
018
019    int getRemaining()
020    {
021        // TODO: maybe one day this can become more accurate
022        return _limit;
023    }
024    
025    protected void setParentEofDetect(boolean on)
026    {
027        if (_in instanceof IndefiniteLengthInputStream)
028        {
029            ((IndefiniteLengthInputStream)_in).setEofOn00(on);
030        }
031    }
032}