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

public Class ReferImporter

extends Importer
Class Inheritance
Imports
java.io.BufferedReader, .IOException, .Reader, java.util.ArrayList, .HashMap, .List, .Map, java.util.concurrent.atomic.AtomicBoolean, java.util.regex.Pattern, org.jabref.logic.citationkeypattern.CitationKeyGenerator, .CitationKeyPatternPreferences, org.jabref.logic.importer.Importer, .ParserResult, org.jabref.logic.l10n.Localization, org.jabref.logic.util.FileType, .StandardFileType, org.jabref.model.entry.AuthorList, .BibEntry, org.jabref.model.entry.field.Field, .InternalField, .StandardField, org.jabref.model.entry.types.EntryType, .StandardEntryType, org.jspecify.annotations.NonNull

This is BibIX variant of Refer. There is hardly any official document so fields are added taking standard refer type. Originally number of fields were less and overtime some of these modified or added by various management systems.

Field Summary

Modifier and TypeField and Description
private final CitationKeyPatternPreferences
private static final String
private static final Pattern

Constructor Summary

AccessConstructor and Description
public
ReferImporter(CitationKeyPatternPreferences citationKeyPatternPreferences)

Method Summary

Modifier and TypeMethod and Description
private void
private void
private void
addTag(Map<Field, String> m, EntryType type, String val, String tag)

private static String

Returns:

The fixed author string
fixAuthor
(String
The author string
s
)

We must be careful about the author names, since they can be presented differently by different sources.

public String
getDescription()

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

Returns the description of the import format.

public FileType
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 EntryType
getType(String val, AtomicBoolean isEdited)

public ParserResult
importDatabase(@NonNull BufferedReader reader)

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

Parse the database in the source.

public boolean
isRecognizedFormat(@NonNull Reader reader)

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

#isRecognizedFormat(BufferedReader) without the requirement to reset

private void
postFix(Map<Field, String> hm, StringBuilder author, StringBuilder editor, AtomicBoolean isEditedBook)

private void
stringToBibEntry(List<BibEntry> bibEntryList, List<String> allEntries)

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

Field Detail

citationKeyPatternPreferencesback to summary
private final CitationKeyPatternPreferences citationKeyPatternPreferences
ENDOFRECORDback to summary
private static final String ENDOFRECORD
Z_PATTERNback to summary
private static final Pattern Z_PATTERN

Constructor Detail

ReferImporterback to summary
public ReferImporter(CitationKeyPatternPreferences citationKeyPatternPreferences)

Method Detail

addAuthorback to summary
private void addAuthor(StringBuilder auth, String val)
addEditorback to summary
private void addEditor(StringBuilder edt, String val)
addTagback to summary
private void addTag(Map<Field, String> m, EntryType type, String val, String tag)
fixAuthorback to summary
private static String fixAuthor(String s)

We must be careful about the author names, since they can be presented differently by different sources. Normally each %A tag brings one name, and we get the authors separated by " and ". This is the correct behaviour. One source lists the names separated by comma, with a comma at the end. We can detect this format and fix it.

Parameters
s:String

The author string

Returns:String

The fixed author string

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 FileType 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
getTypeback to summary
private EntryType getType(String val, AtomicBoolean isEdited)
importDatabaseback to summary
public ParserResult importDatabase(@NonNull BufferedReader reader) 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
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
postFixback to summary
private void postFix(Map<Field, String> hm, StringBuilder author, StringBuilder editor, AtomicBoolean isEditedBook)
stringToBibEntryback to summary
private void stringToBibEntry(List<BibEntry> bibEntryList, List<String> allEntries)