Java MessageFormat resource with optional parameter?
Is it possible to have an optional parameter to a message format? I have
code that history for something with an event type and parameters encoded
as strings. This gets loaded by other code and does a resource lookup
based on the type name (i.e. eventtype..format), and then passes the
stored parameters.
One of the event types is 'action performed because user-defined rule
matched'. Previously, I didn't include the rule name as one of the
parameters, and now I want to, so I was hoping to be able to use the same
event type without redefining it just to add a parameter.
My question is, is it possible to do something like this
eventtype.matchedRule.format=Action performed because of user-defined rule
{if{0},(Rule name:{0})}
so that if an event type of 'matchedRule' is loaded and has no parameters
defined, this resolves to
"Action performed because of user-defined rule"
and if rule name was defined as "My Rule", it would be resolved to
"Action performed because of user-defined rule (Rule name: My Rule)"
Again, I don't really have control to pass a different resource at the
time if there are no parameters, so I'd have to define a separate event
type, which would be something like matchedRuleWithRuleName for new events
that get stored, and leave the ones already stored with matchedRule.
Help?
No comments:
Post a Comment