freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [2/3] incubator-freemarker git commit: (Could make some more classes and members package private now.)
Date Sun, 26 Feb 2017 01:30:58 GMT
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/main/java/org/apache/freemarker/core/Template.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/Template.java b/src/main/java/org/apache/freemarker/core/Template.java
index 76053ee..dc831d6 100644
--- a/src/main/java/org/apache/freemarker/core/Template.java
+++ b/src/main/java/org/apache/freemarker/core/Template.java
@@ -32,7 +32,6 @@ import java.io.Writer;
 import java.lang.reflect.UndeclaredThrowableException;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -79,7 +78,7 @@ public class Template extends Configurable {
     
     private Map macros = new HashMap();
     private List imports = new Vector();
-    private _ASTElement rootElement;
+    private ASTElement rootElement;
     private String encoding, defaultNS;
     private Object customLookupCondition;
     private int actualTagSyntax;
@@ -284,17 +283,17 @@ public class Template extends Configurable {
         namespaceURIToPrefixLookup = Collections.unmodifiableMap(namespaceURIToPrefixLookup);
         prefixToNamespaceURILookup = Collections.unmodifiableMap(prefixToNamespaceURILookup);
     }
-    
+
     /**
-     * Same as {@link #getPlainTextTemplate(String, String, String, Configuration)} with {@code null} {@code sourceName}
-     * argument.
+     * Same as {@link #createPlainTextTemplate(String, String, String, Configuration, String)} with {@code null}
+     * {@code sourceName} argument.
      */
-    static public Template getPlainTextTemplate(String name, String content, Configuration config) {
-        return getPlainTextTemplate(name, null, content, config);
+    static public Template createPlainTextTemplate(String name, String content, Configuration config) {
+        return createPlainTextTemplate(name, null, content, config, null);
     }
-    
+
     /**
-     * Creates (not "get"-s) a {@link Template} that only contains a single block of static text, no dynamic content.
+     * Creates a {@link Template} that only contains a single block of static text, no dynamic content.
      * 
      * @param name
      *            See {@link #getName} for more details.
@@ -304,10 +303,12 @@ public class Template extends Configurable {
      *            the block of text that this template represents
      * @param config
      *            the configuration to which this template belongs
-     * 
+     *
+     * @param encoding
      * @since 2.3.22
      */
-    static public Template getPlainTextTemplate(String name, String sourceName, String content, Configuration config) {
+    static public Template createPlainTextTemplate(String name, String sourceName, String content, Configuration config,
+               String encoding) {
         Template template;
         try {
             template = new Template(name, sourceName, new StringReader("X"), config);
@@ -315,7 +316,10 @@ public class Template extends Configurable {
             throw new BugException("Plain text template creation failed", e);
         }
         ((ASTStaticText) template.rootElement).replaceText(content);
+        template.setEncoding(encoding);
+
         DebuggerService.registerTemplate(template);
+
         return template;
     }
 
@@ -566,11 +570,8 @@ public class Template extends Configurable {
      *            The encoding that was used to read this template. When this template {@code #include}-s or
      *            {@code #import}-s another template, by default it will use this encoding for those. For backward
      *            compatibility, this can be {@code null}, which will unset this setting.
-     * 
-     * @deprecated Should only be used internally, and might will be removed later.
      */
-    @Deprecated
-    public void setEncoding(String encoding) {
+    void setEncoding(String encoding) {
         this.encoding = encoding;
     }
 
@@ -685,23 +686,11 @@ public class Template extends Configurable {
         out.write(rootElement.getCanonicalForm());
     }
 
-    /**
-     * Called by code internally to maintain a table of macros
-     * 
-     * @deprecated Should only be used internally, and might will be removed later.
-     */
-    @Deprecated
-    public void addMacro(ASTDirMacro macro) {
+    void addMacro(ASTDirMacro macro) {
         macros.put(macro.getName(), macro);
     }
 
-    /**
-     * Called by code internally to maintain a list of imports
-     * 
-     * @deprecated Should only be used internally, and might will be removed later.
-     */
-    @Deprecated
-    public void addImport(ASTDirImport ll) {
+    void addImport(ASTDirImport ll) {
         imports.add(ll);
     }
 
@@ -853,37 +842,19 @@ public class Template extends Configurable {
         }
     }
 
-    /**
-     * @deprecated Should only be used internally, and might will be removed later.
-     */
-    @Deprecated
-    public _ASTElement getRootTreeNode() {
+    ASTElement getRootASTNode() {
         return rootElement;
     }
     
-    /**
-     * @deprecated Should only be used internally, and might will be removed later.
-     */
-    @Deprecated
-    public Map getMacros() {
+    Map getMacros() {
         return macros;
     }
 
-    /**
-     * @deprecated Should only be used internally, and might will be removed later.
-     */
-    @Deprecated
-    public List getImports() {
+    List getImports() {
         return imports;
     }
 
-    /**
-     * This is used internally.
-     * 
-     * @deprecated Should only be used internally, and might will be removed later.
-     */
-    @Deprecated
-    public void addPrefixNSMapping(String prefix, String nsURI) {
+    void addPrefixNSMapping(String prefix, String nsURI) {
         if (nsURI.length() == 0) {
             throw new IllegalArgumentException("Cannot map empty string URI");
         }
@@ -959,28 +930,6 @@ public class Template extends Configurable {
         }
         return prefix + ":" + localName;
     }
-    
-    /**
-     * @return an array of the {@link _ASTElement}s containing the given column and line numbers.
-     * @deprecated Should only be used internally, and might will be removed later.
-     */
-    @Deprecated
-    public List containingElements(int column, int line) {
-        final ArrayList elements = new ArrayList();
-        _ASTElement element = rootElement;
-        mainloop: while (element.contains(column, line)) {
-            elements.add(element);
-            for (Enumeration enumeration = element.children(); enumeration.hasMoreElements(); ) {
-                _ASTElement elem = (_ASTElement) enumeration.nextElement();
-                if (elem.contains(column, line)) {
-                    element = elem;
-                    continue mainloop;
-                }
-            }
-            break;
-        }
-        return elements.isEmpty() ? null : elements;
-    }
 
     /**
      * Thrown by the {@link Template} constructors that specify a non-{@code null} encoding whoch doesn't match the

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/main/java/org/apache/freemarker/core/TemplateElementArrayBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/TemplateElementArrayBuilder.java b/src/main/java/org/apache/freemarker/core/TemplateElementArrayBuilder.java
index cbe745c..fba4a0f 100644
--- a/src/main/java/org/apache/freemarker/core/TemplateElementArrayBuilder.java
+++ b/src/main/java/org/apache/freemarker/core/TemplateElementArrayBuilder.java
@@ -21,7 +21,7 @@ package org.apache.freemarker.core;
 import org.apache.freemarker.core.util._CollectionUtil;
 
 /**
- * Holds an buffer (array) of {@link _ASTElement}-s with the count of the utilized items in it. The un-utilized tail
+ * Holds an buffer (array) of {@link ASTElement}-s with the count of the utilized items in it. The un-utilized tail
  * of the array must only contain {@code null}-s.
  * 
  * @since 2.3.24
@@ -30,7 +30,7 @@ class TemplateElements {
     
     static final TemplateElements EMPTY = new TemplateElements(null, 0);
 
-    private final _ASTElement[] buffer;
+    private final ASTElement[] buffer;
     private final int count;
 
     /**
@@ -39,7 +39,7 @@ class TemplateElements {
      * @param count
      *            The number of utilized buffer elements; if 0, then {@code null} must be {@code null}.
      */
-    TemplateElements(_ASTElement[] buffer, int count) {
+    TemplateElements(ASTElement[] buffer, int count) {
         /*
         // Assertion:
         if (count == 0 && buffer != null) {
@@ -51,7 +51,7 @@ class TemplateElements {
         this.count = count;
     }
 
-    _ASTElement[] getBuffer() {
+    ASTElement[] getBuffer() {
         return buffer;
     }
 
@@ -59,22 +59,22 @@ class TemplateElements {
         return count;
     }
 
-    _ASTElement getFirst() {
+    ASTElement getFirst() {
         return buffer != null ? buffer[0] : null;
     }
     
-    _ASTElement getLast() {
+    ASTElement getLast() {
         return buffer != null ? buffer[count - 1] : null;
     }
     
     /**
      * Used for some backward compatibility hacks.
      */
-    _ASTElement asSingleElement() {
+    ASTElement asSingleElement() {
         if (count == 0) {
             return new ASTStaticText(_CollectionUtil.EMPTY_CHAR_ARRAY, false);
         } else {
-            _ASTElement first = buffer[0];
+            ASTElement first = buffer[0];
             if (count == 1) {
                 return first;
             } else {
@@ -92,7 +92,7 @@ class TemplateElements {
     ASTImplicitParent asMixedContent() {
         ASTImplicitParent mixedContent = new ASTImplicitParent();
         if (count != 0) {
-            _ASTElement first = buffer[0];
+            ASTElement first = buffer[0];
             mixedContent.setChildren(this);
             mixedContent.setLocation(first.getTemplate(), first, getLast());
         }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/main/java/org/apache/freemarker/core/TemplateElementsToVisit.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/TemplateElementsToVisit.java b/src/main/java/org/apache/freemarker/core/TemplateElementsToVisit.java
index bd9d473..c49ada6 100644
--- a/src/main/java/org/apache/freemarker/core/TemplateElementsToVisit.java
+++ b/src/main/java/org/apache/freemarker/core/TemplateElementsToVisit.java
@@ -22,26 +22,26 @@ import java.util.Collection;
 import java.util.Collections;
 
 /**
- * Used as the return value of {@link _ASTElement#accept(Environment)} when the invoked element has nested elements
+ * Used as the return value of {@link ASTElement#accept(Environment)} when the invoked element has nested elements
  * to invoke. It would be more natural to invoke child elements before returning from
- * {@link _ASTElement#accept(Environment)}, however, if there's nothing to do after the child elements were invoked,
+ * {@link ASTElement#accept(Environment)}, however, if there's nothing to do after the child elements were invoked,
  * that would mean wasting stack space.
  * 
  * @since 2.3.24
  */
 class TemplateElementsToVisit {
 
-    private final Collection<_ASTElement> templateElements;
+    private final Collection<ASTElement> templateElements;
 
-    TemplateElementsToVisit(Collection<_ASTElement> templateElements) {
-        this.templateElements = null != templateElements ? templateElements : Collections.<_ASTElement> emptyList();
+    TemplateElementsToVisit(Collection<ASTElement> templateElements) {
+        this.templateElements = null != templateElements ? templateElements : Collections.<ASTElement> emptyList();
     }
 
-    TemplateElementsToVisit(_ASTElement nestedBlock) {
+    TemplateElementsToVisit(ASTElement nestedBlock) {
         this(Collections.singleton(nestedBlock));
     }
 
-    Collection<_ASTElement> getTemplateElements() {
+    Collection<ASTElement> getTemplateElements() {
         return templateElements;
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/main/java/org/apache/freemarker/core/TemplateException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/TemplateException.java b/src/main/java/org/apache/freemarker/core/TemplateException.java
index 9721447..3302c74 100644
--- a/src/main/java/org/apache/freemarker/core/TemplateException.java
+++ b/src/main/java/org/apache/freemarker/core/TemplateException.java
@@ -42,7 +42,7 @@ public class TemplateException extends Exception {
     private transient _ErrorDescriptionBuilder descriptionBuilder;
     private final transient Environment env;
     private final transient ASTExpression blamedExpression;
-    private transient _ASTElement[] ftlInstructionStackSnapshot;
+    private transient ASTElement[] ftlInstructionStackSnapshot;
     
     // Calculated on demand:
     private String renderedFtlInstructionStackSnapshot;  // clalc. from ftlInstructionStackSnapshot 
@@ -276,7 +276,7 @@ public class TemplateException extends Exception {
         }
     }
 
-    private _ASTElement getFailingInstruction() {
+    private ASTElement getFailingInstruction() {
         if (ftlInstructionStackSnapshot != null && ftlInstructionStackSnapshot.length > 0) {
             return ftlInstructionStackSnapshot[0];
         } else {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java b/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
index c24f2f2..27b6dce 100644
--- a/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
+++ b/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
@@ -48,11 +48,11 @@ class ThreadInterruptionSupportTemplatePostProcessor extends TemplatePostProcess
 
     @Override
     public void postProcess(Template t) throws TemplatePostProcessorException {
-        final _ASTElement te = t.getRootTreeNode();
+        final ASTElement te = t.getRootASTNode();
         addInterruptionChecks(te);
     }
 
-    private void addInterruptionChecks(final _ASTElement te) throws TemplatePostProcessorException {
+    private void addInterruptionChecks(final ASTElement te) throws TemplatePostProcessorException {
         if (te == null) {
             return;
         }
@@ -75,14 +75,14 @@ class ThreadInterruptionSupportTemplatePostProcessor extends TemplatePostProcess
      * AST directive-like node: Checks if the current thread's "interrupted" flag is set, and throws
      * {@link TemplateProcessingThreadInterruptedException} if it is. We inject this to some points into the AST.
      */
-    static class ASTThreadInterruptionCheck extends _ASTElement {
+    static class ASTThreadInterruptionCheck extends ASTElement {
         
-        private ASTThreadInterruptionCheck(_ASTElement te) throws ParseException {
+        private ASTThreadInterruptionCheck(ASTElement te) throws ParseException {
             setLocation(te.getTemplate(), te.beginColumn, te.beginLine, te.beginColumn, te.beginLine);
         }
 
         @Override
-        _ASTElement[] accept(Environment env) throws TemplateException, IOException {
+        ASTElement[] accept(Environment env) throws TemplateException, IOException {
             // As the API doesn't allow throwing InterruptedException here (nor anywhere else, most importantly,
             // Template.process can't throw it), we must not clear the "interrupted" flag of the thread.
             if (Thread.currentThread().isInterrupted()) {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/main/java/org/apache/freemarker/core/_ASTDebugBreak.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/_ASTDebugBreak.java b/src/main/java/org/apache/freemarker/core/_ASTDebugBreak.java
deleted file mode 100644
index f113722..0000000
--- a/src/main/java/org/apache/freemarker/core/_ASTDebugBreak.java
+++ /dev/null
@@ -1,90 +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.io.IOException;
-
-import org.apache.freemarker.core.debug.impl.DebuggerService;
-
-/**
- * Don't use this; used internally by FreeMarker, might changes without notice.
- * A debug breakpoint inserted into the template 
- */
-class _ASTDebugBreak extends _ASTElement {
-    public _ASTDebugBreak(_ASTElement nestedBlock) {
-        addChild(nestedBlock);
-        copyLocationFrom(nestedBlock);
-    }
-    
-    @Override
-    protected _ASTElement[] accept(Environment env) throws TemplateException, IOException {
-        if (!DebuggerService.suspendEnvironment(
-                env, getTemplate().getSourceName(), getChild(0).getBeginLine())) {
-            return getChild(0).accept(env);
-        } else {
-            throw new StopException(env, "Stopped by debugger");
-        }
-    }
-
-    @Override
-    protected String dump(boolean canonical) {
-        if (canonical) {
-            StringBuilder sb = new StringBuilder();
-            sb.append("<#-- ");
-            sb.append("debug break");
-            if (getChildCount() == 0) {
-                sb.append(" /-->");
-            } else {
-                sb.append(" -->");
-                sb.append(getChild(0).getCanonicalForm());                
-                sb.append("<#--/ debug break -->");
-            }
-            return sb.toString();
-        } else {
-            return "debug break";
-        }
-    }
-    
-    @Override
-    String getNodeTypeSymbol() {
-        return "#debug_break";
-    }
-
-    @Override
-    int getParameterCount() {
-        return 0;
-    }
-
-    @Override
-    Object getParameterValue(int idx) {
-        throw new IndexOutOfBoundsException();
-    }
-
-    @Override
-    ParameterRole getParameterRole(int idx) {
-        throw new IndexOutOfBoundsException();
-    }
-
-    @Override
-    boolean isNestedBlockRepeater() {
-        return false;
-    }
-        
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/main/java/org/apache/freemarker/core/_ASTElement.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/_ASTElement.java b/src/main/java/org/apache/freemarker/core/_ASTElement.java
deleted file mode 100644
index bac5540..0000000
--- a/src/main/java/org/apache/freemarker/core/_ASTElement.java
+++ /dev/null
@@ -1,473 +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.io.IOException;
-import java.util.Collections;
-import java.util.Enumeration;
-
-import org.apache.freemarker.core.model.TemplateNodeModel;
-import org.apache.freemarker.core.model.TemplateSequenceModel;
-import org.apache.freemarker.core.model.impl.SimpleSequence;
-import org.apache.freemarker.core.util._ArrayEnumeration;
-
-/**
- * AST non-expression node superclass: Superclass of directive calls, interpolations, static text, top-level comments,
- * or other such non-expression node in the parsed template. Some information that can be found here can be accessed
- * through the {@link Environment#getCurrentDirectiveCallPlace()}, which is a published API, and thus promises backward
- * compatibility.
- */
-// TODO [FM3] Get rid of "public" and thus the "_" prefix
-abstract class _ASTElement extends ASTNode {
-
-    private static final int INITIAL_CHILD_BUFFER_CAPACITY = 6;
-
-    private _ASTElement parent;
-
-    /**
-     * Contains 1 or more nested elements with optional trailing {@code null}-s, or is {@code null} exactly if there are
-     * no nested elements.
-     */
-    private _ASTElement[] childBuffer;
-
-    /**
-     * Contains the number of elements in the {@link #childBuffer}, not counting the trailing {@code null}-s. If this is
-     * 0, then and only then {@link #childBuffer} must be {@code null}.
-     */
-    private int childCount;
-
-    /**
-     * The index of the element in the parent's {@link #childBuffer} array.
-     * 
-     * @since 2.3.23
-     */
-    private int index;
-
-    /**
-     * Executes this {@link _ASTElement}. Usually should not be called directly, but through
-     * {@link Environment#visit(_ASTElement)} or a similar {@link Environment} method.
-     *
-     * @param env
-     *            The runtime environment
-     * 
-     * @return The template elements to execute (meant to be used for nested elements), or {@code null}. Can have
-     *         <em>trailing</em> {@code null}-s (unused buffer capacity). Returning the nested elements instead of
-     *         executing them inside this method is a trick used for decreasing stack usage when there's nothing to do
-     *         after the children was processed anyway.
-     */
-    abstract _ASTElement[] accept(Environment env) throws TemplateException, IOException;
-
-    /**
-     * One-line description of the element, that contain all the information that is used in {@link #getCanonicalForm()}
-     * , except the nested content (elements) of the element. The expressions inside the element (the parameters) has to
-     * be shown. Meant to be used for stack traces, also for tree views that don't go down to the expression-level.
-     * There are no backward-compatibility guarantees regarding the format used ATM, but it must be regular enough to be
-     * machine-parseable, and it must contain all information necessary for restoring an AST equivalent to the original.
-     * 
-     * This final implementation calls {@link #dump(boolean) dump(false)}.
-     * 
-     * @see #getCanonicalForm()
-     * @see #getNodeTypeSymbol()
-     */
-    public final String getDescription() {
-        return dump(false);
-    }
-
-    /**
-     * This final implementation calls {@link #dump(boolean) dump(false)}.
-     */
-    @Override
-    public final String getCanonicalForm() {
-        return dump(true);
-    }
-
-    final String getChildrenCanonicalForm() {
-        return getChildrenCanonicalForm(childBuffer);
-    }
-    
-    static String getChildrenCanonicalForm(_ASTElement[] children) {
-        if (children == null) {
-            return "";
-        }
-        StringBuilder sb = new StringBuilder();
-        for (_ASTElement child : children) {
-            if (child == null) {
-                break;
-            }
-            sb.append(child.getCanonicalForm());
-        }
-        return sb.toString();
-    }
-
-    /**
-     * Tells if the element should show up in error stack traces. Note that this will be ignored for the top (current)
-     * element of a stack trace, as that's always shown.
-     */
-    boolean isShownInStackTrace() {
-        return false;
-    }
-
-    /**
-     * Tells if this element possibly executes its nested content for many times. This flag is useful when a template
-     * AST is modified for running time limiting (see {@link ThreadInterruptionSupportTemplatePostProcessor}). Elements
-     * that use {@link #childBuffer} should not need this, as the insertion of the timeout checks is impossible there,
-     * given their rigid nested element schema.
-     */
-    abstract boolean isNestedBlockRepeater();
-
-    /**
-     * Brings the implementation of {@link #getCanonicalForm()} and {@link #getDescription()} to a single place. Don't
-     * call those methods in method on {@code this}, because that will result in infinite recursion!
-     * 
-     * @param canonical
-     *            if {@code true}, it calculates the return value of {@link #getCanonicalForm()}, otherwise of
-     *            {@link #getDescription()}.
-     */
-    abstract protected String dump(boolean canonical);
-
-    // Methods to implement TemplateNodeModel
-
-    public TemplateNodeModel getParentNode() {
-        // return parent;
-        return null;
-    }
-
-    public String getNodeNamespace() {
-        return null;
-    }
-
-    public String getNodeType() {
-        return "element";
-    }
-
-    public TemplateSequenceModel getChildNodes() {
-        if (childBuffer != null) {
-            final SimpleSequence seq = new SimpleSequence(childCount);
-            for (int i = 0; i < childCount; i++) {
-                seq.add(childBuffer[i]);
-            }
-            return seq;
-        } else {
-            return new SimpleSequence(0);
-        }
-    }
-
-    public String getNodeName() {
-        String className = getClass().getName();
-        int shortNameOffset = className.lastIndexOf('.') + 1;
-        return className.substring(shortNameOffset);
-    }
-
-    // Methods so that we can implement the Swing TreeNode API.
-
-    public boolean isLeaf() {
-        return childCount == 0;
-    }
-
-    public int getIndex(_ASTElement node) {
-        for (int i = 0; i < childCount; i++) {
-            if (childBuffer[i].equals(node)) {
-                return i;
-            }
-        }
-        return -1;
-    }
-
-    public int getChildCount() {
-        return childCount;
-    }
-
-    /**
-     * Note: For element with {@code #nestedBlock}, this will hide the {@code #nestedBlock} when that's a
-     * {@link ASTImplicitParent}.
-     */
-    public Enumeration children() {
-        return childBuffer != null
-                ? new _ArrayEnumeration(childBuffer, childCount)
-                : Collections.enumeration(Collections.EMPTY_LIST);
-    }
-
-    public void setChildAt(int index, _ASTElement element) {
-        if (index < childCount && index >= 0) {
-            childBuffer[index] = element;
-            element.index = index;
-            element.parent = this;
-        } else {
-            throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + childCount);
-        }
-    }
-    
-    /**
-     * The element whose child this element is, or {@code null} if this is the root node.
-     */
-    final _ASTElement getParent() {
-        return parent;
-    }
-
-    final void setChildBufferCapacity(int capacity) {
-        int ln = childCount;
-        _ASTElement[] newChildBuffer = new _ASTElement[capacity];
-        for (int i = 0; i < ln; i++) {
-            newChildBuffer[i] = childBuffer[i];
-        }
-        childBuffer = newChildBuffer;
-    }
-
-    /**
-     * Inserts a new nested element after the last nested element.
-     */
-    final void addChild(_ASTElement nestedElement) {
-        addChild(childCount, nestedElement);
-    }
-
-    /**
-     * Inserts a new nested element at the given index, which can also be one higher than the current highest index.
-     */
-    final void addChild(int index, _ASTElement nestedElement) {
-        final int lChildCount = childCount;
-
-        _ASTElement[] lChildBuffer = childBuffer;
-        if (lChildBuffer == null) {
-            lChildBuffer = new _ASTElement[INITIAL_CHILD_BUFFER_CAPACITY];
-            childBuffer = lChildBuffer;
-        } else if (lChildCount == lChildBuffer.length) {
-            setChildBufferCapacity(lChildCount != 0 ? lChildCount * 2 : 1);
-            lChildBuffer = childBuffer;
-        }
-        // At this point: nestedElements == this.nestedElements, and has sufficient capacity.
-
-        for (int i = lChildCount; i > index; i--) {
-            _ASTElement movedElement = lChildBuffer[i - 1];
-            movedElement.index = i;
-            lChildBuffer[i] = movedElement;
-        }
-        nestedElement.index = index;
-        nestedElement.parent = this;
-        lChildBuffer[index] = nestedElement;
-        childCount = lChildCount + 1;
-    }
-
-    final _ASTElement getChild(int index) {
-        return childBuffer[index];
-    }
-
-    /**
-     * @return Array containing 1 or more nested elements with optional trailing {@code null}-s, or is {@code null}
-     *         exactly if there are no nested elements.
-     */
-    final _ASTElement[] getChildBuffer() {
-        return childBuffer;
-    }
-
-    /**
-     * @param buffWithCnt Maybe {@code null}
-     * 
-     * @since 2.3.24
-     */
-    final void setChildren(TemplateElements buffWithCnt) {
-        _ASTElement[] childBuffer = buffWithCnt.getBuffer();
-        int childCount = buffWithCnt.getCount();
-        for (int i = 0; i < childCount; i++) {
-            _ASTElement child = childBuffer[i];
-            child.index = i;
-            child.parent = this;
-        }
-        this.childBuffer = childBuffer;
-        this.childCount = childCount;
-    }
-
-    final int getIndex() {
-        return index;
-    }
-
-    /**
-     * This is a special case, because a root element is not contained in another element, so we couldn't set the
-     * private fields.
-     */
-    final void setFieldsForRootElement() {
-        index = 0;
-        parent = null;
-    }
-
-    /**
-     * Walk the AST subtree rooted by this element, and do simplifications where possible, also removes superfluous
-     * whitespace.
-     * 
-     * @param stripWhitespace
-     *            whether to remove superfluous whitespace
-     * 
-     * @return The element this element should be replaced with in the parent. If it's the same as this element, no
-     *         actual replacement will happen. Note that adjusting the {@link #parent} and {@link #index} of the result
-     *         is the duty of the caller, not of this method.
-     */
-    _ASTElement postParseCleanup(boolean stripWhitespace) throws ParseException {
-        int childCount = this.childCount;
-        if (childCount != 0) {
-            for (int i = 0; i < childCount; i++) {
-                _ASTElement te = childBuffer[i];
-                
-                /*
-                // Assertion:
-                if (te.getIndex() != i) {
-                    throw new BugException("Invalid index " + te.getIndex() + " (expected: "
-                            + i + ") for: " + te.dump(false));
-                }
-                if (te.getParent() != this) {
-                    throw new BugException("Invalid parent " + te.getParent() + " (expected: "
-                            + this.dump(false) + ") for: " + te.dump(false));
-                }
-                */
-                
-                te = te.postParseCleanup(stripWhitespace);
-                childBuffer[i] = te;
-                te.parent = this;
-                te.index = i;
-            }
-            for (int i = 0; i < childCount; i++) {
-                _ASTElement te = childBuffer[i];
-                if (te.isIgnorable(stripWhitespace)) {
-                    childCount--;
-                    // As later isIgnorable calls might investigates the siblings, we have to move all the items now. 
-                    for (int j = i; j < childCount; j++) {
-                        final _ASTElement te2 = childBuffer[j + 1];
-                        childBuffer[j] = te2;
-                        te2.index = j;
-                    }
-                    childBuffer[childCount] = null;
-                    this.childCount = childCount;
-                    i--;
-                }
-            }
-            if (childCount == 0) {
-                childBuffer = null;
-            } else if (childCount < childBuffer.length
-                    && childCount <= childBuffer.length * 3 / 4) {
-                _ASTElement[] trimmedChildBuffer = new _ASTElement[childCount];
-                for (int i = 0; i < childCount; i++) {
-                    trimmedChildBuffer[i] = childBuffer[i];
-                }
-                childBuffer = trimmedChildBuffer;
-            }
-        }
-        return this;
-    }
-
-    boolean isIgnorable(boolean stripWhitespace) {
-        return false;
-    }
-
-    // The following methods exist to support some fancier tree-walking
-    // and were introduced to support the whitespace cleanup feature in 2.2
-
-    _ASTElement prevTerminalNode() {
-        _ASTElement prev = previousSibling();
-        if (prev != null) {
-            return prev.getLastLeaf();
-        } else if (parent != null) {
-            return parent.prevTerminalNode();
-        }
-        return null;
-    }
-
-    _ASTElement nextTerminalNode() {
-        _ASTElement next = nextSibling();
-        if (next != null) {
-            return next.getFirstLeaf();
-        } else if (parent != null) {
-            return parent.nextTerminalNode();
-        }
-        return null;
-    }
-
-    _ASTElement previousSibling() {
-        if (parent == null) {
-            return null;
-        }
-        return index > 0 ? parent.childBuffer[index - 1] : null;
-    }
-
-    _ASTElement nextSibling() {
-        if (parent == null) {
-            return null;
-        }
-        return index + 1 < parent.childCount ? parent.childBuffer[index + 1] : null;
-    }
-
-    private _ASTElement getFirstChild() {
-        return childCount == 0 ? null : childBuffer[0];
-    }
-
-    private _ASTElement getLastChild() {
-        final int childCount = this.childCount;
-        return childCount == 0 ? null : childBuffer[childCount - 1];
-    }
-
-    private _ASTElement getFirstLeaf() {
-        _ASTElement te = this;
-        while (!te.isLeaf() && !(te instanceof ASTDirMacro) && !(te instanceof ASTDirCapturingAssignment)) {
-            // A macro or macro invocation is treated as a leaf here for special reasons
-            te = te.getFirstChild();
-        }
-        return te;
-    }
-
-    private _ASTElement getLastLeaf() {
-        _ASTElement te = this;
-        while (!te.isLeaf() && !(te instanceof ASTDirMacro) && !(te instanceof ASTDirCapturingAssignment)) {
-            // A macro or macro invocation is treated as a leaf here for special reasons
-            te = te.getLastChild();
-        }
-        return te;
-    }
-
-    /**
-     * Tells if executing this element has output that only depends on the template content and that has no side
-     * effects.
-     */
-    boolean isOutputCacheable() {
-        return false;
-    }
-
-    boolean isChildrenOutputCacheable() {
-        int ln = childCount;
-        for (int i = 0; i < ln; i++) {
-            if (!childBuffer[i].isOutputCacheable()) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * determines whether this element's presence on a line indicates that we should not strip opening whitespace in the
-     * post-parse whitespace gobbling step.
-     */
-    boolean heedsOpeningWhitespace() {
-        return false;
-    }
-
-    /**
-     * determines whether this element's presence on a line indicates that we should not strip trailing whitespace in
-     * the post-parse whitespace gobbling step.
-     */
-    boolean heedsTrailingWhitespace() {
-        return false;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/main/java/org/apache/freemarker/core/_Debug.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/_Debug.java b/src/main/java/org/apache/freemarker/core/_Debug.java
index 15cfed1..d712693 100644
--- a/src/main/java/org/apache/freemarker/core/_Debug.java
+++ b/src/main/java/org/apache/freemarker/core/_Debug.java
@@ -15,12 +15,12 @@ public final class _Debug {
 
 
     public static void insertDebugBreak(Template t, int line) {
-        _ASTElement te = findTemplateElement(t.getRootTreeNode(), line);
+        ASTElement te = findTemplateElement(t.getRootASTNode(), line);
         if (te == null) {
             return;
         }
-        _ASTElement parent = te.getParent();
-        _ASTDebugBreak db = new _ASTDebugBreak(te);
+        ASTElement parent = te.getParent();
+        ASTDebugBreak db = new ASTDebugBreak(te);
         // TODO: Ensure there always is a parent by making sure
         // that the root element in the template is always a ASTImplicitParent
         // Also make sure it doesn't conflict with anyone's code.
@@ -28,14 +28,14 @@ public final class _Debug {
     }
 
     public static void removeDebugBreak(Template t, int line) {
-        _ASTElement te = findTemplateElement(t.getRootTreeNode(), line);
+        ASTElement te = findTemplateElement(t.getRootASTNode(), line);
         if (te == null) {
             return;
         }
-        _ASTDebugBreak db = null;
+        ASTDebugBreak db = null;
         while (te != null) {
-            if (te instanceof _ASTDebugBreak) {
-                db = (_ASTDebugBreak) te;
+            if (te instanceof ASTDebugBreak) {
+                db = (ASTDebugBreak) te;
                 break;
             }
             te = te.getParent();
@@ -43,27 +43,27 @@ public final class _Debug {
         if (db == null) {
             return;
         }
-        _ASTElement parent = db.getParent();
+        ASTElement parent = db.getParent();
         parent.setChildAt(parent.getIndex(db), db.getChild(0));
     }
 
-    private static _ASTElement findTemplateElement(_ASTElement te, int line) {
+    private static ASTElement findTemplateElement(ASTElement te, int line) {
         if (te.getBeginLine() > line || te.getEndLine() < line) {
             return null;
         }
         // Find the narrowest match
         List childMatches = new ArrayList();
         for (Enumeration children = te.children(); children.hasMoreElements(); ) {
-            _ASTElement child = (_ASTElement) children.nextElement();
-            _ASTElement childmatch = findTemplateElement(child, line);
+            ASTElement child = (ASTElement) children.nextElement();
+            ASTElement childmatch = findTemplateElement(child, line);
             if (childmatch != null) {
                 childMatches.add(childmatch);
             }
         }
         //find a match that exactly matches the begin/end line
-        _ASTElement bestMatch = null;
+        ASTElement bestMatch = null;
         for (int i = 0; i < childMatches.size(); i++) {
-            _ASTElement e = (_ASTElement) childMatches.get(i);
+            ASTElement e = (ASTElement) childMatches.get(i);
 
             if ( bestMatch == null ) {
                 bestMatch = e;
@@ -86,15 +86,15 @@ public final class _Debug {
     }
 
     public static void removeDebugBreaks(Template t) {
-        removeDebugBreaks(t.getRootTreeNode());
+        removeDebugBreaks(t.getRootASTNode());
     }
 
-    private static void removeDebugBreaks(_ASTElement te) {
+    private static void removeDebugBreaks(ASTElement te) {
         int count = te.getChildCount();
         for (int i = 0; i < count; ++i) {
-            _ASTElement child = te.getChild(i);
-            while (child instanceof _ASTDebugBreak) {
-                _ASTElement dbchild = child.getChild(0);
+            ASTElement child = te.getChild(i);
+            while (child instanceof ASTDebugBreak) {
+                ASTElement dbchild = child.getChild(0);
                 te.setChildAt(i, dbchild);
                 child = dbchild;
             }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/main/java/org/apache/freemarker/core/_ErrorDescriptionBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/_ErrorDescriptionBuilder.java b/src/main/java/org/apache/freemarker/core/_ErrorDescriptionBuilder.java
index afefcd5..812aa5a 100644
--- a/src/main/java/org/apache/freemarker/core/_ErrorDescriptionBuilder.java
+++ b/src/main/java/org/apache/freemarker/core/_ErrorDescriptionBuilder.java
@@ -66,7 +66,7 @@ public class _ErrorDescriptionBuilder {
         return toString(null, true);
     }
     
-    public String toString(_ASTElement parentElement, boolean showTips) {
+    public String toString(ASTElement parentElement, boolean showTips) {
         if (blamed == null && tips == null && tip == null && descriptionParts == null) return description;
 
         StringBuilder sb = new StringBuilder(200);

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/main/java/org/apache/freemarker/core/templateresolver/impl/DefaultTemplateResolver.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/templateresolver/impl/DefaultTemplateResolver.java b/src/main/java/org/apache/freemarker/core/templateresolver/impl/DefaultTemplateResolver.java
index bf574e2..b6e508a 100644
--- a/src/main/java/org/apache/freemarker/core/templateresolver/impl/DefaultTemplateResolver.java
+++ b/src/main/java/org/apache/freemarker/core/templateresolver/impl/DefaultTemplateResolver.java
@@ -623,8 +623,8 @@ public class DefaultTemplateResolver extends TemplateResolver {
                     while ((charsRead = reader.read(buf)) > 0) {
                         sb.append(buf, 0, charsRead);
                     }
-                    template = Template.getPlainTextTemplate(name, sourceName, sb.toString(), config);
-                    template.setEncoding(initialEncoding);
+                    template = Template.createPlainTextTemplate(name, sourceName, sb.toString(), config,
+                            initialEncoding);
                 }
             } finally {
                 reader.close();

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/main/javacc/FTL.jj
----------------------------------------------------------------------
diff --git a/src/main/javacc/FTL.jj b/src/main/javacc/FTL.jj
index 72c0666..b654f44 100644
--- a/src/main/javacc/FTL.jj
+++ b/src/main/javacc/FTL.jj
@@ -2322,7 +2322,7 @@ ASTHashInterpolation ASTHashInterpolation() :
     }
 }
 
-_ASTElement If() :
+ASTElement If() :
 {
     Token start, end, t;
     ASTExpression condition;
@@ -2404,7 +2404,7 @@ ASTDirRecover Recover() :
     }
 }
 
-_ASTElement List() :
+ASTElement List() :
 {
     ASTExpression exp;
     Token loopVar = null, loopVar2 = null, start, end;
@@ -2466,7 +2466,7 @@ _ASTElement List() :
                 childrendBeforeElse, iterCtx.hashListing, false);
         list.setLocation(template, start, end);
 
-        _ASTElement result;
+        ASTElement result;
         if (elseOfList == null) {
             result = list;
         } else {
@@ -2753,7 +2753,7 @@ ASTDirStop Stop() :
     }
 }
 
-_ASTElement Nested() :
+ASTElement Nested() :
 {
     Token t, end;
     ArrayList bodyParameters;
@@ -2787,7 +2787,7 @@ _ASTElement Nested() :
     }
 }
 
-_ASTElement Flush() :
+ASTElement Flush() :
 {
     Token t;
 }
@@ -2800,7 +2800,7 @@ _ASTElement Flush() :
     }
 }
 
-_ASTElement Trim() :
+ASTElement Trim() :
 {
     Token t;
     ASTDirTOrTrOrTl result = null;
@@ -2822,7 +2822,7 @@ _ASTElement Trim() :
 }
 
 
-_ASTElement Assign() :
+ASTElement Assign() :
 {
     Token start, end;
     int scope;
@@ -3182,7 +3182,7 @@ ASTDirCompress Compress() :
     }
 }
 
-_ASTElement UnifiedMacroTransform() :
+ASTElement UnifiedMacroTransform() :
 {
     Token start = null, end, t;
     HashMap namedArgs = null;
@@ -3269,7 +3269,7 @@ _ASTElement UnifiedMacroTransform() :
         )
     )
     {
-        _ASTElement result = (positionalArgs != null)
+        ASTElement result = (positionalArgs != null)
         		? new ASTDirUserDefined(exp, positionalArgs, children, bodyParameters)
 	            : new ASTDirUserDefined(exp, namedArgs, children, bodyParameters);
         result.setLocation(template, start, end);
@@ -3277,7 +3277,7 @@ _ASTElement UnifiedMacroTransform() :
     }
 }
 
-_ASTElement Call() :
+ASTElement Call() :
 {
     Token start, end, id;
     HashMap namedArgs = null;
@@ -3728,9 +3728,9 @@ ASTDirSetting Setting() :
 /**
  * A production for FreeMarker directives.
  */
-_ASTElement FreemarkerDirective() :
+ASTElement FreemarkerDirective() :
 {
-    _ASTElement tp;
+    ASTElement tp;
 }
 {
     // Note that this doesn't include elements like "else", "recover", etc., because those indicate the end
@@ -3868,9 +3868,9 @@ Token UnparsedContent(Token start, StringBuilder buf) :
 
 TemplateElements MixedContentElements() :
 {
-    _ASTElement[] childBuffer = null;
+    ASTElement[] childBuffer = null;
     int childCount = 0;
-    _ASTElement elem;
+    ASTElement elem;
     mixedContentNesting++;
 }
 {
@@ -3890,9 +3890,9 @@ TemplateElements MixedContentElements() :
             if (elem != null) {
 	            childCount++;
 	            if (childBuffer == null) {
-	                childBuffer = new _ASTElement[16]; 
+	                childBuffer = new ASTElement[16]; 
 	            } else if (childBuffer.length < childCount) {
-	                _ASTElement[] newChildBuffer = new _ASTElement[childCount * 2];
+	                ASTElement[] newChildBuffer = new ASTElement[childCount * 2];
 	                for (int i = 0; i < childBuffer.length; i++) {
 	                    newChildBuffer[i] = childBuffer[i];
 	                }
@@ -3916,7 +3916,7 @@ TemplateElements MixedContentElements() :
 ASTImplicitParent ASTImplicitParent() :
 {
     ASTImplicitParent mixedContent = new ASTImplicitParent();
-    _ASTElement elem, begin = null;
+    ASTElement elem, begin = null;
     mixedContentNesting++;
 }
 {
@@ -3954,9 +3954,9 @@ ASTImplicitParent ASTImplicitParent() :
  *
  * @deprecated Use {@link #MixedContentElements} instead.
  */
-_ASTElement OptionalBlock() :
+ASTElement OptionalBlock() :
 {
-    _ASTElement tp = null;
+    ASTElement tp = null;
 }
 {
     [
@@ -3972,10 +3972,10 @@ _ASTElement OptionalBlock() :
  * A production freemarker text that may contain
  * ${...} and #{...} but no directives.
  */
-_ASTElement FreeMarkerText() :
+ASTElement FreeMarkerText() :
 {
     ASTImplicitParent nodes = new ASTImplicitParent();
-    _ASTElement elem, begin = null;
+    ASTElement elem, begin = null;
 }
 {
     (
@@ -4228,7 +4228,7 @@ List<Object> StaticTextAndInterpolations() :
  * Root production to be used when parsing
  * an entire file.
  */
-_ASTElement Root() :
+ASTElement Root() :
 {
     TemplateElements children;
 }
@@ -4248,7 +4248,7 @@ _ASTElement Root() :
     children = MixedContentElements()
     <EOF>
     {
-        _ASTElement root = children.asSingleElement(); 
+        ASTElement root = children.asSingleElement(); 
         root.setFieldsForRootElement();
         root = root.postParseCleanup(stripWhitespace);
         // The cleanup result is possibly an element from deeper:

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/test/java/org/apache/freemarker/core/ASTPrinter.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/ASTPrinter.java b/src/test/java/org/apache/freemarker/core/ASTPrinter.java
index 9068255..0a2fe21 100644
--- a/src/test/java/org/apache/freemarker/core/ASTPrinter.java
+++ b/src/test/java/org/apache/freemarker/core/ASTPrinter.java
@@ -242,12 +242,12 @@ public class ASTPrinter {
         validateAST(t);
         
         StringWriter out = new StringWriter();
-        printNode(t.getRootTreeNode(), "", null, opts != null ? opts : Options.DEFAULT_INSTANCE, out);
+        printNode(t.getRootASTNode(), "", null, opts != null ? opts : Options.DEFAULT_INSTANCE, out);
         return out.toString();
     }
     
     public static void validateAST(Template t) throws InvalidASTException {
-        final _ASTElement node = t.getRootTreeNode();
+        final ASTElement node = t.getRootASTNode();
         if (node.getParent() != null) {
             throw new InvalidASTException("Root node parent must be null."
                     + "\nRoot node: " + node.dump(false)
@@ -257,11 +257,11 @@ public class ASTPrinter {
         validateAST(node);
     }
 
-    private static void validateAST(_ASTElement te) {
+    private static void validateAST(ASTElement te) {
         int childCount = te.getChildCount();
         for (int i = 0; i < childCount; i++) {
-            _ASTElement child = te.getChild(i);
-            _ASTElement parentElement = child.getParent();
+            ASTElement child = te.getChild(i);
+            ASTElement parentElement = child.getParent();
             // As ASTImplicitParent.accept does nothing but returns its children, it's optimized out in the final
             // AST tree. While it will be present as a child, the parent element also will have children
             // that contains the children of the ASTImplicitParent directly. 
@@ -285,7 +285,7 @@ public class ASTPrinter {
             throw new InvalidASTException("Mixed content with child count less than 2 should removed by optimizatoin, "
                     + "but found one with " + te.getChildCount() + " child(ren).");
         }
-        _ASTElement[] children = te.getChildBuffer();
+        ASTElement[] children = te.getChildBuffer();
         if (children != null) {
             if (childCount == 0) {
                 throw new InvalidASTException(
@@ -343,8 +343,8 @@ public class ASTPrinter {
                 Object value = tObj.getParameterValue(i);
                 printNode(value, ind + INDENTATION, role, opts, out);
             }
-            if (tObj instanceof _ASTElement) {
-                Enumeration enu = ((_ASTElement) tObj).children();
+            if (tObj instanceof ASTElement) {
+                Enumeration enu = ((ASTElement) tObj).children();
                 while (enu.hasMoreElements()) {
                     printNode(enu.nextElement(), INDENTATION + ind, null, opts, out);
                 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/test/java/org/apache/freemarker/core/OptInTemplateClassResolverTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/OptInTemplateClassResolverTest.java b/src/test/java/org/apache/freemarker/core/OptInTemplateClassResolverTest.java
index 669facb..eb515e6 100644
--- a/src/test/java/org/apache/freemarker/core/OptInTemplateClassResolverTest.java
+++ b/src/test/java/org/apache/freemarker/core/OptInTemplateClassResolverTest.java
@@ -51,7 +51,7 @@ public class OptInTemplateClassResolverTest extends TestCase {
             ALLOWED_CLASSES, TRUSTED_TEMPLATES);
     
     private Configuration dummyCfg = new Configuration();
-    private Template dummyTemp = Template.getPlainTextTemplate("foo.ftl", "", dummyCfg);
+    private Template dummyTemp = Template.createPlainTextTemplate("foo.ftl", "", dummyCfg);
     
     public void testOptIn() throws TemplateException {
         assertEquals(String.class, resolver.resolve("java.lang.String", null, dummyTemp));
@@ -66,17 +66,17 @@ public class OptInTemplateClassResolverTest extends TestCase {
 
     public void testTrusted() throws TemplateException {
         assertEquals(Long.class, resolver.resolve("java.lang.Long", null,
-                Template.getPlainTextTemplate("lib/foo.ftl", "", dummyCfg)));
+                Template.createPlainTextTemplate("lib/foo.ftl", "", dummyCfg)));
         assertEquals(String.class, resolver.resolve("java.lang.String", null,
-                Template.getPlainTextTemplate("lib/foo.ftl", "", dummyCfg)));
+                Template.createPlainTextTemplate("lib/foo.ftl", "", dummyCfg)));
         assertEquals(Long.class, resolver.resolve("java.lang.Long", null,
-                Template.getPlainTextTemplate("/lib/foo.ftl", "", dummyCfg)));
+                Template.createPlainTextTemplate("/lib/foo.ftl", "", dummyCfg)));
         assertEquals(Long.class, resolver.resolve("java.lang.Long", null,
-                Template.getPlainTextTemplate("include/foo.ftl", "", dummyCfg)));
+                Template.createPlainTextTemplate("include/foo.ftl", "", dummyCfg)));
         assertEquals(Long.class, resolver.resolve("java.lang.Long", null,
-                Template.getPlainTextTemplate("trusted.ftl", "", dummyCfg)));
+                Template.createPlainTextTemplate("trusted.ftl", "", dummyCfg)));
         assertEquals(Long.class, resolver.resolve("java.lang.Long", null,
-                Template.getPlainTextTemplate("/trusted.ftl", "", dummyCfg)));
+                Template.createPlainTextTemplate("/trusted.ftl", "", dummyCfg)));
     }
 
     public void testCraftedTrusted() throws TemplateException {
@@ -111,7 +111,7 @@ public class OptInTemplateClassResolverTest extends TestCase {
     public void testTrusted_checkFails(String templateName) {
         try {
             resolver.resolve("java.lang.Long", null,
-                    Template.getPlainTextTemplate(templateName, "", dummyCfg));
+                    Template.createPlainTextTemplate(templateName, "", dummyCfg));
             fail();
         } catch (TemplateException e) {
             // Expected
@@ -125,12 +125,12 @@ public class OptInTemplateClassResolverTest extends TestCase {
                 "trusted_templates: foo.ftl, \"lib/*\"");
         TemplateClassResolver res = cfg.getNewBuiltinClassResolver();
         assertEquals(String.class, res.resolve("java.lang.String", null,
-                Template.getPlainTextTemplate("foo.ftl", "", cfg)));
+                Template.createPlainTextTemplate("foo.ftl", "", cfg)));
         assertEquals(String.class, res.resolve("java.lang.String", null,
-                Template.getPlainTextTemplate("lib/bar.ftl", "", cfg)));
+                Template.createPlainTextTemplate("lib/bar.ftl", "", cfg)));
         try {
             res.resolve("java.lang.String", null,
-                    Template.getPlainTextTemplate("bar.ftl", "", cfg));
+                    Template.createPlainTextTemplate("bar.ftl", "", cfg));
             fail();
         } catch (TemplateException e) {
             // Expected
@@ -140,12 +140,12 @@ public class OptInTemplateClassResolverTest extends TestCase {
                 "allowed_classes: java.lang.String, java.lang.Integer");
         res = cfg.getNewBuiltinClassResolver();
         assertEquals(String.class, res.resolve("java.lang.String", null,
-                Template.getPlainTextTemplate("foo.ftl", "", cfg)));
+                Template.createPlainTextTemplate("foo.ftl", "", cfg)));
         assertEquals(Integer.class, res.resolve("java.lang.Integer", null,
-                Template.getPlainTextTemplate("foo.ftl", "", cfg)));
+                Template.createPlainTextTemplate("foo.ftl", "", cfg)));
         try {
             res.resolve("java.lang.Long", null,
-                    Template.getPlainTextTemplate("foo.ftl", "", cfg));
+                    Template.createPlainTextTemplate("foo.ftl", "", cfg));
             fail();
         } catch (TemplateException e) {
             // good
@@ -156,23 +156,23 @@ public class OptInTemplateClassResolverTest extends TestCase {
                 "allowed_classes: 'java.lang.String', java.lang.Integer");
         res = cfg.getNewBuiltinClassResolver();
         assertEquals(String.class, res.resolve("java.lang.String", null,
-                Template.getPlainTextTemplate("x.ftl", "", cfg)));
+                Template.createPlainTextTemplate("x.ftl", "", cfg)));
         assertEquals(Integer.class, res.resolve("java.lang.Integer", null,
-                Template.getPlainTextTemplate("x.ftl", "", cfg)));
+                Template.createPlainTextTemplate("x.ftl", "", cfg)));
         try {
             res.resolve("java.lang.Long", null,
-                    Template.getPlainTextTemplate("x.ftl", "", cfg));
+                    Template.createPlainTextTemplate("x.ftl", "", cfg));
             fail();
         } catch (TemplateException e) {
             // Expected
         }
         assertEquals(Long.class, res.resolve("java.lang.Long", null,
-                Template.getPlainTextTemplate("foo.ftl", "", cfg)));
+                Template.createPlainTextTemplate("foo.ftl", "", cfg)));
         assertEquals(Long.class, res.resolve("java.lang.Long", null,
-                Template.getPlainTextTemplate("lib/bar.ftl", "", cfg)));
+                Template.createPlainTextTemplate("lib/bar.ftl", "", cfg)));
         try {
             res.resolve("java.lang.Long", null,
-                    Template.getPlainTextTemplate("x.ftl", "", cfg));
+                    Template.createPlainTextTemplate("x.ftl", "", cfg));
             fail();
         } catch (TemplateException e) {
             // Expected
@@ -190,16 +190,16 @@ public class OptInTemplateClassResolverTest extends TestCase {
                 "'trusted_templates' :\"lib:*\"");
         res = cfg.getNewBuiltinClassResolver();
         assertEquals(String.class, res.resolve("java.lang.String", null,
-                Template.getPlainTextTemplate("x.ftl", "", cfg)));
+                Template.createPlainTextTemplate("x.ftl", "", cfg)));
         try {
             res.resolve("java.lang.Long", null,
-                    Template.getPlainTextTemplate("x.ftl", "", cfg));
+                    Template.createPlainTextTemplate("x.ftl", "", cfg));
             fail();
         } catch (TemplateException e) {
             // Expected
         }
         assertEquals(Long.class, res.resolve("java.lang.Long", null,
-                Template.getPlainTextTemplate("lib:bar.ftl", "", cfg)));
+                Template.createPlainTextTemplate("lib:bar.ftl", "", cfg)));
     }
     
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/test/java/org/apache/freemarker/core/OutputFormatTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/OutputFormatTest.java b/src/test/java/org/apache/freemarker/core/OutputFormatTest.java
index e988477..6856c3c 100644
--- a/src/test/java/org/apache/freemarker/core/OutputFormatTest.java
+++ b/src/test/java/org/apache/freemarker/core/OutputFormatTest.java
@@ -403,7 +403,7 @@ public class OutputFormatTest extends TemplateTest {
     public void testUnparsedTemplate() throws IOException, TemplateException {
         String content = "<#ftl>a<#foo>b${x}";
         {
-            Template t = Template.getPlainTextTemplate("x", content, getConfiguration());
+            Template t = Template.createPlainTextTemplate("x", content, getConfiguration());
             Writer sw = new StringWriter();
             t.process(null, sw);
             assertEquals(content, sw.toString());
@@ -412,7 +412,7 @@ public class OutputFormatTest extends TemplateTest {
         
         {
             getConfiguration().setOutputFormat(HTMLOutputFormat.INSTANCE);
-            Template t = Template.getPlainTextTemplate("x", content, getConfiguration());
+            Template t = Template.createPlainTextTemplate("x", content, getConfiguration());
             Writer sw = new StringWriter();
             t.process(null, sw);
             assertEquals(content, sw.toString());

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/test/java/org/apache/freemarker/core/TemplatGetEncodingTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/TemplatGetEncodingTest.java b/src/test/java/org/apache/freemarker/core/TemplatGetEncodingTest.java
index fbe68e5..d27b1a6 100644
--- a/src/test/java/org/apache/freemarker/core/TemplatGetEncodingTest.java
+++ b/src/test/java/org/apache/freemarker/core/TemplatGetEncodingTest.java
@@ -76,7 +76,7 @@ public class TemplatGetEncodingTest {
         }
 
         {
-            Template nonStoredT = Template.getPlainTextTemplate(null, "<#test>", cfg);
+            Template nonStoredT = Template.createPlainTextTemplate(null, "<#test>", cfg);
             assertNull(nonStoredT.getEncoding());
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d74ccf3c/src/test/java/org/apache/freemarker/core/TemplateConstructorsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/TemplateConstructorsTest.java b/src/test/java/org/apache/freemarker/core/TemplateConstructorsTest.java
index 8ff71d3..2677d39 100644
--- a/src/test/java/org/apache/freemarker/core/TemplateConstructorsTest.java
+++ b/src/test/java/org/apache/freemarker/core/TemplateConstructorsTest.java
@@ -80,7 +80,7 @@ public class TemplateConstructorsTest {
             assertEquals("UTF-16LE", t.getEncoding());
         }
         {
-            Template t = Template.getPlainTextTemplate(name, content, cfg);
+            Template t = Template.createPlainTextTemplate(name, content, cfg);
             assertEquals(name, t.getName());
             assertEquals(name, t.getSourceName());
             assertEquals(content, t.toString());


Mime
View raw message