KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > syndication > io > impl > BaseWireFeedGenerator


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 JavaDoc;
8 import java.util.Iterator JavaDoc;
9 import java.util.List JavaDoc;
10 import java.util.Set JavaDoc;
11
12 /**
13  * @author Alejandro Abdelnur
14  */

15 public abstract class BaseWireFeedGenerator implements WireFeedGenerator {
16
17     /**
18      * [TYPE].feed.ModuleParser.classes= [className] ...
19      *
20      */

21     private static final String JavaDoc FEED_MODULE_GENERATORS_POSFIX_KEY = ".feed.ModuleGenerator.classes";
22
23     /**
24      * [TYPE].item.ModuleParser.classes= [className] ...
25      *
26      */

27     private static final String JavaDoc ITEM_MODULE_GENERATORS_POSFIX_KEY = ".item.ModuleGenerator.classes";
28
29
30     private String JavaDoc _type;
31     private ModuleGenerators _feedModuleGenerators;
32     private ModuleGenerators _itemModuleGenerators;
33     private Namespace[] _allModuleNamespaces;
34
35     protected BaseWireFeedGenerator(String JavaDoc 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 JavaDoc allModuleNamespaces = new HashSet JavaDoc();
40         Iterator JavaDoc 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 JavaDoc 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 JavaDoc modules,Element feed) {
63         _feedModuleGenerators.generateModules(modules,feed);
64     }
65
66     protected void generateItemModules(List JavaDoc modules,Element item) {
67         _itemModuleGenerators.generateModules(modules,item);
68     }
69
70 }
71
Popular Tags