View Javadoc

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.SyndFeedI;
25  import com.sun.syndication.feed.synd.SyndContentI;
26  import com.sun.syndication.feed.synd.SyndEntryI;
27  import com.sun.syndication.feed.synd.SyndImageI;
28  import com.sun.syndication.feed.synd.SyndContent;
29  
30  import java.util.ArrayList;
31  import java.util.List;
32  
33  /***
34   */
35  public class ConverterForRSS091 extends ConverterForRSS090 {
36  
37      public String getType() {
38          return "rss_0.91";
39      }
40  
41      public void copyInto(WireFeed feed,SyndFeedI syndFeed) {
42          Channel channel = (Channel) feed;
43          super.copyInto(channel,syndFeed);
44          syndFeed.setLanguage(channel.getLanguage());
45          syndFeed.setCopyright(channel.getCopyright());
46          syndFeed.setPublishedDate(channel.getPubDate());
47          syndFeed.setAuthor(channel.getManagingEditor());
48      }
49  
50      protected SyndImageI createSyndImage(Image rssImage) {
51          SyndImageI syndImage = super.createSyndImage(rssImage);
52          syndImage.setDescription(rssImage.getDescription());
53          return syndImage;
54      }
55  
56      protected SyndEntryI createSyndEntry(Item item) {
57          SyndEntryI syndEntry = super.createSyndEntry(item);
58          Description desc = item.getDescription();
59          if (desc!=null) {
60              SyndContentI content = new SyndContent();
61              content.setType(desc.getType());
62              content.setValue(desc.getValue());
63              syndEntry.setDescription(content);
64  
65              // contents[0] and description then reference the same content
66              //
67              List contents = new ArrayList();
68              contents.add(content);
69              syndEntry.setContents(contents);
70  
71          }
72          return syndEntry;
73      }
74  
75      protected WireFeed createRealFeed(String type,SyndFeedI syndFeed) {
76          Channel channel = (Channel) super.createRealFeed(type,syndFeed);
77          channel.setLanguage(syndFeed.getLanguage());
78          channel.setCopyright(syndFeed.getCopyright());
79          channel.setPubDate(syndFeed.getPublishedDate());
80          channel.setManagingEditor(syndFeed.getAuthor());
81          return channel;
82      }
83  
84      protected Image createRSSImage(SyndImageI sImage) {
85          Image image = super.createRSSImage(sImage);
86          image.setDescription(sImage.getDescription());
87          return image;
88      }
89  
90      protected Item createRSSItem(SyndEntryI sEntry) {
91          Item item = super.createRSSItem(sEntry);
92  
93          SyndContentI sContent = sEntry.getDescription();
94          if (sContent!=null) {
95              item.setDescription(createItemDescription(sContent));
96          }
97          return item;
98      }
99  
100     protected Description createItemDescription(SyndContentI sContent) {
101         Description desc = new Description();
102         desc.setValue(sContent.getValue());
103         desc.setType(sContent.getType());
104         return desc;
105     }
106 
107 
108 }