Revision: 461
http://svn.sourceforge.net/stripes/?rev=461&view=rev
Author: tfenne
Date: 2006-10-29 05:08:11 -0800 (Sun, 29 Oct 2006)
Log Message:
-----------
Fix for STS-293: ActionResolver.PackageFilters does not handle white space
gracefully. In addition checked every place that uses String.split() and
standardized the usage through a new utility class.
Modified Paths:
--------------
trunk/stripes/src/net/sourceforge/stripes/config/RuntimeConfiguration.java
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
trunk/stripes/src/net/sourceforge/stripes/exception/DelegatingExceptionHandler.java
trunk/stripes/src/net/sourceforge/stripes/localization/DefaultLocalePicker.java
trunk/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java
Added Paths:
-----------
trunk/stripes/src/net/sourceforge/stripes/util/StringUtil.java
Modified:
trunk/stripes/src/net/sourceforge/stripes/config/RuntimeConfiguration.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/config/RuntimeConfiguration.java
2006-10-28 17:19:40 UTC (rev 460)
+++ trunk/stripes/src/net/sourceforge/stripes/config/RuntimeConfiguration.java
2006-10-29 13:08:11 UTC (rev 461)
@@ -30,6 +30,7 @@
import net.sourceforge.stripes.tag.TagErrorRendererFactory;
import net.sourceforge.stripes.util.Log;
import net.sourceforge.stripes.util.ReflectUtil;
+import net.sourceforge.stripes.util.StringUtil;
import net.sourceforge.stripes.validation.TypeConverterFactory;
import java.util.Collection;
@@ -163,7 +164,7 @@
return null;
}
else {
- String[] classNames = classList.split(",");
+ String[] classNames = StringUtil.standardSplit(classList);
Map<LifecycleStage, Collection<Interceptor>> map =
new HashMap<LifecycleStage, Collection<Interceptor>>();
Modified:
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
===================================================================
---
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
2006-10-28 17:19:40 UTC (rev 460)
+++
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
2006-10-29 13:08:11 UTC (rev 461)
@@ -26,6 +26,7 @@
import net.sourceforge.stripes.exception.StripesServletException;
import net.sourceforge.stripes.util.Log;
import net.sourceforge.stripes.util.ResolverUtil;
+import net.sourceforge.stripes.util.StringUtil;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
@@ -537,7 +538,7 @@
);
}
- String[] pkgs = packages.trim().split("\\s*,\\s*");
+ String[] pkgs = StringUtil.standardSplit(packages);
ResolverUtil<ActionBean> resolver = new ResolverUtil<ActionBean>();
resolver.findImplementations(ActionBean.class, pkgs);
return resolver.getClasses();
Modified:
trunk/stripes/src/net/sourceforge/stripes/exception/DelegatingExceptionHandler.java
===================================================================
---
trunk/stripes/src/net/sourceforge/stripes/exception/DelegatingExceptionHandler.java
2006-10-28 17:19:40 UTC (rev 460)
+++
trunk/stripes/src/net/sourceforge/stripes/exception/DelegatingExceptionHandler.java
2006-10-29 13:08:11 UTC (rev 461)
@@ -19,6 +19,7 @@
import net.sourceforge.stripes.config.Configuration;
import net.sourceforge.stripes.util.Log;
import net.sourceforge.stripes.util.ResolverUtil;
+import net.sourceforge.stripes.util.StringUtil;
import net.sourceforge.stripes.controller.AnnotatedClassActionResolver;
import javax.servlet.ServletException;
@@ -265,7 +266,7 @@
);
}
- String[] pkgs = packages.trim().split("\\s*,\\s*");
+ String[] pkgs = StringUtil.standardSplit(packages);
ResolverUtil<AutoExceptionHandler> resolver = new
ResolverUtil<AutoExceptionHandler>();
resolver.findImplementations(AutoExceptionHandler.class, pkgs);
return resolver.getClasses();
Modified:
trunk/stripes/src/net/sourceforge/stripes/localization/DefaultLocalePicker.java
===================================================================
---
trunk/stripes/src/net/sourceforge/stripes/localization/DefaultLocalePicker.java
2006-10-28 17:19:40 UTC (rev 460)
+++
trunk/stripes/src/net/sourceforge/stripes/localization/DefaultLocalePicker.java
2006-10-29 13:08:11 UTC (rev 461)
@@ -16,6 +16,7 @@
import net.sourceforge.stripes.config.Configuration;
import net.sourceforge.stripes.util.Log;
+import net.sourceforge.stripes.util.StringUtil;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
@@ -79,7 +80,7 @@
}
else {
// Split apart the Locales on commas, and then parse the local
strings into their bits
- String[] localeStrings = configuredLocales.split(",");
+ String[] localeStrings =
StringUtil.standardSplit(configuredLocales);
for (String localeString : localeStrings) {
// Each locale string can be made up of two parts,
locale:encoding
// and the locale can be made up of up to three segment, e.g.
en_US_PC
Modified:
trunk/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java
===================================================================
---
trunk/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java
2006-10-28 17:19:40 UTC (rev 460)
+++
trunk/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java
2006-10-29 13:08:11 UTC (rev 461)
@@ -19,6 +19,7 @@
import net.sourceforge.stripes.util.bean.BeanUtil;
import net.sourceforge.stripes.util.bean.ExpressionException;
import net.sourceforge.stripes.util.bean.BeanComparator;
+import net.sourceforge.stripes.util.StringUtil;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.Tag;
@@ -223,7 +224,7 @@
// Determine if we're going to be sorting the collection
List<Entry> sortedEntries = new LinkedList<Entry>(this.entries);
if (this.sort != null) {
- String[] props = this.sort.split(" *, *");
+ String[] props = StringUtil.standardSplit(this.sort);
for (int i=0;i<props.length;++i) {
if (!props[i].equals("label") && !props[i].equals("value")) {
props[i] = "bean." + props[i];
Added: trunk/stripes/src/net/sourceforge/stripes/util/StringUtil.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/util/StringUtil.java
(rev 0)
+++ trunk/stripes/src/net/sourceforge/stripes/util/StringUtil.java
2006-10-29 13:08:11 UTC (rev 461)
@@ -0,0 +1,34 @@
+package net.sourceforge.stripes.util;
+
+import java.util.regex.Pattern;
+
+/**
+ * Provies utility methods for manipulating and parsing Strings.
+ *
+ * @author Tim Fennell
+ * @since Stripes 1.4.2
+ */
+public class StringUtil {
+ /**
+ * A regular expression for splitting apart a String where individual
parts are
+ * separated by any whitespace (including new lines) and/or a comma.
+ */
+ private static final Pattern STANDARD_SPLIT = Pattern.compile("[\\s,]+");
+
+ /**
+ * Splits apart the input String on any whitespace and/or commas. Leading
and trailing
+ * whitespace are ignored. If a null String is provided as input a zero
length array
+ * will be returned.
+ *
+ * @param input the String to split apart
+ * @return an array of substrings of the input String based on the split
+ */
+ public static String[] standardSplit(String input) {
+ if (input == null) {
+ return new String[0];
+ }
+ else {
+ return STANDARD_SPLIT.split(input.trim());
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development