本文整理了Java中freemarker.core.Environment.getTemplateNumberFormatWithoutCache()
方法的一些代码示例,展示了Environment.getTemplateNumberFormatWithoutCache()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.getTemplateNumberFormatWithoutCache()
方法的具体详情如下:
包路径:freemarker.core.Environment
类名称: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
/**
* Gets the {@link TemplateNumberFormat} <em>for the current locale</em>.
*
* @param formatString
* Not {@code null}
* @param cacheResult
* If the results should stored in the {@link Environment}-level cache. It will still try to get the
* result from the cache regardless of this parameter.
*/
private TemplateNumberFormat getTemplateNumberFormat(String formatString, boolean cacheResult)
throws TemplateValueFormatException {
if (cachedTemplateNumberFormats == null) {
if (cacheResult) {
cachedTemplateNumberFormats = new HashMap<String, TemplateNumberFormat>();
}
} else {
TemplateNumberFormat format = cachedTemplateNumberFormats.get(formatString);
if (format != null) {
return format;
}
}
TemplateNumberFormat format = getTemplateNumberFormatWithoutCache(formatString, getLocale());
if (cacheResult) {
cachedTemplateNumberFormats.put(formatString, format);
}
return format;
}
代码示例来源:origin: org.freemarker/freemarker
/**
* Returns the number format as {@link TemplateNumberFormat}, for the given format string and locale. To get a
* number format for the current locale, use {@link #getTemplateNumberFormat(String)} instead.
*
* <p>
* Note on performance (which was true at least for 2.3.24): Unless the locale happens to be equal to the current
* locale, the {@link Environment}-level format cache can't be used, so the format string has to be parsed and the
* matching factory has to be get an invoked, which is much more expensive than getting the format from the cache.
* Thus the returned format should be stored by the caller for later reuse (but only within the current thread and
* in relation to the current {@link Environment}), if it will be needed frequently.
*
* @param formatString
* A string that you could also use as the value of the {@code numberFormat} configuration setting.
* @param locale
* The locale of the number format; not {@code null}.
*
* @since 2.3.24
*/
public TemplateNumberFormat getTemplateNumberFormat(String formatString, Locale locale)
throws TemplateValueFormatException {
if (locale.equals(getLocale())) {
getTemplateNumberFormat(formatString);
}
return getTemplateNumberFormatWithoutCache(formatString, locale);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
/**
* Gets the {@link TemplateNumberFormat} <em>for the current locale</em>.
*
* @param formatString
* Not {@code null}
* @param cacheResult
* If the results should stored in the {@link Environment}-level cache. It will still try to get the
* result from the cache regardless of this parameter.
*/
private TemplateNumberFormat getTemplateNumberFormat(String formatString, boolean cacheResult)
throws TemplateValueFormatException {
if (cachedTemplateNumberFormats == null) {
if (cacheResult) {
cachedTemplateNumberFormats = new HashMap<String, TemplateNumberFormat>();
}
} else {
TemplateNumberFormat format = cachedTemplateNumberFormats.get(formatString);
if (format != null) {
return format;
}
}
TemplateNumberFormat format = getTemplateNumberFormatWithoutCache(formatString, getLocale());
if (cacheResult) {
cachedTemplateNumberFormats.put(formatString, format);
}
return format;
}
代码示例来源:origin: org.freemarker/freemarker-gae
/**
* Gets the {@link TemplateNumberFormat} <em>for the current locale</em>.
*
* @param formatString
* Not {@code null}
* @param cacheResult
* If the results should stored in the {@link Environment}-level cache. It will still try to get the
* result from the cache regardless of this parameter.
*/
private TemplateNumberFormat getTemplateNumberFormat(String formatString, boolean cacheResult)
throws TemplateValueFormatException {
if (cachedTemplateNumberFormats == null) {
if (cacheResult) {
cachedTemplateNumberFormats = new HashMap<String, TemplateNumberFormat>();
}
} else {
TemplateNumberFormat format = cachedTemplateNumberFormats.get(formatString);
if (format != null) {
return format;
}
}
TemplateNumberFormat format = getTemplateNumberFormatWithoutCache(formatString, getLocale());
if (cacheResult) {
cachedTemplateNumberFormats.put(formatString, format);
}
return format;
}
代码示例来源:origin: org.freemarker/freemarker-gae
/**
* Returns the number format as {@link TemplateNumberFormat}, for the given format string and locale. To get a
* number format for the current locale, use {@link #getTemplateNumberFormat(String)} instead.
*
* <p>
* Note on performance (which was true at least for 2.3.24): Unless the locale happens to be equal to the current
* locale, the {@link Environment}-level format cache can't be used, so the format string has to be parsed and the
* matching factory has to be get an invoked, which is much more expensive than getting the format from the cache.
* Thus the returned format should be stored by the caller for later reuse (but only within the current thread and
* in relation to the current {@link Environment}), if it will be needed frequently.
*
* @param formatString
* A string that you could also use as the value of the {@code numberFormat} configuration setting.
* @param locale
* The locale of the number format; not {@code null}.
*
* @since 2.3.24
*/
public TemplateNumberFormat getTemplateNumberFormat(String formatString, Locale locale)
throws TemplateValueFormatException {
if (locale.equals(getLocale())) {
getTemplateNumberFormat(formatString);
}
return getTemplateNumberFormatWithoutCache(formatString, locale);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
/**
* Returns the number format as {@link TemplateNumberFormat}, for the given format string and locale. To get a
* number format for the current locale, use {@link #getTemplateNumberFormat(String)} instead.
*
* <p>
* Note on performance (which was true at least for 2.3.24): Unless the locale happens to be equal to the current
* locale, the {@link Environment}-level format cache can't be used, so the format string has to be parsed and the
* matching factory has to be get an invoked, which is much more expensive than getting the format from the cache.
* Thus the returned format should be stored by the caller for later reuse (but only within the current thread and
* in relation to the current {@link Environment}), if it will be needed frequently.
*
* @param formatString
* A string that you could also use as the value of the {@code numberFormat} configuration setting.
* @param locale
* The locale of the number format; not {@code null}.
*
* @since 2.3.24
*/
public TemplateNumberFormat getTemplateNumberFormat(String formatString, Locale locale)
throws TemplateValueFormatException {
if (locale.equals(getLocale())) {
getTemplateNumberFormat(formatString);
}
return getTemplateNumberFormatWithoutCache(formatString, locale);
}
内容来源于网络,如有侵权,请联系作者删除!