1 package com.sun.syndication.io.impl; 2 3 import com.sun.syndication.io.WireFeedGenerator; 4 import org.jdom.Element; 5 import org.jdom.Namespace; 6 7 import java.util.HashSet ; 8 import java.util.Iterator ; 9 import java.util.List ; 10 import java.util.Set ; 11 12 15 public abstract class BaseWireFeedGenerator implements WireFeedGenerator { 16 17 21 private static final String FEED_MODULE_GENERATORS_POSFIX_KEY = ".feed.ModuleGenerator.classes"; 22 23 27 private static final String ITEM_MODULE_GENERATORS_POSFIX_KEY = ".item.ModuleGenerator.classes"; 28 29 30 private String _type; 31 private ModuleGenerators _feedModuleGenerators; 32 private ModuleGenerators _itemModuleGenerators; 33 private Namespace[] _allModuleNamespaces; 34 35 protected BaseWireFeedGenerator(String type) { 36 _type = type; 37 _feedModuleGenerators = new ModuleGenerators(type+FEED_MODULE_GENERATORS_POSFIX_KEY); 38 _itemModuleGenerators = new ModuleGenerators(type+ITEM_MODULE_GENERATORS_POSFIX_KEY); 39 Set allModuleNamespaces = new HashSet (); 40 Iterator i = _feedModuleGenerators.getAllNamespaces().iterator(); 41 while (i.hasNext()) { 42 allModuleNamespaces.add(i.next()); 43 } 44 i = _itemModuleGenerators.getAllNamespaces().iterator(); 45 while (i.hasNext()) { 46 allModuleNamespaces.add(i.next()); 47 } 48 _allModuleNamespaces = new Namespace[allModuleNamespaces.size()]; 49 allModuleNamespaces.toArray(_allModuleNamespaces); 50 } 51 52 public String getType() { 53 return _type; 54 } 55 56 protected void generateModuleNamespaceDefs(Element root) { 57 for (int i=0;i<_allModuleNamespaces.length;i++) { 58 root.addNamespaceDeclaration(_allModuleNamespaces[i]); 59 } 60 } 61 62 protected void generateFeedModules(List modules,Element feed) { 63 _feedModuleGenerators.generateModules(modules,feed); 64 } 65 66 protected void generateItemModules(List modules,Element item) { 67 _itemModuleGenerators.generateModules(modules,item); 68 } 69 70 } 71 | Popular Tags |