You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2017/02/16 23:08:57 UTC
[32/54] [partial] incubator-freemarker git commit: Top level package
name change to org.apache.freemarker,
and some of of the internal package structure changes. Other smaller cleanup.
To be continued...
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/TextBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TextBlock.java b/src/main/java/freemarker/core/TextBlock.java
deleted file mode 100644
index dce4958..0000000
--- a/src/main/java/freemarker/core/TextBlock.java
+++ /dev/null
@@ -1,410 +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 freemarker.core;
-
-import java.io.IOException;
-
-import freemarker.template.utility.CollectionUtils;
-import freemarker.template.utility.StringUtil;
-
-/**
- * A TemplateElement representing a block of plain text.
- *
- * @deprected This is an internal API; don't use it.
- */
-public final class TextBlock extends TemplateElement {
-
- // We're using char[] instead of String for storing the text block because
- // Writer.write(String) involves copying the String contents to a char[]
- // using String.getChars(), and then calling Writer.write(char[]). By
- // using Writer.write(char[]) directly, we avoid array copying on each
- // write.
- private char[] text;
- private final boolean unparsed;
-
- public TextBlock(String text) {
- this(text, false);
- }
-
- public TextBlock(String text, boolean unparsed) {
- this(text.toCharArray(), unparsed);
- }
-
- TextBlock(char[] text, boolean unparsed) {
- this.text = text;
- this.unparsed = unparsed;
- }
-
- void replaceText(String text) {
- this.text = text.toCharArray();
- }
-
- /**
- * Simply outputs the text.
- *
- * @deprected This is an internal API; don't call or override it.
- */
- @Override
- public TemplateElement[] accept(Environment env)
- throws IOException {
- env.getOut().write(text);
- return null;
- }
-
- @Override
- protected String dump(boolean canonical) {
- if (canonical) {
- String text = new String(this.text);
- if (unparsed) {
- return "<#noparse>" + text + "</#noparse>";
- }
- return text;
- } else {
- return "text " + StringUtil.jQuote(new String(text));
- }
- }
-
- @Override
- String getNodeTypeSymbol() {
- return "#text";
- }
-
- @Override
- int getParameterCount() {
- return 1;
- }
-
- @Override
- Object getParameterValue(int idx) {
- if (idx != 0) throw new IndexOutOfBoundsException();
- return new String(text);
- }
-
- @Override
- ParameterRole getParameterRole(int idx) {
- if (idx != 0) throw new IndexOutOfBoundsException();
- return ParameterRole.CONTENT;
- }
-
- @Override
- TemplateElement postParseCleanup(boolean stripWhitespace) {
- if (text.length == 0) return this;
- int openingCharsToStrip = 0, trailingCharsToStrip = 0;
- boolean deliberateLeftTrim = deliberateLeftTrim();
- boolean deliberateRightTrim = deliberateRightTrim();
- if (!stripWhitespace || text.length == 0 ) {
- return this;
- }
- TemplateElement parentElement = getParentElement();
- if (isTopLevelTextIfParentIs(parentElement) && previousSibling() == null) {
- return this;
- }
- if (!deliberateLeftTrim) {
- trailingCharsToStrip = trailingCharsToStrip();
- }
- if (!deliberateRightTrim) {
- openingCharsToStrip = openingCharsToStrip();
- }
- if (openingCharsToStrip == 0 && trailingCharsToStrip == 0) {
- return this;
- }
- this.text = substring(text, openingCharsToStrip, text.length - trailingCharsToStrip);
- if (openingCharsToStrip > 0) {
- this.beginLine++;
- this.beginColumn = 1;
- }
- if (trailingCharsToStrip > 0) {
- this.endColumn = 0;
- }
- return this;
- }
-
- /**
- * Scans forward the nodes on the same line to see whether there is a
- * deliberate left trim in effect. Returns true if the left trim was present.
- */
- private boolean deliberateLeftTrim() {
- boolean result = false;
- for (TemplateElement elem = this.nextTerminalNode();
- elem != null && elem.beginLine == this.endLine;
- elem = elem.nextTerminalNode()) {
- if (elem instanceof TrimInstruction) {
- TrimInstruction ti = (TrimInstruction) elem;
- if (!ti.left && !ti.right) {
- result = true;
- }
- if (ti.left) {
- result = true;
- int lastNewLineIndex = lastNewLineIndex();
- if (lastNewLineIndex >= 0 || beginColumn == 1) {
- char[] firstPart = substring(text, 0, lastNewLineIndex + 1);
- char[] lastLine = substring(text, 1 + lastNewLineIndex);
- if (StringUtil.isTrimmableToEmpty(lastLine)) {
- this.text = firstPart;
- this.endColumn = 0;
- } else {
- int i = 0;
- while (Character.isWhitespace(lastLine[i])) {
- i++;
- }
- char[] printablePart = substring(lastLine, i);
- this.text = concat(firstPart, printablePart);
- }
- }
- }
- }
- }
- return result;
- }
-
- /**
- * Checks for the presence of a t or rt directive on the
- * same line. Returns true if the right trim directive was present.
- */
- private boolean deliberateRightTrim() {
- boolean result = false;
- for (TemplateElement elem = this.prevTerminalNode();
- elem != null && elem.endLine == this.beginLine;
- elem = elem.prevTerminalNode()) {
- if (elem instanceof TrimInstruction) {
- TrimInstruction ti = (TrimInstruction) elem;
- if (!ti.left && !ti.right) {
- result = true;
- }
- if (ti.right) {
- result = true;
- int firstLineIndex = firstNewLineIndex() + 1;
- if (firstLineIndex == 0) {
- return false;
- }
- if (text.length > firstLineIndex
- && text[firstLineIndex - 1] == '\r'
- && text[firstLineIndex] == '\n') {
- firstLineIndex++;
- }
- char[] trailingPart = substring(text, firstLineIndex);
- char[] openingPart = substring(text, 0, firstLineIndex);
- if (StringUtil.isTrimmableToEmpty(openingPart)) {
- this.text = trailingPart;
- this.beginLine++;
- this.beginColumn = 1;
- } else {
- int lastNonWS = openingPart.length - 1;
- while (Character.isWhitespace(text[lastNonWS])) {
- lastNonWS--;
- }
- char[] printablePart = substring(text, 0, lastNonWS + 1);
- if (StringUtil.isTrimmableToEmpty(trailingPart)) {
- // THIS BLOCK IS HEINOUS! THERE MUST BE A BETTER WAY! REVISIT (JR)
- boolean trimTrailingPart = true;
- for (TemplateElement te = this.nextTerminalNode();
- te != null && te.beginLine == this.endLine;
- te = te.nextTerminalNode()) {
- if (te.heedsOpeningWhitespace()) {
- trimTrailingPart = false;
- }
- if (te instanceof TrimInstruction && ((TrimInstruction) te).left) {
- trimTrailingPart = true;
- break;
- }
- }
- if (trimTrailingPart) trailingPart = CollectionUtils.EMPTY_CHAR_ARRAY;
- }
- this.text = concat(printablePart, trailingPart);
- }
- }
- }
- }
- return result;
- }
-
- private int firstNewLineIndex() {
- char[] text = this.text;
- for (int i = 0; i < text.length; i++) {
- char c = text[i];
- if (c == '\r' || c == '\n' ) {
- return i;
- }
- }
- return -1;
- }
-
- private int lastNewLineIndex() {
- char[] text = this.text;
- for (int i = text.length - 1; i >= 0; i--) {
- char c = text[i];
- if (c == '\r' || c == '\n' ) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * figures out how many opening whitespace characters to strip
- * in the post-parse cleanup phase.
- */
- private int openingCharsToStrip() {
- int newlineIndex = firstNewLineIndex();
- if (newlineIndex == -1 && beginColumn != 1) {
- return 0;
- }
- ++newlineIndex;
- if (text.length > newlineIndex) {
- if (newlineIndex > 0 && text[newlineIndex - 1] == '\r' && text[newlineIndex] == '\n') {
- ++newlineIndex;
- }
- }
- if (!StringUtil.isTrimmableToEmpty(text, 0, newlineIndex)) {
- return 0;
- }
- // We look at the preceding elements on the line to see if we should
- // strip the opening newline and any whitespace preceding it.
- for (TemplateElement elem = this.prevTerminalNode();
- elem != null && elem.endLine == this.beginLine;
- elem = elem.prevTerminalNode()) {
- if (elem.heedsOpeningWhitespace()) {
- return 0;
- }
- }
- return newlineIndex;
- }
-
- /**
- * figures out how many trailing whitespace characters to strip
- * in the post-parse cleanup phase.
- */
- private int trailingCharsToStrip() {
- int lastNewlineIndex = lastNewLineIndex();
- if (lastNewlineIndex == -1 && beginColumn != 1) {
- return 0;
- }
- if (!StringUtil.isTrimmableToEmpty(text, lastNewlineIndex + 1)) {
- return 0;
- }
- // We look at the elements afterward on the same line to see if we should
- // strip any whitespace after the last newline
- for (TemplateElement elem = this.nextTerminalNode();
- elem != null && elem.beginLine == this.endLine;
- elem = elem.nextTerminalNode()) {
- if (elem.heedsTrailingWhitespace()) {
- return 0;
- }
- }
- return text.length - (lastNewlineIndex + 1);
- }
-
- @Override
- boolean heedsTrailingWhitespace() {
- if (isIgnorable(true)) {
- return false;
- }
- for (int i = 0; i < text.length; i++) {
- char c = text[i];
- if (c == '\n' || c == '\r') {
- return false;
- }
- if (!Character.isWhitespace(c)) {
- return true;
- }
- }
- return true;
- }
-
- @Override
- boolean heedsOpeningWhitespace() {
- if (isIgnorable(true)) {
- return false;
- }
- for (int i = text.length - 1; i >= 0; i--) {
- char c = text[i];
- if (c == '\n' || c == '\r') {
- return false;
- }
- if (!Character.isWhitespace(c)) {
- return true;
- }
- }
- return true;
- }
-
- @Override
- boolean isIgnorable(boolean stripWhitespace) {
- if (text == null || text.length == 0) {
- return true;
- }
- if (stripWhitespace) {
- if (!StringUtil.isTrimmableToEmpty(text)) {
- return false;
- }
- TemplateElement parentElement = getParentElement();
- boolean atTopLevel = isTopLevelTextIfParentIs(parentElement);
- TemplateElement prevSibling = previousSibling();
- TemplateElement nextSibling = nextSibling();
- return ((prevSibling == null && atTopLevel) || nonOutputtingType(prevSibling))
- && ((nextSibling == null && atTopLevel) || nonOutputtingType(nextSibling));
- } else {
- return false;
- }
- }
-
- private boolean isTopLevelTextIfParentIs(TemplateElement parentElement) {
- return parentElement == null
- || parentElement.getParentElement() == null && parentElement instanceof MixedContent;
- }
-
-
- private boolean nonOutputtingType(TemplateElement element) {
- return (element instanceof Macro ||
- element instanceof Assignment ||
- element instanceof AssignmentInstruction ||
- element instanceof PropertySetting ||
- element instanceof LibraryLoad ||
- element instanceof Comment);
- }
-
- private static char[] substring(char[] c, int from, int to) {
- char[] c2 = new char[to - from];
- System.arraycopy(c, from, c2, 0, c2.length);
- return c2;
- }
-
- private static char[] substring(char[] c, int from) {
- return substring(c, from, c.length);
- }
-
- private static char[] concat(char[] c1, char[] c2) {
- char[] c = new char[c1.length + c2.length];
- System.arraycopy(c1, 0, c, 0, c1.length);
- System.arraycopy(c2, 0, c, c1.length, c2.length);
- return c;
- }
-
- @Override
- boolean isOutputCacheable() {
- return true;
- }
-
- @Override
- boolean isNestedBlockRepeater() {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java b/src/main/java/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
deleted file mode 100644
index 26d54aa..0000000
--- a/src/main/java/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
+++ /dev/null
@@ -1,141 +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 freemarker.core;
-
-import java.io.IOException;
-
-import freemarker.template.Template;
-import freemarker.template.TemplateDateModel;
-import freemarker.template.TemplateException;
-
-/**
- * Not yet public; subject to change.
- *
- * <p>
- * Known compatibility risks when using this post-processor:
- * <ul>
- * <li>{@link TemplateDateModel}-s that care to explicitly check if their nested content is {@code null} might start to
- * complain that you have specified a body despite that the directive doesn't support that. Directives should use
- * {@link NestedContentNotSupportedException#check(freemarker.template.TemplateDirectiveBody)} instead of a simple
- * {@code null}-check to avoid this problem.</li>
- * <li>
- * Software that uses {@link DirectiveCallPlace#isNestedOutputCacheable()} will always get {@code false}, because
- * interruption checks ({@link ThreadInterruptionCheck} elements) are, obviously, not cacheable. This should only
- * impact the performance.
- * <li>
- * Software that investigates the AST will see the injected {@link ThreadInterruptionCheck} elements. As of this
- * writing the AST API-s aren't published, also such software need to be able to deal with new kind of elements
- * anyway, so this shouldn't be a problem.
- * </ul>
- */
-class ThreadInterruptionSupportTemplatePostProcessor extends TemplatePostProcessor {
-
- @Override
- public void postProcess(Template t) throws TemplatePostProcessorException {
- final TemplateElement te = t.getRootTreeNode();
- addInterruptionChecks(te);
- }
-
- private void addInterruptionChecks(final TemplateElement te) throws TemplatePostProcessorException {
- if (te == null) {
- return;
- }
-
- final int regulatedChildrenCount = te.getChildCount();
- for (int i = 0; i < regulatedChildrenCount; i++) {
- addInterruptionChecks(te.getChild(i));
- }
-
- if (te.isNestedBlockRepeater()) {
- try {
- te.addChild(0, new ThreadInterruptionCheck(te));
- } catch (ParseException e) {
- throw new TemplatePostProcessorException("Unexpected error; see cause", e);
- }
- }
- }
-
- /**
- * Check if the current thread's "interrupted" flag is set, and throws
- * {@link TemplateProcessingThreadInterruptedException} if it is. We inject this to some points in the AST.
- */
- static class ThreadInterruptionCheck extends TemplateElement {
-
- private ThreadInterruptionCheck(TemplateElement te) throws ParseException {
- setLocation(te.getTemplate(), te.beginColumn, te.beginLine, te.beginColumn, te.beginLine);
- }
-
- @Override
- TemplateElement[] 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()) {
- throw new TemplateProcessingThreadInterruptedException();
- }
- return null;
- }
-
- @Override
- protected String dump(boolean canonical) {
- return canonical ? "" : "<#--" + getNodeTypeSymbol() + "--#>";
- }
-
- @Override
- String getNodeTypeSymbol() {
- return "##threadInterruptionCheck";
- }
-
- @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;
- }
-
- }
-
- /**
- * Indicates that the template processing thread's "interrupted" flag was found to be set.
- *
- * <p>ATTENTION: This is used by https://github.com/kenshoo/freemarker-online. Don't break backward
- * compatibility without updating that project too!
- */
- static class TemplateProcessingThreadInterruptedException extends RuntimeException {
-
- TemplateProcessingThreadInterruptedException() {
- super("Template processing thread \"interrupted\" flag was set.");
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/TokenMgrError.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TokenMgrError.java b/src/main/java/freemarker/core/TokenMgrError.java
deleted file mode 100644
index ae37ae6..0000000
--- a/src/main/java/freemarker/core/TokenMgrError.java
+++ /dev/null
@@ -1,263 +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 freemarker.core;
-
-import freemarker.template.Template;
-
-/**
- * Exception thrown on lower (lexical) level parsing errors. Shouldn't reach normal FreeMarker users, as FreeMarker
- * usually catches this and wraps it into a {@link ParseException}.
- *
- * This is a modified version of file generated by JavaCC from FTL.jj.
- * You can modify this class to customize the error reporting mechanisms so long as the public interface
- * remains compatible with the original.
- *
- * @see ParseException
- */
-public class TokenMgrError extends Error {
- /*
- * Ordinals for various reasons why an Error of this type can be thrown.
- */
-
- /**
- * Lexical error occurred.
- */
- static final int LEXICAL_ERROR = 0;
-
- /**
- * An attempt was made to create a second instance of a static token manager.
- */
- static final int STATIC_LEXER_ERROR = 1;
-
- /**
- * Tried to change to an invalid lexical state.
- */
- static final int INVALID_LEXICAL_STATE = 2;
-
- /**
- * Detected (and bailed out of) an infinite loop in the token manager.
- */
- static final int LOOP_DETECTED = 3;
-
- /**
- * Indicates the reason why the exception is thrown. It will have
- * one of the above 4 values.
- */
- int errorCode;
-
- private String detail;
- private Integer lineNumber, columnNumber;
- private Integer endLineNumber, endColumnNumber;
-
- /**
- * Replaces unprintable characters by their espaced (or unicode escaped)
- * equivalents in the given string
- */
- protected static final String addEscapes(String str) {
- StringBuilder retval = new StringBuilder();
- char ch;
- for (int i = 0; i < str.length(); i++) {
- switch (str.charAt(i))
- {
- case 0 :
- continue;
- case '\b':
- retval.append("\\b");
- continue;
- case '\t':
- retval.append("\\t");
- continue;
- case '\n':
- retval.append("\\n");
- continue;
- case '\f':
- retval.append("\\f");
- continue;
- case '\r':
- retval.append("\\r");
- continue;
- case '\"':
- retval.append("\\\"");
- continue;
- case '\'':
- retval.append("\\\'");
- continue;
- case '\\':
- retval.append("\\\\");
- continue;
- default:
- if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
- String s = "0000" + Integer.toString(ch, 16);
- retval.append("\\u" + s.substring(s.length() - 4, s.length()));
- } else {
- retval.append(ch);
- }
- continue;
- }
- }
- return retval.toString();
- }
-
- /**
- * Returns a detailed message for the Error when it's thrown by the
- * token manager to indicate a lexical error.
- * Parameters :
- * EOFSeen : indicates if EOF caused the lexicl error
- * curLexState : lexical state in which this error occurred
- * errorLine : line number when the error occurred
- * errorColumn : column number when the error occurred
- * errorAfter : prefix that was seen before this error occurred
- * curchar : the offending character
- * Note: You can customize the lexical error message by modifying this method.
- */
- protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
- return("Lexical error: encountered " +
- (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int) curChar + "), ") +
- "after \"" + addEscapes(errorAfter) + "\".");
- }
-
- /**
- * You can also modify the body of this method to customize your error messages.
- * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
- * of end-users concern, so you can return something like :
- *
- * "Internal Error : Please file a bug report .... "
- *
- * from this method for such cases in the release version of your parser.
- */
- @Override
-public String getMessage() {
- return super.getMessage();
- }
-
- /*
- * Constructors of various flavors follow.
- */
-
- public TokenMgrError() {
- }
-
- public TokenMgrError(String detail, int reason) {
- super(detail); // the "detail" must not contain location information, the "message" might does
- this.detail = detail;
- errorCode = reason;
- }
-
- /**
- * @since 2.3.20
- *
- * @deprecated If you know the end position, use {@link #TokenMgrError(String, int, int, int, int, int)} instead.
- */
- @Deprecated
-public TokenMgrError(String detail, int reason, int errorLine, int errorColumn) {
- this(detail, reason, errorLine, errorColumn, 0, 0);
- this.endLineNumber = null;
- this.endColumnNumber = null;
- }
-
- /**
- * @since 2.3.21
- */
- public TokenMgrError(String detail, int reason,
- int errorLine, int errorColumn,
- int endLineNumber, int endColumnNumber) {
- super(detail); // the "detail" must not contain location information, the "message" might does
- this.detail = detail;
- errorCode = reason;
-
- this.lineNumber = Integer.valueOf(errorLine); // In J2SE there was no Integer.valueOf(int)
- this.columnNumber = Integer.valueOf(errorColumn);
- this.endLineNumber = Integer.valueOf(endLineNumber);
- this.endColumnNumber = Integer.valueOf(endColumnNumber);
- }
-
- /**
- * Overload for JavaCC 6 compatibility.
- *
- * @since 2.3.24
- */
- TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar, int reason) {
- this(EOFSeen, lexState, errorLine, errorColumn, errorAfter, (char) curChar, reason);
- }
-
- public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
- this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
-
- this.lineNumber = Integer.valueOf(errorLine); // In J2SE there was no Integer.valueOf(int)
- this.columnNumber = Integer.valueOf(errorColumn);
- // We blame the single character that can't be the start of a legal token:
- this.endLineNumber = this.lineNumber;
- this.endColumnNumber = this.columnNumber;
- }
-
- /**
- * 1-based line number of the unexpected character(s).
- *
- * @since 2.3.20
- */
- public Integer getLineNumber() {
- return lineNumber;
- }
-
- /**
- * 1-based column number of the unexpected character(s).
- *
- * @since 2.3.20
- */
- public Integer getColumnNumber() {
- return columnNumber;
- }
-
- /**
- * Returns the 1-based line at which the last character of the wrong section is. This will be usually (but not
- * always) the same as {@link #getLineNumber()} because the lexer can only point to the single character that
- * doesn't match any patterns.
- *
- * @since 2.3.21
- */
- public Integer getEndLineNumber() {
- return endLineNumber;
- }
-
- /**
- * Returns the 1-based column at which the last character of the wrong section is. This will be usually (but not
- * always) the same as {@link #getColumnNumber()} because the lexer can only point to the single character that
- * doesn't match any patterns.
- *
- * @since 2.3.21
- */
- public Integer getEndColumnNumber() {
- return endColumnNumber;
- }
-
- public String getDetail() {
- return detail;
- }
-
- public ParseException toParseException(Template template) {
- return new ParseException(getDetail(),
- template,
- getLineNumber() != null ? getLineNumber().intValue() : 0,
- getColumnNumber() != null ? getColumnNumber().intValue() : 0,
- getEndLineNumber() != null ? getEndLineNumber().intValue() : 0,
- getEndColumnNumber() != null ? getEndColumnNumber().intValue() : 0);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/TransformBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TransformBlock.java b/src/main/java/freemarker/core/TransformBlock.java
deleted file mode 100644
index 5cfddc4..0000000
--- a/src/main/java/freemarker/core/TransformBlock.java
+++ /dev/null
@@ -1,168 +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 freemarker.core;
-
-import java.io.IOException;
-import java.lang.ref.Reference;
-import java.lang.ref.SoftReference;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import freemarker.template.EmptyMap;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateTransformModel;
-
-/**
- * A template element that contains a nested block
- * that is transformed according to an instance of T
- * TemplateTransformModel
- */
-final class TransformBlock extends TemplateElement {
-
- private Expression transformExpression;
- Map namedArgs;
- private transient volatile SoftReference/*List<Map.Entry<String,Expression>>*/ sortedNamedArgsCache;
-
- /**
- * Creates new TransformBlock, with a given transformation
- */
- TransformBlock(Expression transformExpression,
- Map namedArgs,
- TemplateElements children) {
- this.transformExpression = transformExpression;
- this.namedArgs = namedArgs;
- setChildren(children);
- }
-
- @Override
- TemplateElement[] accept(Environment env)
- throws TemplateException, IOException {
- TemplateTransformModel ttm = env.getTransform(transformExpression);
- if (ttm != null) {
- Map args;
- if (namedArgs != null && !namedArgs.isEmpty()) {
- args = new HashMap();
- for (Iterator it = namedArgs.entrySet().iterator(); it.hasNext(); ) {
- Map.Entry entry = (Map.Entry) it.next();
- String key = (String) entry.getKey();
- Expression valueExp = (Expression) entry.getValue();
- TemplateModel value = valueExp.eval(env);
- args.put(key, value);
- }
- } else {
- args = EmptyMap.instance;
- }
- env.visitAndTransform(getChildBuffer(), ttm, args);
- } else {
- TemplateModel tm = transformExpression.eval(env);
- throw new UnexpectedTypeException(
- transformExpression, tm,
- "transform", new Class[] { TemplateTransformModel.class }, env);
- }
- return null;
- }
-
- @Override
- protected String dump(boolean canonical) {
- StringBuilder sb = new StringBuilder();
- if (canonical) sb.append('<');
- sb.append(getNodeTypeSymbol());
- sb.append(' ');
- sb.append(transformExpression);
- if (namedArgs != null) {
- for (Iterator it = getSortedNamedArgs().iterator(); it.hasNext(); ) {
- Map.Entry entry = (Map.Entry) it.next();
- sb.append(' ');
- sb.append(entry.getKey());
- sb.append('=');
- MessageUtil.appendExpressionAsUntearable(sb, (Expression) entry.getValue());
- }
- }
- if (canonical) {
- sb.append(">");
- sb.append(getChildrenCanonicalForm());
- sb.append("</").append(getNodeTypeSymbol()).append('>');
- }
- return sb.toString();
- }
-
- @Override
- String getNodeTypeSymbol() {
- return "#transform";
- }
-
- @Override
- int getParameterCount() {
- return 1/*nameExp*/ + (namedArgs != null ? namedArgs.size() * 2 : 0);
- }
-
- @Override
- Object getParameterValue(int idx) {
- if (idx == 0) {
- return transformExpression;
- } else if (namedArgs != null && idx - 1 < namedArgs.size() * 2) {
- Map.Entry namedArg = (Map.Entry) getSortedNamedArgs().get((idx - 1) / 2);
- return (idx - 1) % 2 == 0 ? namedArg.getKey() : namedArg.getValue();
- } else {
- throw new IndexOutOfBoundsException();
- }
- }
-
- @Override
- ParameterRole getParameterRole(int idx) {
- if (idx == 0) {
- return ParameterRole.CALLEE;
- } else if (idx - 1 < namedArgs.size() * 2) {
- return (idx - 1) % 2 == 0 ? ParameterRole.ARGUMENT_NAME : ParameterRole.ARGUMENT_VALUE;
- } else {
- throw new IndexOutOfBoundsException();
- }
- }
-
- /**
- * Returns the named args by source-code order; it's not meant to be used during template execution, too slow for
- * that!
- */
- private List/*<Map.Entry<String, Expression>>*/ getSortedNamedArgs() {
- Reference ref = sortedNamedArgsCache;
- if (ref != null) {
- List res = (List) ref.get();
- if (res != null) return res;
- }
-
- List res = MiscUtil.sortMapOfExpressions(namedArgs);
- sortedNamedArgsCache = new SoftReference(res);
- return res;
- }
-
- @Override
- boolean isNestedBlockRepeater() {
- return false;
- }
-
- @Override
- boolean isShownInStackTrace() {
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/TrimInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TrimInstruction.java b/src/main/java/freemarker/core/TrimInstruction.java
deleted file mode 100644
index 7e48367..0000000
--- a/src/main/java/freemarker/core/TrimInstruction.java
+++ /dev/null
@@ -1,110 +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 freemarker.core;
-
-/**
- * An instruction that indicates that that opening
- * and trailing whitespace on this line should be trimmed.
- */
-final class TrimInstruction extends TemplateElement {
-
- private final int TYPE_T = 0;
- private final int TYPE_LT = 1;
- private final int TYPE_RT = 2;
- private final int TYPE_NT = 3;
-
- final boolean left, right;
-
- TrimInstruction(boolean left, boolean right) {
- this.left = left;
- this.right = right;
- }
-
- @Override
- TemplateElement[] accept(Environment env) {
- // This instruction does nothing at render-time, only parse-time.
- return null;
- }
-
- @Override
- protected String dump(boolean canonical) {
- StringBuilder sb = new StringBuilder();
- if (canonical) sb.append('<');
- sb.append(getNodeTypeSymbol());
- if (canonical) sb.append("/>");
- return sb.toString();
- }
-
- @Override
- String getNodeTypeSymbol() {
- if (left && right) {
- return "#t";
- } else if (left) {
- return "#lt";
- } else if (right) {
- return "#rt";
- } else {
- return "#nt";
- }
- }
-
- @Override
- boolean isIgnorable(boolean stripWhitespace) {
- return true;
- }
-
- @Override
- int getParameterCount() {
- return 1;
- }
-
- @Override
- Object getParameterValue(int idx) {
- if (idx != 0) throw new IndexOutOfBoundsException();
- int type;
- if (left && right) {
- type = TYPE_T;
- } else if (left) {
- type = TYPE_LT;
- } else if (right) {
- type = TYPE_RT;
- } else {
- type = TYPE_NT;
- }
- return Integer.valueOf(type);
- }
-
- @Override
- ParameterRole getParameterRole(int idx) {
- if (idx != 0) throw new IndexOutOfBoundsException();
- return ParameterRole.AST_NODE_SUBTYPE;
- }
-
- @Override
- boolean isOutputCacheable() {
- return true;
- }
-
- @Override
- boolean isNestedBlockRepeater() {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/UnaryPlusMinusExpression.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UnaryPlusMinusExpression.java b/src/main/java/freemarker/core/UnaryPlusMinusExpression.java
deleted file mode 100644
index 9ca17b6..0000000
--- a/src/main/java/freemarker/core/UnaryPlusMinusExpression.java
+++ /dev/null
@@ -1,106 +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 freemarker.core;
-
-import freemarker.template.SimpleNumber;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateNumberModel;
-
-final class UnaryPlusMinusExpression extends Expression {
-
- private final int TYPE_MINUS = 0;
- private final int TYPE_PLUS = 1;
-
- private final Expression target;
- private final boolean isMinus;
- private static final Integer MINUS_ONE = Integer.valueOf(-1);
-
- UnaryPlusMinusExpression(Expression target, boolean isMinus) {
- this.target = target;
- this.isMinus = isMinus;
- }
-
- @Override
- TemplateModel _eval(Environment env) throws TemplateException {
- TemplateNumberModel targetModel = null;
- TemplateModel tm = target.eval(env);
- try {
- targetModel = (TemplateNumberModel) tm;
- } catch (ClassCastException cce) {
- throw new NonNumericalException(target, tm, env);
- }
- if (!isMinus) {
- return targetModel;
- }
- target.assertNonNull(targetModel, env);
- Number n = targetModel.getAsNumber();
- n = ArithmeticEngine.CONSERVATIVE_ENGINE.multiply(MINUS_ONE, n);
- return new SimpleNumber(n);
- }
-
- @Override
- public String getCanonicalForm() {
- String op = isMinus ? "-" : "+";
- return op + target.getCanonicalForm();
- }
-
- @Override
- String getNodeTypeSymbol() {
- return isMinus ? "-..." : "+...";
- }
-
- @Override
- boolean isLiteral() {
- return target.isLiteral();
- }
-
- @Override
- protected Expression deepCloneWithIdentifierReplaced_inner(
- String replacedIdentifier, Expression replacement, ReplacemenetState replacementState) {
- return new UnaryPlusMinusExpression(
- target.deepCloneWithIdentifierReplaced(replacedIdentifier, replacement, replacementState),
- isMinus);
- }
-
- @Override
- int getParameterCount() {
- return 2;
- }
-
- @Override
- Object getParameterValue(int idx) {
- switch (idx) {
- case 0: return target;
- case 1: return Integer.valueOf(isMinus ? TYPE_MINUS : TYPE_PLUS);
- default: throw new IndexOutOfBoundsException();
- }
- }
-
- @Override
- ParameterRole getParameterRole(int idx) {
- switch (idx) {
- case 0: return ParameterRole.RIGHT_HAND_OPERAND;
- case 1: return ParameterRole.AST_NODE_SUBTYPE;
- default: throw new IndexOutOfBoundsException();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/UndefinedCustomFormatException.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UndefinedCustomFormatException.java b/src/main/java/freemarker/core/UndefinedCustomFormatException.java
deleted file mode 100644
index 160ae46..0000000
--- a/src/main/java/freemarker/core/UndefinedCustomFormatException.java
+++ /dev/null
@@ -1,34 +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 freemarker.core;
-
-/**
- * @since 2.3.24
- */
-public class UndefinedCustomFormatException extends InvalidFormatStringException {
-
- public UndefinedCustomFormatException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public UndefinedCustomFormatException(String message) {
- super(message);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/UndefinedOutputFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UndefinedOutputFormat.java b/src/main/java/freemarker/core/UndefinedOutputFormat.java
deleted file mode 100644
index 4dce258..0000000
--- a/src/main/java/freemarker/core/UndefinedOutputFormat.java
+++ /dev/null
@@ -1,57 +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 freemarker.core;
-
-import freemarker.template.Configuration;
-
-/**
- * Represents the output format used when the template output format is undecided. This is the default output format if
- * FreeMarker can't select anything more specific (see
- * {@link Configuration#setTemplateConfigurations(freemarker.cache.TemplateConfigurationFactory)}). This format doesn't
- * support auto-escaping ({@link Configuration#setAutoEscapingPolicy(int)}). It will print
- * {@link TemplateMarkupOutputModel}-s as is (doesn't try to convert them).
- *
- * @see PlainTextOutputFormat
- *
- * @since 2.3.24
- */
-public final class UndefinedOutputFormat extends OutputFormat {
-
- public static final UndefinedOutputFormat INSTANCE = new UndefinedOutputFormat();
-
- private UndefinedOutputFormat() {
- // Only to decrease visibility
- }
-
- @Override
- public boolean isOutputFormatMixingAllowed() {
- return true;
- }
-
- @Override
- public String getName() {
- return "undefined";
- }
-
- @Override
- public String getMimeType() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/UnexpectedTypeException.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UnexpectedTypeException.java b/src/main/java/freemarker/core/UnexpectedTypeException.java
deleted file mode 100644
index 6939b7c..0000000
--- a/src/main/java/freemarker/core/UnexpectedTypeException.java
+++ /dev/null
@@ -1,110 +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 freemarker.core;
-
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-
-/**
- * The type of a value differs from what was expected.
- *
- * @since 2.3.20
- */
-public class UnexpectedTypeException extends TemplateException {
-
- public UnexpectedTypeException(Environment env, String description) {
- super(description, env);
- }
-
- UnexpectedTypeException(Environment env, _ErrorDescriptionBuilder description) {
- super(null, env, null, description);
- }
-
- UnexpectedTypeException(
- Expression blamed, TemplateModel model, String expectedTypesDesc, Class[] expectedTypes, Environment env)
- throws InvalidReferenceException {
- super(null, env, blamed, newDesciptionBuilder(blamed, null, model, expectedTypesDesc, expectedTypes, env));
- }
-
- UnexpectedTypeException(
- Expression blamed, TemplateModel model, String expectedTypesDesc, Class[] expectedTypes, String tip,
- Environment env)
- throws InvalidReferenceException {
- super(null, env, blamed, newDesciptionBuilder(blamed, null, model, expectedTypesDesc, expectedTypes, env)
- .tip(tip));
- }
-
- UnexpectedTypeException(
- Expression blamed, TemplateModel model, String expectedTypesDesc, Class[] expectedTypes, Object[] tips,
- Environment env)
- throws InvalidReferenceException {
- super(null, env, blamed, newDesciptionBuilder(blamed, null, model, expectedTypesDesc, expectedTypes, env)
- .tips(tips));
- }
-
- UnexpectedTypeException(
- String blamedAssignmentTargetVarName, TemplateModel model, String expectedTypesDesc, Class[] expectedTypes,
- Object[] tips,
- Environment env)
- throws InvalidReferenceException {
- super(null, env, null, newDesciptionBuilder(
- null, blamedAssignmentTargetVarName, model, expectedTypesDesc, expectedTypes, env).tips(tips));
- }
-
- /**
- * @param blamedAssignmentTargetVarName
- * Used for assignments that use {@code +=} and such, in which case the {@code blamed} expression
- * parameter will be null {@code null} and this parameter will be non-{null}.
- */
- private static _ErrorDescriptionBuilder newDesciptionBuilder(
- Expression blamed, String blamedAssignmentTargetVarName,
- TemplateModel model, String expectedTypesDesc, Class[] expectedTypes, Environment env)
- throws InvalidReferenceException {
- if (model == null) throw InvalidReferenceException.getInstance(blamed, env);
-
- _ErrorDescriptionBuilder errorDescBuilder = new _ErrorDescriptionBuilder(
- unexpectedTypeErrorDescription(expectedTypesDesc, blamed, blamedAssignmentTargetVarName, model))
- .blame(blamed).showBlamer(true);
- if (model instanceof _UnexpectedTypeErrorExplainerTemplateModel) {
- Object[] tip = ((_UnexpectedTypeErrorExplainerTemplateModel) model).explainTypeError(expectedTypes);
- if (tip != null) {
- errorDescBuilder.tip(tip);
- }
- }
- return errorDescBuilder;
- }
-
- private static Object[] unexpectedTypeErrorDescription(
- String expectedTypesDesc,
- Expression blamed, String blamedAssignmentTargetVarName,
- TemplateModel model) {
- return new Object[] {
- "Expected ", new _DelayedAOrAn(expectedTypesDesc), ", but ",
- (blamedAssignmentTargetVarName == null
- ? (Object) (blamed != null ? "this" : "the expression")
- : new Object[] {
- "assignment target variable ",
- new _DelayedJQuote(blamedAssignmentTargetVarName) }),
- " has evaluated to ",
- new _DelayedAOrAn(new _DelayedFTLTypeDescription(model)),
- (blamedAssignmentTargetVarName == null ? ":" : ".")};
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/UnformattableValueException.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UnformattableValueException.java b/src/main/java/freemarker/core/UnformattableValueException.java
deleted file mode 100644
index d769680..0000000
--- a/src/main/java/freemarker/core/UnformattableValueException.java
+++ /dev/null
@@ -1,41 +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 freemarker.core;
-
-import freemarker.template.TemplateModel;
-
-/**
- * Thrown when a {@link TemplateModel} can't be formatted because of the value/properties of it are outside of that the
- * {@link TemplateValueFormat} supports. For example, a formatter may not support dates before year 1, or can't format
- * NaN. The most often used subclass is {@link UnknownDateTypeFormattingUnsupportedException}.
- *
- * @since 2.3.24
- */
-public class UnformattableValueException extends TemplateValueFormatException {
-
- public UnformattableValueException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public UnformattableValueException(String message) {
- super(message);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/UnifiedCall.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UnifiedCall.java b/src/main/java/freemarker/core/UnifiedCall.java
deleted file mode 100644
index 6608b0a..0000000
--- a/src/main/java/freemarker/core/UnifiedCall.java
+++ /dev/null
@@ -1,341 +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 freemarker.core;
-
-import java.io.IOException;
-import java.lang.ref.Reference;
-import java.lang.ref.SoftReference;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import freemarker.template.EmptyMap;
-import freemarker.template.TemplateDirectiveModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateTransformModel;
-import freemarker.template.utility.ObjectFactory;
-import freemarker.template.utility.StringUtil;
-
-/**
- * An element for the unified macro/transform syntax.
- */
-final class UnifiedCall extends TemplateElement implements DirectiveCallPlace {
-
- private Expression nameExp;
- private Map namedArgs;
- private List positionalArgs, bodyParameterNames;
- boolean legacySyntax;
- private transient volatile SoftReference/*List<Map.Entry<String,Expression>>*/ sortedNamedArgsCache;
- private CustomDataHolder customDataHolder;
-
- UnifiedCall(Expression nameExp,
- Map namedArgs,
- TemplateElements children,
- List bodyParameterNames) {
- this.nameExp = nameExp;
- this.namedArgs = namedArgs;
- setChildren(children);
- this.bodyParameterNames = bodyParameterNames;
- }
-
- UnifiedCall(Expression nameExp,
- List positionalArgs,
- TemplateElements children,
- List bodyParameterNames) {
- this.nameExp = nameExp;
- this.positionalArgs = positionalArgs;
- setChildren(children);
- this.bodyParameterNames = bodyParameterNames;
- }
-
- @Override
- TemplateElement[] accept(Environment env) throws TemplateException, IOException {
- TemplateModel tm = nameExp.eval(env);
- if (tm == Macro.DO_NOTHING_MACRO) return null; // shortcut here.
- if (tm instanceof Macro) {
- Macro macro = (Macro) tm;
- if (macro.isFunction() && !legacySyntax) {
- throw new _MiscTemplateException(env,
- "Routine ", new _DelayedJQuote(macro.getName()), " is a function, not a directive. "
- + "Functions can only be called from expressions, like in ${f()}, ${x + f()} or ",
- "<@someDirective someParam=f() />", ".");
- }
- env.invoke(macro, namedArgs, positionalArgs, bodyParameterNames, getChildBuffer());
- } else {
- boolean isDirectiveModel = tm instanceof TemplateDirectiveModel;
- if (isDirectiveModel || tm instanceof TemplateTransformModel) {
- Map args;
- if (namedArgs != null && !namedArgs.isEmpty()) {
- args = new HashMap();
- for (Iterator it = namedArgs.entrySet().iterator(); it.hasNext(); ) {
- Map.Entry entry = (Map.Entry) it.next();
- String key = (String) entry.getKey();
- Expression valueExp = (Expression) entry.getValue();
- TemplateModel value = valueExp.eval(env);
- args.put(key, value);
- }
- } else {
- args = EmptyMap.instance;
- }
- if (isDirectiveModel) {
- env.visit(getChildBuffer(), (TemplateDirectiveModel) tm, args, bodyParameterNames);
- } else {
- env.visitAndTransform(getChildBuffer(), (TemplateTransformModel) tm, args);
- }
- } else if (tm == null) {
- throw InvalidReferenceException.getInstance(nameExp, env);
- } else {
- throw new NonUserDefinedDirectiveLikeException(nameExp, tm, env);
- }
- }
- return null;
- }
-
- @Override
- protected String dump(boolean canonical) {
- StringBuilder sb = new StringBuilder();
- if (canonical) sb.append('<');
- sb.append('@');
- MessageUtil.appendExpressionAsUntearable(sb, nameExp);
- boolean nameIsInParen = sb.charAt(sb.length() - 1) == ')';
- if (positionalArgs != null) {
- for (int i = 0; i < positionalArgs.size(); i++) {
- Expression argExp = (Expression) positionalArgs.get(i);
- if (i != 0) {
- sb.append(',');
- }
- sb.append(' ');
- sb.append(argExp.getCanonicalForm());
- }
- } else {
- List entries = getSortedNamedArgs();
- for (int i = 0; i < entries.size(); i++) {
- Map.Entry entry = (Map.Entry) entries.get(i);
- Expression argExp = (Expression) entry.getValue();
- sb.append(' ');
- sb.append(_CoreStringUtils.toFTLTopLevelIdentifierReference((String) entry.getKey()));
- sb.append('=');
- MessageUtil.appendExpressionAsUntearable(sb, argExp);
- }
- }
- if (bodyParameterNames != null && !bodyParameterNames.isEmpty()) {
- sb.append("; ");
- for (int i = 0; i < bodyParameterNames.size(); i++) {
- if (i != 0) {
- sb.append(", ");
- }
- sb.append(_CoreStringUtils.toFTLTopLevelIdentifierReference((String) bodyParameterNames.get(i)));
- }
- }
- if (canonical) {
- if (getChildCount() == 0) {
- sb.append("/>");
- } else {
- sb.append('>');
- sb.append(getChildrenCanonicalForm());
- sb.append("</@");
- if (!nameIsInParen
- && (nameExp instanceof Identifier
- || (nameExp instanceof Dot && ((Dot) nameExp).onlyHasIdentifiers()))) {
- sb.append(nameExp.getCanonicalForm());
- }
- sb.append('>');
- }
- }
- return sb.toString();
- }
-
- @Override
- String getNodeTypeSymbol() {
- return "@";
- }
-
- @Override
- int getParameterCount() {
- return 1/*nameExp*/
- + (positionalArgs != null ? positionalArgs.size() : 0)
- + (namedArgs != null ? namedArgs.size() * 2 : 0)
- + (bodyParameterNames != null ? bodyParameterNames.size() : 0);
- }
-
- @Override
- Object getParameterValue(int idx) {
- if (idx == 0) {
- return nameExp;
- } else {
- int base = 1;
- final int positionalArgsSize = positionalArgs != null ? positionalArgs.size() : 0;
- if (idx - base < positionalArgsSize) {
- return positionalArgs.get(idx - base);
- } else {
- base += positionalArgsSize;
- final int namedArgsSize = namedArgs != null ? namedArgs.size() : 0;
- if (idx - base < namedArgsSize * 2) {
- Map.Entry namedArg = (Map.Entry) getSortedNamedArgs().get((idx - base) / 2);
- return (idx - base) % 2 == 0 ? namedArg.getKey() : namedArg.getValue();
- } else {
- base += namedArgsSize * 2;
- final int bodyParameterNamesSize = bodyParameterNames != null ? bodyParameterNames.size() : 0;
- if (idx - base < bodyParameterNamesSize) {
- return bodyParameterNames.get(idx - base);
- } else {
- throw new IndexOutOfBoundsException();
- }
- }
- }
- }
- }
-
- @Override
- ParameterRole getParameterRole(int idx) {
- if (idx == 0) {
- return ParameterRole.CALLEE;
- } else {
- int base = 1;
- final int positionalArgsSize = positionalArgs != null ? positionalArgs.size() : 0;
- if (idx - base < positionalArgsSize) {
- return ParameterRole.ARGUMENT_VALUE;
- } else {
- base += positionalArgsSize;
- final int namedArgsSize = namedArgs != null ? namedArgs.size() : 0;
- if (idx - base < namedArgsSize * 2) {
- return (idx - base) % 2 == 0 ? ParameterRole.ARGUMENT_NAME : ParameterRole.ARGUMENT_VALUE;
- } else {
- base += namedArgsSize * 2;
- final int bodyParameterNamesSize = bodyParameterNames != null ? bodyParameterNames.size() : 0;
- if (idx - base < bodyParameterNamesSize) {
- return ParameterRole.TARGET_LOOP_VARIABLE;
- } else {
- throw new IndexOutOfBoundsException();
- }
- }
- }
- }
- }
-
- /**
- * Returns the named args by source-code order; it's not meant to be used during template execution, too slow for
- * that!
- */
- private List/*<Map.Entry<String, Expression>>*/ getSortedNamedArgs() {
- Reference ref = sortedNamedArgsCache;
- if (ref != null) {
- List res = (List) ref.get();
- if (res != null) return res;
- }
-
- List res = MiscUtil.sortMapOfExpressions(namedArgs);
- sortedNamedArgsCache = new SoftReference(res);
- return res;
- }
-
- @SuppressFBWarnings(value={ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }, justification="Performance tricks")
- public Object getOrCreateCustomData(Object providerIdentity, ObjectFactory objectFactory)
- throws CallPlaceCustomDataInitializationException {
- // We are using double-checked locking, utilizing Java memory model "final" trick.
- // Note that this.customDataHolder is NOT volatile.
-
- CustomDataHolder customDataHolder = this.customDataHolder; // Findbugs false alarm
- if (customDataHolder == null) { // Findbugs false alarm
- synchronized (this) {
- customDataHolder = this.customDataHolder;
- if (customDataHolder == null || customDataHolder.providerIdentity != providerIdentity) {
- customDataHolder = createNewCustomData(providerIdentity, objectFactory);
- this.customDataHolder = customDataHolder;
- }
- }
- }
-
- if (customDataHolder.providerIdentity != providerIdentity) {
- synchronized (this) {
- customDataHolder = this.customDataHolder;
- if (customDataHolder == null || customDataHolder.providerIdentity != providerIdentity) {
- customDataHolder = createNewCustomData(providerIdentity, objectFactory);
- this.customDataHolder = customDataHolder;
- }
- }
- }
-
- return customDataHolder.customData;
- }
-
- private CustomDataHolder createNewCustomData(Object provierIdentity, ObjectFactory objectFactory)
- throws CallPlaceCustomDataInitializationException {
- CustomDataHolder customDataHolder;
- Object customData;
- try {
- customData = objectFactory.createObject();
- } catch (Exception e) {
- throw new CallPlaceCustomDataInitializationException(
- "Failed to initialize custom data for provider identity "
- + StringUtil.tryToString(provierIdentity) + " via factory "
- + StringUtil.tryToString(objectFactory), e);
- }
- if (customData == null) {
- throw new NullPointerException("ObjectFactory.createObject() has returned null");
- }
- customDataHolder = new CustomDataHolder(provierIdentity, customData);
- return customDataHolder;
- }
-
- public boolean isNestedOutputCacheable() {
- return isChildrenOutputCacheable();
- }
-
-/*
- //REVISIT
- boolean heedsOpeningWhitespace() {
- return nestedBlock == null;
- }
-
- //REVISIT
- boolean heedsTrailingWhitespace() {
- return nestedBlock == null;
- }*/
-
- /**
- * Used for implementing double check locking in implementing the
- * {@link DirectiveCallPlace#getOrCreateCustomData(Object, ObjectFactory)}.
- */
- private static class CustomDataHolder {
-
- private final Object providerIdentity;
- private final Object customData;
- public CustomDataHolder(Object providerIdentity, Object customData) {
- this.providerIdentity = providerIdentity;
- this.customData = customData;
- }
-
- }
-
- @Override
- boolean isNestedBlockRepeater() {
- return true;
- }
-
- @Override
- boolean isShownInStackTrace() {
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/UnknownDateTypeFormattingUnsupportedException.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UnknownDateTypeFormattingUnsupportedException.java b/src/main/java/freemarker/core/UnknownDateTypeFormattingUnsupportedException.java
deleted file mode 100644
index 84275bd..0000000
--- a/src/main/java/freemarker/core/UnknownDateTypeFormattingUnsupportedException.java
+++ /dev/null
@@ -1,35 +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 freemarker.core;
-
-import freemarker.template.TemplateDateModel;
-
-/**
- * Thrown when a {@link TemplateDateModel} can't be formatted because its type is {@link TemplateDateModel#UNKNOWN}.
- *
- * @since 2.3.24
- */
-public final class UnknownDateTypeFormattingUnsupportedException extends UnformattableValueException {
-
- public UnknownDateTypeFormattingUnsupportedException() {
- super(MessageUtil.UNKNOWN_DATE_TO_STRING_ERROR_MESSAGE);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/UnknownDateTypeParsingUnsupportedException.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UnknownDateTypeParsingUnsupportedException.java b/src/main/java/freemarker/core/UnknownDateTypeParsingUnsupportedException.java
deleted file mode 100644
index a8deaf6..0000000
--- a/src/main/java/freemarker/core/UnknownDateTypeParsingUnsupportedException.java
+++ /dev/null
@@ -1,36 +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 freemarker.core;
-
-import freemarker.template.TemplateDateModel;
-
-/**
- * Thrown when a string can't be parsed to {@link TemplateDateModel}, because the provided target type is
- * {@link TemplateDateModel#UNKNOWN}.
- *
- * @since 2.3.24
- */
-public final class UnknownDateTypeParsingUnsupportedException extends UnformattableValueException {
-
- public UnknownDateTypeParsingUnsupportedException() {
- super(MessageUtil.UNKNOWN_DATE_PARSING_ERROR_MESSAGE);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/UnparsableValueException.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UnparsableValueException.java b/src/main/java/freemarker/core/UnparsableValueException.java
deleted file mode 100644
index dab0397..0000000
--- a/src/main/java/freemarker/core/UnparsableValueException.java
+++ /dev/null
@@ -1,38 +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 freemarker.core;
-
-/**
- * Thrown when the content of the string that should be parsed by the {@link TemplateValueFormat} doesn't match what the
- * format expects.
- *
- * @since 2.3.24
- */
-public class UnparsableValueException extends TemplateValueFormatException {
-
- public UnparsableValueException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public UnparsableValueException(String message) {
- this(message, null);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/UnregisteredOutputFormatException.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UnregisteredOutputFormatException.java b/src/main/java/freemarker/core/UnregisteredOutputFormatException.java
deleted file mode 100644
index e1d5279..0000000
--- a/src/main/java/freemarker/core/UnregisteredOutputFormatException.java
+++ /dev/null
@@ -1,34 +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 freemarker.core;
-
-/**
- * @since 2.3.24
- */
-public class UnregisteredOutputFormatException extends Exception {
-
- public UnregisteredOutputFormatException(String message) {
- this(message, null);
- }
-
- public UnregisteredOutputFormatException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/VisitNode.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/VisitNode.java b/src/main/java/freemarker/core/VisitNode.java
deleted file mode 100644
index e116c4a..0000000
--- a/src/main/java/freemarker/core/VisitNode.java
+++ /dev/null
@@ -1,128 +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 freemarker.core;
-
-import java.io.IOException;
-
-import freemarker.template.SimpleSequence;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateNodeModel;
-import freemarker.template.TemplateScalarModel;
-import freemarker.template.TemplateSequenceModel;
-
-
-/**
- * An instruction to visit an XML node.
- */
-final class VisitNode extends TemplateElement {
-
- Expression targetNode, namespaces;
-
- VisitNode(Expression targetNode, Expression namespaces) {
- this.targetNode = targetNode;
- this.namespaces = namespaces;
- }
-
- @Override
- TemplateElement[] accept(Environment env) throws IOException, TemplateException {
- TemplateModel node = targetNode.eval(env);
- if (!(node instanceof TemplateNodeModel)) {
- throw new NonNodeException(targetNode, node, env);
- }
-
- TemplateModel nss = namespaces == null ? null : namespaces.eval(env);
- if (namespaces instanceof StringLiteral) {
- nss = env.importLib(((TemplateScalarModel) nss).getAsString(), null);
- } else if (namespaces instanceof ListLiteral) {
- nss = ((ListLiteral) namespaces).evaluateStringsToNamespaces(env);
- }
- if (nss != null) {
- if (nss instanceof Environment.Namespace) {
- SimpleSequence ss = new SimpleSequence(1);
- ss.add(nss);
- nss = ss;
- } else if (!(nss instanceof TemplateSequenceModel)) {
- if (namespaces != null) {
- throw new NonSequenceException(namespaces, nss, env);
- } else {
- // Should not occur
- throw new _MiscTemplateException(env, "Expecting a sequence of namespaces after \"using\"");
- }
- }
- }
- env.invokeNodeHandlerFor((TemplateNodeModel) node, (TemplateSequenceModel) nss);
- return null;
- }
-
- @Override
- protected String dump(boolean canonical) {
- StringBuilder sb = new StringBuilder();
- if (canonical) sb.append('<');
- sb.append(getNodeTypeSymbol());
- sb.append(' ');
- sb.append(targetNode.getCanonicalForm());
- if (namespaces != null) {
- sb.append(" using ");
- sb.append(namespaces.getCanonicalForm());
- }
- if (canonical) sb.append("/>");
- return sb.toString();
- }
-
- @Override
- String getNodeTypeSymbol() {
- return "#visit";
- }
-
- @Override
- int getParameterCount() {
- return 2;
- }
-
- @Override
- Object getParameterValue(int idx) {
- switch (idx) {
- case 0: return targetNode;
- case 1: return namespaces;
- default: throw new IndexOutOfBoundsException();
- }
- }
-
- @Override
- ParameterRole getParameterRole(int idx) {
- switch (idx) {
- case 0: return ParameterRole.NODE;
- case 1: return ParameterRole.NAMESPACE;
- default: throw new IndexOutOfBoundsException();
- }
- }
-
- @Override
- boolean isNestedBlockRepeater() {
- return true;
- }
-
- @Override
- boolean isShownInStackTrace() {
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/XHTMLOutputFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/XHTMLOutputFormat.java b/src/main/java/freemarker/core/XHTMLOutputFormat.java
deleted file mode 100644
index 432a5ff..0000000
--- a/src/main/java/freemarker/core/XHTMLOutputFormat.java
+++ /dev/null
@@ -1,75 +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 freemarker.core;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import freemarker.template.TemplateModelException;
-import freemarker.template.utility.StringUtil;
-
-/**
- * Represents the XML output format (MIME type "application/xhtml+xml", name "XHTML"). This format escapes by default
- * (via {@link StringUtil#XHTMLEnc(String)}). The {@code ?xml} built-in silently bypasses template output values of the
- * type produced by this output format ({@link TemplateXHTMLOutputModel}).
- *
- * @since 2.3.24
- */
-public final class XHTMLOutputFormat extends CommonMarkupOutputFormat<TemplateXHTMLOutputModel> {
-
- /**
- * The only instance (singleton) of this {@link OutputFormat}.
- */
- public static final XHTMLOutputFormat INSTANCE = new XHTMLOutputFormat();
-
- private XHTMLOutputFormat() {
- // Only to decrease visibility
- }
-
- @Override
- public String getName() {
- return "XHTML";
- }
-
- @Override
- public String getMimeType() {
- return "application/xhtml+xml";
- }
-
- @Override
- public void output(String textToEsc, Writer out) throws IOException, TemplateModelException {
- StringUtil.XHTMLEnc(textToEsc, out);
- }
-
- @Override
- public String escapePlainText(String plainTextContent) {
- return StringUtil.XHTMLEnc(plainTextContent);
- }
-
- @Override
- public boolean isLegacyBuiltInBypassed(String builtInName) {
- return builtInName.equals("html") || builtInName.equals("xml") || builtInName.equals("xhtml");
- }
-
- @Override
- protected TemplateXHTMLOutputModel newTemplateMarkupOutputModel(String plainTextContent, String markupContent) {
- return new TemplateXHTMLOutputModel(plainTextContent, markupContent);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/core/XMLOutputFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/XMLOutputFormat.java b/src/main/java/freemarker/core/XMLOutputFormat.java
deleted file mode 100644
index 90fed02..0000000
--- a/src/main/java/freemarker/core/XMLOutputFormat.java
+++ /dev/null
@@ -1,75 +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 freemarker.core;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import freemarker.template.TemplateModelException;
-import freemarker.template.utility.StringUtil;
-
-/**
- * Represents the XML output format (MIME type "application/xml", name "XML"). This format escapes by default (via
- * {@link StringUtil#XMLEnc(String)}). The {@code ?html}, {@code ?xhtml} and {@code ?xml} built-ins silently bypass
- * template output values of the type produced by this output format ({@link TemplateXHTMLOutputModel}).
- *
- * @since 2.3.24
- */
-public final class XMLOutputFormat extends CommonMarkupOutputFormat<TemplateXMLOutputModel> {
-
- /**
- * The only instance (singleton) of this {@link OutputFormat}.
- */
- public static final XMLOutputFormat INSTANCE = new XMLOutputFormat();
-
- private XMLOutputFormat() {
- // Only to decrease visibility
- }
-
- @Override
- public String getName() {
- return "XML";
- }
-
- @Override
- public String getMimeType() {
- return "application/xml";
- }
-
- @Override
- public void output(String textToEsc, Writer out) throws IOException, TemplateModelException {
- StringUtil.XMLEnc(textToEsc, out);
- }
-
- @Override
- public String escapePlainText(String plainTextContent) {
- return StringUtil.XMLEnc(plainTextContent);
- }
-
- @Override
- public boolean isLegacyBuiltInBypassed(String builtInName) {
- return builtInName.equals("xml");
- }
-
- @Override
- protected TemplateXMLOutputModel newTemplateMarkupOutputModel(String plainTextContent, String markupContent) {
- return new TemplateXMLOutputModel(plainTextContent, markupContent);
- }
-
-}