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, java.nio.charset.StandardCharsets, java.util.ArrayList, .Collections, .HashMap, .List, .Locale, .Map, .Objects, .Optional, javax.xml.stream.XMLInputFactory, .XMLStreamException, .XMLStreamReader, javax.xml.stream.events.XMLEvent, 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.util.StandardFileType, org.jabref.model.entry.BibEntry, .Date, .Month, org.jabref.model.entry.field.Field, .FieldFactory, .StandardField, .UnknownField, org.jabref.model.entry.types.StandardEntryType, org.jabref.model.strings.StringUtil, 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()

Overrides org.jabref.logic.importer.Importer.getId.

Returns a one-word ID which identifies this importer.

public String
getName()

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

Returns the name of this import format.

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

private void
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(BufferedReader
the input to read from
input
)

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

Parse the database in the source.

private boolean
private boolean
public boolean
isRecognizedFormat(BufferedReader reader)

Implements abstract 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
parseDate(XMLStreamReader reader, Map<Field, String> fields, String startElement)

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

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

private void
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:
compareToequalsgetCharsetgetReadergetReaderhashCodeimportDatabaseimportDatabaseisRecognizedFormatisRecognizedFormattoString

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 recognizes an import format
Returns:String

description of the 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

Returns:StandardFileType

FileType corresponding to the importer

Annotations
@Override
getIdback to summary
public String getId()

Overrides org.jabref.logic.importer.Importer.getId.

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

Returns a one-word ID which identifies this importer. Used for example, to identify the importer when used from the command line.

Returns:String

ID, must be unique and not null

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.

The name must be unique.

Returns:String

format name, must be unique and not null

Annotations
@Override
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)
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(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.

This method should never return null.

Parameters
input:BufferedReader

the input to read from

Annotations
@Override
isCharacterXMLEventback to summary
private boolean isCharacterXMLEvent(XMLStreamReader reader)
isEndXMLEventback to summary
private boolean isEndXMLEvent(XMLStreamReader reader)
isRecognizedFormatback to summary
public boolean isRecognizedFormat(BufferedReader reader) throws IOException

Implements abstract 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.

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 behaviour 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
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
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
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)