Search in sources :

Example 1 with UpperCaseFormatter

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

the class FieldFormatterCleanupTest method testInternalAllField.

@Test
public void testInternalAllField() throws Exception {
    FieldFormatterCleanup cleanup = new FieldFormatterCleanup(FieldName.INTERNAL_ALL_FIELD, new UpperCaseFormatter());
    cleanup.cleanup(entry);
    Assert.assertEquals(fieldMap.get("title").toUpperCase(), entry.getField("title").get());
    Assert.assertEquals(fieldMap.get("booktitle").toUpperCase(), entry.getField("booktitle").get());
    Assert.assertEquals(fieldMap.get("year").toUpperCase(), entry.getField("year").get());
    Assert.assertEquals(fieldMap.get("month").toUpperCase(), entry.getField("month").get());
    Assert.assertEquals(fieldMap.get("abstract").toUpperCase(), entry.getField("abstract").get());
    Assert.assertEquals(fieldMap.get("doi").toUpperCase(), entry.getField("doi").get());
    Assert.assertEquals(fieldMap.get("issn").toUpperCase(), entry.getField("issn").get());
}
Also used : FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) UpperCaseFormatter(org.jabref.logic.formatter.casechanger.UpperCaseFormatter) Test(org.junit.Test)

Example 2 with UpperCaseFormatter

use of org.jabref.logic.formatter.casechanger.UpperCaseFormatter 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 3 with UpperCaseFormatter

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

the class FieldFormatterCleanupTest method testInternalAllTextFieldsField.

@Test
public void testInternalAllTextFieldsField() throws Exception {
    FieldFormatterCleanup cleanup = new FieldFormatterCleanup(FieldName.INTERNAL_ALL_TEXT_FIELDS_FIELD, new UpperCaseFormatter());
    cleanup.cleanup(entry);
    Assert.assertEquals(fieldMap.get("title").toUpperCase(), entry.getField("title").get());
    Assert.assertEquals(fieldMap.get("booktitle").toUpperCase(), entry.getField("booktitle").get());
    Assert.assertEquals(fieldMap.get("year"), entry.getField("year").get());
    Assert.assertEquals(fieldMap.get("month"), entry.getField("month").get());
    Assert.assertEquals(fieldMap.get("abstract").toUpperCase(), entry.getField("abstract").get());
    Assert.assertEquals(fieldMap.get("doi"), entry.getField("doi").get());
    Assert.assertEquals(fieldMap.get("issn"), entry.getField("issn").get());
}
Also used : FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) UpperCaseFormatter(org.jabref.logic.formatter.casechanger.UpperCaseFormatter) Test(org.junit.Test)

Aggregations

UpperCaseFormatter (org.jabref.logic.formatter.casechanger.UpperCaseFormatter)3 FieldFormatterCleanup (org.jabref.model.cleanup.FieldFormatterCleanup)2 Test (org.junit.Test)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 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 NormalizeDateFormatter (org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter)1 NormalizeMonthFormatter (org.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter)1 NormalizeNamesFormatter (org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter)1 NormalizePagesFormatter (org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter)1 OrdinalsToSuperscriptFormatter (org.jabref.logic.formatter.bibtexfields.OrdinalsToSuperscriptFormatter)1 RemoveBracesFormatter (org.jabref.logic.formatter.bibtexfields.RemoveBracesFormatter)1 UnicodeToLatexFormatter (org.jabref.logic.formatter.bibtexfields.UnicodeToLatexFormatter)1