Class OutputStreamSelector
java.lang.Object
java.io.OutputStream
com.cloudbees.jenkins.support.util.OutputStreamSelector
- All Implemented Interfaces:
WrapperOutputStream,Closeable,Flushable,AutoCloseable
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
public class OutputStreamSelector
extends OutputStream
implements WrapperOutputStream
Dynamically selects either a textual or binary OutputStream destination based on simple content type probing.
- Since:
- TODO
-
Constructor Summary
ConstructorsConstructorDescriptionOutputStreamSelector(Supplier<OutputStream> binaryOutputStreamProvider, Supplier<OutputStream> textOutputStreamProvider) Constructs an OutputStreamSelector using the provided streams. -
Method Summary
Methods inherited from class java.io.OutputStream
nullOutputStream, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.cloudbees.jenkins.support.util.WrapperOutputStream
unwrapRecursively
-
Constructor Details
-
OutputStreamSelector
public OutputStreamSelector(@NonNull Supplier<OutputStream> binaryOutputStreamProvider, @NonNull Supplier<OutputStream> textOutputStreamProvider) Constructs an OutputStreamSelector using the provided streams.- Parameters:
binaryOutputStreamProvider- a provider of an OutputStream to use if the contents written appear to be binarytextOutputStreamProvider- a provider of an OutputStream to use if the contents written appear to be textual
-
-
Method Details
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
reset
public void reset()Resets the state of this stream to allow for contents to be probed again. -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
unwrap
Description copied from interface:WrapperOutputStreamUnwraps this stream, potentially forcing unwritten data to be flushed.- Specified by:
unwrapin interfaceWrapperOutputStream- Returns:
- the underlying stream being wrapped
- Throws:
IOException- if an exception occurs preparing the unwrapped reference
-