Package eu.bandm.tools.message
Class Message
java.lang.Object
eu.bandm.tools.message.Message
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
SimpleMessage
Abstract base class of the metatools message architecture.
Does have as attributes only a
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, resp. on a subclass thereof.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Fundamental enum type for categorization of allMessage
objects. -
Field Summary
FieldsModifier and TypeFieldDescriptionA throwable which has been caught and thus caused this message.static final int
Value of level, unless explicitly given.static final StackTraceElement[]
An empty stack trace.protected final Message.Kind
The kind of the message.protected int
Numeric qualification, can by used to realize levels of verbosity.protected long
The system time when this message is created. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a clone, but with newer date,protected
Create a message with only kind and timestamp set.protected
Message
(Message.Kind k, int v) Create a message with kind, level, and timestamp set.protected
Message
(Message.Kind k, int v, @Opt Throwable e) Create a message with kind, level, cause, and timestamp set.protected
Message
(Message.Kind k, @Opt Throwable e) Create a message with kind, cause, and timestamp set.protected
Creates a message ofMessage.Kind.failure
kind. -
Method Summary
Modifier and TypeMethodDescription(package private) void
adjustTimeStamp
(long ts) Not public, only for internal re-adjustment after a clone.explode()
Throws an exception carrying this message.getCause()
Returns the cause of the message.final Message.Kind
getKind()
Returns the kind of the message.final int
getLevel()
Returns the level of the message.final StackTraceElement[]
Returns aStackTraceElement
[] taken from the "cause", if there is one.final long
Returns the time when this message was constructed.final boolean
Distinguishes betweenMessage.Kind.error
andMessage.Kind.failure
as "critical" and all others as "uncritical".toString()
Delivers a primitive visualisation, required for tracing and debugging.
-
Field Details
-
kind
The kind of the message. -
timestamp
protected long timestampThe system time when this message is created. -
cause
A throwable which has been caught and thus caused this message. -
DEFAULT_LEVEL
public static final int DEFAULT_LEVELValue of level, unless explicitly given.- See Also:
-
level
protected int levelNumeric qualification, can by used to realize levels of verbosity.- See Also:
-
emptyStackTrace
An empty stack trace.
-
-
Constructor Details
-
Message
Create a message with only kind and timestamp set.- Parameters:
k
- the kind of the message.
-
Message
Create a message with kind, cause, and timestamp set.- Parameters:
k
- the kind of the message.e
- the cause of the message.
-
Message
Create a message with kind, level, and timestamp set.- Parameters:
k
- the kind of the message.v
- the level of the message.
-
Message
Create a message with kind, level, cause, and timestamp set.- Parameters:
k
- the kind of the message.v
- the level of the message.e
- the cause of the message.
-
Message
Creates a message ofMessage.Kind.failure
kind.- Parameters:
e
- the cause of the message.
-
Message
Creates a clone, but with newer date,- Parameters:
original
- the message to clone.
-
-
Method Details
-
getKind
Returns the kind of the message.- Returns:
- the kind of the message.
-
getLevel
public final int getLevel()Returns the level of the message.- Returns:
- the level of the message.
-
adjustTimeStamp
void adjustTimeStamp(long ts) Not public, only for internal re-adjustment after a clone.- Parameters:
ts
- the new value of the time stamp.
-
isCritical
public final boolean isCritical()Distinguishes betweenMessage.Kind.error
andMessage.Kind.failure
as "critical" and all others as "uncritical".- Returns:
- whether the message is of kind failure or error.
- See Also:
-
getTimeStamp
public final long getTimeStamp()Returns the time when this message was constructed. It is encoded according toSystem.currentTimeMillis()
.- Returns:
- the time when this message was constructed.
-
getCause
Returns the cause of the message.- Returns:
- the cause of the message.
-
getStackTrace
Returns aStackTraceElement
[] 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.- Returns:
- the stack trace form the ".cause", if there is any,
-
toString
Delivers a primitive visualisation, required for tracing and debugging. An actual user-levelMessagePrinter
or sim., will provide much more elaborate rendering. -
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 athrow
statement to inform the Java compiler's control flow analysis that the call never completes normally. - Throws:
MessageException
- which encapsulates this Message
-