@Test public void testSplit() throws Exception { SplitCommaReverseService service = new SplitCommaReverseService(); List<String> res = service.split(FULL); Assert.assertNotNull(res); Assert.assertEquals(3, res.size()); Assert.assertEquals(PART0, res.get(0)); Assert.assertEquals(PART1, res.get(1)); Assert.assertEquals(PART2, res.get(2)); }
public List<String> split(String location) { List<String> res = new ArrayList<String>(); String remaining = location; for (int pos = remaining.indexOf(','); pos >= 0; pos = remaining.indexOf(',')) { String part = remaining.substring(0, pos).trim(); if (part.length() > 0) { res.add(0, part); } remaining = remaining.substring(pos + 1); } remaining = remaining.trim(); if (remaining.length() > 0) { res.add(0, remaining.trim()); } return res; }
SplitCommaReverseService implements SplitGeocoderStringService { public List<String> split(String location) { List<String> res = new ArrayList<String>(); String remaining = location; for (int pos = remaining.indexOf(','); pos >= 0; pos = remaining.indexOf(',')) { String part = remaining.substring(0, pos).trim(); if (part.length() > 0) { res.add(0, part); } remaining = remaining.substring(pos + 1); } remaining = remaining.trim(); if (remaining.length() > 0) { res.add(0, remaining.trim()); } return res; } }
SplitCommaReverseService implements SplitGeocoderStringService { public List<String> split(String location) { List<String> res = new ArrayList<String>(); String remaining = location; for (int pos = remaining.indexOf(','); pos >= 0; pos = remaining.indexOf(',')) { String part = remaining.substring(0, pos).trim(); if (part.length() > 0) { res.add(0, part); } remaining = remaining.substring(pos + 1); } remaining = remaining.trim(); if (remaining.length() > 0) { res.add(0, remaining.trim()); } return res; }  }
SplitCommaReverseService implements SplitGeocoderStringService { public List<String> split(String location) { List<String> res = new ArrayList<String>(); String remaining = location; for (int pos = remaining.indexOf(','); pos >= 0; pos = remaining.indexOf(',')) { String part = remaining.substring(0, pos).trim(); if (part.length() > 0) { res.add(0, part); } remaining = remaining.substring(pos + 1); } remaining = remaining.trim(); if (remaining.length() > 0) { res.add(0, remaining.trim()); } return res; }  List<String> split(String location); String combine(List<String> matchedStrings); }
SplitCommaReverseService implements SplitGeocoderStringService { public List<String> split(String location) { List<String> res = new ArrayList<String>(); String remaining = location; for (int pos = remaining.indexOf(','); pos >= 0; pos = remaining.indexOf(',')) { String part = remaining.substring(0, pos).trim(); if (part.length() > 0) { res.add(0, part); } remaining = remaining.substring(pos + 1); } remaining = remaining.trim(); if (remaining.length() > 0) { res.add(0, remaining.trim()); } return res; }  List<String> split(String location); String combine(List<String> matchedStrings);  }