roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1577774 - in /roller/trunk/app/src/main/java/org/apache/roller: planet/business/ weblogger/business/runnable/ weblogger/pojos/ weblogger/ui/rendering/pagers/ weblogger/ui/rendering/util/cache/ weblogger/ui/struts2/admin/ weblogger/util/
Date Sat, 15 Mar 2014 02:52:48 GMT
Author: gmazza
Date: Sat Mar 15 02:52:48 2014
New Revision: 1577774

URL: http://svn.apache.org/r1577774
Log:
ROL-1907 Switch from keySet to entrySet in 10 places Sonar has found.

Modified:
    roller/trunk/app/src/main/java/org/apache/roller/planet/business/MultiPlanetURLStrategy.java
    roller/trunk/app/src/main/java/org/apache/roller/planet/business/PlanetURLStrategy.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/runnable/HitCountProcessingJob.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogEntry.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesDayPager.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesLatestPager.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesMonthPager.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogPageCache.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/URLUtilities.java

Modified: roller/trunk/app/src/main/java/org/apache/roller/planet/business/MultiPlanetURLStrategy.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/planet/business/MultiPlanetURLStrategy.java?rev=1577774&r1=1577773&r2=1577774&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/planet/business/MultiPlanetURLStrategy.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/planet/business/MultiPlanetURLStrategy.java
Sat Mar 15 02:52:48 2014
@@ -107,28 +107,27 @@ public class MultiPlanetURLStrategy impl
     /**
      * Compose a map of key=value params into a query string.
      */
-    public String getQueryString(Map params) {
+    public String getQueryString(Map<String, String> params) {
         
         if(params == null) {
             return null;
         }
         
         StringBuilder queryString = new StringBuilder();
-        
-        for(Object key : params.keySet()) {
-            String value = (String) params.get(key);
-            
+
+        for (Map.Entry<String, String> entry : params.entrySet()) {
+
             if (queryString.length() == 0) {
                 queryString.append("?");
             } else {
                 queryString.append("&");
             }
-            
-            queryString.append(key);
+
+            queryString.append(entry.getKey());
             queryString.append("=");
-            queryString.append(value);
+            queryString.append(entry.getValue());
         }
-        
+
         return queryString.toString();
     }
     

Modified: roller/trunk/app/src/main/java/org/apache/roller/planet/business/PlanetURLStrategy.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/planet/business/PlanetURLStrategy.java?rev=1577774&r1=1577773&r2=1577774&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/planet/business/PlanetURLStrategy.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/planet/business/PlanetURLStrategy.java
Sat Mar 15 02:52:48 2014
@@ -73,7 +73,7 @@ public interface PlanetURLStrategy {
     /**
      * Compose a map of key=value params into a query string.
      */
-    String getQueryString(Map params);
+    String getQueryString(Map<String, String> params);
     
     
     /**

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/runnable/HitCountProcessingJob.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/runnable/HitCountProcessingJob.java?rev=1577774&r1=1577773&r2=1577774&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/runnable/HitCountProcessingJob.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/runnable/HitCountProcessingJob.java
Sat Mar 15 02:52:48 2014
@@ -79,10 +79,10 @@ public class HitCountProcessingJob imple
             long startTime = System.currentTimeMillis();
             
             Weblog weblog;
-            for (String key : hitsTally.keySet()) {
+            for (Map.Entry<String, Long> entry : hitsTally.entrySet()) {
                 try {
-                    weblog = wmgr.getWeblogByHandle(key);
-                    emgr.incrementHitCount(weblog, (hitsTally.get(key)).intValue());
+                    weblog = wmgr.getWeblogByHandle(entry.getKey());
+                    emgr.incrementHitCount(weblog, entry.getValue().intValue());
                 } catch (WebloggerException ex) {
                     log.error(ex);
                 }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogEntry.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogEntry.java?rev=1577774&r1=1577773&r2=1577774&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogEntry.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogEntry.java Sat
Mar 15 02:52:48 2014
@@ -987,9 +987,9 @@ public class WeblogEntry implements Seri
                 // now loop over mPagePlugins, matching
                 // against Entry plugins (by name):
                 // where a match is found render Plugin.
-                for (String key : inPlugins.keySet()) {
-                    if (entryPlugins.contains(key)) {
-                        WeblogEntryPlugin pagePlugin = inPlugins.get(key);
+                for (Map.Entry<String, WeblogEntryPlugin> entry : inPlugins.entrySet())
{
+                    if (entryPlugins.contains(entry.getKey())) {
+                        WeblogEntryPlugin pagePlugin = entry.getValue();
                         try {
                             ret = pagePlugin.render(this, ret);
                         } catch (Exception e) {

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesDayPager.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesDayPager.java?rev=1577774&r1=1577773&r2=1577774&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesDayPager.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesDayPager.java
Sat Mar 15 02:52:48 2014
@@ -125,10 +125,10 @@ public class WeblogEntriesDayPager exten
                 
                 // need to wrap pojos
                 int count = 0;
-                for (Date key : mmap.keySet()) {
+                for (Map.Entry<Date, List<WeblogEntry>> entry : mmap.entrySet())
{
                     // now we need to go through each entry in a day and wrap
                     List<WeblogEntryWrapper> wrapped = new ArrayList<WeblogEntryWrapper>();
-                    List<WeblogEntry> unwrapped = mmap.get(key);
+                    List<WeblogEntry> unwrapped = entry.getValue();
                     for(int i=0; i < unwrapped.size(); i++) {
                         if (count++ < length) {
                             wrapped.add(i,WeblogEntryWrapper.wrap(unwrapped.get(i), urlStrategy));
@@ -139,7 +139,7 @@ public class WeblogEntriesDayPager exten
                     
                     // done with that day, put it in the map
                     if (wrapped.size() > 0) {
-                        entries.put(key, wrapped);
+                        entries.put(entry.getKey(), wrapped);
                     }
                 }
                 

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesLatestPager.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesLatestPager.java?rev=1577774&r1=1577773&r2=1577774&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesLatestPager.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesLatestPager.java
Sat Mar 15 02:52:48 2014
@@ -83,10 +83,10 @@ public class WeblogEntriesLatestPager ex
                 
                 // need to wrap pojos
                 int count = 0;
-                for (Date key : mmap.keySet()) {
+                for (Map.Entry<Date, List<WeblogEntry>> entry : mmap.entrySet())
{
                     // now we need to go through each entry in a day and wrap
                     List<WeblogEntryWrapper> wrapped = new ArrayList<WeblogEntryWrapper>();
-                    List<WeblogEntry> unwrapped= mmap.get(key);
+                    List<WeblogEntry> unwrapped = entry.getValue();
                     for(int i=0; i < unwrapped.size(); i++) {
                         if (count++ < length) {
                             wrapped.add(i,WeblogEntryWrapper.wrap(unwrapped.get(i), urlStrategy));
@@ -97,7 +97,7 @@ public class WeblogEntriesLatestPager ex
                     
                     // done with that day, put it in the map
                     if(wrapped.size() > 0) {
-                        entries.put(key, wrapped);
+                        entries.put(entry.getKey(), wrapped);
                     }
                 }
             } catch (Exception e) {

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesMonthPager.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesMonthPager.java?rev=1577774&r1=1577773&r2=1577774&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesMonthPager.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/pagers/WeblogEntriesMonthPager.java
Sat Mar 15 02:52:48 2014
@@ -121,11 +121,11 @@ public class WeblogEntriesMonthPager ext
                               
                 // need to wrap pojos
                 int count = 0;
-                for (Date key : mmap.keySet()) {
+                for (Map.Entry<Date, List<WeblogEntry>> entry : mmap.entrySet())
{
                     // now we need to go through each entry in a day and wrap
                     List<WeblogEntryWrapper> wrapped = new ArrayList<WeblogEntryWrapper>();
-                    List<WeblogEntry> unwrapped = mmap.get(key);
-                    for(int i=0; i < unwrapped.size(); i++) {
+                    List<WeblogEntry> unwrapped = entry.getValue();
+                    for (int i=0; i < unwrapped.size(); i++) {
                         if (count++ < length) {
                             wrapped.add(i,WeblogEntryWrapper.wrap(unwrapped.get(i), urlStrategy));
                         } else {
@@ -134,8 +134,8 @@ public class WeblogEntriesMonthPager ext
                     }
                     
                     // done with that day, put it in the map
-                    if(wrapped.size() > 0) {
-                        entries.put(key, wrapped);
+                    if (wrapped.size() > 0) {
+                        entries.put(entry.getKey(), wrapped);
                     }
                 }
             } catch (Exception e) {

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java?rev=1577774&r1=1577773&r2=1577774&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java
Sat Mar 15 02:52:48 2014
@@ -422,18 +422,15 @@ public class SiteWideCache implements Ca
     
     private String paramsToString(Map<String, String[]> map) {
         
-        if(map == null) {
+        if (map == null) {
             return null;
         }
         
         StringBuilder string = new StringBuilder();
         
-        String[] value;
-        for (String key : map.keySet()) {
-            value = map.get(key);
-            
-            if(value != null) {
-                string.append(",").append(key).append("=").append(value[0]);
+        for (Map.Entry<String, String[]> entry : map.entrySet()) {
+            if(entry.getValue() != null) {
+                string.append(",").append(entry.getKey()).append("=").append(entry.getValue()[0]);
             }
         }
         

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogPageCache.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogPageCache.java?rev=1577774&r1=1577773&r2=1577774&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogPageCache.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogPageCache.java
Sat Mar 15 02:52:48 2014
@@ -243,18 +243,15 @@ public final class WeblogPageCache {
     
     private String paramsToString(Map<String, String[]> map) {
 
-        if(map == null) {
+        if (map == null) {
             return null;
         }
 
         StringBuilder string = new StringBuilder();
 
-        String[] value;
-        for (String key : map.keySet()) {
-            value = map.get(key);
-
-            if(value != null) {
-                string.append(",").append(key).append("=").append(value[0]);
+        for (Map.Entry<String, String[]> entry : map.entrySet()) {
+            if(entry.getKey() != null) {
+                string.append(",").append(entry.getKey()).append("=").append(entry.getValue()[0]);
             }
         }
 

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java?rev=1577774&r1=1577773&r2=1577774&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java
Sat Mar 15 02:52:48 2014
@@ -214,14 +214,14 @@ public class GlobalConfig extends UIActi
     }
     
     
-    public void setParameters(Map parameters) {
+    public void setParameters(Map<String, String[]> parameters) {
         this.params = parameters;
         
         if (log.isDebugEnabled()) {
             log.debug("Parameter map:");
-            Set<String> keys = parameters.keySet();
-            for(String key : keys) {
-                log.debug(key+" = "+parameters.get(key));
+
+            for(Map.Entry<String, String[]> entry : parameters.entrySet()) {
+                log.debug(entry.getKey() + " = " + entry.getValue());
             }
         }
     }
@@ -229,7 +229,7 @@ public class GlobalConfig extends UIActi
     // convenience method for getting a single parameter as a String
     private String getParameter(String key) {
         
-        String[] p = (String[]) this.params.get(key);
+        String[] p = this.params.get(key);
         if(p != null && p.length > 0) {
             return p[0];
         }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/URLUtilities.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/URLUtilities.java?rev=1577774&r1=1577773&r2=1577774&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/URLUtilities.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/URLUtilities.java Sat
Mar 15 02:52:48 2014
@@ -45,8 +45,7 @@ public final class URLUtilities {
         }
         
         StringBuilder queryString = new StringBuilder();
-        for (String key : params.keySet()) {
-            String value = params.get(key);
+        for (Map.Entry<String, String> entry : params.entrySet()) {
 
             if (queryString.length() == 0) {
                 queryString.append("?");
@@ -54,9 +53,9 @@ public final class URLUtilities {
                 queryString.append("&");
             }
 
-            queryString.append(key);
+            queryString.append(entry.getKey());
             queryString.append("=");
-            queryString.append(value);
+            queryString.append(entry.getValue());
         }
 
         return queryString.toString();



Mime
View raw message