Verified Owner
Top Description Fields Constructors Methods
org.jabref.logic.search

public Class SearchContext

extends Object
implements SearchBackend
Class Inheritance
All Implemented Interfaces
org.jabref.logic.search.SearchBackend
Imports
java.util.List, java.util.function.Supplier, javafx.beans.property.BooleanProperty, org.jabref.model.entry.BibEntry, org.jabref.model.entry.event.FieldChangedEvent, org.jabref.model.search.query.SearchQuery, .SearchResults, com.tobiasdiez.easybind.EasyBind, com.tobiasdiez.easybind.Subscription, org.slf4j.Logger, .LoggerFactory

Abstraction role of the GoF Bridge pattern (cf. Design Patterns: Elements of Reusable Object-Oriented Software, Gamma et al., 1994, pp. 151-161), where SearchBackend is the Implementor.

SearchContext decouples the GUI's view of search from the concrete backend. Callers always work against this abstraction; the backend reference may be swapped live (e.g. when the user toggles the "use Postgres-backed search" preference). When the backing preference changes, the context closes the previous backend and instantiates a new one via the supplier passed in at construction time. Switching to the SQL backend triggers a full re-index because the org.jabref.logic.search.sqlbased.IndexManager constructor indexes all current entries on creation.

All methods are synchronized so concurrent search calls and a live swap do not interleave. The lock is held for the duration of each forwarded call.

Field Summary

Modifier and TypeField and Description
private SearchBackend
private final Supplier<SearchBackend>
private static final Logger
private final com.tobiasdiez.easybind.Subscription
private final Supplier<SearchBackend>
private final BooleanProperty

Constructor Summary

AccessConstructor and Description
public
SearchContext(BooleanProperty usePostgresProperty, Supplier<SearchBackend> sqlFactory, Supplier<SearchBackend> inMemoryFactory)

Method Summary

Modifier and TypeMethod and Description
public synchronized void
private SearchBackend
public synchronized void
close()

Implements org.jabref.logic.search.SearchBackend.close.

Release backend resources (DB connections, Lucene index handles, …).

public synchronized boolean
isEntryMatched(BibEntry entry, SearchQuery query)

Implements org.jabref.logic.search.SearchBackend.isEntryMatched.

Test a single entry against the query without re-running a full library search.

public synchronized void
rebuildFullTextIndex()

Implements org.jabref.logic.search.SearchBackend.rebuildFullTextIndex.

Re-index linked-file fulltext from scratch.

public synchronized void
public synchronized SearchResults
search(SearchQuery query)

Implements org.jabref.logic.search.SearchBackend.search.

Run the query against this backend.

private synchronized void
public synchronized void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

backendback to summary
private SearchBackend backend
inMemoryFactoryback to summary
private final Supplier<SearchBackend> inMemoryFactory
LOGGERback to summary
private static final Logger LOGGER
preferenceSubscriptionback to summary
private final com.tobiasdiez.easybind.Subscription preferenceSubscription
sqlFactoryback to summary
private final Supplier<SearchBackend> sqlFactory
usePostgresPropertyback to summary
private final BooleanProperty usePostgresProperty

Constructor Detail

SearchContextback to summary
public SearchContext(BooleanProperty usePostgresProperty, Supplier<SearchBackend> sqlFactory, Supplier<SearchBackend> inMemoryFactory)

Method Detail

addToIndexback to summary
public synchronized void addToIndex(List<BibEntry> entries)

Implements org.jabref.logic.search.SearchBackend.addToIndex.

Doc from org.jabref.logic.search.SearchBackend.addToIndex.

Indexing lifecycle. Backends without an index (e.g. in-memory) implement these as no-ops.

Annotations
@Override
buildBackendback to summary
private SearchBackend buildBackend()
closeback to summary
public synchronized void close()

Implements org.jabref.logic.search.SearchBackend.close.

Doc from org.jabref.logic.search.SearchBackend.close.

Release backend resources (DB connections, Lucene index handles, …). Idempotent.

Annotations
@Override
isEntryMatchedback to summary
public synchronized boolean isEntryMatched(BibEntry entry, SearchQuery query)

Implements org.jabref.logic.search.SearchBackend.isEntryMatched.

Doc from org.jabref.logic.search.SearchBackend.isEntryMatched.

Test a single entry against the query without re-running a full library search.

Annotations
@Override
rebuildFullTextIndexback to summary
public synchronized void rebuildFullTextIndex()

Implements org.jabref.logic.search.SearchBackend.rebuildFullTextIndex.

Doc from org.jabref.logic.search.SearchBackend.rebuildFullTextIndex.

Re-index linked-file fulltext from scratch. Backends without a fulltext index implement as a no-op.

Annotations
@Override
removeFromIndexback to summary
public synchronized void removeFromIndex(List<BibEntry> entries)

Implements org.jabref.logic.search.SearchBackend.removeFromIndex.

Annotations
@Override
searchback to summary
public synchronized SearchResults search(SearchQuery query)

Implements org.jabref.logic.search.SearchBackend.search.

Doc from org.jabref.logic.search.SearchBackend.search.

Run the query against this backend.

Annotations
@Override
swapBackendback to summary
private synchronized void swapBackend()
updateEntryback to summary
public synchronized void updateEntry(FieldChangedEvent event)

Implements org.jabref.logic.search.SearchBackend.updateEntry.

Annotations
@Override