Drupal: číštění HTML – Tidy.
3 * see AUTHORS for the list of contributors
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package org.sonews.config;
21 * Configuration facade class.
22 * @author Christian Lins
25 public class Config extends AbstractConfig {
27 public static final int LEVEL_CLI = 1;
28 public static final int LEVEL_FILE = 2;
29 public static final int LEVEL_BACKEND = 3;
30 public static final String CONFIGFILE = "sonews.configfile";
31 /** BackendConfig key constant. Value is the maximum article size in kilobytes. */
32 public static final String ARTICLE_MAXSIZE = "sonews.article.maxsize";
33 /** BackendConfig key constant. Value: Amount of news that are feeded per run. */
34 public static final String EVENTLOG = "sonews.eventlog";
36 public static final String FEED_NEWSPERRUN = "sonews.feed.newsperrun";
37 public static final String FEED_PULLINTERVAL = "sonews.feed.pullinterval";
39 public static final String HOSTNAME = "sonews.hostname";
40 public static final String PORT = "sonews.port";
41 public static final String TIMEOUT = "sonews.timeout";
42 public static final String LOGLEVEL = "sonews.loglevel";
44 public static final String MLPOLL_DELETEUNKNOWN = "sonews.mlpoll.deleteunknown";
45 public static final String MLPOLL_HOST = "sonews.mlpoll.host";
46 public static final String MLPOLL_PASSWORD = "sonews.mlpoll.password";
47 public static final String MLPOLL_USER = "sonews.mlpoll.user";
49 public static final String MLSEND_ADDRESS = "sonews.mlsend.address";
50 public static final String MLSEND_RW_FROM = "sonews.mlsend.rewrite.from";
51 public static final String MLSEND_RW_SENDER = "sonews.mlsend.rewrite.sender";
52 public static final String MLSEND_HOST = "sonews.mlsend.host";
53 public static final String MLSEND_PASSWORD = "sonews.mlsend.password";
54 public static final String MLSEND_PORT = "sonews.mlsend.port";
55 public static final String MLSEND_USER = "sonews.mlsend.user";
56 public static final String MLSEND_AUTH = "sonews.mlsend.auth";
58 /** Key constant. If value is "true" every I/O is written to logfile
59 * (which is a lot!) */
60 public static final String DEBUG = "sonews.debug";
62 /** Key constant. Value is classname of the JDBC driver */
63 public static final String STORAGE_DBMSDRIVER = "sonews.storage.dbmsdriver";
64 /** Key constant. Value is JDBC connect String to the database. */
65 public static final String STORAGE_DATABASE = "sonews.storage.database";
66 /** Key constant. Value is the username for the DBMS. */
67 public static final String STORAGE_USER = "sonews.storage.user";
68 /** Key constant. Value is the password for the DBMS. */
69 public static final String STORAGE_PASSWORD = "sonews.storage.password";
70 public static final String STORAGE_PROVIDER = "sonews.storage.provider";
72 /** Key constant. Value is the name of the host which is allowed to use the
73 * XDAEMON command; default: "localhost" */
74 public static final String XDAEMON_HOST = "sonews.xdaemon.host";
76 /** The config key for the filename of the logfile */
77 public static final String LOGFILE = "sonews.log";
78 public static final String[] AVAILABLE_KEYS = {
99 private static Config instance = new Config();
101 public static Config inst() {
109 public String get(String key, String def) {
110 String val = CommandLineConfig.getInstance().get(key, null);
113 val = FileConfig.getInstance().get(key, null);
117 val = BackendConfig.getInstance().get(key, def);
123 public String get(int maxLevel, String key, String def) {
124 String val = CommandLineConfig.getInstance().get(key, null);
126 if (val == null && maxLevel >= LEVEL_FILE) {
127 val = FileConfig.getInstance().get(key, null);
128 if (val == null && maxLevel >= LEVEL_BACKEND) {
129 val = BackendConfig.getInstance().get(key, def);
133 return val != null ? val : def;
137 public void set(String key, String val) {
138 set(LEVEL_BACKEND, key, val);
141 public void set(int level, String key, String val) {
144 CommandLineConfig.getInstance().set(key, val);
148 FileConfig.getInstance().set(key, val);
151 case LEVEL_BACKEND: {
152 BackendConfig.getInstance().set(key, val);