http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core-test/src/test/java/org/apache/freemarker/core/util/StringUtilsTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/util/StringUtilsTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/util/StringUtilsTest.java new file mode 100644 index 0000000..a4d57a8 --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/util/StringUtilsTest.java @@ -0,0 +1,416 @@ +/* + * 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.util; + +import static junit.framework.TestCase.assertNull; +import static org.junit.Assert.*; + +import java.io.IOException; +import java.io.StringWriter; +import java.util.regex.Pattern; + +import org.hamcrest.Matchers; +import org.junit.Test; + +public class StringUtilsTest { + + @Test + public void testV2319() { + assertEquals("\\n\\r\\f\\b\\t\\x00\\x19", _StringUtils.javaScriptStringEnc("\n\r\f\b\t\u0000\u0019")); + } + + @Test + public void testControlChars() { + assertEsc( + "\n\r\f\b\t \u0000\u0019\u001F \u007F\u0080\u009F \u2028\u2029", + "\\n\\r\\f\\b\\t \\x00\\x19\\x1F \\x7F\\x80\\x9F \\u2028\\u2029", + "\\n\\r\\f\\b\\t \\u0000\\u0019\\u001F \\u007F\\u0080\\u009F \\u2028\\u2029"); + } + + @Test + public void testHtmlChars() { + assertEsc( + "<safe>/>->]> </foo> <!-- --> <![CDATA[ ]]> <?php?>", + "<safe>/>->]> <\\/foo> \\x3C!-- --\\> \\x3C![CDATA[ ]]\\> \\x3C?php?>", + "<safe>/>->]> <\\/foo> \\u003C!-- --\\u003E \\u003C![CDATA[ ]]\\u003E \\u003C?php?>"); + assertEsc("<!c", "\\x3C!c", "\\u003C!c"); + assertEsc("c<!", "c\\x3C!", "c\\u003C!"); + assertEsc("c<", "c\\x3C", "c\\u003C"); + assertEsc("c<c", "c<c", "c<c"); + assertEsc("<c", "<c", "<c"); + assertEsc(">", "\\>", "\\u003E"); + assertEsc("->", "-\\>", "-\\u003E"); + assertEsc("-->", "--\\>", "--\\u003E"); + assertEsc("c-->", "c--\\>", "c--\\u003E"); + assertEsc("-->c", "--\\>c", "--\\u003Ec"); + assertEsc("]>", "]\\>", "]\\u003E"); + assertEsc("]]>", "]]\\>", "]]\\u003E"); + assertEsc("c]]>", "c]]\\>", "c]]\\u003E"); + assertEsc("]]>c", "]]\\>c", "]]\\u003Ec"); + assertEsc("c->", "c->", "c->"); + assertEsc("c>", "c>", "c>"); + assertEsc("-->", "--\\>", "--\\u003E"); + assertEsc("/", "\\/", "\\/"); + assertEsc("/c", "\\/c", "\\/c"); + assertEsc("</", "<\\/", "<\\/"); + assertEsc("</c", "<\\/c", "<\\/c"); + assertEsc("c/", "c/", "c/"); + } + + @Test + public void testJSChars() { + assertEsc("\"", "\\\"", "\\\""); + assertEsc("'", "\\'", "'"); + assertEsc("\\", "\\\\", "\\\\"); + } + + @Test + public void testSameStringsReturned() { + String s = "==> I/m <safe>!"; + assertTrue(s == _StringUtils.jsStringEnc(s, false)); // "==" because is must return the same object + assertTrue(s == _StringUtils.jsStringEnc(s, true)); + + s = ""; + assertTrue(s == _StringUtils.jsStringEnc(s, false)); + assertTrue(s == _StringUtils.jsStringEnc(s, true)); + + s = "\u00E1rv\u00EDzt\u0171r\u0151 \u3020"; + assertEquals(s, _StringUtils.jsStringEnc(s, false)); + assertTrue(s == _StringUtils.jsStringEnc(s, false)); + assertTrue(s == _StringUtils.jsStringEnc(s, true)); + } + + @Test + public void testOneOffs() { + assertEsc("c\"c\"cc\"\"c", "c\\\"c\\\"cc\\\"\\\"c", "c\\\"c\\\"cc\\\"\\\"c"); + assertEsc("\"c\"cc\"", "\\\"c\\\"cc\\\"", "\\\"c\\\"cc\\\""); + assertEsc("c/c/cc//c", "c/c/cc//c", "c/c/cc//c"); + assertEsc("c<c<cc<<c", "c<c<cc<<c", "c<c<cc<<c"); + assertEsc("/<", "\\/\\x3C", "\\/\\u003C"); + assertEsc(">", "\\>", "\\u003E"); + assertEsc("]>", "]\\>", "]\\u003E"); + assertEsc("->", "-\\>", "-\\u003E"); + } + + private void assertEsc(String s, String javaScript, String json) { + assertEquals(javaScript, _StringUtils.jsStringEnc(s, false)); + assertEquals(json, _StringUtils.jsStringEnc(s, true)); + } + + @Test + public void testTrim() { + assertSame(_CollectionUtils.EMPTY_CHAR_ARRAY, _StringUtils.trim(_CollectionUtils.EMPTY_CHAR_ARRAY)); + assertSame(_CollectionUtils.EMPTY_CHAR_ARRAY, _StringUtils.trim(" \t\u0001 ".toCharArray())); + { + char[] cs = "foo".toCharArray(); + assertSame(cs, cs); + } + assertArrayEquals("foo".toCharArray(), _StringUtils.trim("foo ".toCharArray())); + assertArrayEquals("foo".toCharArray(), _StringUtils.trim(" foo".toCharArray())); + assertArrayEquals("foo".toCharArray(), _StringUtils.trim(" foo ".toCharArray())); + assertArrayEquals("foo".toCharArray(), _StringUtils.trim("\t\tfoo \r\n".toCharArray())); + assertArrayEquals("x".toCharArray(), _StringUtils.trim(" x ".toCharArray())); + assertArrayEquals("x y z".toCharArray(), _StringUtils.trim(" x y z ".toCharArray())); + } + + @Test + public void testIsTrimmedToEmpty() { + assertTrue(_StringUtils.isTrimmableToEmpty("".toCharArray())); + assertTrue(_StringUtils.isTrimmableToEmpty("\r\r\n\u0001".toCharArray())); + assertFalse(_StringUtils.isTrimmableToEmpty("x".toCharArray())); + assertFalse(_StringUtils.isTrimmableToEmpty(" x ".toCharArray())); + } + + @Test + public void testJQuote() { + assertEquals("null", _StringUtils.jQuote(null)); + assertEquals("\"foo\"", _StringUtils.jQuote("foo")); + assertEquals("\"123\"", _StringUtils.jQuote(Integer.valueOf(123))); + assertEquals("\"foo's \\\"bar\\\"\"", + _StringUtils.jQuote("foo's \"bar\"")); + assertEquals("\"\\n\\r\\t\\u0001\"", + _StringUtils.jQuote("\n\r\t\u0001")); + assertEquals("\"<\\nb\\rc\\td\\u0001>\"", + _StringUtils.jQuote("<\nb\rc\td\u0001>")); + } + + @Test + public void testJQuoteNoXSS() { + assertEquals("null", _StringUtils.jQuoteNoXSS(null)); + assertEquals("\"foo\"", _StringUtils.jQuoteNoXSS("foo")); + assertEquals("\"123\"", _StringUtils.jQuoteNoXSS(Integer.valueOf(123))); + assertEquals("\"foo's \\\"bar\\\"\"", + _StringUtils.jQuoteNoXSS("foo's \"bar\"")); + assertEquals("\"\\n\\r\\t\\u0001\"", + _StringUtils.jQuoteNoXSS("\n\r\t\u0001")); + assertEquals("\"\\u003C\\nb\\rc\\td\\u0001>\"", + _StringUtils.jQuoteNoXSS("<\nb\rc\td\u0001>")); + assertEquals("\"\\u003C\\nb\\rc\\td\\u0001>\"", + _StringUtils.jQuoteNoXSS((Object) "<\nb\rc\td\u0001>")); + } + + @Test + public void testGlobToRegularExpression() { + assertGlobMatches("a/b/c.ftl", "a/b/c.ftl"); + assertGlobDoesNotMatch("/a/b/cxftl", "/a/b/c.ftl", "a/b/C.ftl"); + + assertGlobMatches("a/b/*.ftl", "a/b/.ftl", "a/b/x.ftl", "a/b/xx.ftl"); + assertGlobDoesNotMatch("a/b/*.ftl", "a/c/x.ftl", "a/b/c/x.ftl", "/a/b/x.ftl", "a/b/xxftl"); + + assertGlobMatches("a/b/?.ftl", "a/b/x.ftl"); + assertGlobDoesNotMatch("a/b/?.ftl", "a/c/x.ftl", "a/b/.ftl", "a/b/xx.ftl", "a/b/xxftl"); + + assertGlobMatches("a/**/c.ftl", "a/b/c.ftl", "a/c.ftl", "a/b/b2/b3/c.ftl", "a//c.ftl"); + assertGlobDoesNotMatch("a/**/c.ftl", "x/b/c.ftl", "a/b/x.ftl"); + + assertGlobMatches("**/c.ftl", "a/b/c.ftl", "c.ftl", "/c.ftl", "///c.ftl"); + assertGlobDoesNotMatch("**/c.ftl", "a/b/x.ftl"); + + assertGlobMatches("a/b/**", "a/b/c.ftl", "a/b/c2/c.ftl", "a/b/", "a/b/c/"); + assertGlobDoesNotMatch("a/b.ftl"); + + assertGlobMatches("**", "a/b/c.ftl", ""); + + assertGlobMatches("\\[\\{\\*\\?\\}\\]\\\\", "[{*?}]\\"); + assertGlobDoesNotMatch("\\[\\{\\*\\?\\}\\]\\\\", "[{xx}]\\"); + + assertGlobMatches("a/b/\\?.ftl", "a/b/?.ftl"); + assertGlobDoesNotMatch("a/b/\\?.ftl", "a/b/x.ftl"); + + assertGlobMatches("\\?\\?.ftl", "??.ftl"); + assertGlobMatches("\\\\\\\\", "\\\\"); + assertGlobMatches("\\\\\\\\?", "\\\\x"); + assertGlobMatches("x\\", "x"); + + assertGlobMatches("???*", "123", "1234", "12345"); + assertGlobDoesNotMatch("???*", "12", "1", ""); + + assertGlobMatches("**/a??/b*.ftl", "a11/b1.ftl", "x/a11/b123.ftl", "x/y/a11/b.ftl"); + assertGlobDoesNotMatch("**/a??/b*.ftl", "a1/b1.ftl", "x/a11/c123.ftl"); + + assertFalse(_StringUtils.globToRegularExpression("ab*").matcher("aBc").matches()); + assertTrue(_StringUtils.globToRegularExpression("ab*", true).matcher("aBc").matches()); + assertTrue(_StringUtils.globToRegularExpression("ab", true).matcher("aB").matches()); + assertTrue(_StringUtils.globToRegularExpression("\u00E1b*", true).matcher("\u00C1bc").matches()); + + try { + _StringUtils.globToRegularExpression("x**/y"); + fail(); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage(), Matchers.containsString("**")); + } + + try { + _StringUtils.globToRegularExpression("**y"); + fail(); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage(), Matchers.containsString("**")); + } + + try { + _StringUtils.globToRegularExpression("[ab]c"); + fail(); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage(), Matchers.containsString("unsupported")); + } + + try { + _StringUtils.globToRegularExpression("{aa,bb}c"); + fail(); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage(), Matchers.containsString("unsupported")); + } + } + + private void assertGlobMatches(String glob, String... ss) { + Pattern pattern = _StringUtils.globToRegularExpression(glob); + for (String s : ss) { + if (!pattern.matcher(s).matches()) { + fail("Glob " + glob + " (regexp: " + pattern + ") doesn't match " + s); + } + } + } + + private void assertGlobDoesNotMatch(String glob, String... ss) { + Pattern pattern = _StringUtils.globToRegularExpression(glob); + for (String s : ss) { + if (pattern.matcher(s).matches()) { + fail("Glob " + glob + " (regexp: " + pattern + ") matches " + s); + } + } + } + + @Test + public void testHTMLEnc() { + String s = ""; + assertSame(s, _StringUtils.XMLEncNA(s)); + + s = "asd"; + assertSame(s, _StringUtils.XMLEncNA(s)); + + assertEquals("a&b<c>d"e'f", _StringUtils.XMLEncNA("a&b<c>d\"e'f")); + assertEquals("<", _StringUtils.XMLEncNA("<")); + assertEquals("<a", _StringUtils.XMLEncNA("<a")); + assertEquals("<a>", _StringUtils.XMLEncNA("<a>")); + assertEquals("a>", _StringUtils.XMLEncNA("a>")); + assertEquals("<>", _StringUtils.XMLEncNA("<>")); + assertEquals("a<>b", _StringUtils.XMLEncNA("a<>b")); + } + + @Test + public void testXHTMLEnc() throws IOException { + String s = ""; + assertSame(s, _StringUtils.XHTMLEnc(s)); + + s = "asd"; + assertSame(s, _StringUtils.XHTMLEnc(s)); + + testXHTMLEnc("a&b<c>d"e'f", "a&b<c>d\"e'f"); + testXHTMLEnc("<", "<"); + testXHTMLEnc("<a", "<a"); + testXHTMLEnc("<a>", "<a>"); + testXHTMLEnc("a>", "a>"); + testXHTMLEnc("<>", "<>"); + testXHTMLEnc("a<>b", "a<>b"); + } + + private void testXHTMLEnc(String expected, String in) throws IOException { + assertEquals(expected, _StringUtils.XHTMLEnc(in)); + + StringWriter sw = new StringWriter(); + _StringUtils.XHTMLEnc(in, sw); + assertEquals(expected, sw.toString()); + } + + @Test + public void testXMLEnc() throws IOException { + String s = ""; + assertSame(s, _StringUtils.XMLEnc(s)); + + s = "asd"; + assertSame(s, _StringUtils.XMLEnc(s)); + + testXMLEnc("a&b<c>d"e'f", "a&b<c>d\"e'f"); + testXMLEnc("<", "<"); + testXMLEnc("<a", "<a"); + testXMLEnc("<a>", "<a>"); + testXMLEnc("a>", "a>"); + testXMLEnc("<>", "<>"); + testXMLEnc("a<>b", "a<>b"); + } + + private void testXMLEnc(String expected, String in) throws IOException { + assertEquals(expected, _StringUtils.XMLEnc(in)); + + StringWriter sw = new StringWriter(); + _StringUtils.XMLEnc(in, sw); + assertEquals(expected, sw.toString()); + } + + @Test + public void testXMLEncQAttr() throws IOException { + String s = ""; + assertSame(s, _StringUtils.XMLEncQAttr(s)); + + s = "asd"; + assertSame(s, _StringUtils.XMLEncQAttr(s)); + + assertEquals("a&b<c>d"e'f", _StringUtils.XMLEncQAttr("a&b<c>d\"e'f")); + assertEquals("<", _StringUtils.XMLEncQAttr("<")); + assertEquals("<a", _StringUtils.XMLEncQAttr("<a")); + assertEquals("<a>", _StringUtils.XMLEncQAttr("<a>")); + assertEquals("a>", _StringUtils.XMLEncQAttr("a>")); + assertEquals("<>", _StringUtils.XMLEncQAttr("<>")); + assertEquals("a<>b", _StringUtils.XMLEncQAttr("a<>b")); + } + + @Test + public void testXMLEncNQG() throws IOException { + String s = ""; + assertSame(s, _StringUtils.XMLEncNQG(s)); + + s = "asd"; + assertSame(s, _StringUtils.XMLEncNQG(s)); + + assertEquals("a&b<c>d\"e'f", _StringUtils.XMLEncNQG("a&b<c>d\"e'f")); + assertEquals("<", _StringUtils.XMLEncNQG("<")); + assertEquals("<a", _StringUtils.XMLEncNQG("<a")); + assertEquals("<a>", _StringUtils.XMLEncNQG("<a>")); + assertEquals("a>", _StringUtils.XMLEncNQG("a>")); + assertEquals("<>", _StringUtils.XMLEncNQG("<>")); + assertEquals("a<>b", _StringUtils.XMLEncNQG("a<>b")); + + assertEquals(">", _StringUtils.XMLEncNQG(">")); + assertEquals("]>", _StringUtils.XMLEncNQG("]>")); + assertEquals("]]>", _StringUtils.XMLEncNQG("]]>")); + assertEquals("x]]>", _StringUtils.XMLEncNQG("x]]>")); + assertEquals("x]>", _StringUtils.XMLEncNQG("x]>")); + assertEquals("]x>", _StringUtils.XMLEncNQG("]x>")); + } + + @Test + public void testRTFEnc() throws IOException { + String s = ""; + assertSame(s, _StringUtils.RTFEnc(s)); + + s = "asd"; + assertSame(s, _StringUtils.RTFEnc(s)); + + testRTFEnc("a\\{b\\}c\\\\d", "a{b}c\\d"); + testRTFEnc("\\{", "{"); + testRTFEnc("\\{a", "{a"); + testRTFEnc("\\{a\\}", "{a}"); + testRTFEnc("a\\}", "a}"); + testRTFEnc("\\{\\}", "{}"); + testRTFEnc("a\\{\\}b", "a{}b"); + } + + private void testRTFEnc(String expected, String in) throws IOException { + assertEquals(expected, _StringUtils.RTFEnc(in)); + + StringWriter sw = new StringWriter(); + _StringUtils.RTFEnc(in, sw); + assertEquals(expected, sw.toString()); + } + + @Test + public void testNormalizeEOLs() { + assertNull(_StringUtils.normalizeEOLs(null)); + assertEquals("", _StringUtils.normalizeEOLs("")); + assertEquals("x", _StringUtils.normalizeEOLs("x")); + assertEquals("x\ny", _StringUtils.normalizeEOLs("x\ny")); + assertEquals("x\ny", _StringUtils.normalizeEOLs("x\r\ny")); + assertEquals("x\ny", _StringUtils.normalizeEOLs("x\ry")); + assertEquals("\n\n\n\n\n\n", _StringUtils.normalizeEOLs("\n\r\r\r\n\r\n\r")); + } + + @Test + public void snakeCaseToCamelCase() { + assertNull(_StringUtils.snakeCaseToCamelCase(null)); + assertEquals("", _StringUtils.snakeCaseToCamelCase("")); + assertEquals("x", _StringUtils.snakeCaseToCamelCase("x")); + assertEquals("xxx", _StringUtils.snakeCaseToCamelCase("xXx")); + assertEquals("fooBar", _StringUtils.snakeCaseToCamelCase("foo_bar")); + assertEquals("fooBar", _StringUtils.snakeCaseToCamelCase("FOO_BAR")); + assertEquals("fooBar", _StringUtils.snakeCaseToCamelCase("_foo__bar_")); + assertEquals("aBC", _StringUtils.snakeCaseToCamelCase("a_b_c")); + } + +}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTComment.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTComment.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTComment.java index 2efd4f7..8a16965 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTComment.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTComment.java @@ -19,7 +19,7 @@ package org.apache.freemarker.core; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * AST comment node @@ -43,7 +43,7 @@ final class ASTComment extends ASTElement { if (canonical) { return "<#--" + text + "-->"; } else { - return "comment " + _StringUtil.jQuote(text.trim()); + return "comment " + _StringUtils.jQuote(text.trim()); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirAssignment.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirAssignment.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirAssignment.java index db548cf..09bf4ea 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirAssignment.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirAssignment.java @@ -22,7 +22,7 @@ package org.apache.freemarker.core; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateNumberModel; import org.apache.freemarker.core.util.BugException; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * AST directive node: An instruction that makes a single assignment, like {@code <#local x=1>}, {@code <#global x=1>}, @@ -154,7 +154,7 @@ final class ASTDirAssignment extends ASTDirective { } else { // Numerical operation Number lhoNumber; if (lhoValue instanceof TemplateNumberModel) { - lhoNumber = _EvalUtil.modelToNumber((TemplateNumberModel) lhoValue, null); + lhoNumber = _EvalUtils.modelToNumber((TemplateNumberModel) lhoValue, null); } else if (lhoValue == null) { throw InvalidReferenceException.getInstance(variableName, getOperatorTypeAsString(), env); } else { @@ -191,7 +191,7 @@ final class ASTDirAssignment extends ASTDirective { buf.append(' '); } - buf.append(_StringUtil.toFTLTopLevelTragetIdentifier(variableName)); + buf.append(_StringUtils.toFTLTopLevelTragetIdentifier(variableName)); if (valueExp != null) { buf.append(' '); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirEscape.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirEscape.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirEscape.java index 56414e4..7a324cd 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirEscape.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirEscape.java @@ -22,7 +22,7 @@ package org.apache.freemarker.core; import java.io.IOException; import org.apache.freemarker.core.ASTExpression.ReplacemenetState; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * AST directive node: {@code #escape}. @@ -60,7 +60,7 @@ class ASTDirEscape extends ASTDirective { StringBuilder sb = new StringBuilder(); if (canonical) sb.append('<'); sb.append(getASTNodeDescriptor()) - .append(' ').append(_StringUtil.toFTLTopLevelIdentifierReference(variable)) + .append(' ').append(_StringUtils.toFTLTopLevelIdentifierReference(variable)) .append(" as ").append(expr.getCanonicalForm()); if (canonical) { sb.append('>'); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirImport.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirImport.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirImport.java index db95913..79b320a 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirImport.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirImport.java @@ -22,7 +22,7 @@ package org.apache.freemarker.core; import java.io.IOException; import org.apache.freemarker.core.templateresolver.MalformedTemplateNameException; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * AST directive node: {@code #import} @@ -75,7 +75,7 @@ final class ASTDirImport extends ASTDirective { buf.append(' '); buf.append(importedTemplateNameExp.getCanonicalForm()); buf.append(" as "); - buf.append(_StringUtil.toFTLTopLevelTragetIdentifier(targetNsVarName)); + buf.append(_StringUtils.toFTLTopLevelTragetIdentifier(targetNsVarName)); if (canonical) buf.append("/>"); return buf.toString(); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirInclude.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirInclude.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirInclude.java index b458537..169541b 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirInclude.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirInclude.java @@ -23,7 +23,7 @@ import java.io.IOException; import org.apache.freemarker.core.templateresolver.MalformedTemplateNameException; import org.apache.freemarker.core.util.BugException; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * AST directive node: {@code #include} @@ -147,7 +147,7 @@ final class ASTDirInclude extends ASTDirective { private boolean getYesNo(ASTExpression exp, String s) throws TemplateException { try { - return _StringUtil.getYesNo(s); + return _StringUtils.getYesNo(s); } catch (IllegalArgumentException iae) { throw new _MiscTemplateException(exp, "Value must be boolean (or one of these strings: " http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirItems.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirItems.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirItems.java index 7290153..0f2508b 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirItems.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirItems.java @@ -21,7 +21,7 @@ package org.apache.freemarker.core; import java.io.IOException; import org.apache.freemarker.core.ASTDirList.IterationContext; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * AST directive node: {@code #items} @@ -66,10 +66,10 @@ class ASTDirItems extends ASTDirective { if (canonical) sb.append('<'); sb.append(getASTNodeDescriptor()); sb.append(" as "); - sb.append(_StringUtil.toFTLTopLevelIdentifierReference(nestedContentParamName)); + sb.append(_StringUtils.toFTLTopLevelIdentifierReference(nestedContentParamName)); if (nestedContentParam2Name != null) { sb.append(", "); - sb.append(_StringUtil.toFTLTopLevelIdentifierReference(nestedContentParam2Name)); + sb.append(_StringUtils.toFTLTopLevelIdentifierReference(nestedContentParam2Name)); } if (canonical) { sb.append('>'); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java index 14c7189..40da397 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirList.java @@ -35,7 +35,7 @@ import org.apache.freemarker.core.model.TemplateModelIterator; import org.apache.freemarker.core.model.TemplateScalarModel; import org.apache.freemarker.core.model.TemplateSequenceModel; import org.apache.freemarker.core.model.impl.SimpleNumber; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * AST directive node: {@code #list} element, or pre-{@code #else} section of it inside a @@ -130,10 +130,10 @@ final class ASTDirList extends ASTDirective { buf.append(listedExp.getCanonicalForm()); if (nestedContentParamName != null) { buf.append(" as "); - buf.append(_StringUtil.toFTLTopLevelIdentifierReference(nestedContentParamName)); + buf.append(_StringUtils.toFTLTopLevelIdentifierReference(nestedContentParamName)); if (nestedContentParam2Name != null) { buf.append(", "); - buf.append(_StringUtil.toFTLTopLevelIdentifierReference(nestedContentParam2Name)); + buf.append(_StringUtils.toFTLTopLevelIdentifierReference(nestedContentParam2Name)); } } if (canonical) { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirMacroOrFunction.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirMacroOrFunction.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirMacroOrFunction.java index 6aecfff..344f86f 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirMacroOrFunction.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirMacroOrFunction.java @@ -28,7 +28,7 @@ import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateModelIterator; import org.apache.freemarker.core.util.StringToIndexMap; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * AST directive node: {@code #macro} or {@code #function} @@ -143,7 +143,7 @@ final class ASTDirMacroOrFunction extends ASTDirective implements TemplateModel if (canonical) sb.append('<'); sb.append(getASTNodeDescriptor()); sb.append(' '); - sb.append(_StringUtil.toFTLTopLevelTragetIdentifier(name)); + sb.append(_StringUtils.toFTLTopLevelTragetIdentifier(name)); if (function) sb.append('('); @@ -160,7 +160,7 @@ final class ASTDirMacroOrFunction extends ASTDirective implements TemplateModel ParameterDefinition paramDef = paramDefsByArgArrayIdx[idx]; - sb.append(_StringUtil.toFTLTopLevelIdentifierReference(paramDef.name)); + sb.append(_StringUtils.toFTLTopLevelIdentifierReference(paramDef.name)); if (!function) { sb.append("{").append(POSITIONAL_PARAMETER_OPTION_NAME).append("}"); } @@ -179,7 +179,7 @@ final class ASTDirMacroOrFunction extends ASTDirective implements TemplateModel firstParam = false; } - sb.append(_StringUtil.toFTLTopLevelIdentifierReference(paramDefsByArgArrayIdx[posVarargsArgIdx].name)); + sb.append(_StringUtils.toFTLTopLevelIdentifierReference(paramDefsByArgArrayIdx[posVarargsArgIdx].name)); if (!function) { sb.append("{").append(POSITIONAL_PARAMETER_OPTION_NAME).append("}"); } @@ -201,7 +201,7 @@ final class ASTDirMacroOrFunction extends ASTDirective implements TemplateModel ParameterDefinition paramDef = paramDefsByArgArrayIdx[idx]; - sb.append(_StringUtil.toFTLTopLevelIdentifierReference(paramDef.name)); + sb.append(_StringUtils.toFTLTopLevelIdentifierReference(paramDef.name)); if (function) { sb.append("{").append(NAMED_PARAMETER_OPTION_NAME).append("}"); } @@ -224,7 +224,7 @@ final class ASTDirMacroOrFunction extends ASTDirective implements TemplateModel firstParam = false; } - sb.append(_StringUtil.toFTLTopLevelIdentifierReference(paramDefsByArgArrayIdx[namedVarargsArgIdx].name)); + sb.append(_StringUtils.toFTLTopLevelIdentifierReference(paramDefsByArgArrayIdx[namedVarargsArgIdx].name)); if (function) { sb.append("{").append(NAMED_PARAMETER_OPTION_NAME).append("}"); } @@ -360,7 +360,7 @@ final class ASTDirMacroOrFunction extends ASTDirective implements TemplateModel @Override public String toString() { return "ParameterDefinition(" + - "name=" + _StringUtil.jQuote(name) + "name=" + _StringUtils.jQuote(name) + (defaultExpression != null ? ", default=" + defaultExpression.getCanonicalForm() : "") + ')'; } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/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 576b05a..2217a18 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 @@ -26,7 +26,7 @@ import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateNumberModel; import org.apache.freemarker.core.model.TemplateScalarModel; import org.apache.freemarker.core.util._SortedArraySet; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * AST directive node: {@code #setting}. @@ -60,12 +60,12 @@ final class ASTDirSetting extends ASTDirective { + "supported."); } else { sb.append("Unknown setting name: "); - sb.append(_StringUtil.jQuote(key)).append("."); + sb.append(_StringUtils.jQuote(key)).append("."); String correctedKey; if (key.indexOf('_') != -1) { - sb.append(MessageUtil.FM3_SNAKE_CASE); - correctedKey = _StringUtil.snakeCaseToCamelCase(key); + sb.append(MessageUtils.FM3_SNAKE_CASE); + correctedKey = _StringUtils.snakeCaseToCamelCase(key); if (!SETTING_NAMES.contains(correctedKey)) { if (key.equals("datetime_format")) { correctedKey = "dateTimeFormat"; @@ -130,7 +130,7 @@ final class ASTDirSetting extends ASTDirective { if (canonical) sb.append('<'); sb.append(getASTNodeDescriptor()); sb.append(' '); - sb.append(_StringUtil.toFTLTopLevelTragetIdentifier(key)); + sb.append(_StringUtils.toFTLTopLevelTragetIdentifier(key)); sb.append('='); sb.append(value.getCanonicalForm()); if (canonical) sb.append("/>"); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSwitch.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSwitch.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSwitch.java index 97d58c3..1d5d6ea 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSwitch.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDirSwitch.java @@ -66,9 +66,9 @@ final class ASTDirSwitch extends ASTDirective { processCase = true; } else if (cas.condition != null) { // Otherwise, if this case isn't the default, test it. - processCase = _EvalUtil.compare( + processCase = _EvalUtils.compare( searched, - _EvalUtil.CMP_OP_EQUALS, "case==", cas.condition, cas.condition, env); + _EvalUtils.CMP_OP_EQUALS, "case==", cas.condition, cas.condition, env); } if (processCase) { env.visit(cas); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java index a2c68e4..9003b07 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java @@ -95,7 +95,7 @@ final class ASTDollarInterpolation extends ASTInterpolation { @Override protected Object calculateInterpolatedStringOrMarkup(Environment env) throws TemplateException { - return _EvalUtil.coerceModelToStringOrMarkup(escapedExpression.eval(env), escapedExpression, null, env); + return _EvalUtils.coerceModelToStringOrMarkup(escapedExpression.eval(env), escapedExpression, null, env); } @Override http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDynamicTopLevelCall.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDynamicTopLevelCall.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDynamicTopLevelCall.java index 7bf4737..7250620 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDynamicTopLevelCall.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTDynamicTopLevelCall.java @@ -32,7 +32,7 @@ import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.util.BugException; import org.apache.freemarker.core.util.CommonSupplier; import org.apache.freemarker.core.util.StringToIndexMap; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -149,7 +149,7 @@ class ASTDynamicTopLevelCall extends ASTDirective implements CallPlace { StringBuilder sb = new StringBuilder(); if (canonical) sb.append('<'); sb.append('@'); - MessageUtil.appendExpressionAsUntearable(sb, callableValueExp); + MessageUtils.appendExpressionAsUntearable(sb, callableValueExp); boolean nameIsInParen = sb.charAt(sb.length() - 1) == ')'; if (positionalArgs != null) { for (int i = 0; i < positionalArgs.length; i++) { @@ -163,7 +163,7 @@ class ASTDynamicTopLevelCall extends ASTDirective implements CallPlace { if (namedArgs != null) { for (NamedArgument namedArg : namedArgs) { sb.append(' '); - sb.append(_StringUtil.toFTLTopLevelIdentifierReference(namedArg.getName())); + sb.append(_StringUtils.toFTLTopLevelIdentifierReference(namedArg.getName())); sb.append('='); sb.append(namedArg.getValue().getCanonicalForm()); } @@ -177,7 +177,7 @@ class ASTDynamicTopLevelCall extends ASTDirective implements CallPlace { } else { first = false; } - sb.append(_StringUtil.toFTLTopLevelIdentifierReference(nestedContentParamName)); + sb.append(_StringUtils.toFTLTopLevelIdentifierReference(nestedContentParamName)); } } if (canonical) { @@ -360,8 +360,8 @@ class ASTDynamicTopLevelCall extends ASTDirective implements CallPlace { } catch (Exception e) { throw new CallPlaceCustomDataInitializationException( "Failed to initialize custom data for provider identity " - + _StringUtil.tryToString(providerIdentity) + " via factory " - + _StringUtil.tryToString(supplier), e); + + _StringUtils.tryToString(providerIdentity) + " via factory " + + _StringUtils.tryToString(supplier), e); } if (customData == null) { throw new NullPointerException("CommonSupplier.get() has returned null"); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpAddOrConcat.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpAddOrConcat.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpAddOrConcat.java index c303daa..4385dac 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpAddOrConcat.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpAddOrConcat.java @@ -68,8 +68,8 @@ final class ASTExpAddOrConcat extends ASTExpression { ASTExpression rightExp, TemplateModel rightModel) throws TemplateException { if (leftModel instanceof TemplateNumberModel && rightModel instanceof TemplateNumberModel) { - Number first = _EvalUtil.modelToNumber((TemplateNumberModel) leftModel, leftExp); - Number second = _EvalUtil.modelToNumber((TemplateNumberModel) rightModel, rightExp); + Number first = _EvalUtils.modelToNumber((TemplateNumberModel) leftModel, leftExp); + Number second = _EvalUtils.modelToNumber((TemplateNumberModel) rightModel, rightExp); return _evalOnNumbers(env, parent, first, second); } else if (leftModel instanceof TemplateSequenceModel && rightModel instanceof TemplateSequenceModel) { return new ConcatenatedSequence((TemplateSequenceModel) leftModel, (TemplateSequenceModel) rightModel); @@ -80,7 +80,7 @@ final class ASTExpAddOrConcat extends ASTExpression { // We try string addition first. If hash addition is possible, then instead of throwing exception // we return null and do hash addition instead. (We can't simply give hash addition a priority, like // with sequence addition above, as FTL strings are often also FTL hashes.) - Object leftOMOrStr = _EvalUtil.coerceModelToStringOrMarkup( + Object leftOMOrStr = _EvalUtils.coerceModelToStringOrMarkup( leftModel, leftExp, /* returnNullOnNonCoercableType = */ hashConcatPossible, null, env); if (leftOMOrStr == null) { @@ -88,7 +88,7 @@ final class ASTExpAddOrConcat extends ASTExpression { } // Same trick with null return as above. - Object rightOMOrStr = _EvalUtil.coerceModelToStringOrMarkup( + Object rightOMOrStr = _EvalUtils.coerceModelToStringOrMarkup( rightModel, rightExp, /* returnNullOnNonCoercableType = */ hashConcatPossible, null, env); if (rightOMOrStr == null) { @@ -100,18 +100,18 @@ final class ASTExpAddOrConcat extends ASTExpression { return new SimpleScalar(((String) leftOMOrStr).concat((String) rightOMOrStr)); } else { // rightOMOrStr instanceof TemplateMarkupOutputModel TemplateMarkupOutputModel<?> rightMO = (TemplateMarkupOutputModel<?>) rightOMOrStr; - return _EvalUtil.concatMarkupOutputs(parent, + return _EvalUtils.concatMarkupOutputs(parent, rightMO.getOutputFormat().fromPlainTextByEscaping((String) leftOMOrStr), rightMO); } } else { // leftOMOrStr instanceof TemplateMarkupOutputModel TemplateMarkupOutputModel<?> leftMO = (TemplateMarkupOutputModel<?>) leftOMOrStr; if (rightOMOrStr instanceof String) { // markup output - return _EvalUtil.concatMarkupOutputs(parent, + return _EvalUtils.concatMarkupOutputs(parent, leftMO, leftMO.getOutputFormat().fromPlainTextByEscaping((String) rightOMOrStr)); } else { // rightOMOrStr instanceof TemplateMarkupOutputModel - return _EvalUtil.concatMarkupOutputs(parent, + return _EvalUtils.concatMarkupOutputs(parent, leftMO, (TemplateMarkupOutputModel<?>) rightOMOrStr); } @@ -148,7 +148,7 @@ final class ASTExpAddOrConcat extends ASTExpression { static TemplateModel _evalOnNumbers(Environment env, ASTNode parent, Number first, Number second) throws TemplateException { - ArithmeticEngine ae = _EvalUtil.getArithmeticEngine(env, parent); + ArithmeticEngine ae = _EvalUtils.getArithmeticEngine(env, parent); return new SimpleNumber(ae.add(first, second)); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpArithmetic.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpArithmetic.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpArithmetic.java index 99fd7f0..e05a72c 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpArithmetic.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpArithmetic.java @@ -53,7 +53,7 @@ final class ASTExpArithmetic extends ASTExpression { static TemplateModel _eval(Environment env, ASTNode parent, Number lhoNumber, int operator, Number rhoNumber) throws TemplateException { - ArithmeticEngine ae = _EvalUtil.getArithmeticEngine(env, parent); + ArithmeticEngine ae = _EvalUtils.getArithmeticEngine(env, parent); switch (operator) { case TYPE_SUBSTRACTION : return new SimpleNumber(ae.subtract(lhoNumber, rhoNumber)); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBooleanLiteral.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBooleanLiteral.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBooleanLiteral.java index 8525ea3..0cb9c50 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBooleanLiteral.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBooleanLiteral.java @@ -44,7 +44,7 @@ final class ASTExpBooleanLiteral extends ASTExpression { @Override public String getCanonicalForm() { - return val ? MiscUtil.C_TRUE : MiscUtil.C_FALSE; + return val ? TemplateBooleanFormat.C_TRUE : TemplateBooleanFormat.C_FALSE; } @Override @@ -54,7 +54,7 @@ final class ASTExpBooleanLiteral extends ASTExpression { @Override public String toString() { - return val ? MiscUtil.C_TRUE : MiscUtil.C_FALSE; + return val ? TemplateBooleanFormat.C_TRUE : TemplateBooleanFormat.C_FALSE; } @Override http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/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 c69c297..7e93646 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 @@ -66,8 +66,8 @@ import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateNumberModel; import org.apache.freemarker.core.model.TemplateScalarModel; -import org.apache.freemarker.core.util._DateUtil; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._DateUtils; +import org.apache.freemarker.core.util._StringUtils; /** * AST expression node: {@code exp?name} @@ -151,66 +151,66 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { putBI("isTime", new BuiltInsForMultipleTypes.is_dateOfTypeBI(TemplateDateModel.TIME)); putBI("isoUtc", new iso_utc_or_local_BI( - /* showOffset = */ null, _DateUtil.ACCURACY_SECONDS, /* useUTC = */ true)); + /* showOffset = */ null, _DateUtils.ACCURACY_SECONDS, /* useUTC = */ true)); putBI("isoUtcFZ", new iso_utc_or_local_BI( - /* showOffset = */ Boolean.TRUE, _DateUtil.ACCURACY_SECONDS, /* useUTC = */ true)); + /* showOffset = */ Boolean.TRUE, _DateUtils.ACCURACY_SECONDS, /* useUTC = */ true)); putBI("isoUtcNZ", new iso_utc_or_local_BI( - /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_SECONDS, /* useUTC = */ true)); + /* showOffset = */ Boolean.FALSE, _DateUtils.ACCURACY_SECONDS, /* useUTC = */ true)); putBI("isoUtcMs", new iso_utc_or_local_BI( - /* showOffset = */ null, _DateUtil.ACCURACY_MILLISECONDS, /* useUTC = */ true)); + /* showOffset = */ null, _DateUtils.ACCURACY_MILLISECONDS, /* useUTC = */ true)); putBI("isoUtcMsNZ", new iso_utc_or_local_BI( - /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_MILLISECONDS, /* useUTC = */ true)); + /* showOffset = */ Boolean.FALSE, _DateUtils.ACCURACY_MILLISECONDS, /* useUTC = */ true)); putBI("isoUtcM", new iso_utc_or_local_BI( - /* showOffset = */ null, _DateUtil.ACCURACY_MINUTES, /* useUTC = */ true)); + /* showOffset = */ null, _DateUtils.ACCURACY_MINUTES, /* useUTC = */ true)); putBI("isoUtcMNZ", new iso_utc_or_local_BI( - /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_MINUTES, /* useUTC = */ true)); + /* showOffset = */ Boolean.FALSE, _DateUtils.ACCURACY_MINUTES, /* useUTC = */ true)); putBI("isoUtcH", new iso_utc_or_local_BI( - /* showOffset = */ null, _DateUtil.ACCURACY_HOURS, /* useUTC = */ true)); + /* showOffset = */ null, _DateUtils.ACCURACY_HOURS, /* useUTC = */ true)); putBI("isoUtcHNZ", new iso_utc_or_local_BI( - /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_HOURS, /* useUTC = */ true)); + /* showOffset = */ Boolean.FALSE, _DateUtils.ACCURACY_HOURS, /* useUTC = */ true)); putBI("isoLocal", new iso_utc_or_local_BI( - /* showOffset = */ null, _DateUtil.ACCURACY_SECONDS, /* useUTC = */ false)); + /* showOffset = */ null, _DateUtils.ACCURACY_SECONDS, /* useUTC = */ false)); putBI("isoLocalNZ", new iso_utc_or_local_BI( - /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_SECONDS, /* useUTC = */ false)); + /* showOffset = */ Boolean.FALSE, _DateUtils.ACCURACY_SECONDS, /* useUTC = */ false)); putBI("isoLocalMs", new iso_utc_or_local_BI( - /* showOffset = */ null, _DateUtil.ACCURACY_MILLISECONDS, /* useUTC = */ false)); + /* showOffset = */ null, _DateUtils.ACCURACY_MILLISECONDS, /* useUTC = */ false)); putBI("isoLocalMsNZ", new iso_utc_or_local_BI( - /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_MILLISECONDS, /* useUTC = */ false)); + /* showOffset = */ Boolean.FALSE, _DateUtils.ACCURACY_MILLISECONDS, /* useUTC = */ false)); putBI("isoLocalM", new iso_utc_or_local_BI( - /* showOffset = */ null, _DateUtil.ACCURACY_MINUTES, /* useUTC = */ false)); + /* showOffset = */ null, _DateUtils.ACCURACY_MINUTES, /* useUTC = */ false)); putBI("isoLocalMNZ", new iso_utc_or_local_BI( - /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_MINUTES, /* useUTC = */ false)); + /* showOffset = */ Boolean.FALSE, _DateUtils.ACCURACY_MINUTES, /* useUTC = */ false)); putBI("isoLocalH", new iso_utc_or_local_BI( - /* showOffset = */ null, _DateUtil.ACCURACY_HOURS, /* useUTC = */ false)); + /* showOffset = */ null, _DateUtils.ACCURACY_HOURS, /* useUTC = */ false)); putBI("isoLocalHNZ", new iso_utc_or_local_BI( - /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_HOURS, /* useUTC = */ false)); + /* showOffset = */ Boolean.FALSE, _DateUtils.ACCURACY_HOURS, /* useUTC = */ false)); putBI("iso", new iso_BI( - /* showOffset = */ null, _DateUtil.ACCURACY_SECONDS)); + /* showOffset = */ null, _DateUtils.ACCURACY_SECONDS)); putBI("isoNZ", new iso_BI( - /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_SECONDS)); + /* showOffset = */ Boolean.FALSE, _DateUtils.ACCURACY_SECONDS)); putBI("isoMs", new iso_BI( - /* showOffset = */ null, _DateUtil.ACCURACY_MILLISECONDS)); + /* showOffset = */ null, _DateUtils.ACCURACY_MILLISECONDS)); putBI("isoMsNZ", new iso_BI( - /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_MILLISECONDS)); + /* showOffset = */ Boolean.FALSE, _DateUtils.ACCURACY_MILLISECONDS)); putBI("isoM", new iso_BI( - /* showOffset = */ null, _DateUtil.ACCURACY_MINUTES)); + /* showOffset = */ null, _DateUtils.ACCURACY_MINUTES)); putBI("isoMNZ", new iso_BI( - /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_MINUTES)); + /* showOffset = */ Boolean.FALSE, _DateUtils.ACCURACY_MINUTES)); putBI("isoH", new iso_BI( - /* showOffset = */ null, _DateUtil.ACCURACY_HOURS)); + /* showOffset = */ null, _DateUtils.ACCURACY_HOURS)); putBI("isoHNZ", new iso_BI( - /* showOffset = */ Boolean.FALSE, _DateUtil.ACCURACY_HOURS)); + /* showOffset = */ Boolean.FALSE, _DateUtils.ACCURACY_HOURS)); putBI("jString", new BuiltInsForStringsEncoding.j_stringBI()); putBI("join", new BuiltInsForSequences.joinBI()); @@ -301,12 +301,12 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { String key = keyTk.image; ASTExpBuiltIn bi = BUILT_INS_BY_NAME.get(key); if (bi == null) { - StringBuilder sb = new StringBuilder("Unknown built-in: ").append(_StringUtil.jQuote(key)).append("."); + StringBuilder sb = new StringBuilder("Unknown built-in: ").append(_StringUtils.jQuote(key)).append("."); String correctedKey; if (key.indexOf("_") != -1) { - sb.append(MessageUtil.FM3_SNAKE_CASE); - correctedKey = _StringUtil.snakeCaseToCamelCase(key); + sb.append(MessageUtils.FM3_SNAKE_CASE); + correctedKey = _StringUtils.snakeCaseToCamelCase(key); if (!BUILT_INS_BY_NAME.containsKey(correctedKey)) { if (correctedKey.length() > 1) { correctedKey = correctedKey.substring(0, correctedKey.length() - 2) @@ -397,7 +397,7 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { protected final void checkMethodArgCount(int argCnt, int expectedCnt) throws TemplateModelException { if (argCnt != expectedCnt) { - throw MessageUtil.newArgCntError("?" + key, argCnt, expectedCnt); + throw MessageUtils.newArgCntError("?" + key, argCnt, expectedCnt); } } @@ -412,7 +412,7 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { protected final void checkMethodArgCount(int argCnt, int minCnt, int maxCnt) throws TemplateModelException { if (argCnt < minCnt || argCnt > maxCnt) { - throw MessageUtil.newArgCntError("?" + key, argCnt, minCnt, maxCnt); + throw MessageUtils.newArgCntError("?" + key, argCnt, minCnt, maxCnt); } } @@ -440,9 +440,9 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { if (optional && arg == null) { return null; } - throw MessageUtil.newMethodArgMustBeStringException("?" + key, argIdx, arg); + throw MessageUtils.newMethodArgMustBeStringException("?" + key, argIdx, arg); } else { - return _EvalUtil.modelToString((TemplateScalarModel) arg, null, null); + return _EvalUtils.modelToString((TemplateScalarModel) arg, null, null); } } @@ -471,18 +471,18 @@ abstract class ASTExpBuiltIn extends ASTExpression implements Cloneable { if (optional && arg == null) { return null; } - throw MessageUtil.newMethodArgMustBeNumberException("?" + key, argIdx, arg); + throw MessageUtils.newMethodArgMustBeNumberException("?" + key, argIdx, arg); } else { - return _EvalUtil.modelToNumber((TemplateNumberModel) arg, null); + return _EvalUtils.modelToNumber((TemplateNumberModel) arg, null); } } protected final TemplateModelException newMethodArgInvalidValueException(int argIdx, Object[] details) { - return MessageUtil.newMethodArgInvalidValueException("?" + key, argIdx, details); + return MessageUtils.newMethodArgInvalidValueException("?" + key, argIdx, details); } protected final TemplateModelException newMethodArgsInvalidValueException(Object[] details) { - return MessageUtil.newMethodArgsInvalidValueException("?" + key, details); + return MessageUtils.newMethodArgsInvalidValueException("?" + key, details); } @Override http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/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 ab50470..d48135e 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 @@ -30,7 +30,7 @@ import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.impl.SimpleDate; import org.apache.freemarker.core.model.impl.SimpleScalar; import org.apache.freemarker.core.util._SortedArraySet; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * AST expression node: {@code .name} @@ -94,12 +94,12 @@ final class ASTExpBuiltInVariable extends ASTExpression { if (!BUILT_IN_VARIABLE_NAMES.contains(name)) { StringBuilder sb = new StringBuilder(); sb.append("Unknown special variable name: "); - sb.append(_StringUtil.jQuote(name)).append("."); + sb.append(_StringUtils.jQuote(name)).append("."); String correctedName; if (name.indexOf('_') != -1) { - sb.append(MessageUtil.FM3_SNAKE_CASE); - correctedName = _StringUtil.snakeCaseToCamelCase(name); + sb.append(MessageUtils.FM3_SNAKE_CASE); + correctedName = _StringUtils.snakeCaseToCamelCase(name); if (!BUILT_IN_VARIABLE_NAMES.contains(correctedName)) { correctedName = null; } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpComparison.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpComparison.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpComparison.java index 7629a94..4f429ac 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpComparison.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpComparison.java @@ -37,17 +37,17 @@ final class ASTExpComparison extends ASTExpBoolean { opString = opString.intern(); this.opString = opString; if (opString == "==") { - operation = _EvalUtil.CMP_OP_EQUALS; + operation = _EvalUtils.CMP_OP_EQUALS; } else if (opString == "!=") { - operation = _EvalUtil.CMP_OP_NOT_EQUALS; + operation = _EvalUtils.CMP_OP_NOT_EQUALS; } else if (opString == "gt" || opString == "\\gt" || opString == ">" || opString == ">") { - operation = _EvalUtil.CMP_OP_GREATER_THAN; + operation = _EvalUtils.CMP_OP_GREATER_THAN; } else if (opString == "gte" || opString == "\\gte" || opString == ">=" || opString == ">=") { - operation = _EvalUtil.CMP_OP_GREATER_THAN_EQUALS; + operation = _EvalUtils.CMP_OP_GREATER_THAN_EQUALS; } else if (opString == "lt" || opString == "\\lt" || opString == "<" || opString == "<") { - operation = _EvalUtil.CMP_OP_LESS_THAN; + operation = _EvalUtils.CMP_OP_LESS_THAN; } else if (opString == "lte" || opString == "\\lte" || opString == "<=" || opString == "<=") { - operation = _EvalUtil.CMP_OP_LESS_THAN_EQUALS; + operation = _EvalUtils.CMP_OP_LESS_THAN_EQUALS; } else { throw new BugException("Unknown comparison operator " + opString); } @@ -59,7 +59,7 @@ final class ASTExpComparison extends ASTExpBoolean { */ @Override boolean evalToBoolean(Environment env) throws TemplateException { - return _EvalUtil.compare(left, operation, opString, right, this, env); + return _EvalUtils.compare(left, operation, opString, right, this, env); } @Override http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDot.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDot.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDot.java index 8fc6a82..c1da34e 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDot.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDot.java @@ -21,7 +21,7 @@ package org.apache.freemarker.core; import org.apache.freemarker.core.model.TemplateHashModel; import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * AST expression node: {@code .} operator. @@ -46,7 +46,7 @@ final class ASTExpDot extends ASTExpression { @Override public String getCanonicalForm() { - return target.getCanonicalForm() + getASTNodeDescriptor() + _StringUtil.toFTLIdentifierReferenceAfterDot(key); + return target.getCanonicalForm() + getASTNodeDescriptor() + _StringUtils.toFTLIdentifierReferenceAfterDot(key); } @Override http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDynamicKeyName.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDynamicKeyName.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDynamicKeyName.java index 416019c..c69972f 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDynamicKeyName.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpDynamicKeyName.java @@ -52,7 +52,7 @@ final class ASTExpDynamicKeyName extends ASTExpression { return dealWithNumericalKey(targetModel, index, env); } if (keyModel instanceof TemplateScalarModel) { - String key = _EvalUtil.modelToString((TemplateScalarModel) keyModel, keyExpression, env); + String key = _EvalUtils.modelToString((TemplateScalarModel) keyModel, keyExpression, env); return dealWithStringKey(targetModel, key, env); } if (keyModel instanceof RangeModel) { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpFunctionCall.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpFunctionCall.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpFunctionCall.java index 5101db7..391e5a7 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpFunctionCall.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpFunctionCall.java @@ -30,7 +30,7 @@ import org.apache.freemarker.core._CallableUtils.NamedArgument; import org.apache.freemarker.core.model.TemplateFunctionModel; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.util.CommonSupplier; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** @@ -97,7 +97,7 @@ final class ASTExpFunctionCall extends ASTExpression implements CallPlace { } else { first = false; } - sb.append(_StringUtil.toFTLTopLevelIdentifierReference(namedArg.getName())); + sb.append(_StringUtils.toFTLTopLevelIdentifierReference(namedArg.getName())); sb.append('='); sb.append(namedArg.getValue().getCanonicalForm()); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/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 b66eb1d..0dbcfb1 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 @@ -105,7 +105,7 @@ final class ASTExpStringLiteral extends ASTExpression implements TemplateScalarM TemplateMarkupOutputModel<?> partMO = calcedPart instanceof String ? markupResult.getOutputFormat().fromPlainTextByEscaping((String) calcedPart) : (TemplateMarkupOutputModel<?>) calcedPart; - markupResult = _EvalUtil.concatMarkupOutputs(this, markupResult, partMO); + markupResult = _EvalUtils.concatMarkupOutputs(this, markupResult, partMO); } else { // We are using `plainTextOutput` (or nothing yet) if (calcedPart instanceof String) { String partStr = (String) calcedPart; @@ -119,7 +119,7 @@ final class ASTExpStringLiteral extends ASTExpression implements TemplateScalarM if (plainTextResult != null) { TemplateMarkupOutputModel<?> leftHandMO = moPart.getOutputFormat() .fromPlainTextByEscaping(plainTextResult.toString()); - markupResult = _EvalUtil.concatMarkupOutputs(this, leftHandMO, moPart); + markupResult = _EvalUtils.concatMarkupOutputs(this, leftHandMO, moPart); plainTextResult = null; } else { markupResult = moPart; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpVariable.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpVariable.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpVariable.java index e4a2327..890563f 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpVariable.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpVariable.java @@ -20,7 +20,7 @@ package org.apache.freemarker.core; import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * AST expression node: Reference to a "top-level" (local, current namespace, global, data-model) variable @@ -50,7 +50,7 @@ final class ASTExpVariable extends ASTExpression { @Override public String getCanonicalForm() { - return _StringUtil.toFTLTopLevelIdentifierReference(name); + return _StringUtils.toFTLTopLevelIdentifierReference(name); } /** http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpression.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpression.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpression.java index be00f66..97f82a5 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpression.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpression.java @@ -72,36 +72,36 @@ abstract class ASTExpression extends ASTNode { } String evalAndCoerceToPlainText(Environment env) throws TemplateException { - return _EvalUtil.coerceModelToPlainText(eval(env), this, null, env); + return _EvalUtils.coerceModelToPlainText(eval(env), this, null, env); } /** * @param seqTip Tip to display if the value type is not coercable, but it's sequence or collection. */ String evalAndCoerceToPlainText(Environment env, String seqTip) throws TemplateException { - return _EvalUtil.coerceModelToPlainText(eval(env), this, seqTip, env); + return _EvalUtils.coerceModelToPlainText(eval(env), this, seqTip, env); } Object evalAndCoerceToStringOrMarkup(Environment env) throws TemplateException { - return _EvalUtil.coerceModelToStringOrMarkup(eval(env), this, null, env); + return _EvalUtils.coerceModelToStringOrMarkup(eval(env), this, null, env); } /** * @param seqTip Tip to display if the value type is not coercable, but it's sequence or collection. */ Object evalAndCoerceToStringOrMarkup(Environment env, String seqTip) throws TemplateException { - return _EvalUtil.coerceModelToStringOrMarkup(eval(env), this, seqTip, env); + return _EvalUtils.coerceModelToStringOrMarkup(eval(env), this, seqTip, env); } String evalAndCoerceToStringOrUnsupportedMarkup(Environment env) throws TemplateException { - return _EvalUtil.coerceModelToStringOrUnsupportedMarkup(eval(env), this, null, env); + return _EvalUtils.coerceModelToStringOrUnsupportedMarkup(eval(env), this, null, env); } /** * @param seqTip Tip to display if the value type is not coercable, but it's sequence or collection. */ String evalAndCoerceToStringOrUnsupportedMarkup(Environment env, String seqTip) throws TemplateException { - return _EvalUtil.coerceModelToStringOrUnsupportedMarkup(eval(env), this, seqTip, env); + return _EvalUtils.coerceModelToStringOrUnsupportedMarkup(eval(env), this, seqTip, env); } Number evalToNumber(Environment env) throws TemplateException { @@ -111,7 +111,7 @@ abstract class ASTExpression extends ASTNode { Number modelToNumber(TemplateModel model, Environment env) throws TemplateException { if (model instanceof TemplateNumberModel) { - return _EvalUtil.modelToNumber((TemplateNumberModel) model, this); + return _EvalUtils.modelToNumber((TemplateNumberModel) model, this); } else { throw new NonNumericalException(this, model, env); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/ASTNode.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTNode.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTNode.java index 6a2ce15..4ca9b7f 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTNode.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTNode.java @@ -88,7 +88,7 @@ abstract class ASTNode { * where in the template source, this object is. */ public String getStartLocation() { - return MessageUtil.formatLocationForEvaluationError(template, beginLine, beginColumn); + return MessageUtils.formatLocationForEvaluationError(template, beginLine, beginColumn); } /** @@ -100,7 +100,7 @@ abstract class ASTNode { } public String getEndLocation() { - return MessageUtil.formatLocationForEvaluationError(template, endLine, endColumn); + return MessageUtils.formatLocationForEvaluationError(template, endLine, endColumn); } /** http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/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 eceb412..76f1019 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 @@ -21,8 +21,8 @@ package org.apache.freemarker.core; import java.io.IOException; -import org.apache.freemarker.core.util._CollectionUtil; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._CollectionUtils; +import org.apache.freemarker.core.util._StringUtils; /** * AST node representing static text. @@ -76,7 +76,7 @@ final class ASTStaticText extends ASTElement { } return text; } else { - return "text " + _StringUtil.jQuote(new String(text)); + return "text " + _StringUtils.jQuote(new String(text)); } } @@ -155,7 +155,7 @@ final class ASTStaticText extends ASTElement { if (lastNewLineIndex >= 0 || beginColumn == 1) { char[] firstPart = substring(text, 0, lastNewLineIndex + 1); char[] lastLine = substring(text, 1 + lastNewLineIndex); - if (_StringUtil.isTrimmableToEmpty(lastLine)) { + if (_StringUtils.isTrimmableToEmpty(lastLine)) { text = firstPart; endColumn = 0; } else { @@ -200,7 +200,7 @@ final class ASTStaticText extends ASTElement { } char[] trailingPart = substring(text, firstLineIndex); char[] openingPart = substring(text, 0, firstLineIndex); - if (_StringUtil.isTrimmableToEmpty(openingPart)) { + if (_StringUtils.isTrimmableToEmpty(openingPart)) { text = trailingPart; beginLine++; beginColumn = 1; @@ -210,7 +210,7 @@ final class ASTStaticText extends ASTElement { lastNonWS--; } char[] printablePart = substring(text, 0, lastNonWS + 1); - if (_StringUtil.isTrimmableToEmpty(trailingPart)) { + if (_StringUtils.isTrimmableToEmpty(trailingPart)) { // THIS BLOCK IS HEINOUS! THERE MUST BE A BETTER WAY! REVISIT (JR) boolean trimTrailingPart = true; for (ASTElement te = nextTerminalNode(); @@ -224,7 +224,7 @@ final class ASTStaticText extends ASTElement { break; } } - if (trimTrailingPart) trailingPart = _CollectionUtil.EMPTY_CHAR_ARRAY; + if (trimTrailingPart) trailingPart = _CollectionUtils.EMPTY_CHAR_ARRAY; } text = concat(printablePart, trailingPart); } @@ -271,7 +271,7 @@ final class ASTStaticText extends ASTElement { ++newlineIndex; } } - if (!_StringUtil.isTrimmableToEmpty(text, 0, newlineIndex)) { + if (!_StringUtils.isTrimmableToEmpty(text, 0, newlineIndex)) { return 0; } // We look at the preceding elements on the line to see if we should @@ -295,7 +295,7 @@ final class ASTStaticText extends ASTElement { if (lastNewlineIndex == -1 && beginColumn != 1) { return 0; } - if (!_StringUtil.isTrimmableToEmpty(text, lastNewlineIndex + 1)) { + if (!_StringUtils.isTrimmableToEmpty(text, lastNewlineIndex + 1)) { return 0; } // We look at the elements afterward on the same line to see if we should @@ -349,7 +349,7 @@ final class ASTStaticText extends ASTElement { return true; } if (stripWhitespace) { - if (!_StringUtil.isTrimmableToEmpty(text)) { + if (!_StringUtils.isTrimmableToEmpty(text)) { return false; } ASTElement parentElement = getParent(); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForDate.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForDate.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForDate.java index 33971f5..44fda23 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForDate.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForDate.java @@ -31,7 +31,7 @@ abstract class BuiltInForDate extends ASTExpBuiltIn { TemplateModel model = target.eval(env); if (model instanceof TemplateDateModel) { TemplateDateModel tdm = (TemplateDateModel) model; - return calculateResult(_EvalUtil.modelToDate(tdm, target), tdm.getDateType(), env); + return calculateResult(_EvalUtils.modelToDate(tdm, target), tdm.getDateType(), env); } else { throw newNonDateException(env, model, target); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForLegacyEscaping.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForLegacyEscaping.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForLegacyEscaping.java index 8cdcbf6..e1f46d1 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForLegacyEscaping.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInForLegacyEscaping.java @@ -31,7 +31,7 @@ abstract class BuiltInForLegacyEscaping extends BuiltInBannedWhenAutoEscaping { TemplateModel _eval(Environment env) throws TemplateException { TemplateModel tm = target.eval(env); - Object moOrStr = _EvalUtil.coerceModelToStringOrMarkup(tm, target, null, env); + Object moOrStr = _EvalUtils.coerceModelToStringOrMarkup(tm, target, null, env); if (moOrStr instanceof String) { return calculateResult((String) moOrStr, env); } else { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java index 3760c77..829c5fa 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/BuiltInsForDates.java @@ -31,7 +31,7 @@ import org.apache.freemarker.core.model.TemplateScalarModel; import org.apache.freemarker.core.model.impl.SimpleDate; import org.apache.freemarker.core.model.impl.SimpleScalar; import org.apache.freemarker.core.util.UnrecognizedTimeZoneException; -import org.apache.freemarker.core.util._DateUtil; +import org.apache.freemarker.core.util._DateUtils; /** * A holder for built-ins that operate exclusively on date left-hand values. @@ -56,7 +56,7 @@ class BuiltInsForDates { if (tdmDateType != TemplateDateModel.UNKNOWN) { return tdm; } - return new SimpleDate(_EvalUtil.modelToDate(tdm, target), dateType); + return new SimpleDate(_EvalUtils.modelToDate(tdm, target), dateType); } else { throw BuiltInForDate.newNonDateException(env, model, target); } @@ -94,9 +94,9 @@ class BuiltInsForDates { instanceof TimeZone) { tzArg = (TimeZone) adaptedObj; } else if (tzArgTM instanceof TemplateScalarModel) { - String tzName = _EvalUtil.modelToString((TemplateScalarModel) tzArgTM, null, null); + String tzName = _EvalUtils.modelToString((TemplateScalarModel) tzArgTM, null, null); try { - tzArg = _DateUtil.getTimeZone(tzName); + tzArg = _DateUtils.getTimeZone(tzName); } catch (UnrecognizedTimeZoneException e) { throw new _TemplateModelException( "The time zone string specified for ?", key, @@ -104,11 +104,11 @@ class BuiltInsForDates { new _DelayedJQuote(tzName)); } } else { - throw MessageUtil.newMethodArgUnexpectedTypeException( + throw MessageUtils.newMethodArgUnexpectedTypeException( "?" + key, 0, "string or java.util.TimeZone", tzArgTM); } - return new SimpleScalar(_DateUtil.dateToISO8601String( + return new SimpleScalar(_DateUtils.dateToISO8601String( date, dateType != TemplateDateModel.TIME, dateType != TemplateDateModel.DATE, @@ -157,14 +157,14 @@ class BuiltInsForDates { Date date, int dateType, Environment env) throws TemplateException { checkDateTypeNotUnknown(dateType); - return new SimpleScalar(_DateUtil.dateToISO8601String( + return new SimpleScalar(_DateUtils.dateToISO8601String( date, dateType != TemplateDateModel.TIME, dateType != TemplateDateModel.DATE, shouldShowOffset(date, dateType, env), accuracy, useUTC - ? _DateUtil.UTC + ? _DateUtils.UTC : env.shouldUseSQLDTTZ(date.getClass()) ? env.getSQLDateAndTimeTimeZone() : env.getTimeZone(), @@ -191,7 +191,7 @@ class BuiltInsForDates { throw new _MiscTemplateException(new _ErrorDescriptionBuilder( "The value of the following has unknown date type, but ?", key, " needs a value where it's known if it's a date (no time part), time, or date-time value:" - ).blame(target).tip(MessageUtil.UNKNOWN_DATE_TYPE_ERROR_TIP)); + ).blame(target).tip(MessageUtils.UNKNOWN_DATE_TYPE_ERROR_TIP)); } }