Verified Owner
Top Fields Constructors Methods
org.jabref.logic.bibtex.comparator.plausibility

public Class YearFieldValuePlausibilityComparator

extends Object
implements FieldValuePlausibilityComparator
Class Inheritance
All Implemented Interfaces
org.jabref.logic.bibtex.comparator.plausibility.FieldValuePlausibilityComparator
Imports
java.time.Year, java.util.Optional, java.util.regex.Matcher, .Pattern, org.jabref.logic.bibtex.comparator.ComparisonResult, org.jabref.logic.integrity.YearChecker, org.jabref.logic.util.strings.StringUtil

Field Summary

Modifier and TypeField and Description
private static final Pattern

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public ComparisonResult

Returns:

ComparisonResult indicating which year is more plausible: RIGHT_BETTER, LEFT_BETTER, or UNDETERMINED
compare
(String
value from the library (or candidate)
leftValue
,
String
value from the fetcher (or existing record)
rightValue
)

Implements org.jabref.logic.bibtex.comparator.plausibility.FieldValuePlausibilityComparator.compare.

Compares the plausibility of two field values.

private Optional<Integer>

Returns:

Optional containing the 4-digit year if found, otherwise Optional.empty()
extractYear
(String
the input string possibly containing a year
value
)

Extracts the first 4-digit number found in the string.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

YEAR_PATTERNback to summary
private static final Pattern YEAR_PATTERN

Constructor Detail

YearFieldValuePlausibilityComparatorback to summary
pack-priv YearFieldValuePlausibilityComparator()

Method Detail

compareback to summary
public ComparisonResult compare(String leftValue, String rightValue)

Implements org.jabref.logic.bibtex.comparator.plausibility.FieldValuePlausibilityComparator.compare.

Compares the plausibility of two field values.

Parameters
leftValue:String

value from the library (or candidate)

rightValue:String

value from the fetcher (or existing record)

Returns:ComparisonResult

ComparisonResult indicating which year is more plausible: RIGHT_BETTER, LEFT_BETTER, or UNDETERMINED

Annotations
@Override
extractYearback to summary
private Optional<Integer> extractYear(String value)

Extracts the first 4-digit number found in the string. Used to identify year-like values such as "About 2000" or "Published in 1999".

Parameters
value:String

the input string possibly containing a year

Returns:Optional<Integer>

Optional containing the 4-digit year if found, otherwise Optional.empty()