1   package net.sf.flock.support;
2   
3   import java.util.Collection;
4   import java.util.Iterator;
5   
6   import net.sf.flock.FeedInfoI;
7   import net.sf.flock.SubscriptionInfoI;
8   import org.jdom.Document;
9   import org.jdom.Element;
10  
11  /***
12   * Exports subscriptions to an AmphetaDesk-style OPML document.
13   *
14   * @version	$Revision: 1.10 $
15   * @author	$Author: phraktle $
16   */
17  public class OpmlSubscriptionExport {
18  
19  	public Document export(Collection subscriptions) {
20  
21          Element root = new Element("opml");
22          root.setAttribute("version", "1.0");
23  
24  		Element head = new Element("head");
25  		head.addContent( new Element("title").addContent("Flock subscriptions") );
26  		root.addContent( head );
27  
28  		Element body = new Element("body");
29  
30  		for (Iterator i=subscriptions.iterator(); i.hasNext(); ) {
31  			SubscriptionInfoI sub = (SubscriptionInfoI)i.next();
32  			FeedInfoI feed = sub.getFeedInfo();
33  			Element outline = new Element("outline");
34  			outline.setAttribute("description", feed.getTitle());
35  
36  			outline.setAttribute("type", "link");
37  			outline.setAttribute("xmlUrl", sub.getLocation().toExternalForm());
38  			if (feed.getSite()!=null) {
39  				outline.setAttribute("htmlUrl", feed.getSite().toExternalForm());
40  			}
41  
42  			outline.setAttribute("path", sub.getMetaData().get("path") );
43  			
44  			body.addContent( outline );			
45  		}
46  
47  		root.addContent( body );
48  
49          Document doc = new Document(root);
50          return doc;
51  	}
52  
53  }
This page was automatically generated by Maven