Verified Owner
Top Description Fields Constructors Methods
org.jabref.logic.importer.fileformat

public Class MedlineImporter

extends Importer
implements Parser
Class Inheritance
All Implemented Interfaces
org.jabref.logic.importer.Parser
Imports
java.io.BufferedReader, .IOException, .InputStream, .InputStreamReader, .Reader, java.nio.charset.StandardCharsets, java.util.ArrayList, .HashMap, .List, .Locale, .Map, .Optional, javax.xml.stream.XMLInputFactory, .XMLStreamConstants, .XMLStreamException, .XMLStreamReader, org.jabref.logic.importer.Importer, .ParseException, .Parser, .ParserResult, org.jabref.logic.importer.fileformat.medline.ArticleId, .Investigator, .MeshHeading, .OtherId, .PersonalNameSubject, org.jabref.logic.importer.util.MathMLParser, org.jabref.logic.l10n.Localization, org.jabref.logic.util.StandardFileType, org.jabref.logic.util.strings.StringUtil, org.jabref.model.entry.BibEntry, .Date, .Month, org.jabref.model.entry.field.Field, .FieldFactory, .StandardField, .UnknownField, org.jabref.model.entry.types.StandardEntryType, org.jspecify.annotations.NonNull, org.slf4j.Logger, .LoggerFactory

Importer for the Medline/Pubmed format.

check here for details on the format https://www.nlm.nih.gov/bsd/licensee/elements_descriptions.html

Field Summary

Modifier and TypeField and Description
private static final Locale
private static final String
private static final Logger
private final XMLInputFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
addAbstract(XMLStreamReader reader, Map<Field, String> fields, String startElement)

private void
addArticleIdList(Map<Field, String> fields, List<ArticleId> articleIdList)

private void
addInvestigators(Map<Field, String> fields, List<Investigator> investigatorList)

private void
addKeywords(Map<Field, String> fields, List<String> keywordList)

private void
addMeshHeading(Map<Field, String> fields, List<MeshHeading> meshHeadingList)

private void
addNotes(Map<Field, String> fields, List<String> generalNoteList)

private void
addOtherId(Map<Field, String> fields, List<OtherId> otherIdList)

private void
addPagination(XMLStreamReader reader, Map<Field, String> fields, String startElement)

private void
addPersonalNames(Map<Field, String> fields, List<PersonalNameSubject> personalNameSubjectList)

private void
addPubDate(XMLStreamReader reader, Map<Field, String> fields, String startElement)

private String
extractYear(String medlineDate)

private String
fixPageRange(String pageRange)

Convert medline page ranges from short form to full form.

public String
getDescription()

Implements abstract org.jabref.logic.importer.Importer.getDescription.

Returns the description of the import format.

public StandardFileType
getFileType()

Implements abstract org.jabref.logic.importer.Importer.getFileType.

Returns the type of files that this importer can read

public String
getId()

Implements abstract org.jabref.logic.importer.Importer.getId.

Returns a slug, which identifies this importer.

public String
getName()

Implements abstract org.jabref.logic.importer.Importer.getName.

Returns the name of this import format.

private void
handleAbstractTextElement(XMLStreamReader reader, List<String> textList, String startElement)

Handles text entities of abstracts that can have inner tags such as <i>, <b> etc. We ignore the tags and return only the characters present in the enclosing parent element.

private void
handleAuthorList(XMLStreamReader reader, Map<Field, String> fields, String startElement)

private void
private void
handleText(XMLStreamReader reader, List<String> textList, String startElement, StringBuilder result)

private void
handleTextElement(XMLStreamReader reader, List<String> textList, String startElement)

Handles text entities that can have inner tags such as <i>, <b> etc. We ignore the tags and return only the characters present in the enclosing parent element.

public ParserResult
importDatabase(@NonNull BufferedReader input)

Implements abstract org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the source.

private boolean
private boolean
public boolean
isRecognizedFormat(@NonNull Reader reader)

Overrides org.jabref.logic.importer.Importer.isRecognizedFormat.

#isRecognizedFormat(BufferedReader) without the requirement to reset

public boolean
isRecognizedFormat(@NonNull BufferedReader reader)

Overrides org.jabref.logic.importer.Importer.isRecognizedFormat.

Check whether the source is in the correct format for this importer.

private boolean
private void
parseArticle(XMLStreamReader reader, List<BibEntry> bibItems, String startElement)

private void
private void
parseAuthor(XMLStreamReader reader, List<String> authorNames)

private void
parseBookArticle(XMLStreamReader reader, List<BibEntry> bibItems, String startElement)

private void
parseBookDocument(XMLStreamReader reader, Map<Field, String> fields, String startElement)

private void
parseBookInformation(XMLStreamReader reader, Map<Field, String> fields, String startElement)

private void
parseChemicalList(XMLStreamReader reader, Map<Field, String> fields, String startElement)

private void
parseCollectiveName(XMLStreamReader reader, List<String> collectiveNames)

private void
parseDate(XMLStreamReader reader, Map<Field, String> fields, String startElement)

public List<BibEntry>
private void
private void
parseGeneSymbolList(XMLStreamReader reader, Map<Field, String> fields, String startElement)

private void
parseInvestigator(XMLStreamReader reader, List<Investigator> investigatorList, String startElement)

private void
private StringBuilder
private void
parseMedlineCitation(XMLStreamReader reader, Map<Field, String> fields, String startElement)

private void
private void
parseMeshHeading(XMLStreamReader reader, List<MeshHeading> meshHeadingList, String startElement)

private void
parsePersonalNameSubject(XMLStreamReader reader, List<PersonalNameSubject> personalNameSubjectList, String startElement)

private void
parsePubmedData(XMLStreamReader reader, Map<Field, String> fields, String startElement)

private void
parseSections(XMLStreamReader reader, List<String> sectionTitleList)

private void
putIfValueNotNull(Map<Field, String> fields, Field field, String value)

Inherited from org.jabref.logic.importer.Importer:
compareToequalsgetCharsetgetReadergetReaderhashCodeimportDatabaseimportDatabaseisRecognizedFormatisRecognizedFormatsupportsFileExtensiontoString

Field Detail

ENGLISHback to summary
private static final Locale ENGLISH
KEYWORD_SEPARATORback to summary
private static final String KEYWORD_SEPARATOR
LOGGERback to summary
private static final Logger LOGGER

Hides org.jabref.logic.importer.Importer.LOGGER.

xmlInputFactoryback to summary
private final XMLInputFactory xmlInputFactory

Constructor Detail

MedlineImporterback to summary
public MedlineImporter()

Method Detail

addAbstractback to summary
private void addAbstract(XMLStreamReader reader, Map<Field, String> fields, String startElement) throws XMLStreamException
addArticleIdListback to summary
private void addArticleIdList(Map<Field, String> fields, List<ArticleId> articleIdList)
addInvestigatorsback to summary
private void addInvestigators(Map<Field, String> fields, List<Investigator> investigatorList)
addKeywordsback to summary
private void addKeywords(Map<Field, String> fields, List<String> keywordList)
addMeshHeadingback to summary
private void addMeshHeading(Map<Field, String> fields, List<MeshHeading> meshHeadingList)
addNotesback to summary
private void addNotes(Map<Field, String> fields, List<String> generalNoteList)
addOtherIdback to summary
private void addOtherId(Map<Field, String> fields, List<OtherId> otherIdList)
addPaginationback to summary
private void addPagination(XMLStreamReader reader, Map<Field, String> fields, String startElement) throws XMLStreamException
addPersonalNamesback to summary
private void addPersonalNames(Map<Field, String> fields, List<PersonalNameSubject> personalNameSubjectList)
addPubDateback to summary
private void addPubDate(XMLStreamReader reader, Map<Field, String> fields, String startElement) throws XMLStreamException
extractYearback to summary
private String extractYear(String medlineDate)
fixPageRangeback to summary
private String fixPageRange(String pageRange)

Convert medline page ranges from short form to full form. Medline reports page ranges in a shorthand format. The last page is reported using only the digits which differ from the first page. i.e. 12345-51 refers to the actual range 12345-12351

getDescriptionback to summary
public String getDescription()

Implements abstract org.jabref.logic.importer.Importer.getDescription.

Doc from org.jabref.logic.importer.Importer.getDescription.

Returns the description of the import format.

The description should specify
what kind of entries from what sources and based on what specification it is able to import

by what criteria it isRecognizedFormat(BufferedReader) recognizes an import format

Annotations
@Override
getFileTypeback to summary
public StandardFileType getFileType()

Implements abstract org.jabref.logic.importer.Importer.getFileType.

Doc from org.jabref.logic.importer.Importer.getFileType.

Returns the type of files that this importer can read

Annotations
@Override
getIdback to summary
public String getId()

Implements abstract org.jabref.logic.importer.Importer.getId.

Doc from org.jabref.logic.importer.Importer.getId.

Returns a slug, which identifies this importer. Used, for example, to identify the importer in CLI.

Typically, this name should be short, in English, and should not contain special characters like #, %, etc.

Annotations
@Override
getNameback to summary
public String getName()

Implements abstract org.jabref.logic.importer.Importer.getName.

Doc from org.jabref.logic.importer.Importer.getName.

Returns the name of this import format. Typically, this is a string that denotes file type or format. It can also be localized, like "XMP-annotated PDF".

Annotations
@Override
handleAbstractTextElementback to summary
private void handleAbstractTextElement(XMLStreamReader reader, List<String> textList, String startElement) throws XMLStreamException

Handles text entities of abstracts that can have inner tags such as <i>, <b> etc. We ignore the tags and return only the characters present in the enclosing parent element.

handleAuthorListback to summary
private void handleAuthorList(XMLStreamReader reader, Map<Field, String> fields, String startElement) throws XMLStreamException
handleElocationIdback to summary
private void handleElocationId(Map<Field, String> fields, XMLStreamReader reader, String eidType)
handleTextback to summary
private void handleText(XMLStreamReader reader, List<String> textList, String startElement, StringBuilder result) throws XMLStreamException
handleTextElementback to summary
private void handleTextElement(XMLStreamReader reader, List<String> textList, String startElement) throws XMLStreamException

Handles text entities that can have inner tags such as <i>, <b> etc. We ignore the tags and return only the characters present in the enclosing parent element.

importDatabaseback to summary
public ParserResult importDatabase(@NonNull BufferedReader input) throws IOException

Implements abstract org.jabref.logic.importer.Importer.importDatabase.

Doc from org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the source.

This method can be called in two different contexts - either when importing in a specified format, or when importing in unknown format. In the latter case, JabRef cycles through all available import formats. No error messages or feedback is displayed from individual import formats in this case.

If importing in a specified format and an empty library is returned, JabRef reports that no entries were found.

If your format is binary-based (PDF, ZIP-based, or others), then you should not solely override this method. For binary formats do this:

  1. Throw UnsupportedOperationException in this method.
  2. Override the method Importer#importDatabase(Path). Example of this workaround is in: org.jabref.logic.importer.fileformat.pdf.PdfImporter.
Annotations
@Override
isCharacterXMLEventback to summary
private boolean isCharacterXMLEvent(XMLStreamReader reader)
isEndXMLEventback to summary
private boolean isEndXMLEvent(XMLStreamReader reader)
isRecognizedFormatback to summary
public boolean isRecognizedFormat(@NonNull Reader reader) throws IOException

Overrides org.jabref.logic.importer.Importer.isRecognizedFormat.

Doc from org.jabref.logic.importer.Importer.isRecognizedFormat.

#isRecognizedFormat(BufferedReader) without the requirement to reset

Annotations
@Override
isRecognizedFormatback to summary
public boolean isRecognizedFormat(@NonNull BufferedReader reader) throws IOException

Overrides org.jabref.logic.importer.Importer.isRecognizedFormat.

Doc from org.jabref.logic.importer.Importer.isRecognizedFormat.

Check whether the source is in the correct format for this importer.

All implementations need to reset the input stream to the beginning again - to enable importing at subsequent calls.

The effect of this method is primarily to avoid unnecessary processing of files when searching for a suitable import format. If this method returns false, the import routine will move on to the next import format.

Thus, the correct behavior is to return false if it is certain that the file is not of the suitable type, and true otherwise. Returning true is the safe choice if not certain.

Annotations
@Override
isStartXMLEventback to summary
private boolean isStartXMLEvent(XMLStreamReader reader)
parseArticleback to summary
private void parseArticle(XMLStreamReader reader, List<BibEntry> bibItems, String startElement) throws XMLStreamException
parseArticleInformationback to summary
private void parseArticleInformation(XMLStreamReader reader, Map<Field, String> fields) throws XMLStreamException
parseAuthorback to summary
private void parseAuthor(XMLStreamReader reader, List<String> authorNames) throws XMLStreamException
parseBookArticleback to summary
private void parseBookArticle(XMLStreamReader reader, List<BibEntry> bibItems, String startElement) throws XMLStreamException
parseBookDocumentback to summary
private void parseBookDocument(XMLStreamReader reader, Map<Field, String> fields, String startElement) throws XMLStreamException
parseBookInformationback to summary
private void parseBookInformation(XMLStreamReader reader, Map<Field, String> fields, String startElement) throws XMLStreamException
parseChemicalListback to summary
private void parseChemicalList(XMLStreamReader reader, Map<Field, String> fields, String startElement) throws XMLStreamException
parseCollectiveNameback to summary
private void parseCollectiveName(XMLStreamReader reader, List<String> collectiveNames) throws XMLStreamException
parseDateback to summary
private void parseDate(XMLStreamReader reader, Map<Field, String> fields, String startElement) throws XMLStreamException
parseEntriesback to summary
public List<BibEntry> parseEntries(InputStream inputStream) throws ParseException

Implements org.jabref.logic.importer.Parser.parseEntries.

Annotations
@Override
parseForeNameback to summary
private void parseForeName(XMLStreamReader reader, StringBuilder authorName) throws XMLStreamException
parseGeneSymbolListback to summary
private void parseGeneSymbolList(XMLStreamReader reader, Map<Field, String> fields, String startElement) throws XMLStreamException
parseInvestigatorback to summary
private void parseInvestigator(XMLStreamReader reader, List<Investigator> investigatorList, String startElement) throws XMLStreamException
parseJournalback to summary
private void parseJournal(XMLStreamReader reader, Map<Field, String> fields) throws XMLStreamException
parseLastNameback to summary
private StringBuilder parseLastName(XMLStreamReader reader, StringBuilder authorName) throws XMLStreamException
parseMedlineCitationback to summary
private void parseMedlineCitation(XMLStreamReader reader, Map<Field, String> fields, String startElement) throws XMLStreamException
parseMedlineJournalInfoback to summary
private void parseMedlineJournalInfo(XMLStreamReader reader, Map<Field, String> fields, String startElement) throws XMLStreamException
parseMeshHeadingback to summary
private void parseMeshHeading(XMLStreamReader reader, List<MeshHeading> meshHeadingList, String startElement) throws XMLStreamException
parsePersonalNameSubjectback to summary
private void parsePersonalNameSubject(XMLStreamReader reader, List<PersonalNameSubject> personalNameSubjectList, String startElement) throws XMLStreamException
parsePubmedDataback to summary
private void parsePubmedData(XMLStreamReader reader, Map<Field, String> fields, String startElement) throws XMLStreamException
parseSectionsback to summary
private void parseSections(XMLStreamReader reader, List<String> sectionTitleList) throws XMLStreamException
putIfValueNotNullback to summary
private void putIfValueNotNull(Map<Field, String> fields, Field field, String value)