_TemplateAPI.checkVersionNotNullAndSupported(incompatibleImprovements); locale = _TemplateAPI.getDefaultLocale(); properties.setProperty(LOCALE_KEY, locale.toString()); timeZone = _TemplateAPI.getDefaultTimeZone(); properties.setProperty(TIME_ZONE_KEY, timeZone.getID()); properties.setProperty(CLASSIC_COMPATIBLE_KEY, classicCompatible.toString()); templateExceptionHandler = _TemplateAPI.getDefaultTemplateExceptionHandler(incompatibleImprovements); properties.setProperty(TEMPLATE_EXCEPTION_HANDLER_KEY, templateExceptionHandler.getClass().getName()); wrapUncheckedExceptions = _TemplateAPI.getDefaultWrapUncheckedExceptions(incompatibleImprovements); attemptExceptionReporter = _TemplateAPI.getDefaultAttemptExceptionReporter(incompatibleImprovements); _TemplateAPI.getDefaultLogTemplateExceptions(incompatibleImprovements)); properties.setProperty(LOG_TEMPLATE_EXCEPTIONS_KEY, logTemplateExceptions.toString());
/** * Same as {@link #TemplateCache(TemplateLoader, CacheStorage, Configuration)} with a new {@link SoftCacheStorage} * as the 2nd parameter. * * @since 2.3.21 */ public TemplateCache(TemplateLoader templateLoader, Configuration config) { this(templateLoader, _TemplateAPI.createDefaultCacheStorage(Configuration.VERSION_2_3_0), config); }
/** * Returns a template cache that will first try to load a template from * the file system relative to the current user directory (i.e. the value * of the system property <code>user.dir</code>), then from the classpath. * * @deprecated Use {@link #TemplateCache(TemplateLoader)} instead. The default loader is useless in most * applications, also it can mean a security risk. */ @Deprecated public TemplateCache() { this(_TemplateAPI.createDefaultTemplateLoader(Configuration.VERSION_2_3_0)); }
/** * Same as * {@link #TemplateCache(TemplateLoader, CacheStorage, TemplateLookupStrategy, TemplateNameFormat, Configuration)} * with {@link TemplateLookupStrategy#DEFAULT_2_3_0} and {@link TemplateNameFormat#DEFAULT_2_3_0}. * * @since 2.3.21 */ public TemplateCache(TemplateLoader templateLoader, CacheStorage cacheStorage, Configuration config) { this(templateLoader, cacheStorage, _TemplateAPI.getDefaultTemplateLookupStrategy(Configuration.VERSION_2_3_0), _TemplateAPI.getDefaultTemplateNameFormat(Configuration.VERSION_2_3_0), config); }
private static Version normalizeTemplateLanguageVersion(Version incompatibleImprovements) { _TemplateAPI.checkVersionNotNullAndSupported(incompatibleImprovements); int v = incompatibleImprovements.intValue(); if (v < _TemplateAPI.VERSION_INT_2_3_19) { return Configuration.VERSION_2_3_0; } else if (v > _TemplateAPI.VERSION_INT_2_3_21) { return Configuration.VERSION_2_3_21; } else { // if 2.3.19 or 2.3.20 or 2.3.21 return incompatibleImprovements; } }
/** * The work around the problematic cases where we should throw a {@link TemplateException}, but we are inside * a {@link TemplateModel} method and so we can only throw {@link TemplateModelException}-s. */ public static TemplateModelException ensureIsTemplateModelException(String modelOpMsg, TemplateException e) { if (e instanceof TemplateModelException) { return (TemplateModelException) e; } else { return new _TemplateModelException( _TemplateAPI.getBlamedExpression(e), e.getCause(), e.getEnvironment(), modelOpMsg); } }
if (Arrays.binarySearch(SETTING_NAMES, key) < 0) { StringBuilder sb = new StringBuilder(); if (_TemplateAPI.getConfigurationSettingNames(cfg, true).contains(key) || _TemplateAPI.getConfigurationSettingNames(cfg, false).contains(key)) { sb.append("The setting name is recognized, but changing this setting from inside a template isn't " + "supported.");
/** * Returns the lowest version number that is equivalent with the parameter version. * * @since 2.3.22 */ protected static Version normalizeIncompatibleImprovementsVersion(Version incompatibleImprovements) { _TemplateAPI.checkVersionNotNullAndSupported(incompatibleImprovements); Version bwIcI = BeansWrapper.normalizeIncompatibleImprovementsVersion(incompatibleImprovements); return incompatibleImprovements.intValue() < _TemplateAPI.VERSION_INT_2_3_22 || bwIcI.intValue() >= _TemplateAPI.VERSION_INT_2_3_22 ? bwIcI : Configuration.VERSION_2_3_22; }
/** * Same as * {@link #TemplateCache(TemplateLoader, CacheStorage, TemplateLookupStrategy, TemplateNameFormat, Configuration)} * with {@link TemplateLookupStrategy#DEFAULT_2_3_0} and {@link TemplateNameFormat#DEFAULT_2_3_0}. * * @since 2.3.21 */ public TemplateCache(TemplateLoader templateLoader, CacheStorage cacheStorage, Configuration config) { this(templateLoader, cacheStorage, _TemplateAPI.getDefaultTemplateLookupStrategy(Configuration.VERSION_2_3_0), _TemplateAPI.getDefaultTemplateNameFormat(Configuration.VERSION_2_3_0), config); }
/** * The work around the problematic cases where we should throw a {@link TemplateException}, but we are inside * a {@link TemplateModel} method and so we can only throw {@link TemplateModelException}-s. */ public static TemplateModelException ensureIsTemplateModelException(String modelOpMsg, TemplateException e) { if (e instanceof TemplateModelException) { return (TemplateModelException) e; } else { return new _TemplateModelException( _TemplateAPI.getBlamedExpression(e), e.getCause(), e.getEnvironment(), modelOpMsg); } }
if (Arrays.binarySearch(SETTING_NAMES, key) < 0) { StringBuilder sb = new StringBuilder(); if (_TemplateAPI.getConfigurationSettingNames(cfg, true).contains(key) || _TemplateAPI.getConfigurationSettingNames(cfg, false).contains(key)) { sb.append("The setting name is recognized, but changing this setting from inside a template isn't " + "supported.");
_TemplateAPI.checkVersionNotNullAndSupported(incompatibleImprovements); locale = _TemplateAPI.getDefaultLocale(); properties.setProperty(LOCALE_KEY, locale.toString()); timeZone = _TemplateAPI.getDefaultTimeZone(); properties.setProperty(TIME_ZONE_KEY, timeZone.getID()); properties.setProperty(CLASSIC_COMPATIBLE_KEY, classicCompatible.toString()); templateExceptionHandler = _TemplateAPI.getDefaultTemplateExceptionHandler(incompatibleImprovements); properties.setProperty(TEMPLATE_EXCEPTION_HANDLER_KEY, templateExceptionHandler.getClass().getName()); wrapUncheckedExceptions = _TemplateAPI.getDefaultWrapUncheckedExceptions(incompatibleImprovements); attemptExceptionReporter = _TemplateAPI.getDefaultAttemptExceptionReporter(incompatibleImprovements); _TemplateAPI.getDefaultLogTemplateExceptions(incompatibleImprovements)); properties.setProperty(LOG_TEMPLATE_EXCEPTIONS_KEY, logTemplateExceptions.toString());
/** * Returns the lowest version number that is equivalent with the parameter version. * @since 2.3.21 */ protected static Version normalizeIncompatibleImprovementsVersion(Version incompatibleImprovements) { _TemplateAPI.checkVersionNotNullAndSupported(incompatibleImprovements); if (incompatibleImprovements.intValue() < _TemplateAPI.VERSION_INT_2_3_0) { throw new IllegalArgumentException("Version must be at least 2.3.0."); } return incompatibleImprovements.intValue() >= _TemplateAPI.VERSION_INT_2_3_27 ? Configuration.VERSION_2_3_27 : incompatibleImprovements.intValue() == _TemplateAPI.VERSION_INT_2_3_26 ? Configuration.VERSION_2_3_26 : is2324Bugfixed(incompatibleImprovements) ? Configuration.VERSION_2_3_24 : is2321Bugfixed(incompatibleImprovements) ? Configuration.VERSION_2_3_21 : Configuration.VERSION_2_3_0; }
/** * Same as * {@link #TemplateCache(TemplateLoader, CacheStorage, TemplateLookupStrategy, TemplateNameFormat, Configuration)} * with {@link TemplateLookupStrategy#DEFAULT_2_3_0} and {@link TemplateNameFormat#DEFAULT_2_3_0}. * * @since 2.3.21 */ public TemplateCache(TemplateLoader templateLoader, CacheStorage cacheStorage, Configuration config) { this(templateLoader, cacheStorage, _TemplateAPI.getDefaultTemplateLookupStrategy(Configuration.VERSION_2_3_0), _TemplateAPI.getDefaultTemplateNameFormat(Configuration.VERSION_2_3_0), config); }
/** * Returns the deprecated default template loader of FreeMarker 2.3.0. * * @deprecated The {@link TemplateLoader} should be always specified by the constructor caller. */ @Deprecated protected static TemplateLoader createLegacyDefaultTemplateLoader() { return _TemplateAPI.createDefaultTemplateLoader(Configuration.VERSION_2_3_0); }
/** * Same as {@link #TemplateCache(TemplateLoader, CacheStorage, Configuration)} with a new {@link SoftCacheStorage} * as the 2nd parameter. * * @since 2.3.21 */ public TemplateCache(TemplateLoader templateLoader, Configuration config) { this(templateLoader, _TemplateAPI.createDefaultCacheStorage(Configuration.VERSION_2_3_0), config); }
/** * The work around the problematic cases where we should throw a {@link TemplateException}, but we are inside * a {@link TemplateModel} method and so we can only throw {@link TemplateModelException}-s. */ public static TemplateModelException ensureIsTemplateModelException(String modelOpMsg, TemplateException e) { if (e instanceof TemplateModelException) { return (TemplateModelException) e; } else { return new _TemplateModelException( _TemplateAPI.getBlamedExpression(e), e.getCause(), e.getEnvironment(), modelOpMsg); } }
if (Arrays.binarySearch(SETTING_NAMES, key) < 0) { StringBuilder sb = new StringBuilder(); if (_TemplateAPI.getConfigurationSettingNames(cfg, true).contains(key) || _TemplateAPI.getConfigurationSettingNames(cfg, false).contains(key)) { sb.append("The setting name is recognized, but changing this setting from inside a template isn't " + "supported.");
_TemplateAPI.checkVersionNotNullAndSupported(incompatibleImprovements); locale = _TemplateAPI.getDefaultLocale(); properties.setProperty(LOCALE_KEY, locale.toString()); timeZone = _TemplateAPI.getDefaultTimeZone(); properties.setProperty(TIME_ZONE_KEY, timeZone.getID()); properties.setProperty(CLASSIC_COMPATIBLE_KEY, classicCompatible.toString()); templateExceptionHandler = _TemplateAPI.getDefaultTemplateExceptionHandler(incompatibleImprovements); properties.setProperty(TEMPLATE_EXCEPTION_HANDLER_KEY, templateExceptionHandler.getClass().getName()); wrapUncheckedExceptions = _TemplateAPI.getDefaultWrapUncheckedExceptions(incompatibleImprovements); attemptExceptionReporter = _TemplateAPI.getDefaultAttemptExceptionReporter(incompatibleImprovements); _TemplateAPI.getDefaultLogTemplateExceptions(incompatibleImprovements)); properties.setProperty(LOG_TEMPLATE_EXCEPTIONS_KEY, logTemplateExceptions.toString());
/** * @param incompatibleImprovements * See the corresponding parameter of {@link BeansWrapper#BeansWrapper(Version)}. Not {@code null}. Note * that the version will be normalized to the lowest version where the same incompatible * {@link BeansWrapper} improvements were already present, so for the returned instance * {@link #getIncompatibleImprovements()} might returns a lower version than what you have specified * here. * @param isIncompImprsAlreadyNormalized * Tells if the {@code incompatibleImprovements} parameter contains an <em>already normalized</em> value. * This parameter meant to be {@code true} when the class that extends {@link BeansWrapper} needs to add * additional breaking versions over those of {@link BeansWrapper}. Thus, if this parameter is * {@code true}, the versions where {@link BeansWrapper} had breaking changes must be already factored * into the {@code incompatibleImprovements} parameter value, as no more normalization will happen. (You * can use {@link BeansWrapper#normalizeIncompatibleImprovementsVersion(Version)} to discover those.) * * @since 2.3.22 */ protected BeansWrapperConfiguration(Version incompatibleImprovements, boolean isIncompImprsAlreadyNormalized) { _TemplateAPI.checkVersionNotNullAndSupported(incompatibleImprovements); incompatibleImprovements = isIncompImprsAlreadyNormalized ? incompatibleImprovements : BeansWrapper.normalizeIncompatibleImprovementsVersion(incompatibleImprovements); this.incompatibleImprovements = incompatibleImprovements; preferIndexedReadMethod = incompatibleImprovements.intValue() < _TemplateAPI.VERSION_INT_2_3_27; classIntrospectorBuilder = new ClassIntrospectorBuilder(incompatibleImprovements); }