org.springframework.context.support.ResourceBundleMessageSource.getStringOrNull()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(83)

本文整理了Java中org.springframework.context.support.ResourceBundleMessageSource.getStringOrNull方法的一些代码示例,展示了ResourceBundleMessageSource.getStringOrNull的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceBundleMessageSource.getStringOrNull方法的具体详情如下:
包路径:org.springframework.context.support.ResourceBundleMessageSource
类名称:ResourceBundleMessageSource
方法名:getStringOrNull

ResourceBundleMessageSource.getStringOrNull介绍

[英]Efficiently retrieve the String value for the specified key, or return null if not found.

As of 4.2, the default implementation checks containsKeybefore it attempts to call getString (which would require catching MissingResourceException for key not found).

Can be overridden in subclasses.
[中]高效地检索指定键的字符串值,如果找不到,则返回null。
从4.2开始,默认实现会在尝试调用getString之前检查ContainesKeyBefore(这需要捕获未找到密钥的MissingResourceException)。
可以在子类中重写。

代码示例

代码示例来源:origin: spring-projects/spring-framework

String msg = getStringOrNull(bundle, code);
if (msg != null) {
  if (codeMap == null) {

代码示例来源:origin: spring-projects/spring-framework

/**
 * Resolves the given message code as key in the registered resource bundles,
 * returning the value found in the bundle as-is (without MessageFormat parsing).
 */
@Override
protected String resolveCodeWithoutArguments(String code, Locale locale) {
  Set<String> basenames = getBasenameSet();
  for (String basename : basenames) {
    ResourceBundle bundle = getResourceBundle(basename, locale);
    if (bundle != null) {
      String result = getStringOrNull(bundle, code);
      if (result != null) {
        return result;
      }
    }
  }
  return null;
}

代码示例来源:origin: org.springframework/spring-context

String msg = getStringOrNull(bundle, code);
if (msg != null) {
  if (codeMap == null) {

代码示例来源:origin: org.springframework/spring-context

/**
 * Resolves the given message code as key in the registered resource bundles,
 * returning the value found in the bundle as-is (without MessageFormat parsing).
 */
@Override
protected String resolveCodeWithoutArguments(String code, Locale locale) {
  Set<String> basenames = getBasenameSet();
  for (String basename : basenames) {
    ResourceBundle bundle = getResourceBundle(basename, locale);
    if (bundle != null) {
      String result = getStringOrNull(bundle, code);
      if (result != null) {
        return result;
      }
    }
  }
  return null;
}

相关文章

微信公众号

最新文章

更多