Class MsgPrinter


  • public class MsgPrinter
    extends java.lang.Object
    This utility class formats messages to the specified line width, by inserting line-breaks between words, and printing the resulting lines.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int lw
      The line width to use
    • Constructor Summary

      Constructors 
      Constructor Description
      MsgPrinter​(int linewidth)
      Creates a new message printer with the specified line width and with the default locale.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getLineWidth()
      Returns the line width that is used for formatting.
      void print​(java.io.PrintWriter out, int flind, int ind, java.lang.String msg)
      Formats the message to print in the current line width, by breaking the message into lines between words.
      void setLineWidth​(int linewidth)
      Sets the line width to the specified value.
      • Methods inherited from class java.lang.Object

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

      • lw

        public int lw
        The line width to use
    • Constructor Detail

      • MsgPrinter

        public MsgPrinter​(int linewidth)
        Creates a new message printer with the specified line width and with the default locale.
        Parameters:
        linewidth - The line width for which to format (in characters)
    • Method Detail

      • getLineWidth

        public int getLineWidth()
        Returns the line width that is used for formatting.
        Returns:
        The line width used for formatting
      • setLineWidth

        public void setLineWidth​(int linewidth)
        Sets the line width to the specified value. This new value will be used in subsequent calls to the print() message.
        Parameters:
        linewidth - The new line width to use (in cahracters)
      • print

        public void print​(java.io.PrintWriter out,
                          int flind,
                          int ind,
                          java.lang.String msg)
        Formats the message to print in the current line width, by breaking the message into lines between words. The number of spaces to indent the first line is specified by 'flind' and the number of spaces to indent each of the following lines is specified by 'ind'. Newlines in 'msg' are respected. A newline is always printed at the end.
        Parameters:
        out - Where to print the message.
        flind - The indentation for the first line.
        ind - The indentation for the other lines.
        msg - The message to format and print.