Class DefaultConsoleOutputInterceptor

  • All Implemented Interfaces:
    ConsoleOutputInterceptor

    public class DefaultConsoleOutputInterceptor
    extends java.lang.Object
    implements ConsoleOutputInterceptor
    Default implementation of a console output interceptor. Hooks the System.out and System.err streams to do its work, thus it is critical that there's only one instance of this service in a given JVM. This imlementation automatically hooks the streams when at least one target is registered, and unhooks them when the last target unregisters.
    Author:
    Rene Schneider - initial API and implementation
    • Constructor Detail

      • DefaultConsoleOutputInterceptor

        public DefaultConsoleOutputInterceptor()
    • Method Detail

      • updateStreamCapture

        protected void updateStreamCapture()
        Reevaluates whether the streams are to be captured at the time of calling, and hooks or unhooks the streams as necessary.
      • printlnStdErr

        public void printlnStdErr​(java.lang.String aLine)
        Description copied from interface: ConsoleOutputInterceptor
        Prints a line on the original System.err stream, including an added newline. Automatically flushes the stream.
        Specified by:
        printlnStdErr in interface ConsoleOutputInterceptor
        Parameters:
        aLine - the line
        See Also:
        PrintWriter.println(String)
      • printStdErr

        public void printStdErr​(java.lang.String aText)
        Description copied from interface: ConsoleOutputInterceptor
        Prints text on the original System.err stream.
        Specified by:
        printStdErr in interface ConsoleOutputInterceptor
        Parameters:
        aText - the text to print
        See Also:
        PrintWriter.print(String)
      • printlnStdOut

        public void printlnStdOut​(java.lang.String aLine)
        Description copied from interface: ConsoleOutputInterceptor
        Prints a line on the original System.out stream, including an added newline. Automatically flushes the stream.
        Specified by:
        printlnStdOut in interface ConsoleOutputInterceptor
        Parameters:
        aLine - the line
        See Also:
        PrintWriter.println(String)
      • printStdOut

        public void printStdOut​(java.lang.String aText)
        Description copied from interface: ConsoleOutputInterceptor
        Prints text on the original System.out stream.
        Specified by:
        printStdOut in interface ConsoleOutputInterceptor
        Parameters:
        aText - the text to print
        See Also:
        PrintWriter.print(String)