KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nemesis > forum > config > Config


1 package org.nemesis.forum.config;
2 import java.util.ArrayList JavaDoc;
3 import java.util.Iterator JavaDoc;
4 import java.util.List JavaDoc;
5 import java.util.Properties JavaDoc;
6
7 import org.apache.commons.lang.StringUtils;
8 import org.nemesis.forum.search.Indexer;
9
10
11
12 /**
13  * @author dlaurent
14  *
15  * application configuration
16  * @see nemesis-forum-config.xml
17  */

18 public class Config {
19
20     public static String JavaDoc DATA_DIR = InitServlet.DATA_PATH;
21
22     private String JavaDoc JDBCConnectionProviderClass = null;
23
24     private Properties JavaDoc JDBCProviderProperties = new Properties JavaDoc();
25
26     private List JavaDoc userExtendedProperties = new ArrayList JavaDoc();
27     private List JavaDoc forumExtendedProperties = new ArrayList JavaDoc();
28     private List JavaDoc messageExtendedProperties = new ArrayList JavaDoc();
29     
30     private boolean autoIndex=false;
31     /**
32      * protected constructor
33      */

34     protected Config() {
35         super();
36         new Indexer();
37     }
38
39     public void addUserExtendedProperties(String JavaDoc s) {
40         userExtendedProperties.add(s);
41     }
42     public void addForumExtendedProperties(String JavaDoc s) {
43         forumExtendedProperties.add(s);
44     }
45     public void addMessageExtendedProperties(String JavaDoc s) {
46         messageExtendedProperties.add(s);
47     }
48     public void addJDBCProviderProperties(String JavaDoc key,String JavaDoc value){
49         JDBCProviderProperties.put(key, StringUtils.replace(value,"{data.dir}",DATA_DIR));
50     }
51
52     /**
53      * @return the JDBC provider class
54      */

55     public String JavaDoc getJDBCConnectionProviderClass() {
56         return JDBCConnectionProviderClass;
57     }
58
59     /**
60      * @param string the provider class
61      */

62     public void setJDBCConnectionProviderClass(String JavaDoc string) {
63         JDBCConnectionProviderClass = string;
64     }
65
66     /**
67      * @return
68      */

69     public List JavaDoc getForumExtendedProperties() {
70         return forumExtendedProperties;
71     }
72
73     /**
74      * @return
75      */

76     public Properties JavaDoc getJDBCProviderProperties() {
77         return JDBCProviderProperties;
78     }
79
80     /**
81      * @return
82      */

83     public List JavaDoc getMessageExtendedProperties() {
84         return messageExtendedProperties;
85     }
86
87     /**
88      * @return
89      */

90     public List JavaDoc getUserExtendedProperties() {
91         return userExtendedProperties;
92     }
93
94     public String JavaDoc toString() {
95         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("Config :\n");
96         sb.append("\nDATA_DIR:" + DATA_DIR);
97         sb.append("\nJDBCConnectionProviderClass:" + JDBCConnectionProviderClass);
98         sb.append("\nJDBCProviderProperties:" + JDBCProviderProperties.toString());
99         
100
101         sb.append("\nuserExtendedProperties:");
102         for (Iterator JavaDoc it = userExtendedProperties.iterator(); it.hasNext();) {
103             sb.append("\n\t>" + it.next());
104         }
105         sb.append("\nforumExtendedProperties:");
106         for (Iterator JavaDoc it = forumExtendedProperties.iterator(); it.hasNext();) {
107             sb.append("\n\t>" + it.next());
108         }
109         sb.append("\nmessageExtendedProperties:");
110         for (Iterator JavaDoc it = messageExtendedProperties.iterator(); it.hasNext();) {
111             sb.append("\n\t>" + it.next());
112         }
113         
114         sb.append("\nautoindex:"+autoIndex);
115         
116         
117
118         return sb.toString();
119     }
120
121     /**
122      * @return datadir
123      */

124     public String JavaDoc getDataDir() {
125         return DATA_DIR;
126     }
127
128
129
130     /**
131      * @return
132      */

133     public boolean isAutoIndex() {
134         return autoIndex;
135     }
136
137     /**
138      * @param b
139      */

140     public void setAutoIndex(boolean b) {
141         autoIndex = b;
142     }
143
144 }
145
Popular Tags