Class ConsoleAccumulator

java.lang.Object
com.scivicslab.turingworkflow.plugins.logoutput.ConsoleAccumulator
All Implemented Interfaces:
com.scivicslab.pojoactor.core.accumulator.Accumulator

public class ConsoleAccumulator extends Object implements com.scivicslab.pojoactor.core.accumulator.Accumulator
An Accumulator implementation that writes output to the console via PrintStream instances (typically System.out and System.err).

Each entry is formatted with a [source] prefix on every line. Entries with type "stderr" are routed to the error stream; all other types (including "stdout" and "cowsay") are routed to the standard output stream.

When quiet mode is enabled, entries are counted but not printed.

Since:
1.0
Author:
devteam@scivicslab.com
  • Constructor Details

    • ConsoleAccumulator

      public ConsoleAccumulator()
      Constructs a ConsoleAccumulator that writes to System.out and System.err.
    • ConsoleAccumulator

      public ConsoleAccumulator(PrintStream stdout, PrintStream stderr)
      Constructs a ConsoleAccumulator with the specified output streams.
      Parameters:
      stdout - the stream for standard output entries
      stderr - the stream for error output entries
  • Method Details

    • setQuiet

      public void setQuiet(boolean quiet)
      Enables or disables quiet mode. In quiet mode, entries are counted but not printed to the console.
      Parameters:
      quiet - true to suppress output; false to print normally
    • isQuiet

      public boolean isQuiet()
      Returns whether quiet mode is currently enabled.
      Returns:
      true if quiet mode is enabled
    • add

      public void add(String source, String type, String data)

      Routes the entry to stderr if the type is "stderr", otherwise to stdout. If quiet mode is enabled or data is null/empty, the entry is silently counted.

      Specified by:
      add in interface com.scivicslab.pojoactor.core.accumulator.Accumulator
    • getSummary

      public String getSummary()
      Specified by:
      getSummary in interface com.scivicslab.pojoactor.core.accumulator.Accumulator
    • getCount

      public int getCount()
      Specified by:
      getCount in interface com.scivicslab.pojoactor.core.accumulator.Accumulator
    • clear

      public void clear()
      Specified by:
      clear in interface com.scivicslab.pojoactor.core.accumulator.Accumulator