Class DefensiveDrainable
java.lang.Object
java.io.InputStream
io.deephaven.extensions.barrage.util.DefensiveDrainable
- All Implemented Interfaces:
io.grpc.Drainable,Closeable,AutoCloseable
- Direct Known Subclasses:
ChunkWriter.DrainableColumn,ConsecutiveDrainableStreams,DrainableByteArrayInputStream
A defensive
Drainable implementation that supports the non-read methods of InputStream. Callers
should use Drainable.drainTo(OutputStream) when applicable. If handing off to external code that needs a real
InputStream, use capture().-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintA defensive drainable needs to override available.final InputStreamcapture()Capturesthisdrainable as a realInputStream.final intread()final intread(@org.jetbrains.annotations.NotNull byte[] b) final intread(@org.jetbrains.annotations.NotNull byte[] b, int off, int len) final longskip(long n) Methods inherited from class java.io.InputStream
close, mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferToMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.grpc.Drainable
drainTo
-
Constructor Details
-
DefensiveDrainable
public DefensiveDrainable()
-
-
Method Details
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
public final int read(@NotNull @org.jetbrains.annotations.NotNull byte[] b, int off, int len) throws IOException - Overrides:
readin classInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
available
A defensive drainable needs to override available. As opposed to the genericInputStream, this method must return the exact amount available.- Overrides:
availablein classInputStream- Returns:
- the exact amount available
- Throws:
IOException- if an I/O exception occurs
-
capture
Capturesthisdrainable as a realInputStream.- Returns:
- a real input stream
-