Class PrintMessage


  • public class PrintMessage
    extends java.lang.Object
    This is an internally used class whose primary purpose is to generate the actual Java-Strings which are printed to the User's Terminal on Error.

    PrintMessage is the core printer class used by the Messager system to emit structured messages to the user’s terminal. Its job is to control the final appearance of the output — including indentation, spacing, line-wrapping, and ANSI color codes — when reporting errors or assertion failures.

    This class is responsible for producing the complete, flushed message block that the user ultimately sees on the screen. It writes directly to the terminal via the screenWriterSW field (defined inside PrintRecord), which acts as the standard output buffer.

    A PrintMessage is not a passive data holder. It is an active builder that provides methods to:

    • Set a heading (e.g., WARNING, ASSERT)
    • Adjust indentation for nested or hierarchical message blocks
    • Add one or more lines of text content
    • Control blank lines before or after the block
    • Apply terminal styles or ANSI color codes

    These methods allow the developer to assemble a well-formatted message interactively, line-by-line, before it is ultimately flushed to the output stream using .print() or a related flush method.

    The structure of a full error message might include:

    • A top-level heading (generated using PrintHeading)
    • A few explanatory lines, indented consistently
    • Optional spacing or blank lines between sections
    • Line-length wrapping, if enabled
    • Final output sent to both the terminal and (optionally) the logging appendable

    Unlike PrintRecord, this class is not a singleton and is not reused. Each instance represents a new block of output, fully constructed and flushed before disposal.

    From the perspective of developers using the Messager API, PrintMessage is the primary class to interact with. It allows you to express the structure, formatting, and context of a message without worrying about the low-level details of terminal output or log writing.

    This class does not manage state across invocations — it simply builds and emits a single message block using the values already available inside PrintRecord.

    Click the “Hi-Lited Source” button above to view the full implementation and method list.


    Written by Chat-GPT, on July 1st, 2025


    • Method Summary

      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait