freemarker.core.Environment.getTemplateNumberFormatWithoutCache()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(118)

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

Environment.getTemplateNumberFormatWithoutCache介绍

[英]Returns the TemplateNumberFormat for the given parameters without using the Environment-level cache. Of course, the TemplateNumberFormatFactory involved might still uses its own cache.
[中]返回给定参数的TemplateNumberFormat,而不使用环境级缓存。当然,涉及的TemplateNumberFormatFactory可能仍然使用自己的缓存。

代码示例

代码示例来源:origin: org.freemarker/freemarker

  1. /**
  2. * Gets the {@link TemplateNumberFormat} <em>for the current locale</em>.
  3. *
  4. * @param formatString
  5. * Not {@code null}
  6. * @param cacheResult
  7. * If the results should stored in the {@link Environment}-level cache. It will still try to get the
  8. * result from the cache regardless of this parameter.
  9. */
  10. private TemplateNumberFormat getTemplateNumberFormat(String formatString, boolean cacheResult)
  11. throws TemplateValueFormatException {
  12. if (cachedTemplateNumberFormats == null) {
  13. if (cacheResult) {
  14. cachedTemplateNumberFormats = new HashMap<String, TemplateNumberFormat>();
  15. }
  16. } else {
  17. TemplateNumberFormat format = cachedTemplateNumberFormats.get(formatString);
  18. if (format != null) {
  19. return format;
  20. }
  21. }
  22. TemplateNumberFormat format = getTemplateNumberFormatWithoutCache(formatString, getLocale());
  23. if (cacheResult) {
  24. cachedTemplateNumberFormats.put(formatString, format);
  25. }
  26. return format;
  27. }

代码示例来源:origin: org.freemarker/freemarker

  1. /**
  2. * Returns the number format as {@link TemplateNumberFormat}, for the given format string and locale. To get a
  3. * number format for the current locale, use {@link #getTemplateNumberFormat(String)} instead.
  4. *
  5. * <p>
  6. * Note on performance (which was true at least for 2.3.24): Unless the locale happens to be equal to the current
  7. * locale, the {@link Environment}-level format cache can't be used, so the format string has to be parsed and the
  8. * matching factory has to be get an invoked, which is much more expensive than getting the format from the cache.
  9. * Thus the returned format should be stored by the caller for later reuse (but only within the current thread and
  10. * in relation to the current {@link Environment}), if it will be needed frequently.
  11. *
  12. * @param formatString
  13. * A string that you could also use as the value of the {@code numberFormat} configuration setting.
  14. * @param locale
  15. * The locale of the number format; not {@code null}.
  16. *
  17. * @since 2.3.24
  18. */
  19. public TemplateNumberFormat getTemplateNumberFormat(String formatString, Locale locale)
  20. throws TemplateValueFormatException {
  21. if (locale.equals(getLocale())) {
  22. getTemplateNumberFormat(formatString);
  23. }
  24. return getTemplateNumberFormatWithoutCache(formatString, locale);
  25. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker

  1. /**
  2. * Gets the {@link TemplateNumberFormat} <em>for the current locale</em>.
  3. *
  4. * @param formatString
  5. * Not {@code null}
  6. * @param cacheResult
  7. * If the results should stored in the {@link Environment}-level cache. It will still try to get the
  8. * result from the cache regardless of this parameter.
  9. */
  10. private TemplateNumberFormat getTemplateNumberFormat(String formatString, boolean cacheResult)
  11. throws TemplateValueFormatException {
  12. if (cachedTemplateNumberFormats == null) {
  13. if (cacheResult) {
  14. cachedTemplateNumberFormats = new HashMap<String, TemplateNumberFormat>();
  15. }
  16. } else {
  17. TemplateNumberFormat format = cachedTemplateNumberFormats.get(formatString);
  18. if (format != null) {
  19. return format;
  20. }
  21. }
  22. TemplateNumberFormat format = getTemplateNumberFormatWithoutCache(formatString, getLocale());
  23. if (cacheResult) {
  24. cachedTemplateNumberFormats.put(formatString, format);
  25. }
  26. return format;
  27. }

代码示例来源:origin: org.freemarker/freemarker-gae

  1. /**
  2. * Gets the {@link TemplateNumberFormat} <em>for the current locale</em>.
  3. *
  4. * @param formatString
  5. * Not {@code null}
  6. * @param cacheResult
  7. * If the results should stored in the {@link Environment}-level cache. It will still try to get the
  8. * result from the cache regardless of this parameter.
  9. */
  10. private TemplateNumberFormat getTemplateNumberFormat(String formatString, boolean cacheResult)
  11. throws TemplateValueFormatException {
  12. if (cachedTemplateNumberFormats == null) {
  13. if (cacheResult) {
  14. cachedTemplateNumberFormats = new HashMap<String, TemplateNumberFormat>();
  15. }
  16. } else {
  17. TemplateNumberFormat format = cachedTemplateNumberFormats.get(formatString);
  18. if (format != null) {
  19. return format;
  20. }
  21. }
  22. TemplateNumberFormat format = getTemplateNumberFormatWithoutCache(formatString, getLocale());
  23. if (cacheResult) {
  24. cachedTemplateNumberFormats.put(formatString, format);
  25. }
  26. return format;
  27. }

代码示例来源:origin: org.freemarker/freemarker-gae

  1. /**
  2. * Returns the number format as {@link TemplateNumberFormat}, for the given format string and locale. To get a
  3. * number format for the current locale, use {@link #getTemplateNumberFormat(String)} instead.
  4. *
  5. * <p>
  6. * Note on performance (which was true at least for 2.3.24): Unless the locale happens to be equal to the current
  7. * locale, the {@link Environment}-level format cache can't be used, so the format string has to be parsed and the
  8. * matching factory has to be get an invoked, which is much more expensive than getting the format from the cache.
  9. * Thus the returned format should be stored by the caller for later reuse (but only within the current thread and
  10. * in relation to the current {@link Environment}), if it will be needed frequently.
  11. *
  12. * @param formatString
  13. * A string that you could also use as the value of the {@code numberFormat} configuration setting.
  14. * @param locale
  15. * The locale of the number format; not {@code null}.
  16. *
  17. * @since 2.3.24
  18. */
  19. public TemplateNumberFormat getTemplateNumberFormat(String formatString, Locale locale)
  20. throws TemplateValueFormatException {
  21. if (locale.equals(getLocale())) {
  22. getTemplateNumberFormat(formatString);
  23. }
  24. return getTemplateNumberFormatWithoutCache(formatString, locale);
  25. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker

  1. /**
  2. * Returns the number format as {@link TemplateNumberFormat}, for the given format string and locale. To get a
  3. * number format for the current locale, use {@link #getTemplateNumberFormat(String)} instead.
  4. *
  5. * <p>
  6. * Note on performance (which was true at least for 2.3.24): Unless the locale happens to be equal to the current
  7. * locale, the {@link Environment}-level format cache can't be used, so the format string has to be parsed and the
  8. * matching factory has to be get an invoked, which is much more expensive than getting the format from the cache.
  9. * Thus the returned format should be stored by the caller for later reuse (but only within the current thread and
  10. * in relation to the current {@link Environment}), if it will be needed frequently.
  11. *
  12. * @param formatString
  13. * A string that you could also use as the value of the {@code numberFormat} configuration setting.
  14. * @param locale
  15. * The locale of the number format; not {@code null}.
  16. *
  17. * @since 2.3.24
  18. */
  19. public TemplateNumberFormat getTemplateNumberFormat(String formatString, Locale locale)
  20. throws TemplateValueFormatException {
  21. if (locale.equals(getLocale())) {
  22. getTemplateNumberFormat(formatString);
  23. }
  24. return getTemplateNumberFormatWithoutCache(formatString, locale);
  25. }

相关文章

Environment类方法