This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-3877-removes-alt-syntax in repository https://gitbox.apache.org/repos/asf/struts.git
commit 4fe3d48f6cd14237b9c482de2ea76f5579ca61cc Author: Lukasz Lenart <lukaszlen...@apache.org> AuthorDate: Sun Dec 13 16:03:12 2020 +0100 WW-3877 Removes comments about altSyntax --- .../org/apache/struts2/components/Component.java | 58 ++++++++++------------ .../struts2/config/entities/ConstantConfig.java | 1 - .../org/apache/struts2/util/ComponentUtils.java | 7 ++- .../java/org/apache/struts2/util/StrutsUtil.java | 2 +- 4 files changed, 31 insertions(+), 37 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/components/Component.java b/core/src/main/java/org/apache/struts2/components/Component.java index 1794029..e20b4f5 100644 --- a/core/src/main/java/org/apache/struts2/components/Component.java +++ b/core/src/main/java/org/apache/struts2/components/Component.java @@ -272,38 +272,36 @@ public class Component { /** * Finds a value from the OGNL stack based on the given expression. * Will always evaluate <code>expr</code> against stack except when <code>expr</code> - * is null. If altsyntax (%{...}) is applied, simply strip it off. + * is null. If %{...} is applied, simply strip it off. * - * @param expr the expression. Returns <tt>null</tt> if expr is null. + * @param expression the expression. Returns <tt>null</tt> if expr is null. * @return the value, <tt>null</tt> if not found. */ - protected Object findValue(String expr) { - if (expr == null) { + protected Object findValue(String expression) { + if (expression == null) { return null; } - expr = stripExpression(expr); + expression = stripExpression(expression); - return getStack().findValue(expr, throwExceptionOnELFailure); + return getStack().findValue(expression, throwExceptionOnELFailure); } /** - * If altsyntax (%{...}) is applied, simply strip the "%{" and "}" off. + * If %{...} is applied, simply strip the "%{" and "}" off. * - * @param expr the expression (must be not null) - * @return the stripped expression if altSyntax is enabled. Otherwise - * the parameter expression is returned as is. + * @param expression the expression (must be not null) + * @return the stripped expression */ - protected String stripExpression(String expr) { - return ComponentUtils.stripExpression(expr); + protected String stripExpression(String expression) { + return ComponentUtils.stripExpression(expression); } /** * Adds the surrounding %{ } to the expression for proper processing. * * @param expr the expression. - * @return the modified expression if altSyntax is enabled, or the parameter - * expression otherwise. + * @return the modified expression wrapped with %{...} */ protected String completeExpression(String expr) { if (expr == null) { @@ -356,38 +354,36 @@ public class Component { /** * Evaluates the OGNL stack to find an Object of the given type. Will evaluate - * <code>expr</code> the portion wrapped with altSyntax (%{...}) - * against stack when altSyntax is on, else the whole <code>expr</code> - * is evaluated against the stack. - * <br> - * This method only supports the altSyntax. So this should be set to true. + * <code>expression</code> the portion wrapped with %{...} against stack if + * evaluating to String.class, else the whole <code>expression</code> is evaluated + * against the stack. * - * @param expr OGNL expression. + * @param expression OGNL expression. * @param toType the type expected to find. * @return the Object found, or <tt>null</tt> if not found. */ - protected Object findValue(String expr, Class<?> toType) { + protected Object findValue(String expression, Class<?> toType) { if (toType == String.class) { - if (ComponentUtils.containsExpression(expr)) { - return TextParseUtil.translateVariables('%', expr, stack); + if (ComponentUtils.containsExpression(expression)) { + return TextParseUtil.translateVariables('%', expression, stack); } else { - return expr; + return expression; } } else { - expr = stripExpression(expr); + expression = stripExpression(expression); - return getStack().findValue(expr, toType, throwExceptionOnELFailure); + return getStack().findValue(expression, toType, throwExceptionOnELFailure); } } /** - * Detects if altSyntax is enabled and then checks if expression contains %{...} + * Detects if expression already contains %{...} * - * @param expr a string to examined - * @return true if altSyntax is enabled and expr contains %{...} + * @param expression a string to examined + * @return true if expression contains %{...} */ - protected boolean recursion(String expr) { - return ComponentUtils.containsExpression(expr); + protected boolean recursion(String expression) { + return ComponentUtils.containsExpression(expression); } /** diff --git a/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java b/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java index 1245558..6d9be83 100644 --- a/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java +++ b/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java @@ -37,7 +37,6 @@ public class ConstantConfig { private Boolean configurationXmlReload; private List<String> actionExtension; private List<Pattern> actionExcludePattern; - private Boolean tagAltSyntax; private Integer urlHttpPort; private Integer urlHttpsPort; private String urlIncludeParams; diff --git a/core/src/main/java/org/apache/struts2/util/ComponentUtils.java b/core/src/main/java/org/apache/struts2/util/ComponentUtils.java index edbcb7f..ab15e3d 100644 --- a/core/src/main/java/org/apache/struts2/util/ComponentUtils.java +++ b/core/src/main/java/org/apache/struts2/util/ComponentUtils.java @@ -24,11 +24,10 @@ package org.apache.struts2.util; public class ComponentUtils { /** - * If altSyntax (%{...}) is applied, simply strip the "%{" and "}" off. + * Simply strip the "%{" and "}" off. * * @param expr the expression (must be not null) - * @return the stripped expression if altSyntax is enabled. Otherwise - * the parameter expression is returned as is. + * @return the stripped expression */ public static String stripExpression(String expr) { // does the expression start with %{ and end with }? if so, just cut it off! @@ -39,7 +38,7 @@ public class ComponentUtils { } /** - * Check if object is expression base on altSyntax + * Check if object is an expression * * @param expr to treat as an expression * @return true if it is an expression diff --git a/core/src/main/java/org/apache/struts2/util/StrutsUtil.java b/core/src/main/java/org/apache/struts2/util/StrutsUtil.java index 2d95314..b694250 100644 --- a/core/src/main/java/org/apache/struts2/util/StrutsUtil.java +++ b/core/src/main/java/org/apache/struts2/util/StrutsUtil.java @@ -136,7 +136,7 @@ public class StrutsUtil { } public String translateVariables(String expression) { - return TextParseUtil.translateVariables(expression, stack); + return TextParseUtil.translateVariables('%', expression, stack); } /**