KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > syndication > feed > synd > impl > ConverterForRSS091Userland


1 /*
2  * Copyright 2004 Sun Microsystems, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
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.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 JavaDoc;
31 import java.util.List JavaDoc;
32 import java.util.Date JavaDoc;
33
34 /**
35  */

36 public class ConverterForRSS091Userland extends ConverterForRSS090 {
37
38     public ConverterForRSS091Userland() {
39         this("rss_0.91U");
40     }
41
42     protected ConverterForRSS091Userland(String JavaDoc 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()); //c
50
syndFeed.setCopyright(channel.getCopyright()); //c
51
Date JavaDoc pubDate = channel.getPubDate();
52         if (pubDate!=null) {
53             syndFeed.setPublishedDate(pubDate); //c
54
}
55         syndFeed.setAuthor(channel.getManagingEditor()); //c
56
}
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             // contents[0] and description then reference the same content
74
//
75
List JavaDoc contents = new ArrayList JavaDoc();
76             contents.add(content);
77             syndEntry.setContents(contents);
78
79         }
80         return syndEntry;
81     }
82
83     protected WireFeed createRealFeed(String JavaDoc type,SyndFeed syndFeed) {
84         Channel channel = (Channel) super.createRealFeed(type,syndFeed);
85         channel.setLanguage(syndFeed.getLanguage()); //c
86
channel.setCopyright(syndFeed.getCopyright()); //c
87
channel.setPubDate(syndFeed.getPublishedDate()); //c
88
channel.setManagingEditor(syndFeed.getAuthor()); //c
89
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