$NONNLS1$(转载几篇解惑)规格严格

$NONNLS1$(转载几篇解惑)规格严格,第1张

Look at this snap:

public static String valueOf(boolean value) {   
        return value ? "true" : "false"; //$NON-NLS-1$ //$NON-NLS-2$
}    

What is "//$NON-NLS-1$ //$NON-NLS-2$" mean ?

It's used by Eclipse to indicate that a string doesn't need to be translated, probably because it's not going to be seen by the application's users. Netbeans uses NOI18N for the same purpose.

If you don't add that, you'll get a compiler warning. It doesn't stop your code from compiling into a valid class file, but it tells you that you may be doing something undesirable. You are free to ignore the warning. But if you don't want to see it at all--perhaps because too many warnings about something that you're doing on purpose clutters up the output and obscures warnings you do care--then you can add that $NON-NLS-1$ to tell the compiler not to produce the warning.

It's just about fine-tuning which warnings you do and do not care to see.

 

http://my.oschina.net/zengsai/blog/6305

 

--------------------------------------------------------------------------

最近写了很多junit test case, 很多方法的参数用了“XXX”。
组织上要求我把这些不需要国际化的参数后面加上注释//$NON-NLS-1$。
问:有什么办法可以自动加上,因为要改的文件实在太多了,我手动加体力不支吃不消。。。

------------------------------------------------------------------------------------------------------------------
问题补充:

moyan_java 写道

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/2090984.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-07-22
下一篇 2022-07-22

发表评论

登录后才能评论

评论列表(0条)

保存