NameFinderCensus90NameStream implements ObjectStream<StringList> { public StringList read() throws IOException { String line = lineStream.read(); StringList name = null; if ((line != null) && (!StringUtil.isEmpty(line))) { String name2; int pos = line.indexOf(' '); if ((pos != -1)) { String parsed = line.substring(0, pos); if ((parsed.length() > 2) && (parsed.startsWith("MC"))) { name2 = parsed.substring(0,1).toUpperCase(locale) + parsed.substring(1,2).toLowerCase(locale) + parsed.substring(2,3).toUpperCase(locale) + parsed.substring(3).toLowerCase(locale); } else { name2 = parsed.substring(0,1).toUpperCase(locale) + parsed.substring(1).toLowerCase(locale); } name = new StringList(new String[]{name2}); } } return name; } NameFinderCensus90NameStream(ObjectStream<String> lineStream);  NameFinderCensus90NameStream(InputStream in, Charset encoding); StringList read(); void reset(); void close();  }
@Test public void testParsingEnglishSample() throws IOException { ObjectStream<StringList> sampleStream = openData("census90.sample"); StringList personName = sampleStream.read(); assertNotNull(personName); assertEquals("Smith", personName.getToken(0)); personName = sampleStream.read(); assertNotNull(personName); assertEquals("Johnson", personName.getToken(0)); personName = sampleStream.read(); assertNotNull(personName); assertEquals("Williams", personName.getToken(0)); personName = sampleStream.read(); assertNotNull(personName); assertEquals("Jones", personName.getToken(0)); personName = sampleStream.read(); assertNotNull(personName); assertEquals("Brown", personName.getToken(0)); personName = sampleStream.read(); assertNotNull(personName); assertEquals("Mary", personName.getToken(0)); personName = sampleStream.read(); assertNotNull(personName); assertEquals("Patricia", personName.getToken(0)); personName = sampleStream.read(); assertNotNull(personName); assertEquals("Linda", personName.getToken(0)); personName = sampleStream.read(); assertNotNull(personName); assertEquals("Barbara", personName.getToken(0)); personName = sampleStream.read(); assertNotNull(personName); assertEquals("Elizabeth", personName.getToken(0)); personName = sampleStream.read(); assertNotNull(personName); assertEquals("James", personName.getToken(0)); personName = sampleStream.read(); assertNotNull(personName); assertEquals("John", personName.getToken(0)); personName = sampleStream.read(); assertNotNull(personName); assertEquals("Robert", personName.getToken(0)); personName = sampleStream.read(); assertNotNull(personName); assertEquals("Michael", personName.getToken(0)); personName = sampleStream.read(); assertNotNull(personName); assertEquals("William", personName.getToken(0)); personName = sampleStream.read(); assertNull(personName); }