[jboss-svn-commits] JBL Code SVN: r6831 - labs/jbosslabs/trunk/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Oct 16 16:28:55 EDT 2006


Author: wrzep
Date: 2006-10-16 16:28:54 -0400 (Mon, 16 Oct 2006)
New Revision: 6831

Modified:
   labs/jbosslabs/trunk/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java
Log:
JBLAB-782
Nothing more than slight refactoring.

Pawel


Modified: labs/jbosslabs/trunk/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java	2006-10-16 19:45:12 UTC (rev 6830)
+++ labs/jbosslabs/trunk/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java	2006-10-16 20:28:54 UTC (rev 6831)
@@ -122,9 +122,12 @@
 		}
 		
 		// Parse and sort the items
-		allItemsArr = getAllItems(nodes).toArray();
+		Map<String,String> urls = getURLs(nodes);
+		
+		allItemsArr = getAllItems(urls).toArray();
 		java.util.Arrays.sort((Object[]) allItemsArr, new ItemComparator(true));	
 	}
+	
 	/**
 	 * Fills the given context with item information
 	 * 
@@ -380,33 +383,50 @@
 		return ret;
 	}
 	
+	private Map<String,String> getURLs(HashSet<Map<String, Node>> nodes) {
+	
+		Map<String,String> map = new HashMap<String,String>();
+		
+		Node urlNode = null;
+		String urlString = null;
+		Node idNode = null;
+		String id = null;
+		
+		for (Map<String, Node> nodeMap : nodes) {
+			
+			urlNode = (Node) nodeMap.get(URL_ELEMENT);
+			
+			urlString = XmlTools.unmarshallText(urlNode);
+			if (urlString.charAt(0) == '/') { // local link
+				urlString = serverAdress + urlString;
+			}
+			
+			idNode = nodeMap.get(ID_ELEMENT);
+			id = XmlTools.unmarshallText(idNode);
+			
+			map.put(id,urlString);
+		}
+		
+		return map;
+	}
+	
 	/**
 	 * For the given Set of feeds descripions, computes Set of all items from these feeds.
 	 * 
-	 * @param nodes Set of Maps describing the feeds. 
-	 * For each feed, it's Map binds "id" and "url" with appropiate Nodes.
+	 * @param URLs Map describing the feeds. 
+	 * For each feed, map binds it's "id" with feed "url".
 	 *   
 	 * @return Set of all items from feeds described in the given Set.
 	 */
 	@SuppressWarnings("unchecked")
-	private Set<ItemIF> getAllItems(Set<Map<String,Node>> nodes) {
+	private Set<ItemIF> getAllItems(Map<String,String> URLs) {
 		
 		HashSet<ItemIF> ret = new HashSet<ItemIF>();
 		
-		Node urlNode = null;
-		String urlString = null;
-		
-		for (Iterator<Map<String,Node>> iter = nodes.iterator(); iter.hasNext();) {
+		for (String urlString : URLs.values()) {
+			
 			try {
-				Map<String,Node> nodeProperties = (Map<String,Node>) iter.next();
 				
-				urlNode = (Node) nodeProperties.get(URL_ELEMENT);
-				
-				urlString = XmlTools.unmarshallText(urlNode);
-				if (urlString.charAt(0) == '/') { // local link
-					urlString = serverAdress + urlString;
-				}
-				
 				URL url = new URL(urlString);
 							
 				ChannelIF channel = FeedParser.parse(new ChannelBuilder(), url.openStream());




More information about the jboss-svn-commits mailing list