/*
* Copyright 2004 Sun Microsystems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.sun.syndication.feed.synd.impl;
import com.sun.syndication.feed.WireFeed;
import com.sun.syndication.feed.rss.Channel;
import com.sun.syndication.feed.rss.Item;
import com.sun.syndication.feed.rss.Guid;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.feed.synd.SyndEntry;
import java.util.List;
/**
*/
public class ConverterForRSS094 extends ConverterForRSS093 {
public ConverterForRSS094() {
this("rss_0.94");
}
protected ConverterForRSS094(String type) {
super(type);
}
public void copyInto(WireFeed feed,SyndFeed syndFeed) {
Channel channel = (Channel) feed;
super.copyInto(channel,syndFeed);
List cats = channel.getCategories(); //c
if (cats!=null) {
syndFeed.setCategories(this.createSyndCategories(cats));
}
}
protected SyndEntry createSyndEntry(Item item) {
SyndEntry syndEntry = super.createSyndEntry(item);
syndEntry.setAuthor(item.getAuthor()); //c
Guid guid = item.getGuid();
if (guid!=null) {
syndEntry.setUri(guid.getValue());
if (item.getLink()==null && guid.isPermaLink()) {
syndEntry.setLink(guid.getValue());
}
}
else {
syndEntry.setUri(item.getLink());
}
return syndEntry;
}
protected WireFeed createRealFeed(String type,SyndFeed syndFeed) {
Channel channel = (Channel) super.createRealFeed(type,syndFeed);
List cats = syndFeed.getCategories(); //c
if (cats!=null) {
channel.setCategories(createRSSCategories(cats));
}
return channel;
}
protected Item createRSSItem(SyndEntry sEntry) {
Item item = super.createRSSItem(sEntry);
item.setAuthor(sEntry.getAuthor()); //c
Guid guid = null;
String uri = sEntry.getUri();
if (uri!=null) {
guid = new Guid();
guid.setPermaLink(false);
guid.setValue(uri);
}
else {
String link = sEntry.getLink();
if (link!=null) {
guid = new Guid();
guid.setPermaLink(true);
guid.setValue(link);
}
}
item.setGuid(guid);
return item;
}
}