maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r1588926 - /maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
Date Mon, 21 Apr 2014 16:55:48 GMT
Author: hboutemy
Date: Mon Apr 21 16:55:47 2014
New Revision: 1588926

URL: http://svn.apache.org/r1588926
Log:
add endsWithIgnoreCase() method to improve readability

Modified:
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java

Modified: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java?rev=1588926&r1=1588925&r2=1588926&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
(original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
Mon Apr 21 16:55:47 2014
@@ -53,6 +53,8 @@ import java.util.zip.ZipEntry;
 import java.util.zip.ZipException;
 import java.util.zip.ZipFile;
 
+import javax.annotation.Nullable;
+
 import org.apache.maven.doxia.Doxia;
 import org.apache.maven.doxia.logging.PlexusLoggerWrapper;
 import org.apache.maven.doxia.parser.ParseException;
@@ -201,8 +203,7 @@ public class DefaultSiteRenderer
             {
                 String name = it.next();
 
-                if ( ( name.length() < fullExtension.length() )
-                    || !name.substring( name.length() - fullExtension.length() ).equalsIgnoreCase(
fullExtension ) )
+                if ( endsWithIgnoreCase( name, fullExtension ) )
                 {
                     it.remove();
                 }
@@ -215,8 +216,7 @@ public class DefaultSiteRenderer
             {
                 String name = it.next();
 
-                if ( ( name.length() < fullExtension.length() )
-                    || !name.substring( name.length() - fullExtension.length() ).equalsIgnoreCase(
fullExtension ) )
+                if ( endsWithIgnoreCase( name, fullExtension ) )
                 {
                     it.remove();
                 }
@@ -922,4 +922,14 @@ public class DefaultSiteRenderer
         }
     }
 
+    // TODO replace with StringUtils.endsWithIgnoreCase() from maven-shared-utils 0.7
+    private boolean endsWithIgnoreCase( String str, String searchStr )
+    {
+        if ( str.length() < searchStr.length() )
+        {
+            return false;
+        }
+
+        return str.regionMatches( true, str.length() - searchStr.length(), searchStr, 0,
searchStr.length() );
+    }
 }



Mime
View raw message