http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/MessageUtils.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/MessageUtils.java b/freemarker-core/src/main/java/org/apache/freemarker/core/MessageUtils.java new file mode 100644 index 0000000..3ce73b8 --- /dev/null +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/MessageUtils.java @@ -0,0 +1,344 @@ +/* + * 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 org.apache.freemarker.core; + +import java.util.ArrayList; + +import org.apache.freemarker.core.model.TemplateModel; +import org.apache.freemarker.core.model.TemplateModelException; +import org.apache.freemarker.core.util._StringUtils; +import org.apache.freemarker.core.valueformat.TemplateDateFormat; +import org.apache.freemarker.core.valueformat.TemplateNumberFormat; +import org.apache.freemarker.core.valueformat.TemplateValueFormatException; +import org.apache.freemarker.core.valueformat.UnknownDateTypeFormattingUnsupportedException; + +/** + * Utilities for creating error messages (and other messages). + */ +class MessageUtils { + + static final String UNKNOWN_DATE_TO_STRING_ERROR_MESSAGE + = "Can't convert the date-like value to string because it isn't " + + "known if it's a date (no time part), time or date-time value."; + + static final String UNKNOWN_DATE_TYPE_ERROR_TIP = + "Use ?date, ?time, or ?dateTime to tell FreeMarker the exact type."; + + static final Object[] UNKNOWN_DATE_TO_STRING_TIPS = { + UNKNOWN_DATE_TYPE_ERROR_TIP, + "If you need a particular format only once, use ?string(pattern), like ?string('dd.MM.yyyy HH:mm:ss'), " + + "to specify which fields to display. " + }; + + static final String FM3_SNAKE_CASE = "\nThe name contains '_' character, but since FreeMarker 3 names defined " + + "by the template language use camel case (e.g. someExampleName)."; + + static final String EMBEDDED_MESSAGE_BEGIN = "---begin-message---\n"; + + static final String EMBEDDED_MESSAGE_END = "\n---end-message---"; + + static final String ERROR_MESSAGE_HR = "----"; + + // Can't be instantiated + private MessageUtils() { } + + static String formatLocationForSimpleParsingError(Template template, int line, int column) { + return formatLocation("in", template, line, column); + } + + static String formatLocationForSimpleParsingError(String templateSourceOrLookupName, int line, int column) { + return formatLocation("in", templateSourceOrLookupName, line, column); + } + + static String formatLocationForEvaluationError(Template template, int line, int column) { + return formatLocation("at", template, line, column); + } + + static String formatLocationForEvaluationError(ASTDirMacroOrFunction macro, int line, int column) { + Template t = macro.getTemplate(); + return formatLocation("at", t != null ? t.getSourceOrLookupName() : null, macro.getName(), macro.isFunction(), + line, column); + } + + private static String formatLocation(String preposition, Template template, int line, int column) { + return formatLocation(preposition, template != null ? template.getSourceOrLookupName() : null, line, column); + } + + private static String formatLocation(String preposition, String templateSourceName, int line, int column) { + return formatLocation( + preposition, templateSourceName, + null, false, + line, column); + } + + private static String formatLocation( + String preposition, String templateSourceName, + String macroOrFuncName, boolean isFunction, + int line, int column) { + String templateDesc; + if (line < 0) { + templateDesc = "?eval-ed string"; + macroOrFuncName = null; + } else { + templateDesc = templateSourceName != null + ? "template " + _StringUtils.jQuoteNoXSS(templateSourceName) + : "nameless template"; + } + return "in " + templateDesc + + (macroOrFuncName != null + ? " in " + (isFunction ? "function " : "macro ") + _StringUtils.jQuote(macroOrFuncName) + : "") + + " " + + preposition + " " + formatPosition(line, column); + } + + static String formatPosition(int line, int column) { + return "line " + (line >= 0 ? line : line - (ASTNode.RUNTIME_EVAL_LINE_DISPLACEMENT - 1)) + + ", column " + column; + } + + /** + * Returns a single line string that is no longer than {@code maxLength}. + * If will truncate the string at line-breaks too. + * The truncation is always signaled with a a {@code "..."} at the end of the result string. + */ + static String shorten(String s, int maxLength) { + if (maxLength < 5) maxLength = 5; + + boolean isTruncated = false; + + int brIdx = s.indexOf('\n'); + if (brIdx != -1) { + s = s.substring(0, brIdx); + isTruncated = true; + } + brIdx = s.indexOf('\r'); + if (brIdx != -1) { + s = s.substring(0, brIdx); + isTruncated = true; + } + + if (s.length() > maxLength) { + s = s.substring(0, maxLength - 3); + isTruncated = true; + } + + if (!isTruncated) { + return s; + } else { + if (s.endsWith(".")) { + if (s.endsWith("..")) { + if (s.endsWith("...")) { + return s; + } else { + return s + "."; + } + } else { + return s + ".."; + } + } else { + return s + "..."; + } + } + } + + static StringBuilder appendExpressionAsUntearable(StringBuilder sb, ASTExpression argExp) { + boolean needParen = + !(argExp instanceof ASTExpNumberLiteral) + && !(argExp instanceof ASTExpStringLiteral) + && !(argExp instanceof ASTExpBooleanLiteral) + && !(argExp instanceof ASTExpListLiteral) + && !(argExp instanceof ASTExpHashLiteral) + && !(argExp instanceof ASTExpVariable) + && !(argExp instanceof ASTExpDot) + && !(argExp instanceof ASTExpDynamicKeyName) + && !(argExp instanceof ASTExpFunctionCall) + && !(argExp instanceof ASTExpBuiltIn); + if (needParen) sb.append('('); + sb.append(argExp.getCanonicalForm()); + if (needParen) sb.append(')'); + return sb; + } + + static TemplateModelException newArgCntError(String methodName, int argCnt, int expectedCnt) { + return newArgCntError(methodName, argCnt, expectedCnt, expectedCnt); + } + + static TemplateModelException newArgCntError(String methodName, int argCnt, int minCnt, int maxCnt) { + ArrayList/*<Object>*/ desc = new ArrayList(20); + + desc.add(methodName); + + desc.add("("); + if (maxCnt != 0) desc.add("..."); + desc.add(") expects "); + + if (minCnt == maxCnt) { + if (maxCnt == 0) { + desc.add("no"); + } else { + desc.add(Integer.valueOf(maxCnt)); + } + } else if (maxCnt - minCnt == 1) { + desc.add(Integer.valueOf(minCnt)); + desc.add(" or "); + desc.add(Integer.valueOf(maxCnt)); + } else { + desc.add(Integer.valueOf(minCnt)); + if (maxCnt != Integer.MAX_VALUE) { + desc.add(" to "); + desc.add(Integer.valueOf(maxCnt)); + } else { + desc.add(" or more (unlimited)"); + } + } + desc.add(" argument"); + if (maxCnt > 1) desc.add("s"); + + desc.add(" but has received "); + if (argCnt == 0) { + desc.add("none"); + } else { + desc.add(Integer.valueOf(argCnt)); + } + desc.add("."); + + return new _TemplateModelException(desc.toArray()); + } + + static TemplateModelException newMethodArgMustBeStringException(String methodName, int argIdx, TemplateModel arg) { + return newMethodArgUnexpectedTypeException(methodName, argIdx, "string", arg); + } + + static TemplateModelException newMethodArgMustBeNumberException(String methodName, int argIdx, TemplateModel arg) { + return newMethodArgUnexpectedTypeException(methodName, argIdx, "number", arg); + } + + static TemplateModelException newMethodArgMustBeBooleanException(String methodName, int argIdx, TemplateModel arg) { + return newMethodArgUnexpectedTypeException(methodName, argIdx, "boolean", arg); + } + + static TemplateModelException newMethodArgMustBeExtendedHashException( + String methodName, int argIdx, TemplateModel arg) { + return newMethodArgUnexpectedTypeException(methodName, argIdx, "extended hash", arg); + } + + static TemplateModelException newMethodArgMustBeSequenceException( + String methodName, int argIdx, TemplateModel arg) { + return newMethodArgUnexpectedTypeException(methodName, argIdx, "sequence", arg); + } + + static TemplateModelException newMethodArgMustBeSequenceOrCollectionException( + String methodName, int argIdx, TemplateModel arg) { + return newMethodArgUnexpectedTypeException(methodName, argIdx, "sequence or collection", arg); + } + + static TemplateModelException newMethodArgUnexpectedTypeException( + String methodName, int argIdx, String expectedType, TemplateModel arg) { + return new _TemplateModelException( + methodName, "(...) expects ", new _DelayedAOrAn(expectedType), " as argument #", Integer.valueOf(argIdx + 1), + ", but received ", new _DelayedAOrAn(new _DelayedFTLTypeDescription(arg)), "."); + } + + /** + * The type of the argument was good, but it's value wasn't. + */ + static TemplateModelException newMethodArgInvalidValueException( + String methodName, int argIdx, Object... details) { + return new _TemplateModelException( + methodName, "(...) argument #", Integer.valueOf(argIdx + 1), + " had invalid value: ", details); + } + + /** + * The type of the argument was good, but the values of two or more arguments are inconsistent with each other. + */ + static TemplateModelException newMethodArgsInvalidValueException( + String methodName, Object... details) { + return new _TemplateModelException(methodName, "(...) arguments have invalid value: ", details); + } + + static TemplateException newInstantiatingClassNotAllowedException(String className, Environment env) { + return new _MiscTemplateException(env, + "Instantiating ", className, " is not allowed in the template for security reasons."); + } + + static TemplateModelException newCantFormatUnknownTypeDateException( + ASTExpression dateSourceExpr, UnknownDateTypeFormattingUnsupportedException cause) { + return new _TemplateModelException(cause, null, new _ErrorDescriptionBuilder( + MessageUtils.UNKNOWN_DATE_TO_STRING_ERROR_MESSAGE) + .blame(dateSourceExpr) + .tips(MessageUtils.UNKNOWN_DATE_TO_STRING_TIPS)); + } + + static TemplateException newCantFormatDateException(TemplateDateFormat format, ASTExpression dataSrcExp, + TemplateValueFormatException e, boolean useTempModelExc) { + _ErrorDescriptionBuilder desc = new _ErrorDescriptionBuilder( + "Failed to format date/time/dateTime with format ", new _DelayedJQuote(format.getDescription()), ": ", + e.getMessage()) + .blame(dataSrcExp); + return useTempModelExc + ? new _TemplateModelException(e, null, desc) + : new _MiscTemplateException(e, null, desc); + } + + static TemplateException newCantFormatNumberException(TemplateNumberFormat format, ASTExpression dataSrcExp, + TemplateValueFormatException e, boolean useTempModelExc) { + _ErrorDescriptionBuilder desc = new _ErrorDescriptionBuilder( + "Failed to format number with format ", new _DelayedJQuote(format.getDescription()), ": ", + e.getMessage()) + .blame(dataSrcExp); + return useTempModelExc + ? new _TemplateModelException(e, null, desc) + : new _MiscTemplateException(e, null, desc); + } + + /** + * @return "a" or "an" or "a(n)" (or "" for empty string) for an FTL type name + */ + static String getAOrAn(String s) { + if (s == null) return null; + if (s.length() == 0) return ""; + + char fc = Character.toLowerCase(s.charAt(0)); + if (fc == 'a' || fc == 'e' || fc == 'i') { + return "an"; + } else if (fc == 'h') { + String ls = s.toLowerCase(); + if (ls.startsWith("has") || ls.startsWith("hi")) { + return "a"; + } else if (ls.startsWith("ht")) { + return "an"; + } else { + return "a(n)"; + } + } else if (fc == 'u' || fc == 'o') { + return "a(n)"; + } else { + char sc = (s.length() > 1) ? s.charAt(1) : '\0'; + if (fc == 'x' && !(sc == 'a' || sc == 'e' || sc == 'i' || sc == 'a' || sc == 'o' || sc == 'u')) { + return "an"; + } else { + return "a"; + } + } + } + +}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/MiscUtil.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/MiscUtil.java b/freemarker-core/src/main/java/org/apache/freemarker/core/MiscUtil.java deleted file mode 100644 index 35d5943..0000000 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/MiscUtil.java +++ /dev/null @@ -1,69 +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 org.apache.freemarker.core; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -/** - * Utilities that didn't fit elsewhere. - */ -class MiscUtil { - - // Can't be instatiated - private MiscUtil() { } - - static final String C_FALSE = "false"; - static final String C_TRUE = "true"; - - /** - * Returns the map entries in source code order of the ASTExpression values. - */ - static List/*Map.Entry*/ sortMapOfExpressions(Map/*<?, ASTExpression>*/ map) { - ArrayList res = new ArrayList(map.entrySet()); - Collections.sort(res, - new Comparator() { // for sorting to source code order - @Override - public int compare(Object o1, Object o2) { - Map.Entry ent1 = (Map.Entry) o1; - ASTExpression exp1 = (ASTExpression) ent1.getValue(); - - Map.Entry ent2 = (Map.Entry) o2; - ASTExpression exp2 = (ASTExpression) ent2.getValue(); - - int res = exp1.beginLine - exp2.beginLine; - if (res != 0) return res; - res = exp1.beginColumn - exp2.beginColumn; - if (res != 0) return res; - - if (ent1 == ent2) return 0; - - // Should never reach this - return ((String) ent1.getKey()).compareTo((String) ent1.getKey()); - } - - }); - return res; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java b/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java index 9339c62..0c845b7 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java @@ -28,7 +28,7 @@ import org.apache.freemarker.core.outputformat.impl.UndefinedOutputFormat; import org.apache.freemarker.core.templateresolver.TemplateLoader; import org.apache.freemarker.core.util._NullArgumentException; import org.apache.freemarker.core.util._SortedArraySet; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; import org.apache.freemarker.core.util._UnmodifiableCompositeSet; public abstract class MutableParsingAndProcessingConfiguration< @@ -92,7 +92,7 @@ public abstract class MutableParsingAndProcessingConfiguration< value, OutputFormat.class, true, _SettingEvaluationEnvironment.getCurrent())); } } else if (WHITESPACE_STRIPPING_KEY.equals(name)) { - setWhitespaceStripping(_StringUtil.getYesNo(value)); + setWhitespaceStripping(_StringUtils.getYesNo(value)); } else if (AUTO_ESCAPING_POLICY_KEY.equals(name)) { if ("enableIfDefault".equals(value)) { setAutoEscapingPolicy(AutoEscapingPolicy.ENABLE_IF_DEFAULT); @@ -110,7 +110,7 @@ public abstract class MutableParsingAndProcessingConfiguration< if (value.equalsIgnoreCase(DEFAULT_VALUE)) { unsetRecognizeStandardFileExtensions(); } else { - setRecognizeStandardFileExtensions(_StringUtil.getYesNo(value)); + setRecognizeStandardFileExtensions(_StringUtils.getYesNo(value)); } } else if (TEMPLATE_LANGUAGE_KEY.equals(name)) { if ("FTL".equals(value)) { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java ---------------------------------------------------------------------- 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 d119bbc..d1684d3 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 @@ -61,12 +61,12 @@ import org.apache.freemarker.core.templateresolver.impl.DefaultTemplateNameForma import org.apache.freemarker.core.util.FTLUtil; import org.apache.freemarker.core.util.GenericParseException; import org.apache.freemarker.core.util.OptInTemplateClassResolver; -import org.apache.freemarker.core.util._ClassUtil; -import org.apache.freemarker.core.util._CollectionUtil; +import org.apache.freemarker.core.util._ClassUtils; +import org.apache.freemarker.core.util._CollectionUtils; import org.apache.freemarker.core.util._KeyValuePair; import org.apache.freemarker.core.util._NullArgumentException; import org.apache.freemarker.core.util._SortedArraySet; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; import org.apache.freemarker.core.valueformat.TemplateDateFormatFactory; import org.apache.freemarker.core.valueformat.TemplateNumberFormatFactory; @@ -367,7 +367,7 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces if (customNumberFormats == this.customNumberFormats) { return; } - _CollectionUtil.safeCastMap("customNumberFormats", customNumberFormats, + _CollectionUtils.safeCastMap("customNumberFormats", customNumberFormats, String.class, false, TemplateNumberFormatFactory.class, false); validateFormatNames(customNumberFormats.keySet()); @@ -638,7 +638,7 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces if (customDateFormats == this.customDateFormats) { return; } - _CollectionUtil.safeCastMap("customDateFormats", customDateFormats, + _CollectionUtils.safeCastMap("customDateFormats", customDateFormats, String.class, false, TemplateDateFormatFactory.class, false); validateFormatNames(customDateFormats.keySet()); @@ -1150,7 +1150,7 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces if (autoImports == this.autoImports) { return; } - _CollectionUtil.safeCastMap("autoImports", autoImports, String.class, false, String.class, false); + _CollectionUtils.safeCastMap("autoImports", autoImports, String.class, false, String.class, false); this.autoImports = Collections.unmodifiableMap(new LinkedHashMap<>(autoImports)); } else { this.autoImports = autoImports; @@ -1209,7 +1209,7 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces if (autoIncludes == this.autoIncludes) { return; } - _CollectionUtil.safeCastList("autoIncludes", autoIncludes, String.class, false); + _CollectionUtils.safeCastList("autoIncludes", autoIncludes, String.class, false); Set<String> uniqueItems = new LinkedHashSet<>(autoIncludes.size() * 4 / 3, 1f); for (String templateName : autoIncludes) { if (!uniqueItems.add(templateName)) { @@ -1653,7 +1653,7 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces if (JVM_DEFAULT_VALUE.equalsIgnoreCase(value)) { setLocale(Locale.getDefault()); } else { - setLocale(_StringUtil.deduceLocale(value)); + setLocale(_StringUtils.deduceLocale(value)); } } else if (NUMBER_FORMAT_KEY.equals(name)) { setNumberFormat(value); @@ -1752,11 +1752,11 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces } else if (URL_ESCAPING_CHARSET_KEY.equals(name)) { setURLEscapingCharset(Charset.forName(value)); } else if (AUTO_FLUSH_KEY.equals(name)) { - setAutoFlush(_StringUtil.getYesNo(value)); + setAutoFlush(_StringUtils.getYesNo(value)); } else if (SHOW_ERROR_TIPS_KEY.equals(name)) { - setShowErrorTips(_StringUtil.getYesNo(value)); + setShowErrorTips(_StringUtils.getYesNo(value)); } else if (API_BUILTIN_ENABLED_KEY.equals(name)) { - setAPIBuiltinEnabled(_StringUtil.getYesNo(value)); + setAPIBuiltinEnabled(_StringUtils.getYesNo(value)); } else if (NEW_BUILTIN_CLASS_RESOLVER_KEY.equals(name)) { if ("unrestricted".equals(value)) { setNewBuiltinClassResolver(TemplateClassResolver.UNRESTRICTED); @@ -1775,7 +1775,7 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces trustedTemplates = segmentValue; } else { throw new InvalidSettingValueException(name, value, - "Unrecognized list segment key: " + _StringUtil.jQuote(segmentKey) + + "Unrecognized list segment key: " + _StringUtils.jQuote(segmentKey) + ". Supported keys are: \"" + ALLOWED_CLASSES + "\", \"" + TRUSTED_TEMPLATES + "\""); } @@ -1796,9 +1796,9 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces + "looks like class name"); } } else if (LAZY_AUTO_IMPORTS_KEY.equals(name)) { - setLazyAutoImports(value.equals(NULL_VALUE) ? null : Boolean.valueOf(_StringUtil.getYesNo(value))); + setLazyAutoImports(value.equals(NULL_VALUE) ? null : Boolean.valueOf(_StringUtils.getYesNo(value))); } else if (LAZY_IMPORTS_KEY.equals(name)) { - setLazyImports(_StringUtil.getYesNo(value)); + setLazyImports(_StringUtils.getYesNo(value)); } else if (AUTO_INCLUDES_KEY.equals(name)) { setAutoIncludes(parseAsList(value)); } else if (AUTO_IMPORTS_KEY.equals(name)) { @@ -1834,8 +1834,8 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces for (Object value : values) { if (!expectedClass.isInstance(value)) { throw new IllegalArgumentException(somethingsSentenceStart + " must be instances of " - + _ClassUtil.getShortClassName(expectedClass) + ", but one of them was a(n) " - + _ClassUtil.getShortClassNameOfObject(value) + "."); + + _ClassUtils.getShortClassName(expectedClass) + ", but one of them was a(n) " + + _ClassUtils.getShortClassNameOfObject(value) + "."); } } } @@ -2017,7 +2017,7 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces // When there's no need for inheritance: customSettingsModifiable = false; // Copy-on-write on next modification - return _CollectionUtil.unmodifiableMap(customSettings); + return _CollectionUtils.unmodifiableMap(customSettings); } /** @@ -2185,7 +2185,7 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces "Unexpected end of text: expected \"as\""); String s = fetchKeyword(); if (!s.equalsIgnoreCase("as")) throw new GenericParseException( - "Expected \"as\", but found " + _StringUtil.jQuote(s)); + "Expected \"as\", but found " + _StringUtils.jQuote(s)); c = skipWS(); if (c == ' ') throw new GenericParseException( http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/NonSequenceOrCollectionException.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/NonSequenceOrCollectionException.java b/freemarker-core/src/main/java/org/apache/freemarker/core/NonSequenceOrCollectionException.java index 2836230..c229808 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/NonSequenceOrCollectionException.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/NonSequenceOrCollectionException.java @@ -23,7 +23,7 @@ import org.apache.freemarker.core.model.TemplateCollectionModel; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateSequenceModel; import org.apache.freemarker.core.model.WrapperTemplateModel; -import org.apache.freemarker.core.util._CollectionUtil; +import org.apache.freemarker.core.util._CollectionUtils; /** * Indicates that a {@link TemplateSequenceModel} or {@link TemplateCollectionModel} value was expected, but the value @@ -53,7 +53,7 @@ public class NonSequenceOrCollectionException extends UnexpectedTypeException { NonSequenceOrCollectionException( ASTExpression blamed, TemplateModel model, Environment env) throws InvalidReferenceException { - this(blamed, model, _CollectionUtil.EMPTY_OBJECT_ARRAY, env); + this(blamed, model, _CollectionUtils.EMPTY_OBJECT_ARRAY, env); } NonSequenceOrCollectionException( http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ParseException.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ParseException.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ParseException.java index 2b87cfe..9480562 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ParseException.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ParseException.java @@ -25,8 +25,8 @@ import java.util.Iterator; import java.util.Set; import org.apache.freemarker.core.util._NullArgumentException; -import org.apache.freemarker.core.util._SecurityUtil; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._SecurityUtils; +import org.apache.freemarker.core.util._StringUtils; /** * Parsing-time exception in a template (as opposed to a runtime exception, a {@link TemplateException}). This usually @@ -76,7 +76,7 @@ public class ParseException extends IOException implements FMParserConstants { /** * The end of line string for this machine. */ - protected String eol = _SecurityUtil.getSystemProperty("line.separator", "\n"); + protected String eol = _SecurityUtils.getSystemProperty("line.separator", "\n"); private String templateSourceName; private String templateLookupName; @@ -287,7 +287,7 @@ public class ParseException extends IOException implements FMParserConstants { String prefix; if (!isInJBossToolsMode()) { prefix = "Syntax error " - + MessageUtil.formatLocationForSimpleParsingError(getTemplateSourceOrLookupName(), lineNumber, + + MessageUtils.formatLocationForSimpleParsingError(getTemplateSourceOrLookupName(), lineNumber, columnNumber) + ":\n"; } else { @@ -437,7 +437,7 @@ public class ParseException extends IOException implements FMParserConstants { + "Check if you have a valid #if-#elseIf-#else or #list-#else structure."; } else if (kind == END_IF || kind == ELSE_IF) { return "Unexpected directive, " - + _StringUtil.jQuote(nextToken) + + _StringUtils.jQuote(nextToken) + ". Check if you have a valid #if-#elseIf-#else structure."; } return null; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/RegexpHelper.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/RegexpHelper.java b/freemarker-core/src/main/java/org/apache/freemarker/core/RegexpHelper.java index d564d31..37b5fd5 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/RegexpHelper.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/RegexpHelper.java @@ -24,7 +24,7 @@ import java.util.regex.PatternSyntaxException; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.templateresolver.impl.MruCacheStorage; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -145,7 +145,7 @@ final class RegexpHelper { // [FM3] Should be an error RegexpHelper.logFlagWarning( "Unrecognized regular expression flag: " - + _StringUtil.jQuote(String.valueOf(c)) + "."); + + _StringUtils.jQuote(String.valueOf(c)) + "."); } } // switch } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java index fde11d9..9384b9e 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java @@ -55,7 +55,7 @@ import org.apache.freemarker.core.templateresolver.TemplateLookupStrategy; import org.apache.freemarker.core.templateresolver.impl.DefaultTemplateResolver; import org.apache.freemarker.core.templateresolver.impl.FileTemplateLoader; import org.apache.freemarker.core.util.BugException; -import org.apache.freemarker.core.util._CollectionUtil; +import org.apache.freemarker.core.util._CollectionUtils; import org.apache.freemarker.core.util._NullArgumentException; import org.apache.freemarker.core.valueformat.TemplateDateFormatFactory; import org.apache.freemarker.core.valueformat.TemplateNumberFormatFactory; @@ -332,8 +332,8 @@ public class Template implements ProcessingConfiguration, CustomStateScope { ltbReader.throwFailure(); _DebuggerService.registerTemplate(this); - namespaceURIToPrefixLookup = _CollectionUtil.unmodifiableMap(namespaceURIToPrefixLookup); - prefixToNamespaceURILookup = _CollectionUtil.unmodifiableMap(prefixToNamespaceURILookup); + namespaceURIToPrefixLookup = _CollectionUtils.unmodifiableMap(namespaceURIToPrefixLookup); + prefixToNamespaceURILookup = _CollectionUtils.unmodifiableMap(prefixToNamespaceURILookup); finishConstruction(); } @@ -343,8 +343,8 @@ public class Template implements ProcessingConfiguration, CustomStateScope { * protected when construction is done. */ private void finishConstruction() { - headerCustomSettings = _CollectionUtil.unmodifiableMap(headerCustomSettings); - tcAndHeaderCustomSettings = _CollectionUtil.unmodifiableMap(tcAndHeaderCustomSettings); + headerCustomSettings = _CollectionUtils.unmodifiableMap(headerCustomSettings); + tcAndHeaderCustomSettings = _CollectionUtils.unmodifiableMap(tcAndHeaderCustomSettings); writeProtected = true; } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateBooleanFormat.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateBooleanFormat.java b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateBooleanFormat.java index 240b81e..b2de905 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateBooleanFormat.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateBooleanFormat.java @@ -19,13 +19,15 @@ package org.apache.freemarker.core; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; import org.apache.freemarker.core.valueformat.TemplateValueFormat; // TODO Should be public and moved over to core.valueformat? final class TemplateBooleanFormat extends TemplateValueFormat { - static final String C_TRUE_FALSE = "true,false"; + static final String C_FALSE = "false"; + static final String C_TRUE = "true"; + static final String C_TRUE_FALSE = C_TRUE + "," + C_FALSE; static final TemplateBooleanFormat C_TRUE_FALSE_FORMAT = new TemplateBooleanFormat(); static TemplateBooleanFormat getInstance(String format) { @@ -85,7 +87,7 @@ final class TemplateBooleanFormat extends TemplateValueFormat { @Override public String getDescription() { - return _StringUtil.jQuote(formatString); + return _StringUtils.jQuote(formatString); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateClassResolver.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateClassResolver.java b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateClassResolver.java index 415c66c..0e04b4f 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateClassResolver.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateClassResolver.java @@ -19,7 +19,7 @@ package org.apache.freemarker.core; -import org.apache.freemarker.core.util._ClassUtil; +import org.apache.freemarker.core.util._ClassUtils; /** * Used by built-ins and other template language features that get a class @@ -34,7 +34,7 @@ import org.apache.freemarker.core.util._ClassUtil; public interface TemplateClassResolver { /** - * Simply calls {@link _ClassUtil#forName(String)}. + * Simply calls {@link _ClassUtils#forName(String)}. */ TemplateClassResolver UNRESTRICTED = new TemplateClassResolver() { @@ -42,7 +42,7 @@ public interface TemplateClassResolver { public Class resolve(String className, Environment env, Template template) throws TemplateException { try { - return _ClassUtil.forName(className); + return _ClassUtils.forName(className); } catch (ClassNotFoundException e) { throw new _MiscTemplateException(e, env); } @@ -58,7 +58,7 @@ public interface TemplateClassResolver { @Override public Class resolve(String className, Environment env, Template template) throws TemplateException { - throw MessageUtil.newInstantiatingClassNotAllowedException(className, env); + throw MessageUtils.newInstantiatingClassNotAllowedException(className, env); } }; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java index 3e77e2c..901c4f4 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java @@ -29,7 +29,7 @@ import java.util.TimeZone; import org.apache.freemarker.core.arithmetic.ArithmeticEngine; import org.apache.freemarker.core.outputformat.OutputFormat; import org.apache.freemarker.core.util.CommonBuilder; -import org.apache.freemarker.core.util._CollectionUtil; +import org.apache.freemarker.core.util._CollectionUtils; import org.apache.freemarker.core.valueformat.TemplateDateFormatFactory; import org.apache.freemarker.core.valueformat.TemplateNumberFormatFactory; @@ -779,13 +779,13 @@ public final class TemplateConfiguration implements ParsingAndProcessingConfigur setBooleanFormat(tc.getBooleanFormat()); } if (tc.isCustomDateFormatsSet()) { - setCustomDateFormats(_CollectionUtil.mergeImmutableMaps( + setCustomDateFormats(_CollectionUtils.mergeImmutableMaps( isCustomDateFormatsSet() ? getCustomDateFormats() : null, tc.getCustomDateFormats(), false), true ); } if (tc.isCustomNumberFormatsSet()) { - setCustomNumberFormats(_CollectionUtil.mergeImmutableMaps( + setCustomNumberFormats(_CollectionUtils.mergeImmutableMaps( isCustomNumberFormatsSet() ? getCustomNumberFormats() : null, tc.getCustomNumberFormats(), false), true); } @@ -856,21 +856,21 @@ public final class TemplateConfiguration implements ParsingAndProcessingConfigur setLazyAutoImports(tc.getLazyAutoImports()); } if (tc.isAutoImportsSet()) { - setAutoImports(_CollectionUtil.mergeImmutableMaps( + setAutoImports(_CollectionUtils.mergeImmutableMaps( isAutoImportsSet() ? getAutoImports() : null, tc.isAutoImportsSet() ? tc.getAutoImports() : null, true), true); } if (tc.isAutoIncludesSet()) { - setAutoIncludes(_CollectionUtil.mergeImmutableLists( + setAutoIncludes(_CollectionUtils.mergeImmutableLists( isAutoIncludesSet() ? getAutoIncludes() : null, tc.isAutoIncludesSet() ? tc.getAutoIncludes() : null, true), true); } - setCustomSettingsMap(_CollectionUtil.mergeImmutableMaps( + setCustomSettingsMap(_CollectionUtils.mergeImmutableMaps( getCustomSettings(false), tc.getCustomSettings(false), false)); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateElementArrayBuilder.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateElementArrayBuilder.java b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateElementArrayBuilder.java index 3b8f40f..4bc9a4f 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateElementArrayBuilder.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateElementArrayBuilder.java @@ -18,7 +18,7 @@ */ package org.apache.freemarker.core; -import org.apache.freemarker.core.util._CollectionUtil; +import org.apache.freemarker.core.util._CollectionUtils; /** * Holds an buffer (array) of {@link ASTElement}-s with the count of the utilized items in it. The un-utilized tail @@ -70,7 +70,7 @@ class TemplateElements { */ ASTElement asSingleElement() { if (count == 0) { - return new ASTStaticText(_CollectionUtil.EMPTY_CHAR_ARRAY, false); + return new ASTStaticText(_CollectionUtils.EMPTY_CHAR_ARRAY, false); } else { ASTElement first = buffer[0]; if (count == 1) { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateException.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateException.java b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateException.java index fb54f82..e7f387f 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateException.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateException.java @@ -27,7 +27,7 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.lang.reflect.Method; -import org.apache.freemarker.core.util._CollectionUtil; +import org.apache.freemarker.core.util._CollectionUtils; /** * Runtime exception in a template (as opposed to a parsing-time exception: {@link ParseException}). @@ -170,10 +170,10 @@ public class TemplateException extends Exception { String stackTopFew = getFTLInstructionStackTopFew(); if (stackTopFew != null) { message = messageWithoutStackTop + "\n\n" - + MessageUtil.ERROR_MESSAGE_HR + "\n" + + MessageUtils.ERROR_MESSAGE_HR + "\n" + FTL_INSTRUCTION_STACK_TRACE_TITLE + "\n" + stackTopFew - + MessageUtil.ERROR_MESSAGE_HR; + + MessageUtils.ERROR_MESSAGE_HR; messageWithoutStackTop = message.substring(0, messageWithoutStackTop.length()); // to reuse backing char[] } else { message = messageWithoutStackTop; @@ -339,10 +339,10 @@ public class TemplateException extends Exception { if (stackTrace != null) { out.println(getMessageWithoutStackTop()); // Not getMessage()! out.println(); - out.println(MessageUtil.ERROR_MESSAGE_HR); + out.println(MessageUtils.ERROR_MESSAGE_HR); out.println(FTL_INSTRUCTION_STACK_TRACE_TITLE); out.print(stackTrace); - out.println(MessageUtil.ERROR_MESSAGE_HR); + out.println(MessageUtils.ERROR_MESSAGE_HR); } else { ftlStackTrace = false; javaStackTrace = true; @@ -353,7 +353,7 @@ public class TemplateException extends Exception { if (ftlStackTrace) { // We are after an FTL stack trace out.println(); out.println("Java stack trace (for programmers):"); - out.println(MessageUtil.ERROR_MESSAGE_HR); + out.println(MessageUtils.ERROR_MESSAGE_HR); synchronized (lock) { if (messageWasAlreadyPrintedForThisTrace == null) { messageWasAlreadyPrintedForThisTrace = new ThreadLocal(); @@ -376,8 +376,8 @@ public class TemplateException extends Exception { if (causeCause == null) { try { // Reflection is used to prevent dependency on Servlet classes. - Method m = getCause().getClass().getMethod("getRootCause", _CollectionUtil.EMPTY_CLASS_ARRAY); - Throwable rootCause = (Throwable) m.invoke(getCause(), _CollectionUtil.EMPTY_OBJECT_ARRAY); + Method m = getCause().getClass().getMethod("getRootCause", _CollectionUtils.EMPTY_CLASS_ARRAY); + Throwable rootCause = (Throwable) m.invoke(getCause(), _CollectionUtils.EMPTY_OBJECT_ARRAY); if (rootCause != null) { out.println("ServletException root cause: "); out.printStandardStackTrace(rootCause); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateExceptionHandler.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateExceptionHandler.java b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateExceptionHandler.java index 477cbf6..1269053 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateExceptionHandler.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateExceptionHandler.java @@ -23,7 +23,7 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.io.Writer; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * Used for the {@code templateExceptionHandler} configuration setting; @@ -134,7 +134,7 @@ public interface TemplateExceptionHandler { te.printStackTrace(stackPW, false, true, true); stackPW.close(); pw.println(); - pw.println(_StringUtil.XMLEncNQG(stackTraceSW.toString())); + pw.println(_StringUtils.XMLEncNQG(stackTraceSW.toString())); pw.println("</pre></div></html>"); pw.flush(); // To commit the HTTP response http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateLanguage.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateLanguage.java b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateLanguage.java index 205fa8c..02ccb47 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateLanguage.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateLanguage.java @@ -24,7 +24,7 @@ import java.io.InputStream; import java.io.Reader; import java.nio.charset.Charset; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * Represents a template language. Currently this class is not mature, so it can't be implemented outside FreeMarker, @@ -105,7 +105,7 @@ public abstract class TemplateLanguage { @Override public final String toString() { - return "TemplateLanguage(" + _StringUtil.jQuote(name) + ")"; + return "TemplateLanguage(" + _StringUtils.jQuote(name) + ")"; } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/Version.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Version.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Version.java index 3a542d1..da7e1fc 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/Version.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Version.java @@ -22,7 +22,7 @@ package org.apache.freemarker.core; import java.io.Serializable; import java.util.Date; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * Represents a version number plus the further qualifiers and build info. This is @@ -71,14 +71,14 @@ public final class Version implements Serializable { } else { if (i == 0) { throw new IllegalArgumentException( - "The version number string " + _StringUtil.jQuote(stringValue) + "The version number string " + _StringUtils.jQuote(stringValue) + " doesn't start with a number."); } if (c == '.') { char nextC = i + 1 >= stringValue.length() ? 0 : stringValue.charAt(i + 1); if (nextC == '.') { throw new IllegalArgumentException( - "The version number string " + _StringUtil.jQuote(stringValue) + "The version number string " + _StringUtils.jQuote(stringValue) + " contains multiple dots after a number."); } if (partIdx == 2 || !isNumber(nextC)) { @@ -100,7 +100,7 @@ public final class Version implements Serializable { extraInfoTmp = extraInfoTmp.substring(1); if (extraInfoTmp.length() == 0) { throw new IllegalArgumentException( - "The version number string " + _StringUtil.jQuote(stringValue) + "The version number string " + _StringUtils.jQuote(stringValue) + " has an extra info section opened with \"" + firstChar + "\", but it's empty."); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/_CallableUtils.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/_CallableUtils.java b/freemarker-core/src/main/java/org/apache/freemarker/core/_CallableUtils.java index b1e02ab..81a5aa0 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/_CallableUtils.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/_CallableUtils.java @@ -36,7 +36,7 @@ import org.apache.freemarker.core.model.TemplateScalarModel; import org.apache.freemarker.core.model.TemplateSequenceModel; import org.apache.freemarker.core.util.FTLUtil; import org.apache.freemarker.core.util.StringToIndexMap; -import org.apache.freemarker.core.util._CollectionUtil; +import org.apache.freemarker.core.util._CollectionUtils; /** * For internal use only; don't depend on this, there's no backward compatibility guarantee at all! @@ -161,7 +161,7 @@ public final class _CallableUtils { TemplateModel argValue, String argName, int argIndex, boolean optional) throws TemplateException { if (argValue instanceof TemplateScalarModel) { - return _EvalUtil.modelToString((TemplateScalarModel) argValue, null, null); + return _EvalUtils.modelToString((TemplateScalarModel) argValue, null, null); } if (argValue == null) { if (optional) { @@ -255,7 +255,7 @@ public final class _CallableUtils { (!validPredefNames.isEmpty() ? new Object[] { " The supported parameter names are:\n", new _DelayedJQuotedListing(validPredefNames)} - : _CollectionUtil.EMPTY_OBJECT_ARRAY)} + : _CollectionUtils.EMPTY_OBJECT_ARRAY)} : "") ); if (callableValue instanceof Environment.TemplateLanguageDirective http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedAOrAn.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedAOrAn.java b/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedAOrAn.java index 630fa26..1c5bc09 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedAOrAn.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedAOrAn.java @@ -29,7 +29,7 @@ public class _DelayedAOrAn extends _DelayedConversionToString { @Override protected String doConversion(Object obj) { String s = obj.toString(); - return MessageUtil.getAOrAn(s) + " " + s; + return MessageUtils.getAOrAn(s) + " " + s; } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedJQuote.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedJQuote.java b/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedJQuote.java index 4caf71b..0d04574 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedJQuote.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedJQuote.java @@ -19,7 +19,7 @@ package org.apache.freemarker.core; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** Don't use this; used internally by FreeMarker, might changes without notice. */ public class _DelayedJQuote extends _DelayedConversionToString { @@ -30,7 +30,7 @@ public class _DelayedJQuote extends _DelayedConversionToString { @Override protected String doConversion(Object obj) { - return _StringUtil.jQuote(_ErrorDescriptionBuilder.toString(obj)); + return _StringUtils.jQuote(_ErrorDescriptionBuilder.toString(obj)); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedJQuotedListing.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedJQuotedListing.java b/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedJQuotedListing.java index e809a92..d251281 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedJQuotedListing.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedJQuotedListing.java @@ -21,7 +21,7 @@ package org.apache.freemarker.core; import java.util.Collection; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** Don't use this; used internally by FreeMarker, might changes without notice. */ public class _DelayedJQuotedListing extends _DelayedConversionToString { @@ -37,7 +37,7 @@ public class _DelayedJQuotedListing extends _DelayedConversionToString { if (sb.length() != 0) { sb.append(", "); } - sb.append(_StringUtil.jQuote(element)); + sb.append(_StringUtils.jQuote(element)); } return sb.toString(); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedShortClassName.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedShortClassName.java b/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedShortClassName.java index d9769b9..9a141c2 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedShortClassName.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/_DelayedShortClassName.java @@ -19,7 +19,7 @@ package org.apache.freemarker.core; -import org.apache.freemarker.core.util._ClassUtil; +import org.apache.freemarker.core.util._ClassUtils; public class _DelayedShortClassName extends _DelayedConversionToString { @@ -29,7 +29,7 @@ public class _DelayedShortClassName extends _DelayedConversionToString { @Override protected String doConversion(Object obj) { - return _ClassUtil.getShortClassName((Class) obj, true); + return _ClassUtils.getShortClassName((Class) obj, true); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/_ErrorDescriptionBuilder.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/_ErrorDescriptionBuilder.java b/freemarker-core/src/main/java/org/apache/freemarker/core/_ErrorDescriptionBuilder.java index 13cadcd..48a48fc 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/_ErrorDescriptionBuilder.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/_ErrorDescriptionBuilder.java @@ -23,9 +23,9 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Member; import java.lang.reflect.Method; -import org.apache.freemarker.core.model.impl._MethodUtil; -import org.apache.freemarker.core.util._ClassUtil; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.model.impl._MethodUtils; +import org.apache.freemarker.core.util._ClassUtils; +import org.apache.freemarker.core.util._StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -150,7 +150,7 @@ public class _ErrorDescriptionBuilder { sb.append("\n\n"); for (int i = 0; i < allTips.length; i++) { if (i != 0) sb.append('\n'); - sb.append(MessageUtil.ERROR_MESSAGE_HR).append('\n'); + sb.append(MessageUtils.ERROR_MESSAGE_HR).append('\n'); sb.append("Tip: "); Object tip = allTips[i]; if (!(tip instanceof Object[])) { @@ -159,7 +159,7 @@ public class _ErrorDescriptionBuilder { appendParts(sb, (Object[]) tip); } } - sb.append('\n').append(MessageUtil.ERROR_MESSAGE_HR); + sb.append('\n').append(MessageUtils.ERROR_MESSAGE_HR); } } @@ -262,19 +262,19 @@ public class _ErrorDescriptionBuilder { if (partObj == null) { return null; } else if (partObj instanceof Class) { - partStr = _ClassUtil.getShortClassName((Class) partObj); + partStr = _ClassUtils.getShortClassName((Class) partObj); } else if (partObj instanceof Method || partObj instanceof Constructor) { - partStr = _MethodUtil.toString((Member) partObj); + partStr = _MethodUtils.toString((Member) partObj); } else { - partStr = suppressToStringException ? _StringUtil.tryToString(partObj) : partObj.toString(); + partStr = suppressToStringException ? _StringUtils.tryToString(partObj) : partObj.toString(); } return partStr; } private String[] splitToLines(String s) { - s = _StringUtil.replace(s, "\r\n", "\n"); - s = _StringUtil.replace(s, "\r", "\n"); - return _StringUtil.split(s, '\n'); + s = _StringUtils.replace(s, "\r\n", "\n"); + s = _StringUtils.replace(s, "\r", "\n"); + return _StringUtils.split(s, '\n'); } /**