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.Item;
22  import com.sun.syndication.feed.rss.Guid;
23  import com.sun.syndication.feed.synd.SyndFeed;
24  import com.sun.syndication.feed.synd.SyndEntry;
25  
26  import java.util.List;
27  
28  /***
29   */
30  public class ConverterForRSS094 extends ConverterForRSS093 {
31  
32      public ConverterForRSS094() {
33          this("rss_0.94");
34      }
35  
36      protected ConverterForRSS094(String type) {
37          super(type);
38      }
39  
40      public void copyInto(WireFeed feed,SyndFeed syndFeed) {
41          Channel channel = (Channel) feed;
42          super.copyInto(channel,syndFeed);
43          List cats = channel.getCategories();    //c
44          if (cats!=null) {
45              syndFeed.setCategories(this.createSyndCategories(cats));
46          }
47      }
48  
49      protected SyndEntry createSyndEntry(Item item) {
50          SyndEntry syndEntry = super.createSyndEntry(item);
51          syndEntry.setAuthor(item.getAuthor());    //c
52  
53          Guid guid = item.getGuid();
54          if (guid!=null) {
55              syndEntry.setUri(guid.getValue());
56              if (item.getLink()==null && guid.isPermaLink()) {
57                  syndEntry.setLink(guid.getValue());
58              }
59          }
60          else {
61              syndEntry.setUri(item.getLink());
62          }
63          return syndEntry;
64      }
65  
66  
67      protected WireFeed createRealFeed(String type,SyndFeed syndFeed) {
68          Channel channel = (Channel) super.createRealFeed(type,syndFeed);
69          List cats = syndFeed.getCategories();    //c
70          if (cats!=null) {
71              channel.setCategories(createRSSCategories(cats));
72          }
73          return channel;
74      }
75  
76      protected Item createRSSItem(SyndEntry sEntry) {
77          Item item = super.createRSSItem(sEntry);
78          item.setAuthor(sEntry.getAuthor());    //c
79  
80          Guid guid = null;
81          String uri = sEntry.getUri();
82          if (uri!=null) {
83              guid = new Guid();
84              guid.setPermaLink(false);
85              guid.setValue(uri);
86          }
87          else {
88              String link = sEntry.getLink();
89              if (link!=null) {
90                  guid = new Guid();
91                  guid.setPermaLink(true);
92                  guid.setValue(link);
93              }
94          }
95          item.setGuid(guid);
96  
97          return item;
98      }
99  
100 }