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

public Class MrDLibImporter

extends Importer
Class Inheritance
Imports
java.io.BufferedReader, .IOException, .Reader, java.util.ArrayList, .Comparator, .Iterator, .List, java.util.stream.Collectors, org.jabref.logic.importer.Importer, .ParserResult, org.jabref.logic.util.StandardFileType, org.jabref.model.database.BibDatabase, org.jabref.model.entry.BibEntry, org.jabref.model.entry.field.StandardField, kong.unirest.core.json.JSONException, kong.unirest.core.json.JSONObject, org.jspecify.annotations.NonNull, org.slf4j.Logger, .LoggerFactory

Handles importing of recommended articles to be displayed in the Related Articles tab.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record
MrDLibImporter.RankedBibEntry

Small pair-class to ensure the right order of the recommendations.

Field Summary

Modifier and TypeField and Description
private static final Logger
public ParserResult
private String
private String
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
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.

public ParserResult
public String
public String
public String
public ParserResult
importDatabase(@NonNull BufferedReader input)

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

Parse the database in the source.

public boolean
isRecognizedFormat(@NonNull Reader input)

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

#isRecognizedFormat(BufferedReader) without the requirement to reset

private Boolean
isRecommendationFieldPresent(kong.unirest.core.json.JSONObject recommendation, String field)

private void
parse(BufferedReader
A BufferedReader with a reference to a string with the server's response
input
)

Parses the input from the server to a ParserResult

private MrDLibImporter.RankedBibEntry

Returns:

A ranked bib entry created from the recommendation input
populateBibEntry
(kong.unirest.core.json.JSONObject
JSON object of a single recommendation returned by Mr. DLib
recommendation
)

Parses the JSON recommendations into bib entries

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

Field Detail

LOGGERback to summary
private static final Logger LOGGER

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

parserResultback to summary
public ParserResult parserResult
recommendationsDescriptionback to summary
private String recommendationsDescription
recommendationSetIdback to summary
private String recommendationSetId
recommendationsHeadingback to summary
private String recommendationsHeading

Constructor Detail

MrDLibImporterback to summary
public MrDLibImporter()

Method Detail

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
getParserResultback to summary
public ParserResult getParserResult()
getRecommendationsDescriptionback to summary
public String getRecommendationsDescription()
getRecommendationSetIdback to summary
public String getRecommendationSetId()
getRecommendationsHeadingback to summary
public String getRecommendationsHeading()
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
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
isRecommendationFieldPresentback to summary
private Boolean isRecommendationFieldPresent(kong.unirest.core.json.JSONObject recommendation, String field)
parseback to summary
private void parse(BufferedReader input)

Parses the input from the server to a ParserResult

Parameters
input:BufferedReader

A BufferedReader with a reference to a string with the server's response

populateBibEntryback to summary
private MrDLibImporter.RankedBibEntry populateBibEntry(kong.unirest.core.json.JSONObject recommendation)

Parses the JSON recommendations into bib entries

Parameters
recommendation:kong.unirest.core.json.JSONObject

JSON object of a single recommendation returned by Mr. DLib

Returns:MrDLibImporter.RankedBibEntry

A ranked bib entry created from the recommendation input

org.jabref.logic.importer.fileformat back to summary

private final Record MrDLibImporter.RankedBibEntry

extends Record
Class Inheritance
Record Components
entry:BibEntry 
rank:Integer 

Small pair-class to ensure the right order of the recommendations.

Field Summary

Modifier and TypeField and Description
private final BibEntry
entry

Record Component accessed by entry().

private final Integer
rank

Record Component accessed by rank().

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public BibEntry
entry()

Record Component getter of entry.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public Integer
rank()

Record Component getter of rank.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

entryback to summary
private final BibEntry entry

Record Component accessed by entry().

rankback to summary
private final Integer rank

Record Component accessed by rank().

Constructor Detail

RankedBibEntryback to summary
private RankedBibEntry(BibEntry entry, Integer rank)

Method Detail

entryback to summary
public BibEntry entry()

Record Component getter of entry.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

rankback to summary
public Integer rank()

Record Component getter of rank.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.