Package org.codehaus.groovy.control.messages

# Class SimpleMessage

java.lang.Object
org.codehaus.groovy.control.messages.Message
org.codehaus.groovy.control.messages.SimpleMessage

Direct Known Subclasses:
  `LocatedMessage`

public class SimpleMessage extends Message
A base class for compilation messages.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Object`
  `data`
  used when `message` is an I18N identifier
  `protected String`
  `message`
  Message text to render.
  `protected ProcessingUnit`
  `owner`
  Processing unit that owns the message.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SimpleMessage(String message, Object data, ProcessingUnit owner)`
  Creates a simple message with optional auxiliary data.
  `SimpleMessage(String message, ProcessingUnit owner)`
  Creates a simple message with no auxiliary data.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getMessage()`
  Returns the message text.
  `Diagnostic`
  `toDiagnostic()`
  Returns a format-neutral view of this message: its text and, when known, the source and position it applies to.
  `void`
  `write(PrintWriter writer, Janitor janitor)`
  Writes this message, prefixing it with the source name when available.

  ### Methods inherited from class org.codehaus.groovy.control.messages.Message

  `create, create, create, write`

  ### Methods inherited from class java.lang.Object

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

- ## Field Details

  - ### data

    protected Object data
    used when `message` is an I18N identifier

  - ### message

    protected String message
    Message text to render.

  - ### owner

    protected ProcessingUnit owner
    Processing unit that owns the message.

- ## Constructor Details

  - ### SimpleMessage

    public SimpleMessage(String message, ProcessingUnit owner)
    Creates a simple message with no auxiliary data.
    Parameters:
      `message` - the message text
      `owner` - the owning processing unit

  - ### SimpleMessage

    public SimpleMessage(String message, Object data, ProcessingUnit owner)
    Creates a simple message with optional auxiliary data.
    Parameters:
      `message` - the message text
      `data` - supplemental message data
      `owner` - the owning processing unit

- ## Method Details

  - ### getMessage

    public String getMessage()
    Returns the message text.
    Returns:
      the message text

  - ### toDiagnostic

    public Diagnostic toDiagnostic()
    Description copied from class: `Message`
    Returns a format-neutral view of this message: its text and, when known, the source and position it applies to. Layouts other than the full one are rendered from this rather than from the message classes (GROOVY-12312).

    The default captures the output of `Message.write(PrintWriter)` as the text, with no file or position, so that a subclass which does not override this still renders in every format.

    Overrides:
      `toDiagnostic` in class `Message`
    Returns:
      the diagnostic view, never `null`

  - ### write

    public void write(PrintWriter writer, Janitor janitor)
    Writes this message, prefixing it with the source name when available.
    Specified by:
      `write` in class `Message`
    Parameters:
      `writer` - the destination writer
      `janitor` - the cleanup helper for temporary source access