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
ConstructorDescriptionOutputStreamSelector
(Supplier<OutputStream> binaryOutputStreamProvider, Supplier<OutputStream> textOutputStreamProvider) Constructs an OutputStreamSelector using the provided streams. -
Method Summary
Methods inherited from class java.io.OutputStream
nullOutputStream, write
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
reset
public void reset()Resets the state of this stream to allow for contents to be probed again. -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
unwrap
Description copied from interface:WrapperOutputStream
Unwraps this stream, potentially forcing unwritten data to be flushed.- Specified by:
unwrap
in interfaceWrapperOutputStream
- Returns:
- the underlying stream being wrapped
- Throws:
IOException
- if an exception occurs preparing the unwrapped reference
-