private String createGetStringMethod(String lineDelim) throws CoreException { StringBuffer result= new StringBuffer(); result.append("public static String "); //$NON-NLS-1$ int i= fSubstitutionPattern.indexOf(NLSRefactoring.KEY); if (i != -1) { result.append(fSubstitutionPattern.substring(0, i)); result.append("String key"); //$NON-NLS-1$ result.append(fSubstitutionPattern.substring(i + NLSRefactoring.KEY.length())); } else { //fallback result.append("getString(String key)"); //$NON-NLS-1$ } result.append('{').append(lineDelim); result.append("try {").append(lineDelim) //$NON-NLS-1$ .append("return ") //$NON-NLS-1$ .append(getResourceBundleConstantName()).append(".getString(key);").append(lineDelim) //$NON-NLS-1$ .append("} catch (MissingResourceException e) {").append(lineDelim) //$NON-NLS-1$ .append("return '!' + key + '!';").append(lineDelim) //$NON-NLS-1$ .append("}"); //$NON-NLS-1$ result.append(lineDelim).append('}'); return result.toString(); }
private String createGetStringMethod(String lineDelim) { StringBuilder result= new StringBuilder(); result.append("public static String "); //$NON-NLS-1$ int i= fSubstitutionPattern.indexOf(NLSRefactoring.KEY); if (i != -1) { result.append(fSubstitutionPattern.substring(0, i)); result.append("String key"); //$NON-NLS-1$ result.append(fSubstitutionPattern.substring(i + NLSRefactoring.KEY.length())); } else { //fallback result.append("getString(String key)"); //$NON-NLS-1$ } result.append('{').append(lineDelim); result.append("try {").append(lineDelim) //$NON-NLS-1$ .append("return ") //$NON-NLS-1$ .append(getResourceBundleConstantName()).append(".getString(key);").append(lineDelim) //$NON-NLS-1$ .append("} catch (MissingResourceException e) {").append(lineDelim) //$NON-NLS-1$ .append("return '!' + key + '!';").append(lineDelim) //$NON-NLS-1$ .append("}"); //$NON-NLS-1$ result.append(lineDelim).append('}'); return result.toString(); }
private String createGetStringMethod(String lineDelim) { StringBuffer result= new StringBuffer(); result.append("public static String "); //$NON-NLS-1$ int i= fSubstitutionPattern.indexOf(NLSRefactoring.KEY); if (i != -1) { result.append(fSubstitutionPattern.substring(0, i)); result.append("String key"); //$NON-NLS-1$ result.append(fSubstitutionPattern.substring(i + NLSRefactoring.KEY.length())); } else { //fallback result.append("getString(String key)"); //$NON-NLS-1$ } result.append('{').append(lineDelim); result.append("try {").append(lineDelim) //$NON-NLS-1$ .append("return ") //$NON-NLS-1$ .append(getResourceBundleConstantName()).append(".getString(key);").append(lineDelim) //$NON-NLS-1$ .append("} catch (MissingResourceException e) {").append(lineDelim) //$NON-NLS-1$ .append("return '!' + key + '!';").append(lineDelim) //$NON-NLS-1$ .append("}"); //$NON-NLS-1$ result.append(lineDelim).append('}'); return result.toString(); }
result.append(" = \"").append(getResourceBundleName()).append("\"; ").append(NLSElement.createTagText(1)).append(lineDelim); //$NON-NLS-1$ //$NON-NLS-2$ result.append(lineDelim).append("private static final ResourceBundle ").append(getResourceBundleConstantName()); //$NON-NLS-1$ result.append("= ResourceBundle.getBundle(").append(NLSRefactoring.BUNDLE_NAME_FIELD).append(");").append(lineDelim); //$NON-NLS-1$ //$NON-NLS-2$
result.append(" = \"").append(getResourceBundleName()).append("\"; ").append(NLSElement.createTagText(1)).append(lineDelim); //$NON-NLS-1$ //$NON-NLS-2$ result.append(lineDelim).append("private static final ResourceBundle ").append(getResourceBundleConstantName()); //$NON-NLS-1$ result.append("= ResourceBundle.getBundle(").append(NLSRefactoring.BUNDLE_NAME).append(");").append(lineDelim); //$NON-NLS-1$ //$NON-NLS-2$
result.append(" = \"").append(getResourceBundleName()).append("\"; ").append(NLSElement.createTagText(1)).append(lineDelim); //$NON-NLS-1$ //$NON-NLS-2$ result.append(lineDelim).append("private static final ResourceBundle ").append(getResourceBundleConstantName()); //$NON-NLS-1$ result.append("= ResourceBundle.getBundle(").append(NLSRefactoring.BUNDLE_NAME_FIELD).append(");").append(lineDelim); //$NON-NLS-1$ //$NON-NLS-2$