Package org.apache.commons.io.input
Class BoundedInputStream.AbstractBuilder<T extends BoundedInputStream.AbstractBuilder<T>>
java.lang.Object
org.apache.commons.io.build.AbstractSupplier<BoundedInputStream,T>
org.apache.commons.io.build.AbstractOriginSupplier<BoundedInputStream,T>
org.apache.commons.io.build.AbstractStreamBuilder<BoundedInputStream,T>
org.apache.commons.io.input.ProxyInputStream.AbstractBuilder<BoundedInputStream,T>
org.apache.commons.io.input.BoundedInputStream.AbstractBuilder<T>
- Type Parameters:
T- The subclass.
- All Implemented Interfaces:
IOSupplier<BoundedInputStream>
- Direct Known Subclasses:
BoundedInputStream.Builder
- Enclosing class:
BoundedInputStream
abstract static class BoundedInputStream.AbstractBuilder<T extends BoundedInputStream.AbstractBuilder<T>>
extends ProxyInputStream.AbstractBuilder<BoundedInputStream,T>
For subclassing builders from
BoundedInputStream subclassses.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longThe current count of bytes counted.private longThe max count of bytes to read.private IOBiConsumer<Long, Long> private booleanFlag ifProxyInputStream.close()should be propagated,trueby default. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) longgetCount()(package private) long(package private) IOBiConsumer<Long, Long> (package private) booleansetCount(long count) Sets the current number of bytes counted.setMaxCount(long maxCount) Sets the maximum number of bytes to return.setOnMaxCount(IOBiConsumer<Long, Long> onMaxCount) Sets the defaultBoundedInputStream.onMaxLength(long, long)behavior,nullresets to a NOOP.setPropagateClose(boolean propagateClose) Sets whether theProxyInputStream.close()method should propagate to the underlingInputStream.Methods inherited from class org.apache.commons.io.input.ProxyInputStream.AbstractBuilder
getAfterRead, setAfterReadMethods inherited from class org.apache.commons.io.build.AbstractStreamBuilder
getBufferSize, getBufferSizeDefault, getCharSequence, getCharset, getCharsetDefault, getFile, getInputStream, getOpenOptions, getOutputStream, getPath, getRandomAccessFile, getReader, getWriter, setBufferSize, setBufferSize, setBufferSizeChecker, setBufferSizeDefault, setBufferSizeMax, setCharset, setCharset, setCharsetDefault, setOpenOptionsMethods inherited from class org.apache.commons.io.build.AbstractOriginSupplier
checkOrigin, getOrigin, hasOrigin, newByteArrayOrigin, newCharSequenceOrigin, newFileOrigin, newFileOrigin, newInputStreamOrigin, newOutputStreamOrigin, newPathOrigin, newPathOrigin, newRandomAccessFileOrigin, newRandomAccessFileOrigin, newReaderOrigin, newURIOrigin, newWriterOrigin, setByteArray, setCharSequence, setFile, setFile, setInputStream, setOrigin, setOutputStream, setPath, setPath, setRandomAccessFile, setRandomAccessFile, setReader, setURI, setWriterMethods inherited from class org.apache.commons.io.build.AbstractSupplier
asThisMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.io.function.IOSupplier
asSupplier, get, getUnchecked
-
Field Details
-
count
private long countThe current count of bytes counted. -
maxCount
private long maxCountThe max count of bytes to read. -
onMaxCount
-
propagateClose
private boolean propagateCloseFlag ifProxyInputStream.close()should be propagated,trueby default.
-
-
Constructor Details
-
AbstractBuilder
AbstractBuilder()
-
-
Method Details
-
getCount
long getCount() -
getMaxCount
long getMaxCount() -
getOnMaxCount
IOBiConsumer<Long,Long> getOnMaxCount() -
isPropagateClose
boolean isPropagateClose() -
setCount
Sets the current number of bytes counted.Useful when building from another stream to carry forward a read count.
Default is
0, negative means 0.- Parameters:
count- The current number of bytes counted.- Returns:
thisinstance.
-
setMaxCount
Sets the maximum number of bytes to return.Default is -1, negative means unbound.
- Parameters:
maxCount- The maximum number of bytes to return.- Returns:
thisinstance.
-
setOnMaxCount
Sets the defaultBoundedInputStream.onMaxLength(long, long)behavior,nullresets to a NOOP.The first Long is the max count of bytes to read. The second Long is the count of bytes read.
This does not override a
BoundedInputStreamsubclass' implementation of theBoundedInputStream.onMaxLength(long, long)method.- Parameters:
onMaxCount- theProxyInputStream.afterRead(int)behavior.- Returns:
- this instance.
- Since:
- 2.18.0
-
setPropagateClose
Sets whether theProxyInputStream.close()method should propagate to the underlingInputStream.Default is
true.- Parameters:
propagateClose-trueif callingProxyInputStream.close()propagates to theclose()method of the underlying stream orfalseif it does not.- Returns:
thisinstance.
-