See: Description
| Class | Description |
|---|---|
| Message5WH |
Standard SKB message.
|
| Message5WH_Builder |
Builder for a
Message5WH object. |
| Enum | Description |
|---|---|
| E_MessageType |
Types for
Message5WH. |
Message5WH - the actual message object with all the parts introduced above.Message5WH_Builder - a builder object that is used to create a message object.MessageRenderer - a renderer object that is used to render a message before printing or storing.E_MessageType - an enumerate for the supported message types, e.g. info, warning, error.FormattingTupleWrapper - a wrapper to create SLF4J formatting tuples and convert them into strings when needed.
The wrapper creates a new formatting tuple and uses its getMessage() method in toString().
Message5WH msg = new Message5WH_Builder()
.setWho("from " + this.getClass().getSimpleName())
.addWhat("showing a test message")
.setWhen(null)
.setWhere("the package API documentation", 0, 0)
.addWhy("as a demo")
.addHow("added to the package JavaDoc")
.setReporter("The Author")
.setType(EMessageType.INFO)
.build()
;
The builder provides methods to set the who, when, and where parts of the message as well as the reporter and the type. For the what, why, and how parts the builder provides methods to add to existing information. The where part of a message as a special case is supported with several methods to be set.
Once all information is set, the builder can be instructed to build an actual message using the build() method.
The message class provides a render() method to render a message.
Internally, this method creates a StrBuilder, fills it conditional with all information of the message, and returns the string representation of that builder.
The Author: from Test_Examples at (noon) in the package API documentation showing a test message
==> as a demo
==> added to the package JavaDoc
Changing the render output requires to create a new class inheriting from the Message5WH class and overwriting the render() method.
Alternatively, one can implement a message renderer with any required functionality.
The package 'managers' does exactly that: implement a message renderer that uses string templates and provides many options to render single messages, collections of messages and some classes that use message objects.
Copyright © 2010–2017. All rights reserved.