Verified Owner
Top Fields Constructors Methods
org.jabref.logic.importer.fetcher

public Class BaseSearchFetcher

extends Object
implements PagedSearchBasedParserFetcher, CustomizableKeyFetcher
Class Inheritance
All Implemented Interfaces
org.jabref.logic.importer.fetcher.CustomizableKeyFetcher, org.jabref.logic.importer.WebFetcher, org.jabref.logic.importer.PagedSearchBasedParserFetcher, org.jabref.logic.importer.ParserFetcher, org.jabref.logic.importer.PagedSearchBasedFetcher, org.jabref.logic.importer.SearchBasedFetcher, org.jabref.logic.importer.SearchBasedParserFetcher
Annotations
@NullMarked
Imports
java.net.MalformedURLException, .URISyntaxException, .URL, java.nio.charset.StandardCharsets, java.util.List, .Locale, .Map, .Optional, java.util.stream.IntStream, org.jabref.logic.importer.FetcherException, .ImporterPreferences, .PagedSearchBasedParserFetcher, .ParseException, .Parser, org.jabref.logic.importer.fetcher.transformers.BaseSearchQueryTransformer, org.jabref.logic.net.URLDownload, org.jabref.logic.util.strings.StringUtil, org.jabref.model.entry.BibEntry, org.jabref.model.entry.field.Field, .StandardField, org.jabref.model.entry.types.BiblatexNonStandardEntryType, .EntryType, .IEEETranEntryType, .StandardEntryType, org.jabref.model.search.query.BaseQueryNode, kong.unirest.core.json.JSONArray, kong.unirest.core.json.JSONException, kong.unirest.core.json.JSONObject, org.apache.hc.core5.net.URIBuilder, org.jspecify.annotations.NonNull, .NullMarked, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private static final String
private static final Map<String, EntryType>
public static final String
private final ImporterPreferences
private static final Logger
private static final FetcherRateLimiter

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private URL
buildSearchUrl(String query, int hits, int offset)

private Optional<kong.unirest.core.json.JSONArray>
getDocs(kong.unirest.core.json.JSONObject jsonObject)

private Optional<String>
getFirstValue(kong.unirest.core.json.JSONObject doc, String key)

private Optional<String>
getJoinedValues(kong.unirest.core.json.JSONObject doc, String key, String delimiter)

public String
getName()

Implements org.jabref.logic.importer.WebFetcher.getName.

Returns the localized name of this fetcher.

public Parser
getParser()

Implements org.jabref.logic.importer.SearchBasedParserFetcher.getParser.

Returns the parser used to convert the response to a list of BibEntry.

public URLDownload
getUrlDownload(URL url)

Overrides default org.jabref.logic.importer.WebFetcher.getUrlDownload.

Constructs an URLDownload object for downloading content based on the given URL.

public URL
getURLForQuery(BaseQueryNode queryNode, int pageNumber)

Implements org.jabref.logic.importer.PagedSearchBasedParserFetcher.getURLForQuery.

Constructs a URL based on the query, size and page number.

pack-priv URL
private List<String>
getValues(kong.unirest.core.json.JSONObject doc, String key)

public boolean
isValidKey(String apiKey)

Overrides default org.jabref.logic.importer.fetcher.CustomizableKeyFetcher.isValidKey.

Returns whether the API key is valid

pack-priv boolean
private EntryType
mapEntryType(kong.unirest.core.json.JSONObject doc)

private EntryType
private BibEntry
parseEntry(kong.unirest.core.json.JSONObject doc)

private BibEntry
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

API_URLback to summary
private static final String API_URL
ENTRY_TYPES_BY_CODEback to summary
private static final Map<String, EntryType> ENTRY_TYPES_BY_CODE
FETCHER_NAMEback to summary
public static final String FETCHER_NAME
importerPreferencesback to summary
private final ImporterPreferences importerPreferences
LOGGERback to summary
private static final Logger LOGGER
RATE_LIMITERback to summary
private static final FetcherRateLimiter RATE_LIMITER

Constructor Detail

BaseSearchFetcherback to summary
public BaseSearchFetcher(@NonNull ImporterPreferences importerPreferences)

Method Detail

buildSearchUrlback to summary
private URL buildSearchUrl(String query, int hits, int offset) throws URISyntaxException, MalformedURLException
getDocsback to summary
private Optional<kong.unirest.core.json.JSONArray> getDocs(kong.unirest.core.json.JSONObject jsonObject)
getFirstValueback to summary
private Optional<String> getFirstValue(kong.unirest.core.json.JSONObject doc, String key)
getJoinedValuesback to summary
private Optional<String> getJoinedValues(kong.unirest.core.json.JSONObject doc, String key, String delimiter)
getNameback to summary
public String getName()

Implements org.jabref.logic.importer.WebFetcher.getName.

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

Returns the localized name of this fetcher. The title can be used to display the fetcher in the menu and in the side pane.

Todo

This name is also used for identifying the fetcher in preferences for API keys. Thus, any switch of the language will "remove" API keys.

Annotations
@Override
getParserback to summary
public Parser getParser()

Implements org.jabref.logic.importer.SearchBasedParserFetcher.getParser.

Doc from org.jabref.logic.importer.SearchBasedParserFetcher.getParser.

Returns the parser used to convert the response to a list of BibEntry.

Annotations
@Override
getUrlDownloadback to summary
public URLDownload getUrlDownload(URL url)

Overrides default org.jabref.logic.importer.WebFetcher.getUrlDownload.

Doc from org.jabref.logic.importer.WebFetcher.getUrlDownload.

Constructs an URLDownload object for downloading content based on the given URL. Overwrite, if you need to send additional headers for the download.

Annotations
@Override
getURLForQueryback to summary
public URL getURLForQuery(BaseQueryNode queryNode, int pageNumber) throws URISyntaxException, MalformedURLException

Implements org.jabref.logic.importer.PagedSearchBasedParserFetcher.getURLForQuery.

Doc from org.jabref.logic.importer.PagedSearchBasedParserFetcher.getURLForQuery.

Constructs a URL based on the query, size and page number.

Annotations
@Override
getValidationUrlback to summary
pack-priv URL getValidationUrl(String apiKey) throws URISyntaxException, MalformedURLException
getValuesback to summary
private List<String> getValues(kong.unirest.core.json.JSONObject doc, String key)
isValidKeyback to summary
public boolean isValidKey(String apiKey)

Overrides default org.jabref.logic.importer.fetcher.CustomizableKeyFetcher.isValidKey.

Doc from org.jabref.logic.importer.fetcher.CustomizableKeyFetcher.isValidKey.

Returns whether the API key is valid

Annotations
@Override
isValidKeyResponseback to summary
pack-priv boolean isValidKeyResponse(String response)
mapEntryTypeback to summary
private EntryType mapEntryType(kong.unirest.core.json.JSONObject doc)
mapEntryTypeback to summary
private EntryType mapEntryType(String code)
parseEntryback to summary
private BibEntry parseEntry(kong.unirest.core.json.JSONObject doc)
withFieldIfPresentback to summary
private BibEntry withFieldIfPresent(BibEntry entry, Field field, Optional<String> value)