I am using Eclipse with the PMD Plug-in (4.0.0.v20130510-1000) and get a lot of those violations:
Found \'DD\'-anomaly for variable \'freq\' (line
You could get around this problem (and separate concerns a bit more clearly) by extracting the parsing into a separate method:
double freq = parseDouble(getFrequencyTextField().getText());
// later in the class (or in a utility class):
public static double parseDouble(final String input) {
try {
return Double.parseDouble(input);
} catch (final NumberFormatException e) {
Log.e(e.getMessage());
return 0;
}
}
And if you have different default values, you could also add a two-argument version: public static double parseDouble(final String input, final double defaultValue).