@Test public void testReadMultimap() throws Exception{ expect(reader.readLine()).andReturn(LINE_1); expect(reader.readLine()).andReturn(LINE_2); expect(reader.readLine()).andReturn(null); replay(reader); Map<String, List<String>> multimap = multimapFileReader.readMultimap(); verify(reader); assertEquals(2, multimap.size()); List<String> line1Values = multimap.get("term1"); assertEquals("term111", line1Values.get(0)); assertEquals("term11", line1Values.get(1)); assertEquals("term1", line1Values.get(2)); List<String> line2Values = multimap.get("term2"); assertEquals("term222", line2Values.get(0)); assertEquals("term22", line2Values.get(1)); assertEquals("term2", line2Values.get(2)); }
public Map<String, List<String>> readMultimap() throws IOException { Map<String, List<String>> multimap = new HashMap<String, List<String>>(); String line = reader.readLine(); while (line != null) { String[] keyValue = line.split("="); String term = keyValue[0]; String[] values = keyValue[1].split("\\|"); List<String> valueList = new ArrayList<String>(); for (String hypernym : values) valueList.add(hypernym); multimap.put(term, valueList); line = reader.readLine(); } return multimap; }
MultimapFileReader extends Reader { public Map<String, List<String>> readMultimap() throws IOException { Map<String, List<String>> multimap = new HashMap<String, List<String>>(); String line = reader.readLine(); while (line != null) { String[] keyValue = line.split("="); String term = keyValue[0]; String[] values = keyValue[1].split("\\|"); List<String> valueList = new ArrayList<String>(); for (String hypernym : values) valueList.add(hypernym); multimap.put(term, valueList); line = reader.readLine(); } return multimap; } }
MultimapFileReader extends Reader { public Map<String, List<String>> readMultimap() throws IOException { Map<String, List<String>> multimap = new HashMap<String, List<String>>(); String line = reader.readLine(); while (line != null) { String[] keyValue = line.split("="); String term = keyValue[0]; String[] values = keyValue[1].split("\\|"); List<String> valueList = new ArrayList<String>(); for (String hypernym : values) valueList.add(hypernym); multimap.put(term, valueList); line = reader.readLine(); } return multimap; } MultimapFileReader(BufferedReader reader); }
MultimapFileReader extends Reader { public Map<String, List<String>> readMultimap() throws IOException { Map<String, List<String>> multimap = new HashMap<String, List<String>>(); String line = reader.readLine(); while (line != null) { String[] keyValue = line.split("="); String term = keyValue[0]; String[] values = keyValue[1].split("\\|"); List<String> valueList = new ArrayList<String>(); for (String hypernym : values) valueList.add(hypernym); multimap.put(term, valueList); line = reader.readLine(); } return multimap; } MultimapFileReader(BufferedReader reader); Map<String, List<String>> readMultimap(); @Override void close(); @Override int read(char[] cbuf, int off, int len); }
MultimapFileReader extends Reader { public Map<String, List<String>> readMultimap() throws IOException { Map<String, List<String>> multimap = new HashMap<String, List<String>>(); String line = reader.readLine(); while (line != null) { String[] keyValue = line.split("="); String term = keyValue[0]; String[] values = keyValue[1].split("\\|"); List<String> valueList = new ArrayList<String>(); for (String hypernym : values) valueList.add(hypernym); multimap.put(term, valueList); line = reader.readLine(); } return multimap; } MultimapFileReader(BufferedReader reader); Map<String, List<String>> readMultimap(); @Override void close(); @Override int read(char[] cbuf, int off, int len);  }