GWT和FindBugs:如何解决“国际化 - 考虑使用Locale参数化版本的调用方法”错误?

时间:2012-01-05 16:32:39

标签: gwt locale findbugs

我正在努力实现FindBugs和GWT 2.4之间的和谐(与Java 6一起使用)。 FindBugs抱怨这条线......

childrenStr.append(child.getName().toLowerCase());

错误

Internationalization - Consider using Locale parameterized version of invoked method

为了尝试治愈疼痛,我添加了一个Locale ......

childrenStr.append(child.getName().toLowerCase(Locale.ENGLISH));

然后GWT因编译错误而死...

[ERROR] Line 346: The method toLowerCase() in the type String is not applicable for the arguments (Locale)

如何在两者之间实现持久和平,从而解决FindBugs错误并保持GWT安静?

谢谢, - 戴夫

1 个答案:

答案 0 :(得分:3)

由于GWT doesn't include support用于区域设置敏感的String#toLowerCase(Locale)方法,并且GWT API中没有区域设置敏感的小写转换,suppress FindBugs DM_CONVERT_CASE警告:

@edu.umd.cs.findbugs.annotations.SuppressWarnings(
    value="DM_CONVERT_CASE", 
    justification="No GWT emulation of String#toLowerCase(Locale)")
public void lowercaseUser() {
  childrenStr.append(child.getName().toLowerCase());
}