本文整理了Java中java.util.ResourceBundle.containsKey
方法的一些代码示例,展示了ResourceBundle.containsKey
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceBundle.containsKey
方法的具体详情如下:
包路径:java.util.ResourceBundle
类名称:ResourceBundle
方法名:containsKey
[英]Determines whether the given key
is contained in this ResourceBundle
or its parent bundles.
[中]确定给定的key
是否包含在此ResourceBundle
或其父捆绑包中。
代码示例来源:origin: spring-projects/spring-framework
/**
* 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;
}
代码示例来源:origin: spullara/mustache.java
final protected String lookup(String key) {
if (res.containsKey(key)) {
return res.getString(key); // return translation
} else {
return returnLabels ? key : null;
}
}
}
代码示例来源:origin: killbill/killbill
@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;
}
}
}
}
代码示例来源:origin: org.springframework/spring-context
/**
* 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;
}
代码示例来源:origin: cucumber/cucumber-jvm
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;
}
代码示例来源:origin: spullara/mustache.java
/** 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;
}
}
代码示例来源:origin: wildfly/wildfly
@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);
}
代码示例来源:origin: wildfly/wildfly
@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);
}
代码示例来源:origin: wildfly/wildfly
@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);
}
代码示例来源:origin: wildfly/wildfly
@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);
}
代码示例来源:origin: wildfly/wildfly
@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);
}
代码示例来源:origin: wildfly/wildfly
@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);
}
代码示例来源:origin: wildfly/wildfly
@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);
}
代码示例来源:origin: wildfly/wildfly
@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);
}
代码示例来源:origin: wildfly/wildfly
@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);
}
代码示例来源:origin: wildfly/wildfly
@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);
}
代码示例来源:origin: wildfly/wildfly
@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);
}
代码示例来源:origin: wildfly/wildfly
@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);
}
代码示例来源:origin: GlowstoneMC/Glowstone
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));
}
代码示例来源:origin: wildfly/wildfly
@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);
}
内容来源于网络,如有侵权,请联系作者删除!