Verified Owner
Top Fields Constructors Methods
org.jabref.logic.util

public Class ExternalLinkCreator

extends Object
Class Inheritance
Imports
java.net.URISyntaxException, .URLEncoder, java.nio.charset.StandardCharsets, java.util.Optional, org.jabref.logic.importer.AuthorListParser, .ImporterPreferences, org.jabref.logic.util.strings.StringUtil, org.jabref.model.entry.Author, .AuthorList, .BibEntry, org.jabref.model.entry.field.StandardField, org.jabref.model.strings.LatexToUnicodeAdapter, org.apache.hc.core5.net.URIBuilder, org.jspecify.annotations.Nullable, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final String
private final ImporterPreferences
private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private Optional<String>

Returns:

Optional containing the constructed URL, or empty if construction failed
buildSearchUrl
(String
The custom or default base URL
baseUrl
,
String
The fallback default URL
defaultUrl
,
String
The title to search for
title
,
@Nullable String
Optional author to include in search (null if not present)
author
,
String
Name of the service for logging
serviceName
,
boolean
formats all authors as separate keys with indexing ("author0", "author1", etc.)
addAuthorIndex
)

Builds a search URL using either template replacement or query parameters

private Optional<String>
buildUrlWithQueryParams(String baseUrl, String title, @Nullable String author, String serviceName, boolean addAuthorIndex)

Builds a URL using query parameters (fallback method).

public Optional<String>

Returns:

The URL if it was successfully created
getGoogleScholarSearchURL
(BibEntry
The entry to search for. Expects the BibEntry's title to be set for a successful return.
entry
)

Get a URL to the search results of Google Scholar for the BibEntry's title

public Optional<String>

Returns:

The URL if it was successfully created
getSemanticScholarSearchURL
(BibEntry
The entry to search for. Expects the BibEntry's title to be set for a successful return.
entry
)

Get a URL to the search results of Semantic Scholar for the BibEntry's title

public Optional<String>

Returns:

The URL if it was successfully created
getShortScienceSearchURL
(BibEntry
The entry to search for. Expects the BibEntry's title to be set for a successful return.
entry
)

Get a URL to the search results of ShortScience for the BibEntry's title

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_GOOGLE_SCHOLAR_SEARCH_URLback to summary
private static final String DEFAULT_GOOGLE_SCHOLAR_SEARCH_URL
DEFAULT_SEMANTIC_SCHOLAR_SEARCH_URLback to summary
private static final String DEFAULT_SEMANTIC_SCHOLAR_SEARCH_URL
DEFAULT_SHORTSCIENCE_SEARCH_URLback to summary
private static final String DEFAULT_SHORTSCIENCE_SEARCH_URL
importerPreferencesback to summary
private final ImporterPreferences importerPreferences
LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

ExternalLinkCreatorback to summary
public ExternalLinkCreator(ImporterPreferences importerPreferences)

Method Detail

buildSearchUrlback to summary
private Optional<String> buildSearchUrl(String baseUrl, String defaultUrl, String title, @Nullable String author, String serviceName, boolean addAuthorIndex)

Builds a search URL using either template replacement or query parameters

Parameters
baseUrl:String

The custom or default base URL

defaultUrl:String

The fallback default URL

title:String

The title to search for

author:@Nullable String

Optional author to include in search (null if not present)

serviceName:String

Name of the service for logging

addAuthorIndex:boolean

formats all authors as separate keys with indexing ("author0", "author1", etc.)

Returns:Optional<String>

Optional containing the constructed URL, or empty if construction failed

buildUrlWithQueryParamsback to summary
private Optional<String> buildUrlWithQueryParams(String baseUrl, String title, @Nullable String author, String serviceName, boolean addAuthorIndex)

Builds a URL using query parameters (fallback method).

The parameter addAuthorIndex is used for Semantic Scholar service because it does not understand "author=XYZ", but it uses "author0=XYZ&author1=ABC".

getGoogleScholarSearchURLback to summary
public Optional<String> getGoogleScholarSearchURL(BibEntry entry)

Get a URL to the search results of Google Scholar for the BibEntry's title

Parameters
entry:BibEntry

The entry to search for. Expects the BibEntry's title to be set for a successful return.

Returns:Optional<String>

The URL if it was successfully created

getSemanticScholarSearchURLback to summary
public Optional<String> getSemanticScholarSearchURL(BibEntry entry)

Get a URL to the search results of Semantic Scholar for the BibEntry's title

Parameters
entry:BibEntry

The entry to search for. Expects the BibEntry's title to be set for a successful return.

Returns:Optional<String>

The URL if it was successfully created

getShortScienceSearchURLback to summary
public Optional<String> getShortScienceSearchURL(BibEntry entry)

Get a URL to the search results of ShortScience for the BibEntry's title

Parameters
entry:BibEntry

The entry to search for. Expects the BibEntry's title to be set for a successful return.

Returns:Optional<String>

The URL if it was successfully created