1 17 package com.sun.syndication.feed.synd.impl; 18 19 import com.sun.syndication.feed.rss.Category; 20 import com.sun.syndication.feed.rss.Item; 21 import com.sun.syndication.feed.synd.SyndCategory; 22 import com.sun.syndication.feed.synd.SyndEntry; 23 import com.sun.syndication.feed.synd.SyndCategoryImpl; 24 25 import java.util.ArrayList ; 26 import java.util.List ; 27 import java.util.Set ; 28 import java.util.HashSet ; 29 30 32 public class ConverterForRSS092 extends ConverterForRSS091Userland { 33 34 public ConverterForRSS092() { 35 this("rss_0.92"); 36 } 37 38 protected ConverterForRSS092(String type) { 39 super(type); 40 } 41 42 protected SyndEntry createSyndEntry(Item item) { 43 SyndEntry syndEntry = super.createSyndEntry(item); 44 List cats = item.getCategories(); 45 if (cats.size()>0) { 46 Set s = new HashSet (); s.addAll(createSyndCategories(cats)); s.addAll(syndEntry.getCategories()); syndEntry.setCategories(new ArrayList (s)); } 51 return syndEntry; 52 } 53 54 protected List createSyndCategories(List rssCats) { 55 List syndCats = new ArrayList (); 56 for (int i=0;i<rssCats.size();i++) { 57 Category rssCat = (Category) rssCats.get(i); 58 SyndCategory sCat = new SyndCategoryImpl(); 59 sCat.setTaxonomyUri(rssCat.getDomain()); 60 sCat.setName(rssCat.getValue()); 61 syndCats.add(sCat); 62 } 63 return syndCats; 64 } 65 66 protected Item createRSSItem(SyndEntry sEntry) { 67 Item item = super.createRSSItem(sEntry); 68 69 List sCats = sEntry.getCategories(); if (sCats.size()>0) { 71 item.setCategories(createRSSCategories(sCats)); 72 } 73 return item; 74 } 75 76 protected List createRSSCategories(List sCats) { 77 List cats = new ArrayList (); 78 for (int i=0;i<sCats.size();i++) { 79 SyndCategory sCat = (SyndCategory) sCats.get(i); 80 Category cat = new Category(); 81 cat.setDomain(sCat.getTaxonomyUri()); 82 cat.setValue(sCat.getName()); 83 cats.add(cat); 84 } 85 return cats; 86 } 87 88 } 89 | Popular Tags |