< prev index next >
src/com/sun/javatest/tool/ConfigManager.java
Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg
@@ -209,11 +209,10 @@
throws Command.Fault
{
return new OpenCommand(file);
}
- private static Map commandFactory;
private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(ConfigManager.class);
//--------------------------------------------------------------------------
private static class ConcurrencyCommand extends Command
@@ -877,14 +876,14 @@
public void run(CommandContext ctx) throws Fault {
InterviewParameters p = getConfig(ctx);
Question[] path = p.getPath();
if (file != null) {
- Map values = loadFile(file);
+ Map<String, String> values = loadFile(file);
for (int i = 0; i < path.length; i++) {
Question q = path[i];
- String v = (String) (values.get(q.getTag()));
+ String v = (values.get(q.getTag()));
if (v != null) {
setValue(q, v);
path = p.getPath();
}
}
@@ -965,16 +964,14 @@
sb.append(lineSep); // arguably better to do it later when printing to terminal
}
return (sb.toString());
}
- private Map loadFile(File file) throws Fault {
+ private Map<String, String> loadFile(File file) throws Fault {
try (FileInputStream fis = new FileInputStream(file);
InputStream in = new BufferedInputStream(fis)) {
- Properties props = new Properties();
- props.load(in);
- return props;
+ return com.sun.javatest.util.Properties.load(in);
}
catch (FileNotFoundException e) {
throw new Fault(i18n, "cnfg.set.cantFindFile", file);
}
catch (IOException e) {
@@ -1020,36 +1017,34 @@
}
public void run(CommandContext ctx) throws Fault {
InterviewParameters p = getConfig(ctx);
if (file != null) {
- Map values = loadFile(file);
- Set keys = values.keySet();
- Iterator it = keys.iterator();
+ Map<String, String> values = loadFile(file);
+ Set<String> keys = values.keySet();
+ Iterator<String> it = keys.iterator();
String name = null;
for (int i = 0; it.hasNext(); i++) {
- name = (String)(it.next());
+ name = it.next();
/* could do it this way to reject unknown props
String v = p.retrieveProperty(name);
if (v != null) {
p.storeProperty(name, (String)(values.get(name)));
}
*/
- p.storeProperty(name, (String)(values.get(name)));
+ p.storeProperty(name, (values.get(name)));
}
}
else {
p.storeProperty(name, value);
}
}
- private Map loadFile(File file) throws Fault {
+ private Map<String, String> loadFile(File file) throws Fault {
try (FileInputStream fis = new FileInputStream(file);
InputStream in = new BufferedInputStream(fis)) {
- Properties props = new Properties();
- props.load(in);
- return props;
+ return com.sun.javatest.util.Properties.load(in);
}
catch (FileNotFoundException e) {
throw new Fault(i18n, "cnfg.set.cantFindFile", file);
}
catch (IOException e) {
< prev index next >