Class AnsiOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable
    Direct Known Subclasses:
    ColorizedOutputStream

    public abstract class AnsiOutputStream
    extends java.io.PrintStream
    An output stream that supports customized output via ANSI control codes
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<OutputStreamControlTracker> controls  
      • Fields inherited from class java.io.FilterOutputStream

        out
    • Constructor Summary

      Constructors 
      Constructor Description
      AnsiOutputStream​(java.io.OutputStream output)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void applyAll()
      Method which applies any necessary controls to the stream
      void close()  
      void registerControl​(OutputStreamControlTracker control)
      Registers a control
      void registerControls​(OutputStreamControlTracker... controls)
      Registers some controls
      void reset​(boolean full)
      Resets the stream to the default state i.e.
      protected void resetAll()
      Method which resets the state of any controls that have been previously enabled and applied to the stream
      void write​(byte[] b)  
      void write​(byte[] b, int off, int len)  
      void write​(int b)  
      • Methods inherited from class java.io.PrintStream

        append, append, append, checkError, clearError, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AnsiOutputStream

        public AnsiOutputStream​(java.io.OutputStream output)
    • Method Detail

      • registerControl

        public final void registerControl​(OutputStreamControlTracker control)
        Registers a control

        This method can be useful if you wish to add additional controls beyond those provided by a specific class derived from this abstract class.

        Parameters:
        control - Control
      • registerControls

        public final void registerControls​(OutputStreamControlTracker... controls)
        Registers some controls
        Parameters:
        controls - Controls
      • write

        public void write​(int b)
        Overrides:
        write in class java.io.PrintStream
      • write

        public void write​(byte[] b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
        Overrides:
        write in class java.io.PrintStream
      • applyAll

        protected final void applyAll()
        Method which applies any necessary controls to the stream
      • reset

        public void reset​(boolean full)
        Resets the stream to the default state i.e. disables all controls that may previously have been applied such as colors, text decorations etc
        Parameters:
        full - If true do a full graphics reset in addition to resetting the individual controls
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.PrintStream
      • resetAll

        protected final void resetAll()
        Method which resets the state of any controls that have been previously enabled and applied to the stream