View Javadoc

1   /*
2    * Copyright 2006 - 2012 Christina Bohk and Roland Ewald
3    *  
4    * Licensed under the Apache License, Version 2.0 (the "License"); 
5    * you may not use this file except in compliance with the License. 
6    * You may obtain a copy of the License at 
7    *  
8    *  http://www.apache.org/licenses/LICENSE-2.0
9    *  
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License. 
15   */
16  package p3j.gui.misc;
17  
18  import james.core.data.DBConnectionData;
19  import james.gui.application.preferences.config.ConfFile;
20  import p3j.misc.Misc;
21  
22  /**
23   * Main P3J configuration file.
24   * 
25   * @author Christina Bohk
26   * @author Roland Ewald
27   * 
28   */
29  public class P3JConfigFile extends ConfFile {
30  
31    @Override
32    public void setDefaults() {
33      values.put(Misc.PREF_DB_URL, Misc.DEFAULT_DB_URL);
34      values.put(Misc.PREF_DB_USER, Misc.DEFAULT_DB_USER);
35      values.put(Misc.PREF_DB_PWD, Misc.DEFAULT_DB_PWD);
36      values.put(Misc.PREF_NUM_TRIALS, Misc.DEFAULT_NUM_TRIALS);
37      values.put(Misc.PREF_NUM_PARALLEL_THREADS,
38          Misc.DEFAULT_NUM_PARALLEL_THREADS);
39      values.put(Misc.PREF_EXECUTION_MODE, Misc.DEFAULT_EXEC_MODE);
40    }
41  
42    /**
43     * Gets the dB connection data as defined in the configuration.
44     * 
45     * @return the database connection data
46     */
47    public DBConnectionData getDBConnectionData() {
48      return new DBConnectionData((String) get(Misc.PREF_DB_URL),
49          (String) get(Misc.PREF_DB_USER), (String) get(Misc.PREF_DB_PWD), null);
50    }
51  
52  }