diff --git a/core/src/main/java/com/opensymphony/xwork2/config/impl/AbstractMatcher.java b/core/src/main/java/com/opensymphony/xwork2/config/impl/AbstractMatcher.java
index 0b95367e3b..ed5e053761 100644
--- a/core/src/main/java/com/opensymphony/xwork2/config/impl/AbstractMatcher.java
+++ b/core/src/main/java/com/opensymphony/xwork2/config/impl/AbstractMatcher.java
@@ -74,17 +74,6 @@ public AbstractMatcher(PatternMatcher> helper, boolean appendNamedParameters)
this.appendNamedParameters = appendNamedParameters;
}
- /**
- * Creates a matcher with {@link #appendNamedParameters} set to true to keep backward compatibility
- *
- * @param helper an instance of {@link PatternMatcher}
- * @deprecated use @{link {@link AbstractMatcher(PatternMatcher, boolean)} instead
- */
- @Deprecated
- public AbstractMatcher(PatternMatcher> helper) {
- this(helper, true);
- }
-
/**
*
* Finds and precompiles the wildcard patterns. Patterns will be evaluated
@@ -108,7 +97,7 @@ public void addPattern(String name, E target, boolean looseMatch) {
Object pattern;
if (!wildcard.isLiteral(name)) {
- if (looseMatch && (name.length() > 0) && (name.charAt(0) == '/')) {
+ if (looseMatch && (!name.isEmpty()) && (name.charAt(0) == '/')) {
name = name.substring(1);
}
@@ -142,14 +131,14 @@ public void freeze() {
public E match(String potentialMatch) {
E config = null;
- if (compiledPatterns.size() > 0) {
+ if (!compiledPatterns.isEmpty()) {
LOG.debug("Attempting to match '{}' to a wildcard pattern, {} available", potentialMatch, compiledPatterns.size());
Map vars = new LinkedHashMap<>();
for (Mapping m : compiledPatterns) {
- if (wildcard.match(vars, potentialMatch, m.getPattern())) {
- LOG.debug("Value matches pattern '{}'", m.getOriginalPattern());
- config = convert(potentialMatch, m.getTarget(), vars);
+ if (wildcard.match(vars, potentialMatch, m.pattern())) {
+ LOG.debug("Value matches pattern '{}'", m.originalPattern());
+ config = convert(potentialMatch, m.target(), vars);
break;
}
}
@@ -216,7 +205,7 @@ protected String convertParam(String val, Map vars) {
Matcher wildcardMatcher = WILDCARD_PATTERN.matcher(val);
- StringBuffer result = new StringBuffer();
+ StringBuilder result = new StringBuilder();
while (wildcardMatcher.find()) {
wildcardMatcher.appendReplacement(result, vars.getOrDefault(wildcardMatcher.group(1), ""));
}
@@ -228,62 +217,11 @@ protected String convertParam(String val, Map vars) {
/**
* Stores a compiled wildcard pattern and the object it came
* from.
+ *
+ * @param originalPattern The original pattern.
+ * @param pattern The compiled pattern.
+ * @param target The original object.
*/
- private static class Mapping implements Serializable {
- /**
- * The original pattern.
- */
- private final String original;
-
-
- /**
- * The compiled pattern.
- */
- private final Object pattern;
-
- /**
- * The original object.
- */
- private final E config;
-
- /**
- * Contructs a read-only Mapping instance.
- *
- * @param original The original pattern
- * @param pattern The compiled pattern
- * @param config The original object
- */
- public Mapping(String original, Object pattern, E config) {
- this.original = original;
- this.pattern = pattern;
- this.config = config;
- }
-
- /**
- * Gets the compiled wildcard pattern.
- *
- * @return The compiled pattern
- */
- public Object getPattern() {
- return this.pattern;
- }
-
- /**
- * Gets the object that contains the pattern.
- *
- * @return The associated object
- */
- public E getTarget() {
- return this.config;
- }
-
- /**
- * Gets the original wildcard pattern.
- *
- * @return The original pattern
- */
- public String getOriginalPattern() {
- return this.original;
- }
+ private record Mapping(String originalPattern, Object pattern, E target) implements Serializable {
}
}
diff --git a/core/src/main/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcher.java b/core/src/main/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcher.java
index 027dc4a58f..16ac9a2fbd 100644
--- a/core/src/main/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcher.java
+++ b/core/src/main/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcher.java
@@ -124,7 +124,7 @@ public CompiledPattern compilePattern(String data) {
*/
public boolean match(Map map, String data, CompiledPattern expr) {
- if (data != null && data.length() > 0) {
+ if (data != null && !data.isEmpty()) {
Matcher matcher = expr.getPattern().matcher(data);
if (matcher.matches()) {
for (int x = 0; x < expr.getVariableNames().size(); x++) {
diff --git a/core/src/main/java/com/opensymphony/xwork2/util/PatternMatcher.java b/core/src/main/java/com/opensymphony/xwork2/util/PatternMatcher.java
index 2a52ad375a..e57a74b36f 100644
--- a/core/src/main/java/com/opensymphony/xwork2/util/PatternMatcher.java
+++ b/core/src/main/java/com/opensymphony/xwork2/util/PatternMatcher.java
@@ -22,10 +22,10 @@
/**
* Compiles and matches a pattern against a value
- *
+ *
* @since 2.1
*/
-public interface PatternMatcher {
+public interface PatternMatcher {
/**
* Determines if the pattern is a simple literal string or contains wildcards that will need to be processed
@@ -36,16 +36,16 @@ public interface PatternMatcher {
/**
* Translate the given String
into an object
- * representing the pattern matchable by this class.
+ * representing the pattern matchable by this class.
*
* @param data The string to translate.
- * @return The encoded string
+ * @return The encoded string
* @throws NullPointerException If data is null.
*/
E compilePattern(String data);
/**
- * Match a pattern against a string
+ * Match a pattern against a string
*
* @param map The map to store matched values
* @param data The string to match
@@ -54,5 +54,5 @@ public interface PatternMatcher {
* @throws NullPointerException If any parameters are null
*/
boolean match(Map map, String data, E expr);
-
-}
\ No newline at end of file
+
+}
diff --git a/core/src/main/java/com/opensymphony/xwork2/util/StrutsLocalizedTextProvider.java b/core/src/main/java/com/opensymphony/xwork2/util/StrutsLocalizedTextProvider.java
index 48acc42740..441e52e474 100644
--- a/core/src/main/java/com/opensymphony/xwork2/util/StrutsLocalizedTextProvider.java
+++ b/core/src/main/java/com/opensymphony/xwork2/util/StrutsLocalizedTextProvider.java
@@ -38,65 +38,11 @@ public class StrutsLocalizedTextProvider extends AbstractLocalizedTextProvider {
private static final Logger LOG = LogManager.getLogger(StrutsLocalizedTextProvider.class);
- /**
- * Clears the internal list of resource bundles.
- *
- * @deprecated used only in tests
- */
- @Deprecated
- public static void clearDefaultResourceBundles() {
- // no-op
- }
-
public StrutsLocalizedTextProvider() {
addDefaultResourceBundle(XWORK_MESSAGES_BUNDLE);
addDefaultResourceBundle(STRUTS_MESSAGES_BUNDLE);
}
- /**
- * Builds a {@link java.util.Locale} from a String of the form en_US_foo into a Locale
- * with language "en", country "US" and variant "foo". This will parse the output of
- * {@link java.util.Locale#toString()}.
- *
- * @param localeStr The locale String to parse.
- * @param defaultLocale The locale to use if localeStr is null.
- * @return requested Locale
- * @deprecated please use {@link org.apache.commons.lang3.LocaleUtils#toLocale(String)}
- */
- @Deprecated
- public static Locale localeFromString(String localeStr, Locale defaultLocale) {
- if ((localeStr == null) || (localeStr.trim().length() == 0) || ("_".equals(localeStr))) {
- if (defaultLocale != null) {
- return defaultLocale;
- }
- return Locale.getDefault();
- }
-
- int index = localeStr.indexOf('_');
- if (index < 0) {
- return new Locale(localeStr);
- }
-
- String language = localeStr.substring(0, index);
- if (index == localeStr.length()) {
- return new Locale(language);
- }
-
- localeStr = localeStr.substring(index + 1);
- index = localeStr.indexOf('_');
- if (index < 0) {
- return new Locale(language, localeStr);
- }
-
- String country = localeStr.substring(0, index);
- if (index == localeStr.length()) {
- return new Locale(language, country);
- }
-
- localeStr = localeStr.substring(index + 1);
- return new Locale(language, country, localeStr);
- }
-
/**
* Calls {@link #findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)}
* with aTextName as the default message.
@@ -135,7 +81,7 @@ public String findText(Class aClass, String aTextName, Locale locale) {
* object. If so, repeat the entire process from the beginning with the object's class as
* aClass and "address.state" as the message key.
* If not found, look for the message in aClass' package hierarchy.
- * If still not found, look for the message in the default resource bundles
+ * If still not found, look for the message in the default resource bundles
* (Note: the lookup is not repeated again if {@link #searchDefaultBundlesFirst} was true
).
* Return defaultMessage
*
@@ -190,7 +136,7 @@ public String findText(Class aClass, String aTextName, Locale locale, String def
* object. If so, repeat the entire process from the beginning with the object's class as
* aClass and "address.state" as the message key.
* If not found, look for the message in aClass' package hierarchy.
- * If still not found, look for the message in the default resource bundles
+ * If still not found, look for the message in the default resource bundles
* (Note: the lookup is not repeated again if {@link #searchDefaultBundlesFirst} was true
).
* Return defaultMessage
*
diff --git a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
index fe178257db..067ff50754 100644
--- a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
+++ b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
@@ -28,7 +28,6 @@
import freemarker.cache.FileTemplateLoader;
import freemarker.cache.MultiTemplateLoader;
import freemarker.cache.TemplateLoader;
-import freemarker.ext.jakarta.servlet.WebappTemplateLoader;
import freemarker.core.HTMLOutputFormat;
import freemarker.core.TemplateClassResolver;
import freemarker.ext.jakarta.jsp.TaglibFactory;
@@ -36,6 +35,7 @@
import freemarker.ext.jakarta.servlet.HttpRequestParametersHashModel;
import freemarker.ext.jakarta.servlet.HttpSessionHashModel;
import freemarker.ext.jakarta.servlet.ServletContextHashModel;
+import freemarker.ext.jakarta.servlet.WebappTemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.ObjectWrapper;
import freemarker.template.TemplateException;
@@ -43,6 +43,11 @@
import freemarker.template.TemplateModel;
import freemarker.template.Version;
import freemarker.template.utility.StringUtil;
+import jakarta.servlet.GenericServlet;
+import jakarta.servlet.ServletContext;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpSession;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
@@ -50,11 +55,6 @@
import org.apache.struts2.views.TagLibraryModelProvider;
import org.apache.struts2.views.util.ContextUtil;
-import jakarta.servlet.GenericServlet;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import jakarta.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -137,27 +137,6 @@ public class FreemarkerManager {
public static final String EXPIRATION_DATE;
- /**
- * @deprecated since Struts 6.5.0, do not use as it will be removed in Struts 7.0.0
- */
- @Deprecated
- public static final String KEY_INCLUDE = "include_page";
- /**
- * @deprecated since Struts 6.5.0, do not use as it will be removed in Struts 7.0.0
- */
- @Deprecated
- public static final String KEY_REQUEST_PRIVATE = "__FreeMarkerServlet.Request__";
- /**
- * @deprecated since Struts 6.5.0, do not use as it will be removed in Struts 7.0.0
- */
- @Deprecated
- public static final String KEY_REQUEST_PARAMETERS = "RequestParameters";
- /**
- * @deprecated since Struts 6.5.0, do not use as it will be removed in Struts 7.0.0
- */
- @Deprecated
- public static final String KEY_HASHMODEL_PRIVATE = "__FreeMarkerManager.Request__";
-
/**
* Adds individual settings.
*
diff --git a/core/src/main/resources/struts-beans.xml b/core/src/main/resources/struts-beans.xml
index 5c3121f77f..a51cb4854c 100644
--- a/core/src/main/resources/struts-beans.xml
+++ b/core/src/main/resources/struts-beans.xml
@@ -178,16 +178,6 @@
-
-
-
-
-
-
-
-