This is an automated email from the ASF dual-hosted git repository. ddekany pushed a commit to branch 3 in repository https://gitbox.apache.org/repos/asf/freemarker.git
commit 4df72416c9d4e6a34c204c0d51084c18fd23e689 Author: ddekany <ddek...@apache.org> AuthorDate: Thu Jan 5 16:11:29 2023 +0100 Forward ported from 2.3-gae: (Missed a piece of cFormat JavaDoc, other small things.) --- .../java/org/apache/freemarker/core/ASTDirSetting.java | 4 ++-- .../freemarker/core/MutableProcessingConfiguration.java | 9 ++++++++- .../org/apache/freemarker/core/util/_StringUtils.java | 16 ++++++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSetting.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSetting.java index ec96fc63..2ebd49a1 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSetting.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSetting.java @@ -115,8 +115,8 @@ final class ASTDirSetting extends ASTDirective { } throw new TemplateException("It's not allowed to set \"" + key + "\" to " + _StringUtils.jQuote(actualValue) + " in a template. Use a standard c format name (" - + String.join(", ", StandardCFormats.STANDARD_C_FORMATS.keySet()) + "), " + - "or registered custom c format name after a \"@\".", + + _StringUtils.toCommaSeparatedJQuotedItems(StandardCFormats.STANDARD_C_FORMATS.keySet()) + + "), or registered custom c format name after a \"@\".", env); }; } else { diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java b/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java index c55519dc..5679adee 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java @@ -1338,7 +1338,14 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces * <br>String value: Interpreted as an <a href="#fm_obe">object builder expression</a>. * <br>Example: <code>{ "trade": com.example.TradeTemplateDateFormatFactory, * "log": com.example.LogTemplateDateFormatFactory }</code> - * + * + * <li><p>{@code "cFormat"}: + * See {@link #setCFormat(CFormat)}. + * <br>String value: {@code "default"} (case insensitive) for the default (on {@link Configuration} only), + * or one of the predefined values {@code "JavaScript or JSON"}, {@code "JSON"}, + * {@code "JavaScript"}, {@code "Java"}, {@code "XS"}, + * or an <a href="#fm_obe">object builder expression</a> that gives a {@link CFormat} object. + * * <li><p>{@code "templateExceptionHandler"}: * See {@link #setTemplateExceptionHandler(TemplateExceptionHandler)}. * <br>String value: If the value contains dot, then it's interpreted as an <a href="#fm_obe">object builder diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/util/_StringUtils.java b/freemarker-core/src/main/java/org/apache/freemarker/core/util/_StringUtils.java index addf1461..63367313 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/util/_StringUtils.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/util/_StringUtils.java @@ -27,10 +27,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.io.Writer; import java.nio.charset.Charset; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.StringTokenizer; +import java.util.*; import java.util.regex.Pattern; import static org.apache.freemarker.core.util._StringUtils.JsStringEncQuotation.APOSTROPHE; @@ -1688,6 +1685,17 @@ public class _StringUtils { return NORMALIZE_EOLS_REGEXP.matcher(s).replaceAll("\n"); } + public static String toCommaSeparatedJQuotedItems(Collection<String> items) { + StringBuilder sb = new StringBuilder(); + for (String item : items) { + if (sb.length() != 0) { + sb.append(", "); + } + sb.append(jQuote(item)); + } + return sb.toString(); + } + /** * Used as the argument of {@link _StringUtils#jsStringEnc(String, JsStringEncCompatibility, JsStringEncQuotation)}. */