1 17 package com.sun.syndication.io.impl; 18 19 import com.sun.syndication.feed.WireFeed; 20 import com.sun.syndication.feed.rss.Channel; 21 import com.sun.syndication.feed.rss.Description; 22 import com.sun.syndication.feed.rss.Guid; 23 import com.sun.syndication.feed.rss.Item; 24 import org.jdom.Element; 25 26 import java.util.List ; 27 28 30 public class RSS094Parser extends RSS093Parser { 31 32 public RSS094Parser() { 33 this("rss_0.94"); 34 } 35 36 protected RSS094Parser(String type) { 37 super(type); 38 } 39 40 protected String getRSSVersion() { 41 return "0.94"; 42 } 43 44 protected WireFeed parseChannel(Element rssRoot) { 45 Channel channel = (Channel) super.parseChannel(rssRoot); 46 List eCats = rssRoot.getChild("channel",getRSSNamespace()).getChildren("category",getRSSNamespace()); 47 channel.setCategories(parseCategories(eCats)); 48 return channel; 49 } 50 51 protected Item parseItem(Element rssRoot,Element eItem) { 52 Item item = super.parseItem(rssRoot,eItem); 53 item.setExpirationDate(null); 54 55 Element e = eItem.getChild("author",getRSSNamespace()); 56 if (e!=null) { 57 item.setAuthor(e.getText()); 58 } 59 60 e = eItem.getChild("guid",getRSSNamespace()); 61 if (e!=null) { 62 Guid guid = new Guid(); 63 String att = e.getAttributeValue("isPermaLink"); if (att!=null) { 65 guid.setPermaLink(att.equalsIgnoreCase("true")); 66 } 67 guid.setValue(e.getText()); 68 item.setGuid(guid); 69 } 70 71 e = eItem.getChild("comments",getRSSNamespace()); 72 if (e!=null) { 73 item.setComments(e.getText()); 74 } 75 76 return item; 77 } 78 79 protected Description parseItemDescription(Element rssRoot,Element eDesc) { 80 Description desc = super.parseItemDescription(rssRoot,eDesc); 81 String att = eDesc.getAttributeValue("type"); if (att==null) { 83 att = "text/html"; 84 } 85 desc.setType(att); 86 return desc; 87 } 88 89 } 90 | Popular Tags |