DemoBernoulli extends AbstractConnectedDevice implements Runnable { protected static void populateMap(Map<String, String> numerics, Map<String, String> waveforms) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(DemoBernoulli.class.getResourceAsStream("bernoulli.map"))); String line = null; while (null != (line = br.readLine())) { line = line.trim(); if ('#' != line.charAt(0)) { String v[] = line.split("\t"); if (v.length < 3) { log.warn("Bad line in bernoulli.map:" + line); } else { v[2] = v[2].trim(); String value = getValue(v[1]); if (null == value) { log.warn("Cannot find value for " + v[1]); continue; } if ("W".equals(v[2])) { if (waveforms.containsKey(v[0])) { throw new RuntimeException("Duplicate values for waveform " + v[0] + " " + waveforms.get(v[0]) + " and " + value); } waveforms.put(v[0], value); } else if ("N".equals(v[2])) { if (numerics.containsKey(v[0])) { throw new RuntimeException("Duplicate values for numeric " + v[0] + " " + numerics.get(v[0]) + " and " + value); } numerics.put(v[0], value); } else { log.warn("Unknown field type=" + v[2]); } } } } } DemoBernoulli(Subscriber subscriber, Publisher publisher, EventLoop eventLoop); void init(); @Override boolean connect(String str); @Override void run(); @Override void disconnect(); @Override void shutdown();  }
@Test public void testMappingFileContents() throws Exception { Map<String, String> numerics = new HashMap<String, String>(); Map<String, String> waveforms = new HashMap<String, String>(); DemoBernoulli.populateMap(numerics, waveforms); System.out.println(numerics); System.out.println(waveforms); }