use of org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter in project jabref by JabRef.
the class DoiFetcher method doPostCleanup.
private void doPostCleanup(BibEntry entry) {
new FieldFormatterCleanup(FieldName.PAGES, new NormalizePagesFormatter()).cleanup(entry);
new FieldFormatterCleanup(FieldName.URL, new ClearFormatter()).cleanup(entry);
}
use of org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter in project jabref by JabRef.
the class CleanupWorkerTest method cleanupPageNumbersConvertsSingleDashToDouble.
@Test
public void cleanupPageNumbersConvertsSingleDashToDouble() {
CleanupPreset preset = new CleanupPreset(new FieldFormatterCleanups(true, Collections.singletonList(new FieldFormatterCleanup("pages", new NormalizePagesFormatter()))));
BibEntry entry = new BibEntry();
entry.setField("pages", "1-2");
worker.cleanup(preset, entry);
Assert.assertEquals(Optional.of("1--2"), entry.getField("pages"));
}
use of org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter in project jabref by JabRef.
the class IsbnViaEbookDeFetcher method doPostCleanup.
@Override
public void doPostCleanup(BibEntry entry) {
// We MUST NOT clean the URL. this is the deal with ebook.de
// DO NOT add following code:
// new FieldFormatterCleanup(FieldName.URL, new ClearFormatter()).cleanup(entry);
// Fetcher returns page numbers as "30 Seiten" -> remove every non-digit character in the PAGETOTAL field
entry.getField(FieldName.PAGETOTAL).ifPresent(pages -> entry.setField(FieldName.PAGETOTAL, pages.replaceAll("[\\D]", "")));
new FieldFormatterCleanup(FieldName.PAGETOTAL, new NormalizePagesFormatter()).cleanup(entry);
new FieldFormatterCleanup(FieldName.AUTHOR, new NormalizeNamesFormatter()).cleanup(entry);
}
use of org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter in project jabref by JabRef.
the class FieldFormatterCleanupsTest method checkMultipleSaveActionsWithMultipleFormatters.
@Test
public void checkMultipleSaveActionsWithMultipleFormatters() {
FieldFormatterCleanups actions = new FieldFormatterCleanups(true, Cleanups.parse("pages[normalize_page_numbers,normalize_date]title[lower_case]"));
List<FieldFormatterCleanup> formatterCleanups = actions.getConfiguredActions();
FieldFormatterCleanup normalizePages = new FieldFormatterCleanup("pages", new NormalizePagesFormatter());
FieldFormatterCleanup normalizeDatesInPages = new FieldFormatterCleanup("pages", new NormalizeDateFormatter());
FieldFormatterCleanup lowerCaseTitle = new FieldFormatterCleanup("title", new LowerCaseFormatter());
assertEquals(Arrays.asList(normalizePages, normalizeDatesInPages, lowerCaseTitle), formatterCleanups);
actions.applySaveActions(entry);
assertEquals(Optional.of("educational session 1"), entry.getField("title"));
assertEquals(Optional.of("1--7"), entry.getField("pages"));
}
use of org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter in project jabref by JabRef.
the class FieldFormatterCleanupsTest method checkMultipleSaveActions.
@Test
public void checkMultipleSaveActions() {
FieldFormatterCleanups actions = new FieldFormatterCleanups(true, Cleanups.parse("pages[normalize_page_numbers]title[lower_case]"));
List<FieldFormatterCleanup> formatterCleanups = actions.getConfiguredActions();
FieldFormatterCleanup normalizePages = new FieldFormatterCleanup("pages", new NormalizePagesFormatter());
FieldFormatterCleanup lowerCaseTitle = new FieldFormatterCleanup("title", new LowerCaseFormatter());
assertEquals(Arrays.asList(normalizePages, lowerCaseTitle), formatterCleanups);
actions.applySaveActions(entry);
assertEquals(Optional.of("educational session 1"), entry.getField("title"));
assertEquals(Optional.of("1--7"), entry.getField("pages"));
}
Aggregations