-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refine NoBibtexFieldChecker to treat more biblatex-only fields
- Loading branch information
Showing
2 changed files
with
21 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 20 additions & 16 deletions
36
src/main/java/net/sf/jabref/logic/integrity/NoBibtexFieldChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
package net.sf.jabref.logic.integrity; | ||
|
||
import java.util.Collections; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.SortedSet; | ||
import java.util.TreeSet; | ||
import java.util.stream.Collectors; | ||
|
||
import net.sf.jabref.logic.integrity.IntegrityCheck.Checker; | ||
import net.sf.jabref.logic.l10n.Localization; | ||
import net.sf.jabref.model.entry.BibEntry; | ||
import net.sf.jabref.model.entry.EntryConverter; | ||
import net.sf.jabref.model.entry.FieldName; | ||
|
||
public class NoBibtexFieldChecker implements Checker { | ||
|
||
/** | ||
* BibLaTeX package documentation (Section 2.1.1): | ||
* The title of the periodical is given in the journaltitle field. | ||
*/ | ||
@Override | ||
public List<IntegrityMessage> check(BibEntry entry) { | ||
Optional<String> value = entry.getField(FieldName.JOURNALTITLE); | ||
|
||
//BibTeX | ||
if (!value.isPresent()) { | ||
return Collections.emptyList(); | ||
} | ||
else { | ||
return Collections.singletonList( | ||
new IntegrityMessage(Localization.lang("BibLaTeX field only"), entry, FieldName.JOURNALTITLE)); | ||
} | ||
SortedSet<String> allBibLaTeXOnlyFields = new TreeSet<>(); | ||
allBibLaTeXOnlyFields.addAll(EntryConverter.FIELD_ALIASES_LTX_TO_TEX.keySet()); | ||
|
||
// file is both in bibtex and biblatex | ||
allBibLaTeXOnlyFields.remove(FieldName.FILE); | ||
|
||
// these two are in BibLaTeX only | ||
allBibLaTeXOnlyFields.add(FieldName.JOURNALTITLE); | ||
allBibLaTeXOnlyFields.add(FieldName.JOURNALSUBTITLE); | ||
|
||
List<IntegrityMessage> res = new ArrayList<>(); | ||
return entry.getFieldNames().stream() | ||
.filter(name -> allBibLaTeXOnlyFields.contains(name)) | ||
.map(name -> new IntegrityMessage(Localization.lang("BibLaTeX field only"), entry, name)).collect(Collectors.toList()); | ||
} | ||
|
||
} |