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.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Wraps any text as argument, which itself shall be translated and formatted. -
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 TypeMethodDescriptionstatic MessageFormatter.Formandum
Convenience method to wrap an argument string and mark it for translation and formatting.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) EvidentMethods inherited from class eu.bandm.tools.message.SingleSender
getReceiver, send, setReceiver
-
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 -
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>>
- 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
". AnyMessageFormatter.Formandum
is treated recursively. Any formatting which fails returns the concatenation of the text, an error text and theObject.toString()
results of the arguments. -
process
Applies the text as a format to the arguments. -
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 "%%
". AnyMessageFormatter.Formandum
is treated recursively. Any formatting which fails returns the concatenation of the text, an error text and theObject.toString()
results of the arguments. -
formandum
Convenience method to wrap an argument string and mark it for translation and formatting.
-