Package eu.bandm.tools.message
Class MessageFormatter<D>
- All Implemented Interfaces:
MessageReceiver<SimpleMessage<D>>
Interprets the
SimpleMessage.args
values as arguments to string
formatting and calls String.format(String,Object...)
.
Propagates to its drain a message with the new text.-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Whether the args are only entered to formatting, but not propagated.Fields inherited from class eu.bandm.tools.message.SingleSender
receiver
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprocess
(PreMessage embed) Applies the text as a format to the arguments.Applies the text as a format to the arguments.void
receive
(SimpleMessage<D> m) Applies the message text as a format to the arguments and propagates the new message to the current drain.render
(SimpleMessage<?> msg) Applies the text as a format to the arguments.void
setStripArgs
(boolean b) Evident.Methods inherited from class eu.bandm.tools.message.SingleSender
getReceiver, send, setReceiver
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface eu.bandm.tools.message.MessageReceiver
ifSubcriticalThen, ifSubcriticalThen, ifSubcriticalThenElse
-
Field Details
-
stripArgs
protected boolean stripArgsWhether the args are only entered to formatting, but not propagated. Initially true.
-
-
Constructor Details
-
MessageFormatter
public MessageFormatter() -
MessageFormatter
-
-
Method Details
-
setStripArgs
public void setStripArgs(boolean b) Evident.- Parameters:
b
- whether to strip the arguments.
-
receive
Applies the message text as a format to the arguments and propagates the new message to the current drain.- Specified by:
receive
in interfaceMessageReceiver<D>
- Overrides:
receive
in classMessagePasser<SimpleMessage<D>>
- Parameters:
m
- the message to receive.- See Also:
-
render
Applies the text as a format to the arguments.String.format(String,Object...)
is called in any case, also with empty arg list, for format codes like "%n
". AnyPreMessage
is treated recursively. Any formatting which fails returns the concatenation of the text, an error text and theObject.toString()
results of the arguments.- Parameters:
msg
- the message to be rendered- Returns:
- a string representation of the message text and the rendered arguments
-
process
Applies the text as a format to the arguments.- Parameters:
embed
- text and arguments to be rendered- Returns:
- a string representation of the message text and the rendered arguments
- See Also:
-
process
Applies the text as a format to the arguments.String.format(String,Object...)
is called in any case, also with empty args list, to format codes like "%n
" and "%%
". AnyPreMessage
is treated recursively.Any formatting which fails returns for diagnosis the concatenation of the text, an error text and the
Object.toString()
results of the arguments.- Parameters:
text
- the format text to be renderedargs
- the arguments to be rendered- Returns:
- a string representation of the message text and the rendered
arguments, or
null
iff the text input isnull
.
-