Author: jhm Date: Thu Sep 20 07:33:40 2007 New Revision: 577772 URL: http://svn.apache.org/viewvc?rev=577772&view=rev Log: Factor removeSuffix() out.
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspNameMangler.java ant/core/trunk/src/main/org/apache/tools/ant/util/StringUtils.java Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspNameMangler.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspNameMangler.java?rev=577772&r1=577771&r2=577772&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspNameMangler.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspNameMangler.java Thu Sep 20 07:33:40 2007 @@ -18,6 +18,8 @@ package org.apache.tools.ant.taskdefs.optional.jsp; import java.io.File; +import org.apache.tools.ant.util.StringUtils; + /** * This is a class derived from the Jasper code * (org.apache.jasper.compiler.CommandLineCompiler) to map from a JSP filename @@ -109,14 +111,7 @@ * @return file without any jsp extension */ private String stripExtension(File jspFile) { - String className; - String filename = jspFile.getName(); - if (filename.endsWith(".jsp")) { - className = filename.substring(0, filename.length() - ".jsp".length()); - } else { - className = filename; - } - return className; + return StringUtils.removeSuffix(jspFile.getName(), ".jsp"); } Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/StringUtils.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/StringUtils.java?rev=577772&r1=577771&r2=577772&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/util/StringUtils.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/util/StringUtils.java Thu Sep 20 07:33:40 2007 @@ -241,4 +241,19 @@ } return factor * Long.parseLong(humanSize); } + + /** + * Removes the suffix from a given string, if the string contains + * that suffix. + * @param string String for check + * @param suffix Suffix to remove + * @return the <i>string</i> with the <i>suffix</i> + */ + public static String removeSuffix(String string, String suffix) { + if (string.endsWith(suffix)) { + return string.substring(0, string.length() - suffix.length()); + } else { + return string; + } + } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]