开发者

Java message formatting

开发者 https://www.devze.com 2023-04-13 08:28 出处:网络
I am formatting my messages in a properti开发者_运维技巧es file, but in order to display the desired message fragments I need to validate the arguments... By validate I mean NOT NULL..

I am formatting my messages in a properti开发者_运维技巧es file, but in order to display the desired message fragments I need to validate the arguments... By validate I mean NOT NULL..

ex. LOCATION_NOT_FOUND=Unable to find State: {0} {display only if {1} not null, city:{1}}.

desired output would be- "Unable to find State:New Jersey" if city is not null - "Unable to find State:New Jersey, city:Trenton"

i was thinking about using {1,choice, notnull#city{1}}, but I have no clue if this is correct...

Thanks Guys!


I would have two different messages:

LOCATION_NOT_FOUND_STATE=...
LOCATION_NOT_FOUND_STATE_AND_CITY=...

then format the appropriate one based on what non-null values you have.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号