Class Printer

  • All Implemented Interfaces:
    CSProcess

    public class Printer
    extends java.lang.Object
    implements CSProcess
    Prints each Object from its input channel to a PrintStream.

    Process Diagram

    Description

    Printer is a process for printing each object from its in channel to a PrintStream object (by default, System.out).

    For convenience, Printer may be configured with prefix and postfix strings with which to decorate its output.

    Channel Protocols

    Input Channels
    in java.lang.Object The in Channel can accept data of any Class.

    Example

    See the example in Merge.
    See Also:
    Parallel
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private ChannelInput in
      The channel from which to read
      private java.lang.String postfix
      The string to write after each object
      private java.lang.String prefix
      The string to write in front of each object
      private java.io.PrintStream printStream
      The stream to which to write
    • Constructor Summary

      Constructors 
      Constructor Description
      Printer​(ChannelInput in)
      Construct a new Printer with System.out as its PrintStream and empty prefix and postfix strings.
      Printer​(ChannelInput in, java.io.PrintStream printStream)
      Construct a new Printer with empty prefix and postfix strings.
      Printer​(ChannelInput in, java.io.PrintStream printStream, java.lang.String prefix, java.lang.String postfix)
      Construct a new Printer.
      Printer​(ChannelInput in, java.lang.String prefix, java.lang.String postfix)
      Construct a new Printer with System.out as its PrintStream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void run()
      The main body of this process.
      • Methods inherited from class java.lang.Object

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

      • in

        private ChannelInput in
        The channel from which to read
      • printStream

        private java.io.PrintStream printStream
        The stream to which to write
      • prefix

        private java.lang.String prefix
        The string to write in front of each object
      • postfix

        private java.lang.String postfix
        The string to write after each object
    • Constructor Detail

      • Printer

        public Printer​(ChannelInput in)
        Construct a new Printer with System.out as its PrintStream and empty prefix and postfix strings.
        Parameters:
        in - the channel from which to read
      • Printer

        public Printer​(ChannelInput in,
                       java.lang.String prefix,
                       java.lang.String postfix)
        Construct a new Printer with System.out as its PrintStream.
        Parameters:
        in - the channel from which to read
        prefix - the string to write in front of each object
        postfix - the string to write after each object
      • Printer

        public Printer​(ChannelInput in,
                       java.io.PrintStream printStream)
        Construct a new Printer with empty prefix and postfix strings.
        Parameters:
        in - the channel from which to read
        printStream - the stream to which to write
      • Printer

        public Printer​(ChannelInput in,
                       java.io.PrintStream printStream,
                       java.lang.String prefix,
                       java.lang.String postfix)
        Construct a new Printer.
        Parameters:
        in - he channel from which to read
        printStream - the stream to which to write
        prefix - the string to write in front of each object
        postfix - the string to write after each object
    • Method Detail

      • run

        public void run()
        The main body of this process.
        Specified by:
        run in interface CSProcess