String (final String methodName, final Class componentClass, Module module) { final boolean needIndex = haveSetDisplayedMnemonic(componentClass, module); return "/** @noinspection ALL */ " + "private void " + methodName + "(" + componentClass.getName() + " component, java.lang.String text) {" + " StringBuffer result = new StringBuffer(); " + " boolean haveMnemonic = false; " + " char mnemonic = '\\0';" + (needIndex ? "int mnemonicIndex = -1;" : "") + " for(int i=0; i<text.length(); i++) {" + " if (text.charAt(i) == '&') {" + " i++;" + " if (i == text.length()) break;" + " if (!haveMnemonic && text.charAt(i) != '&') {" + " haveMnemonic = true;" + " mnemonic = text.charAt(i);" + (needIndex ? "mnemonicIndex = result.length();" : "") + " }" + " }" + " result.append(text.charAt(i));" + " }" + " component.setText(result.toString()); " + " if (haveMnemonic) {" + (componentClass.equals(AbstractButton.class) ? " component.setMnemonic(mnemonic);" : " component.setDisplayedMnemonic(mnemonic);") + (needIndex ? "component.setDisplayedMnemonicIndex(mnemonicIndex);" : "") + "} }"; }