Search in sources :

Example 6 with LowerCaseFormatter

use of org.jabref.logic.formatter.casechanger.LowerCaseFormatter in project jabref by JabRef.

the class Formatters method getFormatterForModifier.

public static Optional<Formatter> getFormatterForModifier(String modifier) {
    Objects.requireNonNull(modifier);
    Optional<Formatter> formatter = ALL.stream().filter(f -> f.getKey().equals(modifier)).findAny();
    if (formatter.isPresent()) {
        return formatter;
    }
    switch(modifier) {
        case "lower":
            return Optional.of(new LowerCaseFormatter());
        case "upper":
            return Optional.of(new UpperCaseFormatter());
        default:
            return Optional.empty();
    }
}
Also used : Arrays(java.util.Arrays) HtmlToUnicodeFormatter(org.jabref.logic.formatter.bibtexfields.HtmlToUnicodeFormatter) NormalizeDateFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter) SentenceCaseFormatter(org.jabref.logic.formatter.casechanger.SentenceCaseFormatter) HtmlToLatexFormatter(org.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter) CapitalizeFormatter(org.jabref.logic.formatter.casechanger.CapitalizeFormatter) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) ArrayList(java.util.ArrayList) LatexCleanupFormatter(org.jabref.logic.formatter.bibtexfields.LatexCleanupFormatter) UnicodeToLatexFormatter(org.jabref.logic.formatter.bibtexfields.UnicodeToLatexFormatter) MinifyNameListFormatter(org.jabref.logic.formatter.minifier.MinifyNameListFormatter) LatexToUnicodeFormatter(org.jabref.logic.layout.format.LatexToUnicodeFormatter) Formatter(org.jabref.model.cleanup.Formatter) UpperCaseFormatter(org.jabref.logic.formatter.casechanger.UpperCaseFormatter) NormalizePagesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter) ProtectTermsFormatter(org.jabref.logic.formatter.casechanger.ProtectTermsFormatter) ClearFormatter(org.jabref.logic.formatter.bibtexfields.ClearFormatter) OrdinalsToSuperscriptFormatter(org.jabref.logic.formatter.bibtexfields.OrdinalsToSuperscriptFormatter) TitleCaseFormatter(org.jabref.logic.formatter.casechanger.TitleCaseFormatter) Objects(java.util.Objects) List(java.util.List) NormalizeMonthFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter) Optional(java.util.Optional) UnitsToLatexFormatter(org.jabref.logic.formatter.bibtexfields.UnitsToLatexFormatter) EscapeUnderscoresFormatter(org.jabref.logic.formatter.bibtexfields.EscapeUnderscoresFormatter) RemoveBracesFormatter(org.jabref.logic.formatter.bibtexfields.RemoveBracesFormatter) NormalizeNamesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter) HtmlToUnicodeFormatter(org.jabref.logic.formatter.bibtexfields.HtmlToUnicodeFormatter) NormalizeDateFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter) SentenceCaseFormatter(org.jabref.logic.formatter.casechanger.SentenceCaseFormatter) HtmlToLatexFormatter(org.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter) CapitalizeFormatter(org.jabref.logic.formatter.casechanger.CapitalizeFormatter) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) LatexCleanupFormatter(org.jabref.logic.formatter.bibtexfields.LatexCleanupFormatter) UnicodeToLatexFormatter(org.jabref.logic.formatter.bibtexfields.UnicodeToLatexFormatter) MinifyNameListFormatter(org.jabref.logic.formatter.minifier.MinifyNameListFormatter) LatexToUnicodeFormatter(org.jabref.logic.layout.format.LatexToUnicodeFormatter) Formatter(org.jabref.model.cleanup.Formatter) UpperCaseFormatter(org.jabref.logic.formatter.casechanger.UpperCaseFormatter) NormalizePagesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter) ProtectTermsFormatter(org.jabref.logic.formatter.casechanger.ProtectTermsFormatter) ClearFormatter(org.jabref.logic.formatter.bibtexfields.ClearFormatter) OrdinalsToSuperscriptFormatter(org.jabref.logic.formatter.bibtexfields.OrdinalsToSuperscriptFormatter) TitleCaseFormatter(org.jabref.logic.formatter.casechanger.TitleCaseFormatter) NormalizeMonthFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter) UnitsToLatexFormatter(org.jabref.logic.formatter.bibtexfields.UnitsToLatexFormatter) EscapeUnderscoresFormatter(org.jabref.logic.formatter.bibtexfields.EscapeUnderscoresFormatter) RemoveBracesFormatter(org.jabref.logic.formatter.bibtexfields.RemoveBracesFormatter) NormalizeNamesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter) UpperCaseFormatter(org.jabref.logic.formatter.casechanger.UpperCaseFormatter) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter)

Example 7 with LowerCaseFormatter

use of org.jabref.logic.formatter.casechanger.LowerCaseFormatter 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"));
}
Also used : NormalizeDateFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) NormalizePagesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) Test(org.junit.Test)

Example 8 with LowerCaseFormatter

use of org.jabref.logic.formatter.casechanger.LowerCaseFormatter in project jabref by JabRef.

the class FieldFormatterCleanupsTest method checkThreeSaveActionsForOneField.

@Test
public void checkThreeSaveActionsForOneField() {
    FieldFormatterCleanups actions = new FieldFormatterCleanups(true, Cleanups.parse("title[lower_case,identity,normalize_date]"));
    FieldFormatterCleanup lowerCaseTitle = new FieldFormatterCleanup("title", new LowerCaseFormatter());
    FieldFormatterCleanup identityInTitle = new FieldFormatterCleanup("title", new IdentityFormatter());
    FieldFormatterCleanup normalizeDatesInTitle = new FieldFormatterCleanup("title", new NormalizeDateFormatter());
    assertEquals(Arrays.asList(lowerCaseTitle, identityInTitle, normalizeDatesInTitle), actions.getConfiguredActions());
    actions.applySaveActions(entry);
    assertEquals(Optional.of("educational session 1"), entry.getField("title"));
}
Also used : IdentityFormatter(org.jabref.logic.formatter.IdentityFormatter) NormalizeDateFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) Test(org.junit.Test)

Example 9 with LowerCaseFormatter

use of org.jabref.logic.formatter.casechanger.LowerCaseFormatter in project jabref by JabRef.

the class FieldFormatterCleanupsTest method checkLowerCaseSaveAction.

@Test
public void checkLowerCaseSaveAction() {
    FieldFormatterCleanups actions = new FieldFormatterCleanups(true, Cleanups.parse("title[lower_case]"));
    FieldFormatterCleanup lowerCaseTitle = new FieldFormatterCleanup("title", new LowerCaseFormatter());
    assertEquals(Collections.singletonList(lowerCaseTitle), actions.getConfiguredActions());
    actions.applySaveActions(entry);
    assertEquals(Optional.of("educational session 1"), entry.getField("title"));
}
Also used : FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) Test(org.junit.Test)

Example 10 with LowerCaseFormatter

use of org.jabref.logic.formatter.casechanger.LowerCaseFormatter 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"));
}
Also used : FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) NormalizePagesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) Test(org.junit.Test)

Aggregations

LowerCaseFormatter (org.jabref.logic.formatter.casechanger.LowerCaseFormatter)11 FieldFormatterCleanup (org.jabref.model.cleanup.FieldFormatterCleanup)10 FieldFormatterCleanups (org.jabref.model.cleanup.FieldFormatterCleanups)10 Test (org.junit.Test)10 NormalizeDateFormatter (org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter)3 NormalizePagesFormatter (org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter)3 StringReader (java.io.StringReader)2 IdentityFormatter (org.jabref.logic.formatter.IdentityFormatter)2 ParserResult (org.jabref.logic.importer.ParserResult)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 TreeMap (java.util.TreeMap)1 ClearFormatter (org.jabref.logic.formatter.bibtexfields.ClearFormatter)1 EscapeUnderscoresFormatter (org.jabref.logic.formatter.bibtexfields.EscapeUnderscoresFormatter)1 HtmlToLatexFormatter (org.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter)1 HtmlToUnicodeFormatter (org.jabref.logic.formatter.bibtexfields.HtmlToUnicodeFormatter)1 LatexCleanupFormatter (org.jabref.logic.formatter.bibtexfields.LatexCleanupFormatter)1