@Test public void testExtractProperties() { QueryStringToPropertiesExtractor extractor = new CitationToPropertiesConverter(); Property expectedPublication = new Property(); Property expectedDate = new Property(); Property expectedAuthors = new Property(); expectedPublication.setP("publication"); expectedPublication.setPid(expectedPublication.getP()); expectedAuthors.setP("authors"); expectedAuthors.setPid(expectedAuthors.getP()); expectedDate.setP("date"); expectedDate.setPid(expectedDate.getP()); expectedPublication.setV("Reconciliation Service"); assertThat(asList(extractor.extractProperties("Reconciliation Service")), hasItems(expectedPublication)); assertThat(asList(extractor.extractProperties("Reconciliation Service")).size(), equalTo(1)); expectedPublication.setV("Reconciliation Service"); expectedAuthors.setV("Matthew Blissett et. al."); assertThat(asList(extractor.extractProperties("Reconciliation Service [Matthew Blissett et. al.]")), hasItems(expectedPublication, expectedAuthors)); assertThat(asList(extractor.extractProperties("Reconciliation Service [Matthew Blissett et. al.]")).size(), equalTo(2)); expectedPublication.setV("Reconciliation Service"); expectedDate.setV("2014"); assertThat(asList(extractor.extractProperties("Reconciliation Service, (2014).")), hasItems(expectedPublication, expectedDate)); assertThat(asList(extractor.extractProperties("Reconciliation Service, (2014).")).size(), equalTo(2)); expectedPublication.setV("Reconciliation Service"); expectedAuthors.setV("Matthew Blissett et. al."); expectedDate.setV("2014"); assertThat(asList(extractor.extractProperties("Reconciliation Service [Matthew Blissett et. al.], (2014).")), hasItems(expectedPublication, expectedDate, expectedAuthors)); assertThat(asList(extractor.extractProperties("Reconciliation Service [Matthew Blissett et. al.], (2014).")).size(), equalTo(3)); }
@Override public Property[] extractProperties(String queryString) { queryString.replace(" ", " "); String publication = null, authors = null, date = null; if (queryString != null) { java.util.regex.Matcher m = pattern.matcher(queryString); if (m.find()) { publication = m.group(1).trim(); authors = Strings.emptyToNull(m.group(3)); date = Strings.emptyToNull(m.group(5)); } } return makeProperties(publication, authors, date); }
CitationToPropertiesConverter implements QueryStringToPropertiesExtractor { @Override public Property[] extractProperties(String queryString) { queryString.replace(" ", " "); String publication = null, authors = null, date = null; if (queryString != null) { java.util.regex.Matcher m = pattern.matcher(queryString); if (m.find()) { publication = m.group(1).trim(); authors = Strings.emptyToNull(m.group(3)); date = Strings.emptyToNull(m.group(5)); } } return makeProperties(publication, authors, date); } }
CitationToPropertiesConverter implements QueryStringToPropertiesExtractor { @Override public Property[] extractProperties(String queryString) { queryString.replace(" ", " "); String publication = null, authors = null, date = null; if (queryString != null) { java.util.regex.Matcher m = pattern.matcher(queryString); if (m.find()) { publication = m.group(1).trim(); authors = Strings.emptyToNull(m.group(3)); date = Strings.emptyToNull(m.group(5)); } } return makeProperties(publication, authors, date); }  }
CitationToPropertiesConverter implements QueryStringToPropertiesExtractor { @Override public Property[] extractProperties(String queryString) { queryString.replace(" ", " "); String publication = null, authors = null, date = null; if (queryString != null) { java.util.regex.Matcher m = pattern.matcher(queryString); if (m.find()) { publication = m.group(1).trim(); authors = Strings.emptyToNull(m.group(3)); date = Strings.emptyToNull(m.group(5)); } } return makeProperties(publication, authors, date); }  @Override Property[] extractProperties(String queryString); }
CitationToPropertiesConverter implements QueryStringToPropertiesExtractor { @Override public Property[] extractProperties(String queryString) { queryString.replace(" ", " "); String publication = null, authors = null, date = null; if (queryString != null) { java.util.regex.Matcher m = pattern.matcher(queryString); if (m.find()) { publication = m.group(1).trim(); authors = Strings.emptyToNull(m.group(3)); date = Strings.emptyToNull(m.group(5)); } } return makeProperties(publication, authors, date); }  @Override Property[] extractProperties(String queryString);  }