Class FilteredOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- com.cloudbees.jenkins.support.filter.FilteredOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public class FilteredOutputStream extends FilterOutputStream
Wraps an OutputStream by filtering written lines using a provided ContentFilter. Data written to an instance of this will be decoded on the fly using the provided charset, and each line written is filtered.- Since:
- TODO
- See Also:
ContentFilter
,FilteredWriter
-
-
Field Summary
Fields Modifier and Type Field Description static String
UNKNOWN_INPUT
-
Fields inherited from class java.io.FilterOutputStream
out
-
-
Constructor Summary
Constructors Constructor Description FilteredOutputStream(OutputStream out, ContentFilter contentFilter)
Constructs a filtered stream using the provided filter and assuming UTF-8.FilteredOutputStream(OutputStream out, Charset charset, ContentFilter contentFilter)
Constructs a filtered stream using the provided filter and charset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FilteredWriter
asWriter()
void
close()
void
flush()
Flushes the current buffered contents and filters them as is.void
reset()
Resets the state of this stream's decoders and buffers.void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(int b)
-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Field Detail
-
UNKNOWN_INPUT
public static final String UNKNOWN_INPUT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FilteredOutputStream
public FilteredOutputStream(@NonNull OutputStream out, @NonNull ContentFilter contentFilter)
Constructs a filtered stream using the provided filter and assuming UTF-8.- Parameters:
out
- output stream to write filtered content tocontentFilter
- content filter to apply to lines written through this stream
-
FilteredOutputStream
public FilteredOutputStream(@NonNull OutputStream out, @NonNull Charset charset, @NonNull ContentFilter contentFilter)
Constructs a filtered stream using the provided filter and charset.- Parameters:
out
- output stream to write filtered content tocharset
- character set to use for decoding and encoding bytes written to this streamcontentFilter
- content filter to apply to lines written through this stream
-
-
Method Detail
-
write
public void write(int b) throws IOException
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
public void write(@NonNull byte[] b) throws IOException
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
public void write(@NonNull byte[] b, int off, int len) throws IOException
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
flush
public void flush() throws IOException
Flushes the current buffered contents and filters them as is.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classFilterOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
-
reset
public void reset()
Resets the state of this stream's decoders and buffers.
-
asWriter
public FilteredWriter asWriter()
- Returns:
- a FilteredWriter view of this stream's underlying OutputStream
-
-