public class Message5WH extends Object implements Skb_Renderable
The class comprises methods to build a message (add*, set*), methods to access a message (get*) and some additional
methods to process a complete message (asST, render, toString). Additionally, it carries an enumerate EMessageType for typing messages.
Message properties that have a "set" method (reporter, type, when, where, who) can only be set once and are immutable afterwards.
For message properties that have an "add" method (how, what, why) information can be appended unlimited, but once added it cannot be removed.
The simplest way to create a message is to use the the builder methods. The following example creates a new message and sets all of its properties:
Message5WH msg=new Message5WH()
.setWho("from "+this.getClass().getSimpleName())
.addWhat("showing a test message")
.setWhen(null)
.setWhere("the class API documentation", 0, 0)
.addWhy("as a demo")
.addHow("added to the class JavaDoc")
.setReporter("The Author")
.setType(EMessageType.INFO)
;
This message will print to the following lines:
The Author: info from Message5WHTests in the class API documentation >> showing a test message
==> as a demo
==> added to the class JavaDoc
| Modifier and Type | Field and Description |
|---|---|
protected int |
initialCapacity
Initial capacity for StrBuilder members
|
static String |
messageSTGroup
The default STGroup definition for the 5WH message class.
|
static Map<String,List<String>> |
stChunks |
| Constructor and Description |
|---|
Message5WH()
Simple constructor setting/loading defaults for the object.
|
| Modifier and Type | Method and Description |
|---|---|
Message5WH |
addHow(Object... how)
Builder method: adds to the How? part of the message.
|
Message5WH |
addWhat(Object... what)
Builder method: adds to the What? part of the message.
|
Message5WH |
addWhy(Object... why)
Builder method: adds to the Why? part of the message.
|
org.apache.commons.lang3.text.StrBuilder |
getHow()
Returns the How? part of the message.
|
Object |
getReporter()
Returns the reporter of the message
|
EMessageType |
getType()
Returns the type of the message.
|
org.apache.commons.lang3.text.StrBuilder |
getWhat()
Returns the What? part of the message.
|
Object |
getWhen()
Returns the When? part of the message.
|
org.stringtemplate.v4.ST |
getWhere()
Returns the Where? part of the message.
|
Object |
getWho()
Returns the Who? part of the message.
|
org.apache.commons.lang3.text.StrBuilder |
getWhy()
Returns the Why? part of the message.
|
String |
render()
Renders the message for output.
|
Message5WH |
setReporter(Object reporter)
Builder method: sets the Reporter of the message.
|
Message5WH |
setSTG(org.stringtemplate.v4.STGroup stg)
Sets a new STGroup for the message.
|
Message5WH |
setType(EMessageType type)
Builder method: sets the type of the message.
|
Message5WH |
setWhen(Object when)
Builder method: sets the When? part of the message.
|
Message5WH |
setWhere(Object where) |
Message5WH |
setWhere(Object where,
int line,
int column)
Builder method: sets the Where? part of the message.
|
Message5WH |
setWhere(Object where,
org.antlr.v4.runtime.ParserRuleContext lineAndColumn)
Builder method: sets the Where? part of the message.
|
Message5WH |
setWhere(Object where,
org.antlr.v4.runtime.RecognitionException lineAndColumn)
Builder method: sets the Where? part of the message.
|
Message5WH |
setWhere(Object where,
org.antlr.v4.runtime.Token lineAndColumn)
Builder method: sets the Where? part of the message.
|
Message5WH |
setWhere(StackTraceElement ste)
Builder method: sets the Where? part of the message.
|
Message5WH |
setWho(Object who)
Builder method: sets the Who? part of the message.
|
Set<String> |
testSTG(org.stringtemplate.v4.STGroup stg)
Tests the given STGroup.
|
String |
toString()
Returns a string representation of the message for debugging purpose, but not the rendered output.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitOBJECT_TO_RENDERABLE_VALUEpublic static final String messageSTGroup
protected int initialCapacity
public Message5WH()
public Message5WH addHow(Object... how)
how - additional information for How?public Message5WH addWhat(Object... what)
what - additional information for What?public Message5WH addWhy(Object... why)
why - additional information for Why?public Message5WH setSTG(org.stringtemplate.v4.STGroup stg)
where and message5wh. The default templates are
defined in messageSTGroup.stg - new STGrouppublic Set<String> testSTG(org.stringtemplate.v4.STGroup stg)
where and message5wh and their required arguments.
The required arguments are provided by stChunks.stg - STGroup to testpublic String render()
render in interface Skb_Renderablepublic org.apache.commons.lang3.text.StrBuilder getHow()
public Object getReporter()
public EMessageType getType()
public org.apache.commons.lang3.text.StrBuilder getWhat()
public Object getWhen()
public org.stringtemplate.v4.ST getWhere()
public Object getWho()
public org.apache.commons.lang3.text.StrBuilder getWhy()
public Message5WH setReporter(Object reporter)
reporter - new reporterpublic Message5WH setType(EMessageType type)
type - new typepublic Message5WH setWhen(Object when)
when - new When? partpublic Message5WH setWhere(Object where, int line, int column)
where - location for Where?line - line for Where?, ignored if <1;column - column for Where?, ignored if <1public Message5WH setWhere(Object where, org.antlr.v4.runtime.RecognitionException lineAndColumn)
where - location for Where?lineAndColumn - source for the Where? partpublic Message5WH setWhere(Object where)
public Message5WH setWhere(Object where, org.antlr.v4.runtime.Token lineAndColumn)
where - location for Where?lineAndColumn - source for the Where? partpublic Message5WH setWhere(Object where, org.antlr.v4.runtime.ParserRuleContext lineAndColumn)
where - location for Where?lineAndColumn - source for the Where? partpublic Message5WH setWhere(StackTraceElement ste)
ste - source for the Where? partpublic Message5WH setWho(Object who)
who - new Who? partCopyright © 2010–2015. All rights reserved.