annotate src/org/tn5250j/GlobalConfigure.java @ 75:bf01d1eec5c6 tn5250

convert 5250 to vt320 attributes
author Carl Byington <carl@five-ten-sg.com>
date Sun, 15 Jun 2014 10:56:09 -0700
parents b29b39f386a4
children 8f23b05a51f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2 * Title: GlobalConfigure.java
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
3 * Copyright: Copyright (c) 2001, 2002, 2003
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
4 * Company:
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
5 * @author Kenneth J. Pouncey
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
6 * @version 0.1
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
7 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
8 * Description:
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
9 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2, or (at your option)
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
13 * any later version.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
14 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
18 * GNU General Public License for more details.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
19 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
21 * along with this software; see the file COPYING. If not, write to
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
22 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
23 * Boston, MA 02111-1307 USA
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
24 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
25 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
26 package org.tn5250j;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
27
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
28 import java.io.BufferedReader;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
29 import java.io.File;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
30 import java.io.FileInputStream;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
31 import java.io.FileNotFoundException;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
32 import java.io.FileOutputStream;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
33 import java.io.FileReader;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
34 import java.io.FileWriter;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
35 import java.io.IOException;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
36 import java.io.PrintWriter;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
37 import java.util.Hashtable;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
38 import java.util.Properties;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
39
21
94abfc6441a4 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 20
diff changeset
40 import com.five_ten_sg.connectbot.TerminalView;
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
41 import org.tn5250j.interfaces.ConfigureFactory;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
42 import android.util.Log;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
43
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
44
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
45 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
46 * Utility class for referencing global settings and functions of which at most
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
47 * one instance can exist per VM.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
48 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
49 * Use GlobalConfigure.instance() to access this instance.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
50 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
51 public class GlobalConfigure extends ConfigureFactory {
27
b29b39f386a4 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 25
diff changeset
52 private static final String TAG = "GlobalConfigure";
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
53 public static final String TN5250J_FOLDER = ".tn5250j";
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
54
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
55 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
56 * A handle to the unique GlobalConfigure class
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
57 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
58 static private GlobalConfigure _instance;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
59
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
60 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
61 * A handle to the the Global Properties
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
62 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
63 static private Properties settings;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
64
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
65 static private Hashtable registry = new Hashtable();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
66 static private Hashtable headers = new Hashtable(); //LUC GORRENS
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
67
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
68
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
69 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
70 * The constructor is made protected to allow overriding.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
71 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
72 public GlobalConfigure() {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
73 if (_instance == null) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
74 // initialize the settings information
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
75 initialize();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
76 // set our instance to this one.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
77 _instance = this;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
78 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
79 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
80
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
81 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
82 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
83 * @return The unique instance of this class.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
84 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
85 static public GlobalConfigure instance() {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
86
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
87 if (_instance == null) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
88 _instance = new GlobalConfigure();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
89 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
90 return _instance;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
91
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
92 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
93
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
94 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
95 * Initialize the properties registry for use later.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
96 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
97 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
98 private void initialize() {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
99 verifySettingsFolder();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
100 loadSettings();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
101 loadSessions();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
102 loadMacros();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
103 loadKeyStrokes();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
104 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
105
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
106 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
107 * check if folder %USERPROFILE%/.tn5250j exists
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
108 * and create if necessary
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
109 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
110 private void verifySettingsFolder() {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
111 final String settingsfolder = settingsFolder();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
112 final File f = new File (settingsfolder);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
113 if (!f.exists()) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
114 try {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
115 Log.i(TAG,"Settings folder '"+settingsfolder+"' doesn't exist. Will created now.");
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
116 f.mkdir();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
117 } catch (Exception e) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
118 Log.w(TAG,"Couldn't create settings folder '"+settingsfolder+"'", e);
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
119 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
120 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
121 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
122
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
123 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
124 * Load the sessions properties
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
125 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
126 private void loadSessions() {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
127
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
128 setProperties(SESSIONS,SESSIONS,"------ Sessions --------",true);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
129 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
130
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
131 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
132 * Load the macros
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
133 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
134 private void loadMacros() {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
135
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
136 setProperties(MACROS,MACROS,"------ Macros --------",true);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
137
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
138 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
139
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
140 private void loadKeyStrokes() {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
141
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
142 setProperties(KEYMAP,KEYMAP,
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
143 "------ Key Map key=keycode,isShiftDown,isControlDown,isAltDown,isAltGrDown --------",
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
144 true);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
145
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
146 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
147
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
148 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
149 * Reload the environment settings.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
150 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
151 @Override
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
152 public void reloadSettings() {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
153 Log.i(TAG,"reloading settings");
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
154 loadSettings();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
155 loadSessions();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
156 loadMacros();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
157 loadKeyStrokes();
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
158 Log.i(TAG,"Done (reloading settings).");
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
159 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
160
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
161 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
162 * Loads the emulator setting from the setting(s) file
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
163 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
164 private void loadSettings() {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
165
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
166 FileInputStream in = null;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
167 settings = new Properties();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
168
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
169 try {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
170 in = new FileInputStream(settingsFile());
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
171 settings.load(in);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
172 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
173 catch (FileNotFoundException fnfea) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
174 Log.i(TAG," Information Message: "
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
175 + fnfea.getMessage() + ". The file " + settingsFile()
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
176 + " will be created for first time use.");
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
177 saveSettings();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
178 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
179 catch (IOException ioea) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
180 Log.w(TAG,"IO Exception accessing File "
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
181 + settingsFile() + " for the following reason : "
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
182 + ioea.getMessage());
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
183 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
184 catch (SecurityException sea) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
185 Log.w(TAG,"Security Exception for file "
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
186 + settingsFile() + " This file can not be "
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
187 + "accessed because : " + sea.getMessage());
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
188 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
189 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
190
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
191 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
192 * Save the settings for the global configuration
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
193 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
194 @Override
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
195 public void saveSettings() {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
196
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
197 try {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
198 FileOutputStream out = new FileOutputStream(settingsFile());
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
199 settings.store(out,"----------------- tn5250j Global Settings --------------");
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
200 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
201 catch (FileNotFoundException fnfe) {}
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
202 catch (IOException ioe) {}
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
203 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
204
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
205 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
206 * Save the setting in the registry using the key passed in with no header
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
207 * output.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
208 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
209 * @param regKey
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
210 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
211 @Override
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
212 public void saveSettings(String regKey) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
213
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
214 saveSettings(regKey,"");
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
215 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
216
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
217 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
218 * Save the settings in the registry using the key passed with a header
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
219 * in the output.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
220 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
221 * @param regKey
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
222 * @param Header
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
223 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
224 @Override
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
225 public void saveSettings(String regKey, String header) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
226
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
227 saveSettings(regKey,regKey,header);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
228 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
229
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
230 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
231 * Save the settings in the registry using the key passed with a header
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
232 * in the output.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
233 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
234 * @param regKey
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
235 * @param Header
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
236 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
237 @Override
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
238 public void saveSettings(String regKey, String fileName, String header) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
239
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
240 if (registry.containsKey(regKey)) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
241 try {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
242 FileOutputStream out = new FileOutputStream(
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
243 settingsDirectory() + fileName);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
244 Properties props = (Properties)registry.get(regKey);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
245 props.store(out,header);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
246 out.flush();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
247 out.close();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
248 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
249 catch (FileNotFoundException fnfe) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
250 Log.w(TAG,"File not found : writing file "
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
251 + fileName + ". Description of error is "
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
252 + fnfe.getMessage());
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
253 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
254 catch (IOException ioe) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
255 Log.w(TAG,"IO Exception : writing file "
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
256 + fileName + ". Description of error is "
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
257 + ioe.getMessage());
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
258 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
259 catch (SecurityException se) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
260 Log.w(TAG,"Security Exception : writing file "
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
261 + fileName + ". Description of error is "
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
262 + se.getMessage());
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
263 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
264
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
265 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
266
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
267 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
268
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
269 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
270 * Place the Properties in the registry under a given registry name
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
271 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
272 * @param regKey
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
273 * @param regProps
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
274 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
275 @Override
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
276 public void setProperties(String regKey, Properties regProps) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
277
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
278 registry.put(regKey, regProps);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
279
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
280 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
281
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
282 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
283 * Set the properties for the given registry key.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
284 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
285 * @param regKey
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
286 * @param fileName
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
287 * @param header
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
288 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
289 @Override
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
290 public void setProperties(String regKey, String fileName, String header) { //LG NEW
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
291 setProperties(regKey, fileName, header, false);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
292 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
293
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
294 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
295 * Set the properties for the given registry key.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
296 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
297 * @param regKey
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
298 * @param fileName
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
299 * @param header
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
300 * @param createFile
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
301 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
302 @Override
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
303 public void setProperties(String regKey, String fileName, String header,
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
304 boolean createFile) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
305
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
306 FileInputStream in = null;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
307 Properties props = new Properties();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
308 headers.put(regKey, header);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
309
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
310 try {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
311 in = new FileInputStream(settingsDirectory() + fileName);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
312 props.load(in);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
313
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
314 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
315 catch (FileNotFoundException fnfe) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
316
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
317 if (createFile) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
318 Log.i(TAG," Information Message: " + fnfe.getMessage()
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
319 + ". The file " + fileName + " will"
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
320 + " be created for first time use.");
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
321
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
322 saveSettings(regKey,header);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
323
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
324 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
325 else {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
326
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
327 Log.i(TAG," Information Message: " + fnfe.getMessage()
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
328 + ".");
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
329
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
330 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
331 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
332 catch (IOException ioe) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
333 Log.w(TAG,"IO Exception accessing File "+ fileName +
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
334 " for the following reason : "
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
335 + ioe.getMessage());
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
336 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
337 catch (SecurityException se) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
338 Log.w(TAG,"Security Exception for file "+ fileName
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
339 + ". This file can not be accessed because : "
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
340 + se.getMessage());
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
341 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
342
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
343 registry.put(regKey,props);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
344
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
345 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
346
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
347 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
348 * Returns the properties associated with a given registry key.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
349 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
350 * @param regKey
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
351 * @return
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
352 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
353 @Override
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
354 public Properties getProperties(String regKey) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
355
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
356 if (registry.containsKey(regKey)) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
357 return (Properties)registry.get(regKey);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
358 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
359 return null;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
360 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
361
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
362 public Properties getProperties() {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
363 return settings;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
364 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
365
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
366 @Override
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
367 public Properties getProperties(String regKey,String fileName) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
368 return getProperties(regKey,fileName,false,"",false);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
369 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
370
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
371 @Override
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
372 public Properties getProperties(String regKey,String fileName,
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
373 boolean createFile, String header) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
374 return getProperties(regKey,fileName,false,"",false);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
375 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
376
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
377 @Override
22
e067ee54f638 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 21
diff changeset
378 public Properties getProperties(String regKey,
e067ee54f638 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 21
diff changeset
379 String fileName,
e067ee54f638 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 21
diff changeset
380 boolean createFile,
e067ee54f638 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 21
diff changeset
381 String header,
e067ee54f638 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 21
diff changeset
382 boolean reloadIfLoaded) {
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
383
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
384 if (!registry.containsKey(regKey) || reloadIfLoaded) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
385
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
386 FileInputStream in = null;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
387 Properties props = new Properties();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
388 headers.put(regKey, header);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
389
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
390 try {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
391 in = new FileInputStream(settingsDirectory()
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
392 + fileName);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
393 props.load(in);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
394
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
395 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
396 catch (FileNotFoundException fnfe) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
397
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
398 if (createFile) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
399 Log.i(TAG," Information Message: " + fnfe.getMessage()
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
400 + ". The file " + fileName + " will"
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
401 + " be created for first time use.");
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
402
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
403 registry.put(regKey,props);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
404
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
405 saveSettings(regKey,header);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
406
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
407 return props;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
408
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
409 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
410 else {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
411
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
412 Log.i(TAG," Information Message: " + fnfe.getMessage()
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
413 + ".");
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
414
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
415 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
416 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
417 catch (IOException ioe) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
418 Log.w(TAG,"IO Exception accessing File "+ fileName +
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
419 " for the following reason : "
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
420 + ioe.getMessage());
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
421 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
422 catch (SecurityException se) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 22
diff changeset
423 Log.w(TAG,"Security Exception for file "+ fileName
20
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
424 + ". This file can not be accessed because : "
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
425 + se.getMessage());
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
426 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
427
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
428 registry.put(regKey,props);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
429
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
430 return props;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
431 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
432 else {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
433 return (Properties)registry.get(regKey);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
434 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
435 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
436
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
437 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
438 * Returns the setting from the given key of the global properties or the
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
439 * default passed if the property does not exist.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
440 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
441 * @param key
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
442 * @param def
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
443 * @return
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
444 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
445 @Override
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
446 public String getProperty(String key, String def) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
447 if (settings.containsKey(key))
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
448 return settings.getProperty(key);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
449 else
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
450 return def;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
451 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
452
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
453 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
454 * Returns the setting from the given key of the global properties.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
455 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
456 * @param key
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
457 * @return
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
458 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
459 @Override
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
460 public String getProperty(String key) {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
461 return settings.getProperty(key);
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
462 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
463
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
464 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
465 * Private helper to return the full path to the settings file
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
466 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
467 * @return
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
468 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
469 private String settingsFile() {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
470 return settingsDirectory() + "tn5250jstartup.cfg";
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
471
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
472 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
473
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
474 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
475 * Private helper to return the settings directory
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
476 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
477 * @return
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
478 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
479 private String settingsDirectory() {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
480 return settingsFolder() + File.separator;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
481
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
482 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
483
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
484 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
485 * Private helper to return the settings folder path
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
486 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
487 * @return
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
488 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
489 private String settingsFolder() {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
490 return TerminalView.android_home_directory + File.separator + TN5250J_FOLDER;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
491
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
492 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
493
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
494 /**
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
495 * Not sure yet so be careful using this.
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
496 *
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
497 * @return
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
498 */
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
499 public ClassLoader getClassLoader() {
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
500
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
501 ClassLoader loader = GlobalConfigure.class.getClassLoader();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
502 if (loader == null)
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
503 loader = ClassLoader.getSystemClassLoader();
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
504
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
505 return loader;
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
506 }
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
507
69a407d33146 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
508 }