1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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.Content;
22 import com.sun.syndication.feed.rss.Description;
23 import com.sun.syndication.feed.rss.Item;
24 import com.sun.syndication.feed.synd.SyndContent;
25 import com.sun.syndication.feed.synd.SyndContentImpl;
26 import com.sun.syndication.feed.synd.SyndEntry;
27 import com.sun.syndication.feed.synd.SyndFeed;
28 import java.util.ArrayList;
29 import java.util.List;
30
31 /***
32 */
33 public class ConverterForRSS10 extends ConverterForRSS090 {
34
35 public ConverterForRSS10() {
36 this("rss_1.0");
37 }
38
39 protected ConverterForRSS10(String type) {
40 super(type);
41 }
42
43 public void copyInto(WireFeed feed,SyndFeed syndFeed) {
44 Channel channel = (Channel) feed;
45 super.copyInto(channel,syndFeed);
46 if (channel.getUri() != null) {
47 syndFeed.setUri(channel.getUri());
48 } else {
49
50 syndFeed.setUri(channel.getLink());
51 }
52 }
53
54
55
56
57
58 protected SyndEntry createSyndEntry(Item item) {
59 SyndEntry syndEntry = super.createSyndEntry(item);
60
61 Description desc = item.getDescription();
62 if (desc!=null) {
63 SyndContent descContent = new SyndContentImpl();
64 descContent.setType(desc.getType());
65 descContent.setValue(desc.getValue());
66 syndEntry.setDescription(descContent);
67 }
68 Content cont = item.getContent();
69 if (cont!=null) {
70 SyndContent contContent = new SyndContentImpl();
71 contContent.setType(cont.getType());
72 contContent.setValue(cont.getValue());
73 List contents = new ArrayList();
74 contents.add(contContent);
75 syndEntry.setContents(contents);
76 }
77
78 return syndEntry;
79 }
80
81 protected WireFeed createRealFeed(String type,SyndFeed syndFeed) {
82 Channel channel = (Channel) super.createRealFeed(type,syndFeed);
83 if (syndFeed.getUri() != null) {
84 channel.setUri(syndFeed.getUri());
85 } else {
86
87 channel.setUri(syndFeed.getLink());
88 }
89
90 return channel;
91 }
92
93
94
95
96
97 protected Item createRSSItem(SyndEntry sEntry) {
98 Item item = super.createRSSItem(sEntry);
99
100 SyndContent desc = sEntry.getDescription();
101 if (desc!=null) {
102 item.setDescription(createItemDescription(desc));
103 }
104 List contents = sEntry.getContents();
105 if (contents!=null && contents.size() > 0) {
106 item.setContent(createItemContent((SyndContent)contents.get(0)));
107 }
108
109 String uri = sEntry.getUri();
110 if (uri != null) {
111 item.setUri(uri);
112 }
113
114 return item;
115 }
116
117 protected Description createItemDescription(SyndContent sContent) {
118 Description desc = new Description();
119 desc.setValue(sContent.getValue());
120 desc.setType(sContent.getType());
121 return desc;
122 }
123
124 protected Content createItemContent(SyndContent sContent) {
125 Content cont = new Content();
126 cont.setValue(sContent.getValue());
127 cont.setType(sContent.getType());
128 return cont;
129 }
130
131 }