Class FilteredInputStream
java.lang.Object
java.io.InputStream
com.cloudbees.jenkins.support.filter.FilteredInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
A custom
InputStream
that filters lines of text read from an underlying InputStream
using a provided
mapping function. Each line read from the input stream is processed by the function before being returned, allowing
for modifications such as redaction or transformation of the line content.- Author:
- Basil Crow
-
Constructor Summary
ConstructorDescriptionFilteredInputStream
(InputStream is, Charset encoding, Function<String, String> filter) Constructs a filtered stream using the provided filter and encoding. -
Method Summary
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
FilteredInputStream
public FilteredInputStream(@NonNull InputStream is, @NonNull Charset encoding, @NonNull Function<String, String> filter) Constructs a filtered stream using the provided filter and encoding.- Parameters:
is
- Input stream to read line content fromencoding
- Character set to use for decoding and encoding bytes read from this streamfilter
- Filter to apply to lines read from this stream
-
-
Method Details
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-