Skip navigation links
SKB Base: 0.2.0

Package de.vandermeer.skb.base.managers

Classes that manage other classes or artifacts, for instance a message manager.

See: Description

Package de.vandermeer.skb.base.managers Description

Classes that manage other classes or artifacts, for instance a message manager.

Message Renderer MessageRenderer

To use the message renderer create a new renderer. Three constructors are provided: This standard template is pointed to by MessageRenderer.DEFAULT_STG_FN. A default STGroup is also provided here MessageRenderer.DEFAULT_STG. Any loaded STGroup will be validated against the required chunks. Those chunks define the expected methods and arguments the template must provide. The chunks are defined in MessageRenderer.STG_CHUNKS as follows: All but one arguments in the template will be provided with simple objects. The exception is the type argument, which can have the following values: Once a renderer is created and the STGroup successfully loaded it can be used to render message object or collections of message objects. Simply call the appropriate render method. Let's create a message first:

	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 following example loads a renderer using a defined template (in the src/test/resources of the package source) and uses that to render the message above:

	Message5WH_Renderer ren = new Message5WH_Renderer("de/vandermeer/skb/base/message/5wh-example.stg");
	String rendered = ren.render(msg);
	System.out.println(rendered);
 
With this template the same message will render as:
        showing a test message in the package API documentation created by from Test_Examples as a demo added to the package JavaDoc 
        This has been reported:
        - by The Author
        - as info
        - at noon
 
Version:
v0.2.0 build 170404 (04-Apr-17) for Java 1.8
Author:
Sven van der Meer <vdmeer.sven@mykolab.com>
Skip navigation links
SKB Base: 0.2.0

Copyright © 2010–2017. All rights reserved.