< 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,219 **** 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 --- 209,218 ----
*** 877,890 **** public void run(CommandContext ctx) throws Fault { InterviewParameters p = getConfig(ctx); Question[] path = p.getPath(); if (file != null) { ! Map values = loadFile(file); for (int i = 0; i < path.length; i++) { Question q = path[i]; ! String v = (String) (values.get(q.getTag())); if (v != null) { setValue(q, v); path = p.getPath(); } } --- 876,889 ---- public void run(CommandContext ctx) throws Fault { InterviewParameters p = getConfig(ctx); Question[] path = p.getPath(); if (file != null) { ! Map<String, String> values = loadFile(file); for (int i = 0; i < path.length; i++) { Question q = path[i]; ! String v = (values.get(q.getTag())); if (v != null) { setValue(q, v); path = p.getPath(); } }
*** 965,980 **** sb.append(lineSep); // arguably better to do it later when printing to terminal } return (sb.toString()); } ! private Map 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; } catch (FileNotFoundException e) { throw new Fault(i18n, "cnfg.set.cantFindFile", file); } catch (IOException e) { --- 964,977 ---- sb.append(lineSep); // arguably better to do it later when printing to terminal } return (sb.toString()); } ! private Map<String, String> loadFile(File file) throws Fault { try (FileInputStream fis = new FileInputStream(file); InputStream in = new BufferedInputStream(fis)) { ! return com.sun.javatest.util.Properties.load(in); } catch (FileNotFoundException e) { throw new Fault(i18n, "cnfg.set.cantFindFile", file); } catch (IOException e) {
*** 1020,1055 **** } 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(); String name = null; for (int i = 0; it.hasNext(); i++) { ! name = (String)(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))); } } else { p.storeProperty(name, value); } } ! private Map 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; } catch (FileNotFoundException e) { throw new Fault(i18n, "cnfg.set.cantFindFile", file); } catch (IOException e) { --- 1017,1050 ---- } public void run(CommandContext ctx) throws Fault { InterviewParameters p = getConfig(ctx); if (file != null) { ! 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 = 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, (values.get(name))); } } else { p.storeProperty(name, value); } } ! private Map<String, String> loadFile(File file) throws Fault { try (FileInputStream fis = new FileInputStream(file); InputStream in = new BufferedInputStream(fis)) { ! 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 >