public interface PrintStreamWrapper extends net.kemitix.wrapper.Wrapper<PrintStream>
Wrapper for handling PrintStream.
Provides access to the PrintStream.write(int) and PrintStream.write(byte[], int, int) through
the Wrapper.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
PrintStreamWrapper.ByteFilter
A Function for filtering a Byte.
|
static interface |
PrintStreamWrapper.ByteTransform
A Function for transforming one Byte into another.
|
static interface |
PrintStreamWrapper.StringFilter
A Function for filtering a String.
|
static interface |
PrintStreamWrapper.StringTransform
A Function for transforming one String into another.
|
| Modifier and Type | Method and Description |
|---|---|
static PrintStream |
copy(PrintStream left,
PrintStream right)
Creates a PrintStream that copies
PrintStream.write(int) and
PrintStream.write(byte[], int, int) calls to both the left and the
right PrintStreams. |
static PrintStream |
filter(PrintStream printStream,
PrintStreamWrapper.ByteFilter filter)
Create a Byte filtering PrintStream that will filter using the predicate.
|
static PrintStream |
filter(PrintStream printStream,
PrintStreamWrapper.StringFilter filter)
Create a String filtering PrintStream that will filter using the predicate.
|
default PrintStream |
printStreamDelegate()
The content of the PrintStreamWrapper as a PrintStream.
|
static PrintStream |
transform(PrintStream original,
PrintStreamWrapper.ByteTransform transformer)
Creates a PrintStream that transforms calls the
PrintStream.print(String) using the transformer before
passing it on to the original. |
static PrintStream |
transform(PrintStream original,
PrintStreamWrapper.StringTransform transformer)
Creates a PrintStream that transforms calls the
PrintStream.print(String) using the transformer before
passing it on to the original. |
static Optional<net.kemitix.wrapper.Wrapper<PrintStream>> |
unwrap(PrintStream printStream)
Get the wrapped PrintStream, if one exists.
|
void |
write(byte[] buf,
int off,
int len)
Writes len bytes from the specified byte array starting at offset off to this stream.
|
void |
write(int b)
Writes the specified byte to this stream.
|
static PrintStream filter(PrintStream printStream, PrintStreamWrapper.StringFilter filter)
printStream - the PrintStream to received filtered writesfilter - the String filterstatic PrintStream filter(PrintStream printStream, PrintStreamWrapper.ByteFilter filter)
printStream - the PrintStream to received filtered writesfilter - the Byte filterstatic Optional<net.kemitix.wrapper.Wrapper<PrintStream>> unwrap(PrintStream printStream)
printStream - the PrintStream to unwrapstatic PrintStream copy(PrintStream left, PrintStream right)
PrintStream.write(int) and
PrintStream.write(byte[], int, int) calls to both the left and the
right PrintStreams.left - the first PrintStreamright - the second PrintStreamstatic PrintStream transform(PrintStream original, PrintStreamWrapper.StringTransform transformer)
PrintStream.print(String) using the transformer before
passing it on to the original.original - the PrintStream to receive the transformed callstransformer - the String transformerstatic PrintStream transform(PrintStream original, PrintStreamWrapper.ByteTransform transformer)
PrintStream.print(String) using the transformer before
passing it on to the original.original - the PrintStream to receive the transformed callstransformer - the Byte transformerdefault PrintStream printStreamDelegate()
void write(int b)
If the byte is a newline and automatic flushing is enabled then the flush method will be invoked.
Note that the byte is written as given; to write a character that will be translated according to the platform's default character encoding, use the print(char) or println(char) methods.
This implementation passes the byte, unmodified, to the intercepted PrintStream or Wrapper<PrintStream>.
b - The byte to be writtenPrintStream.print(char),
PrintStream.println(char)void write(byte[] buf,
int off,
int len)
If automatic flushing is enabled then the flush method will be invoked.
Note that the bytes will be written as given; to write characters that will be translated according to the platform's default character encoding, use the print(char) or println(char) methods.
This implementation passes the bytes, unmodified, to the intercepted PrintStream or Wrapper<PrintStream>.
buf - A byte arrayoff - Offset from which to start taking byteslen - Number of bytes to writeCopyright © 2015–2018. All rights reserved.