@Test public void extractTagContents_ManyTags() { String idValue1 = "sds232ewdxsc"; String idValue2 = "sds232ewdxsc"; String idValue3 = "sds232ewdxsc2"; String message = "<id>" + idValue1 + "</id>\n"; message += "<id>" + idValue2 + "</id>"; message += "<id>" + idValue3 + "</id>"; assertExtractedIds(extractor.extractTagContents(message, "id"), idValue1, idValue2, idValue3); }
public List<String> extractTagContents(String message, String tagName) { List<String> ids = Lists.newArrayList(); Matcher m = createMatcher(message, tagName); while(m.find()) { String tagWithValue = m.group(); String value = extractValue(tagWithValue, tagName); ids.add(value); } return ids; }
XmlTagContentExtractor { public List<String> extractTagContents(String message, String tagName) { List<String> ids = Lists.newArrayList(); Matcher m = createMatcher(message, tagName); while(m.find()) { String tagWithValue = m.group(); String value = extractValue(tagWithValue, tagName); ids.add(value); } return ids; } }
XmlTagContentExtractor { public List<String> extractTagContents(String message, String tagName) { List<String> ids = Lists.newArrayList(); Matcher m = createMatcher(message, tagName); while(m.find()) { String tagWithValue = m.group(); String value = extractValue(tagWithValue, tagName); ids.add(value); } return ids; }  }
XmlTagContentExtractor { public List<String> extractTagContents(String message, String tagName) { List<String> ids = Lists.newArrayList(); Matcher m = createMatcher(message, tagName); while(m.find()) { String tagWithValue = m.group(); String value = extractValue(tagWithValue, tagName); ids.add(value); } return ids; }  List<String> extractTagContents(String message, String tagName); String extractFirstTagContent(String message, String tagName); }
XmlTagContentExtractor { public List<String> extractTagContents(String message, String tagName) { List<String> ids = Lists.newArrayList(); Matcher m = createMatcher(message, tagName); while(m.find()) { String tagWithValue = m.group(); String value = extractValue(tagWithValue, tagName); ids.add(value); } return ids; }  List<String> extractTagContents(String message, String tagName); String extractFirstTagContent(String message, String tagName);  }