diff options
Diffstat (limited to 'core/src/main/java/org/spongycastle/asn1/LimitedInputStream.java')
-rw-r--r-- | core/src/main/java/org/spongycastle/asn1/LimitedInputStream.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/core/src/main/java/org/spongycastle/asn1/LimitedInputStream.java b/core/src/main/java/org/spongycastle/asn1/LimitedInputStream.java new file mode 100644 index 00000000..cc3273bf --- /dev/null +++ b/core/src/main/java/org/spongycastle/asn1/LimitedInputStream.java @@ -0,0 +1,32 @@ +package org.spongycastle.asn1; + +import java.io.InputStream; + +abstract class LimitedInputStream + extends InputStream +{ + protected final InputStream _in; + private int _limit; + + LimitedInputStream( + InputStream in, + int limit) + { + this._in = in; + this._limit = limit; + } + + int getRemaining() + { + // TODO: maybe one day this can become more accurate + return _limit; + } + + protected void setParentEofDetect(boolean on) + { + if (_in instanceof IndefiniteLengthInputStream) + { + ((IndefiniteLengthInputStream)_in).setEofOn00(on); + } + } +} |