Moving output format related classes from o.a.f.core into the outputformats subpackage
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/db77001f Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/db77001f Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/db77001f Branch: refs/heads/3 Commit: db77001f7a20301bb3369a17514caabbd34410b9 Parents: 0376a77 Author: ddekany <[email protected]> Authored: Thu Feb 23 23:18:43 2017 +0100 Committer: ddekany <[email protected]> Committed: Thu Feb 23 23:48:09 2017 +0100 ---------------------------------------------------------------------- build.xml | 10 - .../core/ASTDirCapturingAssignment.java | 1 + .../freemarker/core/ASTDollarInterpolation.java | 3 + .../freemarker/core/ASTExpAddOrConcat.java | 1 + .../freemarker/core/ASTExpStringLiteral.java | 2 + .../apache/freemarker/core/ASTExpression.java | 1 + .../freemarker/core/ASTHashInterpolation.java | 1 + .../freemarker/core/ASTInterpolation.java | 2 + .../core/BuiltInForLegacyEscaping.java | 1 + .../freemarker/core/BuiltInForMarkupOutput.java | 1 + .../core/BuiltInsForMarkupOutputs.java | 1 + .../core/BuiltInsForMultipleTypes.java | 1 + .../core/BuiltInsForOutputFormatRelated.java | 2 + .../apache/freemarker/core/CSSOutputFormat.java | 2 + .../core/CombinedMarkupOutputFormat.java | 106 ---------- .../core/CommonMarkupOutputFormat.java | 124 ------------ .../core/CommonTemplateMarkupOutputModel.java | 67 ------- .../apache/freemarker/core/Configurable.java | 6 + .../apache/freemarker/core/Configuration.java | 3 + .../org/apache/freemarker/core/EvalUtil.java | 2 + .../freemarker/core/HTMLOutputFormat.java | 75 ------- .../freemarker/core/JSONOutputFormat.java | 52 ----- .../freemarker/core/JavaScriptOutputFormat.java | 2 + .../freemarker/core/MarkupOutputFormat.java | 131 ------------ .../core/MarkupOutputFormatBoundBuiltIn.java | 1 + .../core/NonMarkupOutputException.java | 1 + .../NonStringOrTemplateOutputException.java | 1 + .../apache/freemarker/core/OutputFormat.java | 83 -------- .../core/OutputFormatBoundBuiltIn.java | 1 + .../freemarker/core/ParserConfiguration.java | 2 + .../freemarker/core/PlainTextOutputFormat.java | 56 ------ .../apache/freemarker/core/RTFOutputFormat.java | 75 ------- .../org/apache/freemarker/core/Template.java | 2 +- .../core/TemplateCombinedMarkupOutputModel.java | 50 ----- .../freemarker/core/TemplateConfiguration.java | 1 + .../freemarker/core/TemplateDateFormat.java | 1 + .../core/TemplateHTMLOutputModel.java | 40 ---- .../core/TemplateMarkupOutputModel.java | 52 ----- .../freemarker/core/TemplateNumberFormat.java | 1 + .../freemarker/core/TemplateRTFOutputModel.java | 40 ---- .../core/TemplateXHTMLOutputModel.java | 40 ---- .../freemarker/core/TemplateXMLOutputModel.java | 40 ---- .../freemarker/core/UndefinedOutputFormat.java | 55 ------ .../core/UnregisteredOutputFormatException.java | 34 ---- .../freemarker/core/XHTMLOutputFormat.java | 75 ------- .../apache/freemarker/core/XMLOutputFormat.java | 75 ------- .../core/_ObjectBuilderSettingEvaluator.java | 5 + ..._ParserConfigurationWithInheritedFormat.java | 2 + .../apache/freemarker/core/_TemplateAPI.java | 1 + .../core/model/TemplateMarkupOutputModel.java | 52 +++++ .../model/impl/beans/OverloadedMethods.java | 2 +- .../core/model/impl/beans/SimpleMethod.java | 2 +- .../outputformat/CommonMarkupOutputFormat.java | 124 ++++++++++++ .../CommonTemplateMarkupOutputModel.java | 69 +++++++ .../core/outputformat/MarkupOutputFormat.java | 135 +++++++++++++ .../core/outputformat/OutputFormat.java | 86 ++++++++ .../UnregisteredOutputFormatException.java | 39 ++++ .../impl/CombinedMarkupOutputFormat.java | 108 ++++++++++ .../outputformat/impl/HTMLOutputFormat.java | 77 ++++++++ .../outputformat/impl/JSONOutputFormat.java | 54 +++++ .../impl/PlainTextOutputFormat.java | 58 ++++++ .../core/outputformat/impl/RTFOutputFormat.java | 77 ++++++++ .../impl/TemplateCombinedMarkupOutputModel.java | 52 +++++ .../impl/TemplateHTMLOutputModel.java | 42 ++++ .../impl/TemplateRTFOutputModel.java | 42 ++++ .../impl/TemplateXHTMLOutputModel.java | 42 ++++ .../impl/TemplateXMLOutputModel.java | 42 ++++ .../impl/UndefinedOutputFormat.java | 59 ++++++ .../outputformat/impl/XHTMLOutputFormat.java | 77 ++++++++ .../core/outputformat/impl/XMLOutputFormat.java | 77 ++++++++ .../apache/freemarker/core/util/FTLUtil.java | 2 +- .../freemarker/servlet/FreemarkerServlet.java | 4 +- src/main/javacc/FTL.jj | 2 + src/manual/en_US/FM3-CHANGE-LOG.txt | 1 + .../apache/freemarker/core/CamelCaseTest.java | 8 +- .../freemarker/core/CoercionToTextualTest.java | 4 +- .../core/CombinedMarkupOutputFormatTest.java | 198 ------------------- .../freemarker/core/ConfigurationTest.java | 13 +- .../freemarker/core/CustomHTMLOutputFormat.java | 72 ------- .../core/CustomTemplateHTMLModel.java | 34 ---- .../freemarker/core/DummyOutputFormat.java | 65 ------ .../core/HTMLISOTemplateDateFormatFactory.java | 11 +- .../freemarker/core/HTMLOutputFormatTest.java | 187 ------------------ .../freemarker/core/OutputFormatTest.java | 21 +- .../PrintfGTemplateNumberFormatFactory.java | 8 +- .../freemarker/core/RTFOutputFormatTest.java | 129 ------------ .../core/SeldomEscapedOutputFormat.java | 71 ------- .../freemarker/core/SpecialVariableTest.java | 9 +- .../core/StringLiteralInterpolationTest.java | 5 +- .../core/TemplateConfigurationTest.java | 20 +- .../core/TemplateDummyOutputModel.java | 34 ---- .../core/TemplateSeldomEscapedOutputModel.java | 34 ---- .../freemarker/core/XHTMLOutputFormatTest.java | 2 +- .../freemarker/core/XMLOutputFormatTest.java | 2 +- .../model/impl/beans/ErrorMessagesTest.java | 4 +- .../core/outputformat/_OutputFormatTestAPI.java | 35 ++++ .../impl/CombinedMarkupOutputFormatTest.java | 196 ++++++++++++++++++ .../outputformat/impl/HTMLOutputFormatTest.java | 191 ++++++++++++++++++ .../outputformat/impl/RTFOutputFormatTest.java | 131 ++++++++++++ .../core/userpkg/CustomHTMLOutputFormat.java | 72 +++++++ .../core/userpkg/CustomTemplateHTMLModel.java | 34 ++++ .../core/userpkg/DummyOutputFormat.java | 65 ++++++ .../core/userpkg/SeldomEscapedOutputFormat.java | 71 +++++++ .../core/userpkg/TemplateDummyOutputModel.java | 34 ++++ .../TemplateSeldomEscapedOutputModel.java | 34 ++++ .../ConfigureOutputFormatExamples.java | 6 +- .../TemplateConfigurationExamples.java | 8 +- 107 files changed, 2277 insertions(+), 2187 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/build.xml ---------------------------------------------------------------------- diff --git a/build.xml b/build.xml index 2e34ce6..3da81a9 100644 --- a/build.xml +++ b/build.xml @@ -375,16 +375,6 @@ sourcepath="build/javadoc-sources" destdir="build/api" doctitle="FreeMarker ${version}" - packagenames=" - org.apache.freemarker.core.*, - org.apache.freemarker.core.debug.*, - org.apache.freemarker.core.templateresolver.*, - org.apache.freemarker.core.model.*, - org.apache.freemarker.core.model.impl.*, - org.apache.freemarker.core.model.impl.beans.*, - org.apache.freemarker.core.model.impl.dom.*, - org.apache.freemarker.servlet.*, - org.apache.freemarker.servlet.jsp.*" use="true" version="true" author="true" http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/ASTDirCapturingAssignment.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ASTDirCapturingAssignment.java b/src/main/java/org/apache/freemarker/core/ASTDirCapturingAssignment.java index d6ff929..0aa5647 100644 --- a/src/main/java/org/apache/freemarker/core/ASTDirCapturingAssignment.java +++ b/src/main/java/org/apache/freemarker/core/ASTDirCapturingAssignment.java @@ -28,6 +28,7 @@ import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateTransformModel; import org.apache.freemarker.core.model.impl.SimpleScalar; +import org.apache.freemarker.core.outputformat.MarkupOutputFormat; /** * AST directive node: Like {@code <#local x>...</#local>}. http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java b/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java index 2396a60..d80c7c0 100644 --- a/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java +++ b/src/main/java/org/apache/freemarker/core/ASTDollarInterpolation.java @@ -22,6 +22,9 @@ package org.apache.freemarker.core; import java.io.IOException; import java.io.Writer; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; +import org.apache.freemarker.core.outputformat.MarkupOutputFormat; +import org.apache.freemarker.core.outputformat.OutputFormat; import org.apache.freemarker.core.util.FTLUtil; /** http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/ASTExpAddOrConcat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ASTExpAddOrConcat.java b/src/main/java/org/apache/freemarker/core/ASTExpAddOrConcat.java index 569db70..088e2fa 100644 --- a/src/main/java/org/apache/freemarker/core/ASTExpAddOrConcat.java +++ b/src/main/java/org/apache/freemarker/core/ASTExpAddOrConcat.java @@ -25,6 +25,7 @@ import java.util.Set; import org.apache.freemarker.core.model.TemplateCollectionModel; import org.apache.freemarker.core.model.TemplateHashModel; import org.apache.freemarker.core.model.TemplateHashModelEx; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateModelIterator; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/ASTExpStringLiteral.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ASTExpStringLiteral.java b/src/main/java/org/apache/freemarker/core/ASTExpStringLiteral.java index 25fa037..4871afb 100644 --- a/src/main/java/org/apache/freemarker/core/ASTExpStringLiteral.java +++ b/src/main/java/org/apache/freemarker/core/ASTExpStringLiteral.java @@ -22,9 +22,11 @@ package org.apache.freemarker.core; import java.io.StringReader; import java.util.List; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateScalarModel; import org.apache.freemarker.core.model.impl.SimpleScalar; +import org.apache.freemarker.core.outputformat.OutputFormat; import org.apache.freemarker.core.util.FTLUtil; /** http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/ASTExpression.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ASTExpression.java b/src/main/java/org/apache/freemarker/core/ASTExpression.java index 692f1bb..629d71c 100644 --- a/src/main/java/org/apache/freemarker/core/ASTExpression.java +++ b/src/main/java/org/apache/freemarker/core/ASTExpression.java @@ -23,6 +23,7 @@ import org.apache.freemarker.core.model.TemplateBooleanModel; import org.apache.freemarker.core.model.TemplateCollectionModel; import org.apache.freemarker.core.model.TemplateDateModel; import org.apache.freemarker.core.model.TemplateHashModel; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateNumberModel; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/ASTHashInterpolation.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ASTHashInterpolation.java b/src/main/java/org/apache/freemarker/core/ASTHashInterpolation.java index 4cd3e7f..4c5a127 100644 --- a/src/main/java/org/apache/freemarker/core/ASTHashInterpolation.java +++ b/src/main/java/org/apache/freemarker/core/ASTHashInterpolation.java @@ -24,6 +24,7 @@ import java.io.Writer; import java.text.NumberFormat; import java.util.Locale; +import org.apache.freemarker.core.outputformat.MarkupOutputFormat; import org.apache.freemarker.core.util.FTLUtil; /** http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/ASTInterpolation.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ASTInterpolation.java b/src/main/java/org/apache/freemarker/core/ASTInterpolation.java index d303642..3d958d0 100644 --- a/src/main/java/org/apache/freemarker/core/ASTInterpolation.java +++ b/src/main/java/org/apache/freemarker/core/ASTInterpolation.java @@ -18,6 +18,8 @@ */ package org.apache.freemarker.core; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; + /** * AST interpolation node superclass. */ http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/BuiltInForLegacyEscaping.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/BuiltInForLegacyEscaping.java b/src/main/java/org/apache/freemarker/core/BuiltInForLegacyEscaping.java index 26d64ad..47622a7 100644 --- a/src/main/java/org/apache/freemarker/core/BuiltInForLegacyEscaping.java +++ b/src/main/java/org/apache/freemarker/core/BuiltInForLegacyEscaping.java @@ -18,6 +18,7 @@ */ package org.apache.freemarker.core; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; import org.apache.freemarker.core.model.TemplateModel; /** http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/BuiltInForMarkupOutput.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/BuiltInForMarkupOutput.java b/src/main/java/org/apache/freemarker/core/BuiltInForMarkupOutput.java index a153d5a..6e81cd0 100644 --- a/src/main/java/org/apache/freemarker/core/BuiltInForMarkupOutput.java +++ b/src/main/java/org/apache/freemarker/core/BuiltInForMarkupOutput.java @@ -19,6 +19,7 @@ package org.apache.freemarker.core; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/BuiltInsForMarkupOutputs.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/BuiltInsForMarkupOutputs.java b/src/main/java/org/apache/freemarker/core/BuiltInsForMarkupOutputs.java index 3c9e473..bca7744 100644 --- a/src/main/java/org/apache/freemarker/core/BuiltInsForMarkupOutputs.java +++ b/src/main/java/org/apache/freemarker/core/BuiltInsForMarkupOutputs.java @@ -19,6 +19,7 @@ package org.apache.freemarker.core; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.impl.SimpleScalar; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/BuiltInsForMultipleTypes.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/BuiltInsForMultipleTypes.java b/src/main/java/org/apache/freemarker/core/BuiltInsForMultipleTypes.java index d37b29a..1db96e5 100644 --- a/src/main/java/org/apache/freemarker/core/BuiltInsForMultipleTypes.java +++ b/src/main/java/org/apache/freemarker/core/BuiltInsForMultipleTypes.java @@ -29,6 +29,7 @@ import org.apache.freemarker.core.model.TemplateDateModel; import org.apache.freemarker.core.model.TemplateDirectiveModel; import org.apache.freemarker.core.model.TemplateHashModel; import org.apache.freemarker.core.model.TemplateHashModelEx; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; import org.apache.freemarker.core.model.TemplateMethodModel; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/BuiltInsForOutputFormatRelated.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/BuiltInsForOutputFormatRelated.java b/src/main/java/org/apache/freemarker/core/BuiltInsForOutputFormatRelated.java index d3f59a7..adff22f 100644 --- a/src/main/java/org/apache/freemarker/core/BuiltInsForOutputFormatRelated.java +++ b/src/main/java/org/apache/freemarker/core/BuiltInsForOutputFormatRelated.java @@ -18,7 +18,9 @@ */ package org.apache.freemarker.core; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; import org.apache.freemarker.core.model.TemplateModel; +import org.apache.freemarker.core.outputformat.MarkupOutputFormat; class BuiltInsForOutputFormatRelated { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/CSSOutputFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/CSSOutputFormat.java b/src/main/java/org/apache/freemarker/core/CSSOutputFormat.java index 69a2465..c171ad1 100644 --- a/src/main/java/org/apache/freemarker/core/CSSOutputFormat.java +++ b/src/main/java/org/apache/freemarker/core/CSSOutputFormat.java @@ -18,6 +18,8 @@ */ package org.apache.freemarker.core; +import org.apache.freemarker.core.outputformat.OutputFormat; + /** * Represents the CSS output format (MIME type "text/css", name "CSS"). This format doesn't support escaping. * http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/CombinedMarkupOutputFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/CombinedMarkupOutputFormat.java b/src/main/java/org/apache/freemarker/core/CombinedMarkupOutputFormat.java deleted file mode 100644 index d629547..0000000 --- a/src/main/java/org/apache/freemarker/core/CombinedMarkupOutputFormat.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 org.apache.freemarker.core; - -import java.io.IOException; -import java.io.Writer; - -import org.apache.freemarker.core.model.TemplateModelException; - -/** - * Represents two markup formats nested into each other. For example, markdown nested into HTML. - * - * @since 2.3.24 - */ -public final class CombinedMarkupOutputFormat extends CommonMarkupOutputFormat<TemplateCombinedMarkupOutputModel> { - - private final String name; - - private final MarkupOutputFormat outer; - private final MarkupOutputFormat inner; - - /** - * Same as {@link #CombinedMarkupOutputFormat(String, MarkupOutputFormat, MarkupOutputFormat)} with {@code null} as - * the {@code name} parameter. - */ - public CombinedMarkupOutputFormat(MarkupOutputFormat outer, MarkupOutputFormat inner) { - this(null, outer, inner); - } - - /** - * @param name - * Maybe {@code null}, in which case it defaults to - * <code>outer.getName() + "{" + inner.getName() + "}"</code>. - */ - public CombinedMarkupOutputFormat(String name, MarkupOutputFormat outer, MarkupOutputFormat inner) { - this.name = name != null ? null : outer.getName() + "{" + inner.getName() + "}"; - this.outer = outer; - this.inner = inner; - } - - @Override - public String getName() { - return name; - } - - @Override - public String getMimeType() { - return outer.getMimeType(); - } - - @Override - public void output(String textToEsc, Writer out) throws IOException, TemplateModelException { - outer.output(inner.escapePlainText(textToEsc), out); - } - - @Override - public String escapePlainText(String plainTextContent) throws TemplateModelException { - return outer.escapePlainText(inner.escapePlainText(plainTextContent)); - } - - @Override - public boolean isLegacyBuiltInBypassed(String builtInName) throws TemplateModelException { - return outer.isLegacyBuiltInBypassed(builtInName); - } - - @Override - public boolean isAutoEscapedByDefault() { - return outer.isAutoEscapedByDefault(); - } - - @Override - public boolean isOutputFormatMixingAllowed() { - return outer.isOutputFormatMixingAllowed(); - } - - public MarkupOutputFormat getOuterOutputFormat() { - return outer; - } - - public MarkupOutputFormat getInnerOutputFormat() { - return inner; - } - - @Override - protected TemplateCombinedMarkupOutputModel newTemplateMarkupOutputModel( - String plainTextContent, String markupContent) { - return new TemplateCombinedMarkupOutputModel(plainTextContent, markupContent, this); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/CommonMarkupOutputFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/CommonMarkupOutputFormat.java b/src/main/java/org/apache/freemarker/core/CommonMarkupOutputFormat.java deleted file mode 100644 index cde0163..0000000 --- a/src/main/java/org/apache/freemarker/core/CommonMarkupOutputFormat.java +++ /dev/null @@ -1,124 +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.io.Writer; - -import org.apache.freemarker.core.model.TemplateModelException; - -/** - * Common superclass for implementing {@link MarkupOutputFormat}-s that use a {@link CommonTemplateMarkupOutputModel} - * subclass. - * - * @since 2.3.24 - */ -public abstract class CommonMarkupOutputFormat<MO extends CommonTemplateMarkupOutputModel> - extends MarkupOutputFormat<MO> { - - protected CommonMarkupOutputFormat() { - // Only to decrease visibility - } - - @Override - public final MO fromPlainTextByEscaping(String textToEsc) throws TemplateModelException { - return newTemplateMarkupOutputModel(textToEsc, null); - } - - @Override - public final MO fromMarkup(String markupText) throws TemplateModelException { - return newTemplateMarkupOutputModel(null, markupText); - } - - @Override - public final void output(MO mo, Writer out) throws IOException, TemplateModelException { - String mc = mo.getMarkupContent(); - if (mc != null) { - out.write(mc); - } else { - output(mo.getPlainTextContent(), out); - } - } - - @Override - public abstract void output(String textToEsc, Writer out) throws IOException, TemplateModelException; - - @Override - public final String getSourcePlainText(MO mo) throws TemplateModelException { - return mo.getPlainTextContent(); - } - - @Override - public final String getMarkupString(MO mo) throws TemplateModelException { - String mc = mo.getMarkupContent(); - if (mc != null) { - return mc; - } - - mc = escapePlainText(mo.getPlainTextContent()); - mo.setMarkupContent(mc); - return mc; - } - - @Override - public final MO concat(MO mo1, MO mo2) throws TemplateModelException { - String pc1 = mo1.getPlainTextContent(); - String mc1 = mo1.getMarkupContent(); - String pc2 = mo2.getPlainTextContent(); - String mc2 = mo2.getMarkupContent(); - - String pc3 = pc1 != null && pc2 != null ? pc1 + pc2 : null; - String mc3 = mc1 != null && mc2 != null ? mc1 + mc2 : null; - if (pc3 != null || mc3 != null) { - return newTemplateMarkupOutputModel(pc3, mc3); - } - - if (pc1 != null) { - return newTemplateMarkupOutputModel(null, getMarkupString(mo1) + mc2); - } else { - return newTemplateMarkupOutputModel(null, mc1 + getMarkupString(mo2)); - } - } - - @Override - public boolean isEmpty(MO mo) throws TemplateModelException { - String s = mo.getPlainTextContent(); - if (s != null) { - return s.length() == 0; - } - return mo.getMarkupContent().length() == 0; - } - - @Override - public boolean isOutputFormatMixingAllowed() { - return false; - } - - @Override - public boolean isAutoEscapedByDefault() { - return true; - } - - /** - * Creates a new {@link CommonTemplateMarkupOutputModel} that's bound to this {@link OutputFormat} instance. - */ - protected abstract MO newTemplateMarkupOutputModel(String plainTextContent, String markupContent) - throws TemplateModelException; - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/CommonTemplateMarkupOutputModel.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/CommonTemplateMarkupOutputModel.java b/src/main/java/org/apache/freemarker/core/CommonTemplateMarkupOutputModel.java deleted file mode 100644 index 809c248..0000000 --- a/src/main/java/org/apache/freemarker/core/CommonTemplateMarkupOutputModel.java +++ /dev/null @@ -1,67 +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; - -/** - * Common superclass for implementing {@link TemplateMarkupOutputModel}-s that belong to a - * {@link CommonMarkupOutputFormat} subclass format. - * - * <p> - * Thread-safe after proper publishing. Calculated fields (typically, the markup calculated from plain text) might will - * be re-calculated for multiple times if accessed from multiple threads (this only affects performance, not - * functionality). - * - * @since 2.3.24 - */ -public abstract class CommonTemplateMarkupOutputModel<MO extends CommonTemplateMarkupOutputModel<MO>> - implements TemplateMarkupOutputModel<MO> { - - private final String plainTextContent; - private String markupContent; - - /** - * A least one of the parameters must be non-{@code null}! - */ - protected CommonTemplateMarkupOutputModel(String plainTextContent, String markupContent) { - this.plainTextContent = plainTextContent; - this.markupContent = markupContent; - } - - @Override - public abstract CommonMarkupOutputFormat<MO> getOutputFormat(); - - /** Maybe {@code null}, but then {@link #getMarkupContent()} isn't {@code null}. */ - final String getPlainTextContent() { - return plainTextContent; - } - - /** Maybe {@code null}, but then {@link #getPlainTextContent()} isn't {@code null}. */ - final String getMarkupContent() { - return markupContent; - } - - /** - * Use only to set the value calculated from {@link #getPlainTextContent()}, when {@link #getMarkupContent()} was - * still {@code null}! - */ - final void setMarkupContent(String markupContent) { - this.markupContent = markupContent; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/Configurable.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/Configurable.java b/src/main/java/org/apache/freemarker/core/Configurable.java index f90a8ed..6ae277c 100644 --- a/src/main/java/org/apache/freemarker/core/Configurable.java +++ b/src/main/java/org/apache/freemarker/core/Configurable.java @@ -46,6 +46,12 @@ import org.apache.freemarker.core.model.impl.DefaultObjectWrapperBuilder; import org.apache.freemarker.core.model.impl.SimpleObjectWrapper; import org.apache.freemarker.core.model.impl._StaticObjectWrappers; import org.apache.freemarker.core.model.impl.beans.BeansWrapper; +import org.apache.freemarker.core.outputformat.*; +import org.apache.freemarker.core.outputformat.impl.HTMLOutputFormat; +import org.apache.freemarker.core.outputformat.impl.PlainTextOutputFormat; +import org.apache.freemarker.core.outputformat.impl.RTFOutputFormat; +import org.apache.freemarker.core.outputformat.impl.UndefinedOutputFormat; +import org.apache.freemarker.core.outputformat.impl.XMLOutputFormat; import org.apache.freemarker.core.templateresolver.AndMatcher; import org.apache.freemarker.core.templateresolver.ConditionalTemplateConfigurationFactory; import org.apache.freemarker.core.templateresolver.FileNameGlobMatcher; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/Configuration.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/Configuration.java b/src/main/java/org/apache/freemarker/core/Configuration.java index 3eba432..edf1184 100644 --- a/src/main/java/org/apache/freemarker/core/Configuration.java +++ b/src/main/java/org/apache/freemarker/core/Configuration.java @@ -42,11 +42,14 @@ import java.util.concurrent.ConcurrentMap; import org.apache.freemarker.core.model.ObjectWrapper; import org.apache.freemarker.core.model.TemplateHashModelEx; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateModelIterator; import org.apache.freemarker.core.model.TemplateScalarModel; import org.apache.freemarker.core.model.impl.DefaultObjectWrapperBuilder; +import org.apache.freemarker.core.outputformat.*; +import org.apache.freemarker.core.outputformat.impl.*; import org.apache.freemarker.core.templateresolver.CacheStorage; import org.apache.freemarker.core.templateresolver.GetTemplateResult; import org.apache.freemarker.core.templateresolver.MalformedTemplateNameException; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/EvalUtil.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/EvalUtil.java b/src/main/java/org/apache/freemarker/core/EvalUtil.java index 5036a36..a0cb119 100644 --- a/src/main/java/org/apache/freemarker/core/EvalUtil.java +++ b/src/main/java/org/apache/freemarker/core/EvalUtil.java @@ -24,11 +24,13 @@ import java.util.Date; import org.apache.freemarker.core.model.TemplateBooleanModel; import org.apache.freemarker.core.model.TemplateCollectionModel; import org.apache.freemarker.core.model.TemplateDateModel; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateNumberModel; import org.apache.freemarker.core.model.TemplateScalarModel; import org.apache.freemarker.core.model.TemplateSequenceModel; +import org.apache.freemarker.core.outputformat.MarkupOutputFormat; import org.apache.freemarker.core.util.BugException; /** http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/HTMLOutputFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/HTMLOutputFormat.java b/src/main/java/org/apache/freemarker/core/HTMLOutputFormat.java deleted file mode 100644 index 5d89d6d..0000000 --- a/src/main/java/org/apache/freemarker/core/HTMLOutputFormat.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 org.apache.freemarker.core; - -import java.io.IOException; -import java.io.Writer; - -import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.util._StringUtil; - -/** - * Represents the HTML output format (MIME type "text/html", name "HTML"). This format escapes by default (via - * {@link _StringUtil#XHTMLEnc(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 TemplateHTMLOutputModel}). - * - * @since 2.3.24 - */ -public final class HTMLOutputFormat extends CommonMarkupOutputFormat<TemplateHTMLOutputModel> { - - /** - * The only instance (singleton) of this {@link OutputFormat}. - */ - public static final HTMLOutputFormat INSTANCE = new HTMLOutputFormat(); - - private HTMLOutputFormat() { - // Only to decrease visibility - } - - @Override - public String getName() { - return "HTML"; - } - - @Override - public String getMimeType() { - return "text/html"; - } - - @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 TemplateHTMLOutputModel newTemplateMarkupOutputModel(String plainTextContent, String markupContent) { - return new TemplateHTMLOutputModel(plainTextContent, markupContent); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/JSONOutputFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/JSONOutputFormat.java b/src/main/java/org/apache/freemarker/core/JSONOutputFormat.java deleted file mode 100644 index 8e76701..0000000 --- a/src/main/java/org/apache/freemarker/core/JSONOutputFormat.java +++ /dev/null @@ -1,52 +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; - -/** - * Represents the JSON output format (MIME type "application/json", name "JSON"). This format doesn't support escaping. - * - * @since 2.3.24 - */ -public class JSONOutputFormat extends OutputFormat { - - /** - * The only instance (singleton) of this {@link OutputFormat}. - */ - public static final JSONOutputFormat INSTANCE = new JSONOutputFormat(); - - private JSONOutputFormat() { - // Only to decrease visibility - } - - @Override - public String getName() { - return "JSON"; - } - - @Override - public String getMimeType() { - return "application/json"; - } - - @Override - public boolean isOutputFormatMixingAllowed() { - return false; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/JavaScriptOutputFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/JavaScriptOutputFormat.java b/src/main/java/org/apache/freemarker/core/JavaScriptOutputFormat.java index 1b35f99..82e20d5 100644 --- a/src/main/java/org/apache/freemarker/core/JavaScriptOutputFormat.java +++ b/src/main/java/org/apache/freemarker/core/JavaScriptOutputFormat.java @@ -18,6 +18,8 @@ */ package org.apache.freemarker.core; +import org.apache.freemarker.core.outputformat.OutputFormat; + /** * Represents the JavaScript output format (MIME type "application/javascript", name "JavaScript"). This format doesn't * support escaping. http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/MarkupOutputFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/MarkupOutputFormat.java b/src/main/java/org/apache/freemarker/core/MarkupOutputFormat.java deleted file mode 100644 index 5966f6f..0000000 --- a/src/main/java/org/apache/freemarker/core/MarkupOutputFormat.java +++ /dev/null @@ -1,131 +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.io.Writer; - -import org.apache.freemarker.core.model.TemplateModelException; - -/** - * Superclass of {@link OutputFormat}-s that represent a "markup" format, which is any format where certain character - * sequences have special meaning and thus may need escaping. (Escaping is important for FreeMarker, as typically it has - * to insert non-markup text from the data-model into the output markup. See also: - * {@link Configuration#setOutputFormat(OutputFormat)}.) - * - * <p> - * An {@link OutputFormat} subclass always has a corresponding {@link TemplateMarkupOutputModel} subclass pair (like - * {@link HTMLOutputFormat} has {@link TemplateHTMLOutputModel}). The {@link OutputFormat} implements the operations - * related to {@link TemplateMarkupOutputModel} objects of that kind, while the {@link TemplateMarkupOutputModel} only - * encapsulates the data (the actual markup or text). - * - * <p> - * To implement a custom output format, you may want to extend {@link CommonMarkupOutputFormat}. - * - * @param <MO> - * The {@link TemplateMarkupOutputModel} class this output format can deal with. - * - * @since 2.3.24 - */ -public abstract class MarkupOutputFormat<MO extends TemplateMarkupOutputModel> extends OutputFormat { - - protected MarkupOutputFormat() { - // Only to decrease visibility - } - - /** - * Converts a {@link String} that's assumed to be plain text to {@link TemplateMarkupOutputModel}, by escaping any - * special characters in the plain text. This corresponds to {@code ?esc}, or, to outputting with auto-escaping if - * that wasn't using {@link #output(String, Writer)} as an optimization. - * - * @see #escapePlainText(String) - * @see #getSourcePlainText(TemplateMarkupOutputModel) - */ - public abstract MO fromPlainTextByEscaping(String textToEsc) throws TemplateModelException; - - /** - * Wraps a {@link String} that's already markup to {@link TemplateMarkupOutputModel} interface, to indicate its - * format. This corresponds to {@code ?noEsc}. (This methods is allowed to throw {@link TemplateModelException} if - * the parameter markup text is malformed, but it's unlikely that an implementation chooses to parse the parameter - * until, and if ever, that becomes necessary.) - * - * @see #getMarkupString(TemplateMarkupOutputModel) - */ - public abstract MO fromMarkup(String markupText) throws TemplateModelException; - - /** - * Prints the parameter model to the output. - */ - public abstract void output(MO mo, Writer out) throws IOException, TemplateModelException; - - /** - * Equivalent to calling {@link #fromPlainTextByEscaping(String)} and then - * {@link #output(TemplateMarkupOutputModel, Writer)}, but the implementation may uses a more efficient solution. - */ - public abstract void output(String textToEsc, Writer out) throws IOException, TemplateModelException; - - /** - * If this {@link TemplateMarkupOutputModel} was created with {@link #fromPlainTextByEscaping(String)}, it returns - * the original plain text, otherwise it returns {@code null}. Useful for converting between different types - * of markups, as if the source format can be converted to plain text without loss, then that just has to be - * re-escaped with the target format to do the conversion. - */ - public abstract String getSourcePlainText(MO mo) throws TemplateModelException; - - /** - * Returns the content as markup text; never {@code null}. If this {@link TemplateMarkupOutputModel} was created - * with {@link #fromMarkup(String)}, it might returns the original markup text literally, but this is not required - * as far as the returned markup means the same. If this {@link TemplateMarkupOutputModel} wasn't created - * with {@link #fromMarkup(String)} and it doesn't yet have the markup, it has to generate the markup now. - */ - public abstract String getMarkupString(MO mo) throws TemplateModelException; - - /** - * Returns a {@link TemplateMarkupOutputModel} that contains the content of both {@link TemplateMarkupOutputModel} - * objects concatenated. - */ - public abstract MO concat(MO mo1, MO mo2) throws TemplateModelException; - - /** - * Should give the same result as {@link #fromPlainTextByEscaping(String)} and then - * {@link #getMarkupString(TemplateMarkupOutputModel)}, but the implementation may uses a more efficient solution. - */ - public abstract String escapePlainText(String plainTextContent) throws TemplateModelException; - - /** - * Returns if the markup is empty (0 length). This is used by at least {@code ?hasContent}. - */ - public abstract boolean isEmpty(MO mo) throws TemplateModelException; - - /** - * Tells if a string built-in that can't handle a {@link TemplateMarkupOutputModel} left hand operand can bypass - * this object as is. A typical such case would be when a {@link TemplateHTMLOutputModel} of "HTML" format bypasses - * {@code ?html}. - */ - public abstract boolean isLegacyBuiltInBypassed(String builtInName) throws TemplateModelException; - - /** - * Tells if by default auto-escaping should be on for this format. It should be {@code true} if you need to escape - * on most of the places where you insert values. - * - * @see Configuration#setAutoEscapingPolicy(int) - */ - public abstract boolean isAutoEscapedByDefault(); - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/MarkupOutputFormatBoundBuiltIn.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/MarkupOutputFormatBoundBuiltIn.java b/src/main/java/org/apache/freemarker/core/MarkupOutputFormatBoundBuiltIn.java index b97663f..14997ae 100644 --- a/src/main/java/org/apache/freemarker/core/MarkupOutputFormatBoundBuiltIn.java +++ b/src/main/java/org/apache/freemarker/core/MarkupOutputFormatBoundBuiltIn.java @@ -19,6 +19,7 @@ package org.apache.freemarker.core; import org.apache.freemarker.core.model.TemplateModel; +import org.apache.freemarker.core.outputformat.MarkupOutputFormat; import org.apache.freemarker.core.util._NullArgumentException; abstract class MarkupOutputFormatBoundBuiltIn extends SpecialBuiltIn { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/NonMarkupOutputException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/NonMarkupOutputException.java b/src/main/java/org/apache/freemarker/core/NonMarkupOutputException.java index 6f69980..bacf0fc 100644 --- a/src/main/java/org/apache/freemarker/core/NonMarkupOutputException.java +++ b/src/main/java/org/apache/freemarker/core/NonMarkupOutputException.java @@ -19,6 +19,7 @@ package org.apache.freemarker.core; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; import org.apache.freemarker.core.model.TemplateModel; /** http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/NonStringOrTemplateOutputException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/NonStringOrTemplateOutputException.java b/src/main/java/org/apache/freemarker/core/NonStringOrTemplateOutputException.java index 4374f2d..11c975d 100644 --- a/src/main/java/org/apache/freemarker/core/NonStringOrTemplateOutputException.java +++ b/src/main/java/org/apache/freemarker/core/NonStringOrTemplateOutputException.java @@ -19,6 +19,7 @@ package org.apache.freemarker.core; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateScalarModel; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/OutputFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/OutputFormat.java b/src/main/java/org/apache/freemarker/core/OutputFormat.java deleted file mode 100644 index 7c16c5b..0000000 --- a/src/main/java/org/apache/freemarker/core/OutputFormat.java +++ /dev/null @@ -1,83 +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 org.apache.freemarker.core.util._ClassUtil; -import org.apache.freemarker.core.util._StringUtil; - -/** - * Represents an output format. If you need auto-escaping, see its subclass, {@link MarkupOutputFormat}. - * - * @see Configuration#setOutputFormat(OutputFormat) - * @see Configuration#setRegisteredCustomOutputFormats(java.util.Collection) - * @see MarkupOutputFormat - * - * @since 2.3.24 - */ -public abstract class OutputFormat { - - /** - * The short name used to refer to this format (like in the {@code #ftl} header). - */ - public abstract String getName(); - - /** - * Returns the MIME type of the output format. This might comes handy when generating a HTTP response. {@code null} - * if this output format doesn't clearly corresponds to a specific MIME type. - */ - public abstract String getMimeType(); - - /** - * Tells if this output format allows inserting {@link TemplateMarkupOutputModel}-s of another output formats into - * it. If {@code true}, the foreign {@link TemplateMarkupOutputModel} will be inserted into the output as is (like - * if the surrounding output format was the same). This is usually a bad idea allow, as such an event could indicate - * application bugs. If this method returns {@code false} (recommended), then FreeMarker will try to assimilate the - * inserted value by converting its format to this format, which will currently (2.3.24) cause exception, unless the - * inserted value is made by escaping plain text and the target format is non-escaping, in which case format - * conversion is trivially possible. (It's not impossible that conversions will be extended beyond this, if there - * will be demand for that.) - * - * <p> - * {@code true} value is used by {@link UndefinedOutputFormat}. - */ - public abstract boolean isOutputFormatMixingAllowed(); - - /** - * Returns the short description of this format, to be used in error messages. - * Override {@link #toStringExtraProperties()} to customize this. - */ - @Override - public final String toString() { - String extras = toStringExtraProperties(); - return getName() + "(" - + "mimeType=" + _StringUtil.jQuote(getMimeType()) + ", " - + "class=" + _ClassUtil.getShortClassNameOfObject(this, true) - + (extras.length() != 0 ? ", " : "") + extras - + ")"; - } - - /** - * Should be like {@code "foo=\"something\", bar=123"}; this will be inserted inside the parentheses in - * {@link #toString()}. Shouldn't return {@code null}; should return {@code ""} if there are no extra properties. - */ - protected String toStringExtraProperties() { - return ""; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/OutputFormatBoundBuiltIn.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/OutputFormatBoundBuiltIn.java b/src/main/java/org/apache/freemarker/core/OutputFormatBoundBuiltIn.java index f0a38d3..924b8c6 100644 --- a/src/main/java/org/apache/freemarker/core/OutputFormatBoundBuiltIn.java +++ b/src/main/java/org/apache/freemarker/core/OutputFormatBoundBuiltIn.java @@ -19,6 +19,7 @@ package org.apache.freemarker.core; import org.apache.freemarker.core.model.TemplateModel; +import org.apache.freemarker.core.outputformat.OutputFormat; import org.apache.freemarker.core.util._NullArgumentException; abstract class OutputFormatBoundBuiltIn extends SpecialBuiltIn { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/ParserConfiguration.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ParserConfiguration.java b/src/main/java/org/apache/freemarker/core/ParserConfiguration.java index 24b6a1d..a72ba36 100644 --- a/src/main/java/org/apache/freemarker/core/ParserConfiguration.java +++ b/src/main/java/org/apache/freemarker/core/ParserConfiguration.java @@ -18,6 +18,8 @@ */ package org.apache.freemarker.core; +import org.apache.freemarker.core.outputformat.OutputFormat; + /** * <b>Don't implement this interface yourself</b>; use the existing implementation(s). This interface is implemented by * classes that hold settings that affect parsing. New parser settings can be added in new FreeMarker versions, which http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/PlainTextOutputFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/PlainTextOutputFormat.java b/src/main/java/org/apache/freemarker/core/PlainTextOutputFormat.java deleted file mode 100644 index 3a58c56..0000000 --- a/src/main/java/org/apache/freemarker/core/PlainTextOutputFormat.java +++ /dev/null @@ -1,56 +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; - -/** - * Represents the plain text output format (MIME type "text/plain", name "plainText"). This format doesn't support - * escaping. This format doesn't allow mixing in template output values of other output formats. - * - * <p> - * The main difference from {@link UndefinedOutputFormat} is that this format doesn't allow inserting values of another - * output format into itself (unless they can be converted to plain text), while {@link UndefinedOutputFormat} would - * just insert the foreign "markup" as is. Also, this format has {"text/plain"} MIME type, while - * {@link UndefinedOutputFormat} has {@code null}. - * - * @since 2.3.24 - */ -public final class PlainTextOutputFormat extends OutputFormat { - - public static final PlainTextOutputFormat INSTANCE = new PlainTextOutputFormat(); - - private PlainTextOutputFormat() { - // Only to decrease visibility - } - - @Override - public boolean isOutputFormatMixingAllowed() { - return false; - } - - @Override - public String getName() { - return "plainText"; - } - - @Override - public String getMimeType() { - return "text/plain"; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/RTFOutputFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/RTFOutputFormat.java b/src/main/java/org/apache/freemarker/core/RTFOutputFormat.java deleted file mode 100644 index 3c00eef..0000000 --- a/src/main/java/org/apache/freemarker/core/RTFOutputFormat.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 org.apache.freemarker.core; - -import java.io.IOException; -import java.io.Writer; - -import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.util._StringUtil; - -/** - * Represents the Rich Text Format output format (MIME type "application/rtf", name "RTF"). This format escapes by - * default (via {@link _StringUtil#RTFEnc(String)}). The {@code ?rtf} built-in silently bypasses template output values - * of the type produced by this output format ({@link TemplateRTFOutputModel}). - * - * @since 2.3.24 - */ -public final class RTFOutputFormat extends CommonMarkupOutputFormat<TemplateRTFOutputModel> { - - /** - * The only instance (singleton) of this {@link OutputFormat}. - */ - public static final RTFOutputFormat INSTANCE = new RTFOutputFormat(); - - private RTFOutputFormat() { - // Only to decrease visibility - } - - @Override - public String getName() { - return "RTF"; - } - - @Override - public String getMimeType() { - return "application/rtf"; - } - - @Override - public void output(String textToEsc, Writer out) throws IOException, TemplateModelException { - _StringUtil.RTFEnc(textToEsc, out); - } - - @Override - public String escapePlainText(String plainTextContent) { - return _StringUtil.RTFEnc(plainTextContent); - } - - @Override - public boolean isLegacyBuiltInBypassed(String builtInName) { - return builtInName.equals("rtf"); - } - - @Override - protected TemplateRTFOutputModel newTemplateMarkupOutputModel(String plainTextContent, String markupContent) { - return new TemplateRTFOutputModel(plainTextContent, markupContent); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/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 8888aaf..6c863c6 100644 --- a/src/main/java/org/apache/freemarker/core/Template.java +++ b/src/main/java/org/apache/freemarker/core/Template.java @@ -29,13 +29,13 @@ import java.util.List; import java.util.Map; import java.util.Vector; -import org.apache.freemarker.core.FMParser; import org.apache.freemarker.core.debug.impl.DebuggerService; import org.apache.freemarker.core.model.ObjectWrapper; import org.apache.freemarker.core.model.TemplateHashModel; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateNodeModel; import org.apache.freemarker.core.model.impl.SimpleHash; +import org.apache.freemarker.core.outputformat.OutputFormat; import org.apache.freemarker.core.templateresolver.TemplateLoader; import org.apache.freemarker.core.templateresolver.TemplateLookupStrategy; import org.apache.freemarker.core.templateresolver.impl.DefaultTemplateResolver; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/TemplateCombinedMarkupOutputModel.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/TemplateCombinedMarkupOutputModel.java b/src/main/java/org/apache/freemarker/core/TemplateCombinedMarkupOutputModel.java deleted file mode 100644 index fef06d6..0000000 --- a/src/main/java/org/apache/freemarker/core/TemplateCombinedMarkupOutputModel.java +++ /dev/null @@ -1,50 +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; - -/** - * Stores combined markup to be printed; used with {@link CombinedMarkupOutputFormat}. - * - * @since 2.3.24 - */ -public final class TemplateCombinedMarkupOutputModel - extends CommonTemplateMarkupOutputModel<TemplateCombinedMarkupOutputModel> { - - private final CombinedMarkupOutputFormat outputFormat; - - /** - * See {@link CommonTemplateMarkupOutputModel#CommonTemplateMarkupOutputModel(String, String)}. - * - * @param outputFormat - * The {@link CombinedMarkupOutputFormat} format this value is bound to. Because - * {@link CombinedMarkupOutputFormat} has no singleton, we have to pass it in, unlike with most other - * {@link CommonTemplateMarkupOutputModel}-s. - */ - TemplateCombinedMarkupOutputModel(String plainTextContent, String markupContent, - CombinedMarkupOutputFormat outputFormat) { - super(plainTextContent, markupContent); - this.outputFormat = outputFormat; - } - - @Override - public CombinedMarkupOutputFormat getOutputFormat() { - return outputFormat; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java b/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java index 583f064..0a01c14 100644 --- a/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java +++ b/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java @@ -27,6 +27,7 @@ import java.util.Map; import java.util.TimeZone; import org.apache.freemarker.core.model.ObjectWrapper; +import org.apache.freemarker.core.outputformat.OutputFormat; import org.apache.freemarker.core.templateresolver.impl.DefaultTemplateResolver; import org.apache.freemarker.core.util._NullArgumentException; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/TemplateDateFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/TemplateDateFormat.java b/src/main/java/org/apache/freemarker/core/TemplateDateFormat.java index 07ee8ee..ed7f996 100644 --- a/src/main/java/org/apache/freemarker/core/TemplateDateFormat.java +++ b/src/main/java/org/apache/freemarker/core/TemplateDateFormat.java @@ -23,6 +23,7 @@ import java.text.DateFormat; import java.util.Date; import org.apache.freemarker.core.model.TemplateDateModel; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; import org.apache.freemarker.core.model.TemplateModelException; /** http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/TemplateHTMLOutputModel.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/TemplateHTMLOutputModel.java b/src/main/java/org/apache/freemarker/core/TemplateHTMLOutputModel.java deleted file mode 100644 index f4acd01..0000000 --- a/src/main/java/org/apache/freemarker/core/TemplateHTMLOutputModel.java +++ /dev/null @@ -1,40 +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; - -/** - * Stores HTML markup to be printed; used with {@link HTMLOutputFormat}. - * - * @since 2.3.24 - */ -public final class TemplateHTMLOutputModel extends CommonTemplateMarkupOutputModel<TemplateHTMLOutputModel> { - - /** - * See {@link CommonTemplateMarkupOutputModel#CommonTemplateMarkupOutputModel(String, String)}. - */ - TemplateHTMLOutputModel(String plainTextContent, String markupContent) { - super(plainTextContent, markupContent); - } - - @Override - public HTMLOutputFormat getOutputFormat() { - return HTMLOutputFormat.INSTANCE; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/TemplateMarkupOutputModel.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/TemplateMarkupOutputModel.java b/src/main/java/org/apache/freemarker/core/TemplateMarkupOutputModel.java deleted file mode 100644 index 1d4c5af..0000000 --- a/src/main/java/org/apache/freemarker/core/TemplateMarkupOutputModel.java +++ /dev/null @@ -1,52 +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 org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.model.TemplateScalarModel; - -/** - * "markup output" template language data-type; stores markup (some kind of "rich text" / structured format, as opposed - * to plain text) that meant to be printed as template output. This type is related to the {@link OutputFormat} - * mechanism. Values of this kind are exempt from {@link OutputFormat}-based automatic escaping. - * - * <p> - * Each implementation of this type has a {@link OutputFormat} subclass pair, whose singleton instance is returned by - * {@link #getOutputFormat()}. See more about how markup output values work at {@link OutputFormat}. - * - * <p> - * Note that {@link TemplateMarkupOutputModel}-s are by design not treated like {@link TemplateScalarModel}-s, and so - * the implementations of this interface usually shouldn't implement {@link TemplateScalarModel}. (Because, operations - * applicable on plain strings, like converting to upper case, substringing, etc., can corrupt markup.) If the template - * author wants to pass in the "source" of the markup as string somewhere, he should use {@code ?markup_string}. - * - * @param <MO> - * Refers to the interface's own type, which is useful in interfaces that extend - * {@link TemplateMarkupOutputModel} (Java Generics trick). - * - * @since 2.3.24 - */ -public interface TemplateMarkupOutputModel<MO extends TemplateMarkupOutputModel<MO>> extends TemplateModel { - - /** - * Returns the singleton {@link OutputFormat} object that implements the operations for the "markup output" value. - */ - MarkupOutputFormat<MO> getOutputFormat(); - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/TemplateNumberFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/TemplateNumberFormat.java b/src/main/java/org/apache/freemarker/core/TemplateNumberFormat.java index f4f4e70..cc35724 100644 --- a/src/main/java/org/apache/freemarker/core/TemplateNumberFormat.java +++ b/src/main/java/org/apache/freemarker/core/TemplateNumberFormat.java @@ -21,6 +21,7 @@ package org.apache.freemarker.core; import java.text.NumberFormat; import org.apache.freemarker.core.model.TemplateDateModel; +import org.apache.freemarker.core.model.TemplateMarkupOutputModel; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateNumberModel; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/TemplateRTFOutputModel.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/TemplateRTFOutputModel.java b/src/main/java/org/apache/freemarker/core/TemplateRTFOutputModel.java deleted file mode 100644 index 008737a..0000000 --- a/src/main/java/org/apache/freemarker/core/TemplateRTFOutputModel.java +++ /dev/null @@ -1,40 +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; - -/** - * Stores RTF markup to be printed; used with {@link RTFOutputFormat}. - * - * @since 2.3.24 - */ -public final class TemplateRTFOutputModel extends CommonTemplateMarkupOutputModel<TemplateRTFOutputModel> { - - /** - * See {@link CommonTemplateMarkupOutputModel#CommonTemplateMarkupOutputModel(String, String)}. - */ - TemplateRTFOutputModel(String plainTextContent, String markupContent) { - super(plainTextContent, markupContent); - } - - @Override - public RTFOutputFormat getOutputFormat() { - return RTFOutputFormat.INSTANCE; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/TemplateXHTMLOutputModel.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/TemplateXHTMLOutputModel.java b/src/main/java/org/apache/freemarker/core/TemplateXHTMLOutputModel.java deleted file mode 100644 index 3871e58..0000000 --- a/src/main/java/org/apache/freemarker/core/TemplateXHTMLOutputModel.java +++ /dev/null @@ -1,40 +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; - -/** - * Stores HTML markup to be printed; used with {@link HTMLOutputFormat}. - * - * @since 2.3.24 - */ -public final class TemplateXHTMLOutputModel extends CommonTemplateMarkupOutputModel<TemplateXHTMLOutputModel> { - - /** - * See {@link CommonTemplateMarkupOutputModel#CommonTemplateMarkupOutputModel(String, String)}. - */ - TemplateXHTMLOutputModel(String plainTextContent, String markupContent) { - super(plainTextContent, markupContent); - } - - @Override - public XHTMLOutputFormat getOutputFormat() { - return XHTMLOutputFormat.INSTANCE; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/TemplateXMLOutputModel.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/TemplateXMLOutputModel.java b/src/main/java/org/apache/freemarker/core/TemplateXMLOutputModel.java deleted file mode 100644 index 38d2fe1..0000000 --- a/src/main/java/org/apache/freemarker/core/TemplateXMLOutputModel.java +++ /dev/null @@ -1,40 +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; - -/** - * Stores XML markup to be printed; used with {@link XMLOutputFormat}. - * - * @since 2.3.24 - */ -public final class TemplateXMLOutputModel extends CommonTemplateMarkupOutputModel<TemplateXMLOutputModel> { - - /** - * See {@link CommonTemplateMarkupOutputModel#CommonTemplateMarkupOutputModel(String, String)}. - */ - TemplateXMLOutputModel(String plainTextContent, String markupContent) { - super(plainTextContent, markupContent); - } - - @Override - public XMLOutputFormat getOutputFormat() { - return XMLOutputFormat.INSTANCE; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/db77001f/src/main/java/org/apache/freemarker/core/UndefinedOutputFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/UndefinedOutputFormat.java b/src/main/java/org/apache/freemarker/core/UndefinedOutputFormat.java deleted file mode 100644 index 6b6d46e..0000000 --- a/src/main/java/org/apache/freemarker/core/UndefinedOutputFormat.java +++ /dev/null @@ -1,55 +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; - -/** - * 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(org.apache.freemarker.core.templateresolver.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/db77001f/src/main/java/org/apache/freemarker/core/UnregisteredOutputFormatException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/UnregisteredOutputFormatException.java b/src/main/java/org/apache/freemarker/core/UnregisteredOutputFormatException.java deleted file mode 100644 index dd5a18a..0000000 --- a/src/main/java/org/apache/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 org.apache.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/db77001f/src/main/java/org/apache/freemarker/core/XHTMLOutputFormat.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/XHTMLOutputFormat.java b/src/main/java/org/apache/freemarker/core/XHTMLOutputFormat.java deleted file mode 100644 index 101d056..0000000 --- a/src/main/java/org/apache/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 org.apache.freemarker.core; - -import java.io.IOException; -import java.io.Writer; - -import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.util._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); - } - -}
