The new (in 2.3.24-pre01) TemplateConfigurer class was renamed to TemplateConfiguration, and the related configuration setting from template_configurers to template_configurations. Also, the TemplateConfigurer.configure method was renamed to TemplateConfiguration.apply. Also did some JavaDoc typo fixes and additions for the related API-s.
diff --git a/src/main/java/freemarker/cache/ConditionalTemplateConfigurationFactory.java b/src/main/java/freemarker/cache/ConditionalTemplateConfigurationFactory.java
new file mode 100644
index 0000000..430632e
--- /dev/null
+++ b/src/main/java/freemarker/cache/ConditionalTemplateConfigurationFactory.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package freemarker.cache;
+
+import java.io.IOException;
+
+import freemarker.core.TemplateConfiguration;
+import freemarker.template.Configuration;
+
+/**
+ * Returns the given {@link TemplateConfiguration} directly, or another {@link TemplateConfigurationFactory}'s result, when
+ * the specified matcher matches the template source.
+ *
+ * @since 2.3.24
+ */
+public class ConditionalTemplateConfigurationFactory extends TemplateConfigurationFactory {
+
+ private final TemplateSourceMatcher matcher;
+ private final TemplateConfiguration templateConfiguration;
+ private final TemplateConfigurationFactory templateConfigurationFactory;
+
+ public ConditionalTemplateConfigurationFactory(
+ TemplateSourceMatcher matcher, TemplateConfigurationFactory templateConfigurationFactory) {
+ this.matcher = matcher;
+ this.templateConfiguration = null;
+ this.templateConfigurationFactory = templateConfigurationFactory;
+ }
+
+ public ConditionalTemplateConfigurationFactory(
+ TemplateSourceMatcher matcher, TemplateConfiguration templateConfiguration) {
+ this.matcher = matcher;
+ this.templateConfiguration = templateConfiguration;
+ this.templateConfigurationFactory = null;
+ }
+
+ @Override
+ public TemplateConfiguration get(String sourceName, Object templateSource)
+ throws IOException, TemplateConfigurationFactoryException {
+ if (matcher.matches(sourceName, templateSource)) {
+ if (templateConfigurationFactory != null) {
+ return templateConfigurationFactory.get(sourceName, templateSource);
+ } else {
+ return templateConfiguration;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ protected void setConfigurationOfChildren(Configuration cfg) {
+ if (templateConfiguration != null) {
+ templateConfiguration.setParentConfiguration(cfg);
+ }
+ if (templateConfigurationFactory != null) {
+ templateConfigurationFactory.setConfiguration(cfg);
+ }
+ }
+
+}
diff --git a/src/main/java/freemarker/cache/ConditionalTemplateConfigurerFactory.java b/src/main/java/freemarker/cache/ConditionalTemplateConfigurerFactory.java
deleted file mode 100644
index 1982951..0000000
--- a/src/main/java/freemarker/cache/ConditionalTemplateConfigurerFactory.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package freemarker.cache;
-
-import java.io.IOException;
-
-import freemarker.core.TemplateConfigurer;
-import freemarker.template.Configuration;
-
-/**
- * Returns the given {@link TemplateConfigurer} directly, or another {@link TemplateConfigurerFactory}'s result, when
- * the specified matcher matches the template source.
- *
- * @since 2.3.24
- */
-public class ConditionalTemplateConfigurerFactory extends TemplateConfigurerFactory {
-
- private final TemplateSourceMatcher matcher;
- private final TemplateConfigurer templateConfigurer;
- private final TemplateConfigurerFactory templateConfigurerFactory;
-
- public ConditionalTemplateConfigurerFactory(
- TemplateSourceMatcher matcher, TemplateConfigurerFactory templateConfigurerFactory) {
- this.matcher = matcher;
- this.templateConfigurer = null;
- this.templateConfigurerFactory = templateConfigurerFactory;
- }
-
- public ConditionalTemplateConfigurerFactory(TemplateSourceMatcher matcher, TemplateConfigurer templateConfigurer) {
- this.matcher = matcher;
- this.templateConfigurer = templateConfigurer;
- this.templateConfigurerFactory = null;
- }
-
- @Override
- public TemplateConfigurer get(String sourceName, Object templateSource)
- throws IOException, TemplateConfigurerFactoryException {
- if (matcher.matches(sourceName, templateSource)) {
- if (templateConfigurerFactory != null) {
- return templateConfigurerFactory.get(sourceName, templateSource);
- } else {
- return templateConfigurer;
- }
- } else {
- return null;
- }
- }
-
- @Override
- protected void setConfigurationOfChildren(Configuration cfg) {
- if (templateConfigurer != null) {
- templateConfigurer.setParentConfiguration(cfg);
- }
- if (templateConfigurerFactory != null) {
- templateConfigurerFactory.setConfiguration(cfg);
- }
- }
-
-}
diff --git a/src/main/java/freemarker/cache/FirstMatchTemplateConfigurerFactory.java b/src/main/java/freemarker/cache/FirstMatchTemplateConfigurationFactory.java
similarity index 73%
rename from src/main/java/freemarker/cache/FirstMatchTemplateConfigurerFactory.java
rename to src/main/java/freemarker/cache/FirstMatchTemplateConfigurationFactory.java
index 77512ff..9382656 100644
--- a/src/main/java/freemarker/cache/FirstMatchTemplateConfigurerFactory.java
+++ b/src/main/java/freemarker/cache/FirstMatchTemplateConfigurationFactory.java
@@ -20,7 +20,7 @@
import java.io.IOException;
-import freemarker.core.TemplateConfigurer;
+import freemarker.core.TemplateConfiguration;
import freemarker.template.Configuration;
import freemarker.template.utility.StringUtil;
@@ -28,28 +28,28 @@
* Returns the first non-{@code null} result of the child factories, ignoring all further child factories. The child
* factories are called in the order as they were added.
*/
-public class FirstMatchTemplateConfigurerFactory extends TemplateConfigurerFactory {
+public class FirstMatchTemplateConfigurationFactory extends TemplateConfigurationFactory {
- private final TemplateConfigurerFactory[] templateConfigurerFactories;
+ private final TemplateConfigurationFactory[] templateConfigurationFactories;
private boolean allowNoMatch;
private String noMatchErrorDetails;
- public FirstMatchTemplateConfigurerFactory(TemplateConfigurerFactory... templateConfigurerFactories) {
- this.templateConfigurerFactories = templateConfigurerFactories;
+ public FirstMatchTemplateConfigurationFactory(TemplateConfigurationFactory... templateConfigurationFactories) {
+ this.templateConfigurationFactories = templateConfigurationFactories;
}
@Override
- public TemplateConfigurer get(String sourceName, Object templateSource)
- throws IOException, TemplateConfigurerFactoryException {
- for (TemplateConfigurerFactory tcf : templateConfigurerFactories) {
- TemplateConfigurer tc = tcf.get(sourceName, templateSource);
+ public TemplateConfiguration get(String sourceName, Object templateSource)
+ throws IOException, TemplateConfigurationFactoryException {
+ for (TemplateConfigurationFactory tcf : templateConfigurationFactories) {
+ TemplateConfiguration tc = tcf.get(sourceName, templateSource);
if (tc != null) {
return tc;
}
}
if (!allowNoMatch) {
- throw new TemplateConfigurerFactoryException(
- FirstMatchTemplateConfigurerFactory.class.getSimpleName()
+ throw new TemplateConfigurationFactoryException(
+ FirstMatchTemplateConfigurationFactory.class.getSimpleName()
+ " has found no matching choice for source name "
+ StringUtil.jQuote(sourceName) + ". "
+ (noMatchErrorDetails != null
@@ -95,7 +95,7 @@
/**
* Same as {@link #setAllowNoMatch(boolean)}, but return this object to support "fluent API" style.
*/
- public FirstMatchTemplateConfigurerFactory allowNoMatch(boolean allow) {
+ public FirstMatchTemplateConfigurationFactory allowNoMatch(boolean allow) {
setAllowNoMatch(allow);
return this;
}
@@ -103,15 +103,15 @@
/**
* Same as {@link #setNoMatchErrorDetails(String)}, but return this object to support "fluent API" style.
*/
- public FirstMatchTemplateConfigurerFactory noMatchErrorDetails(String message) {
+ public FirstMatchTemplateConfigurationFactory noMatchErrorDetails(String message) {
setNoMatchErrorDetails(message);
return this;
}
@Override
protected void setConfigurationOfChildren(Configuration cfg) {
- for (TemplateConfigurerFactory templateConfigurerFactory : templateConfigurerFactories) {
- templateConfigurerFactory.setConfiguration(cfg);
+ for (TemplateConfigurationFactory templateConfigurationFactory : templateConfigurationFactories) {
+ templateConfigurationFactory.setConfiguration(cfg);
}
}
diff --git a/src/main/java/freemarker/cache/MergingTemplateConfigurerFactory.java b/src/main/java/freemarker/cache/MergingTemplateConfigurationFactory.java
similarity index 63%
rename from src/main/java/freemarker/cache/MergingTemplateConfigurerFactory.java
rename to src/main/java/freemarker/cache/MergingTemplateConfigurationFactory.java
index 4a29614..3675d19 100644
--- a/src/main/java/freemarker/cache/MergingTemplateConfigurerFactory.java
+++ b/src/main/java/freemarker/cache/MergingTemplateConfigurationFactory.java
@@ -20,7 +20,7 @@
import java.io.IOException;
-import freemarker.core.TemplateConfigurer;
+import freemarker.core.TemplateConfiguration;
import freemarker.template.Configuration;
/**
@@ -30,21 +30,21 @@
*
* @since 2.3.24
*/
-public class MergingTemplateConfigurerFactory extends TemplateConfigurerFactory {
+public class MergingTemplateConfigurationFactory extends TemplateConfigurationFactory {
- private final TemplateConfigurerFactory[] templateConfigurerFactories;
+ private final TemplateConfigurationFactory[] templateConfigurationFactories;
- public MergingTemplateConfigurerFactory(TemplateConfigurerFactory... templateConfigurerFactories) {
- this.templateConfigurerFactories = templateConfigurerFactories;
+ public MergingTemplateConfigurationFactory(TemplateConfigurationFactory... templateConfigurationFactories) {
+ this.templateConfigurationFactories = templateConfigurationFactories;
}
@Override
- public TemplateConfigurer get(String sourceName, Object templateSource)
- throws IOException, TemplateConfigurerFactoryException {
- TemplateConfigurer mergedTC = null;
- TemplateConfigurer resultTC = null;
- for (TemplateConfigurerFactory tcf : templateConfigurerFactories) {
- TemplateConfigurer tc = tcf.get(sourceName, templateSource);
+ public TemplateConfiguration get(String sourceName, Object templateSource)
+ throws IOException, TemplateConfigurationFactoryException {
+ TemplateConfiguration mergedTC = null;
+ TemplateConfiguration resultTC = null;
+ for (TemplateConfigurationFactory tcf : templateConfigurationFactories) {
+ TemplateConfiguration tc = tcf.get(sourceName, templateSource);
if (tc != null) {
if (resultTC == null) {
resultTC = tc;
@@ -53,10 +53,10 @@
Configuration cfg = getConfiguration();
if (cfg == null) {
throw new IllegalStateException(
- "The TemplateConfigurerFactory wasn't associated to a Configuration yet.");
+ "The TemplateConfigurationFactory wasn't associated to a Configuration yet.");
}
- mergedTC = new TemplateConfigurer();
+ mergedTC = new TemplateConfiguration();
mergedTC.setParentConfiguration(cfg);
mergedTC.merge(resultTC);
resultTC = mergedTC;
@@ -70,8 +70,8 @@
@Override
protected void setConfigurationOfChildren(Configuration cfg) {
- for (TemplateConfigurerFactory templateConfigurerFactory : templateConfigurerFactories) {
- templateConfigurerFactory.setConfiguration(cfg);
+ for (TemplateConfigurationFactory templateConfigurationFactory : templateConfigurationFactories) {
+ templateConfigurationFactory.setConfiguration(cfg);
}
}
diff --git a/src/main/java/freemarker/cache/TemplateCache.java b/src/main/java/freemarker/cache/TemplateCache.java
index 1775f17..4f62d05 100644
--- a/src/main/java/freemarker/cache/TemplateCache.java
+++ b/src/main/java/freemarker/cache/TemplateCache.java
@@ -33,7 +33,7 @@
import freemarker.cache.MultiTemplateLoader.MultiSource;
import freemarker.core.BugException;
import freemarker.core.Environment;
-import freemarker.core.TemplateConfigurer;
+import freemarker.core.TemplateConfiguration;
import freemarker.log.Logger;
import freemarker.template.Configuration;
import freemarker.template.MalformedTemplateNameException;
@@ -77,7 +77,7 @@
private final CacheStorage storage;
private final TemplateLookupStrategy templateLookupStrategy;
private final TemplateNameFormat templateNameFormat;
- private final TemplateConfigurerFactory templateConfigurers;
+ private final TemplateConfigurationFactory templateConfigurations;
private final boolean isStorageConcurrent;
/** {@link Configuration#setTemplateUpdateDelayMilliseconds(long)} */
@@ -143,7 +143,7 @@
/**
* Same as
* {@link TemplateCache#TemplateCache(TemplateLoader, CacheStorage, TemplateLookupStrategy, TemplateNameFormat,
- * TemplateConfigurerFactory, Configuration)} with {@code null} for {@code templateConfigurer}-s.
+ * TemplateConfigurationFactory, Configuration)} with {@code null} for {@code templateConfigurations}-s.
*
* @since 2.3.22
*/
@@ -162,8 +162,8 @@
* The {@link TemplateLookupStrategy} to use. Can't be {@code null}.
* @param templateNameFormat
* The {@link TemplateNameFormat} to use. Can't be {@code null}.
- * @param templateConfigurers
- * The {@link TemplateConfigurerFactory} to use. Can be {@code null} (then all templates will use the
+ * @param templateConfigurations
+ * The {@link TemplateConfigurationFactory} to use. Can be {@code null} (then all templates will use the
* settings coming from the {@link Configuration} as is).
* @param config
* The {@link Configuration} this cache will be used for. Can be {@code null} for backward compatibility,
@@ -173,7 +173,7 @@
*/
public TemplateCache(TemplateLoader templateLoader, CacheStorage cacheStorage,
TemplateLookupStrategy templateLookupStrategy, TemplateNameFormat templateNameFormat,
- TemplateConfigurerFactory templateConfigurers,
+ TemplateConfigurationFactory templateConfigurations,
Configuration config) {
this.templateLoader = templateLoader;
@@ -189,7 +189,7 @@
this.templateNameFormat = templateNameFormat;
// Can be null
- this.templateConfigurers = templateConfigurers;
+ this.templateConfigurations = templateConfigurations;
this.config = config;
}
@@ -232,8 +232,8 @@
/**
* @since 2.3.24
*/
- public TemplateConfigurerFactory getTemplateConfigurers() {
- return templateConfigurers;
+ public TemplateConfigurationFactory getTemplateConfigurations() {
+ return templateConfigurations;
}
/**
@@ -523,11 +523,11 @@
final TemplateLoader templateLoader, final Object source,
final String name, final String sourceName, Locale locale, final Object customLookupCondition,
String initialEncoding, final boolean parseAsFTL) throws IOException {
- final TemplateConfigurer tc;
+ final TemplateConfiguration tc;
try {
- tc = templateConfigurers != null ? templateConfigurers.get(sourceName, source) : null;
- } catch (TemplateConfigurerFactoryException e) {
- throw newIOException("Error while getting TemplateConfigurer; see cause exception.", e);
+ tc = templateConfigurations != null ? templateConfigurations.get(sourceName, source) : null;
+ } catch (TemplateConfigurationFactoryException e) {
+ throw newIOException("Error while getting TemplateConfiguration; see cause exception.", e);
}
if (tc != null) {
// TC.{encoding,locale} is stronger than the cfg.getTemplate arguments by design.
@@ -586,7 +586,7 @@
}
if (tc != null) {
- tc.configure(template);
+ tc.apply(template);
}
template.setLocale(locale);
diff --git a/src/main/java/freemarker/cache/TemplateConfigurerFactory.java b/src/main/java/freemarker/cache/TemplateConfigurationFactory.java
similarity index 66%
rename from src/main/java/freemarker/cache/TemplateConfigurerFactory.java
rename to src/main/java/freemarker/cache/TemplateConfigurationFactory.java
index 0e65a67..ec8d2ae 100644
--- a/src/main/java/freemarker/cache/TemplateConfigurerFactory.java
+++ b/src/main/java/freemarker/cache/TemplateConfigurationFactory.java
@@ -20,21 +20,21 @@
import java.io.IOException;
-import freemarker.core.TemplateConfigurer;
+import freemarker.core.TemplateConfiguration;
import freemarker.template.Configuration;
import freemarker.template.Template;
/**
- * Creates (or returns) {@link TemplateConfigurer}-s for template sources.
+ * Creates (or returns) {@link TemplateConfiguration}-s for template sources.
*
* @since 2.3.24
*/
-public abstract class TemplateConfigurerFactory {
+public abstract class TemplateConfigurationFactory {
private Configuration cfg;
/**
- * Returns (maybe creates) the {@link TemplateConfigurer} for the given template source.
+ * Returns (maybe creates) the {@link TemplateConfiguration} for the given template source.
*
* @param sourceName
* The name (path) that was used for {@link TemplateLoader#findTemplateSource(String)}. See
@@ -42,28 +42,28 @@
* @param templateSource
* The object returned by {@link TemplateLoader#findTemplateSource(String)}.
*
- * @return The {@link TemplateConfigurer} to apply, or {@code null} if the there's no {@link TemplateConfigurer} for
+ * @return The {@link TemplateConfiguration} to apply, or {@code null} if the there's no {@link TemplateConfiguration} for
* this template source.
*
* @throws IOException
* Typically, if there factory needs further I/O to find out more about the template source, but that
* fails.
- * @throws TemplateConfigurerFactoryException
+ * @throws TemplateConfigurationFactoryException
* If there's a problem that's specific to the factory logic.
*/
- public abstract TemplateConfigurer get(String sourceName, Object templateSource)
- throws IOException, TemplateConfigurerFactoryException;
+ public abstract TemplateConfiguration get(String sourceName, Object templateSource)
+ throws IOException, TemplateConfigurationFactoryException;
/**
- * Binds this {@link TemplateConfigurerFactory} to a {@link Configuration}. Once it's bound, it can't be bound to
+ * Binds this {@link TemplateConfigurationFactory} to a {@link Configuration}. Once it's bound, it can't be bound to
* another {@link Configuration} any more. This is automatically called by
- * {@link Configuration#setTemplateConfigurers(TemplateConfigurerFactory)}.
+ * {@link Configuration#setTemplateConfigurations(TemplateConfigurationFactory)}.
*/
public final void setConfiguration(Configuration cfg) {
if (this.cfg != null) {
if (cfg != this.cfg) {
throw new IllegalStateException(
- "The TemplateConfigurerFactory is already bound to another Configuration");
+ "The TemplateConfigurationFactory is already bound to another Configuration");
}
return;
} else {
@@ -81,9 +81,9 @@
}
/**
- * Calls {@link TemplateConfigurer#setParentConfiguration(Configuration)} on each enclosed
- * {@link TemplateConfigurer} and {@link TemplateConfigurerFactory#setConfiguration(Configuration)}
- * on each enclosed {@link TemplateConfigurerFactory} objects. It only supposed to call these on the direct
+ * Calls {@link TemplateConfiguration#setParentConfiguration(Configuration)} on each enclosed
+ * {@link TemplateConfiguration} and {@link TemplateConfigurationFactory#setConfiguration(Configuration)}
+ * on each enclosed {@link TemplateConfigurationFactory} objects. It only supposed to call these on the direct
* "children" of this object, not on the children of the children.
*/
protected abstract void setConfigurationOfChildren(Configuration cfg);
diff --git a/src/main/java/freemarker/cache/TemplateConfigurerFactoryException.java b/src/main/java/freemarker/cache/TemplateConfigurationFactoryException.java
similarity index 76%
rename from src/main/java/freemarker/cache/TemplateConfigurerFactoryException.java
rename to src/main/java/freemarker/cache/TemplateConfigurationFactoryException.java
index 2ddfe68..abbce62 100644
--- a/src/main/java/freemarker/cache/TemplateConfigurerFactoryException.java
+++ b/src/main/java/freemarker/cache/TemplateConfigurationFactoryException.java
@@ -19,17 +19,17 @@
package freemarker.cache;
/**
- * Non-I/O exception thrown by {@link TemplateConfigurerFactory}-s.
+ * Non-I/O exception thrown by {@link TemplateConfigurationFactory}-s.
*
* @since 2.3.24
*/
-public class TemplateConfigurerFactoryException extends Exception {
+public class TemplateConfigurationFactoryException extends Exception {
- public TemplateConfigurerFactoryException(String message) {
+ public TemplateConfigurationFactoryException(String message) {
super(message);
}
- public TemplateConfigurerFactoryException(String message, Throwable cause) {
+ public TemplateConfigurationFactoryException(String message, Throwable cause) {
super(message, cause);
}
diff --git a/src/main/java/freemarker/core/Configurable.java b/src/main/java/freemarker/core/Configurable.java
index c42fdcb..ba5d8c8 100644
--- a/src/main/java/freemarker/core/Configurable.java
+++ b/src/main/java/freemarker/core/Configurable.java
@@ -41,10 +41,10 @@
import java.util.TimeZone;
import freemarker.cache.AndMatcher;
-import freemarker.cache.ConditionalTemplateConfigurerFactory;
+import freemarker.cache.ConditionalTemplateConfigurationFactory;
import freemarker.cache.FileNameGlobMatcher;
-import freemarker.cache.FirstMatchTemplateConfigurerFactory;
-import freemarker.cache.MergingTemplateConfigurerFactory;
+import freemarker.cache.FirstMatchTemplateConfigurationFactory;
+import freemarker.cache.MergingTemplateConfigurationFactory;
import freemarker.cache.NotMatcher;
import freemarker.cache.OrMatcher;
import freemarker.cache.PathGlobMatcher;
@@ -1807,8 +1807,8 @@
* <br>String value: {@code "default"} (case insensitive) for the default, or {@code "true"}, {@code "false"},
* {@code yes}, etc.
*
- * <li><p>{@code "template_configurers"}:
- * See: {@link Configuration#setTemplateConfigurers(freemarker.cache.TemplateConfigurerFactory)}.
+ * <li><p>{@code "template_configurations"}:
+ * See: {@link Configuration#setTemplateConfigurations(freemarker.cache.TemplateConfigurationFactory)}.
* <br>String value: Interpreted as an <a href="#fm_obe">object builder expression</a>,
* can be {@code null}.
*
@@ -1903,9 +1903,9 @@
* <li>
* <p>The following classes can be referred to with short class name instead of full qualified name:
* {@link DefaultObjectWrapper}, {@link BeansWrapper}, {@link SimpleObjectWrapper}, {@link Locale},
- * {@link TemplateConfigurer}, {@link PathGlobMatcher}, {@link FileNameGlobMatcher}, {@link PathRegexMatcher},
- * {@link AndMatcher}, {@link OrMatcher}, {@link NotMatcher}, {@link ConditionalTemplateConfigurerFactory},
- * {@link MergingTemplateConfigurerFactory}, {@link FirstMatchTemplateConfigurerFactory},
+ * {@link TemplateConfiguration}, {@link PathGlobMatcher}, {@link FileNameGlobMatcher}, {@link PathRegexMatcher},
+ * {@link AndMatcher}, {@link OrMatcher}, {@link NotMatcher}, {@link ConditionalTemplateConfigurationFactory},
+ * {@link MergingTemplateConfigurationFactory}, {@link FirstMatchTemplateConfigurationFactory},
* {@link HTMLOutputFormat}, {@link XMLOutputFormat}, {@link RTFOutputFormat}, {@link PlainTextOutputFormat},
* {@link UndefinedOutputFormat}.
* </li>
diff --git a/src/main/java/freemarker/core/CustomAttribute.java b/src/main/java/freemarker/core/CustomAttribute.java
index 40ae92d..fe55eb9 100644
--- a/src/main/java/freemarker/core/CustomAttribute.java
+++ b/src/main/java/freemarker/core/CustomAttribute.java
@@ -131,15 +131,15 @@
}
/**
- * Same as {@link #get(Template)}, but applies to a {@link TemplateConfigurer}.
+ * Same as {@link #get(Template)}, but applies to a {@link TemplateConfiguration}.
*
* @since 2.3.24
*/
- public Object get(TemplateConfigurer templateConfigurer) {
+ public Object get(TemplateConfiguration templateConfiguration) {
if (scope != SCOPE_TEMPLATE) {
throw new UnsupportedOperationException("This is not a template-scope attribute");
}
- return templateConfigurer.getCustomAttribute(key, this);
+ return templateConfiguration.getCustomAttribute(key, this);
}
/**
@@ -209,15 +209,15 @@
}
/**
- * Same as {@link #set(Object, Template)}, but applicable to a {@link TemplateConfigurer}.
+ * Same as {@link #set(Object, Template)}, but applicable to a {@link TemplateConfiguration}.
*
* @since 2.3.24
*/
- public final void set(Object value, TemplateConfigurer templateConfigurer) {
+ public final void set(Object value, TemplateConfiguration templateConfiguration) {
if (scope != SCOPE_TEMPLATE) {
throw new UnsupportedOperationException("This is not a template-scope attribute");
}
- templateConfigurer.setCustomAttribute(key, value);
+ templateConfiguration.setCustomAttribute(key, value);
}
/**
diff --git a/src/main/java/freemarker/core/TemplateConfigurer.java b/src/main/java/freemarker/core/TemplateConfiguration.java
similarity index 86%
rename from src/main/java/freemarker/core/TemplateConfigurer.java
rename to src/main/java/freemarker/core/TemplateConfiguration.java
index 78c627f..310028f 100644
--- a/src/main/java/freemarker/core/TemplateConfigurer.java
+++ b/src/main/java/freemarker/core/TemplateConfiguration.java
@@ -30,14 +30,14 @@
import freemarker.template.utility.NullArgumentException;
/**
- * Used for customizing the configuration settings for individual {@link Template}-s, relatively to the common setting
- * values coming from the {@link Configuration}. This was designed with the standard template loading mechanism of
- * FreeMarker in mind ({@link Configuration#getTemplate(String)} and {@link TemplateCache}), though can also be reused
- * for custom template loading and caching solutions.
+ * Used for customizing the configuration settings for individual {@link Template}-s (or rather groups of templates),
+ * relatively to the common setting values coming from the {@link Configuration}. This was designed with the standard
+ * template loading mechanism of FreeMarker in mind ({@link Configuration#getTemplate(String)} and {@link TemplateCache}
+ * ), though can also be reused for custom template loading and caching solutions.
*
* <p>
- * Note on the {@code locale} setting: When used with the standard template loading/caching mechanism
- * ({@link Configuration#getTemplate(String)} and its overloads), localized lookup happens before the {@code locale}
+ * Note on the {@code locale} setting: When used with the standard template loading/caching mechanism (
+ * {@link Configuration#getTemplate(String)} and its overloads), localized lookup happens before the {@code locale}
* specified here could have effect. The {@code locale} will be only set in the template that the localized looks has
* already found.
*
@@ -54,26 +54,25 @@
* you should be aware of a few more details:
*
* <ul>
- * <li>This class implements both {@link Configurable} and
- * {@link ParserConfiguration}. This means that it can influence both the template parsing phase and the runtime
- * settings. For both aspects (i.e., {@link Configurable} and {@link ParserConfiguration}) to take effect, you have
- * first pass this object to the {@link Template} constructor (this is where the {@link ParserConfiguration} interface
- * is used), and then you have to call {@link #configure(Template)} on the resulting {@link Template} object (this is
- * where the {@link Configurable} aspect is used).
+ * <li>This class implements both {@link Configurable} and {@link ParserConfiguration}. This means that it can influence
+ * both the template parsing phase and the runtime settings. For both aspects (i.e., {@link ParserConfiguration} and
+ * {@link Configurable}) to take effect, you have first pass this object to the {@link Template} constructor
+ * (this is where the {@link ParserConfiguration} interface is used), and then you have to call {@link #apply(Template)}
+ * on the resulting {@link Template} object (this is where the {@link Configurable} aspect is used).
*
- * <li>{@link #configure(Template)} only change the settings that weren't yet set on the {@link Template} (but are
- * inherited from the {@link Configuration}). This is primarily because if the template configures itself via the
- * {@code #ftl} header, those values should have precedence. A consequence of this is that if you want to configure
- * the same {@link Template} with multiple {@link TemplateConfigurer}-s, you either should merge them to a single one
- * before that (with {@link #merge(TemplateConfigurer)}), or you have to apply them in reverse order of their intended
- * precedence.
+ * <li>{@link #apply(Template)} only change the settings that weren't yet set on the {@link Template} (but are inherited
+ * from the {@link Configuration}). This is primarily because if the template configures itself via the {@code #ftl}
+ * header, those values should have precedence. A consequence of this is that if you want to configure the same
+ * {@link Template} with multiple {@link TemplateConfiguration}-s, you either should merge them to a single one before
+ * that (with {@link #merge(TemplateConfiguration)}), or you have to apply them in reverse order of their intended
+ * precedence.
* </ul>
*
* @see Template#Template(String, String, Reader, Configuration, ParserConfiguration, String)
*
* @since 2.3.24
*/
-public final class TemplateConfigurer extends Configurable implements ParserConfiguration {
+public final class TemplateConfiguration extends Configurable implements ParserConfiguration {
private boolean parentConfigurationSet;
private Integer tagSyntax;
@@ -90,27 +89,24 @@
* be changed to the real parent {@link Configuration} when this object is added to the {@link Configuration}. (It's
* not allowed to add the same instance to multiple {@link Configuration}-s).
*/
- public TemplateConfigurer() {
+ public TemplateConfiguration() {
super(Configuration.getDefaultConfiguration());
}
/**
* Same as {@link #setParentConfiguration(Configuration)}.
- *
- * @throws IllegalArgumentException
- * if the argument is {@code null} or not a {@link Configuration}.
*/
@Override
void setParent(Configurable cfg) {
NullArgumentException.check("cfg", cfg);
if (!(cfg instanceof Configuration)) {
- throw new IllegalArgumentException("The parent of a TemplateConfigurer can only be a Configuration");
+ throw new IllegalArgumentException("The parent of a TemplateConfiguration can only be a Configuration");
}
if (parentConfigurationSet) {
if (getParent() != cfg) {
throw new IllegalStateException(
- "This TemplateConfigurer is already associated with a different Configuration instance.");
+ "This TemplateConfiguration is already associated with a different Configuration instance.");
}
return;
}
@@ -118,7 +114,7 @@
if (((Configuration) cfg).getIncompatibleImprovements().intValue() < _TemplateAPI.VERSION_INT_2_3_22
&& hasAnyConfigurableSet()) {
throw new IllegalStateException(
- "This TemplateConfigurer can't be associated to a Configuration that has incompatibleImprovements "
+ "This TemplateConfiguration can't be associated to a Configuration that has incompatibleImprovements "
+ "less than 2.3.22, because it changes non-parser settings.");
}
@@ -131,10 +127,12 @@
* when this instance is added to a {@link Configuration}. This method can be called only once (except with the same
* {@link Configuration} parameter again, as that changes nothing anyway).
*
- * @throws IllegalStateException
- * If the parent configuration was already set to a different {@link Configuration} instance.
* @throws IllegalArgumentException
- * if the argument is {@code null}.
+ * if the argument is {@code null} or not a {@link Configuration}
+ * @throws IllegalStateException
+ * if this object is already associated to a different {@link Configuration} object,
+ * or if the {@code Configuration} has {@code #getIncompatibleImprovements()} less than 2.3.22 and
+ * this object tries to change any non-parser settings
*/
public void setParentConfiguration(Configuration cfg) {
setParent(cfg);
@@ -148,11 +146,11 @@
}
/**
- * Set all settings in this {@link TemplateConfigurer} that that were set in the parameter
- * {@link TemplateConfigurer}, possibly overwriting the earlier value in this object. (A setting is said to be set
- * in a {@link TemplateConfigurer} if it was explicitly set via a setter method, as opposed to be inherited.)
+ * Set all settings in this {@link TemplateConfiguration} that were set in the parameter
+ * {@link TemplateConfiguration}, possibly overwriting the earlier value in this object. (A setting is said to be
+ * set in a {@link TemplateConfiguration} if it was explicitly set via a setter method, as opposed to be inherited.)
*/
- public void merge(TemplateConfigurer tc) {
+ public void merge(TemplateConfiguration tc) {
if (tc.isAPIBuiltinEnabledSet()) {
setAPIBuiltinEnabled(tc.isAPIBuiltinEnabled());
}
@@ -246,8 +244,8 @@
/**
* Sets the settings of the {@link Template} which are not yet set in the {@link Template} and are set in this
- * {@link TemplateConfigurer}, leaves the other settings as is. A setting is said to be set in a
- * {@link TemplateConfigurer} or {@link Template} if it was explicitly set via a setter method on that object, as
+ * {@link TemplateConfiguration}, leaves the other settings as is. A setting is said to be set in a
+ * {@link TemplateConfiguration} or {@link Template} if it was explicitly set via a setter method on that object, as
* opposed to be inherited from the {@link Configuration}.
*
* <p>
@@ -257,13 +255,13 @@
* @throws IllegalStateException
* If the parent configuration wasn't yet set.
*/
- public void configure(Template template) {
+ public void apply(Template template) {
checkParentConfigurationSet();
Configuration cfg = getParentConfiguration();
if (template.getConfiguration() != cfg) {
// This is actually not a problem right now, but for future BC we enforce this.
throw new IllegalArgumentException(
- "The argument Template doesn't belong to the same Configuration as the TemplateConfigurer");
+ "The argument Template doesn't belong to the same Configuration as the TemplateConfiguration");
}
if (isAPIBuiltinEnabledSet() && !template.isAPIBuiltinEnabledSet()) {
@@ -494,7 +492,7 @@
@Override
public void setStrictBeanModels(boolean strict) {
throw new UnsupportedOperationException(
- "Setting strictBeanModels on " + TemplateConfigurer.class.getSimpleName() + " level isn't supported.");
+ "Setting strictBeanModels on " + TemplateConfiguration.class.getSimpleName() + " level isn't supported.");
}
public String getEncoding() {
@@ -512,7 +510,7 @@
* <p>
* If you are developing your own template loading/caching mechanism instead of the standard one, note that the
* above behavior is not guaranteed by this class alone; you have to ensure it. Also, read the note on
- * {@code encoding} in the documentation of {@link #configure(Template)}.
+ * {@code encoding} in the documentation of {@link #apply(Template)}.
*/
public void setEncoding(String encoding) {
NullArgumentException.check("encoding", encoding);
@@ -537,7 +535,7 @@
private void checkParentConfigurationSet() {
if (!parentConfigurationSet) {
- throw new IllegalStateException("The TemplateConfigurer wasn't associated with a Configuration yet.");
+ throw new IllegalStateException("The TemplateConfiguration wasn't associated with a Configuration yet.");
}
}
diff --git a/src/main/java/freemarker/core/UndefinedOutputFormat.java b/src/main/java/freemarker/core/UndefinedOutputFormat.java
index d4cbdd1..4dce258 100644
--- a/src/main/java/freemarker/core/UndefinedOutputFormat.java
+++ b/src/main/java/freemarker/core/UndefinedOutputFormat.java
@@ -23,9 +23,9 @@
/**
* Represents the output format used when the template output format is undecided. This is the default output format if
* FreeMarker can't select anything more specific (see
- * {@link Configuration#setTemplateConfigurers(freemarker.cache.TemplateConfigurerFactory)}). This format doesn't
- * support auto-escaping ({@link Configuration#setAutoEscapingPolicy(int)}). It will print {@link TemplateMarkupOutputModel}-s
- * as is (doesn't try to convert them).
+ * {@link Configuration#setTemplateConfigurations(freemarker.cache.TemplateConfigurationFactory)}). This format doesn't
+ * support auto-escaping ({@link Configuration#setAutoEscapingPolicy(int)}). It will print
+ * {@link TemplateMarkupOutputModel}-s as is (doesn't try to convert them).
*
* @see PlainTextOutputFormat
*
diff --git a/src/main/java/freemarker/core/_ObjectBuilderSettingEvaluator.java b/src/main/java/freemarker/core/_ObjectBuilderSettingEvaluator.java
index efcd3cc..a1e1c22 100644
--- a/src/main/java/freemarker/core/_ObjectBuilderSettingEvaluator.java
+++ b/src/main/java/freemarker/core/_ObjectBuilderSettingEvaluator.java
@@ -36,11 +36,11 @@
import java.util.Properties;
import freemarker.cache.AndMatcher;
-import freemarker.cache.ConditionalTemplateConfigurerFactory;
+import freemarker.cache.ConditionalTemplateConfigurationFactory;
import freemarker.cache.FileExtensionMatcher;
import freemarker.cache.FileNameGlobMatcher;
-import freemarker.cache.FirstMatchTemplateConfigurerFactory;
-import freemarker.cache.MergingTemplateConfigurerFactory;
+import freemarker.cache.FirstMatchTemplateConfigurationFactory;
+import freemarker.cache.MergingTemplateConfigurationFactory;
import freemarker.cache.NotMatcher;
import freemarker.cache.OrMatcher;
import freemarker.cache.PathGlobMatcher;
@@ -661,7 +661,7 @@
addWithSimpleName(SHORTHANDS, BeansWrapper.class);
addWithSimpleName(SHORTHANDS, SimpleObjectWrapper.class);
- addWithSimpleName(SHORTHANDS, TemplateConfigurer.class);
+ addWithSimpleName(SHORTHANDS, TemplateConfiguration.class);
addWithSimpleName(SHORTHANDS, PathGlobMatcher.class);
addWithSimpleName(SHORTHANDS, FileNameGlobMatcher.class);
@@ -671,9 +671,9 @@
addWithSimpleName(SHORTHANDS, OrMatcher.class);
addWithSimpleName(SHORTHANDS, NotMatcher.class);
- addWithSimpleName(SHORTHANDS, ConditionalTemplateConfigurerFactory.class);
- addWithSimpleName(SHORTHANDS, MergingTemplateConfigurerFactory.class);
- addWithSimpleName(SHORTHANDS, FirstMatchTemplateConfigurerFactory.class);
+ addWithSimpleName(SHORTHANDS, ConditionalTemplateConfigurationFactory.class);
+ addWithSimpleName(SHORTHANDS, MergingTemplateConfigurationFactory.class);
+ addWithSimpleName(SHORTHANDS, FirstMatchTemplateConfigurationFactory.class);
addWithSimpleName(SHORTHANDS, HTMLOutputFormat.class);
addWithSimpleName(SHORTHANDS, XMLOutputFormat.class);
diff --git a/src/main/java/freemarker/ext/servlet/FreemarkerServlet.java b/src/main/java/freemarker/ext/servlet/FreemarkerServlet.java
index 6ad1040..498466e 100644
--- a/src/main/java/freemarker/ext/servlet/FreemarkerServlet.java
+++ b/src/main/java/freemarker/ext/servlet/FreemarkerServlet.java
@@ -199,7 +199,7 @@
* {@link HttpServletResponse#setCharacterEncoding(String)} method. Note that the charset of a template usually comes
* from {@link Configuration#getDefaultEncoding()} (i.e., from the {@code default_encoding} FreeMarker setting),
* occasionally from {@link Configuration#getEncoding(Locale)} (when FreeMarker was configured to use different charsets
- * depending on the locale) or even more rarely from {@link Configuration#getTemplateConfigurers()} (when FreeMarker was
+ * depending on the locale) or even more rarely from {@link Configuration#getTemplateConfigurations()} (when FreeMarker was
* configured to use a specific charset for certain templates).
* <li>{@value #INIT_PARAM_VALUE_FROM_TEMPLATE}: This should be used in most applications, but it's not the default for
* backward compatibility. It reads the {@link Configurable#getOutputEncoding()} setting of the template (note that the
diff --git a/src/main/java/freemarker/template/Configuration.java b/src/main/java/freemarker/template/Configuration.java
index c04f37a..0e67121 100644
--- a/src/main/java/freemarker/template/Configuration.java
+++ b/src/main/java/freemarker/template/Configuration.java
@@ -51,7 +51,7 @@
import freemarker.cache.SoftCacheStorage;
import freemarker.cache.TemplateCache;
import freemarker.cache.TemplateCache.MaybeMissingTemplate;
-import freemarker.cache.TemplateConfigurerFactory;
+import freemarker.cache.TemplateConfigurationFactory;
import freemarker.cache.TemplateLoader;
import freemarker.cache.TemplateLookupContext;
import freemarker.cache.TemplateLookupStrategy;
@@ -68,7 +68,7 @@
import freemarker.core.ParserConfiguration;
import freemarker.core.PlainTextOutputFormat;
import freemarker.core.RTFOutputFormat;
-import freemarker.core.TemplateConfigurer;
+import freemarker.core.TemplateConfiguration;
import freemarker.core.TemplateMarkupOutputModel;
import freemarker.core.UndefinedOutputFormat;
import freemarker.core.UnregisteredOutputFormatException;
@@ -268,11 +268,11 @@
public static final String TEMPLATE_NAME_FORMAT_KEY = TEMPLATE_NAME_FORMAT_KEY_SNAKE_CASE;
/** Legacy, snake case ({@code like_this}) variation of the setting name. @since 2.3.24 */
- public static final String TEMPLATE_CONFIGURERS_KEY_SNAKE_CASE = "template_configurers";
+ public static final String TEMPLATE_CONFIGURATIONS_KEY_SNAKE_CASE = "template_configurations";
/** Modern, camel case ({@code likeThis}) variation of the setting name. @since 2.3.24 */
- public static final String TEMPLATE_CONFIGURERS_KEY_CAMEL_CASE = "templateConfigurers";
+ public static final String TEMPLATE_CONFIGURATIONS_KEY_CAMEL_CASE = "templateConfigurations";
/** Alias to the {@code ..._SNAKE_CASE} variation. @since 2.3.24 */
- public static final String TEMPLATE_CONFIGURERS_KEY = TEMPLATE_CONFIGURERS_KEY_SNAKE_CASE;
+ public static final String TEMPLATE_CONFIGURATIONS_KEY = TEMPLATE_CONFIGURATIONS_KEY_SNAKE_CASE;
/** Legacy, snake case ({@code like_this}) variation of the setting name. @since 2.3.23 */
public static final String INCOMPATIBLE_IMPROVEMENTS_KEY_SNAKE_CASE = "incompatible_improvements";
@@ -303,7 +303,7 @@
REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY_SNAKE_CASE,
STRICT_SYNTAX_KEY_SNAKE_CASE,
TAG_SYNTAX_KEY_SNAKE_CASE,
- TEMPLATE_CONFIGURERS_KEY_SNAKE_CASE,
+ TEMPLATE_CONFIGURATIONS_KEY_SNAKE_CASE,
TEMPLATE_LOADER_KEY_SNAKE_CASE,
TEMPLATE_LOOKUP_STRATEGY_KEY_SNAKE_CASE,
TEMPLATE_NAME_FORMAT_KEY_SNAKE_CASE,
@@ -326,7 +326,7 @@
REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY_CAMEL_CASE,
STRICT_SYNTAX_KEY_CAMEL_CASE,
TAG_SYNTAX_KEY_CAMEL_CASE,
- TEMPLATE_CONFIGURERS_KEY_CAMEL_CASE,
+ TEMPLATE_CONFIGURATIONS_KEY_CAMEL_CASE,
TEMPLATE_LOADER_KEY_CAMEL_CASE,
TEMPLATE_LOOKUP_STRATEGY_KEY_CAMEL_CASE,
TEMPLATE_NAME_FORMAT_KEY_CAMEL_CASE,
@@ -815,10 +815,10 @@
private void recreateTemplateCacheWith(
TemplateLoader loader, CacheStorage storage,
TemplateLookupStrategy templateLookupStrategy, TemplateNameFormat templateNameFormat,
- TemplateConfigurerFactory templateConfigurers) {
+ TemplateConfigurationFactory templateConfigurations) {
TemplateCache oldCache = cache;
cache = new TemplateCache(
- loader, storage, templateLookupStrategy, templateNameFormat, templateConfigurers, this);
+ loader, storage, templateLookupStrategy, templateNameFormat, templateConfigurations, this);
cache.clear(); // for fully BC behavior
cache.setDelay(oldCache.getDelay());
cache.setLocalizedLookup(localizedLookup);
@@ -827,7 +827,7 @@
private void recreateTemplateCache() {
recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(),
cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(),
- getTemplateConfigurers());
+ getTemplateConfigurations());
}
private TemplateLoader getDefaultTemplateLoader() {
@@ -932,7 +932,7 @@
copy.recreateTemplateCacheWith(
cache.getTemplateLoader(), cache.getCacheStorage(),
cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(),
- cache.getTemplateConfigurers());
+ cache.getTemplateConfigurations());
return copy;
} catch (CloneNotSupportedException e) {
throw new BugException("Cloning failed", e);
@@ -1122,7 +1122,7 @@
if (cache.getTemplateLoader() != templateLoader) {
recreateTemplateCacheWith(templateLoader, cache.getCacheStorage(),
cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(),
- cache.getTemplateConfigurers());
+ cache.getTemplateConfigurations());
}
templateLoaderExplicitlySet = true;
}
@@ -1171,7 +1171,7 @@
if (cache.getTemplateLookupStrategy() != templateLookupStrategy) {
recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(),
templateLookupStrategy, cache.getTemplateNameFormat(),
- cache.getTemplateConfigurers());
+ cache.getTemplateConfigurations());
}
templateLookupStrategyExplicitlySet = true;
}
@@ -1220,7 +1220,7 @@
if (cache.getTemplateNameFormat() != templateNameFormat) {
recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(),
cache.getTemplateLookupStrategy(), templateNameFormat,
- cache.getTemplateConfigurers());
+ cache.getTemplateConfigurations());
}
templateNameFormatExplicitlySet = true;
}
@@ -1259,38 +1259,38 @@
}
/**
- * Sets a {@link TemplateConfigurerFactory} that will configure individual templates where their settings differ
+ * Sets a {@link TemplateConfigurationFactory} that will configure individual templates where their settings differ
* from those coming from the common {@link Configuration} object. A typical use case for that is specifying the
- * {@link TemplateConfigurer#setOutputFormat(OutputFormat) outputFormat} for templates based on their file
+ * {@link TemplateConfiguration#setOutputFormat(OutputFormat) outputFormat} for templates based on their file
* extension or parent directory.
*
* <p>
* Note that the settings suggested by standard file extensions are stronger than that you set here. See
* {@link #setRecognizeStandardFileExtensions(boolean)} for more information about standard file extensions.
*
- * <p>See "Template configurers" in the FreeMarker Manual for examples.
+ * <p>See "Template configurations" in the FreeMarker Manual for examples.
*
* @since 2.3.24
*/
- public void setTemplateConfigurers(TemplateConfigurerFactory templateConfigurers) {
- if (cache.getTemplateConfigurers() != templateConfigurers) {
- if (templateConfigurers != null) {
- templateConfigurers.setConfiguration(this);
+ public void setTemplateConfigurations(TemplateConfigurationFactory templateConfigurations) {
+ if (cache.getTemplateConfigurations() != templateConfigurations) {
+ if (templateConfigurations != null) {
+ templateConfigurations.setConfiguration(this);
}
recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(),
cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(),
- templateConfigurers);
+ templateConfigurations);
}
}
/**
- * The getter pair of {@link #setTemplateConfigurers(TemplateConfigurerFactory)}.
+ * The getter pair of {@link #setTemplateConfigurations(TemplateConfigurationFactory)}.
*/
- public TemplateConfigurerFactory getTemplateConfigurers() {
+ public TemplateConfigurationFactory getTemplateConfigurations() {
if (cache == null) {
return null;
}
- return cache.getTemplateConfigurers();
+ return cache.getTemplateConfigurations();
}
/**
@@ -1311,7 +1311,7 @@
if (getCacheStorage() != cacheStorage) {
recreateTemplateCacheWith(cache.getTemplateLoader(), cacheStorage,
cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(),
- cache.getTemplateConfigurers());
+ cache.getTemplateConfigurations());
}
cacheStorageExplicitlySet = true;
}
@@ -1740,7 +1740,7 @@
* Auto-escaping has significance when a value is printed with <code>${...}</code> (or <code>#{...}</code>). If
* auto-escaping is on, FreeMarker will assume that the value is plain text (as opposed to markup or some kind of
* rich text), so it will escape it according the current output format (see {@link #setOutputFormat(OutputFormat)}
- * and {@link TemplateConfigurer#setOutputFormat(OutputFormat)}). If auto-escaping is off, FreeMarker will assume
+ * and {@link TemplateConfiguration#setOutputFormat(OutputFormat)}). If auto-escaping is off, FreeMarker will assume
* that the string value is already in the output format, so it prints it as is to the output.
*
* <p>Further notes on auto-escaping:
@@ -1759,16 +1759,16 @@
* </ul>
*
* <p>Note that what you set here is just a default, which can be overridden for individual templates via
- * {@link #setTemplateConfigurers(TemplateConfigurerFactory)}. This setting is also overridden by the standard file
+ * {@link #setTemplateConfigurations(TemplateConfigurationFactory)}. This setting is also overridden by the standard file
* extensions; see them at {@link #setRecognizeStandardFileExtensions(boolean)}.
*
* @param autoEscapingPolicy
* One of the {@link #ENABLE_IF_DEFAULT_AUTO_ESCAPING_POLICY},
* {@link #ENABLE_IF_SUPPORTED_AUTO_ESCAPING_POLICY}, and {@link #DISABLE_AUTO_ESCAPING_POLICY} constants.
*
- * @see TemplateConfigurer#setAutoEscapingPolicy(int)
+ * @see TemplateConfiguration#setAutoEscapingPolicy(int)
* @see Configuration#setOutputFormat(OutputFormat)
- * @see TemplateConfigurer#setOutputFormat(OutputFormat)
+ * @see TemplateConfiguration#setOutputFormat(OutputFormat)
*
* @since 2.3.24
*/
@@ -1794,7 +1794,7 @@
/**
* Sets the (default) output format. Usually, you leave this on its default, which is
* {@link UndefinedOutputFormat#INSTANCE}, and then override it for individual templates based on their name (like
- * based on their "file" extension) with {@link #setTemplateConfigurers(TemplateConfigurerFactory)}. This setting is
+ * based on their "file" extension) with {@link #setTemplateConfigurations(TemplateConfigurationFactory)}. This setting is
* also overridden by the standard file extensions; see them at
* {@link #setRecognizeStandardFileExtensions(boolean)}.
*
@@ -1803,7 +1803,7 @@
* also used by the embedding application to set the HTTP response MIME type, etc.
*
* @see #setRegisteredCustomOutputFormats(Collection)
- * @see #setTemplateConfigurers(TemplateConfigurerFactory)
+ * @see #setTemplateConfigurations(TemplateConfigurationFactory)
* @see #setRecognizeStandardFileExtensions(boolean)
* @see #setAutoEscapingPolicy(int)
*
@@ -2018,26 +2018,26 @@
* Sets if the "file" extension part of the source name ({@link Template#getSourceName()}) will influence certain
* parsing settings. For backward compatibility, it defaults to {@code false} if
* {@link #getIncompatibleImprovements()} is less than 2.3.24. Starting from {@code incompatibleImprovements}
- * 2.3.24, defaults to {@code true}, so the following standard file extensions take their effect:
+ * 2.3.24, it defaults to {@code true}, so the following standard file extensions take their effect:
*
* <ul>
- * <li>{@code ftlh}: Sets {@link TemplateConfigurer#setOutputFormat(OutputFormat) outputFormat} to {@code "HTML"}
- * (i.e., {@link HTMLOutputFormat#INSTANCE} unless the {@code "HTML"} name is overridden by
+ * <li>{@code ftlh}: Sets {@link TemplateConfiguration#setOutputFormat(OutputFormat) outputFormat} to
+ * {@code "HTML"} (i.e., {@link HTMLOutputFormat#INSTANCE}, unless the {@code "HTML"} name is overridden by
* {@link #setRegisteredCustomOutputFormats(Collection)}) and
- * {@link #ENABLE_IF_DEFAULT_AUTO_ESCAPING_POLICY}
- * {@link TemplateConfigurer#setAutoEscapingPolicy(int) autoEscapingPolicy}.
- * <li>{@code ftlx}: Sets {@link TemplateConfigurer#setOutputFormat(OutputFormat) outputFormat} to {@code "XML"}
- * (i.e., {@link XMLOutputFormat#INSTANCE} unless the {@code "XML"} name is overridden by
+ * {@link TemplateConfiguration#setAutoEscapingPolicy(int) autoEscapingPolicy} to
+ * {@link #ENABLE_IF_DEFAULT_AUTO_ESCAPING_POLICY}.
+ * <li>{@code ftlx}: Sets {@link TemplateConfiguration#setOutputFormat(OutputFormat) outputFormat} to
+ * {@code "XML"} (i.e., {@link XMLOutputFormat#INSTANCE}, unless the {@code "XML"} name is overridden by
* {@link #setRegisteredCustomOutputFormats(Collection)}) and
- * {@link #ENABLE_IF_DEFAULT_AUTO_ESCAPING_POLICY}
- * {@link TemplateConfigurer#setAutoEscapingPolicy(int) autoEscapingPolicy}.
+ * {@link TemplateConfiguration#setAutoEscapingPolicy(int) autoEscapingPolicy} to
+ * {@link #ENABLE_IF_DEFAULT_AUTO_ESCAPING_POLICY}.
* </ul>
*
* <p>These file extensions are not case sensitive. The file extension is the part after the last dot in the source
* name. If the source name contains no dot, then it has no file extension.
*
- * <p>The settings activated by these file extensions override the settings values dictated by
- * {@link #setTemplateConfigurers(TemplateConfigurerFactory)}.
+ * <p>The settings activated by these file extensions override the setting values dictated by
+ * {@link #setTemplateConfigurations(TemplateConfigurationFactory)}.
*/
public void setRecognizeStandardFileExtensions(boolean recognizeStandardFileExtensions) {
boolean prevEffectiveValue = getRecognizeStandardFileExtensions();
@@ -2274,7 +2274,7 @@
*
* @param locale
* The requested locale of the template. This is what {@link Template#getLocale()} on the resulting
- * {@link Template} will return (unless it's overridden via {@link #getTemplateConfigurers()}). This
+ * {@link Template} will return (unless it's overridden via {@link #getTemplateConfigurations()}). This
* parameter can be {@code null} since 2.3.22, in which case it defaults to
* {@link Configuration#getLocale()} (note that {@link Template#getLocale()} will give the default value,
* not {@code null}). This parameter also drives localized template lookup. Assuming that you have
@@ -2284,7 +2284,7 @@
* retrieve {@code myTemplate_en_US.html}, then {@code myTemplate.en.ftl}, and finally
* {@code myTemplate.ftl}. Note that that the template's locale will be {@code en_US} even if it only
* finds {@code myTemplate.ftl}. Note that when the {@code locale} setting is overridden with a
- * {@link TemplateConfigurer} provided by {@link #getTemplateConfigurers()}, that overrides the
+ * {@link TemplateConfiguration} provided by {@link #getTemplateConfigurations()}, that overrides the
* value specified here, but only after the localized lookup, that is, it modifies the template
* found by the localized lookup.
*
@@ -2305,7 +2305,7 @@
* instead). Why is this deprecated: It doesn't make sense to get the <em>same</em> template with
* different encodings, hence, it's error prone to specify the encoding where you get the template.
* Instead, if you have template "files" with different charsets, you should use
- * {@link #setTemplateConfigurers(TemplateConfigurerFactory)}, where you can associate encodings to
+ * {@link #setTemplateConfigurations(TemplateConfigurationFactory)}, where you can associate encodings to
* individual templates based on their names (like which "directory" are they in, what's their file
* extension, etc.). The encoding associated with the templates that way overrides the encoding that you
* specify here.
@@ -2900,13 +2900,13 @@
} else {
throw invalidSettingValueException(name, value);
}
- } else if (TEMPLATE_CONFIGURERS_KEY_SNAKE_CASE.equals(name)
- || TEMPLATE_CONFIGURERS_KEY_CAMEL_CASE.equals(name)) {
+ } else if (TEMPLATE_CONFIGURATIONS_KEY_SNAKE_CASE.equals(name)
+ || TEMPLATE_CONFIGURATIONS_KEY_CAMEL_CASE.equals(name)) {
if (value.equals(NULL)) {
- setTemplateConfigurers(null);
+ setTemplateConfigurations(null);
} else {
- setTemplateConfigurers((TemplateConfigurerFactory) _ObjectBuilderSettingEvaluator.eval(
- value, TemplateConfigurerFactory.class, false, _SettingEvaluationEnvironment.getCurrent()));
+ setTemplateConfigurations((TemplateConfigurationFactory) _ObjectBuilderSettingEvaluator.eval(
+ value, TemplateConfigurationFactory.class, false, _SettingEvaluationEnvironment.getCurrent()));
}
} else {
unknown = true;
diff --git a/src/main/java/freemarker/template/Template.java b/src/main/java/freemarker/template/Template.java
index 0530fe2..f785768 100644
--- a/src/main/java/freemarker/template/Template.java
+++ b/src/main/java/freemarker/template/Template.java
@@ -48,7 +48,7 @@
import freemarker.core.OutputFormat;
import freemarker.core.ParseException;
import freemarker.core.ParserConfiguration;
-import freemarker.core.TemplateConfigurer;
+import freemarker.core.TemplateConfiguration;
import freemarker.core.TemplateElement;
import freemarker.core.TextBlock;
import freemarker.core.TokenMgrError;
@@ -73,7 +73,7 @@
* changing FreeMarker settings. Those must not be used while the template is being processed, or if the template object
* is already accessible from multiple threads. If some templates need different settings that those coming from the
* shared {@link Configuration}, and you are using {@link Configuration#getTemplate(String)} (or its overloads), then
- * see {@link Configuration#setTemplateConfigurers(freemarker.cache.TemplateConfigurerFactory)}.
+ * see {@link Configuration#setTemplateConfigurations(freemarker.cache.TemplateConfigurationFactory)}.
*/
public class Template extends Configurable {
public static final String DEFAULT_NAMESPACE_PREFIX = "D";
@@ -207,25 +207,25 @@
/**
* Same as {@link #Template(String, String, Reader, Configuration, String)}, but also specifies a
- * {@link TemplateConfigurer}. This is mostly meant to be used by FreeMarker internally, but advanced users might
+ * {@link TemplateConfiguration}. This is mostly meant to be used by FreeMarker internally, but advanced users might
* still find this useful.
*
* @param customParserConfiguration
* Overrides the parsing related configuration settings of the {@link Configuration} parameter; can be
* {@code null}. This is useful as the {@link Configuration} is normally a singleton shared by all
- * templates, and so it's not good for specifying template-specific settings. (While
- * {@link Template} itself has methods to specify settings just for that template, those don't influence
- * the parsing, and you only have opportunity to call them after the parsing anyway.) This objects is
- * often a {@link TemplateConfigurer} whose parent is the {@link Configuration} parameter, and then it
+ * templates, and so it's not good for specifying template-specific settings. (While {@link Template}
+ * itself has methods to specify settings just for that template, those don't influence the parsing, and
+ * you only have opportunity to call them after the parsing anyway.) This objects is often a
+ * {@link TemplateConfiguration} whose parent is the {@link Configuration} parameter, and then it
* practically just overrides some of the parser settings, as the others are inherited from the
- * {@link Configuration}. Note that if this is a {@link TemplateConfigurer}, you will also want to call
- * {@link TemplateConfigurer#configure(Template)} on the resulting {@link Template} so that
+ * {@link Configuration}. Note that if this is a {@link TemplateConfiguration}, you will also want to
+ * call {@link TemplateConfiguration#apply(Template)} on the resulting {@link Template} so that
* {@link Configurable} settings will be set too, because this constructor only uses it as a
- * {@link ParserConfiguration}.
+ * {@link ParserConfiguration}.
* @param encoding
* Same as in {@link #Template(String, String, Reader, Configuration, String)}. When it's non-{@code
- * null}, it overrides the value coming from the {@code TemplateConfigurer#getEncoding()} method of the
- * {@code templateConfigurer} parameter.
+ * null}, it overrides the value coming from the {@link TemplateConfiguration#getEncoding()} method of
+ * the {@code templateConfiguration} parameter.
*
* @since 2.3.24
*/
@@ -572,7 +572,7 @@
/**
* Returns the {@link ParserConfiguration} that was used for parsing this template. This is most often the same
- * object as {@link #getConfiguration()}, but sometimes it's a {@link TemplateConfigurer}, or something else. It's
+ * object as {@link #getConfiguration()}, but sometimes it's a {@link TemplateConfiguration}, or something else. It's
* never {@code null}.
*
* @since 2.3.24
@@ -663,7 +663,7 @@
* Returns the output format (see {@link Configuration#setOutputFormat(OutputFormat)}) used for this template.
* The output format of a template can come from various places, in order of increasing priority:
* {@link Configuration#getOutputFormat()}, {@link ParserConfiguration#getOutputFormat()} (which is usually
- * provided by {@link Configuration#getTemplateConfigurers()}) and the {@code #ftl} header's {@code output_format}
+ * provided by {@link Configuration#getTemplateConfigurations()}) and the {@code #ftl} header's {@code output_format}
* option in the template.
*
* @since 2.3.24
@@ -683,7 +683,7 @@
* Returns if the template actually uses auto-escaping (see {@link Configuration#setAutoEscapingPolicy(int)}). This value
* is decided by the parser based on the actual {@link OutputFormat}, and the auto-escaping enums, in order of
* increasing priority: {@link Configuration#getAutoEscapingPolicy()}, {@link ParserConfiguration#getAutoEscapingPolicy()}
- * (which is usually provided by {@link Configuration#getTemplateConfigurers()}), and finally on the {@code #ftl}
+ * (which is usually provided by {@link Configuration#getTemplateConfigurations()}), and finally on the {@code #ftl}
* header's {@code auto_esc} option in the template.
*
* @since 2.3.24
diff --git a/src/manual/book.xml b/src/manual/book.xml
index 0b80c41..c561322 100644
--- a/src/manual/book.xml
+++ b/src/manual/book.xml
@@ -7991,10 +7991,10 @@
<listitem>
<para><literal>Template</literal> layer: Settings on individual
templates are normally set by <link
- linkend="pgui_config_templateconfigurers">template configurers
- (see them in their own chapter)</link>, which basically associate
- setting assignments to template name (template path) patterns.
- There's a deviation from this approach with the
+ linkend="pgui_config_templateconfigurations">template
+ configurations (see them in their own chapter)</link>, which
+ basically associate setting assignments to template name (template
+ path) patterns. There's a deviation from this approach with the
<literal>locale</literal> setting, because that you can also
specify to <literal>Configuration.getTemplate(...)</literal> as
parameter, to get the template for the requested locale (so called
@@ -8689,13 +8689,13 @@
</section>
</section>
- <section xml:id="pgui_config_templateconfigurers">
- <title>Template configurers</title>
+ <section xml:id="pgui_config_templateconfigurations">
+ <title>Template configurations</title>
- <para>Template configurers refers to the
- <literal>template_configurers</literal> setting of
+ <para><quote>Template configurations</quote> refers to the
+ <literal>template_configurations</literal> setting of
<literal>Configuration</literal>
- (<literal>Configuration.setTemplateConfigurers(<replaceable>...</replaceable>)</literal>).
+ (<literal>Configuration.setTemplateConfigurations(<replaceable>...</replaceable>)</literal>).
This setting lets you override individual settings coming from the
common <literal>Configuration</literal> object, depending on the name
(path) of the template.</para>
@@ -8713,13 +8713,13 @@
<itemizedlist>
<listitem>
- <para><literal>TemplateConfigurer</literal>-s: These store the
+ <para><literal>TemplateConfiguration</literal>-s: These store the
actual setting assignments that you want to do. For example, this
- <literal>TemplateConfigurer</literal> will set the encoding and
+ <literal>TemplateConfiguration</literal> will set the encoding and
the output format of the matched template (and leave all other
settings of it alone):</para>
- <programlisting role="unspecified">TemplateConfigurer tcUTF8XML = new TemplateConfigurer();
+ <programlisting role="unspecified">TemplateConfiguration tcUTF8XML = new TemplateConfiguration();
tc.setEncoding("utf-8");
tc.setOutputFormat(XMLOutputFormat.INSTANCE);</programlisting>
</listitem>
@@ -8736,11 +8736,11 @@
</listitem>
<listitem>
- <para><literal>TemplateConfigurerFactory</literal>-es: This is
- what connects <literal>TemplateConfigurer</literal> and
+ <para><literal>TemplateConfigurationFactory</literal>-es: This is
+ what connects <literal>TemplateConfiguration</literal> and
<literal>TemplateSourceMatcher</literal> together. This is the
- Java type of the <literal>template_configurers</literal> setting.
- See the examples below for more.</para>
+ Java type of the <literal>template_configurations</literal>
+ setting. See the examples below for more.</para>
</listitem>
</itemizedlist>
@@ -8748,12 +8748,12 @@
<title>Example 1</title>
<para>This setup combines our earlier two example object with a
- <literal>ConditionalTemplateConfigurerFactory</literal>, causing all
- templates with <literal>xml</literal> extension to get UTF-8
+ <literal>ConditionalTemplateConfigurationFactory</literal>, causing
+ all templates with <literal>xml</literal> extension to get UTF-8
encoding and XML output format:</para>
- <programlisting role="unspecified">cfg.setTemplateConfigurers(
- new ConditionalTemplateConfigurerFactory(
+ <programlisting role="unspecified">cfg.setTemplateConfigurations(
+ new ConditionalTemplateConfigurationFactory(
new FileExtensionMatcher("xml"),
tcUTF8XML));</programlisting>
@@ -8763,10 +8763,10 @@
key value pairs (the <literal>\</literal>-s are prescribed by the
Java Properties file format):</para>
- <programlisting role="unspecified">templateConfigurers = \
- ConditionalTemplateConfigurerFactory( \
+ <programlisting role="unspecified">templateConfigurations = \
+ ConditionalTemplateConfigurationFactory( \
FileExtensionMatcher("xml"), \
- TemplateConfigurer( \
+ TemplateConfiguration( \
encoding = "utf-8", \
outputFormat = XMLOutputFormat() \
) \
@@ -8784,20 +8784,20 @@
Subject templates must get <literal>plainText</literal> output
format, while body templates must get <literal>HTML</literal> output
format. So we have to make a choice here, and that's when you need a
- <literal>FirstMatchTemplateConfigurerFactory</literal>.</para>
+ <literal>FirstMatchTemplateConfigurationFactory</literal>.</para>
<para>Assuming <literal>cfg</literal> stores the shared
<literal>Configuration</literal> singleton, you set this up like
this:</para>
- <programlisting role="unspecified">cfg.setTemplateConfigurers(
- new ConditionalTemplateConfigurerFactory(
+ <programlisting role="unspecified">cfg.setTemplateConfigurations(
+ new ConditionalTemplateConfigurationFactory(
new PathGlobMatcher("mail/**"),
- new FirstMatchTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(
+ new FirstMatchTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(
new FileNameGlobMatcher("*.subject.*"),
tcSubject),
- new ConditionalTemplateConfigurerFactory(
+ new ConditionalTemplateConfigurationFactory(
new FileNameGlobMatcher("*.body.*"),
tcBody)
)
@@ -8810,17 +8810,17 @@
key value pairs (the <literal>\</literal>-s are prescribed by the
Java Properties file format only):</para>
- <programlisting role="unspecified">templateConfigurers = \
- ConditionalTemplateConfigurerFactory( \
+ <programlisting role="unspecified">templateConfigurations = \
+ ConditionalTemplateConfigurationFactory( \
PathGlobMatcher("mail/**"), \
- FirstMatchTemplateConfigurerFactory( \
- ConditionalTemplateConfigurerFactory( \
+ FirstMatchTemplateConfigurationFactory( \
+ ConditionalTemplateConfigurationFactory( \
FileNameGlobMatcher("*.subject.*"), \
- TemplateConfigurer(outputFormat = PlainTextOutputFormat()) \
+ TemplateConfiguration(outputFormat = PlainTextOutputFormat()) \
), \
- ConditionalTemplateConfigurerFactory( \
+ ConditionalTemplateConfigurationFactory( \
FileNameGlobMatcher("*.body.*"), \
- TemplateConfigurer(outputFormat = HTMLOutputFormat()) \
+ TemplateConfiguration(outputFormat = HTMLOutputFormat()) \
), \
noMatchErrorDetails = 'Mail template names must contain ".subject." or ".body."!' \
) \
@@ -8858,42 +8858,42 @@
<para>Here we have 3 independent concerns, and possibly multiple (or
none) of those apply to a template; that's when you need a
- <literal>MergingTemplateConfigurerFactory</literal>. The last point
- describes a rule where you have mutually exclusive choices; that's
- when you need a
- <literal>FirstMatchTemplateConfigurerFactory</literal>, but this
+ <literal>MergingTemplateConfigurationFactory</literal>. The last
+ point describes a rule where you have mutually exclusive choices;
+ that's when you need a
+ <literal>FirstMatchTemplateConfigurationFactory</literal>, but this
time no choice is also allowed. Here's the source code, assuming
<literal>cfg</literal> stores the shared
<literal>Configuration</literal> instance:</para>
- <programlisting role="unspecified">TemplateConfigurer tcStats = new TemplateConfigurer();
+ <programlisting role="unspecified">TemplateConfiguration tcStats = new TemplateConfiguration();
tcStats.setDateTimeFormat("iso");
tcStats.setDateFormat("iso");
tcStats.setTimeFormat("iso");
tcStats.setTimeZone(DateUtil.UTC);
-TemplateConfigurer tcMail = new TemplateConfigurer();
+TemplateConfiguration tcMail = new TemplateConfiguration();
tcMail.setEncoding("utf-8");
-TemplateConfigurer tcHTML = new TemplateConfigurer();
+TemplateConfiguration tcHTML = new TemplateConfiguration();
tcHTML.setOutputFormat(HTMLOutputFormat.INSTANCE);
-TemplateConfigurer tcXML = new TemplateConfigurer();
+TemplateConfiguration tcXML = new TemplateConfiguration();
tcXML.setOutputFormat(XMLOutputFormat.INSTANCE);
-cfg.setTemplateConfigurers(
- new MergingTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(
+cfg.setTemplateConfigurations(
+ new MergingTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(
new FileNameGlobMatcher("*.stats.*"),
tcStats),
- new ConditionalTemplateConfigurerFactory(
+ new ConditionalTemplateConfigurationFactory(
new PathGlobMatcher("mail/**"),
tcMail),
- new FirstMatchTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(
+ new FirstMatchTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(
new FileExtensionMatcher("xml"),
tcXML),
- new ConditionalTemplateConfigurerFactory(
+ new ConditionalTemplateConfigurationFactory(
new OrMatcher(
new FileExtensionMatcher("html"),
new FileExtensionMatcher("htm")),
@@ -8907,32 +8907,32 @@
key value pairs (the <literal>\</literal>-s are prescribed by the
Java Properties file format only):</para>
- <programlisting role="unspecified">templateConfigurers = \
- MergingTemplateConfigurerFactory( \
- ConditionalTemplateConfigurerFactory( \
+ <programlisting role="unspecified">templateConfigurations = \
+ MergingTemplateConfigurationFactory( \
+ ConditionalTemplateConfigurationFactory( \
FileNameGlobMatcher("*.stats.*"), \
- TemplateConfigurer( \
+ TemplateConfiguration( \
dateTimeFormat = "iso", \
dateFormat = "iso", \
timeFormat = "iso", \
timeZone = TimeZone("UTC") \
) \
), \
- ConditionalTemplateConfigurerFactory( \
+ ConditionalTemplateConfigurationFactory( \
PathGlobMatcher("mail/**"), \
- TemplateConfigurer(encoding = "utf-8") \
+ TemplateConfiguration(encoding = "utf-8") \
), \
- FirstMatchTemplateConfigurerFactory( \
- ConditionalTemplateConfigurerFactory( \
+ FirstMatchTemplateConfigurationFactory( \
+ ConditionalTemplateConfigurationFactory( \
FileExtensionMatcher("xml"), \
- TemplateConfigurer(outputFormat = XMLOutputFormat()) \
+ TemplateConfiguration(outputFormat = XMLOutputFormat()) \
), \
- ConditionalTemplateConfigurerFactory( \
+ ConditionalTemplateConfigurationFactory( \
OrMatcher( \
FileExtensionMatcher("html"), \
FileExtensionMatcher("htm") \
), \
- TemplateConfigurer(outputFormat = HTMLOutputFormat()) \
+ TemplateConfiguration(outputFormat = HTMLOutputFormat()) \
), \
allowNoMatch = true \
) \
@@ -8970,7 +8970,7 @@
file extensions is the recommended way of activating HTML and XML
auto-escaping. You can also associate output formats to templates
based on arbitrary name patterns with the <link
- linkend="pgui_config_templateconfigurers"><literal>template_configurers</literal>
+ linkend="pgui_config_templateconfigurations"><literal>template_configurations</literal>
setting</link>; see some examples of that below.</para>
<para>There's another a related setting, called
@@ -9038,11 +9038,11 @@
<programlisting role="unspecified">// Where you initalize the Configuration singletion, add:
-TemplateConfigurer tcHTML = new TemplateConfigurer();
+TemplateConfiguration tcHTML = new TemplateConfiguration();
tcHTML.setOutputFormat(HTMLOutputFormat.INSTANCE);
-cfg.setTemplateConfigurers(
- new ConditionalTemplateConfigurerFactory(
+cfg.setTemplateConfigurations(
+ new ConditionalTemplateConfigurationFactory(
new PathGlobMatcher("mail/**"),
tcHTML));</programlisting>
@@ -9050,10 +9050,10 @@
<literal>*.properties</literal> file (the <literal>\</literal>-s
are required for the Java Properties file format only):</para>
- <programlisting role="unspecified">templateConfigurers = \
- ConditionalTemplateConfigurerFactory( \
+ <programlisting role="unspecified">templateConfigurations = \
+ ConditionalTemplateConfigurationFactory( \
PathGlobMatcher("mail/**"), \
- TemplateConfigurer(outputFormat = HTMLOutputFormat()))</programlisting>
+ TemplateConfiguration(outputFormat = HTMLOutputFormat()))</programlisting>
</listitem>
<listitem>
@@ -9067,26 +9067,26 @@
<literal>cfg.getTemplate(<replaceable>...</replaceable>)</literal>,
and not instantiating them yourself):</para>
- <programlisting role="unspecified">TemplateConfigurer tcHTML = new TemplateConfigurer();
+ <programlisting role="unspecified">TemplateConfiguration tcHTML = new TemplateConfiguration();
tcHTML.setOutputFormat(HTMLOutputFormat.INSTANCE);
-TemplateConfigurer tcXML = new TemplateConfigurer();
+TemplateConfiguration tcXML = new TemplateConfiguration();
tcXML.setOutputFormat(XMLOutputFormat.INSTANCE);
-TemplateConfigurer tcRTF = new TemplateConfigurer();
+TemplateConfiguration tcRTF = new TemplateConfiguration();
tcRTF.setOutputFormat(RTFOutputFormat.INSTANCE);
-cfg.setTemplateConfigurers(
- new FirstMatchTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(
+cfg.setTemplateConfigurations(
+ new FirstMatchTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(
new FileExtensionMatcher("xml"),
tcXML),
- new ConditionalTemplateConfigurerFactory(
+ new ConditionalTemplateConfigurationFactory(
new OrMatcher(
new FileExtensionMatcher("html"),
new FileExtensionMatcher("htm")),
tcHTML),
- new ConditionalTemplateConfigurerFactory(
+ new ConditionalTemplateConfigurationFactory(
new FileExtensionMatcher("rtf"),
tcRTF)
).allowNoMatch(true)
@@ -9096,26 +9096,26 @@
<literal>*.properties</literal> file (the <literal>\</literal>-s
are required for the Java Properties file format only):</para>
- <programlisting role="unspecified">templateConfigurers = \
- FirstMatchTemplateConfigurerFactory( \
- ConditionalTemplateConfigurerFactory( \
+ <programlisting role="unspecified">templateConfigurations = \
+ FirstMatchTemplateConfigurationFactory( \
+ ConditionalTemplateConfigurationFactory( \
FileExtensionMatcher("xml"), \
- TemplateConfigurer(outputFormat = XMLOutputFormat())), \
- ConditionalTemplateConfigurerFactory( \
+ TemplateConfiguration(outputFormat = XMLOutputFormat())), \
+ ConditionalTemplateConfigurationFactory( \
OrMatcher( \
FileExtensionMatcher("html"), \
FileExtensionMatcher("htm")), \
- TemplateConfigurer(outputFormat = HTMLOutputFormat())), \
- ConditionalTemplateConfigurerFactory( \
+ TemplateConfiguration(outputFormat = HTMLOutputFormat())), \
+ ConditionalTemplateConfigurationFactory( \
FileExtensionMatcher("rtf"), \
- TemplateConfigurer(outputFormat = RTFOutputFormat())), \
+ TemplateConfiguration(outputFormat = RTFOutputFormat())), \
allowNoMatch = true)</programlisting>
</listitem>
</itemizedlist>
<para>(You can find some more complex
- <literal>template_configurers</literal> setups <link
- linkend="pgui_config_templateconfigurers">here...</link>)</para>
+ <literal>template_configurations</literal> setups <link
+ linkend="pgui_config_templateconfigurations">here...</link>)</para>
</section>
<section xml:id="pgui_config_custom_formats">
@@ -19091,9 +19091,9 @@
included template. You shouldn't use this option anymore; if
different template use different encodings, then the programmers
should associated the encoding to the templates via
- <literal>Configuration.setTemplateConfigurers(<replaceable>...</replaceable>)</literal>-s
+ <literal>Configuration.setTemplateConfigurations(<replaceable>...</replaceable>)</literal>-s
(which also overrides that you specify here). If
- <literal>Configuration.setTemplateConfigurers(<replaceable>...</replaceable>)</literal>
+ <literal>Configuration.setTemplateConfigurations(<replaceable>...</replaceable>)</literal>
doesn't specify an encoding for the included template, then the
included file inherits the encoding (the charset) of the
top-level template, unless you specify an encoding with this
@@ -25881,11 +25881,11 @@
<listitem>
<para>Added new configuration setting:
- <literal>template_configurers</literal>. This allows overriding
- the settings coming from the shared
+ <literal>template_configurations</literal>. This allows
+ overriding the settings coming from the shared
<literal>Configuration</literal> object for individual
templates, based on template name patterns. <link
- linkend="pgui_config_templateconfigurers">See more
+ linkend="pgui_config_templateconfigurations">See more
here...</link></para>
</listitem>
@@ -25921,7 +25921,7 @@
<literal>XML</literal>, <literal>plainText</literal>, etc.)
that governs auto-escaping. The output format can be
different for different templates, using the
- <literal>template_configurers</literal> setting (<link
+ <literal>template_configurations</literal> setting (<link
linkend="pgui_config_outputformatsautoesc">see here
how...</link>).</para>
</listitem>
@@ -25997,7 +25997,7 @@
<literal>custom_number_formats</literal> and
<literal>custom_date_formats</literal> settings can be set
per-template (via the new
- <literal>template_configurers</literal> settings) or
+ <literal>template_configurations</literal> settings) or
per-<literal>Environment</literal> too, thus
<literal>@foo</literal> can mean something different in
different templates.</para>
@@ -26508,6 +26508,17 @@
</listitem>
<listitem>
+ <para>The new <literal>TemplateConfigurer</literal> class was
+ renamed to <literal>TemplateConfiguration</literal>, and the
+ related configuration setting from
+ <literal>template_configurers</literal> to
+ <literal>template_configurations</literal>. Also, the
+ <literal>TemplateConfigurer.configure</literal> method was
+ renamed to
+ <literal>TemplateConfiguration.apply</literal>.</para>
+ </listitem>
+
+ <listitem>
<para>Bug fixed: It wasn't well defined when a Java
<literal>Iterator</literal> counts as empty. Depending on what
<literal>ObjectWrapper</literal> you are using, one of these
diff --git a/src/test/java/freemarker/cache/TemplateConfigurationFactoryTest.java b/src/test/java/freemarker/cache/TemplateConfigurationFactoryTest.java
new file mode 100644
index 0000000..663eed2
--- /dev/null
+++ b/src/test/java/freemarker/cache/TemplateConfigurationFactoryTest.java
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package freemarker.cache;
+
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+
+import freemarker.core.TemplateConfiguration;
+import freemarker.template.Configuration;
+
+public class TemplateConfigurationFactoryTest {
+
+ private Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
+
+ @Test
+ public void testCondition1() throws IOException, TemplateConfigurationFactoryException {
+ TemplateConfiguration tc = newTemplateConfiguration(1);
+
+ TemplateConfigurationFactory tcf = new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.ftlx"), tc);
+ tcf.setConfiguration(cfg);
+
+ assertNotApplicable(tcf, "x.ftl");
+ assertApplicable(tcf, "x.ftlx", tc);
+ }
+
+ @Test
+ public void testCondition2() throws IOException, TemplateConfigurationFactoryException {
+ TemplateConfiguration tc = newTemplateConfiguration(1);
+
+ TemplateConfigurationFactory tcf = new ConditionalTemplateConfigurationFactory(
+ new FileNameGlobMatcher("*.ftlx"),
+ new ConditionalTemplateConfigurationFactory(
+ new FileNameGlobMatcher("x.*"), tc));
+ tcf.setConfiguration(cfg);
+
+ assertNotApplicable(tcf, "x.ftl");
+ assertNotApplicable(tcf, "y.ftlx");
+ assertApplicable(tcf, "x.ftlx", tc);
+ }
+
+ @Test
+ public void testMerging() throws IOException, TemplateConfigurationFactoryException {
+ TemplateConfiguration tc1 = newTemplateConfiguration(1);
+ TemplateConfiguration tc2 = newTemplateConfiguration(2);
+ TemplateConfiguration tc3 = newTemplateConfiguration(3);
+
+ TemplateConfigurationFactory tcf = new MergingTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.ftlx"), tc1),
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*a*.*"), tc2),
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*b*.*"), tc3));
+ tcf.setConfiguration(cfg);
+
+ assertNotApplicable(tcf, "x.ftl");
+ assertApplicable(tcf, "x.ftlx", tc1);
+ assertApplicable(tcf, "a.ftl", tc2);
+ assertApplicable(tcf, "b.ftl", tc3);
+ assertApplicable(tcf, "a.ftlx", tc1, tc2);
+ assertApplicable(tcf, "b.ftlx", tc1, tc3);
+ assertApplicable(tcf, "ab.ftl", tc2, tc3);
+ assertApplicable(tcf, "ab.ftlx", tc1, tc2, tc3);
+
+ assertNotApplicable(new MergingTemplateConfigurationFactory(), "x.ftl");
+ }
+
+ @Test
+ public void testFirstMatch() throws IOException, TemplateConfigurationFactoryException {
+ TemplateConfiguration tc1 = newTemplateConfiguration(1);
+ TemplateConfiguration tc2 = newTemplateConfiguration(2);
+ TemplateConfiguration tc3 = newTemplateConfiguration(3);
+
+ FirstMatchTemplateConfigurationFactory tcf = new FirstMatchTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.ftlx"), tc1),
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*a*.*"), tc2),
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*b*.*"), tc3));
+ tcf.setConfiguration(cfg);
+
+ try {
+ assertNotApplicable(tcf, "x.ftl");
+ } catch (TemplateConfigurationFactoryException e) {
+ assertThat(e.getMessage(), containsString("x.ftl"));
+ }
+ tcf.setNoMatchErrorDetails("Test details");
+ try {
+ assertNotApplicable(tcf, "x.ftl");
+ } catch (TemplateConfigurationFactoryException e) {
+ assertThat(e.getMessage(), containsString("Test details"));
+ }
+
+ tcf.setAllowNoMatch(true);
+
+ assertNotApplicable(tcf, "x.ftl");
+ assertApplicable(tcf, "x.ftlx", tc1);
+ assertApplicable(tcf, "a.ftl", tc2);
+ assertApplicable(tcf, "b.ftl", tc3);
+ assertApplicable(tcf, "a.ftlx", tc1);
+ assertApplicable(tcf, "b.ftlx", tc1);
+ assertApplicable(tcf, "ab.ftl", tc2);
+ assertApplicable(tcf, "ab.ftlx", tc1);
+
+ assertNotApplicable(new FirstMatchTemplateConfigurationFactory().allowNoMatch(true), "x.ftl");
+ }
+
+ @Test
+ public void testComplex() throws IOException, TemplateConfigurationFactoryException {
+ TemplateConfiguration tcA = newTemplateConfiguration(1);
+ TemplateConfiguration tcBSpec = newTemplateConfiguration(2);
+ TemplateConfiguration tcBCommon = newTemplateConfiguration(3);
+ TemplateConfiguration tcHH = newTemplateConfiguration(4);
+ TemplateConfiguration tcHtml = newTemplateConfiguration(5);
+ TemplateConfiguration tcXml = newTemplateConfiguration(6);
+ TemplateConfiguration tcNWS = newTemplateConfiguration(7);
+
+ TemplateConfigurationFactory tcf = new MergingTemplateConfigurationFactory(
+ new FirstMatchTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(new PathGlobMatcher("a/**"), tcA),
+ new ConditionalTemplateConfigurationFactory(new PathGlobMatcher("b/**"),
+ new MergingTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*"), tcBCommon),
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.s.*"), tcBSpec))))
+ .allowNoMatch(true),
+ new FirstMatchTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.hh"), tcHH),
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.*h"), tcHtml),
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.*x"), tcXml))
+ .allowNoMatch(true),
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.nws.*"), tcNWS));
+ tcf.setConfiguration(cfg);
+
+ assertNotApplicable(tcf, "x.ftl");
+ assertApplicable(tcf, "b/x.ftl", tcBCommon);
+ assertApplicable(tcf, "b/x.s.ftl", tcBCommon, tcBSpec);
+ assertApplicable(tcf, "b/x.s.ftlh", tcBCommon, tcBSpec, tcHtml);
+ assertApplicable(tcf, "b/x.s.nws.ftlx", tcBCommon, tcBSpec, tcXml, tcNWS);
+ assertApplicable(tcf, "a/x.s.nws.ftlx", tcA, tcXml, tcNWS);
+ assertApplicable(tcf, "a.hh", tcHH);
+ assertApplicable(tcf, "a.nws.hh", tcHH, tcNWS);
+ }
+
+ @Test
+ public void testSetConfiguration() {
+ TemplateConfiguration tc = new TemplateConfiguration();
+ ConditionalTemplateConfigurationFactory tcf = new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*"), tc);
+ assertNull(tcf.getConfiguration());
+ assertNull(tc.getParentConfiguration());
+
+ tcf.setConfiguration(cfg);
+ assertEquals(cfg, tcf.getConfiguration());
+ assertEquals(cfg, tc.getParentConfiguration());
+
+ // Ignored:
+ tcf.setConfiguration(cfg);
+
+ try {
+ tcf.setConfiguration(Configuration.getDefaultConfiguration());
+ fail();
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage(), containsString("TemplateConfigurationFactory"));
+ }
+ }
+
+ @SuppressWarnings("boxing")
+ private TemplateConfiguration newTemplateConfiguration(int id) {
+ TemplateConfiguration tc = new TemplateConfiguration();
+ tc.setCustomAttribute("id", id);
+ tc.setCustomAttribute("contains" + id, true);
+ return tc;
+ }
+
+ private void assertNotApplicable(TemplateConfigurationFactory tcf, String sourceName)
+ throws IOException, TemplateConfigurationFactoryException {
+ assertNull(tcf.get(sourceName, "dummy"));
+ }
+
+ private void assertApplicable(TemplateConfigurationFactory tcf, String sourceName, TemplateConfiguration... expectedTCs)
+ throws IOException, TemplateConfigurationFactoryException {
+ TemplateConfiguration mergedTC = tcf.get(sourceName, "dummy");
+ assertNotNull("TC should have its parents Configuration set", mergedTC.getParentConfiguration());
+ List<String> mergedTCAttNames = Arrays.asList(mergedTC.getCustomAttributeNames());
+
+ for (TemplateConfiguration expectedTC : expectedTCs) {
+ Integer tcId = (Integer) expectedTC.getCustomAttribute("id");
+ if (tcId == null) {
+ fail("TemplateConfiguration-s must be created with newTemplateConfiguration(id) in this test");
+ }
+ if (!mergedTCAttNames.contains("contains" + tcId)) {
+ fail("TemplateConfiguration with ID " + tcId + " is missing from the asserted value");
+ }
+ }
+
+ for (String attName: mergedTCAttNames) {
+ if (!containsCustomAttr(attName, expectedTCs)) {
+ fail("The asserted TemplateConfiguration contains an unexpected custom attribute: " + attName);
+ }
+ }
+
+ assertEquals(expectedTCs[expectedTCs.length - 1].getCustomAttribute("id"), mergedTC.getCustomAttribute("id"));
+ }
+
+ private boolean containsCustomAttr(String attName, TemplateConfiguration... expectedTCs) {
+ for (TemplateConfiguration expectedTC : expectedTCs) {
+ if (expectedTC.getCustomAttribute(attName) != null) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/src/test/java/freemarker/cache/TemplateConfigurerFactoryTest.java b/src/test/java/freemarker/cache/TemplateConfigurerFactoryTest.java
deleted file mode 100644
index 500d088..0000000
--- a/src/test/java/freemarker/cache/TemplateConfigurerFactoryTest.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package freemarker.cache;
-
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Test;
-
-import freemarker.core.TemplateConfigurer;
-import freemarker.template.Configuration;
-
-public class TemplateConfigurerFactoryTest {
-
- private Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
-
- @Test
- public void testCondition1() throws IOException, TemplateConfigurerFactoryException {
- TemplateConfigurer tc = newTemplateConfigurer(1);
-
- TemplateConfigurerFactory tcf = new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*.ftlx"), tc);
- tcf.setConfiguration(cfg);
-
- assertNotApplicable(tcf, "x.ftl");
- assertApplicable(tcf, "x.ftlx", tc);
- }
-
- @Test
- public void testCondition2() throws IOException, TemplateConfigurerFactoryException {
- TemplateConfigurer tc = newTemplateConfigurer(1);
-
- TemplateConfigurerFactory tcf = new ConditionalTemplateConfigurerFactory(
- new FileNameGlobMatcher("*.ftlx"),
- new ConditionalTemplateConfigurerFactory(
- new FileNameGlobMatcher("x.*"), tc));
- tcf.setConfiguration(cfg);
-
- assertNotApplicable(tcf, "x.ftl");
- assertNotApplicable(tcf, "y.ftlx");
- assertApplicable(tcf, "x.ftlx", tc);
- }
-
- @Test
- public void testMerging() throws IOException, TemplateConfigurerFactoryException {
- TemplateConfigurer tc1 = newTemplateConfigurer(1);
- TemplateConfigurer tc2 = newTemplateConfigurer(2);
- TemplateConfigurer tc3 = newTemplateConfigurer(3);
-
- TemplateConfigurerFactory tcf = new MergingTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*.ftlx"), tc1),
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*a*.*"), tc2),
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*b*.*"), tc3));
- tcf.setConfiguration(cfg);
-
- assertNotApplicable(tcf, "x.ftl");
- assertApplicable(tcf, "x.ftlx", tc1);
- assertApplicable(tcf, "a.ftl", tc2);
- assertApplicable(tcf, "b.ftl", tc3);
- assertApplicable(tcf, "a.ftlx", tc1, tc2);
- assertApplicable(tcf, "b.ftlx", tc1, tc3);
- assertApplicable(tcf, "ab.ftl", tc2, tc3);
- assertApplicable(tcf, "ab.ftlx", tc1, tc2, tc3);
-
- assertNotApplicable(new MergingTemplateConfigurerFactory(), "x.ftl");
- }
-
- @Test
- public void testFirstMatch() throws IOException, TemplateConfigurerFactoryException {
- TemplateConfigurer tc1 = newTemplateConfigurer(1);
- TemplateConfigurer tc2 = newTemplateConfigurer(2);
- TemplateConfigurer tc3 = newTemplateConfigurer(3);
-
- FirstMatchTemplateConfigurerFactory tcf = new FirstMatchTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*.ftlx"), tc1),
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*a*.*"), tc2),
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*b*.*"), tc3));
- tcf.setConfiguration(cfg);
-
- try {
- assertNotApplicable(tcf, "x.ftl");
- } catch (TemplateConfigurerFactoryException e) {
- assertThat(e.getMessage(), containsString("x.ftl"));
- }
- tcf.setNoMatchErrorDetails("Test details");
- try {
- assertNotApplicable(tcf, "x.ftl");
- } catch (TemplateConfigurerFactoryException e) {
- assertThat(e.getMessage(), containsString("Test details"));
- }
-
- tcf.setAllowNoMatch(true);
-
- assertNotApplicable(tcf, "x.ftl");
- assertApplicable(tcf, "x.ftlx", tc1);
- assertApplicable(tcf, "a.ftl", tc2);
- assertApplicable(tcf, "b.ftl", tc3);
- assertApplicable(tcf, "a.ftlx", tc1);
- assertApplicable(tcf, "b.ftlx", tc1);
- assertApplicable(tcf, "ab.ftl", tc2);
- assertApplicable(tcf, "ab.ftlx", tc1);
-
- assertNotApplicable(new FirstMatchTemplateConfigurerFactory().allowNoMatch(true), "x.ftl");
- }
-
- @Test
- public void testComplex() throws IOException, TemplateConfigurerFactoryException {
- TemplateConfigurer tcA = newTemplateConfigurer(1);
- TemplateConfigurer tcBSpec = newTemplateConfigurer(2);
- TemplateConfigurer tcBCommon = newTemplateConfigurer(3);
- TemplateConfigurer tcHH = newTemplateConfigurer(4);
- TemplateConfigurer tcHtml = newTemplateConfigurer(5);
- TemplateConfigurer tcXml = newTemplateConfigurer(6);
- TemplateConfigurer tcNWS = newTemplateConfigurer(7);
-
- TemplateConfigurerFactory tcf = new MergingTemplateConfigurerFactory(
- new FirstMatchTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(new PathGlobMatcher("a/**"), tcA),
- new ConditionalTemplateConfigurerFactory(new PathGlobMatcher("b/**"),
- new MergingTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*"), tcBCommon),
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*.s.*"), tcBSpec))))
- .allowNoMatch(true),
- new FirstMatchTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*.hh"), tcHH),
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*.*h"), tcHtml),
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*.*x"), tcXml))
- .allowNoMatch(true),
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*.nws.*"), tcNWS));
- tcf.setConfiguration(cfg);
-
- assertNotApplicable(tcf, "x.ftl");
- assertApplicable(tcf, "b/x.ftl", tcBCommon);
- assertApplicable(tcf, "b/x.s.ftl", tcBCommon, tcBSpec);
- assertApplicable(tcf, "b/x.s.ftlh", tcBCommon, tcBSpec, tcHtml);
- assertApplicable(tcf, "b/x.s.nws.ftlx", tcBCommon, tcBSpec, tcXml, tcNWS);
- assertApplicable(tcf, "a/x.s.nws.ftlx", tcA, tcXml, tcNWS);
- assertApplicable(tcf, "a.hh", tcHH);
- assertApplicable(tcf, "a.nws.hh", tcHH, tcNWS);
- }
-
- @Test
- public void testSetConfiguration() {
- TemplateConfigurer tc = new TemplateConfigurer();
- ConditionalTemplateConfigurerFactory tcf = new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*"), tc);
- assertNull(tcf.getConfiguration());
- assertNull(tc.getParentConfiguration());
-
- tcf.setConfiguration(cfg);
- assertEquals(cfg, tcf.getConfiguration());
- assertEquals(cfg, tc.getParentConfiguration());
-
- // Ignored:
- tcf.setConfiguration(cfg);
-
- try {
- tcf.setConfiguration(Configuration.getDefaultConfiguration());
- fail();
- } catch (IllegalStateException e) {
- assertThat(e.getMessage(), containsString("TemplateConfigurerFactory"));
- }
- }
-
- @SuppressWarnings("boxing")
- private TemplateConfigurer newTemplateConfigurer(int id) {
- TemplateConfigurer tc = new TemplateConfigurer();
- tc.setCustomAttribute("id", id);
- tc.setCustomAttribute("contains" + id, true);
- return tc;
- }
-
- private void assertNotApplicable(TemplateConfigurerFactory tcf, String sourceName)
- throws IOException, TemplateConfigurerFactoryException {
- assertNull(tcf.get(sourceName, "dummy"));
- }
-
- private void assertApplicable(TemplateConfigurerFactory tcf, String sourceName, TemplateConfigurer... expectedTCs)
- throws IOException, TemplateConfigurerFactoryException {
- TemplateConfigurer mergedTC = tcf.get(sourceName, "dummy");
- assertNotNull("TC should have its parents Configuration set", mergedTC.getParentConfiguration());
- List<String> mergedTCAttNames = Arrays.asList(mergedTC.getCustomAttributeNames());
-
- for (TemplateConfigurer expectedTC : expectedTCs) {
- Integer tcId = (Integer) expectedTC.getCustomAttribute("id");
- if (tcId == null) {
- fail("TemplateConfigurer-s must be created with newTemplateConfigurer(id) in this test");
- }
- if (!mergedTCAttNames.contains("contains" + tcId)) {
- fail("TemplateConfigurer with ID " + tcId + " is missing from the asserted value");
- }
- }
-
- for (String attName: mergedTCAttNames) {
- if (!containsCustomAttr(attName, expectedTCs)) {
- fail("The asserted TemplateConfigurer contains an unexpected custom attribute: " + attName);
- }
- }
-
- assertEquals(expectedTCs[expectedTCs.length - 1].getCustomAttribute("id"), mergedTC.getCustomAttribute("id"));
- }
-
- private boolean containsCustomAttr(String attName, TemplateConfigurer... expectedTCs) {
- for (TemplateConfigurer expectedTC : expectedTCs) {
- if (expectedTC.getCustomAttribute(attName) != null) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/src/test/java/freemarker/core/DateFormatTest.java b/src/test/java/freemarker/core/DateFormatTest.java
index 20b2cc9..792b9b2 100644
--- a/src/test/java/freemarker/core/DateFormatTest.java
+++ b/src/test/java/freemarker/core/DateFormatTest.java
@@ -34,7 +34,7 @@
import com.google.common.collect.ImmutableMap;
-import freemarker.cache.ConditionalTemplateConfigurerFactory;
+import freemarker.cache.ConditionalTemplateConfigurationFactory;
import freemarker.cache.FileNameGlobMatcher;
import freemarker.template.Configuration;
import freemarker.template.SimpleDate;
@@ -347,11 +347,11 @@
"m", new AliasTemplateDateFormatFactory("yyyy-MMM"),
"epoch", EpochMillisTemplateDateFormatFactory.INSTANCE));
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setCustomDateFormats(ImmutableMap.of(
"m", new AliasTemplateDateFormatFactory("yyyy-MMMM"),
"i", new AliasTemplateDateFormatFactory("@epoch")));
- cfg.setTemplateConfigurers(new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*2*"), tc));
+ cfg.setTemplateConfigurations(new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*2*"), tc));
addToDataModel("d", TM);
String commonFtl = "${d?string.@d} ${d?string.@m} "
diff --git a/src/test/java/freemarker/core/NumberFormatTest.java b/src/test/java/freemarker/core/NumberFormatTest.java
index 19d2cba..dee402f 100644
--- a/src/test/java/freemarker/core/NumberFormatTest.java
+++ b/src/test/java/freemarker/core/NumberFormatTest.java
@@ -33,7 +33,7 @@
import com.google.common.collect.ImmutableMap;
-import freemarker.cache.ConditionalTemplateConfigurerFactory;
+import freemarker.cache.ConditionalTemplateConfigurationFactory;
import freemarker.cache.FileNameGlobMatcher;
import freemarker.template.Configuration;
import freemarker.template.SimpleNumber;
@@ -251,11 +251,11 @@
"d", new AliasTemplateNumberFormatFactory("0.0#"),
"hex", HexTemplateNumberFormatFactory.INSTANCE));
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setCustomNumberFormats(ImmutableMap.of(
"d", new AliasTemplateNumberFormatFactory("0.#'d'"),
"i", new AliasTemplateNumberFormatFactory("@hex")));
- cfg.setTemplateConfigurers(new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*2*"), tc));
+ cfg.setTemplateConfigurations(new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*2*"), tc));
String commonFtl = "${1?string.@f} ${1?string.@d} "
+ "<#setting locale='fr_FR'>${1.5?string.@d} "
diff --git a/src/test/java/freemarker/core/OutputFormatTest.java b/src/test/java/freemarker/core/OutputFormatTest.java
index b596437..cc31920 100644
--- a/src/test/java/freemarker/core/OutputFormatTest.java
+++ b/src/test/java/freemarker/core/OutputFormatTest.java
@@ -29,7 +29,7 @@
import com.google.common.collect.ImmutableList;
-import freemarker.cache.ConditionalTemplateConfigurerFactory;
+import freemarker.cache.ConditionalTemplateConfigurationFactory;
import freemarker.cache.FileNameGlobMatcher;
import freemarker.cache.OrMatcher;
import freemarker.template.Configuration;
@@ -111,10 +111,10 @@
case 3:
cfgOutputFormat = UndefinedOutputFormat.INSTANCE;
cfg.unsetOutputFormat();
- TemplateConfigurer tcXml = new TemplateConfigurer();
+ TemplateConfiguration tcXml = new TemplateConfiguration();
tcXml.setOutputFormat(XMLOutputFormat.INSTANCE);
- cfg.setTemplateConfigurers(
- new ConditionalTemplateConfigurerFactory(
+ cfg.setTemplateConfigurations(
+ new ConditionalTemplateConfigurationFactory(
new OrMatcher(
new FileNameGlobMatcher("*.ftlh"),
new FileNameGlobMatcher("*.FTLH"),
@@ -130,7 +130,7 @@
ftlxOutputFormat = UndefinedOutputFormat.INSTANCE;
break;
case 5:
- cfg.setTemplateConfigurers(null);
+ cfg.setTemplateConfigurations(null);
cfgOutputFormat = UndefinedOutputFormat.INSTANCE;
ftlhOutputFormat = UndefinedOutputFormat.INSTANCE;
ftlxOutputFormat = UndefinedOutputFormat.INSTANCE;
@@ -182,25 +182,25 @@
addTemplate("t.ftl",
"${'{}'} ${'{}'?esc} ${'{}'?noEsc}");
- TemplateConfigurer tcHTML = new TemplateConfigurer();
+ TemplateConfiguration tcHTML = new TemplateConfiguration();
tcHTML.setOutputFormat(HTMLOutputFormat.INSTANCE);
- ConditionalTemplateConfigurerFactory tcfHTML = new ConditionalTemplateConfigurerFactory(
+ ConditionalTemplateConfigurationFactory tcfHTML = new ConditionalTemplateConfigurationFactory(
new FileNameGlobMatcher("t.*"), tcHTML);
- TemplateConfigurer tcNoAutoEsc = new TemplateConfigurer();
+ TemplateConfiguration tcNoAutoEsc = new TemplateConfiguration();
tcNoAutoEsc.setAutoEscapingPolicy(Configuration.DISABLE_AUTO_ESCAPING_POLICY);
- ConditionalTemplateConfigurerFactory tcfNoAutoEsc = new ConditionalTemplateConfigurerFactory(
+ ConditionalTemplateConfigurationFactory tcfNoAutoEsc = new ConditionalTemplateConfigurationFactory(
new FileNameGlobMatcher("t.*"), tcNoAutoEsc);
Configuration cfg = getConfiguration();
cfg.setOutputFormat(HTMLOutputFormat.INSTANCE);
assertOutputForNamed("t.ftlx", "' ' '"); // Can't override it
- cfg.setTemplateConfigurers(tcfHTML);
+ cfg.setTemplateConfigurations(tcfHTML);
assertOutputForNamed("t.ftlx", "' ' '"); // Can't override it
- cfg.setTemplateConfigurers(tcfNoAutoEsc);
+ cfg.setTemplateConfigurations(tcfNoAutoEsc);
assertOutputForNamed("t.ftlx", "' ' '"); // Can't override it
- cfg.setTemplateConfigurers(null);
+ cfg.setTemplateConfigurations(null);
cfg.unsetOutputFormat();
cfg.setIncompatibleImprovements(Configuration.VERSION_2_3_23); // Extensions has no effect
assertErrorContainsForNamed("t.ftlx", UndefinedOutputFormat.INSTANCE.getName());
@@ -208,21 +208,21 @@
assertOutputForNamed("t.ftlx", "' ' '");
cfg.setOutputFormat(XMLOutputFormat.INSTANCE);
assertOutputForNamed("t.ftlx", "' ' '");
- cfg.setTemplateConfigurers(tcfHTML);
+ cfg.setTemplateConfigurations(tcfHTML);
assertOutputForNamed("t.ftlx", "' ' '");
- cfg.setTemplateConfigurers(tcfNoAutoEsc);
+ cfg.setTemplateConfigurations(tcfNoAutoEsc);
assertOutputForNamed("t.ftlx", "' ' '");
cfg.setRecognizeStandardFileExtensions(true);
- cfg.setTemplateConfigurers(tcfHTML);
+ cfg.setTemplateConfigurations(tcfHTML);
assertOutputForNamed("t.ftlx", "' ' '"); // Can't override it
- cfg.setTemplateConfigurers(tcfNoAutoEsc);
+ cfg.setTemplateConfigurations(tcfNoAutoEsc);
assertOutputForNamed("t.ftlx", "' ' '"); // Can't override it
- cfg.setTemplateConfigurers(null);
+ cfg.setTemplateConfigurations(null);
cfg.unsetOutputFormat();
cfg.setIncompatibleImprovements(Configuration.VERSION_2_3_24);
- cfg.setTemplateConfigurers(tcfHTML);
+ cfg.setTemplateConfigurations(tcfHTML);
assertOutputForNamed("t.ftlx", "' ' '"); // Can't override it
cfg.setRecognizeStandardFileExtensions(false);
assertOutputForNamed("t.ftlx", "' ' '");
@@ -1005,10 +1005,10 @@
protected Configuration createConfiguration() throws TemplateModelException {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_24);
- TemplateConfigurer xmlTC = new TemplateConfigurer();
+ TemplateConfiguration xmlTC = new TemplateConfiguration();
xmlTC.setOutputFormat(XMLOutputFormat.INSTANCE);
- cfg.setTemplateConfigurers(
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*.xml"), xmlTC));
+ cfg.setTemplateConfigurations(
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.xml"), xmlTC));
cfg.setSharedVariable("rtfPlain", RTFOutputFormat.INSTANCE.fromPlainTextByEscaping("\\par a & b"));
cfg.setSharedVariable("rtfMarkup", RTFOutputFormat.INSTANCE.fromMarkup("\\par c"));
diff --git a/src/test/java/freemarker/core/TemplateConfigurerTest.java b/src/test/java/freemarker/core/TemplateConfigurationTest.java
similarity index 89%
rename from src/test/java/freemarker/core/TemplateConfigurerTest.java
rename to src/test/java/freemarker/core/TemplateConfigurationTest.java
index 382bdf0..99b1b7a 100644
--- a/src/test/java/freemarker/core/TemplateConfigurerTest.java
+++ b/src/test/java/freemarker/core/TemplateConfigurationTest.java
@@ -54,7 +54,7 @@
import freemarker.template.utility.NullArgumentException;
@SuppressWarnings("boxing")
-public class TemplateConfigurerTest {
+public class TemplateConfigurationTest {
private final class DummyArithmeticEngine extends ArithmeticEngine {
@@ -191,12 +191,12 @@
return isSetMethodName;
}
- public static List<PropertyDescriptor> getTemplateConfigurerSettingPropDescs(
+ public static List<PropertyDescriptor> getTemplateConfigurationSettingPropDescs(
boolean includeCompilerSettings, boolean includeSpecialSettings)
throws IntrospectionException {
List<PropertyDescriptor> settingPropDescs = new ArrayList<PropertyDescriptor>();
- BeanInfo beanInfo = Introspector.getBeanInfo(TemplateConfigurer.class);
+ BeanInfo beanInfo = Introspector.getBeanInfo(TemplateConfiguration.class);
for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
String name = pd.getName();
if (pd.getWriteMethod() != null && !IGNORED_PROP_NAMES.contains(name)
@@ -282,10 +282,10 @@
@Test
public void testMergeBasicFunctionality() throws Exception {
- for (PropertyDescriptor propDesc1 : getTemplateConfigurerSettingPropDescs(true, true)) {
- for (PropertyDescriptor propDesc2 : getTemplateConfigurerSettingPropDescs(true, true)) {
- TemplateConfigurer tc1 = new TemplateConfigurer();
- TemplateConfigurer tc2 = new TemplateConfigurer();
+ for (PropertyDescriptor propDesc1 : getTemplateConfigurationSettingPropDescs(true, true)) {
+ for (PropertyDescriptor propDesc2 : getTemplateConfigurationSettingPropDescs(true, true)) {
+ TemplateConfiguration tc1 = new TemplateConfiguration();
+ TemplateConfiguration tc2 = new TemplateConfiguration();
Object value1 = SETTING_ASSIGNMENTS.get(propDesc1.getName());
propDesc1.getWriteMethod().invoke(tc1, value1);
@@ -304,7 +304,7 @@
@Test
public void testMergeMapSettings() throws Exception {
- TemplateConfigurer tc1 = new TemplateConfigurer();
+ TemplateConfiguration tc1 = new TemplateConfiguration();
tc1.setCustomDateFormats(ImmutableMap.of(
"epoch", EpochMillisTemplateDateFormatFactory.INSTANCE,
"x", LocAndTZSensitiveTemplateDateFormatFactory.INSTANCE));
@@ -312,7 +312,7 @@
"hex", HexTemplateNumberFormatFactory.INSTANCE,
"x", LocaleSensitiveTemplateNumberFormatFactory.INSTANCE));
- TemplateConfigurer tc2 = new TemplateConfigurer();
+ TemplateConfiguration tc2 = new TemplateConfiguration();
tc2.setCustomDateFormats(ImmutableMap.of(
"loc", LocAndTZSensitiveTemplateDateFormatFactory.INSTANCE,
"x", EpochMillisDivTemplateDateFormatFactory.INSTANCE));
@@ -333,12 +333,12 @@
assertEquals(BaseNTemplateNumberFormatFactory.INSTANCE, mergedCustomNumberFormats.get("x"));
// Empty map merging optimization:
- tc1.merge(new TemplateConfigurer());
+ tc1.merge(new TemplateConfiguration());
assertSame(mergedCustomDateFormats, tc1.getCustomDateFormats());
assertSame(mergedCustomNumberFormats, tc1.getCustomNumberFormats());
// Empty map merging optimization:
- TemplateConfigurer tc3 = new TemplateConfigurer();
+ TemplateConfiguration tc3 = new TemplateConfiguration();
tc3.merge(tc1);
assertSame(mergedCustomDateFormats, tc3.getCustomDateFormats());
assertSame(mergedCustomNumberFormats, tc3.getCustomNumberFormats());
@@ -346,16 +346,16 @@
@Test
public void testMergePriority() throws Exception {
- TemplateConfigurer tc1 = new TemplateConfigurer();
+ TemplateConfiguration tc1 = new TemplateConfiguration();
tc1.setDateFormat("1");
tc1.setTimeFormat("1");
tc1.setDateTimeFormat("1");
- TemplateConfigurer tc2 = new TemplateConfigurer();
+ TemplateConfiguration tc2 = new TemplateConfiguration();
tc2.setDateFormat("2");
tc2.setTimeFormat("2");
- TemplateConfigurer tc3 = new TemplateConfigurer();
+ TemplateConfiguration tc3 = new TemplateConfiguration();
tc3.setDateFormat("3");
tc1.merge(tc2);
@@ -368,7 +368,7 @@
@Test
public void testMergeCustomAttributes() throws Exception {
- TemplateConfigurer tc1 = new TemplateConfigurer();
+ TemplateConfiguration tc1 = new TemplateConfiguration();
tc1.setCustomAttribute("k1", "v1");
tc1.setCustomAttribute("k2", "v1");
tc1.setCustomAttribute("k3", "v1");
@@ -376,13 +376,13 @@
CA2.set("V1", tc1);
CA3.set("V1", tc1);
- TemplateConfigurer tc2 = new TemplateConfigurer();
+ TemplateConfiguration tc2 = new TemplateConfiguration();
tc2.setCustomAttribute("k1", "v2");
tc2.setCustomAttribute("k2", "v2");
CA1.set("V2", tc2);
CA2.set("V2", tc2);
- TemplateConfigurer tc3 = new TemplateConfigurer();
+ TemplateConfiguration tc3 = new TemplateConfiguration();
tc3.setCustomAttribute("k1", "v3");
CA1.set("V3", tc2);
@@ -399,7 +399,7 @@
@Test
public void testMergeNullCustomAttributes() throws Exception {
- TemplateConfigurer tc1 = new TemplateConfigurer();
+ TemplateConfiguration tc1 = new TemplateConfiguration();
tc1.setCustomAttribute("k1", "v1");
tc1.setCustomAttribute("k2", "v1");
tc1.setCustomAttribute(null, "v1");
@@ -414,13 +414,13 @@
assertEquals("V1", CA2.get(tc1));
assertNull(CA3.get(tc1));
- TemplateConfigurer tc2 = new TemplateConfigurer();
+ TemplateConfiguration tc2 = new TemplateConfiguration();
tc2.setCustomAttribute("k1", "v2");
tc2.setCustomAttribute("k2", null);
CA1.set("V2", tc2);
CA2.set(null, tc2);
- TemplateConfigurer tc3 = new TemplateConfigurer();
+ TemplateConfiguration tc3 = new TemplateConfiguration();
tc3.setCustomAttribute("k1", null);
CA1.set(null, tc2);
@@ -434,7 +434,7 @@
assertNull(CA2.get(tc1));
assertNull(CA3.get(tc1));
- TemplateConfigurer tc4 = new TemplateConfigurer();
+ TemplateConfiguration tc4 = new TemplateConfiguration();
tc4.setCustomAttribute("k1", "v4");
CA1.set("V4", tc4);
@@ -450,8 +450,8 @@
@Test
public void testConfigureNonParserConfig() throws Exception {
- for (PropertyDescriptor pd : getTemplateConfigurerSettingPropDescs(false, true)) {
- TemplateConfigurer tc = new TemplateConfigurer();
+ for (PropertyDescriptor pd : getTemplateConfigurationSettingPropDescs(false, true)) {
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(DEFAULT_CFG);
Object newValue = SETTING_ASSIGNMENTS.get(pd.getName());
@@ -461,7 +461,7 @@
Method tReaderMethod = t.getClass().getMethod(pd.getReadMethod().getName());
assertNotEquals("For \"" + pd.getName() + "\"", newValue, tReaderMethod.invoke(t));
- tc.configure(t);
+ tc.apply(t);
assertEquals("For \"" + pd.getName() + "\"", newValue, tReaderMethod.invoke(t));
}
}
@@ -473,7 +473,7 @@
cfg.setCustomAttribute("k2", "c");
cfg.setCustomAttribute("k3", "c");
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setCustomAttribute("k2", "tc");
tc.setCustomAttribute("k3", null);
tc.setCustomAttribute("k4", "tc");
@@ -492,7 +492,7 @@
CA4.set("t", t);
tc.setParentConfiguration(cfg);
- tc.configure(t);
+ tc.apply(t);
assertEquals("c", t.getCustomAttribute("k1"));
assertEquals("tc", t.getCustomAttribute("k2"));
@@ -512,7 +512,7 @@
Set<String> testedProps = new HashSet<String>();
{
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(DEFAULT_CFG);
tc.setTagSyntax(Configuration.SQUARE_BRACKET_TAG_SYNTAX);
assertOutputWithoutAndWithTC(tc, "[#if true]y[/#if]", "[#if true]y[/#if]", "y");
@@ -520,7 +520,7 @@
}
{
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(DEFAULT_CFG);
tc.setNamingConvention(Configuration.CAMEL_CASE_NAMING_CONVENTION);
assertOutputWithoutAndWithTC(tc, "<#if true>y<#elseif false>n</#if>", "y", null);
@@ -528,7 +528,7 @@
}
{
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(DEFAULT_CFG);
tc.setWhitespaceStripping(false);
assertOutputWithoutAndWithTC(tc, "<#if true>\nx\n</#if>\n", "x\n", "\nx\n\n");
@@ -536,7 +536,7 @@
}
{
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(DEFAULT_CFG);
tc.setArithmeticEngine(new DummyArithmeticEngine());
assertOutputWithoutAndWithTC(tc, "${1} ${1+1}", "1 2", "11 22");
@@ -544,7 +544,7 @@
}
{
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(DEFAULT_CFG);
tc.setOutputFormat(XMLOutputFormat.INSTANCE);
assertOutputWithoutAndWithTC(tc, "${.outputFormat} ${\"a'b\"}",
@@ -554,7 +554,7 @@
}
{
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(DEFAULT_CFG);
tc.setOutputFormat(XMLOutputFormat.INSTANCE);
tc.setAutoEscapingPolicy(Configuration.DISABLE_AUTO_ESCAPING_POLICY);
@@ -563,7 +563,7 @@
}
{
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(DEFAULT_CFG);
tc.setStrictSyntaxMode(false);
assertOutputWithoutAndWithTC(tc, "<if true>y</if>", "<if true>y</if>", "y");
@@ -571,7 +571,7 @@
}
{
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(new Configuration(new Version(2, 3, 0)));
assertOutputWithoutAndWithTC(tc, "<#foo>", null, "<#foo>");
testedProps.add(Configuration.INCOMPATIBLE_IMPROVEMENTS_KEY_CAMEL_CASE);
@@ -579,7 +579,7 @@
{
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(new Configuration(new Version(2, 3, 0)));
tc.setRecognizeStandardFileExtensions(true);
assertOutputWithoutAndWithTC(tc, "${.outputFormat}",
@@ -593,8 +593,8 @@
@Test
public void testConfigureParserTooLowIcI() throws Exception {
Configuration cfgWithTooLowIcI = new Configuration(Configuration.VERSION_2_3_21);
- for (PropertyDescriptor propDesc : getTemplateConfigurerSettingPropDescs(true, false)) {
- TemplateConfigurer tc = new TemplateConfigurer();
+ for (PropertyDescriptor propDesc : getTemplateConfigurationSettingPropDescs(true, false)) {
+ TemplateConfiguration tc = new TemplateConfiguration();
String propName = propDesc.getName();
Object value = SETTING_ASSIGNMENTS.get(propName);
@@ -626,7 +626,7 @@
@Test
public void testArithmeticEngine() throws TemplateException, IOException {
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(DEFAULT_CFG);
tc.setArithmeticEngine(new DummyArithmeticEngine());
assertOutputWithoutAndWithTC(tc,
@@ -640,7 +640,7 @@
@Test
public void testStringInterpolate() throws TemplateException, IOException {
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(DEFAULT_CFG);
tc.setArithmeticEngine(new DummyArithmeticEngine());
assertOutputWithoutAndWithTC(tc,
@@ -654,7 +654,7 @@
@Test
public void testInterpret() throws TemplateException, IOException {
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(DEFAULT_CFG);
tc.setArithmeticEngine(new DummyArithmeticEngine());
assertOutputWithoutAndWithTC(tc,
@@ -670,7 +670,7 @@
@Test
public void testEval() throws TemplateException, IOException {
{
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(DEFAULT_CFG);
tc.setArithmeticEngine(new DummyArithmeticEngine());
assertOutputWithoutAndWithTC(tc,
@@ -682,7 +682,7 @@
}
{
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(DEFAULT_CFG);
String outputEncoding = "ISO-8859-2";
tc.setOutputEncoding(outputEncoding);
@@ -708,11 +708,11 @@
@Test
public void testSetParentConfiguration() throws IOException {
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
Template t = new Template(null, "", DEFAULT_CFG);
try {
- tc.configure(t);
+ tc.apply(t);
fail();
} catch (IllegalStateException e) {
assertThat(e.getMessage(), containsString("Configuration"));
@@ -744,23 +744,23 @@
tc.setParent(DEFAULT_CFG);
- tc.configure(t);
+ tc.apply(t);
}
- private void assertOutputWithoutAndWithTC(TemplateConfigurer tc, String ftl, String expectedDefaultOutput,
+ private void assertOutputWithoutAndWithTC(TemplateConfiguration tc, String ftl, String expectedDefaultOutput,
String expectedConfiguredOutput) throws TemplateException, IOException {
assertOutput(tc, ftl, expectedConfiguredOutput);
assertOutput(null, ftl, expectedDefaultOutput);
}
- private void assertOutput(TemplateConfigurer tc, String ftl, String expectedConfiguredOutput)
+ private void assertOutput(TemplateConfiguration tc, String ftl, String expectedConfiguredOutput)
throws TemplateException, IOException {
StringWriter sw = new StringWriter();
try {
Configuration cfg = tc != null ? tc.getParentConfiguration() : DEFAULT_CFG;
Template t = new Template("adhoc.ftlh", null, new StringReader(ftl), cfg, tc, null);
if (tc != null) {
- tc.configure(t);
+ tc.apply(t);
}
t.process(null, sw);
if (expectedConfiguredOutput == null) {
@@ -782,22 +782,22 @@
@Test
public void testIsSet() throws Exception {
- for (PropertyDescriptor pd : getTemplateConfigurerSettingPropDescs(true, true)) {
- TemplateConfigurer tc = new TemplateConfigurer();
+ for (PropertyDescriptor pd : getTemplateConfigurationSettingPropDescs(true, true)) {
+ TemplateConfiguration tc = new TemplateConfiguration();
checkAllIsSetFalseExcept(tc, null);
pd.getWriteMethod().invoke(tc, SETTING_ASSIGNMENTS.get(pd.getName()));
checkAllIsSetFalseExcept(tc, pd.getName());
}
}
- private void checkAllIsSetFalseExcept(TemplateConfigurer tc, String setSetting)
+ private void checkAllIsSetFalseExcept(TemplateConfiguration tc, String setSetting)
throws SecurityException, IntrospectionException,
IllegalArgumentException, IllegalAccessException, InvocationTargetException {
- for (PropertyDescriptor pd : getTemplateConfigurerSettingPropDescs(true, true)) {
+ for (PropertyDescriptor pd : getTemplateConfigurationSettingPropDescs(true, true)) {
String isSetMethodName = getIsSetMethodName(pd.getReadMethod().getName());
Method isSetMethod;
try {
- isSetMethod = TemplateConfigurer.class.getMethod(isSetMethodName);
+ isSetMethod = TemplateConfiguration.class.getMethod(isSetMethodName);
} catch (NoSuchMethodException e) {
fail("Missing " + isSetMethodName + " method for \"" + pd.getName() + "\".");
return;
@@ -815,7 +815,7 @@
*/
@Test
public void checkTestAssignments() throws Exception {
- for (PropertyDescriptor pd : getTemplateConfigurerSettingPropDescs(true, true)) {
+ for (PropertyDescriptor pd : getTemplateConfigurationSettingPropDescs(true, true)) {
String propName = pd.getName();
if (!SETTING_ASSIGNMENTS.containsKey(propName)) {
fail("Test case doesn't cover all settings in SETTING_ASSIGNMENTS. Missing: " + propName);
@@ -832,7 +832,7 @@
assertNotEquals("SETTING_ASSIGNMENTS must contain a non-default value for " + propName,
assignedValue, defaultSettingValue);
- TemplateConfigurer tc = new TemplateConfigurer();
+ TemplateConfiguration tc = new TemplateConfiguration();
try {
pd.getWriteMethod().invoke(tc, assignedValue);
} catch (Exception e) {
diff --git a/src/test/java/freemarker/core/TemplateConfigurerWithTemplateCacheTest.java b/src/test/java/freemarker/core/TemplateConfigurationWithTemplateCacheTest.java
similarity index 82%
rename from src/test/java/freemarker/core/TemplateConfigurerWithTemplateCacheTest.java
rename to src/test/java/freemarker/core/TemplateConfigurationWithTemplateCacheTest.java
index 53e8193..611c2e3 100644
--- a/src/test/java/freemarker/core/TemplateConfigurerWithTemplateCacheTest.java
+++ b/src/test/java/freemarker/core/TemplateConfigurationWithTemplateCacheTest.java
@@ -28,16 +28,16 @@
import org.junit.Test;
import freemarker.cache.ByteArrayTemplateLoader;
-import freemarker.cache.ConditionalTemplateConfigurerFactory;
+import freemarker.cache.ConditionalTemplateConfigurationFactory;
import freemarker.cache.FileNameGlobMatcher;
-import freemarker.cache.FirstMatchTemplateConfigurerFactory;
-import freemarker.cache.MergingTemplateConfigurerFactory;
+import freemarker.cache.FirstMatchTemplateConfigurationFactory;
+import freemarker.cache.MergingTemplateConfigurationFactory;
import freemarker.cache.StringTemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
-public class TemplateConfigurerWithTemplateCacheTest {
+public class TemplateConfigurationWithTemplateCacheTest {
private static final String TEXT_WITH_ACCENTS = "pr\u00F3ba";
@@ -123,9 +123,9 @@
("<#ftl locale='fr_FR'>${.locale}"));
cfg.setTemplateLoader(tl);
- TemplateConfigurer tcDe = new TemplateConfigurer();
+ TemplateConfiguration tcDe = new TemplateConfiguration();
tcDe.setLocale(Locale.GERMANY);
- cfg.setTemplateConfigurers(new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*(de)*"), tcDe));
+ cfg.setTemplateConfigurations(new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*(de)*"), tcDe));
{
Template t = cfg.getTemplate("(de).ftl");
@@ -154,15 +154,15 @@
Configuration cfg = createCommonEncodingTesterConfig();
cfg.setIncompatibleImprovements(Configuration.VERSION_2_3_22);
- TemplateConfigurer tcDE = new TemplateConfigurer();
+ TemplateConfiguration tcDE = new TemplateConfiguration();
tcDE.setLocale(Locale.GERMANY);
- TemplateConfigurer tcYN = new TemplateConfigurer();
+ TemplateConfiguration tcYN = new TemplateConfiguration();
tcYN.setBooleanFormat("Y,N");
- cfg.setTemplateConfigurers(
- new MergingTemplateConfigurerFactory(
- cfg.getTemplateConfigurers(),
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("utf16.ftl"), tcDE),
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("utf16.ftl"), tcYN)
+ cfg.setTemplateConfigurations(
+ new MergingTemplateConfigurationFactory(
+ cfg.getTemplateConfigurations(),
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("utf16.ftl"), tcDE),
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("utf16.ftl"), tcYN)
)
);
@@ -197,17 +197,17 @@
Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
cfg.setLocale(Locale.US);
- TemplateConfigurer tcFR = new TemplateConfigurer();
+ TemplateConfiguration tcFR = new TemplateConfiguration();
tcFR.setLocale(Locale.FRANCE);
- TemplateConfigurer tcYN = new TemplateConfigurer();
+ TemplateConfiguration tcYN = new TemplateConfiguration();
tcYN.setBooleanFormat("Y,N");
- TemplateConfigurer tc00 = new TemplateConfigurer();
+ TemplateConfiguration tc00 = new TemplateConfiguration();
tc00.setNumberFormat("0.00");
- cfg.setTemplateConfigurers(
- new MergingTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*(fr)*"), tcFR),
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*(yn)*"), tcYN),
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*(00)*"), tc00)
+ cfg.setTemplateConfigurations(
+ new MergingTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*(fr)*"), tcFR),
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*(yn)*"), tcYN),
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*(00)*"), tc00)
)
);
@@ -229,21 +229,21 @@
public void testCustomAttributes() throws Exception {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
- TemplateConfigurer tc1 = new TemplateConfigurer();
+ TemplateConfiguration tc1 = new TemplateConfiguration();
tc1.setCustomAttribute("a1", "a1tc1");
tc1.setCustomAttribute("a2", "a2tc1");
tc1.setCustomAttribute("a3", "a3tc1");
CUST_ATT_1.set("ca1tc1", tc1);
CUST_ATT_2.set("ca2tc1", tc1);
- TemplateConfigurer tc2 = new TemplateConfigurer();
+ TemplateConfiguration tc2 = new TemplateConfiguration();
tc2.setCustomAttribute("a1", "a1tc2");
CUST_ATT_1.set("ca1tc2", tc2);
- cfg.setTemplateConfigurers(
- new MergingTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*(tc1)*"), tc1),
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*(tc2)*"), tc2)
+ cfg.setTemplateConfigurations(
+ new MergingTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*(tc1)*"), tc1),
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*(tc2)*"), tc2)
)
);
@@ -310,14 +310,14 @@
("<#ftl encoding='iso-8859-2'>" + TEXT_WITH_ACCENTS).getBytes("iso-8859-2"));
cfg.setTemplateLoader(tl);
- TemplateConfigurer tcUtf8 = new TemplateConfigurer();
+ TemplateConfiguration tcUtf8 = new TemplateConfiguration();
tcUtf8.setEncoding("utf-8");
- TemplateConfigurer tcUtf16 = new TemplateConfigurer();
+ TemplateConfiguration tcUtf16 = new TemplateConfiguration();
tcUtf16.setEncoding("utf-16");
- cfg.setTemplateConfigurers(
- new FirstMatchTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*utf8*"), tcUtf8),
- new ConditionalTemplateConfigurerFactory(new FileNameGlobMatcher("*utf16*"), tcUtf16)
+ cfg.setTemplateConfigurations(
+ new FirstMatchTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*utf8*"), tcUtf8),
+ new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*utf16*"), tcUtf16)
).allowNoMatch(true));
return cfg;
}
diff --git a/src/test/java/freemarker/ext/servlet/FreemarkerServletTest.java b/src/test/java/freemarker/ext/servlet/FreemarkerServletTest.java
index f008280..0e9f539 100644
--- a/src/test/java/freemarker/ext/servlet/FreemarkerServletTest.java
+++ b/src/test/java/freemarker/ext/servlet/FreemarkerServletTest.java
@@ -38,13 +38,13 @@
import org.springframework.mock.web.MockServletConfig;
import org.springframework.mock.web.MockServletContext;
-import freemarker.cache.ConditionalTemplateConfigurerFactory;
+import freemarker.cache.ConditionalTemplateConfigurationFactory;
import freemarker.cache.FileNameGlobMatcher;
-import freemarker.cache.FirstMatchTemplateConfigurerFactory;
+import freemarker.cache.FirstMatchTemplateConfigurationFactory;
import freemarker.cache.StringTemplateLoader;
import freemarker.cache.TemplateLoader;
import freemarker.core.Environment;
-import freemarker.core.TemplateConfigurer;
+import freemarker.core.TemplateConfiguration;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
@@ -491,7 +491,7 @@
@Override
protected Configuration createConfiguration() {
Configuration cfg = super.createConfiguration();
- // Needed for the TemplateConfigurer that sets outputEncoding:
+ // Needed for the TemplateConfiguration that sets outputEncoding:
cfg.setIncompatibleImprovements(Configuration.VERSION_2_3_22);
// Set a test runner environment independent default locale:
@@ -499,17 +499,17 @@
cfg.setDefaultEncoding(CFG_DEFAULT_ENCODING);
{
- TemplateConfigurer outUtf8TC = new TemplateConfigurer();
+ TemplateConfiguration outUtf8TC = new TemplateConfiguration();
outUtf8TC.setOutputEncoding("UTF-8");
- TemplateConfigurer srcUtf8TC = new TemplateConfigurer();
+ TemplateConfiguration srcUtf8TC = new TemplateConfiguration();
srcUtf8TC.setEncoding("UTF-8");
- cfg.setTemplateConfigurers(
- new FirstMatchTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(
+ cfg.setTemplateConfigurations(
+ new FirstMatchTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(
new FileNameGlobMatcher(FOO_SRC_UTF8_FTL), srcUtf8TC),
- new ConditionalTemplateConfigurerFactory(
+ new ConditionalTemplateConfigurationFactory(
new FileNameGlobMatcher(FOO_OUT_UTF8_FTL), outUtf8TC)
)
.allowNoMatch(true)
diff --git a/src/test/java/freemarker/manual/ConfigureOutputFormatExamples.java b/src/test/java/freemarker/manual/ConfigureOutputFormatExamples.java
index 5f5fb9f..8aa6ff4 100644
--- a/src/test/java/freemarker/manual/ConfigureOutputFormatExamples.java
+++ b/src/test/java/freemarker/manual/ConfigureOutputFormatExamples.java
@@ -22,14 +22,14 @@
import org.junit.Test;
-import freemarker.cache.ConditionalTemplateConfigurerFactory;
+import freemarker.cache.ConditionalTemplateConfigurationFactory;
import freemarker.cache.FileExtensionMatcher;
-import freemarker.cache.FirstMatchTemplateConfigurerFactory;
+import freemarker.cache.FirstMatchTemplateConfigurationFactory;
import freemarker.cache.OrMatcher;
import freemarker.cache.PathGlobMatcher;
import freemarker.core.HTMLOutputFormat;
import freemarker.core.RTFOutputFormat;
-import freemarker.core.TemplateConfigurer;
+import freemarker.core.TemplateConfiguration;
import freemarker.core.XMLOutputFormat;
import freemarker.template.Configuration;
@@ -47,11 +47,11 @@
// Example 2/a:
{
- TemplateConfigurer tcHTML = new TemplateConfigurer();
+ TemplateConfiguration tcHTML = new TemplateConfiguration();
tcHTML.setOutputFormat(HTMLOutputFormat.INSTANCE);
- cfg.setTemplateConfigurers(
- new ConditionalTemplateConfigurerFactory(
+ cfg.setTemplateConfigurations(
+ new ConditionalTemplateConfigurationFactory(
new PathGlobMatcher("mail/**"),
tcHTML));
@@ -60,7 +60,7 @@
// Example 2/b:
{
- cfg.setTemplateConfigurers(null); // Just to be sure...
+ cfg.setTemplateConfigurations(null); // Just to be sure...
cfg.setSettings(loadPropertiesFile("ConfigureOutputFormatExamples1.properties"));
@@ -69,26 +69,26 @@
// Example 3/a:
{
- TemplateConfigurer tcHTML = new TemplateConfigurer();
+ TemplateConfiguration tcHTML = new TemplateConfiguration();
tcHTML.setOutputFormat(HTMLOutputFormat.INSTANCE);
- TemplateConfigurer tcXML = new TemplateConfigurer();
+ TemplateConfiguration tcXML = new TemplateConfiguration();
tcXML.setOutputFormat(XMLOutputFormat.INSTANCE);
- TemplateConfigurer tcRTF = new TemplateConfigurer();
+ TemplateConfiguration tcRTF = new TemplateConfiguration();
tcRTF.setOutputFormat(RTFOutputFormat.INSTANCE);
- cfg.setTemplateConfigurers(
- new FirstMatchTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(
+ cfg.setTemplateConfigurations(
+ new FirstMatchTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(
new FileExtensionMatcher("xml"),
tcXML),
- new ConditionalTemplateConfigurerFactory(
+ new ConditionalTemplateConfigurationFactory(
new OrMatcher(
new FileExtensionMatcher("html"),
new FileExtensionMatcher("htm")),
tcHTML),
- new ConditionalTemplateConfigurerFactory(
+ new ConditionalTemplateConfigurationFactory(
new FileExtensionMatcher("rtf"),
tcRTF)
).allowNoMatch(true)
@@ -102,7 +102,7 @@
// Example 3/b:
{
- cfg.setTemplateConfigurers(null); // Just to be sure...
+ cfg.setTemplateConfigurations(null); // Just to be sure...
cfg.setSettings(loadPropertiesFile("ConfigureOutputFormatExamples2.properties"));
diff --git a/src/test/java/freemarker/manual/TemplateConfigurerExamples.java b/src/test/java/freemarker/manual/TemplateConfigurationExamples.java
similarity index 76%
rename from src/test/java/freemarker/manual/TemplateConfigurerExamples.java
rename to src/test/java/freemarker/manual/TemplateConfigurationExamples.java
index 8e3844d..97e16f9 100644
--- a/src/test/java/freemarker/manual/TemplateConfigurerExamples.java
+++ b/src/test/java/freemarker/manual/TemplateConfigurationExamples.java
@@ -24,23 +24,23 @@
import org.junit.Test;
-import freemarker.cache.ConditionalTemplateConfigurerFactory;
+import freemarker.cache.ConditionalTemplateConfigurationFactory;
import freemarker.cache.FileExtensionMatcher;
import freemarker.cache.FileNameGlobMatcher;
-import freemarker.cache.FirstMatchTemplateConfigurerFactory;
-import freemarker.cache.MergingTemplateConfigurerFactory;
+import freemarker.cache.FirstMatchTemplateConfigurationFactory;
+import freemarker.cache.MergingTemplateConfigurationFactory;
import freemarker.cache.OrMatcher;
import freemarker.cache.PathGlobMatcher;
import freemarker.core.HTMLOutputFormat;
import freemarker.core.PlainTextOutputFormat;
-import freemarker.core.TemplateConfigurer;
+import freemarker.core.TemplateConfiguration;
import freemarker.core.UndefinedOutputFormat;
import freemarker.core.XMLOutputFormat;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.utility.DateUtil;
-public class TemplateConfigurerExamples extends ExamplesTest {
+public class TemplateConfigurationExamples extends ExamplesTest {
@Test
public void example1() throws Exception {
@@ -48,12 +48,12 @@
addTemplate("t.xml", "");
- TemplateConfigurer tcUTF8XML = new TemplateConfigurer();
+ TemplateConfiguration tcUTF8XML = new TemplateConfiguration();
tcUTF8XML.setEncoding("utf-8");
tcUTF8XML.setOutputFormat(XMLOutputFormat.INSTANCE);
{
- cfg.setTemplateConfigurers(new ConditionalTemplateConfigurerFactory(
+ cfg.setTemplateConfigurations(new ConditionalTemplateConfigurationFactory(
new FileExtensionMatcher("xml"), tcUTF8XML));
Template t = cfg.getTemplate("t.xml");
@@ -62,8 +62,8 @@
}
{
- cfg.setTemplateConfigurers(null);
- cfg.setSettings(loadPropertiesFile("TemplateConfigurerExamples1.properties"));
+ cfg.setTemplateConfigurations(null);
+ cfg.setSettings(loadPropertiesFile("TemplateConfigurationExamples1.properties"));
Template t = cfg.getTemplate("t.xml");
assertEquals("utf-8", t.getEncoding());
@@ -79,20 +79,20 @@
addTemplate("mail/t.subject.ftl", "");
addTemplate("mail/t.body.ftl", "");
- TemplateConfigurer tcSubject = new TemplateConfigurer();
+ TemplateConfiguration tcSubject = new TemplateConfiguration();
tcSubject.setOutputFormat(PlainTextOutputFormat.INSTANCE);
- TemplateConfigurer tcBody = new TemplateConfigurer();
+ TemplateConfiguration tcBody = new TemplateConfiguration();
tcBody.setOutputFormat(HTMLOutputFormat.INSTANCE);
- cfg.setTemplateConfigurers(
- new ConditionalTemplateConfigurerFactory(
+ cfg.setTemplateConfigurations(
+ new ConditionalTemplateConfigurationFactory(
new PathGlobMatcher("mail/**"),
- new FirstMatchTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(
+ new FirstMatchTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(
new FileNameGlobMatcher("*.subject.*"),
tcSubject),
- new ConditionalTemplateConfigurerFactory(
+ new ConditionalTemplateConfigurationFactory(
new FileNameGlobMatcher("*.body.*"),
tcBody)
)
@@ -105,8 +105,8 @@
// From properties:
- cfg.setTemplateConfigurers(null);
- cfg.setSettings(loadPropertiesFile("TemplateConfigurerExamples2.properties"));
+ cfg.setTemplateConfigurations(null);
+ cfg.setSettings(loadPropertiesFile("TemplateConfigurationExamples2.properties"));
assertEquals(UndefinedOutputFormat.INSTANCE, cfg.getTemplate("t.subject.ftl").getOutputFormat());
assertEquals(PlainTextOutputFormat.INSTANCE, cfg.getTemplate("mail/t.subject.ftl").getOutputFormat());
@@ -125,34 +125,34 @@
addTemplate("t.xml", "");
addTemplate("mail/t.html", "");
- TemplateConfigurer tcStats = new TemplateConfigurer();
+ TemplateConfiguration tcStats = new TemplateConfiguration();
tcStats.setDateTimeFormat("iso");
tcStats.setDateFormat("iso");
tcStats.setTimeFormat("iso");
tcStats.setTimeZone(DateUtil.UTC);
- TemplateConfigurer tcMail = new TemplateConfigurer();
+ TemplateConfiguration tcMail = new TemplateConfiguration();
tcMail.setEncoding("utf-8");
- TemplateConfigurer tcHTML = new TemplateConfigurer();
+ TemplateConfiguration tcHTML = new TemplateConfiguration();
tcHTML.setOutputFormat(HTMLOutputFormat.INSTANCE);
- TemplateConfigurer tcXML = new TemplateConfigurer();
+ TemplateConfiguration tcXML = new TemplateConfiguration();
tcXML.setOutputFormat(XMLOutputFormat.INSTANCE);
- cfg.setTemplateConfigurers(
- new MergingTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(
+ cfg.setTemplateConfigurations(
+ new MergingTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(
new FileNameGlobMatcher("*.stats.*"),
tcStats),
- new ConditionalTemplateConfigurerFactory(
+ new ConditionalTemplateConfigurationFactory(
new PathGlobMatcher("mail/**"),
tcMail),
- new FirstMatchTemplateConfigurerFactory(
- new ConditionalTemplateConfigurerFactory(
+ new FirstMatchTemplateConfigurationFactory(
+ new ConditionalTemplateConfigurationFactory(
new FileExtensionMatcher("xml"),
tcXML),
- new ConditionalTemplateConfigurerFactory(
+ new ConditionalTemplateConfigurationFactory(
new OrMatcher(
new FileExtensionMatcher("html"),
new FileExtensionMatcher("htm")),
@@ -171,8 +171,8 @@
// From properties:
- cfg.setTemplateConfigurers(null);
- cfg.setSettings(loadPropertiesFile("TemplateConfigurerExamples3.properties"));
+ cfg.setTemplateConfigurations(null);
+ cfg.setSettings(loadPropertiesFile("TemplateConfigurationExamples3.properties"));
assertEquals(HTMLOutputFormat.INSTANCE, cfg.getTemplate("t.html").getOutputFormat());
assertEquals("ISO-8859-1", cfg.getTemplate("t.html").getEncoding());
diff --git a/src/test/java/freemarker/template/ConfigurationTest.java b/src/test/java/freemarker/template/ConfigurationTest.java
index b7de38e..9e69d90 100644
--- a/src/test/java/freemarker/template/ConfigurationTest.java
+++ b/src/test/java/freemarker/template/ConfigurationTest.java
@@ -66,7 +66,6 @@
import freemarker.core.HexTemplateNumberFormatFactory;
import freemarker.core.MarkupOutputFormat;
import freemarker.core.OutputFormat;
-import freemarker.core.ParseException;
import freemarker.core.RTFOutputFormat;
import freemarker.core.TemplateDateFormatFactory;
import freemarker.core.TemplateNumberFormatFactory;
@@ -812,9 +811,9 @@
assertEquals(0, cache.getSize());
}
- public void testSetTemplateConfigurers() throws TemplateException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException {
+ public void testSetTemplateConfigurations() throws Exception {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
- assertNull(cfg.getTemplateConfigurers());
+ assertNull(cfg.getTemplateConfigurations());
StringTemplateLoader tl = new StringTemplateLoader();
tl.putTemplate("t.de.ftlh", "");
@@ -825,25 +824,25 @@
cfg.setTimeZone(TimeZone.getTimeZone("GMT+09"));
- cfg.setSetting(Configuration.TEMPLATE_CONFIGURERS_KEY,
- "MergingTemplateConfigurerFactory("
- + "FirstMatchTemplateConfigurerFactory("
- + "ConditionalTemplateConfigurerFactory("
- + "FileNameGlobMatcher('*.de.*'), TemplateConfigurer(timeZone=TimeZone('GMT+01'))), "
- + "ConditionalTemplateConfigurerFactory("
- + "FileNameGlobMatcher('*.fr.*'), TemplateConfigurer(timeZone=TimeZone('GMT'))), "
+ cfg.setSetting(Configuration.TEMPLATE_CONFIGURATIONS_KEY,
+ "MergingTemplateConfigurationFactory("
+ + "FirstMatchTemplateConfigurationFactory("
+ + "ConditionalTemplateConfigurationFactory("
+ + "FileNameGlobMatcher('*.de.*'), TemplateConfiguration(timeZone=TimeZone('GMT+01'))), "
+ + "ConditionalTemplateConfigurationFactory("
+ + "FileNameGlobMatcher('*.fr.*'), TemplateConfiguration(timeZone=TimeZone('GMT'))), "
+ "allowNoMatch=true"
+ "), "
- + "FirstMatchTemplateConfigurerFactory("
- + "ConditionalTemplateConfigurerFactory("
- + "FileExtensionMatcher('ftlh'), TemplateConfigurer(booleanFormat='TODO,HTML')), "
- + "ConditionalTemplateConfigurerFactory("
- + "FileExtensionMatcher('ftlx'), TemplateConfigurer(booleanFormat='TODO,XML')), "
+ + "FirstMatchTemplateConfigurationFactory("
+ + "ConditionalTemplateConfigurationFactory("
+ + "FileExtensionMatcher('ftlh'), TemplateConfiguration(booleanFormat='TODO,HTML')), "
+ + "ConditionalTemplateConfigurationFactory("
+ + "FileExtensionMatcher('ftlx'), TemplateConfiguration(booleanFormat='TODO,XML')), "
+ "noMatchErrorDetails='Unrecognized template file extension'"
+ "), "
- + "ConditionalTemplateConfigurerFactory("
+ + "ConditionalTemplateConfigurationFactory("
+ "PathGlobMatcher('stat/**', caseInsensitive=true), "
- + "TemplateConfigurer(timeZone=TimeZone('UTC'))"
+ + "TemplateConfiguration(timeZone=TimeZone('UTC'))"
+ ")"
+ ")");
@@ -868,9 +867,9 @@
assertEquals(DateUtil.UTC, t.getTimeZone());
}
- assertNotNull(cfg.getTemplateConfigurers());
- cfg.setSetting(Configuration.TEMPLATE_CONFIGURERS_KEY, "null");
- assertNull(cfg.getTemplateConfigurers());
+ assertNotNull(cfg.getTemplateConfigurations());
+ cfg.setSetting(Configuration.TEMPLATE_CONFIGURATIONS_KEY, "null");
+ assertNull(cfg.getTemplateConfigurations());
}
public void testSetAutoEscaping() throws Exception {
@@ -1013,7 +1012,7 @@
new ArrayList(cfg.getRegisteredCustomOutputFormats()));
try {
- cfg.setSetting(Configuration.REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY_SNAKE_CASE, "[TemplateConfigurer()]");
+ cfg.setSetting(Configuration.REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY_SNAKE_CASE, "[TemplateConfiguration()]");
fail();
} catch (Exception e) {
assertThat(e.getCause().getMessage(), containsString(OutputFormat.class.getSimpleName()));
diff --git a/src/test/resources/freemarker/manual/ConfigureOutputFormatExamples1.properties b/src/test/resources/freemarker/manual/ConfigureOutputFormatExamples1.properties
index 0f59312..f21272a 100644
--- a/src/test/resources/freemarker/manual/ConfigureOutputFormatExamples1.properties
+++ b/src/test/resources/freemarker/manual/ConfigureOutputFormatExamples1.properties
@@ -1,4 +1,4 @@
-templateConfigurers = \
- ConditionalTemplateConfigurerFactory( \
+templateConfigurations = \
+ ConditionalTemplateConfigurationFactory( \
PathGlobMatcher("mail/**"), \
- TemplateConfigurer(outputFormat = HTMLOutputFormat()))
\ No newline at end of file
+ TemplateConfiguration(outputFormat = HTMLOutputFormat()))
\ No newline at end of file
diff --git a/src/test/resources/freemarker/manual/ConfigureOutputFormatExamples2.properties b/src/test/resources/freemarker/manual/ConfigureOutputFormatExamples2.properties
index 23fcee3..b01090b 100644
--- a/src/test/resources/freemarker/manual/ConfigureOutputFormatExamples2.properties
+++ b/src/test/resources/freemarker/manual/ConfigureOutputFormatExamples2.properties
@@ -1,14 +1,14 @@
-templateConfigurers = \
- FirstMatchTemplateConfigurerFactory( \
- ConditionalTemplateConfigurerFactory( \
+templateConfigurations = \
+ FirstMatchTemplateConfigurationFactory( \
+ ConditionalTemplateConfigurationFactory( \
FileExtensionMatcher("xml"), \
- TemplateConfigurer(outputFormat = XMLOutputFormat())), \
- ConditionalTemplateConfigurerFactory( \
+ TemplateConfiguration(outputFormat = XMLOutputFormat())), \
+ ConditionalTemplateConfigurationFactory( \
OrMatcher( \
FileExtensionMatcher("html"), \
FileExtensionMatcher("htm")), \
- TemplateConfigurer(outputFormat = HTMLOutputFormat())), \
- ConditionalTemplateConfigurerFactory( \
+ TemplateConfiguration(outputFormat = HTMLOutputFormat())), \
+ ConditionalTemplateConfigurationFactory( \
FileExtensionMatcher("rtf"), \
- TemplateConfigurer(outputFormat = RTFOutputFormat())), \
+ TemplateConfiguration(outputFormat = RTFOutputFormat())), \
allowNoMatch = true)
diff --git a/src/test/resources/freemarker/manual/TemplateConfigurationExamples1.properties b/src/test/resources/freemarker/manual/TemplateConfigurationExamples1.properties
new file mode 100644
index 0000000..b6edf1a
--- /dev/null
+++ b/src/test/resources/freemarker/manual/TemplateConfigurationExamples1.properties
@@ -0,0 +1,8 @@
+templateConfigurations = \
+ ConditionalTemplateConfigurationFactory( \
+ FileExtensionMatcher("xml"), \
+ TemplateConfiguration( \
+ encoding = "utf-8", \
+ outputFormat = XMLOutputFormat() \
+ ) \
+ )
\ No newline at end of file
diff --git a/src/test/resources/freemarker/manual/TemplateConfigurationExamples2.properties b/src/test/resources/freemarker/manual/TemplateConfigurationExamples2.properties
new file mode 100644
index 0000000..a39acca
--- /dev/null
+++ b/src/test/resources/freemarker/manual/TemplateConfigurationExamples2.properties
@@ -0,0 +1,15 @@
+templateConfigurations = \
+ ConditionalTemplateConfigurationFactory( \
+ PathGlobMatcher("mail/**"), \
+ FirstMatchTemplateConfigurationFactory( \
+ ConditionalTemplateConfigurationFactory( \
+ FileNameGlobMatcher("*.subject.*"), \
+ TemplateConfiguration(outputFormat = PlainTextOutputFormat()) \
+ ), \
+ ConditionalTemplateConfigurationFactory( \
+ FileNameGlobMatcher("*.body.*"), \
+ TemplateConfiguration(outputFormat = HTMLOutputFormat()) \
+ ), \
+ noMatchErrorDetails = 'Mail template names must contain ".subject." or ".body."!' \
+ ) \
+ )
diff --git a/src/test/resources/freemarker/manual/TemplateConfigurationExamples3.properties b/src/test/resources/freemarker/manual/TemplateConfigurationExamples3.properties
new file mode 100644
index 0000000..424330b
--- /dev/null
+++ b/src/test/resources/freemarker/manual/TemplateConfigurationExamples3.properties
@@ -0,0 +1,30 @@
+templateConfigurations = \
+ MergingTemplateConfigurationFactory( \
+ ConditionalTemplateConfigurationFactory( \
+ FileNameGlobMatcher("*.stats.*"), \
+ TemplateConfiguration( \
+ dateTimeFormat = "iso", \
+ dateFormat = "iso", \
+ timeFormat = "iso", \
+ timeZone = TimeZone("UTC") \
+ ) \
+ ), \
+ ConditionalTemplateConfigurationFactory( \
+ PathGlobMatcher("mail/**"), \
+ TemplateConfiguration(encoding = "utf-8") \
+ ), \
+ FirstMatchTemplateConfigurationFactory( \
+ ConditionalTemplateConfigurationFactory( \
+ FileExtensionMatcher("xml"), \
+ TemplateConfiguration(outputFormat = XMLOutputFormat()) \
+ ), \
+ ConditionalTemplateConfigurationFactory( \
+ OrMatcher( \
+ FileExtensionMatcher("html"), \
+ FileExtensionMatcher("htm") \
+ ), \
+ TemplateConfiguration(outputFormat = HTMLOutputFormat()) \
+ ), \
+ allowNoMatch = true \
+ ) \
+ )
diff --git a/src/test/resources/freemarker/manual/TemplateConfigurerExamples1.properties b/src/test/resources/freemarker/manual/TemplateConfigurerExamples1.properties
deleted file mode 100644
index 30edee6..0000000
--- a/src/test/resources/freemarker/manual/TemplateConfigurerExamples1.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-templateConfigurers = \
- ConditionalTemplateConfigurerFactory( \
- FileExtensionMatcher("xml"), \
- TemplateConfigurer( \
- encoding = "utf-8", \
- outputFormat = XMLOutputFormat() \
- ) \
- )
\ No newline at end of file
diff --git a/src/test/resources/freemarker/manual/TemplateConfigurerExamples2.properties b/src/test/resources/freemarker/manual/TemplateConfigurerExamples2.properties
deleted file mode 100644
index 07bd91b..0000000
--- a/src/test/resources/freemarker/manual/TemplateConfigurerExamples2.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-templateConfigurers = \
- ConditionalTemplateConfigurerFactory( \
- PathGlobMatcher("mail/**"), \
- FirstMatchTemplateConfigurerFactory( \
- ConditionalTemplateConfigurerFactory( \
- FileNameGlobMatcher("*.subject.*"), \
- TemplateConfigurer(outputFormat = PlainTextOutputFormat()) \
- ), \
- ConditionalTemplateConfigurerFactory( \
- FileNameGlobMatcher("*.body.*"), \
- TemplateConfigurer(outputFormat = HTMLOutputFormat()) \
- ), \
- noMatchErrorDetails = 'Mail template names must contain ".subject." or ".body."!' \
- ) \
- )
diff --git a/src/test/resources/freemarker/manual/TemplateConfigurerExamples3.properties b/src/test/resources/freemarker/manual/TemplateConfigurerExamples3.properties
deleted file mode 100644
index bbdd5e8..0000000
--- a/src/test/resources/freemarker/manual/TemplateConfigurerExamples3.properties
+++ /dev/null
@@ -1,30 +0,0 @@
-templateConfigurers = \
- MergingTemplateConfigurerFactory( \
- ConditionalTemplateConfigurerFactory( \
- FileNameGlobMatcher("*.stats.*"), \
- TemplateConfigurer( \
- dateTimeFormat = "iso", \
- dateFormat = "iso", \
- timeFormat = "iso", \
- timeZone = TimeZone("UTC") \
- ) \
- ), \
- ConditionalTemplateConfigurerFactory( \
- PathGlobMatcher("mail/**"), \
- TemplateConfigurer(encoding = "utf-8") \
- ), \
- FirstMatchTemplateConfigurerFactory( \
- ConditionalTemplateConfigurerFactory( \
- FileExtensionMatcher("xml"), \
- TemplateConfigurer(outputFormat = XMLOutputFormat()) \
- ), \
- ConditionalTemplateConfigurerFactory( \
- OrMatcher( \
- FileExtensionMatcher("html"), \
- FileExtensionMatcher("htm") \
- ), \
- TemplateConfigurer(outputFormat = HTMLOutputFormat()) \
- ), \
- allowNoMatch = true \
- ) \
- )