com.sun.syndication.feed.synd.impl.ConverterForRSS092 Maven / Gradle / Ivy
/*
* 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 java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import com.sun.syndication.feed.rss.Category;
import com.sun.syndication.feed.rss.Enclosure;
import com.sun.syndication.feed.rss.Item;
import com.sun.syndication.feed.synd.SyndCategory;
import com.sun.syndication.feed.synd.SyndCategoryImpl;
import com.sun.syndication.feed.synd.SyndEnclosure;
import com.sun.syndication.feed.synd.SyndEnclosureImpl;
import com.sun.syndication.feed.synd.SyndEntry;
/**
*/
public class ConverterForRSS092 extends ConverterForRSS091Userland {
public ConverterForRSS092() {
this("rss_0.92");
}
protected ConverterForRSS092(String type) {
super(type);
}
@Override
protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) {
SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
List cats = item.getCategories();
if (cats.size()>0) {
Set s = new LinkedHashSet(); // using a set to remove duplicates and use a LinkedHashSet to try to retain the document order
s.addAll(createSyndCategories(cats)); // feed native categories (as syndcat)
s.addAll(syndEntry.getCategories()); // DC subjects (as syndcat)
syndEntry.setCategories(new ArrayList(s)); //c
}
List enclosures = item.getEnclosures();
if (enclosures.size()>0) {
syndEntry.setEnclosures(createSyndEnclosures(enclosures));
}
return syndEntry;
}
protected List createSyndCategories(List rssCats) {
List syndCats = new ArrayList();
for (int i=0;i0) {
item.setCategories(createRSSCategories(sCats));
}
List sEnclosures = sEntry.getEnclosures();
if (sEnclosures.size()>0) {
item.setEnclosures(createEnclosures(sEnclosures));
}
return item;
}
protected List createRSSCategories(List sCats) {
List cats = new ArrayList();
for (int i=0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy