diff --git a/src/main/java/org/jabref/logic/importer/fileformat/MedlineImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/MedlineImporter.java index 741f758d0e6..15eeac08b54 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/MedlineImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/MedlineImporter.java @@ -41,7 +41,6 @@ import org.jabref.model.entry.types.StandardEntryType; import org.jabref.model.strings.StringUtil; -import com.google.common.base.Joiner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,10 +56,6 @@ public class MedlineImporter extends Importer implements Parser { private static final Locale ENGLISH = Locale.ENGLISH; - private static String join(List list, String string) { - return Joiner.on(string).join(list); - } - @Override public String getName() { return "Medline/PubMed"; @@ -228,14 +223,14 @@ private void parseBookDocument(XMLStreamReader reader, Map fields // populate multiple occurrence fields if (!sectionTitleList.isEmpty()) { - fields.put(new UnknownField("sections"), join(sectionTitleList, "; ")); + fields.put(new UnknownField("sections"), String.join("; ", sectionTitleList)); } addKeywords(fields, keywordList); if (!publicationTypeList.isEmpty()) { - fields.put(new UnknownField("pubtype"), join(publicationTypeList, ", ")); + fields.put(new UnknownField("pubtype"), String.join(", ", publicationTypeList)); } if (!articleTitleList.isEmpty()) { - fields.put(new UnknownField("article"), join(articleTitleList, ", ")); + fields.put(new UnknownField("article"), String.join(", ", articleTitleList)); } } @@ -316,11 +311,11 @@ private void parseBookInformation(XMLStreamReader reader, Map fie } if (!isbnList.isEmpty()) { - fields.put(StandardField.ISBN, join(isbnList, ", ")); + fields.put(StandardField.ISBN, String.join(", ", isbnList)); } if (!titleList.isEmpty()) { - putIfValueNotNull(fields, StandardField.TITLE, join(titleList, " ")); + putIfValueNotNull(fields, StandardField.TITLE, String.join(" ", titleList)); } } @@ -538,14 +533,14 @@ private void parseMedlineCitation(XMLStreamReader reader, Map fie // populate multiple occurrence fields if (!citationSubsets.isEmpty()) { - fields.put(new UnknownField("citation-subset"), join(citationSubsets, ", ")); + fields.put(new UnknownField("citation-subset"), String.join(", ", citationSubsets)); } addMeshHeading(fields, meshHeadingList); addPersonalNames(fields, personalNameSubjectList); addOtherId(fields, otherIdList); addKeywords(fields, keywordList); if (!spaceFlightMissionList.isEmpty()) { - fields.put(new UnknownField("space-flight-mission"), join(spaceFlightMissionList, ", ")); + fields.put(new UnknownField("space-flight-mission"), String.join(", ", spaceFlightMissionList)); } addInvestigators(fields, investigatorList); addNotes(fields, generalNoteList); @@ -679,7 +674,7 @@ private void parseGeneSymbolList(XMLStreamReader reader, Map fiel } if (!geneSymbols.isEmpty()) { - fields.put(new UnknownField("gene-symbols"), join(geneSymbols, ", ")); + fields.put(new UnknownField("gene-symbols"), String.join(", ", geneSymbols)); } } @@ -704,7 +699,7 @@ private void parseChemicalList(XMLStreamReader reader, Map fields } } - fields.put(new UnknownField("chemicals"), join(chemicalNames, ", ")); + fields.put(new UnknownField("chemicals"), String.join(", ", chemicalNames)); } private void parseMedlineJournalInfo(XMLStreamReader reader, Map fields, String startElement) @@ -789,7 +784,7 @@ private void parseArticleInformation(XMLStreamReader reader, Map } if (!titleList.isEmpty()) { - fields.put(StandardField.TITLE, StringUtil.stripBrackets(join(titleList, " "))); + fields.put(StandardField.TITLE, StringUtil.stripBrackets(String.join(" ", titleList))); } } @@ -908,7 +903,7 @@ private void addNotes(Map fields, List generalNoteList) { } if (!notes.isEmpty()) { - fields.put(StandardField.NOTE, join(notes, ", ")); + fields.put(StandardField.NOTE, String.join(", ", notes)); } } @@ -932,21 +927,21 @@ private void addInvestigators(Map fields, List inve } if (!affiliationInfos.isEmpty()) { - fields.put(new UnknownField("affiliation"), join(affiliationInfos, ", ")); + fields.put(new UnknownField("affiliation"), String.join(", ", affiliationInfos)); } - fields.put(new UnknownField("investigator"), join(investigatorNames, " and ")); + fields.put(new UnknownField("investigator"), String.join(" and ", investigatorNames)); } } private void addKeywords(Map fields, List keywordList) { // Check whether MeshHeadingList exists or not if (fields.get(StandardField.KEYWORDS) == null) { - fields.put(StandardField.KEYWORDS, join(keywordList, KEYWORD_SEPARATOR)); + fields.put(StandardField.KEYWORDS, String.join(KEYWORD_SEPARATOR, keywordList)); } else { if (!keywordList.isEmpty()) { // if it exists, combine the MeshHeading with the keywords - String result = join(keywordList, "; "); + String result = String.join("; ", keywordList); result = fields.get(StandardField.KEYWORDS) + KEYWORD_SEPARATOR + result; fields.put(StandardField.KEYWORDS, result); } @@ -975,7 +970,7 @@ private void addPersonalNames(Map fields, List fields, List meshHea keywords.add(result.toString()); } - fields.put(StandardField.KEYWORDS, join(keywords, KEYWORD_SEPARATOR)); + fields.put(StandardField.KEYWORDS, String.join(KEYWORD_SEPARATOR, keywords)); } } @@ -1065,7 +1060,7 @@ private void addAbstract(XMLStreamReader reader, Map fields, Stri } if (!abstractTextList.isEmpty()) { - fields.put(StandardField.ABSTRACT, join(abstractTextList, " ")); + fields.put(StandardField.ABSTRACT, String.join(" ", abstractTextList)); } } @@ -1170,7 +1165,7 @@ private void handleAuthorList(XMLStreamReader reader, Map fields, } } - fields.put(StandardField.AUTHOR, join(authorNames, " and ")); + fields.put(StandardField.AUTHOR, String.join(" and ", authorNames)); } private void parseAuthor(XMLStreamReader reader, List authorNames) throws XMLStreamException { diff --git a/src/test/java/org/jabref/logic/importer/fileformat/MedlineImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/MedlineImporterTest.java index b20effa34aa..79044243f87 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/MedlineImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/MedlineImporterTest.java @@ -8,10 +8,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals; /** - * Articles in the medline format can be downloaded from http://www.ncbi.nlm.nih.gov/pubmed/. 1. Search for a term and - * make sure you have selected the PubMed database 2. Select the results you want to export by checking their checkboxes - * 3. Press on the 'Send to' drop down menu on top of the search results 4. Select 'File' as Destination and 'XML' as - * Format 5. Press 'Create File' to download your search results in a medline xml file + * Articles in the medline format can be downloaded from http://www.ncbi.nlm.nih.gov/pubmed/. + *
    + *
  1. Search for a term and make sure you have selected the PubMed database.
  2. + *
  3. Select the results you want to export by checking their checkboxes.
  4. + *
  5. Press on the 'Send to' drop down menu on top of the search results.
  6. + *
  7. Select 'File' as Destination and 'XML' as Format.
  8. + *
  9. Press 'Create File' to download your search results in a medline xml file.
  10. + *
*/ public class MedlineImporterTest {