http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/51dba882/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSetting.java ---------------------------------------------------------------------- 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 fe2c4f8..0a8a160 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 @@ -37,25 +37,16 @@ final class ASTDirSetting extends ASTDirective { static final String[] SETTING_NAMES = new String[] { // Must be sorted alphabetically! - MutableProcessingConfiguration.BOOLEAN_FORMAT_KEY_CAMEL_CASE, - MutableProcessingConfiguration.BOOLEAN_FORMAT_KEY_SNAKE_CASE, - MutableProcessingConfiguration.DATE_FORMAT_KEY_CAMEL_CASE, - MutableProcessingConfiguration.DATE_FORMAT_KEY_SNAKE_CASE, - MutableProcessingConfiguration.DATETIME_FORMAT_KEY_CAMEL_CASE, - MutableProcessingConfiguration.DATETIME_FORMAT_KEY_SNAKE_CASE, + MutableProcessingConfiguration.BOOLEAN_FORMAT_KEY, + MutableProcessingConfiguration.DATE_FORMAT_KEY, + MutableProcessingConfiguration.DATE_TIME_FORMAT_KEY, MutableProcessingConfiguration.LOCALE_KEY, - MutableProcessingConfiguration.NUMBER_FORMAT_KEY_CAMEL_CASE, - MutableProcessingConfiguration.NUMBER_FORMAT_KEY_SNAKE_CASE, - MutableProcessingConfiguration.OUTPUT_ENCODING_KEY_CAMEL_CASE, - MutableProcessingConfiguration.OUTPUT_ENCODING_KEY_SNAKE_CASE, - MutableProcessingConfiguration.SQL_DATE_AND_TIME_TIME_ZONE_KEY_CAMEL_CASE, + MutableProcessingConfiguration.NUMBER_FORMAT_KEY, + MutableProcessingConfiguration.OUTPUT_ENCODING_KEY, MutableProcessingConfiguration.SQL_DATE_AND_TIME_TIME_ZONE_KEY, - MutableProcessingConfiguration.TIME_FORMAT_KEY_CAMEL_CASE, - MutableProcessingConfiguration.TIME_ZONE_KEY_CAMEL_CASE, - MutableProcessingConfiguration.TIME_FORMAT_KEY_SNAKE_CASE, - MutableProcessingConfiguration.TIME_ZONE_KEY_SNAKE_CASE, - MutableProcessingConfiguration.URL_ESCAPING_CHARSET_KEY_CAMEL_CASE, - MutableProcessingConfiguration.URL_ESCAPING_CHARSET_KEY_SNAKE_CASE + MutableProcessingConfiguration.TIME_FORMAT_KEY, + MutableProcessingConfiguration.TIME_ZONE_KEY, + MutableProcessingConfiguration.URL_ESCAPING_CHARSET_KEY, }; ASTDirSetting(Token keyTk, FMParserTokenManager tokenManager, ASTExpression value, Configuration cfg) @@ -63,8 +54,7 @@ final class ASTDirSetting extends ASTDirective { String key = keyTk.image; if (Arrays.binarySearch(SETTING_NAMES, key) < 0) { StringBuilder sb = new StringBuilder(); - if (Configuration.ExtendableBuilder.getSettingNames(true).contains(key) - || Configuration.ExtendableBuilder.getSettingNames(false).contains(key)) { + if (Configuration.ExtendableBuilder.getSettingNames().contains(key)) { sb.append("The setting name is recognized, but changing this setting from inside a template isn't " + "supported."); } else { @@ -72,27 +62,15 @@ final class ASTDirSetting extends ASTDirective { sb.append(_StringUtil.jQuote(key)).append("."); sb.append(" The allowed setting names are: "); - NamingConvention shownNamingConvention; - { - NamingConvention namingConvention = tokenManager.namingConvention; - shownNamingConvention = namingConvention != NamingConvention.AUTO_DETECT - ? namingConvention : NamingConvention.LEGACY /* [2.4] CAMEL_CASE */; - } - boolean first = true; for (String correctName : SETTING_NAMES) { - NamingConvention correctNameNamingConvention = _StringUtil.getIdentifierNamingConvention(correctName); - if (shownNamingConvention == NamingConvention.CAMEL_CASE - ? correctNameNamingConvention != NamingConvention.LEGACY - : correctNameNamingConvention != NamingConvention.CAMEL_CASE) { - if (first) { - first = false; - } else { - sb.append(", "); - } - - sb.append(correctName); + if (first) { + first = false; + } else { + sb.append(", "); } + + sb.append(correctName); } } throw new ParseException(sb.toString(), null, keyTk);
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/51dba882/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirective.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirective.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirective.java index 778fed1..e20c0e3 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirective.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirective.java @@ -27,72 +27,52 @@ import java.util.TreeSet; */ abstract class ASTDirective extends ASTElement { - private static void addName(Set<String> allNames, Set<String> lcNames, Set<String> ccNames, - String commonName) { - allNames.add(commonName); - lcNames.add(commonName); - ccNames.add(commonName); - } - - private static void addName(Set<String> allNames, Set<String> lcNames, Set<String> ccNames, - String lcName, String ccName) { - allNames.add(lcName); - allNames.add(ccName); - lcNames.add(lcName); - ccNames.add(ccName); - } - - static final Set<String> ALL_BUILT_IN_DIRECTIVE_NAMES; - static final Set<String> LEGACY_BUILT_IN_DIRECTIVE_NAMES; - static final Set<String> CAMEL_CASE_BUILT_IN_DIRECTIVE_NAMES; + static final Set<String> BUILT_IN_DIRECTIVE_NAMES; static { - Set<String> allNames = new TreeSet(); - Set<String> lcNames = new TreeSet(); - Set<String> ccNames = new TreeSet(); + TreeSet<String> names = new TreeSet<>(); + + names.add("assign"); + names.add("attempt"); + names.add("autoEsc"); + names.add("break"); + names.add("case"); + names.add("compress"); + names.add("default"); + names.add("else"); + names.add("elseIf"); + names.add("escape"); + names.add("fallback"); + names.add("flush"); + names.add("ftl"); + names.add("function"); + names.add("global"); + names.add("if"); + names.add("import"); + names.add("include"); + names.add("items"); + names.add("list"); + names.add("local"); + names.add("lt"); + names.add("macro"); + names.add("nested"); + names.add("noAutoEsc"); + names.add("noEscape"); + names.add("noParse"); + names.add("nt"); + names.add("outputFormat"); + names.add("recover"); + names.add("recurse"); + names.add("return"); + names.add("rt"); + names.add("sep"); + names.add("setting"); + names.add("stop"); + names.add("switch"); + names.add("t"); + names.add("visit"); - addName(allNames, lcNames, ccNames, "assign"); - addName(allNames, lcNames, ccNames, "attempt"); - addName(allNames, lcNames, ccNames, "autoesc", "autoEsc"); - addName(allNames, lcNames, ccNames, "break"); - addName(allNames, lcNames, ccNames, "case"); - addName(allNames, lcNames, ccNames, "compress"); - addName(allNames, lcNames, ccNames, "default"); - addName(allNames, lcNames, ccNames, "else"); - addName(allNames, lcNames, ccNames, "elseif", "elseIf"); - addName(allNames, lcNames, ccNames, "escape"); - addName(allNames, lcNames, ccNames, "fallback"); - addName(allNames, lcNames, ccNames, "flush"); - addName(allNames, lcNames, ccNames, "ftl"); - addName(allNames, lcNames, ccNames, "function"); - addName(allNames, lcNames, ccNames, "global"); - addName(allNames, lcNames, ccNames, "if"); - addName(allNames, lcNames, ccNames, "import"); - addName(allNames, lcNames, ccNames, "include"); - addName(allNames, lcNames, ccNames, "items"); - addName(allNames, lcNames, ccNames, "list"); - addName(allNames, lcNames, ccNames, "local"); - addName(allNames, lcNames, ccNames, "lt"); - addName(allNames, lcNames, ccNames, "macro"); - addName(allNames, lcNames, ccNames, "nested"); - addName(allNames, lcNames, ccNames, "noautoesc", "noAutoEsc"); - addName(allNames, lcNames, ccNames, "noescape", "noEscape"); - addName(allNames, lcNames, ccNames, "noparse", "noParse"); - addName(allNames, lcNames, ccNames, "nt"); - addName(allNames, lcNames, ccNames, "outputformat", "outputFormat"); - addName(allNames, lcNames, ccNames, "recover"); - addName(allNames, lcNames, ccNames, "recurse"); - addName(allNames, lcNames, ccNames, "return"); - addName(allNames, lcNames, ccNames, "rt"); - addName(allNames, lcNames, ccNames, "sep"); - addName(allNames, lcNames, ccNames, "setting"); - addName(allNames, lcNames, ccNames, "stop"); - addName(allNames, lcNames, ccNames, "switch"); - addName(allNames, lcNames, ccNames, "t"); - addName(allNames, lcNames, ccNames, "visit"); + BUILT_IN_DIRECTIVE_NAMES = Collections.unmodifiableSet(names); - ALL_BUILT_IN_DIRECTIVE_NAMES = Collections.unmodifiableSet(allNames); - LEGACY_BUILT_IN_DIRECTIVE_NAMES = Collections.unmodifiableSet(lcNames); - CAMEL_CASE_BUILT_IN_DIRECTIVE_NAMES = Collections.unmodifiableSet(ccNames); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/51dba882/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltIn.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltIn.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltIn.java index b246ad4..3f0454f 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltIn.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltIn.java @@ -23,8 +23,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; -import java.util.Set; -import java.util.TreeSet; import org.apache.freemarker.core.BuiltInsForDates.iso_BI; import org.apache.freemarker.core.BuiltInsForDates.iso_utc_or_local_BI; @@ -79,8 +77,6 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { protected ASTExpression target; protected String key; - static final Set<String> CAMEL_CASE_NAMES = new TreeSet<>(); - static final Set<String> SNAKE_CASE_NAMES = new TreeSet<>(); static final int NUMBER_OF_BIS = 263; static final HashMap<String, ASTExpBuiltIn> BUILT_INS_BY_NAME = new HashMap(NUMBER_OF_BIS * 3 / 2 + 1, 1f); @@ -93,21 +89,21 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { putBI("boolean", new BuiltInsForStringsMisc.booleanBI()); putBI("byte", new byteBI()); putBI("c", new BuiltInsForMultipleTypes.cBI()); - putBI("cap_first", "capFirst", new BuiltInsForStringsBasic.cap_firstBI()); + putBI("capFirst", new BuiltInsForStringsBasic.cap_firstBI()); putBI("capitalize", new BuiltInsForStringsBasic.capitalizeBI()); putBI("ceiling", new ceilingBI()); putBI("children", new childrenBI()); - putBI("chop_linebreak", "chopLinebreak", new BuiltInsForStringsBasic.chop_linebreakBI()); + putBI("chopLinebreak", new BuiltInsForStringsBasic.chop_linebreakBI()); putBI("contains", new BuiltInsForStringsBasic.containsBI()); putBI("date", new BuiltInsForMultipleTypes.dateBI(TemplateDateModel.DATE)); - putBI("date_if_unknown", "dateIfUnknown", new BuiltInsForDates.dateType_if_unknownBI(TemplateDateModel.DATE)); + putBI("dateIfUnknown", new BuiltInsForDates.dateType_if_unknownBI(TemplateDateModel.DATE)); putBI("datetime", new BuiltInsForMultipleTypes.dateBI(TemplateDateModel.DATETIME)); - putBI("datetime_if_unknown", "datetimeIfUnknown", new BuiltInsForDates.dateType_if_unknownBI(TemplateDateModel.DATETIME)); + putBI("datetimeIfUnknown", new BuiltInsForDates.dateType_if_unknownBI(TemplateDateModel.DATETIME)); putBI("default", new BuiltInsForExistenceHandling.defaultBI()); putBI("double", new doubleBI()); - putBI("ends_with", "endsWith", new BuiltInsForStringsBasic.ends_withBI()); - putBI("ensure_ends_with", "ensureEndsWith", new BuiltInsForStringsBasic.ensure_ends_withBI()); - putBI("ensure_starts_with", "ensureStartsWith", new BuiltInsForStringsBasic.ensure_starts_withBI()); + putBI("endsWith", new BuiltInsForStringsBasic.ends_withBI()); + putBI("ensureEndsWith", new BuiltInsForStringsBasic.ensure_ends_withBI()); + putBI("ensureStartsWith", new BuiltInsForStringsBasic.ensure_starts_withBI()); putBI("esc", new escBI()); putBI("eval", new evalBI()); putBI("exists", new BuiltInsForExistenceHandling.existsBI()); @@ -116,171 +112,171 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { putBI("floor", new floorBI()); putBI("chunk", new chunkBI()); putBI("counter", new BuiltInsForLoopVariables.counterBI()); - putBI("item_cycle", "itemCycle", new BuiltInsForLoopVariables.item_cycleBI()); - putBI("has_api", "hasApi", new BuiltInsForMultipleTypes.has_apiBI()); - putBI("has_content", "hasContent", new BuiltInsForExistenceHandling.has_contentBI()); - putBI("has_next", "hasNext", new BuiltInsForLoopVariables.has_nextBI()); + putBI("itemCycle", new BuiltInsForLoopVariables.item_cycleBI()); + putBI("hasApi", new BuiltInsForMultipleTypes.has_apiBI()); + putBI("hasContent", new BuiltInsForExistenceHandling.has_contentBI()); + putBI("hasNext", new BuiltInsForLoopVariables.has_nextBI()); putBI("html", new BuiltInsForStringsEncoding.htmlBI()); - putBI("if_exists", "ifExists", new BuiltInsForExistenceHandling.if_existsBI()); + putBI("ifExists", new BuiltInsForExistenceHandling.if_existsBI()); putBI("index", new BuiltInsForLoopVariables.indexBI()); - putBI("index_of", "indexOf", new BuiltInsForStringsBasic.index_ofBI(false)); + putBI("indexOf", new BuiltInsForStringsBasic.index_ofBI(false)); putBI("int", new intBI()); putBI("interpret", new BuiltInsForStringsMisc.interpretBI()); - putBI("is_boolean", "isBoolean", new BuiltInsForMultipleTypes.is_booleanBI()); - putBI("is_collection", "isCollection", new BuiltInsForMultipleTypes.is_collectionBI()); - putBI("is_collection_ex", "isCollectionEx", new BuiltInsForMultipleTypes.is_collection_exBI()); + putBI("isBoolean", new BuiltInsForMultipleTypes.is_booleanBI()); + putBI("isCollection", new BuiltInsForMultipleTypes.is_collectionBI()); + putBI("isCollectionEx", new BuiltInsForMultipleTypes.is_collection_exBI()); is_dateLikeBI bi = new BuiltInsForMultipleTypes.is_dateLikeBI(); - putBI("is_date", "isDate", bi); // misnomer - putBI("is_date_like", "isDateLike", bi); - putBI("is_date_only", "isDateOnly", new BuiltInsForMultipleTypes.is_dateOfTypeBI(TemplateDateModel.DATE)); - putBI("is_even_item", "isEvenItem", new BuiltInsForLoopVariables.is_even_itemBI()); - putBI("is_first", "isFirst", new BuiltInsForLoopVariables.is_firstBI()); - putBI("is_last", "isLast", new BuiltInsForLoopVariables.is_lastBI()); - putBI("is_unknown_date_like", "isUnknownDateLike", new BuiltInsForMultipleTypes.is_dateOfTypeBI(TemplateDateModel.UNKNOWN)); - putBI("is_datetime", "isDatetime", new BuiltInsForMultipleTypes.is_dateOfTypeBI(TemplateDateModel.DATETIME)); - putBI("is_directive", "isDirective", new BuiltInsForMultipleTypes.is_directiveBI()); - putBI("is_enumerable", "isEnumerable", new BuiltInsForMultipleTypes.is_enumerableBI()); - putBI("is_hash_ex", "isHashEx", new BuiltInsForMultipleTypes.is_hash_exBI()); - putBI("is_hash", "isHash", new BuiltInsForMultipleTypes.is_hashBI()); - putBI("is_infinite", "isInfinite", new is_infiniteBI()); - putBI("is_indexable", "isIndexable", new BuiltInsForMultipleTypes.is_indexableBI()); - putBI("is_macro", "isMacro", new BuiltInsForMultipleTypes.is_macroBI()); - putBI("is_markup_output", "isMarkupOutput", new BuiltInsForMultipleTypes.is_markup_outputBI()); - putBI("is_method", "isMethod", new BuiltInsForMultipleTypes.is_methodBI()); - putBI("is_nan", "isNan", new is_nanBI()); - putBI("is_node", "isNode", new BuiltInsForMultipleTypes.is_nodeBI()); - putBI("is_number", "isNumber", new BuiltInsForMultipleTypes.is_numberBI()); - putBI("is_odd_item", "isOddItem", new BuiltInsForLoopVariables.is_odd_itemBI()); - putBI("is_sequence", "isSequence", new BuiltInsForMultipleTypes.is_sequenceBI()); - putBI("is_string", "isString", new BuiltInsForMultipleTypes.is_stringBI()); - putBI("is_time", "isTime", new BuiltInsForMultipleTypes.is_dateOfTypeBI(TemplateDateModel.TIME)); - putBI("is_transform", "isTransform", new BuiltInsForMultipleTypes.is_transformBI()); + putBI("isDate", bi); // misnomer + putBI("isDateLike", bi); + putBI("isDateOnly", new BuiltInsForMultipleTypes.is_dateOfTypeBI(TemplateDateModel.DATE)); + putBI("isEvenItem", new BuiltInsForLoopVariables.is_even_itemBI()); + putBI("isFirst", new BuiltInsForLoopVariables.is_firstBI()); + putBI("isLast", new BuiltInsForLoopVariables.is_lastBI()); + putBI("isUnknownDateLike", new BuiltInsForMultipleTypes.is_dateOfTypeBI(TemplateDateModel.UNKNOWN)); + putBI("isDatetime", new BuiltInsForMultipleTypes.is_dateOfTypeBI(TemplateDateModel.DATETIME)); + putBI("isDirective", new BuiltInsForMultipleTypes.is_directiveBI()); + putBI("isEnumerable", new BuiltInsForMultipleTypes.is_enumerableBI()); + putBI("isHashEx", new BuiltInsForMultipleTypes.is_hash_exBI()); + putBI("isHash", new BuiltInsForMultipleTypes.is_hashBI()); + putBI("isInfinite", new is_infiniteBI()); + putBI("isIndexable", new BuiltInsForMultipleTypes.is_indexableBI()); + putBI("isMacro", new BuiltInsForMultipleTypes.is_macroBI()); + putBI("isMarkupOutput", new BuiltInsForMultipleTypes.is_markup_outputBI()); + putBI("isMethod", new BuiltInsForMultipleTypes.is_methodBI()); + putBI("isNan", new is_nanBI()); + putBI("isNode", new BuiltInsForMultipleTypes.is_nodeBI()); + putBI("isNumber", new BuiltInsForMultipleTypes.is_numberBI()); + putBI("isOddItem", new BuiltInsForLoopVariables.is_odd_itemBI()); + putBI("isSequence", new BuiltInsForMultipleTypes.is_sequenceBI()); + putBI("isString", new BuiltInsForMultipleTypes.is_stringBI()); + putBI("isTime", new BuiltInsForMultipleTypes.is_dateOfTypeBI(TemplateDateModel.TIME)); + putBI("isTransform", new BuiltInsForMultipleTypes.is_transformBI()); - putBI("iso_utc", "isoUtc", new iso_utc_or_local_BI( + putBI("isoUtc", new iso_utc_or_local_BI( /* showOffset = */ null, _DateUtil.ACCURACY_SECONDS, /* useUTC = */ true)); - putBI("iso_utc_fz", "isoUtcFZ", new iso_utc_or_local_BI( + putBI("isoUtcFZ", new iso_utc_or_local_BI( /* showOffset = */ Boolean.TRUE, _DateUtil.ACCURACY_SECONDS, /* useUTC = */ true)); - putBI("iso_utc_nz", "isoUtcNZ", new iso_utc_or_local_BI( + putBI("isoUtcNZ", new iso_utc_or_local_BI( /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_SECONDS, /* useUTC = */ true)); - putBI("iso_utc_ms", "isoUtcMs", new iso_utc_or_local_BI( + putBI("isoUtcMs", new iso_utc_or_local_BI( /* showOffset = */ null, _DateUtil.ACCURACY_MILLISECONDS, /* useUTC = */ true)); - putBI("iso_utc_ms_nz", "isoUtcMsNZ", new iso_utc_or_local_BI( + putBI("isoUtcMsNZ", new iso_utc_or_local_BI( /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_MILLISECONDS, /* useUTC = */ true)); - putBI("iso_utc_m", "isoUtcM", new iso_utc_or_local_BI( + putBI("isoUtcM", new iso_utc_or_local_BI( /* showOffset = */ null, _DateUtil.ACCURACY_MINUTES, /* useUTC = */ true)); - putBI("iso_utc_m_nz", "isoUtcMNZ", new iso_utc_or_local_BI( + putBI("isoUtcMNZ", new iso_utc_or_local_BI( /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_MINUTES, /* useUTC = */ true)); - putBI("iso_utc_h", "isoUtcH", new iso_utc_or_local_BI( + putBI("isoUtcH", new iso_utc_or_local_BI( /* showOffset = */ null, _DateUtil.ACCURACY_HOURS, /* useUTC = */ true)); - putBI("iso_utc_h_nz", "isoUtcHNZ", new iso_utc_or_local_BI( + putBI("isoUtcHNZ", new iso_utc_or_local_BI( /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_HOURS, /* useUTC = */ true)); - putBI("iso_local", "isoLocal", new iso_utc_or_local_BI( + putBI("isoLocal", new iso_utc_or_local_BI( /* showOffset = */ null, _DateUtil.ACCURACY_SECONDS, /* useUTC = */ false)); - putBI("iso_local_nz", "isoLocalNZ", new iso_utc_or_local_BI( + putBI("isoLocalNZ", new iso_utc_or_local_BI( /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_SECONDS, /* useUTC = */ false)); - putBI("iso_local_ms", "isoLocalMs", new iso_utc_or_local_BI( + putBI("isoLocalMs", new iso_utc_or_local_BI( /* showOffset = */ null, _DateUtil.ACCURACY_MILLISECONDS, /* useUTC = */ false)); - putBI("iso_local_ms_nz", "isoLocalMsNZ", new iso_utc_or_local_BI( + putBI("isoLocalMsNZ", new iso_utc_or_local_BI( /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_MILLISECONDS, /* useUTC = */ false)); - putBI("iso_local_m", "isoLocalM", new iso_utc_or_local_BI( + putBI("isoLocalM", new iso_utc_or_local_BI( /* showOffset = */ null, _DateUtil.ACCURACY_MINUTES, /* useUTC = */ false)); - putBI("iso_local_m_nz", "isoLocalMNZ", new iso_utc_or_local_BI( + putBI("isoLocalMNZ", new iso_utc_or_local_BI( /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_MINUTES, /* useUTC = */ false)); - putBI("iso_local_h", "isoLocalH", new iso_utc_or_local_BI( + putBI("isoLocalH", new iso_utc_or_local_BI( /* showOffset = */ null, _DateUtil.ACCURACY_HOURS, /* useUTC = */ false)); - putBI("iso_local_h_nz", "isoLocalHNZ", new iso_utc_or_local_BI( + putBI("isoLocalHNZ", new iso_utc_or_local_BI( /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_HOURS, /* useUTC = */ false)); putBI("iso", new iso_BI( /* showOffset = */ null, _DateUtil.ACCURACY_SECONDS)); - putBI("iso_nz", "isoNZ", new iso_BI( + putBI("isoNZ", new iso_BI( /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_SECONDS)); - putBI("iso_ms", "isoMs", new iso_BI( + putBI("isoMs", new iso_BI( /* showOffset = */ null, _DateUtil.ACCURACY_MILLISECONDS)); - putBI("iso_ms_nz", "isoMsNZ", new iso_BI( + putBI("isoMsNZ", new iso_BI( /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_MILLISECONDS)); - putBI("iso_m", "isoM", new iso_BI( + putBI("isoM", new iso_BI( /* showOffset = */ null, _DateUtil.ACCURACY_MINUTES)); - putBI("iso_m_nz", "isoMNZ", new iso_BI( + putBI("isoMNZ", new iso_BI( /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_MINUTES)); - putBI("iso_h", "isoH", new iso_BI( + putBI("isoH", new iso_BI( /* showOffset = */ null, _DateUtil.ACCURACY_HOURS)); - putBI("iso_h_nz", "isoHNZ", new iso_BI( + putBI("isoHNZ", new iso_BI( /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_HOURS)); - putBI("j_string", "jString", new BuiltInsForStringsEncoding.j_stringBI()); + putBI("jString", new BuiltInsForStringsEncoding.j_stringBI()); putBI("join", new BuiltInsForSequences.joinBI()); - putBI("js_string", "jsString", new BuiltInsForStringsEncoding.js_stringBI()); - putBI("json_string", "jsonString", new BuiltInsForStringsEncoding.json_stringBI()); - putBI("keep_after", "keepAfter", new BuiltInsForStringsBasic.keep_afterBI()); - putBI("keep_before", "keepBefore", new BuiltInsForStringsBasic.keep_beforeBI()); - putBI("keep_after_last", "keepAfterLast", new BuiltInsForStringsBasic.keep_after_lastBI()); - putBI("keep_before_last", "keepBeforeLast", new BuiltInsForStringsBasic.keep_before_lastBI()); + putBI("jsString", new BuiltInsForStringsEncoding.js_stringBI()); + putBI("jsonString", new BuiltInsForStringsEncoding.json_stringBI()); + putBI("keepAfter", new BuiltInsForStringsBasic.keep_afterBI()); + putBI("keepBefore", new BuiltInsForStringsBasic.keep_beforeBI()); + putBI("keepAfterLast", new BuiltInsForStringsBasic.keep_after_lastBI()); + putBI("keepBeforeLast", new BuiltInsForStringsBasic.keep_before_lastBI()); putBI("keys", new BuiltInsForHashes.keysBI()); - putBI("last_index_of", "lastIndexOf", new BuiltInsForStringsBasic.index_ofBI(true)); + putBI("lastIndexOf", new BuiltInsForStringsBasic.index_ofBI(true)); putBI("last", new lastBI()); - putBI("left_pad", "leftPad", new BuiltInsForStringsBasic.padBI(true)); + putBI("leftPad", new BuiltInsForStringsBasic.padBI(true)); putBI("length", new BuiltInsForStringsBasic.lengthBI()); putBI("long", new longBI()); - putBI("lower_abc", "lowerAbc", new BuiltInsForNumbers.lower_abcBI()); - putBI("lower_case", "lowerCase", new BuiltInsForStringsBasic.lower_caseBI()); + putBI("lowerAbc", new BuiltInsForNumbers.lower_abcBI()); + putBI("lowerCase", new BuiltInsForStringsBasic.lower_caseBI()); putBI("namespace", new BuiltInsForMultipleTypes.namespaceBI()); putBI("new", new BuiltInsForStringsMisc.newBI()); - putBI("markup_string", "markupString", new markup_stringBI()); - putBI("node_name", "nodeName", new node_nameBI()); - putBI("node_namespace", "nodeNamespace", new node_namespaceBI()); - putBI("node_type", "nodeType", new node_typeBI()); - putBI("no_esc", "noEsc", new no_escBI()); + putBI("markupString", new markup_stringBI()); + putBI("nodeName", new node_nameBI()); + putBI("nodeNamespace", new node_namespaceBI()); + putBI("nodeType", new node_typeBI()); + putBI("noEsc", new no_escBI()); putBI("number", new BuiltInsForStringsMisc.numberBI()); - putBI("number_to_date", "numberToDate", new number_to_dateBI(TemplateDateModel.DATE)); - putBI("number_to_time", "numberToTime", new number_to_dateBI(TemplateDateModel.TIME)); - putBI("number_to_datetime", "numberToDatetime", new number_to_dateBI(TemplateDateModel.DATETIME)); + putBI("numberToDate", new number_to_dateBI(TemplateDateModel.DATE)); + putBI("numberToTime", new number_to_dateBI(TemplateDateModel.TIME)); + putBI("numberToDatetime", new number_to_dateBI(TemplateDateModel.DATETIME)); putBI("parent", new parentBI()); - putBI("previous_sibling", "previousSibling", new previousSiblingBI()); - putBI("next_sibling", "nextSibling", new nextSiblingBI()); - putBI("item_parity", "itemParity", new BuiltInsForLoopVariables.item_parityBI()); - putBI("item_parity_cap", "itemParityCap", new BuiltInsForLoopVariables.item_parity_capBI()); + putBI("previousSibling", new previousSiblingBI()); + putBI("nextSibling", new nextSiblingBI()); + putBI("itemParity", new BuiltInsForLoopVariables.item_parityBI()); + putBI("itemParityCap", new BuiltInsForLoopVariables.item_parity_capBI()); putBI("reverse", new reverseBI()); - putBI("right_pad", "rightPad", new BuiltInsForStringsBasic.padBI(false)); + putBI("rightPad", new BuiltInsForStringsBasic.padBI(false)); putBI("root", new rootBI()); putBI("round", new roundBI()); - putBI("remove_ending", "removeEnding", new BuiltInsForStringsBasic.remove_endingBI()); - putBI("remove_beginning", "removeBeginning", new BuiltInsForStringsBasic.remove_beginningBI()); + putBI("removeEnding", new BuiltInsForStringsBasic.remove_endingBI()); + putBI("removeBeginning", new BuiltInsForStringsBasic.remove_beginningBI()); putBI("rtf", new BuiltInsForStringsEncoding.rtfBI()); - putBI("seq_contains", "seqContains", new seq_containsBI()); - putBI("seq_index_of", "seqIndexOf", new seq_index_ofBI(1)); - putBI("seq_last_index_of", "seqLastIndexOf", new seq_index_ofBI(-1)); + putBI("seqContains", new seq_containsBI()); + putBI("seqIndexOf", new seq_index_ofBI(1)); + putBI("seqLastIndexOf", new seq_index_ofBI(-1)); putBI("short", new shortBI()); putBI("size", new BuiltInsForMultipleTypes.sizeBI()); - putBI("sort_by", "sortBy", new sort_byBI()); + putBI("sortBy", new sort_byBI()); putBI("sort", new sortBI()); putBI("split", new BuiltInsForStringsBasic.split_BI()); putBI("switch", new BuiltInsWithParseTimeParameters.switch_BI()); - putBI("starts_with", "startsWith", new BuiltInsForStringsBasic.starts_withBI()); + putBI("startsWith", new BuiltInsForStringsBasic.starts_withBI()); putBI("string", new BuiltInsForMultipleTypes.stringBI()); putBI("substring", new BuiltInsForStringsBasic.substringBI()); putBI("then", new BuiltInsWithParseTimeParameters.then_BI()); putBI("time", new BuiltInsForMultipleTypes.dateBI(TemplateDateModel.TIME)); - putBI("time_if_unknown", "timeIfUnknown", new BuiltInsForDates.dateType_if_unknownBI(TemplateDateModel.TIME)); + putBI("timeIfUnknown", new BuiltInsForDates.dateType_if_unknownBI(TemplateDateModel.TIME)); putBI("trim", new BuiltInsForStringsBasic.trimBI()); - putBI("uncap_first", "uncapFirst", new BuiltInsForStringsBasic.uncap_firstBI()); - putBI("upper_abc", "upperAbc", new BuiltInsForNumbers.upper_abcBI()); - putBI("upper_case", "upperCase", new BuiltInsForStringsBasic.upper_caseBI()); + putBI("uncapFirst", new BuiltInsForStringsBasic.uncap_firstBI()); + putBI("upperAbc", new BuiltInsForNumbers.upper_abcBI()); + putBI("upperCase", new BuiltInsForStringsBasic.upper_caseBI()); putBI("url", new BuiltInsForStringsEncoding.urlBI()); - putBI("url_path", "urlPath", new BuiltInsForStringsEncoding.urlPathBI()); + putBI("urlPath", new BuiltInsForStringsEncoding.urlPathBI()); putBI("values", new BuiltInsForHashes.valuesBI()); - putBI("web_safe", "webSafe", BUILT_INS_BY_NAME.get("html")); // deprecated; use ?html instead - putBI("word_list", "wordList", new BuiltInsForStringsBasic.word_listBI()); + putBI("webSafe", BUILT_INS_BY_NAME.get("html")); // deprecated; use ?html instead + putBI("wordList", new BuiltInsForStringsBasic.word_listBI()); putBI("xhtml", new BuiltInsForStringsEncoding.xhtmlBI()); putBI("xml", new BuiltInsForStringsEncoding.xmlBI()); putBI("matches", new BuiltInsForStringsRegexp.matchesBI()); @@ -295,17 +291,8 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { private static void putBI(String name, ASTExpBuiltIn bi) { BUILT_INS_BY_NAME.put(name, bi); - SNAKE_CASE_NAMES.add(name); - CAMEL_CASE_NAMES.add(name); } - private static void putBI(String nameSnakeCase, String nameCamelCase, ASTExpBuiltIn bi) { - BUILT_INS_BY_NAME.put(nameSnakeCase, bi); - BUILT_INS_BY_NAME.put(nameCamelCase, bi); - SNAKE_CASE_NAMES.add(nameSnakeCase); - CAMEL_CASE_NAMES.add(nameCamelCase); - } - /** * @param target * Left-hand-operand expression @@ -328,32 +315,20 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { Collections.sort(names); char lastLetter = 0; - NamingConvention shownNamingConvention; - { - NamingConvention namingConvention = tokenManager.namingConvention; - shownNamingConvention = namingConvention != NamingConvention.AUTO_DETECT - ? namingConvention : NamingConvention.LEGACY /* [2.4] CAMEL_CASE */; - } - boolean first = true; for (String correctName : names) { - NamingConvention correctNameNamingConvetion = _StringUtil.getIdentifierNamingConvention(correctName); - if (shownNamingConvention == NamingConvention.CAMEL_CASE - ? correctNameNamingConvetion != NamingConvention.LEGACY - : correctNameNamingConvetion != NamingConvention.CAMEL_CASE) { - if (first) { - first = false; - } else { - buf.append(", "); - } + if (first) { + first = false; + } else { + buf.append(", "); + } - char firstChar = correctName.charAt(0); - if (firstChar != lastLetter) { - lastLetter = firstChar; - buf.append('\n'); - } - buf.append(correctName); + char firstChar = correctName.charAt(0); + if (firstChar != lastLetter) { + lastLetter = firstChar; + buf.append('\n'); } + buf.append(correctName); } throw new ParseException(buf.toString(), null, keyTk); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/51dba882/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java index d2304fe..c7afcda 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java @@ -36,73 +36,51 @@ import org.apache.freemarker.core.util._StringUtil; */ final class ASTExpBuiltInVariable extends ASTExpression { - static final String TEMPLATE_NAME_CC = "templateName"; - static final String TEMPLATE_NAME = "template_name"; - static final String MAIN_TEMPLATE_NAME_CC = "mainTemplateName"; - static final String MAIN_TEMPLATE_NAME = "main_template_name"; - static final String CURRENT_TEMPLATE_NAME_CC = "currentTemplateName"; - static final String CURRENT_TEMPLATE_NAME = "current_template_name"; + static final String TEMPLATE_NAME = "templateName"; + static final String MAIN_TEMPLATE_NAME = "mainTemplateName"; + static final String CURRENT_TEMPLATE_NAME = "currentTemplateName"; static final String NAMESPACE = "namespace"; static final String MAIN = "main"; static final String GLOBALS = "globals"; static final String LOCALS = "locals"; - static final String DATA_MODEL_CC = "dataModel"; - static final String DATA_MODEL = "data_model"; + static final String DATA_MODEL = "dataModel"; static final String LANG = "lang"; static final String LOCALE = "locale"; - static final String LOCALE_OBJECT_CC = "localeObject"; - static final String LOCALE_OBJECT = "locale_object"; - static final String CURRENT_NODE_CC = "currentNode"; - static final String CURRENT_NODE = "current_node"; + static final String LOCALE_OBJECT = "localeObject"; + static final String CURRENT_NODE = "currentNode"; static final String NODE = "node"; static final String PASS = "pass"; static final String VARS = "vars"; static final String VERSION = "version"; - static final String INCOMPATIBLE_IMPROVEMENTS_CC = "incompatibleImprovements"; - static final String INCOMPATIBLE_IMPROVEMENTS = "incompatible_improvements"; + static final String INCOMPATIBLE_IMPROVEMENTS = "incompatibleImprovements"; static final String ERROR = "error"; - static final String OUTPUT_ENCODING_CC = "outputEncoding"; - static final String OUTPUT_ENCODING = "output_encoding"; - static final String OUTPUT_FORMAT_CC = "outputFormat"; - static final String OUTPUT_FORMAT = "output_format"; - static final String AUTO_ESC_CC = "autoEsc"; - static final String AUTO_ESC = "auto_esc"; - static final String URL_ESCAPING_CHARSET_CC = "urlEscapingCharset"; - static final String URL_ESCAPING_CHARSET = "url_escaping_charset"; + static final String OUTPUT_ENCODING = "outputEncoding"; + static final String OUTPUT_FORMAT = "outputFormat"; + static final String AUTO_ESC = "autoEsc"; + static final String URL_ESCAPING_CHARSET = "urlEscapingCharset"; static final String NOW = "now"; - static final String[] SPEC_VAR_NAMES = new String[] { - AUTO_ESC_CC, + static final String[] BUILT_IN_VARIABLE_NAMES = new String[] { AUTO_ESC, - CURRENT_NODE_CC, - CURRENT_TEMPLATE_NAME_CC, CURRENT_NODE, CURRENT_TEMPLATE_NAME, - DATA_MODEL_CC, DATA_MODEL, ERROR, GLOBALS, - INCOMPATIBLE_IMPROVEMENTS_CC, INCOMPATIBLE_IMPROVEMENTS, LANG, LOCALE, - LOCALE_OBJECT_CC, LOCALE_OBJECT, LOCALS, MAIN, - MAIN_TEMPLATE_NAME_CC, MAIN_TEMPLATE_NAME, NAMESPACE, NODE, NOW, - OUTPUT_ENCODING_CC, - OUTPUT_FORMAT_CC, OUTPUT_ENCODING, OUTPUT_FORMAT, PASS, - TEMPLATE_NAME_CC, TEMPLATE_NAME, - URL_ESCAPING_CHARSET_CC, URL_ESCAPING_CHARSET, VARS, VERSION @@ -115,23 +93,16 @@ final class ASTExpBuiltInVariable extends ASTExpression { throws ParseException { String name = nameTk.image; this.parseTimeValue = parseTimeValue; - if (Arrays.binarySearch(SPEC_VAR_NAMES, name) < 0) { + if (Arrays.binarySearch(BUILT_IN_VARIABLE_NAMES, name) < 0) { StringBuilder sb = new StringBuilder(); sb.append("Unknown special variable name: "); sb.append(_StringUtil.jQuote(name)).append("."); - NamingConvention shownNamingConvention; - { - NamingConvention namingConvention = tokenManager.namingConvention; - shownNamingConvention = namingConvention != NamingConvention.AUTO_DETECT - ? namingConvention : NamingConvention.LEGACY /* [2.4] CAMEL_CASE */; - } - { String correctName; - if (name.equals("auto_escape") || name.equals("auto_escaping") || name.equals("autoesc")) { - correctName = "auto_esc"; - } else if (name.equals("autoEscape") || name.equals("autoEscaping")) { + if ( + name.equals("auto_escape") || name.equals("auto_escaping") || name.equals("autoEsc") || + name.equals("autoEscape") || name.equals("autoEscaping")) { correctName = "autoEsc"; } else { correctName = null; @@ -144,18 +115,13 @@ final class ASTExpBuiltInVariable extends ASTExpression { sb.append("\nThe allowed special variable names are: "); boolean first = true; - for (final String correctName : SPEC_VAR_NAMES) { - NamingConvention correctNameNamingConvention = _StringUtil.getIdentifierNamingConvention(correctName); - if (shownNamingConvention == NamingConvention.CAMEL_CASE - ? correctNameNamingConvention != NamingConvention.LEGACY - : correctNameNamingConvention != NamingConvention.CAMEL_CASE) { - if (first) { - first = false; - } else { - sb.append(", "); - } - sb.append(correctName); + for (final String correctName : BUILT_IN_VARIABLE_NAMES) { + if (first) { + first = false; + } else { + sb.append(", "); } + sb.append(correctName); } throw new ParseException(sb.toString(), null, nameTk); } @@ -181,7 +147,7 @@ final class ASTExpBuiltInVariable extends ASTExpression { ASTDirMacro.Context ctx = env.getCurrentMacroContext(); return ctx == null ? null : ctx.getLocals(); } - if (name == DATA_MODEL || name == DATA_MODEL_CC) { + if (name == DATA_MODEL) { return env.getDataModel(); } if (name == VARS) { @@ -190,31 +156,30 @@ final class ASTExpBuiltInVariable extends ASTExpression { if (name == LOCALE) { return new SimpleScalar(env.getLocale().toString()); } - if (name == LOCALE_OBJECT || name == LOCALE_OBJECT_CC) { + if (name == LOCALE_OBJECT) { return env.getObjectWrapper().wrap(env.getLocale()); } if (name == LANG) { return new SimpleScalar(env.getLocale().getLanguage()); } - if (name == CURRENT_NODE || name == NODE || name == CURRENT_NODE_CC) { + if (name == CURRENT_NODE || name == NODE) { return env.getCurrentVisitorNode(); } - if (name == MAIN_TEMPLATE_NAME || name == MAIN_TEMPLATE_NAME_CC) { + if (name == MAIN_TEMPLATE_NAME) { return SimpleScalar.newInstanceOrNull(env.getMainTemplate().getLookupName()); } // [FM3] Some of these two should be removed. - if (name == CURRENT_TEMPLATE_NAME || name == CURRENT_TEMPLATE_NAME_CC - || name == TEMPLATE_NAME || name == TEMPLATE_NAME_CC) { + if (name == CURRENT_TEMPLATE_NAME || name == TEMPLATE_NAME) { return SimpleScalar.newInstanceOrNull(env.getCurrentTemplate().getLookupName()); } if (name == PASS) { return ASTDirMacro.DO_NOTHING_MACRO; } - if (name == OUTPUT_ENCODING || name == OUTPUT_ENCODING_CC) { + if (name == OUTPUT_ENCODING) { Charset encoding = env.getOutputEncoding(); return encoding != null ? new SimpleScalar(encoding.name()) : null; } - if (name == URL_ESCAPING_CHARSET || name == URL_ESCAPING_CHARSET_CC) { + if (name == URL_ESCAPING_CHARSET) { Charset charset = env.getURLEscapingCharset(); return charset != null ? new SimpleScalar(charset.name()) : null; } @@ -227,7 +192,7 @@ final class ASTExpBuiltInVariable extends ASTExpression { if (name == VERSION) { return new SimpleScalar(Configuration.getVersion().toString()); } - if (name == INCOMPATIBLE_IMPROVEMENTS || name == INCOMPATIBLE_IMPROVEMENTS_CC) { + if (name == INCOMPATIBLE_IMPROVEMENTS) { return new SimpleScalar(env.getConfiguration().getIncompatibleImprovements().toString()); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/51dba882/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpStringLiteral.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpStringLiteral.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpStringLiteral.java index 82901b2..b66eb1d 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpStringLiteral.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpStringLiteral.java @@ -45,8 +45,8 @@ final class ASTExpStringLiteral extends ASTExpression implements TemplateScalarM /** * @param parentTkMan - * The token source of the template that contains this string literal. As of this writing, we only need - * this to share the {@code namingConvetion} with that. + * The token source of the template that contains this string literal. This is possibly needed to + * inherit tokenizer-level auto-detected settings. */ void parseValue(FMParserTokenManager parentTkMan, OutputFormat outputFormat) throws ParseException { // The way this works is incorrect (the literal should be parsed without un-escaping), http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/51dba882/freemarker-core/src/main/java/org/apache/freemarker/core/ASTImplicitParent.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTImplicitParent.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTImplicitParent.java index 453bcf5..97991a7 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTImplicitParent.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTImplicitParent.java @@ -71,7 +71,7 @@ final class ASTImplicitParent extends ASTElement { @Override String getASTNodeDescriptor() { - return "#mixed_content"; + return "#mixedContent"; } @Override http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/51dba882/freemarker-core/src/main/java/org/apache/freemarker/core/ASTStaticText.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTStaticText.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTStaticText.java index 4353400..1ed4d2d 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTStaticText.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTStaticText.java @@ -72,7 +72,7 @@ final class ASTStaticText extends ASTElement { if (canonical) { String text = new String(this.text); if (unparsed) { - return "<#noparse>" + text + "</#noparse>"; + return "<#noParse>" + text + "</#noParse>"; } return text; } else { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/51dba882/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java index 814b362..e131406 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForSequences.java @@ -702,9 +702,9 @@ class BuiltInsForSequences { throw new _TemplateModelException( startErrorMessage(keyNamesLn, i), (keyNameI == 0 - ? "Sequence items must be hashes when using ?sort_by. " + ? "Sequence items must be hashes when using ?sortBy. " : "The " + _StringUtil.jQuote(keyNames[keyNameI - 1])), - " subvariable is not a hash, so ?sort_by ", + " subvariable is not a hash, so ?sortBy ", "can't proceed with getting the ", new _DelayedJQuote(keyNames[keyNameI]), " subvariable."); @@ -818,12 +818,12 @@ class BuiltInsForSequences { } static Object[] startErrorMessage(int keyNamesLn) { - return new Object[] { (keyNamesLn == 0 ? "?sort" : "?sort_by(...)"), " failed: " }; + return new Object[] { (keyNamesLn == 0 ? "?sort" : "?sortBy(...)"), " failed: " }; } static Object[] startErrorMessage(int keyNamesLn, int index) { return new Object[] { - (keyNamesLn == 0 ? "?sort" : "?sort_by(...)"), + (keyNamesLn == 0 ? "?sort" : "?sortBy(...)"), " failed at sequence index ", Integer.valueOf(index), (index == 0 ? ": " : " (0-based): ") }; } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/51dba882/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java index bcf00c4..e8cd15c 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsBasic.java @@ -89,7 +89,7 @@ class BuiltInsForStringsBasic { @Override TemplateModel _eval(Environment env) throws TemplateException { return new BIMethod(target.evalAndCoerceToStringOrUnsupportedMarkup(env, - "For sequences/collections (lists and such) use \"?seq_contains\" instead.")); + "For sequences/collections (lists and such) use \"?seqContains\" instead.")); } } @@ -221,7 +221,7 @@ class BuiltInsForStringsBasic { @Override TemplateModel _eval(Environment env) throws TemplateException { return new BIMethod(target.evalAndCoerceToStringOrUnsupportedMarkup(env, - "For sequences/collections (lists and such) use \"?seq_index_of\" instead.")); + "For sequences/collections (lists and such) use \"?seqIndexOf\" instead.")); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/51dba882/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java index 80eb9d3..bfb44c6 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForStringsEncoding.java @@ -177,7 +177,7 @@ class BuiltInsForStringsEncoding { + "programmers to fix it. Or, as a last chance, " + "you can set the url_encoding_charset setting in " + "the template, e.g. " - + "<#setting url_escaping_charset='ISO-8859-1'>, or " + + "<#setting urlEscapingCharset='ISO-8859-1'>, or " + "give the charset explicitly to the buit-in, e.g. " + "foo?url('ISO-8859-1')."); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/51dba882/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java index 9f31556..cd3a524 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java @@ -80,7 +80,6 @@ import org.apache.freemarker.core.templateresolver.impl.DefaultTemplateNameForma import org.apache.freemarker.core.templateresolver.impl.DefaultTemplateResolver; import org.apache.freemarker.core.templateresolver.impl.MruCacheStorage; import org.apache.freemarker.core.templateresolver.impl.SoftCacheStorage; -import org.apache.freemarker.core.util.BugException; import org.apache.freemarker.core.util.CaptureOutput; import org.apache.freemarker.core.util.HtmlEscape; import org.apache.freemarker.core.util.NormalizeNewlines; @@ -139,36 +138,6 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc private static final String VERSION_PROPERTIES_PATH = "org/apache/freemarker/core/version.properties"; - private static final String[] SETTING_NAMES_SNAKE_CASE = new String[] { - // Must be sorted alphabetically! - ExtendableBuilder.INCOMPATIBLE_IMPROVEMENTS_KEY_SNAKE_CASE, - ExtendableBuilder.LOCALIZED_TEMPLATE_LOOKUP_KEY_SNAKE_CASE, - ExtendableBuilder.OBJECT_WRAPPER_KEY_SNAKE_CASE, - ExtendableBuilder.REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY_SNAKE_CASE, - ExtendableBuilder.SHARED_VARIABLES_KEY_SNAKE_CASE, - ExtendableBuilder.TEMPLATE_CACHE_STORAGE_KEY_SNAKE_CASE, - ExtendableBuilder.TEMPLATE_CONFIGURATIONS_KEY_SNAKE_CASE, - ExtendableBuilder.TEMPLATE_LOADER_KEY_SNAKE_CASE, - ExtendableBuilder.TEMPLATE_LOOKUP_STRATEGY_KEY_SNAKE_CASE, - ExtendableBuilder.TEMPLATE_NAME_FORMAT_KEY_SNAKE_CASE, - ExtendableBuilder.TEMPLATE_UPDATE_DELAY_KEY_SNAKE_CASE - }; - - private static final String[] SETTING_NAMES_CAMEL_CASE = new String[] { - // Must be sorted alphabetically! - ExtendableBuilder.INCOMPATIBLE_IMPROVEMENTS_KEY_CAMEL_CASE, - ExtendableBuilder.LOCALIZED_TEMPLATE_LOOKUP_KEY_CAMEL_CASE, - ExtendableBuilder.OBJECT_WRAPPER_KEY_CAMEL_CASE, - ExtendableBuilder.REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY_CAMEL_CASE, - ExtendableBuilder.SHARED_VARIABLES_KEY_CAMEL_CASE, - ExtendableBuilder.TEMPLATE_CACHE_STORAGE_KEY_CAMEL_CASE, - ExtendableBuilder.TEMPLATE_CONFIGURATIONS_KEY_CAMEL_CASE, - ExtendableBuilder.TEMPLATE_LOADER_KEY_CAMEL_CASE, - ExtendableBuilder.TEMPLATE_LOOKUP_STRATEGY_KEY_CAMEL_CASE, - ExtendableBuilder.TEMPLATE_NAME_FORMAT_KEY_CAMEL_CASE, - ExtendableBuilder.TEMPLATE_UPDATE_DELAY_KEY_CAMEL_CASE - }; - private static final Map<String, OutputFormat> STANDARD_OUTPUT_FORMATS; static { STANDARD_OUTPUT_FORMATS = new HashMap<>(); @@ -235,7 +204,6 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc private final TemplateLanguage templateLanguage; private final TagSyntax tagSyntax; - private final NamingConvention namingConvention; private final boolean whitespaceStripping; private final AutoEscapingPolicy autoEscapingPolicy; private final OutputFormat outputFormat; @@ -401,7 +369,6 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc templateLanguage = builder.getTemplateLanguage(); tagSyntax = builder.getTagSyntax(); - namingConvention = builder.getNamingConvention(); whitespaceStripping = builder.getWhitespaceStripping(); autoEscapingPolicy = builder.getAutoEscapingPolicy(); outputFormat = builder.getOutputFormat(); @@ -650,6 +617,11 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc } @Override + public boolean isIncompatibleImprovementsSet() { + return true; + } + + @Override public boolean getWhitespaceStripping() { return whitespaceStripping; } @@ -873,20 +845,6 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc } @Override - public NamingConvention getNamingConvention() { - return namingConvention; - } - - /** - * Always {@code true} in {@link Configuration}-s; even if this setting wasn't set in the builder, it gets a default - * value in the {@link Configuration}. - */ - @Override - public boolean isNamingConventionSet() { - return true; - } - - @Override public int getTabSize() { return tabSize; } @@ -1354,7 +1312,7 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc * not {@code null}). This parameter also drives localized template lookup. Assuming that you have * specified {@code en_US} as the locale and {@code myTemplate.ftl} as the name of the template, and the * default {@link TemplateLookupStrategy} is used and - * {@code #setLocalizedTemplateLookup(boolean) localized_template_lookup} is {@code true}, FreeMarker will first try to + * {@code #setLocalizedTemplateLookup(boolean) localizedTemplateLookup} is {@code true}, FreeMarker will first try to * 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 @@ -1406,7 +1364,7 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc String msg; if (tl == null) { msg = "Don't know where to load template " + _StringUtil.jQuote(name) - + " from because the \"template_loader\" FreeMarker " + + " from because the \"templateLoader\" FreeMarker " + "setting wasn't set (Configuration.setTemplateLoader), so it's null."; } else { final String missingTempNormName = maybeTemp.getMissingTemplateNormalizedName(); @@ -1544,67 +1502,20 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc } /** - * Same as {@link #getSupportedBuiltInNames(NamingConvention)} with argument {@link #getNamingConvention()}. - */ - public Set getSupportedBuiltInNames() { - return getSupportedBuiltInNames(getNamingConvention()); - } - - /** * Returns the names of the supported "built-ins". These are the ({@code expr?builtin_name}-like things). As of this * writing, this information doesn't depend on the configuration options, so it could be a static method, but * to be future-proof, it's an instance method. - * - * @param namingConvention - * One of {@link NamingConvention#AUTO_DETECT}, - * {@link NamingConvention#LEGACY}, and - * {@link NamingConvention#CAMEL_CASE}. If it's - * {@link NamingConvention#AUTO_DETECT} then the union - * of the names in all the naming conventions is returned. */ - public Set<String> getSupportedBuiltInNames(NamingConvention namingConvention) { - Set<String> names; - if (namingConvention == NamingConvention.AUTO_DETECT) { - names = ASTExpBuiltIn.BUILT_INS_BY_NAME.keySet(); - } else if (namingConvention == NamingConvention.LEGACY) { - names = ASTExpBuiltIn.SNAKE_CASE_NAMES; - } else if (namingConvention == NamingConvention.CAMEL_CASE) { - names = ASTExpBuiltIn.CAMEL_CASE_NAMES; - } else { - throw new BugException("Unsupported naming convention constant: " + namingConvention); - } - return Collections.unmodifiableSet(names); + public Set<String> getSupportedBuiltInNames() { + return Collections.unmodifiableSet(ASTExpBuiltIn.BUILT_INS_BY_NAME.keySet()); } /** - * Same as {@link #getSupportedBuiltInDirectiveNames(NamingConvention)} with argument - * {@link #getNamingConvention()}. - */ - public Set getSupportedBuiltInDirectiveNames() { - return getSupportedBuiltInDirectiveNames(getNamingConvention()); - } - - /** * Returns the names of the directives that are predefined by FreeMarker. These are the things that you call like * <tt><#directiveName ...></tt>. - * - * @param namingConvention - * One of {@link NamingConvention#AUTO_DETECT}, - * {@link NamingConvention#LEGACY}, and - * {@link NamingConvention#CAMEL_CASE}. If it's - * {@link NamingConvention#AUTO_DETECT} then the union - * of the names in all the naming conventions is returned. */ - public Set<String> getSupportedBuiltInDirectiveNames(NamingConvention namingConvention) { - if (namingConvention == NamingConvention.AUTO_DETECT) { - return ASTDirective.ALL_BUILT_IN_DIRECTIVE_NAMES; - } else if (namingConvention == NamingConvention.LEGACY) { - return ASTDirective.LEGACY_BUILT_IN_DIRECTIVE_NAMES; - } else if (namingConvention == NamingConvention.CAMEL_CASE) { - return ASTDirective.CAMEL_CASE_BUILT_IN_DIRECTIVE_NAMES; - } else { - throw new BugException("Unsupported naming convention constant: " + namingConvention); - } + public Set<String> getSupportedBuiltInDirectiveNames() { + return ASTDirective.BUILT_IN_DIRECTIVE_NAMES; } private static String getRequiredVersionProperty(Properties vp, String properyName) { @@ -1626,82 +1537,34 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc extends MutableParsingAndProcessingConfiguration<SelfT> implements TopLevelConfiguration, org.apache.freemarker.core.util.CommonBuilder<Configuration> { - /** Legacy, snake case ({@code like_this}) variation of the setting name. */ - public static final String LOCALIZED_TEMPLATE_LOOKUP_KEY_SNAKE_CASE = "localized_template_lookup"; - /** Alias to the {@code ..._SNAKE_CASE} variation due to backward compatibility constraints. */ - public static final String LOCALIZED_TEMPLATE_LOOKUP_KEY = LOCALIZED_TEMPLATE_LOOKUP_KEY_SNAKE_CASE; - /** Modern, camel case ({@code likeThis}) variation of the setting name. */ - public static final String LOCALIZED_TEMPLATE_LOOKUP_KEY_CAMEL_CASE = "localizedTemplateLookup"; - - /** Legacy, snake case ({@code like_this}) variation of the setting name. */ - public static final String REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY_SNAKE_CASE = "registered_custom_output_formats"; - /** Alias to the {@code ..._SNAKE_CASE} variation due to backward compatibility constraints. */ - public static final String REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY = REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY_SNAKE_CASE; - /** Modern, camel case ({@code likeThis}) variation of the setting name. */ - public static final String REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY_CAMEL_CASE = "registeredCustomOutputFormats"; - - /** Legacy, snake case ({@code like_this}) variation of the setting name. */ - public static final String TEMPLATE_CACHE_STORAGE_KEY_SNAKE_CASE = "template_cache_storage"; - /** Alias to the {@code ..._SNAKE_CASE} variation due to backward compatibility constraints. */ - public static final String TEMPLATE_CACHE_STORAGE_KEY = TEMPLATE_CACHE_STORAGE_KEY_SNAKE_CASE; - /** Modern, camel case ({@code likeThis}) variation of the setting name. */ - public static final String TEMPLATE_CACHE_STORAGE_KEY_CAMEL_CASE = "templateCacheStorage"; - - /** Legacy, snake case ({@code like_this}) variation of the setting name. */ - public static final String TEMPLATE_UPDATE_DELAY_KEY_SNAKE_CASE = "template_update_delay"; - /** Alias to the {@code ..._SNAKE_CASE} variation due to backward compatibility constraints. */ - public static final String TEMPLATE_UPDATE_DELAY_KEY = TEMPLATE_UPDATE_DELAY_KEY_SNAKE_CASE; - /** Modern, camel case ({@code likeThis}) variation of the setting name. */ - public static final String TEMPLATE_UPDATE_DELAY_KEY_CAMEL_CASE = "templateUpdateDelay"; - - /** Legacy, snake case ({@code like_this}) variation of the setting name. */ - public static final String TEMPLATE_LOADER_KEY_SNAKE_CASE = "template_loader"; - /** Alias to the {@code ..._SNAKE_CASE} variation due to backward compatibility constraints. */ - public static final String TEMPLATE_LOADER_KEY = TEMPLATE_LOADER_KEY_SNAKE_CASE; - /** Modern, camel case ({@code likeThis}) variation of the setting name. */ - public static final String TEMPLATE_LOADER_KEY_CAMEL_CASE = "templateLoader"; - - /** Legacy, snake case ({@code like_this}) variation of the setting name. */ - public static final String TEMPLATE_LOOKUP_STRATEGY_KEY_SNAKE_CASE = "template_lookup_strategy"; - /** Alias to the {@code ..._SNAKE_CASE} variation due to backward compatibility constraints. */ - public static final String TEMPLATE_LOOKUP_STRATEGY_KEY = TEMPLATE_LOOKUP_STRATEGY_KEY_SNAKE_CASE; - /** Modern, camel case ({@code likeThis}) variation of the setting name. */ - public static final String TEMPLATE_LOOKUP_STRATEGY_KEY_CAMEL_CASE = "templateLookupStrategy"; - - /** Legacy, snake case ({@code like_this}) variation of the setting name. */ - public static final String TEMPLATE_NAME_FORMAT_KEY_SNAKE_CASE = "template_name_format"; - /** Alias to the {@code ..._SNAKE_CASE} variation due to backward compatibility constraints. */ - public static final String TEMPLATE_NAME_FORMAT_KEY = TEMPLATE_NAME_FORMAT_KEY_SNAKE_CASE; - /** Modern, camel case ({@code likeThis}) variation of the setting name. */ - public static final String TEMPLATE_NAME_FORMAT_KEY_CAMEL_CASE = "templateNameFormat"; - - /** Legacy, snake case ({@code like_this}) variation of the setting name. */ - public static final String SHARED_VARIABLES_KEY_SNAKE_CASE = "shared_variables"; - /** Alias to the {@code ..._SNAKE_CASE} variation due to backward compatibility constraints. */ - public static final String SHARED_VARIABLES_KEY = SHARED_VARIABLES_KEY_SNAKE_CASE; - /** Modern, camel case ({@code likeThis}) variation of the setting name. */ - public static final String SHARED_VARIABLES_KEY_CAMEL_CASE = "sharedVariables"; - - /** Legacy, snake case ({@code like_this}) variation of the setting name. */ - public static final String TEMPLATE_CONFIGURATIONS_KEY_SNAKE_CASE = "template_configurations"; - /** Alias to the {@code ..._SNAKE_CASE} variation. */ - public static final String TEMPLATE_CONFIGURATIONS_KEY = TEMPLATE_CONFIGURATIONS_KEY_SNAKE_CASE; - /** Modern, camel case ({@code likeThis}) variation of the setting name. */ - public static final String TEMPLATE_CONFIGURATIONS_KEY_CAMEL_CASE = "templateConfigurations"; - - /** Legacy, snake case ({@code like_this}) variation of the setting name. */ - public static final String OBJECT_WRAPPER_KEY_SNAKE_CASE = "object_wrapper"; - /** Modern, camel case ({@code likeThis}) variation of the setting name. */ - public static final String OBJECT_WRAPPER_KEY_CAMEL_CASE = "objectWrapper"; - /** Alias to the {@code ..._SNAKE_CASE} variation due to backward compatibility constraints. */ - public static final String OBJECT_WRAPPER_KEY = OBJECT_WRAPPER_KEY_SNAKE_CASE; - - /** Legacy, snake case ({@code like_this}) variation of the setting name. */ - public static final String INCOMPATIBLE_IMPROVEMENTS_KEY_SNAKE_CASE = "incompatible_improvements"; - /** Alias to the {@code ..._SNAKE_CASE} variation due to backward compatibility constraints. */ - public static final String INCOMPATIBLE_IMPROVEMENTS_KEY = INCOMPATIBLE_IMPROVEMENTS_KEY_SNAKE_CASE; - /** Modern, camel case ({@code likeThis}) variation of the setting name. */ - public static final String INCOMPATIBLE_IMPROVEMENTS_KEY_CAMEL_CASE = "incompatibleImprovements"; + public static final String LOCALIZED_TEMPLATE_LOOKUP_KEY = "localizedTemplateLookup"; + public static final String REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY = "registeredCustomOutputFormats"; + public static final String TEMPLATE_RESOLVER_KEY = "templateResolver"; + public static final String TEMPLATE_CACHE_STORAGE_KEY = "templateCacheStorage"; + public static final String TEMPLATE_UPDATE_DELAY_KEY = "templateUpdateDelay"; + public static final String TEMPLATE_LOADER_KEY = "templateLoader"; + public static final String TEMPLATE_LOOKUP_STRATEGY_KEY = "templateLookupStrategy"; + public static final String TEMPLATE_NAME_FORMAT_KEY = "templateNameFormat"; + public static final String SHARED_VARIABLES_KEY = "sharedVariables"; + public static final String TEMPLATE_CONFIGURATIONS_KEY = "templateConfigurations"; + public static final String OBJECT_WRAPPER_KEY = "objectWrapper"; + + private static final _UnmodifiableCompositeSet<String> SETTING_NAMES = new _UnmodifiableCompositeSet<>( + MutableParsingAndProcessingConfiguration.getSettingNames(), + new _SortedArraySet<>( + // Must be sorted alphabetically! + ExtendableBuilder.LOCALIZED_TEMPLATE_LOOKUP_KEY, + ExtendableBuilder.OBJECT_WRAPPER_KEY, + ExtendableBuilder.REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY, + ExtendableBuilder.SHARED_VARIABLES_KEY, + ExtendableBuilder.TEMPLATE_CACHE_STORAGE_KEY, + ExtendableBuilder.TEMPLATE_CONFIGURATIONS_KEY, + ExtendableBuilder.TEMPLATE_LOADER_KEY, + ExtendableBuilder.TEMPLATE_LOOKUP_STRATEGY_KEY, + ExtendableBuilder.TEMPLATE_NAME_FORMAT_KEY, + ExtendableBuilder.TEMPLATE_RESOLVER_KEY, + ExtendableBuilder.TEMPLATE_UPDATE_DELAY_KEY + )); private Version incompatibleImprovements = Configuration.VERSION_3_0_0; @@ -1754,11 +1617,9 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc public void setSetting(String name, String value) throws ConfigurationException { boolean nameUnhandled = false; try { - if (LOCALIZED_TEMPLATE_LOOKUP_KEY_SNAKE_CASE.equals(name) - || LOCALIZED_TEMPLATE_LOOKUP_KEY_CAMEL_CASE.equals(name)) { + if (LOCALIZED_TEMPLATE_LOOKUP_KEY.equals(name)) { setLocalizedTemplateLookup(_StringUtil.getYesNo(value)); - } else if (REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY_SNAKE_CASE.equals(name) - || REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY_CAMEL_CASE.equals(name)) { + } else if (REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY.equals(name)) { List list = (List) _ObjectBuilderSettingEvaluator.eval( value, List.class, true, _SettingEvaluationEnvironment.getCurrent()); for (Object item : list) { @@ -1768,7 +1629,7 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc } } setRegisteredCustomOutputFormats(list); - } else if (TEMPLATE_CACHE_STORAGE_KEY_SNAKE_CASE.equals(name) || TEMPLATE_CACHE_STORAGE_KEY_CAMEL_CASE.equals(name)) { + } else if (TEMPLATE_CACHE_STORAGE_KEY.equals(name)) { if (value.equalsIgnoreCase(DEFAULT_VALUE)) { unsetTemplateCacheStorage(); } if (value.indexOf('.') == -1) { @@ -1806,8 +1667,7 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc setTemplateCacheStorage((CacheStorage) _ObjectBuilderSettingEvaluator.eval( value, CacheStorage.class, false, _SettingEvaluationEnvironment.getCurrent())); } - } else if (TEMPLATE_UPDATE_DELAY_KEY_SNAKE_CASE.equals(name) - || TEMPLATE_UPDATE_DELAY_KEY_CAMEL_CASE.equals(name)) { + } else if (TEMPLATE_UPDATE_DELAY_KEY.equals(name)) { final String valueWithoutUnit; final String unit; int numberEnd = 0; @@ -1840,8 +1700,7 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc } setTemplateUpdateDelayMilliseconds(parsedValue * multipier); - } else if (SHARED_VARIABLES_KEY_SNAKE_CASE.equals(name) - || SHARED_VARIABLES_KEY_CAMEL_CASE.equals(name)) { + } else if (SHARED_VARIABLES_KEY.equals(name)) { Map<?, ?> sharedVariables = (Map<?, ?>) _ObjectBuilderSettingEvaluator.eval( value, Map.class, false, _SettingEvaluationEnvironment.getCurrent()); for (Object key : sharedVariables.keySet()) { @@ -1852,42 +1711,48 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc } } setSharedVariables((Map) sharedVariables); - } else if (INCOMPATIBLE_IMPROVEMENTS_KEY_SNAKE_CASE.equals(name) - || INCOMPATIBLE_IMPROVEMENTS_KEY_CAMEL_CASE.equals(name)) { + } else if (INCOMPATIBLE_IMPROVEMENTS_KEY.equals(name)) { setIncompatibleImprovements(new Version(value)); - } else if (TEMPLATE_LOADER_KEY_SNAKE_CASE.equals(name) || TEMPLATE_LOADER_KEY_CAMEL_CASE.equals(name)) { + } else if (TEMPLATE_RESOLVER_KEY.equals(name)) { + if (value.equalsIgnoreCase(DEFAULT_VALUE)) { + unsetTemplateResolver(); + } else { + setTemplateResolver((TemplateResolver) _ObjectBuilderSettingEvaluator.eval( + value, TemplateResolver.class, false, + _SettingEvaluationEnvironment.getCurrent())); + } + } else if (TEMPLATE_LOADER_KEY.equals(name)) { if (value.equalsIgnoreCase(DEFAULT_VALUE)) { unsetTemplateLoader(); } else { setTemplateLoader((TemplateLoader) _ObjectBuilderSettingEvaluator.eval( - value, TemplateLoader.class, true, _SettingEvaluationEnvironment.getCurrent())); + value, TemplateLoader.class, true, + _SettingEvaluationEnvironment.getCurrent())); } - } else if (TEMPLATE_LOOKUP_STRATEGY_KEY_SNAKE_CASE.equals(name) - || TEMPLATE_LOOKUP_STRATEGY_KEY_CAMEL_CASE.equals(name)) { + } else if (TEMPLATE_LOOKUP_STRATEGY_KEY.equals(name)) { if (value.equalsIgnoreCase(DEFAULT_VALUE)) { unsetTemplateLookupStrategy(); } else { setTemplateLookupStrategy((TemplateLookupStrategy) _ObjectBuilderSettingEvaluator.eval( - value, TemplateLookupStrategy.class, false, _SettingEvaluationEnvironment.getCurrent())); + value, TemplateLookupStrategy.class, false, + _SettingEvaluationEnvironment.getCurrent())); } - } else if (TEMPLATE_NAME_FORMAT_KEY_SNAKE_CASE.equals(name) - || TEMPLATE_NAME_FORMAT_KEY_CAMEL_CASE.equals(name)) { + } else if (TEMPLATE_NAME_FORMAT_KEY.equals(name)) { if (value.equalsIgnoreCase(DEFAULT_VALUE)) { unsetTemplateNameFormat(); } else { throw new InvalidSettingValueException(name, value, "No such predefined template name format"); } - } else if (TEMPLATE_CONFIGURATIONS_KEY_SNAKE_CASE.equals(name) - || TEMPLATE_CONFIGURATIONS_KEY_CAMEL_CASE.equals(name)) { + } else if (TEMPLATE_CONFIGURATIONS_KEY.equals(name)) { if (value.equals(NULL_VALUE)) { setTemplateConfigurations(null); } else { setTemplateConfigurations((TemplateConfigurationFactory) _ObjectBuilderSettingEvaluator.eval( - value, TemplateConfigurationFactory.class, false, _SettingEvaluationEnvironment.getCurrent())); + value, TemplateConfigurationFactory.class, false, + _SettingEvaluationEnvironment.getCurrent())); } - } else if (OBJECT_WRAPPER_KEY_SNAKE_CASE.equals(name) - || OBJECT_WRAPPER_KEY_CAMEL_CASE.equals(name)) { + } else if (OBJECT_WRAPPER_KEY.equals(name)) { if (DEFAULT_VALUE.equalsIgnoreCase(value)) { this.unsetObjectWrapper(); } else if ("restricted".equalsIgnoreCase(value)) { @@ -1911,24 +1776,18 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc } /** - * Returns the valid {@link Configuration} setting names. Naturally, this includes the {@link MutableProcessingConfiguration} setting - * names too. + * Returns the valid {@link Configuration} setting names. Naturally, this includes the + * {@link MutableProcessingConfiguration} setting names too. * - * @param camelCase - * If we want the setting names with camel case naming convention, or with snake case (legacy) naming - * convention. - * - * @see MutableProcessingConfiguration#getSettingNames(boolean) + * @see MutableProcessingConfiguration#getSettingNames() */ - public static Set<String> getSettingNames(boolean camelCase) { - return new _UnmodifiableCompositeSet<>( - MutableParsingAndProcessingConfiguration.getSettingNames(camelCase), - new _SortedArraySet<>(camelCase ? SETTING_NAMES_CAMEL_CASE : SETTING_NAMES_SNAKE_CASE)); + public static Set<String> getSettingNames() { + return SETTING_NAMES; } @Override protected Version getRemovalVersionForUnknownSetting(String name) { - if (name.equals("strictSyntax") || name.equals("strict_syntax")) { + if (name.equals("strictSyntax") || name.equalsIgnoreCase("strict_syntax")) { return Configuration.VERSION_3_0_0; } return super.getRemovalVersionForUnknownSetting(name); @@ -1936,37 +1795,39 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc @Override protected String getCorrectedNameForUnknownSetting(String name) { - if ("encoding".equals(name) || "default_encoding".equals(name) || "charset".equals(name) - || "default_charset".equals(name)) { - // [2.4] Default might changes to camel-case - return SOURCE_ENCODING_KEY; - } - if ("defaultEncoding".equalsIgnoreCase(name) || "defaultCharset".equals(name)) { - return SOURCE_ENCODING_KEY_CAMEL_CASE; - } - if (name.equals("incompatible_enhancements")) { - return INCOMPATIBLE_IMPROVEMENTS_KEY_SNAKE_CASE; - } - if (name.equals("incompatibleEnhancements")) { - return INCOMPATIBLE_IMPROVEMENTS_KEY_CAMEL_CASE; - } - if (name.equals("cacheStorage")) { - return TEMPLATE_CACHE_STORAGE_KEY_CAMEL_CASE; - } - if (name.equals("cache_storage")) { - return TEMPLATE_CACHE_STORAGE_KEY_SNAKE_CASE; - } - if (name.equals("localizedLookup")) { - return LOCALIZED_TEMPLATE_LOOKUP_KEY_CAMEL_CASE; - } - if (name.equals("localized_lookup")) { - return LOCALIZED_TEMPLATE_LOOKUP_KEY_SNAKE_CASE; - } - if ("TemplateUpdateInterval".equalsIgnoreCase(name)) { - return TEMPLATE_UPDATE_DELAY_KEY; + switch(name.toLowerCase()) { + case "encoding": + case "default_encoding": + case "charset": + case "default_charset": + case "defaultencoding": + case "defaultcharset": + case "sourceencoding": + case "source_encoding": + return SOURCE_ENCODING_KEY; + case "incompatible_enhancements": + case "incompatibleenhancements": + case "incompatibleimprovements": + case "incompatibleImprovements": + return INCOMPATIBLE_IMPROVEMENTS_KEY; + case "cachestorage": + case "cache_storage": + case "templatecachestorage": + case "template_cache_storage": + return TEMPLATE_CACHE_STORAGE_KEY; + case "localizedlookup": + case "localized_lookup": + case "localizedtemplatelookup": + case "localized_template_lookup": + return LOCALIZED_TEMPLATE_LOOKUP_KEY; + case "templateupdateinterval": + case "templateupdatedelay": + case "template_update_delay": + return TEMPLATE_UPDATE_DELAY_KEY; + default: + return super.getCorrectedNameForUnknownSetting(name); } - return super.getCorrectedNameForUnknownSetting(name); } @Override @@ -2503,13 +2364,13 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc } @Override - protected NamingConvention getDefaultNamingConvention() { - return NamingConvention.AUTO_DETECT; + public Version getIncompatibleImprovements() { + return incompatibleImprovements; } @Override - public Version getIncompatibleImprovements() { - return incompatibleImprovements; + public boolean isIncompatibleImprovementsSet() { + return true; } /** http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/51dba882/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java index fd9e35c..e0f6118 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java @@ -1789,7 +1789,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen settingValue = getDateFormat(); break; case TemplateDateModel.DATETIME: - settingName = MutableProcessingConfiguration.DATETIME_FORMAT_KEY; + settingName = MutableProcessingConfiguration.DATE_TIME_FORMAT_KEY; settingValue = getDateTimeFormat(); break; default: