您的位置:首页 > 其它

What does $NON-NLS-1$ mean?

2013-07-12 17:26 260 查看
private static final String
BUNDLE_NAME = "net.tourbook.statistics.messages";
//$NON-NLS-1$

They silence a warning that Eclipse emits when it encounters string literals (and has been configured to complain).

The idea is that UI messages should not be embedded as string literals, but rather sourced from a resource file (so that they can be translated, proofed, etc). Consequently, Eclipse can be configured to detect string literals, so
that you don't accidentally have leave unexternalized UI strings in the code;
however, there are strings which should not be externalized (such as regexps) and so, //$NON-NLS-1$ gives you a way to communicate that fact to the compiler.

The warning in Eclipse can be turned on/off at
Window
-> preferences -> java -> Compiler -> code style -> "Non-externalized Strings (missing/unused $NON-NLS$ tag)
.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: