22
|
1 /*
|
|
2 * @(#)ConfigureFactory.java
|
|
3 * @author Kenneth J. Pouncey
|
|
4 * Modified by LDC Luc
|
|
5 *
|
|
6 * Copyright: Copyright (c) 2001, 2002, 2003
|
|
7 *
|
|
8 * This program is free software; you can redistribute it and/or modify
|
|
9 * it under the terms of the GNU General Public License as published by
|
|
10 * the Free Software Foundation; either version 2, or (at your option)
|
|
11 * any later version.
|
|
12 *
|
|
13 * This program is distributed in the hope that it will be useful,
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 * GNU General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License
|
|
19 * along with this software; see the file COPYING. If not, write to
|
|
20 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
21 * Boston, MA 02111-1307 USA
|
|
22 *
|
|
23 */
|
|
24 package org.tn5250j.interfaces;
|
|
25
|
|
26 import org.tn5250j.GlobalConfigure;
|
|
27 import java.util.Properties;
|
|
28
|
|
29 /**
|
|
30 * An interface defining objects that can create Configure
|
|
31 * instances.
|
|
32 */
|
|
33 public abstract class ConfigureFactory {
|
|
34
|
|
35 static final public String SESSIONS = "sessions";
|
|
36 static final public String MACROS = "macros";
|
|
37 static final public String KEYMAP = "keymap";
|
|
38 private static ConfigureFactory factory;
|
|
39
|
|
40 /**
|
|
41 * @return An instance of the Configure.
|
|
42 */
|
|
43 public static ConfigureFactory getInstance()
|
|
44 {
|
|
45 ConfigureFactory.setFactory();
|
|
46 return factory;
|
|
47 }
|
|
48
|
|
49 private static final void setFactory()
|
|
50 {
|
|
51 if (factory == null)
|
|
52 {
|
|
53 try
|
|
54 {
|
|
55 String className = System.getProperty(ConfigureFactory.class.getName());
|
|
56 if (className != null)
|
|
57 {
|
|
58 Class<?> classObject = Class.forName(className);
|
|
59 Object object = classObject.newInstance();
|
|
60 if (object instanceof ConfigureFactory)
|
|
61 {
|
|
62 ConfigureFactory.factory = (ConfigureFactory) object;
|
|
63 }
|
|
64 }
|
|
65 }
|
|
66 catch (Exception ex)
|
|
67 {
|
|
68 ;
|
|
69 }
|
|
70 if (ConfigureFactory.factory == null)
|
|
71 { //take the default
|
|
72 // ConfigureFactory.factory = new GlobalConfigureFactory();
|
|
73 ConfigureFactory.factory = new GlobalConfigure();
|
|
74 }
|
|
75 }
|
|
76 }
|
|
77
|
|
78 abstract public void reloadSettings();
|
|
79 abstract public void saveSettings();
|
|
80 abstract public String getProperty(String regKey);
|
|
81 abstract public String getProperty(String regKey, String defaultValue);
|
|
82 abstract public void setProperties(String regKey, Properties regProps);
|
|
83
|
|
84 abstract public void setProperties(String regKey, String fileName, String header);
|
|
85 abstract public void setProperties(String regKey, String fileName, String header,
|
|
86 boolean createFile);
|
|
87 abstract public Properties getProperties(String regKey);
|
|
88 abstract public Properties getProperties(String regKey,String fileName);
|
|
89 abstract public Properties getProperties(String regKey,String fileName,
|
|
90 boolean createFile, String header);
|
|
91 abstract public Properties getProperties(String regKey,String fileName,
|
|
92 boolean createFile, String header,
|
|
93 boolean reloadIfLoaded);
|
|
94 abstract public void saveSettings(String regKey);
|
|
95 abstract public void saveSettings(String regKey, String header);
|
|
96 abstract public void saveSettings(String regKey, String fileName, String header);
|
|
97
|
|
98 } |