1 17 package com.sun.syndication.feed.synd.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.Image; 23 import com.sun.syndication.feed.rss.Item; 24 import com.sun.syndication.feed.synd.SyndFeed; 25 import com.sun.syndication.feed.synd.SyndContent; 26 import com.sun.syndication.feed.synd.SyndEntry; 27 import com.sun.syndication.feed.synd.SyndImage; 28 import com.sun.syndication.feed.synd.SyndContentImpl; 29 30 import java.util.ArrayList ; 31 import java.util.List ; 32 import java.util.Date ; 33 34 36 public class ConverterForRSS091Userland extends ConverterForRSS090 { 37 38 public ConverterForRSS091Userland() { 39 this("rss_0.91U"); 40 } 41 42 protected ConverterForRSS091Userland(String type) { 43 super(type); 44 } 45 46 public void copyInto(WireFeed feed,SyndFeed syndFeed) { 47 Channel channel = (Channel) feed; 48 super.copyInto(channel,syndFeed); 49 syndFeed.setLanguage(channel.getLanguage()); syndFeed.setCopyright(channel.getCopyright()); Date pubDate = channel.getPubDate(); 52 if (pubDate!=null) { 53 syndFeed.setPublishedDate(pubDate); } 55 syndFeed.setAuthor(channel.getManagingEditor()); } 57 58 protected SyndImage createSyndImage(Image rssImage) { 59 SyndImage syndImage = super.createSyndImage(rssImage); 60 syndImage.setDescription(rssImage.getDescription()); 61 return syndImage; 62 } 63 64 protected SyndEntry createSyndEntry(Item item) { 65 SyndEntry syndEntry = super.createSyndEntry(item); 66 Description desc = item.getDescription(); 67 if (desc!=null) { 68 SyndContent content = new SyndContentImpl(); 69 content.setType(desc.getType()); 70 content.setValue(desc.getValue()); 71 syndEntry.setDescription(content); 72 73 List contents = new ArrayList (); 76 contents.add(content); 77 syndEntry.setContents(contents); 78 79 } 80 return syndEntry; 81 } 82 83 protected WireFeed createRealFeed(String type,SyndFeed syndFeed) { 84 Channel channel = (Channel) super.createRealFeed(type,syndFeed); 85 channel.setLanguage(syndFeed.getLanguage()); channel.setCopyright(syndFeed.getCopyright()); channel.setPubDate(syndFeed.getPublishedDate()); channel.setManagingEditor(syndFeed.getAuthor()); return channel; 90 } 91 92 protected Image createRSSImage(SyndImage sImage) { 93 Image image = super.createRSSImage(sImage); 94 image.setDescription(sImage.getDescription()); 95 return image; 96 } 97 98 protected Item createRSSItem(SyndEntry sEntry) { 99 Item item = super.createRSSItem(sEntry); 100 101 SyndContent sContent = sEntry.getDescription(); 102 if (sContent!=null) { 103 item.setDescription(createItemDescription(sContent)); 104 } 105 return item; 106 } 107 108 protected Description createItemDescription(SyndContent sContent) { 109 Description desc = new Description(); 110 desc.setValue(sContent.getValue()); 111 desc.setType(sContent.getType()); 112 return desc; 113 } 114 115 116 } 117 | Popular Tags |