roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1546770 - in /roller/trunk/app/src/main/java/org/apache/roller/planet: business/MultiPlanetURLStrategy.java business/fetcher/RomeFeedFetcher.java business/jpa/JPAPlanetManagerImpl.java pojos/Subscription.java pojos/SubscriptionEntry.java
Date Sat, 30 Nov 2013 22:57:58 GMT
Author: gmazza
Date: Sat Nov 30 22:57:58 2013
New Revision: 1546770

URL: http://svn.apache.org/r1546770
Log:
Replaced some iterators with for-each loops.

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/fetcher/RomeFeedFetcher.java
    roller/trunk/app/src/main/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java
    roller/trunk/app/src/main/java/org/apache/roller/planet/pojos/Subscription.java
    roller/trunk/app/src/main/java/org/apache/roller/planet/pojos/SubscriptionEntry.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=1546770&r1=1546769&r2=1546770&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 Nov 30 22:57:58 2013
@@ -21,7 +21,6 @@ package org.apache.roller.planet.busines
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.net.URLEncoder;
-import java.util.Iterator;
 import java.util.Map;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
@@ -41,10 +40,7 @@ public class MultiPlanetURLStrategy impl
             return null;
         }
         
-        StringBuffer url = new StringBuffer();
-        
-        PlanetManager mgr = WebloggerFactory.getWeblogger().getPlanetManager();
-        
+        StringBuilder url = new StringBuilder();
         url.append(WebloggerRuntimeConfig.getProperty("site.absoluteurl"));
         url.append("/").append(planet).append("/");
         
@@ -61,7 +57,7 @@ public class MultiPlanetURLStrategy impl
             return null;
         }
         
-        StringBuffer url = new StringBuffer();
+        StringBuilder url = new StringBuilder();
         
         url.append(getPlanetURL(planet));
         url.append("group/").append(group).append("/");
@@ -84,8 +80,7 @@ public class MultiPlanetURLStrategy impl
             return null;
         }
         
-        StringBuffer url = new StringBuffer();
-        
+        StringBuilder url = new StringBuilder();
         url.append(getPlanetGroupURL(planet, group, -1));
         url.append("feed/").append(format);
         
@@ -102,8 +97,7 @@ public class MultiPlanetURLStrategy impl
             return null;
         }
         
-        StringBuffer url = new StringBuffer();
-        
+        StringBuilder url = new StringBuilder();
         url.append(getPlanetGroupURL(planet, group, -1));
         url.append("opml");
         
@@ -120,10 +114,9 @@ public class MultiPlanetURLStrategy impl
             return null;
         }
         
-        StringBuffer queryString = new StringBuffer();
+        StringBuilder queryString = new StringBuilder();
         
-        for(Iterator keys = params.keySet().iterator(); keys.hasNext();) {
-            String key = (String) keys.next();
+        for(Object key : params.keySet()) {
             String value = (String) params.get(key);
             
             if (queryString.length() == 0) {

Modified: roller/trunk/app/src/main/java/org/apache/roller/planet/business/fetcher/RomeFeedFetcher.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/planet/business/fetcher/RomeFeedFetcher.java?rev=1546770&r1=1546769&r2=1546770&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/planet/business/fetcher/RomeFeedFetcher.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/planet/business/fetcher/RomeFeedFetcher.java
Sat Nov 30 22:57:58 2013
@@ -36,7 +36,6 @@ import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.List;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.logging.Log;
@@ -227,10 +226,8 @@ public class RomeFeedFetcher implements 
         // copy categories
         if (romeEntry.getCategories().size() > 0) {
             List list = new ArrayList();
-            Iterator cats = romeEntry.getCategories().iterator();
-            while (cats.hasNext()) {
-                SyndCategory cat = (SyndCategory)cats.next();
-                list.add(cat.getName());
+            for (Object cat : romeEntry.getCategories()) {
+                list.add(((SyndCategory) cat).getName());
             }
             newEntry.setCategoriesString(list);
         }

Modified: roller/trunk/app/src/main/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java?rev=1546770&r1=1546769&r2=1546770&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java
Sat Nov 30 22:57:58 2013
@@ -205,16 +205,14 @@ public class JPAPlanetManagerImpl extend
     }
     
     public List getGroupHandles(Planet planet) throws RollerException {
-        List handles = new ArrayList();
-        Iterator list = getGroups(planet).iterator();
-        while (list.hasNext()) {
-            PlanetGroup group = (PlanetGroup) list.next();
+        List<String> handles = new ArrayList<String>();
+        for (PlanetGroup group : getGroups(planet)) {
             handles.add(group.getHandle());
         }
         return handles;
     }
     
-    public List getGroups(Planet planet) throws RollerException {
+    public List<PlanetGroup> getGroups(Planet planet) throws RollerException {
         Query q = strategy.getNamedQuery("PlanetGroup.getByPlanet");
         q.setParameter(1, planet.getHandle());
         return q.getResultList();
@@ -237,12 +235,10 @@ public class JPAPlanetManagerImpl extend
     
     public void deleteEntries(Subscription sub) 
         throws RollerException {
-        Iterator entries = sub.getEntries().iterator();
-        while(entries.hasNext()) {
-            strategy.remove(entries.next());
+        for (Object entry : sub.getEntries()) {
+            strategy.remove(entry);
         }
-        
-        // make sure and clear the other side of the assocation
+        // make sure and clear the other side of the association
         sub.getEntries().clear();
     }
     

Modified: roller/trunk/app/src/main/java/org/apache/roller/planet/pojos/Subscription.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/planet/pojos/Subscription.java?rev=1546770&r1=1546769&r2=1546770&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/planet/pojos/Subscription.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/planet/pojos/Subscription.java Sat Nov
30 22:57:58 2013
@@ -20,7 +20,6 @@ import java.io.Serializable;
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 import org.apache.roller.util.UUIDGenerator;
 
@@ -197,10 +196,9 @@ public class Subscription implements Ser
     /**
      * Add a collection of SubscriptionEntry to this Subscription.
      */
-    public void addEntries(Collection newEntries) {
+    public void addEntries(Collection<SubscriptionEntry> newEntries) {
         // bi-directional one-to-many
-        for (Iterator it = newEntries.iterator(); it.hasNext();) {
-            SubscriptionEntry entry = (SubscriptionEntry) it.next();
+        for (SubscriptionEntry entry : newEntries) {
             entry.setSubscription(this);
         }
         this.getEntries().addAll(newEntries);

Modified: roller/trunk/app/src/main/java/org/apache/roller/planet/pojos/SubscriptionEntry.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/planet/pojos/SubscriptionEntry.java?rev=1546770&r1=1546769&r2=1546770&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/planet/pojos/SubscriptionEntry.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/planet/pojos/SubscriptionEntry.java Sat
Nov 30 22:57:58 2013
@@ -195,7 +195,7 @@ public class SubscriptionEntry implement
         Iterator cats = getCategories().iterator();
         while (cats.hasNext()) {
             String catName = ((String)cats.next()).toLowerCase();
-            if (catName.indexOf(category.toLowerCase()) != -1) {
+            if (catName.contains(category.toLowerCase())) {
                 return true;
             }
         }



Mime
View raw message