Refine search
/** * Efficiently retrieve the String value for the specified key, * or return {@code null} if not found. * <p>As of 4.2, the default implementation checks {@code containsKey} * before it attempts to call {@code getString} (which would require * catching {@code MissingResourceException} for key not found). * <p>Can be overridden in subclasses. * @param bundle the ResourceBundle to perform the lookup in * @param key the key to look up * @return the associated value, or {@code null} if none * @since 4.2 * @see ResourceBundle#getString(String) * @see ResourceBundle#containsKey(String) */ @Nullable protected String getStringOrNull(ResourceBundle bundle, String key) { if (bundle.containsKey(key)) { try { return bundle.getString(key); } catch (MissingResourceException ex){ // Assume key not found for some other reason // -> do NOT throw the exception to allow for checking parent message source. } } return null; }
final protected String lookup(String key) { if (res.containsKey(key)) { return res.getString(key); // return translation } else { return returnLabels ? key : null; } } }
@Override public String getTranslation(final String originalText) { if (originalText == null) { return null; } if ((bundle != null) && (bundle.containsKey(originalText))) { return bundle.getString(originalText); } else { if ((defaultBundle != null) && (defaultBundle.containsKey(originalText))) { return defaultBundle.getString(originalText); } else { return originalText; } } } }
/** * Efficiently retrieve the String value for the specified key, * or return {@code null} if not found. * <p>As of 4.2, the default implementation checks {@code containsKey} * before it attempts to call {@code getString} (which would require * catching {@code MissingResourceException} for key not found). * <p>Can be overridden in subclasses. * @param bundle the ResourceBundle to perform the lookup in * @param key the key to look up * @return the associated value, or {@code null} if none * @since 4.2 * @see ResourceBundle#getString(String) * @see ResourceBundle#containsKey(String) */ @Nullable protected String getStringOrNull(ResourceBundle bundle, String key) { if (bundle.containsKey(key)) { try { return bundle.getString(key); } catch (MissingResourceException ex){ // Assume key not found for some other reason // -> do NOT throw the exception to allow for checking parent message source. } } return null; }
public final Set<String> apply(final ResourceBundle resourceBundle) { final LinkedHashSet<String> result = new LinkedHashSet<String>(); if (resourceBundle != null && resourceBundle.containsKey(CUSTOM_INJECTION_PROVIDER_CLASSES)) { final String csvProperty = resourceBundle.getString(CUSTOM_INJECTION_PROVIDER_CLASSES); for (final String className : csvProperty.split(",")) { if (className != null) { final String trim = className.trim(); if (!"".equals(trim)) { result.add(trim); } } } } return result; }
/** Return translation from the localized ResourceBundle. */ @Override public String apply(String input) { String[] inputWithParams = input.split(" "); String key = inputWithParams[0]; if(!res.containsKey(key)) { return input; // return untranslated label } String translatedValue = res.getString(key); for (int i = 1; i < inputWithParams.length; i++) { String[] splitParam = inputWithParams[i].split("="); String oldTag = splitParam[0]; String newTag = splitParam[1]; translatedValue = translatedValue.replace("{{" + oldTag + "}}", "{{" + newTag + "}}"); } return translatedValue; } }
@Override public String getOperationParameterValueTypeDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle, String... suffixes) { for (PathElement path : this.paths) { String key = this.getBundleKey(path, operationName.equals(ModelDescriptionConstants.ADD) ? new String[] { paramName } : new String[] { operationName, paramName }, suffixes); if (bundle.containsKey(key)) { return bundle.getString(key); } } return this.parent.getOperationParameterValueTypeDescription(operationName, paramName, locale, bundle, suffixes); }
@Override public String getOperationParameterDeprecatedDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle) { for (PathElement path : this.paths) { String key = this.getBundleKey(path, operationName.equals(ModelDescriptionConstants.ADD) ? new String[] { paramName } : new String[] { operationName, paramName }, ModelDescriptionConstants.DEPRECATED); if (bundle.containsKey(key)) { return bundle.getString(key); } } return this.parent.getOperationParameterDeprecatedDescription(operationName, paramName, locale, bundle); }
@Override public String getOperationParameterDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle) { for (PathElement path : this.paths) { String key = this.getBundleKey(path, operationName.equals(ModelDescriptionConstants.ADD) ? new String[] { paramName } : new String[] { operationName, paramName }); if (bundle.containsKey(key)) { return bundle.getString(key); } } return this.parent.getOperationParameterDescription(operationName, paramName, locale, bundle); }
@Override public String getResourceAttributeDescription(String attributeName, Locale locale, ResourceBundle bundle) { for (PathElement path : this.paths) { String key = this.getBundleKey(path, attributeName); if (bundle.containsKey(key)) { return bundle.getString(key); } } return this.parent.getResourceAttributeDescription(attributeName, locale, bundle); }
@Override public String getResourceAttributeValueTypeDescription(String attributeName, Locale locale, ResourceBundle bundle, String... suffixes) { for (PathElement path : this.paths) { String key = this.getBundleKey(path, attributeName, suffixes); if (bundle.containsKey(key)) { return bundle.getString(key); } } return this.parent.getResourceAttributeValueTypeDescription(attributeName, locale, bundle, suffixes); }
@Override public String getResourceDeprecatedDescription(Locale locale, ResourceBundle bundle) { for (PathElement path : this.paths) { String key = this.getBundleKey(path, ModelDescriptionConstants.DEPRECATED); if (bundle.containsKey(key)) { return bundle.getString(key); } } return this.parent.getResourceDeprecatedDescription(locale, bundle); }
@Override public String getResourceAttributeDeprecatedDescription(String attributeName, Locale locale, ResourceBundle bundle) { for (PathElement path : this.paths) { String key = this.getBundleKey(path, attributeName, ModelDescriptionConstants.DEPRECATED); if (bundle.containsKey(key)) { return bundle.getString(key); } } return this.parent.getResourceAttributeDeprecatedDescription(attributeName, locale, bundle); }
@Override public String getOperationReplyValueTypeDescription(String operationName, Locale locale, ResourceBundle bundle, String... suffixes) { for (PathElement path : this.paths) { String key = this.getBundleKey(path, new String[] { operationName, StandardResourceDescriptionResolver.REPLY }, suffixes); if (bundle.containsKey(key)) { return bundle.getString(key); } } return this.parent.getOperationReplyValueTypeDescription(operationName, locale, bundle, suffixes); }
@Override public String getNotificationDescription(String notificationType, Locale locale, ResourceBundle bundle) { for (PathElement path : this.paths) { String key = this.getBundleKey(path, notificationType); if (bundle.containsKey(key)) { return bundle.getString(key); } } return this.parent.getNotificationDescription(notificationType, locale, bundle); }
@Override public String getResourceDescription(Locale locale, ResourceBundle bundle) { for (PathElement path : this.paths) { String key = this.getBundleKey(path); if (bundle.containsKey(key)) { return bundle.getString(key); } } return this.parent.getResourceDescription(locale, bundle); }
@Override public String getOperationDescription(String operationName, Locale locale, ResourceBundle bundle) { for (PathElement path : this.paths) { String key = this.getBundleKey(path, operationName); if (bundle.containsKey(key)) { return bundle.getString(key); } } return this.parent.getOperationDescription(operationName, locale, bundle); }
@Override public String getOperationReplyDescription(String operationName, Locale locale, ResourceBundle bundle) { for (PathElement path : this.paths) { String key = this.getBundleKey(path, new String[] { operationName, StandardResourceDescriptionResolver.REPLY }); if (bundle.containsKey(key)) { return bundle.getString(key); } } return this.parent.getOperationReplyDescription(operationName, locale, bundle); }
protected CommandMessages readResourceBundle(ResourceBundle bundle) { String name = getName(); String permissionKey = name + PERMISSION_SUFFIX; return new CommandMessages( bundle, bundle.getString(name + DESCRIPTION_SUFFIX), bundle.getString(name + USAGE_SUFFIX), bundle.getString( bundle.containsKey(permissionKey) ? permissionKey : DEFAULT_PERMISSION)); }
@Override public String getChildTypeDescription(String childType, Locale locale, ResourceBundle bundle) { for (PathElement path : this.paths) { String key = this.getBundleKey(path, childType); if (bundle.containsKey(key)) { return bundle.getString(key); } } return this.parent.getChildTypeDescription(childType, locale, bundle); }