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

public Class ModsImporter

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, .Set, java.util.regex.Pattern, javax.xml.stream.XMLInputFactory, .XMLStreamException, .XMLStreamReader, javax.xml.stream.events.XMLEvent, org.jabref.logic.importer.ImportFormatPreferences, .Importer, .ParseException, .Parser, .ParserResult, org.jabref.logic.importer.fileformat.mods.Identifier, .Name, .RecordInfo, org.jabref.logic.l10n.Localization, org.jabref.logic.util.StandardFileType, org.jabref.model.entry.BibEntry, .Date, org.jabref.model.entry.field.Field, .FieldFactory, .StandardField, .UnknownField, org.jabref.model.entry.types.EntryType, .EntryTypeFactory, .StandardEntryType, org.jspecify.annotations.NonNull, .Nullable, org.slf4j.Logger, .LoggerFactory

Importer for the MODS format.

More details about the format can be found here http://www.loc.gov/standards/mods/.

The newest xml schema can also be found here www.loc.gov/standards/mods/mods-schemas.html..

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
ModsImporter(ImportFormatPreferences importFormatPreferences)

Method Summary

Modifier and TypeMethod and Description
private void
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
private void
private void
public ParserResult
importDatabase(@NonNull BufferedReader input)

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

Parse the database in the source.

private Optional<EntryType>
private Optional<EntryType>
private boolean
private boolean
public boolean
isRecognizedFormat(@NonNull Reader input)

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

#isRecognizedFormat(BufferedReader) without the requirement to reset

private boolean
private String
public List<BibEntry>
private void
parseIdentifier(Map<Field, String> fields, Identifier identifier, BibEntry entry)

private Optional<EntryType>
private void
private void
private void
private void
private void
parseName(XMLStreamReader reader, Map<Field, String> fields, List<String> authors)

private void
parseOriginInfo(XMLStreamReader reader, Map<Field, String> fields, ModsImporter.TypeHints typeHints, boolean hostOriginInfo)

private void
private void
parseRelatedItem(XMLStreamReader reader, Map<Field, String> fields, ModsImporter.TypeHints typeHints)

Parses information from the RelatedModsGroup.

private void
parseSubject(XMLStreamReader reader, Map<Field, String> fields, List<String> keywords)

private void
private void
putDate(Map<Field, String> fields, String elementName, String date)

private void
putIfListIsNotEmpty(Map<Field, String> fields, List<String> list, Field key, String separator)

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

private void
Inherited from org.jabref.logic.importer.Importer:
compareToequalsgetCharsetgetReadergetReaderhashCodeimportDatabaseimportDatabaseisRecognizedFormatisRecognizedFormatisRecognizedFormatsupportsFileExtensiontoString

Field Detail

keywordSeparatorback to summary
private final String keywordSeparator
LOGGERback to summary
private static final Logger LOGGER

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

MODS_PATTERNback to summary
private static final Pattern MODS_PATTERN
xmlInputFactoryback to summary
private final XMLInputFactory xmlInputFactory

Constructor Detail

ModsImporterback to summary
public ModsImporter(ImportFormatPreferences importFormatPreferences)

Method Detail

appendIfValueNotNullOrBlankback to summary
private void appendIfValueNotNullOrBlank(List<String> list, String value)
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
handleAuthorsInNamePartback to summary
private void handleAuthorsInNamePart(List<Name> names, List<String> authors)
handleDetailback to summary
private void handleDetail(XMLStreamReader reader, Map<Field, String> fields) throws XMLStreamException
handleExtentback to summary
private void handleExtent(XMLStreamReader reader, Map<Field, String> fields) throws XMLStreamException
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
inferEntryTypeback to summary
private Optional<EntryType> inferEntryType(ModsImporter.TypeHints typeHints)
inferHostEntryTypeback to summary
private Optional<EntryType> inferHostEntryType(ModsImporter.TypeHints typeHints)
isCharacterXMLEventback to summary
private boolean isCharacterXMLEvent(XMLStreamReader reader)
isEndXMLEventback to summary
private boolean isEndXMLEvent(XMLStreamReader reader)
isRecognizedFormatback to summary
public boolean isRecognizedFormat(@NonNull Reader input) 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
isStartXMLEventback to summary
private boolean isStartXMLEvent(XMLStreamReader reader)
mapGenreback to summary
private String mapGenre(String genre)
parseEntriesback to summary
public List<BibEntry> parseEntries(InputStream inputStream) throws ParseException

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

Annotations
@Override
parseIdentifierback to summary
private void parseIdentifier(Map<Field, String> fields, Identifier identifier, BibEntry entry)
parseKnownEntryTypeback to summary
private Optional<EntryType> parseKnownEntryType(String typeName)
parseLanguageback to summary
private void parseLanguage(XMLStreamReader reader, Map<Field, String> fields) throws XMLStreamException
parseLocationAndUrlback to summary
private void parseLocationAndUrl(XMLStreamReader reader, Map<Field, String> fields) throws XMLStreamException
parseModsCollectionback to summary
private void parseModsCollection(List<BibEntry> bibItems, XMLStreamReader reader) throws XMLStreamException
parseModsGroupback to summary
private void parseModsGroup(Map<Field, String> fields, XMLStreamReader reader, BibEntry entry) throws XMLStreamException
parseNameback to summary
private void parseName(XMLStreamReader reader, Map<Field, String> fields, List<String> authors) throws XMLStreamException
parseOriginInfoback to summary
private void parseOriginInfo(XMLStreamReader reader, Map<Field, String> fields, ModsImporter.TypeHints typeHints, boolean hostOriginInfo) throws XMLStreamException
parseRecordInfoback to summary
private void parseRecordInfo(XMLStreamReader reader, Map<Field, String> fields) throws XMLStreamException
parseRelatedItemback to summary
private void parseRelatedItem(XMLStreamReader reader, Map<Field, String> fields, ModsImporter.TypeHints typeHints) throws XMLStreamException

Parses information from the RelatedModsGroup. It has the same elements as ModsGroup. But information like volume, issue and the pages appear here instead of in the ModsGroup. Also, if there appears a title field, then this indicates that is the name of the journal which the article belongs to.

parseSubjectback to summary
private void parseSubject(XMLStreamReader reader, Map<Field, String> fields, List<String> keywords) throws XMLStreamException
parseTitleback to summary
private void parseTitle(XMLStreamReader reader, Map<Field, String> fields) throws XMLStreamException
putDateback to summary
private void putDate(Map<Field, String> fields, String elementName, String date)
putIfListIsNotEmptyback to summary
private void putIfListIsNotEmpty(Map<Field, String> fields, List<String> list, Field key, String separator)
putIfValueNotNullback to summary
private void putIfValueNotNull(Map<Field, String> fields, Field field, String value)
putRelatedItemTitleback to summary
private void putRelatedItemTitle(Map<Field, String> fields, ModsImporter.TypeHints typeHints, EntryType entryType)
org.jabref.logic.importer.fileformat back to summary

private final Class ModsImporter.TypeHints

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final List<String>
private @Nullable String
private @Nullable String
private final List<String>
private @Nullable String
private @Nullable String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hostGenresback to summary
private final List<String> hostGenres
hostIssuanceback to summary
private @Nullable String hostIssuance
hostTitleback to summary
private @Nullable String hostTitle
mainGenresback to summary
private final List<String> mainGenres
mainIssuanceback to summary
private @Nullable String mainIssuance
mainResourceback to summary
private @Nullable String mainResource

Constructor Detail

TypeHintsback to summary
private TypeHints()