de.caff.util.debug

## Class DebugMessageCook

- java.lang.Object
- - de.caff.util.debug.DebugMessageCook

- All Implemented Interfaces:
    AnyMessageDebugListener, AssertionMessageDebugListener, DebugConstants, ErrorMessageDebugListener, FatalMessageDebugListener, LogMessageListener, StandardMessageDebugListener, TraceMessageDebugListener, WarningMessageDebugListener

      class DebugMessageCook
      extends java.lang.Object
      implements AnyMessageDebugListener, DebugConstants

  This class "cooks" debug messages. I.e. the messages are prepended with date and type information and extended with a line showing where the message was created. The message itself is inserted by a tab.
  Author:
    Rammi
  See Also:
    `Debug`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) static class` | `DebugMessageCook.ListenerData` Data collection for listener.

  - ### Field Summary

    - ### Fields inherited from interface de.caff.util.debug.DebugConstants

      `ASSERT, ASSERT_CHAR, ASSERT_FLAG, DEBUG_ALL_MASK, ERROR, ERROR_CHAR, ERROR_FLAG, FATAL, FATAL_CHAR, FATAL_FLAG, LOG, LOG_CHAR, LOG_FLAG, MESSAGE, MESSAGE_CHAR, MESSAGE_FLAG, NO_DEBUG_MASK, NR_DEBUG_TYPES, TRACE, TRACE_CHAR, TRACE_FLAG, WARNING, WARNING_CHAR, WARNING_FLAG`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DebugMessageCook()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addListener(CookedMessageDebugListener listener)` Add a listener.
    `void` | `addListener(CookedMessageDebugListener listener, boolean stopOnFatalErrors, boolean throwAssertionException)` Add a listener.
    `static java.lang.String` | `cookedPosition(java.lang.String pos)` Get a position in default cooked format.
    `void` | `receiveErrorMessage(java.lang.String msg, java.lang.String pos)` Receive an error debug message, cook it and serve it to the listeners.
    `boolean` | `receiveFailedAssertionMessage(java.lang.String msg, java.lang.String pos)` Receive a failed assertion message, cook it and serve it to the listeners.
    `int` | `receiveFatalMessage(java.lang.String msg, java.lang.String pos)` Receive a fatal error message, cook it and serve it to the listeners.
    `void` | `receiveLogMessage(java.lang.String msg, java.lang.String pos)` Receive a logging message, cook it and serve it to the listeners.
    `void` | `receiveStandardMessage(java.lang.String msg, java.lang.String pos)` Receive a standard debug message, cook it and serve it to the listeners.
    `void` | `receiveTraceMessage(java.lang.String msg, java.lang.String pos)` Receive a trace debug message, cook it and serve it to the listeners.
    `void` | `receiveWarningMessage(java.lang.String msg, java.lang.String pos)` Receive a warning debug message, cook it and serve it to the listeners.
    `void` | `removeListener(CookedMessageDebugListener listener)` Remove a listener.

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

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

- - ### Constructor Detail

    - #### DebugMessageCook

          DebugMessageCook()

  - ### Method Detail

    - #### addListener

          public void addListener(@NotNull
                                  CookedMessageDebugListener listener)

      Add a listener. This one stops on fatal errors and throws an exception on failed assertions.
      Parameters:
        `listener` - the listener waiting to be served by this cook

    - #### addListener

          public void addListener(@NotNull
                                  CookedMessageDebugListener listener,
                                  boolean stopOnFatalErrors,
                                  boolean throwAssertionException)

      Add a listener.
      Parameters:
        `listener` - the listener waiting to be served by this cook
        `stopOnFatalErrors` - stop program on fatal errors?
        `throwAssertionException` - throw exception on failed assertions?

    - #### removeListener

          public void removeListener(@NotNull
                                     CookedMessageDebugListener listener)

      Remove a listener.
      Parameters:
        `listener` - listener to be removed

    - #### receiveTraceMessage

          public void receiveTraceMessage(@NotNull
                                          java.lang.String msg,
                                          @NotNull
                                          java.lang.String pos)

      Receive a trace debug message, cook it and serve it to the listeners.
      Specified by:
        `receiveTraceMessage` in interface `TraceMessageDebugListener`
      Parameters:
        `msg` - the raw message
        `pos` - postion

    - #### receiveStandardMessage

          public void receiveStandardMessage(@NotNull
                                             java.lang.String msg,
                                             @NotNull
                                             java.lang.String pos)

      Receive a standard debug message, cook it and serve it to the listeners.
      Specified by:
        `receiveStandardMessage` in interface `StandardMessageDebugListener`
      Parameters:
        `msg` - the raw message
        `pos` - postion

    - #### receiveWarningMessage

          public void receiveWarningMessage(@NotNull
                                            java.lang.String msg,
                                            @NotNull
                                            java.lang.String pos)

      Receive a warning debug message, cook it and serve it to the listeners.
      Specified by:
        `receiveWarningMessage` in interface `WarningMessageDebugListener`
      Parameters:
        `msg` - the raw message
        `pos` - postion

    - #### receiveErrorMessage

          public void receiveErrorMessage(@NotNull
                                          java.lang.String msg,
                                          @NotNull
                                          java.lang.String pos)

      Receive an error debug message, cook it and serve it to the listeners.
      Specified by:
        `receiveErrorMessage` in interface `ErrorMessageDebugListener`
      Parameters:
        `msg` - the raw message
        `pos` - postion

    - #### receiveLogMessage

          public void receiveLogMessage(@NotNull
                                        java.lang.String msg,
                                        @NotNull
                                        java.lang.String pos)

      Receive a logging message, cook it and serve it to the listeners.
      Specified by:
        `receiveLogMessage` in interface `LogMessageListener`
      Parameters:
        `msg` - the raw message
        `pos` - postion

    - #### receiveFatalMessage

          public int receiveFatalMessage(@NotNull
                                         java.lang.String msg,
                                         @NotNull
                                         java.lang.String pos)

      Receive a fatal error message, cook it and serve it to the listeners. If the listener list is empty, `0` is returned.
      Specified by:
        `receiveFatalMessage` in interface `FatalMessageDebugListener`
      Parameters:
        `msg` - the raw message
        `pos` - postion
      Returns:
        not equal to `0` for exit
        else keep program running

    - #### receiveFailedAssertionMessage

          public boolean receiveFailedAssertionMessage(@NotNull
                                                       java.lang.String msg,
                                                       @NotNull
                                                       java.lang.String pos)

      Receive a failed assertion message, cook it and serve it to the listeners. If the listener list is empty, `false` is returned.
      Specified by:
        `receiveFailedAssertionMessage` in interface `AssertionMessageDebugListener`
      Parameters:
        `msg` - the raw message
        `pos` - postion
      Returns:
        throw an assertion?

    - #### cookedPosition

          public static java.lang.String cookedPosition(java.lang.String pos)

      Get a position in default cooked format.
      Parameters:
        `pos` - position string
      Returns:
        cooked version to be appended to a message