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

public Class DatabaseMerger

extends Object
Class Inheritance
Imports
java.util.ArrayList, .List, .Optional, org.jabref.model.database.BibDatabase, .BibDatabaseContext, .BibDatabaseModeDetection, org.jabref.model.entry.BibEntry, .BibEntryTypesManager, .BibtexString, .KeywordList, org.jabref.model.entry.field.StandardField, org.jabref.model.groups.AllEntriesGroup, .ExplicitGroup, .GroupHierarchyType, org.jabref.model.metadata.ContentSelector, .MetaData, org.jspecify.annotations.NonNull, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private final char
private static final Logger

Constructor Summary

AccessConstructor and Description
public
DatabaseMerger(char keywordDelimiter)

Method Summary

Modifier and TypeMethod and Description
public synchronized void
merge(BibDatabase target, BibDatabase
The other databases that is merged into this database
other
)

Merges all entries and strings of the other database into the target database.

public synchronized void
merge(BibDatabaseContext target, BibDatabaseContext
The other databases that is merged into this database
other
,
String otherFileName)

Merges all entries, strings, and metaData of the other database context into the target database context.

private void
private void
mergeEntries(BibDatabase target, BibDatabase other)

Merges all entries of the other database into the target database.

private void
mergeGroups(@NonNull MetaData target, @NonNull MetaData other, @NonNull String otherFilename, @NonNull List<BibEntry> allOtherEntries)

private void
mergeGroupsField(BibEntry surviving, BibEntry dropped)

public void
mergeMetaData(@NonNull MetaData
the metaData that is the merge target
target
,
@NonNull MetaData
the metaData to merge into the target
other
,
@NonNull String
the filename of the other library. Pass "unknown" if not known.
otherFilename
,
@NonNull List<BibEntry> allOtherEntries)

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

keywordDelimiterback to summary
private final char keywordDelimiter
LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

DatabaseMergerback to summary
public DatabaseMerger(char keywordDelimiter)

Method Detail

mergeback to summary
public synchronized void merge(BibDatabase target, BibDatabase other)

Merges all entries and strings of the other database into the target database. Any duplicates are ignored. In case a string has a different content, it is added with a new unique name. The unique name is generated by suffix "_i", where i runs from 1 onwards.

Parameters
other:BibDatabase

The other databases that is merged into this database

mergeback to summary
public synchronized void merge(BibDatabaseContext target, BibDatabaseContext other, String otherFileName)

Merges all entries, strings, and metaData of the other database context into the target database context. Any duplicates are ignored. In case a string has a different content, it is added with a new unique name. The unique name is generated by suffix "_i", where i runs from 1 onwards.

Parameters
other:BibDatabaseContext

The other databases that is merged into this database

mergeContentSelectorsback to summary
private void mergeContentSelectors(MetaData target, MetaData other)
mergeEntriesback to summary
private void mergeEntries(BibDatabase target, BibDatabase other)

Merges all entries of the other database into the target database. Duplicate entries are not inserted. If a duplicate is detected, its groups field is union-merged into the existing entry.

mergeGroupsback to summary
private void mergeGroups(@NonNull MetaData target, @NonNull MetaData other, @NonNull String otherFilename, @NonNull List<BibEntry> allOtherEntries)
mergeGroupsFieldback to summary
private void mergeGroupsField(BibEntry surviving, BibEntry dropped)
mergeMetaDataback to summary
public void mergeMetaData(@NonNull MetaData target, @NonNull MetaData other, @NonNull String otherFilename, @NonNull List<BibEntry> allOtherEntries)
Parameters
target:@NonNull MetaData

the metaData that is the merge target

other:@NonNull MetaData

the metaData to merge into the target

otherFilename:@NonNull String

the filename of the other library. Pass "unknown" if not known.

mergeStringsback to summary
public void mergeStrings(BibDatabase target, BibDatabase other)