Class Message

java.lang.Object
eu.bandm.tools.message.Message
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
SimpleMessage

public abstract class Message extends Object implements Serializable
Abstract base class of the metatools message architecture.
Does have as attributes only a Kind, a timestamp and a cause. All message processing classes in this package (derived from MessageReceiver) operate on this data.
See Also:
  • Field Details

    • kind

      protected final Message.Kind kind
      Evident
    • timestamp

      protected final long timestamp
      The system time when this message is created.
    • cause

      @Opt protected @Opt Throwable cause
      Evident
    • DEFAULT_LEVEL

      public static final int DEFAULT_LEVEL
      Value of level, unless explicitly given.
      See Also:
    • level

      protected int level
      Numeric qualification, can by used to realize levels of verbosity.
    • emptyStackTrace

      public static final StackTraceElement[] emptyStackTrace
      Evident
  • Constructor Details

    • Message

      protected Message(Message.Kind k)
      Create a message with only kind and timestamp set
    • Message

      protected Message(Message.Kind k, @Opt @Opt Throwable e)
      Create a message with kind, cause and timestamp set
    • Message

      protected Message(Message.Kind k, int v)
      Create a message with kind, level and timestamp set
    • Message

      protected Message(Message.Kind k, int v, @Opt @Opt Throwable e)
      Create a message with kind, level, cause and timestamp set
    • Message

      protected Message(@Opt @Opt Throwable e)
      Creates a message of Message.Kind.failure kind.
    • Message

      protected Message(Message original)
      Creates a clone, but with newer date,
  • Method Details

    • getKind

      public final Message.Kind getKind()
      Evident
    • getLevel

      public final int getLevel()
      Evident
    • isCritical

      public final boolean isCritical()
      Distinguishes in many processing situations between Message.Kind.error and Message.Kind.failure as "critical" and all others as "uncritical". See Kind.isCritical().
    • getTimeStamp

      public final long getTimeStamp()
      returns the time when this message was constructed. It is encoded according to System.currentTimeMillis().
    • getCause

      @Opt public final @Opt Throwable getCause()
      Evident
    • getStackTrace

      public final StackTraceElement[] getStackTrace()
      Returns a StackTraceElement[] taken from the "cause", if there is one.

      The "cause" is the Throwable returned by getCause(). Iff this is null, the method returns an empty array.

    • toString

      public String toString()
      Delivers a primitive visualisation, required for tracing and debugging. An actual user-level MessagePrinter or sim., will provide much more elaborate rendering.
      Overrides:
      toString in class Object
    • explode

      public RuntimeException explode()
      Throws an exception carrying this message.
      Returns:
      nothing; the return type is RuntimeException nevertheless. The calling code can use this method as the argument to a throw statement to inform the Java compiler's control flow analysis that the call never completes normally.
      Throws:
      MessageException