1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.cms.core.wiki.base;
17
18 import java.util.Collection;
19 import java.util.HashMap;
20 import java.util.Iterator;
21 import java.util.Map;
22 import java.util.Set;
23
24 import org.seasar.tuigwaa.cms.core.CmsEngine;
25 import org.seasar.tuigwaa.cms.core.wiki.WikiContext;
26 import org.seasar.tuigwaa.plugin.Plugin;
27
28
29 /***
30 * @author someda
31 */
32 public class WikiConfiguration {
33
34 private boolean debug_ = false;
35
36 private WikiContext wikicontext_;
37
38 private Map pluginmap_;
39
40 private Map enginemap_;
41
42 public WikiConfiguration(){
43 }
44
45 public boolean isDebug() {
46 return debug_;
47 }
48
49 public void setDebug(boolean debug) {
50 this.debug_ = debug;
51 }
52
53 public void setWikiContext(WikiContext wikicontext){
54 this.wikicontext_ = wikicontext;
55 }
56
57 public WikiContext getWikiContext(){
58 return wikicontext_;
59 }
60
61 public void addEngine(String contentType, CmsEngine engine){
62 if(enginemap_ == null) enginemap_ = new HashMap();
63 enginemap_.put(contentType,engine);
64 }
65
66 public CmsEngine getEngine(String contentType){
67 return (CmsEngine)enginemap_.get(contentType);
68 }
69
70 public void addPlugin(String name, Plugin plugin){
71 if(pluginmap_ == null) pluginmap_ = new HashMap();
72 pluginmap_.put(name,plugin);
73 }
74
75 public Plugin getPlugin(String name){
76 if(pluginmap_.get(name) == null) return null;
77 return (Plugin) pluginmap_.get(name);
78 }
79
80 public Set getPluginnameSet(){
81 if(pluginmap_ == null) return null;
82 return pluginmap_.keySet();
83 }
84
85 public Collection getPluginSet(){
86 if(pluginmap_ == null) return null;
87 return pluginmap_.values();
88 }
89
90 public boolean isPluginLoaded(String name){
91 if(pluginmap_ == null) return false;
92 return pluginmap_.keySet().contains(name);
93 }
94
95 public Plugin getPluginByClassname(String classname){
96 if(pluginmap_ == null) return null;
97 for(Iterator i = getPluginSet().iterator();i.hasNext();){
98 Plugin p = (Plugin)i.next();
99 if(p.getClass().getName().equals(classname))
100 return p;
101 }
102 return null;
103 }
104
105 }