diff --git a/src/main/java/net/sf/jabref/MetaData.java b/src/main/java/net/sf/jabref/MetaData.java index 25dfa6c6fab..5321bc0c95b 100644 --- a/src/main/java/net/sf/jabref/MetaData.java +++ b/src/main/java/net/sf/jabref/MetaData.java @@ -127,10 +127,10 @@ public Optional getSaveOrderConfig() { * Add default metadata for new database: */ public void initializeNewDatabase() { - metaData.put(SELECTOR_META_PREFIX + "keywords", new Vector<>()); + metaData.put(SELECTOR_META_PREFIX + FieldName.KEYWORDS, new Vector<>()); metaData.put(SELECTOR_META_PREFIX + FieldName.AUTHOR, new Vector<>()); - metaData.put(SELECTOR_META_PREFIX + "journal", new Vector<>()); - metaData.put(SELECTOR_META_PREFIX + "publisher", new Vector<>()); + metaData.put(SELECTOR_META_PREFIX + FieldName.JOURNAL, new Vector<>()); + metaData.put(SELECTOR_META_PREFIX + FieldName.PUBLISHER, new Vector<>()); metaData.put(SELECTOR_META_PREFIX + FieldName.REVIEW, new Vector<>()); } diff --git a/src/main/java/net/sf/jabref/gui/ContentSelectorDialog2.java b/src/main/java/net/sf/jabref/gui/ContentSelectorDialog2.java index 7fc85b95459..282d1fbe1b6 100644 --- a/src/main/java/net/sf/jabref/gui/ContentSelectorDialog2.java +++ b/src/main/java/net/sf/jabref/gui/ContentSelectorDialog2.java @@ -322,9 +322,9 @@ private void setupFieldSelector() { if (contents.isEmpty()) { // if nothing was added, put the default fields (as described in the help) fieldListModel.addElement(FieldName.AUTHOR); - fieldListModel.addElement("journal"); - fieldListModel.addElement("keywords"); - fieldListModel.addElement("publisher"); + fieldListModel.addElement(FieldName.JOURNAL); + fieldListModel.addElement(FieldName.KEYWORDS); + fieldListModel.addElement(FieldName.PUBLISHER); } else { for (String s : contents) { fieldListModel.addElement(s); diff --git a/src/main/java/net/sf/jabref/gui/actions/ManageKeywordsAction.java b/src/main/java/net/sf/jabref/gui/actions/ManageKeywordsAction.java index ab2a817742a..20a7da5ffb7 100644 --- a/src/main/java/net/sf/jabref/gui/actions/ManageKeywordsAction.java +++ b/src/main/java/net/sf/jabref/gui/actions/ManageKeywordsAction.java @@ -54,6 +54,7 @@ import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.model.FieldChange; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.FieldName; import net.sf.jabref.preferences.JabRefPreferences; import net.sf.jabref.specialfields.Printed; import net.sf.jabref.specialfields.Priority; @@ -67,8 +68,6 @@ import com.jgoodies.forms.builder.FormBuilder; import com.jgoodies.forms.layout.FormLayout; -import static net.sf.jabref.model.entry.BibEntry.KEYWORDS_FIELD; - /** * An Action for launching keyword managing dialog * @@ -195,7 +194,7 @@ public void keyPressed(KeyEvent arg0) { }); AutoCompleter autoComp = JabRefGUI.getMainFrame().getCurrentBasePanel().getAutoCompleters() - .get(KEYWORDS_FIELD); + .get(FieldName.KEYWORDS); AutoCompleteListener acl = new AutoCompleteListener(autoComp); keyword.addKeyListener(acl); keyword.addFocusListener(acl); diff --git a/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java index 5d1b31b9943..24fb2cb53f2 100644 --- a/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java @@ -262,7 +262,7 @@ private void setupFieldPanels() { Set deprecatedFields = new HashSet<>(EntryConverter.FIELD_ALIASES_TEX_TO_LTX.keySet()); deprecatedFields.add(FieldName.YEAR); - deprecatedFields.add("month"); + deprecatedFields.add(FieldName.MONTH); List secondaryOptionalFields = type.getSecondaryOptionalFields(); List optionalFieldsNotPrimaryOrDeprecated = new ArrayList<>(secondaryOptionalFields); optionalFieldsNotPrimaryOrDeprecated.removeAll(deprecatedFields); @@ -307,7 +307,7 @@ private void setupFieldPanels() { // other fields List displayedFields = Stream.concat(requiredFields.stream(), displayedOptionalFields.stream()).map(String::toLowerCase).collect(Collectors.toList()); List otherFields = entry.getFieldNames().stream().map(String::toLowerCase).filter(f -> !displayedFields.contains(f)).collect(Collectors.toList()); - otherFields.remove("bibtexkey"); + otherFields.remove(BibEntry.KEY_FIELD); otherFields.removeAll(Globals.prefs.getCustomTabFieldNames()); if (!otherFields.isEmpty()) { diff --git a/src/main/java/net/sf/jabref/gui/groups/GroupDialog.java b/src/main/java/net/sf/jabref/gui/groups/GroupDialog.java index 18932a7d4b3..11af83d908f 100644 --- a/src/main/java/net/sf/jabref/gui/groups/GroupDialog.java +++ b/src/main/java/net/sf/jabref/gui/groups/GroupDialog.java @@ -57,6 +57,7 @@ import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.search.SearchQuery; import net.sf.jabref.logic.util.strings.StringUtil; +import net.sf.jabref.model.entry.FieldName; import net.sf.jabref.preferences.JabRefPreferences; import com.jgoodies.forms.builder.ButtonBarBuilder; @@ -89,7 +90,7 @@ class GroupDialog extends JDialog { Localization.lang("Include subgroups: When selected, view entries contained in this group or its subgroups")); // for KeywordGroup private final JTextField keywordGroupSearchField = new JTextField(GroupDialog.TEXTFIELD_LENGTH); - private final TextField keywordGroupSearchTerm = new TextField("keywords", "", false); + private final TextField keywordGroupSearchTerm = new TextField(FieldName.KEYWORDS, "", false); private final JCheckBox keywordGroupCaseSensitive = new JCheckBox(Localization.lang("Case sensitive")); private final JCheckBox keywordGroupRegExp = new JCheckBox(Localization.lang("regular expression")); // for SearchGroup diff --git a/src/main/java/net/sf/jabref/gui/groups/WarnAssignmentSideEffects.java b/src/main/java/net/sf/jabref/gui/groups/WarnAssignmentSideEffects.java index 524b83f3fdf..81406583f3f 100644 --- a/src/main/java/net/sf/jabref/gui/groups/WarnAssignmentSideEffects.java +++ b/src/main/java/net/sf/jabref/gui/groups/WarnAssignmentSideEffects.java @@ -10,6 +10,7 @@ import net.sf.jabref.logic.groups.AbstractGroup; import net.sf.jabref.logic.groups.KeywordGroup; import net.sf.jabref.logic.l10n.Localization; +import net.sf.jabref.model.entry.FieldName; import net.sf.jabref.model.entry.InternalBibtexFields; public class WarnAssignmentSideEffects { @@ -30,7 +31,7 @@ public static boolean warnAssignmentSideEffects(List groups, Comp if (group instanceof KeywordGroup) { KeywordGroup keywordGroup = (KeywordGroup) group; String field = keywordGroup.getSearchField().toLowerCase(); - if ("keywords".equals(field) || "groups".equals(field)) { + if (FieldName.KEYWORDS.equals(field) || "groups".equals(field)) { continue; // this is not undesired } int len = InternalBibtexFields.numberOfPublicFields(); diff --git a/src/main/java/net/sf/jabref/gui/journals/AbbreviateAction.java b/src/main/java/net/sf/jabref/gui/journals/AbbreviateAction.java index ac94c7899d4..26a42cfab76 100644 --- a/src/main/java/net/sf/jabref/gui/journals/AbbreviateAction.java +++ b/src/main/java/net/sf/jabref/gui/journals/AbbreviateAction.java @@ -24,6 +24,7 @@ import net.sf.jabref.logic.journals.JournalAbbreviationPreferences; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.FieldName; /** * Converts journal full names to either iso or medline abbreviations for all selected entries. @@ -60,10 +61,10 @@ public void run() { NamedCompound ce = new NamedCompound(Localization.lang("Abbreviate journal names")); int count = 0; for (BibEntry entry : entries) { - if (undoableAbbreviator.abbreviate(panel.getDatabase(), entry, "journal", ce)) { + if (undoableAbbreviator.abbreviate(panel.getDatabase(), entry, FieldName.JOURNAL, ce)) { count++; } - if (undoableAbbreviator.abbreviate(panel.getDatabase(), entry, "journaltitle", ce)) { + if (undoableAbbreviator.abbreviate(panel.getDatabase(), entry, FieldName.JOURNALTITLE, ce)) { count++; } } diff --git a/src/main/java/net/sf/jabref/gui/journals/UnabbreviateAction.java b/src/main/java/net/sf/jabref/gui/journals/UnabbreviateAction.java index 28b5a3a505b..c4c603a365a 100644 --- a/src/main/java/net/sf/jabref/gui/journals/UnabbreviateAction.java +++ b/src/main/java/net/sf/jabref/gui/journals/UnabbreviateAction.java @@ -24,6 +24,7 @@ import net.sf.jabref.logic.journals.JournalAbbreviationPreferences; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.FieldName; /** * Converts journal abbreviations back to full name for all selected entries. @@ -57,10 +58,10 @@ public void run() { NamedCompound ce = new NamedCompound(Localization.lang("Unabbreviate journal names")); int count = 0; for (BibEntry entry : entries) { - if (undoableAbbreviator.unabbreviate(panel.getDatabase(), entry, "journal", ce)) { + if (undoableAbbreviator.unabbreviate(panel.getDatabase(), entry, FieldName.JOURNAL, ce)) { count++; } - if (undoableAbbreviator.unabbreviate(panel.getDatabase(), entry, "journaltitle", ce)) { + if (undoableAbbreviator.unabbreviate(panel.getDatabase(), entry, FieldName.JOURNALTITLE, ce)) { count++; } } diff --git a/src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java b/src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java index e22eafc01e3..89bc47ee2e2 100644 --- a/src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java +++ b/src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java @@ -376,10 +376,10 @@ private void setupPrevEntry() { prevEntry.setField(FieldName.AUTHOR, "Smith, Bill and Jones, Bob and Williams, Jeff"); prevEntry.setField(FieldName.EDITOR, "Taylor, Phil"); prevEntry.setField(FieldName.TITLE, "Title of the test entry for reference styles"); - prevEntry.setField("volume", "34"); + prevEntry.setField(FieldName.VOLUME, "34"); prevEntry.setField(FieldName.YEAR, "2008"); - prevEntry.setField("journal", "BibTeX journal"); - prevEntry.setField("publisher", "JabRef publishing"); + prevEntry.setField(FieldName.JOURNAL, "BibTeX journal"); + prevEntry.setField(FieldName.PUBLISHER, "JabRef publishing"); prevEntry.setField("address", "Trondheim"); prevEntry.setField("www", "https://github.com/JabRef"); } diff --git a/src/main/java/net/sf/jabref/gui/plaintextimport/TextInputDialog.java b/src/main/java/net/sf/jabref/gui/plaintextimport/TextInputDialog.java index 4107bb59e61..86771d7628d 100644 --- a/src/main/java/net/sf/jabref/gui/plaintextimport/TextInputDialog.java +++ b/src/main/java/net/sf/jabref/gui/plaintextimport/TextInputDialog.java @@ -129,6 +129,7 @@ import net.sf.jabref.model.EntryTypes; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.model.entry.EntryType; +import net.sf.jabref.model.entry.FieldName; import net.sf.jabref.model.entry.FieldProperties; import net.sf.jabref.model.entry.InternalBibtexFields; import net.sf.jabref.preferences.JabRefPreferences; @@ -475,7 +476,7 @@ private void insertTextForTag(boolean overrideField) { // insert a new name with an additional "and" if (InternalBibtexFields.getFieldExtras(fieldName).contains(FieldProperties.PERSON_NAMES)) { entry.setField(fieldName, old.get() + " and " + txt); - } else if ("keywords".equals(fieldName)) { + } else if (FieldName.KEYWORDS.equals(fieldName)) { // Add keyword entry.addKeyword(txt, Globals.prefs.get(JabRefPreferences.KEYWORD_SEPARATOR)); } else { diff --git a/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java b/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java index ccbb504101f..0cb3e3eeb83 100644 --- a/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java +++ b/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java @@ -196,13 +196,13 @@ private static BibEntry getTestEntry() { PreviewPrefsTab.entry.setField(FieldName.TITLE, "Amino acid metabolism and protein turnover in larval turbot (Scophthalmus maximus) fed natural zooplankton or Artemia"); PreviewPrefsTab.entry.setField(FieldName.YEAR, "1997"); - PreviewPrefsTab.entry.setField("journal", "Marine Biology"); - PreviewPrefsTab.entry.setField("month", "January"); - PreviewPrefsTab.entry.setField("number", "2"); - PreviewPrefsTab.entry.setField("volume", "123"); + PreviewPrefsTab.entry.setField(FieldName.JOURNAL, "Marine Biology"); + PreviewPrefsTab.entry.setField(FieldName.MONTH, "January"); + PreviewPrefsTab.entry.setField(FieldName.NUMBER, "2"); + PreviewPrefsTab.entry.setField(FieldName.VOLUME, "123"); PreviewPrefsTab.entry.setField("pdf", "conceicao1997.pdf"); PreviewPrefsTab.entry.setField(FieldName.PAGES, "255--265"); - PreviewPrefsTab.entry.setField("keywords", "energetics, artemia, metabolism, amino acid, turbot"); + PreviewPrefsTab.entry.setField(FieldName.KEYWORDS, "energetics, artemia, metabolism, amino acid, turbot"); PreviewPrefsTab.entry.setField(FieldName.URL, "http://ejournals.ebsco.com/direct.asp?ArticleID=TYY4NT82XA9H7R8PFPPV"); PreviewPrefsTab.entry.setField(FieldName.ABSTRACT, "Abstract The present paper studied the influence of different food regimes " diff --git a/src/main/java/net/sf/jabref/gui/search/SearchResultsDialog.java b/src/main/java/net/sf/jabref/gui/search/SearchResultsDialog.java index 5ac62ad3ef2..a93ff925925 100644 --- a/src/main/java/net/sf/jabref/gui/search/SearchResultsDialog.java +++ b/src/main/java/net/sf/jabref/gui/search/SearchResultsDialog.java @@ -97,7 +97,7 @@ public class SearchResultsDialog { private JDialog diag; private static final String[] FIELDS = new String[] { - FieldName.AUTHOR, FieldName.TITLE, FieldName.YEAR, "journal" + FieldName.AUTHOR, FieldName.TITLE, FieldName.YEAR, FieldName.JOURNAL }; private static final int FILE_COL = 0; private static final int URL_COL = 1; diff --git a/src/main/java/net/sf/jabref/importer/EntryFromFileCreator.java b/src/main/java/net/sf/jabref/importer/EntryFromFileCreator.java index 3910db9d53d..3a845164a00 100644 --- a/src/main/java/net/sf/jabref/importer/EntryFromFileCreator.java +++ b/src/main/java/net/sf/jabref/importer/EntryFromFileCreator.java @@ -108,7 +108,7 @@ public Optional createEntry(File f, boolean addPathTokensAsKeywords) { } if (addPathTokensAsKeywords) { - appendToField(newEntry.get(), "keywords", extractPathesToKeyWordsfield(f.getAbsolutePath())); + appendToField(newEntry.get(), FieldName.KEYWORDS, extractPathesToKeyWordsfield(f.getAbsolutePath())); } if (!newEntry.get().hasField(FieldName.TITLE)) { diff --git a/src/main/java/net/sf/jabref/importer/EntryFromPDFCreator.java b/src/main/java/net/sf/jabref/importer/EntryFromPDFCreator.java index 2b78cd1a70b..bd2c4cec29d 100644 --- a/src/main/java/net/sf/jabref/importer/EntryFromPDFCreator.java +++ b/src/main/java/net/sf/jabref/importer/EntryFromPDFCreator.java @@ -14,6 +14,7 @@ import net.sf.jabref.gui.IconTheme; import net.sf.jabref.logic.xmp.XMPUtil; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.InternalBibtexFields; import net.sf.jabref.pdfimport.PdfImporter; import net.sf.jabref.pdfimport.PdfImporter.ImportPdfFilesResult; @@ -96,7 +97,7 @@ private void addEntryDataFromPDDocumentInformation(File pdfFile, BibEntry entry) // default time stamp follows ISO-8601. Reason: https://xkcd.com/1179/ String date = new SimpleDateFormat("yyyy-MM-dd") .format(creationDate.getTime()); - appendToField(entry, "timestamp", date); + appendToField(entry, InternalBibtexFields.TIMESTAMP, date); } if (pdfDocInfo.getCustomMetadataValue("bibtex/bibtexkey") != null) { diff --git a/src/main/java/net/sf/jabref/importer/OAI2Handler.java b/src/main/java/net/sf/jabref/importer/OAI2Handler.java index df8522881b7..c46dfbf6531 100644 --- a/src/main/java/net/sf/jabref/importer/OAI2Handler.java +++ b/src/main/java/net/sf/jabref/importer/OAI2Handler.java @@ -80,10 +80,10 @@ public void endElement(String uri, String localName, String qualifiedName) throw forenames = content; } else if ("journal-ref".equals(qualifiedName)) { String journal = content.replaceFirst("[0-9].*", ""); - entry.setField("journal", journal); + entry.setField(FieldName.JOURNAL, journal); String volume = content.replaceFirst(journal, ""); volume = volume.replaceFirst(" .*", ""); - entry.setField("volume", volume); + entry.setField(FieldName.VOLUME, volume); String year = content.replaceFirst(".*?\\(", ""); year = year.replaceFirst("\\).*", ""); entry.setField(FieldName.YEAR, year); diff --git a/src/main/java/net/sf/jabref/importer/fetcher/GVKParser.java b/src/main/java/net/sf/jabref/importer/fetcher/GVKParser.java index 1ab9af461bb..905c33fcc31 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/GVKParser.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/GVKParser.java @@ -385,7 +385,7 @@ private BibEntry parseEntry(Element e) { result.setField("subtitle", newSubtitle.toString()); } if (publisher != null) { - result.setField("publisher", publisher); + result.setField(FieldName.PUBLISHER, publisher); } if (year != null) { result.setField(FieldName.YEAR, year); @@ -406,7 +406,7 @@ private BibEntry parseEntry(Element e) { result.setField(FieldName.ISSN, issn); } if (number != null) { - result.setField("number", number); + result.setField(FieldName.NUMBER, number); } if (pagetotal != null) { result.setField("pagetotal", pagetotal); @@ -415,10 +415,10 @@ private BibEntry parseEntry(Element e) { result.setField(FieldName.PAGES, pages); } if (volume != null) { - result.setField("volume", volume); + result.setField(FieldName.VOLUME, volume); } if (journal != null) { - result.setField("journal", journal); + result.setField(FieldName.JOURNAL, journal); } if (ppn != null) { result.setField("ppn_GVK", ppn); @@ -431,7 +431,7 @@ private BibEntry parseEntry(Element e) { } if ("article".equals(entryType) && (journal != null)) { - result.setField("journal", journal); + result.setField(FieldName.JOURNAL, journal); } else if ("incollection".equals(entryType) && (booktitle != null)) { result.setField("booktitle", booktitle); } diff --git a/src/main/java/net/sf/jabref/importer/fetcher/IEEEXploreFetcher.java b/src/main/java/net/sf/jabref/importer/fetcher/IEEEXploreFetcher.java index 0cce39ce67a..d3484928d0d 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/IEEEXploreFetcher.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/IEEEXploreFetcher.java @@ -322,7 +322,7 @@ private BibEntry cleanup(BibEntry entry) { } // clean up month - String month = entry.getField("month"); + String month = entry.getField(FieldName.MONTH); if ((month != null) && !month.isEmpty()) { month = month.replace(".", ""); month = month.toLowerCase(); @@ -352,7 +352,7 @@ private BibEntry cleanup(BibEntry entry) { .append(mm.group(3)).append(','); } } - entry.setField("month", date.toString()); + entry.setField(FieldName.MONTH, date.toString()); } // clean up pages @@ -372,7 +372,7 @@ private BibEntry cleanup(BibEntry entry) { String type = entry.getType(); String sourceField = ""; if ("article".equals(type)) { - sourceField = "journal"; + sourceField = FieldName.JOURNAL; entry.clearField("booktitle"); } else if ("inproceedings".equals(type)) { sourceField = "booktitle"; @@ -384,9 +384,9 @@ private BibEntry cleanup(BibEntry entry) { if (ind > 0) { fullName = fullName.substring(0, ind); entry.setField(FieldName.YEAR, "to be published"); - entry.clearField("month"); + entry.clearField(FieldName.MONTH); entry.clearField(FieldName.PAGES); - entry.clearField("number"); + entry.clearField(FieldName.NUMBER); } String[] parts = fullName.split("[\\[\\]]"); //[see also...], [legacy...] fullName = parts[0]; @@ -396,9 +396,9 @@ private BibEntry cleanup(BibEntry entry) { String note = entry.getField("note"); if ("Early Access".equals(note)) { entry.setField(FieldName.YEAR, "to be published"); - entry.clearField("month"); + entry.clearField(FieldName.MONTH); entry.clearField(FieldName.PAGES); - entry.clearField("number"); + entry.clearField(FieldName.NUMBER); } } else { fullName = fullName.replace("Conference Proceedings", "Proceedings") @@ -510,7 +510,7 @@ private BibEntry cleanup(BibEntry entry) { .ifPresent(url -> entry.setField(FieldName.URL, "http://ieeexplore.ieee.org" + url.replace("tp=&", ""))); // Replace ; as keyword separator - entry.getFieldOptional("keywords").ifPresent(keys -> entry.setField("keywords", + entry.getFieldOptional(FieldName.KEYWORDS).ifPresent(keys -> entry.setField(FieldName.KEYWORDS, keys.replace(";", Globals.prefs.get(JabRefPreferences.KEYWORD_SEPARATOR)))); return entry; } diff --git a/src/main/java/net/sf/jabref/importer/fetcher/OAI2Fetcher.java b/src/main/java/net/sf/jabref/importer/fetcher/OAI2Fetcher.java index 6c7ee5f03ff..0ecc84b97c8 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/OAI2Fetcher.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/OAI2Fetcher.java @@ -212,7 +212,7 @@ public BibEntry importOai2Entry(String key) { int monthNumber = Integer.parseInt(fixedKey.substring(2, 4)); MonthUtil.Month month = MonthUtil.getMonthByNumber(monthNumber); if (month.isValid()) { - be.setField("month", month.bibtexFormat); + be.setField(FieldName.MONTH, month.bibtexFormat); } } } diff --git a/src/main/java/net/sf/jabref/importer/fileformat/BiblioscapeImporter.java b/src/main/java/net/sf/jabref/importer/fileformat/BiblioscapeImporter.java index ca0c1d43785..07422b6344a 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/BiblioscapeImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/BiblioscapeImporter.java @@ -95,10 +95,10 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { hm.put(FieldName.YEAR, entry .getValue().toString()); } else if ("VL".equals(entry.getKey())) { - hm.put("volume", entry + hm.put(FieldName.VOLUME, entry .getValue().toString()); } else if ("NB".equals(entry.getKey())) { - hm.put("number", entry + hm.put(FieldName.NUMBER, entry .getValue().toString()); } else if ("PS".equals(entry.getKey())) { pages[0] = entry.getValue() @@ -107,7 +107,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { pages[1] = entry.getValue() .toString(); } else if ("KW".equals(entry.getKey())) { - hm.put("keywords", entry + hm.put(FieldName.KEYWORDS, entry .getValue().toString()); } else if ("RT".equals(entry.getKey())) { type[0] = entry.getValue() @@ -122,7 +122,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { hm.put("note", entry .getValue().toString()); } else if ("PB".equals(entry.getKey())) { - hm.put("publisher", entry + hm.put(FieldName.PUBLISHER, entry .getValue().toString()); } else if ("TA".equals(entry.getKey())) { comments @@ -232,7 +232,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { // titleTI if ("article".equals(bibtexType)) { if (titleST != null) { - hm.put("journal", titleST); + hm.put(FieldName.JOURNAL, titleST); } if (titleTI != null) { hm.put(FieldName.TITLE, titleTI); diff --git a/src/main/java/net/sf/jabref/importer/fileformat/BibtexParser.java b/src/main/java/net/sf/jabref/importer/fileformat/BibtexParser.java index 9cfd91af080..d9ec808c196 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/BibtexParser.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/BibtexParser.java @@ -41,6 +41,7 @@ import net.sf.jabref.model.entry.BibtexString; import net.sf.jabref.model.entry.CustomEntryType; import net.sf.jabref.model.entry.EntryType; +import net.sf.jabref.model.entry.FieldName; import net.sf.jabref.model.entry.FieldProperties; import net.sf.jabref.model.entry.IdGenerator; import net.sf.jabref.model.entry.InternalBibtexFields; @@ -563,7 +564,7 @@ private void parseField(BibEntry entry) throws IOException { // for users if JabRef didn't accept it. if (InternalBibtexFields.getFieldExtras(key).contains(FieldProperties.PERSON_NAMES)) { entry.setField(key, entry.getFieldOptional(key).get() + " and " + content); - } else if ("keywords".equals(key)) { + } else if (FieldName.KEYWORDS.equals(key)) { //multiple keywords fields should be combined to one entry.addKeyword(content, Globals.prefs.get(JabRefPreferences.KEYWORD_SEPARATOR)); } diff --git a/src/main/java/net/sf/jabref/importer/fileformat/CopacImporter.java b/src/main/java/net/sf/jabref/importer/fileformat/CopacImporter.java index 7c94b7b853a..ded1972dc61 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/CopacImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/CopacImporter.java @@ -130,13 +130,13 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } else if ("PY- ".equals(code)) { setOrAppend(b, FieldName.YEAR, line.substring(4).trim(), ", "); } else if ("PU- ".equals(code)) { - setOrAppend(b, "publisher", line.substring(4).trim(), ", "); + setOrAppend(b, FieldName.PUBLISHER, line.substring(4).trim(), ", "); } else if ("SE- ".equals(code)) { setOrAppend(b, "series", line.substring(4).trim(), ", "); } else if ("IS- ".equals(code)) { setOrAppend(b, FieldName.ISBN, line.substring(4).trim(), ", "); } else if ("KW- ".equals(code)) { - setOrAppend(b, "keywords", line.substring(4).trim(), ", "); + setOrAppend(b, FieldName.KEYWORDS, line.substring(4).trim(), ", "); } else if ("NT- ".equals(code)) { setOrAppend(b, "note", line.substring(4).trim(), ", "); } else if ("PD- ".equals(code)) { diff --git a/src/main/java/net/sf/jabref/importer/fileformat/EndnoteImporter.java b/src/main/java/net/sf/jabref/importer/fileformat/EndnoteImporter.java index f2a50fbc367..44a5b9e5a9f 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/EndnoteImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/EndnoteImporter.java @@ -182,12 +182,12 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } else if ("J".equals(prefix)) { // "Alternate journal. Let's set it only if no journal // has been set with %B. - hm.putIfAbsent("journal", val); + hm.putIfAbsent(FieldName.JOURNAL, val); } else if ("B".equals(prefix)) { // This prefix stands for "journal" in a journal entry, and // "series" in a book entry. if ("article".equals(type)) { - hm.put("journal", val); + hm.put(FieldName.JOURNAL, val); } else if ("book".equals(type) || "inbook".equals(type)) { hm.put("series", val); } else { @@ -198,16 +198,16 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { if ("phdthesis".equals(type)) { hm.put("school", val); } else { - hm.put("publisher", val); + hm.put(FieldName.PUBLISHER, val); } } // replace single dash page ranges (23-45) with double dashes (23--45): else if ("P".equals(prefix)) { hm.put(FieldName.PAGES, val.replaceAll("([0-9]) *- *([0-9])", "$1--$2")); } else if ("V".equals(prefix)) { - hm.put("volume", val); + hm.put(FieldName.VOLUME, val); } else if ("N".equals(prefix)) { - hm.put("number", val); + hm.put(FieldName.NUMBER, val); } else if ("U".equals(prefix)) { hm.put(FieldName.URL, val); } else if ("R".equals(prefix)) { @@ -225,7 +225,7 @@ else if ("P".equals(prefix)) { hm.put("note", val); } } else if ("K".equals(prefix)) { - hm.put("keywords", val); + hm.put(FieldName.KEYWORDS, val); } else if ("X".equals(prefix)) { hm.put(FieldName.ABSTRACT, val); } else if ("9".equals(prefix)) { diff --git a/src/main/java/net/sf/jabref/importer/fileformat/FreeCiteImporter.java b/src/main/java/net/sf/jabref/importer/fileformat/FreeCiteImporter.java index 75ab875fff4..35d53738b8f 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/FreeCiteImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/FreeCiteImporter.java @@ -154,7 +154,7 @@ public ParserResult importEntries(String text) { // end:authors } e.setField(FieldName.AUTHOR, sb.toString()); - } else if ("journal".equals(ln)) { + } else if (FieldName.JOURNAL.equals(ln)) { // we guess that the entry is a journal // the alternative way is to parse // ctx:context-objects / ctx:context-object / ctx:referent / ctx:metadata-by-val / ctx:metadata / journal / rft:genre @@ -165,16 +165,16 @@ public ParserResult importEntries(String text) { } else if ("tech".equals(ln)) { type = BibtexEntryTypes.TECHREPORT; // the content of the "tech" field seems to contain the number of the technical report - e.setField("number", parser.getElementText()); + e.setField(FieldName.NUMBER, parser.getElementText()); } else if (FieldName.DOI.equals(ln) || "institution".equals(ln) || "location".equals(ln) - || "number".equals(ln) + || FieldName.NUMBER.equals(ln) || "note".equals(ln) || FieldName.TITLE.equals(ln) || FieldName.PAGES.equals(ln) - || "publisher".equals(ln) - || "volume".equals(ln) + || FieldName.PUBLISHER.equals(ln) + || FieldName.VOLUME.equals(ln) || FieldName.YEAR.equals(ln)) { e.setField(ln, parser.getElementText()); } else if ("booktitle".equals(ln)) { diff --git a/src/main/java/net/sf/jabref/importer/fileformat/InspecImporter.java b/src/main/java/net/sf/jabref/importer/fileformat/InspecImporter.java index 3f68cd8e97c..f8953eedd87 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/InspecImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/InspecImporter.java @@ -101,12 +101,12 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } else if ("AB".equals(f3)) { h.put(FieldName.ABSTRACT, frest); } else if ("ID".equals(f3)) { - h.put("keywords", frest); + h.put(FieldName.KEYWORDS, frest); } else if ("SO".equals(f3)) { int m = frest.indexOf('.'); if (m >= 0) { String jr = frest.substring(0, m); - h.put("journal", jr.replace("-", " ")); + h.put(FieldName.JOURNAL, jr.replace("-", " ")); frest = frest.substring(m); m = frest.indexOf(';'); if (m >= 5) { @@ -118,7 +118,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { String pg = frest.substring(m + 1).trim(); h.put(FieldName.PAGES, pg); String vol = frest.substring(1, m).trim(); - h.put("volume", vol); + h.put(FieldName.VOLUME, vol); } } } diff --git a/src/main/java/net/sf/jabref/importer/fileformat/IsiImporter.java b/src/main/java/net/sf/jabref/importer/fileformat/IsiImporter.java index 947d6c460ff..b1c3835b153 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/IsiImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/IsiImporter.java @@ -133,7 +133,7 @@ public static void processSubSup(Map map) { private static void processCapitalization(Map map) { - String[] subsup = {FieldName.TITLE, "journal", "publisher"}; + String[] subsup = {FieldName.TITLE, FieldName.JOURNAL, FieldName.PUBLISHER}; for (String aSubsup : subsup) { @@ -240,17 +240,17 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } else if ("TI".equals(beg)) { hm.put(FieldName.TITLE, value.replace("EOLEOL", " ")); } else if ("SO".equals(beg) || "JA".equals(beg)) { - hm.put("journal", value.replace("EOLEOL", " ")); + hm.put(FieldName.JOURNAL, value.replace("EOLEOL", " ")); } else if ("ID".equals(beg) || "KW".equals(beg)) { value = value.replace("EOLEOL", " "); - String existingKeywords = hm.get("keywords"); + String existingKeywords = hm.get(FieldName.KEYWORDS); if ((existingKeywords == null) || existingKeywords.contains(value)) { existingKeywords = value; } else { existingKeywords += ", " + value; } - hm.put("keywords", existingKeywords); + hm.put(FieldName.KEYWORDS, existingKeywords); } else if ("AB".equals(beg)) { hm.put(FieldName.ABSTRACT, value.replace("EOLEOL", " ")); @@ -270,20 +270,20 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } else if ("AR".equals(beg)) { pages = value; } else if ("IS".equals(beg)) { - hm.put("number", value); + hm.put(FieldName.NUMBER, value); } else if ("PY".equals(beg)) { hm.put(FieldName.YEAR, value); } else if ("VL".equals(beg)) { - hm.put("volume", value); + hm.put(FieldName.VOLUME, value); } else if ("PU".equals(beg)) { - hm.put("publisher", value); + hm.put(FieldName.PUBLISHER, value); } else if ("DI".equals(beg)) { hm.put(FieldName.DOI, value); } else if ("PD".equals(beg)) { String month = IsiImporter.parseMonth(value); if (month != null) { - hm.put("month", month); + hm.put(FieldName.MONTH, month); } } else if ("DT".equals(beg)) { diff --git a/src/main/java/net/sf/jabref/importer/fileformat/JSONEntryParser.java b/src/main/java/net/sf/jabref/importer/fileformat/JSONEntryParser.java index 441061e11fb..badc3fdb766 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/JSONEntryParser.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/JSONEntryParser.java @@ -43,10 +43,10 @@ public class JSONEntryParser { */ public BibEntry parseBibJSONtoBibtex(JSONObject bibJsonEntry) { // Fields that are directly accessible at the top level BibJson object - String[] singleFieldStrings = {FieldName.YEAR, FieldName.TITLE, FieldName.ABSTRACT, "month"}; + String[] singleFieldStrings = {FieldName.YEAR, FieldName.TITLE, FieldName.ABSTRACT, FieldName.MONTH}; // Fields that are accessible in the journal part of the BibJson object - String[] journalSingleFieldStrings = {"publisher", "number", "volume"}; + String[] journalSingleFieldStrings = {FieldName.PUBLISHER, FieldName.NUMBER, FieldName.VOLUME}; @@ -91,7 +91,7 @@ public BibEntry parseBibJSONtoBibtex(JSONObject bibJsonEntry) { JSONObject journal = bibJsonEntry.getJSONObject("journal"); // Journal title if (journal.has("title")) { - entry.setField("journal", journal.getString("title")); + entry.setField(FieldName.JOURNAL, journal.getString("title")); } else { LOGGER.info("No journal title found."); } @@ -156,8 +156,8 @@ public BibEntry parseBibJSONtoBibtex(JSONObject bibJsonEntry) { */ public static BibEntry parseSpringerJSONtoBibtex(JSONObject springerJsonEntry) { // Fields that are directly accessible at the top level Json object - String[] singleFieldStrings = {FieldName.ISSN, "volume", FieldName.ABSTRACT, FieldName.DOI, FieldName.TITLE, "number", - "publisher"}; + String[] singleFieldStrings = {FieldName.ISSN, FieldName.VOLUME, FieldName.ABSTRACT, FieldName.DOI, FieldName.TITLE, FieldName.NUMBER, + FieldName.PUBLISHER}; BibEntry entry = new BibEntry(); String nametype; @@ -167,7 +167,7 @@ public static BibEntry parseSpringerJSONtoBibtex(JSONObject springerJsonEntry) { if (com.google.common.base.Strings.isNullOrEmpty(isbn)) { // Probably article entry.setType("article"); - nametype = "journal"; + nametype = FieldName.JOURNAL; } else { // Probably book chapter or from proceeding, go for book chapter entry.setType("incollection"); @@ -232,7 +232,7 @@ public static BibEntry parseSpringerJSONtoBibtex(JSONObject springerJsonEntry) { entry.setField(FieldName.DATE, date); // For BibLatex String[] dateparts = date.split("-"); entry.setField(FieldName.YEAR, dateparts[0]); - entry.setField("month", MonthUtil.getMonthByNumber(Integer.parseInt(dateparts[1])).bibtexFormat); + entry.setField(FieldName.MONTH, MonthUtil.getMonthByNumber(Integer.parseInt(dateparts[1])).bibtexFormat); } // Clean up abstract (often starting with Abstract) diff --git a/src/main/java/net/sf/jabref/importer/fileformat/MedlineHandler.java b/src/main/java/net/sf/jabref/importer/fileformat/MedlineHandler.java index 04d96a7622b..43a6f822378 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/MedlineHandler.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/MedlineHandler.java @@ -237,7 +237,7 @@ public void endElement(String uri, String localName, String qName) { } // if (!title.equals("")) b.setField("title",Util.replaceSpecialCharacters(title)); if (!"".equals(journal)) { - b.setField("journal", journal); + b.setField(FieldName.JOURNAL, journal); } if (!"".equals(year)) { b.setField(FieldName.YEAR, year); @@ -247,7 +247,7 @@ public void endElement(String uri, String localName, String qName) { b.setField(FieldName.PAGES, fixPageRange(page)); } if (!"".equals(volume)) { - b.setField("volume", volume); + b.setField(FieldName.VOLUME, volume); } if (!"".equals(language)) { b.setField("language", language); @@ -259,14 +259,14 @@ public void endElement(String uri, String localName, String qName) { b.setField(FieldName.ABSTRACT, abstractText.replace("%", "\\%")); } if (!"".equals(keywords)) { - b.setField("keywords", keywords); + b.setField(FieldName.KEYWORDS, keywords); } if (!"".equals(month)) { - b.setField("month", month); + b.setField(FieldName.MONTH, month); } //if (!url.equals("")) b.setField("url",url); if (!"".equals(number)) { - b.setField("number", number); + b.setField(FieldName.NUMBER, number); } if (!"".equals(doi)) { diff --git a/src/main/java/net/sf/jabref/importer/fileformat/MedlinePlainImporter.java b/src/main/java/net/sf/jabref/importer/fileformat/MedlinePlainImporter.java index 2ac838f924c..a73dfed8f79 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/MedlinePlainImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/MedlinePlainImporter.java @@ -160,7 +160,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { hashMap.put("PL", "address"); hashMap.put("PHST", "history"); hashMap.put("PST", "publication-status"); - hashMap.put("VI", "volume"); + hashMap.put("VI", FieldName.VOLUME); hashMap.put("LA", "language"); hashMap.put("LA", "language"); hashMap.put("PUBM", "model"); @@ -168,7 +168,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { hashMap.put("NM", "substance-name"); hashMap.put("OCI", "copyright-owner"); hashMap.put("CN", "corporate"); - hashMap.put("IP", "issue"); + hashMap.put("IP", FieldName.ISSUE); hashMap.put("EN", "edition"); hashMap.put("GS", "gene-symbol"); hashMap.put("GN", "note"); @@ -198,11 +198,11 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { fields.put("investigator", oldInvestigator + ", " + value); } } else if ("MH".equals(label) || "OT".equals(label)) { - if (!fields.containsKey("keywords")) { - fields.put("keywords", value); + if (!fields.containsKey(FieldName.KEYWORDS)) { + fields.put(FieldName.KEYWORDS, value); } else { - String kw = fields.get("keywords"); - fields.put("keywords", kw + ", " + value); + String kw = fields.get(FieldName.KEYWORDS); + fields.put(FieldName.KEYWORDS, kw + ", " + value); } } else if ("CON".equals(label) || "CIN".equals(label) || "EIN".equals(label) || "EFR".equals(label) || "CRI".equals(label) || "CRF".equals(label) || "PRIN".equals(label) || "PROF".equals(label) @@ -346,7 +346,7 @@ private void addTitles(Map hm, String lab, String val, String ty if ("inproceedings".equals(type)) { hm.put("booktitle", val); } else { - hm.put("journal", val); + hm.put(FieldName.JOURNAL, val); } } else if ("CTI".equals(lab)) { hm.put("collection-title", val); @@ -398,7 +398,7 @@ private void addDates(Map hm, String lab, String val) { String[] parts = val.split(" "); hm.put(FieldName.YEAR, parts[0]); if ((parts.length > 1) && !parts[1].isEmpty()) { - hm.put("month", parts[1]); + hm.put(FieldName.MONTH, parts[1]); } } else if ("EDAT".equals(lab) && isCreateDateFormat(val)) { hm.put("publication", val); diff --git a/src/main/java/net/sf/jabref/importer/fileformat/OvidImporter.java b/src/main/java/net/sf/jabref/importer/fileformat/OvidImporter.java index 730fb8c2e3a..32689b7d4ce 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/OvidImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/OvidImporter.java @@ -134,22 +134,22 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } else if (fieldName.startsWith("Source")) { Matcher matcher; if ((matcher = OvidImporter.OVID_SOURCE_PATTERN.matcher(content)).find()) { - h.put("journal", matcher.group(1)); - h.put("volume", matcher.group(2)); - h.put("issue", matcher.group(3)); + h.put(FieldName.JOURNAL, matcher.group(1)); + h.put(FieldName.VOLUME, matcher.group(2)); + h.put(FieldName.ISSUE, matcher.group(3)); h.put(FieldName.PAGES, matcher.group(4)); h.put(FieldName.YEAR, matcher.group(5)); } else if ((matcher = OvidImporter.OVID_SOURCE_PATTERN_NO_ISSUE.matcher(content)).find()) {// may be missing the issue - h.put("journal", matcher.group(1)); - h.put("volume", matcher.group(2)); + h.put(FieldName.JOURNAL, matcher.group(1)); + h.put(FieldName.VOLUME, matcher.group(2)); h.put(FieldName.PAGES, matcher.group(3)); h.put(FieldName.YEAR, matcher.group(4)); } else if ((matcher = OvidImporter.OVID_SOURCE_PATTERN_2.matcher(content)).find()) { - h.put("journal", matcher.group(1)); - h.put("volume", matcher.group(2)); - h.put("issue", matcher.group(3)); - h.put("month", matcher.group(4)); + h.put(FieldName.JOURNAL, matcher.group(1)); + h.put(FieldName.VOLUME, matcher.group(2)); + h.put(FieldName.ISSUE, matcher.group(3)); + h.put(FieldName.MONTH, matcher.group(4)); h.put(FieldName.YEAR, matcher.group(5)); h.put(FieldName.PAGES, matcher.group(6)); @@ -159,12 +159,12 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { h.put("booktitle", matcher.group(3)); h.put(FieldName.PAGES, matcher.group(4)); h.put("address", matcher.group(5)); - h.put("publisher", matcher.group(6)); + h.put(FieldName.PUBLISHER, matcher.group(6)); } else if ((matcher = OvidImporter.BOOK_PATTERN.matcher(content)).find()) { h.put(FieldName.YEAR, matcher.group(1)); h.put(FieldName.PAGES, matcher.group(2)); h.put("address", matcher.group(3)); - h.put("publisher", matcher.group(4)); + h.put(FieldName.PUBLISHER, matcher.group(4)); } // Add double hyphens to page ranges: @@ -187,7 +187,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { h.put("language", content); } else if (fieldName.startsWith("Author Keywords")) { content = content.replace(";", ",").replace(" ", " "); - h.put("keywords", content); + h.put(FieldName.KEYWORDS, content); } else if (fieldName.startsWith("ISSN")) { h.put(FieldName.ISSN, content); } else if (fieldName.startsWith("DOI Number")) { diff --git a/src/main/java/net/sf/jabref/importer/fileformat/PdfContentImporter.java b/src/main/java/net/sf/jabref/importer/fileformat/PdfContentImporter.java index a575794277b..97ac6e5b816 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/PdfContentImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/PdfContentImporter.java @@ -452,7 +452,7 @@ public ParserResult importDatabase(Path filePath, Charset defaultEncoding) { entry.setField(FieldName.ABSTRACT, abstractT); } if (!Strings.isNullOrEmpty(keywords)) { - entry.setField("keywords", keywords); + entry.setField(FieldName.KEYWORDS, keywords); } if (title != null) { entry.setField(FieldName.TITLE, title); @@ -467,10 +467,10 @@ public ParserResult importDatabase(Path filePath, Charset defaultEncoding) { entry.setField("series", series); } if (volume != null) { - entry.setField("volume", volume); + entry.setField(FieldName.VOLUME, volume); } if (number != null) { - entry.setField("number", number); + entry.setField(FieldName.NUMBER, number); } if (pages != null) { entry.setField(FieldName.PAGES, pages); @@ -479,7 +479,7 @@ public ParserResult importDatabase(Path filePath, Charset defaultEncoding) { entry.setField(FieldName.YEAR, year); } if (publisher != null) { - entry.setField("publisher", publisher); + entry.setField(FieldName.PUBLISHER, publisher); } result.add(entry); diff --git a/src/main/java/net/sf/jabref/importer/fileformat/RepecNepImporter.java b/src/main/java/net/sf/jabref/importer/fileformat/RepecNepImporter.java index 45a89a38f30..89ba9e6f382 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/RepecNepImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/RepecNepImporter.java @@ -377,7 +377,7 @@ private void parseAdditionalFields(BibEntry be, boolean multilineUrlFieldAllowed cal.setTime(date == null ? new Date() : date); be.setField(FieldName.YEAR, String.valueOf(cal.get(Calendar.YEAR))); if ((date != null) && recognizedDateFormats[i - 1].contains("MM")) { - be.setField("month", String.valueOf(cal.get(Calendar.MONTH) + 1)); + be.setField(FieldName.MONTH, String.valueOf(cal.get(Calendar.MONTH) + 1)); } if ((date != null) && recognizedDateFormats[i - 1].contains("dd")) { be.setField("day", String.valueOf(cal.get(Calendar.DAY_OF_MONTH))); diff --git a/src/main/java/net/sf/jabref/importer/fileformat/RisImporter.java b/src/main/java/net/sf/jabref/importer/fileformat/RisImporter.java index e6be2fe9475..29c10eaffc2 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/RisImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/RisImporter.java @@ -166,7 +166,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { if ("inproceedings".equals(type)) { hm.put("booktitle", val); } else { - hm.put("journal", val); + hm.put(FieldName.JOURNAL, val); } } else if ("SP".equals(lab)) { startPage = val; @@ -174,7 +174,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { if ("phdthesis".equals(type)) { hm.put("school", val); } else { - hm.put("publisher", val); + hm.put(FieldName.PUBLISHER, val); } } else if ("AD".equals(lab) || "CY".equals(lab)) { hm.put("address", val); @@ -186,9 +186,9 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } else if ("SN".equals(lab)) { hm.put(FieldName.ISSN, val); } else if ("VL".equals(lab)) { - hm.put("volume", val); + hm.put(FieldName.VOLUME, val); } else if ("IS".equals(lab)) { - hm.put("number", val); + hm.put(FieldName.NUMBER, val); } else if ("N2".equals(lab) || "AB".equals(lab)) { String oldAb = hm.get(FieldName.ABSTRACT); if (oldAb == null) { @@ -207,18 +207,18 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { int monthNumber = Integer.parseInt(parts[1]); MonthUtil.Month month = MonthUtil.getMonthByNumber(monthNumber); if (month.isValid()) { - hm.put("month", month.bibtexFormat); + hm.put(FieldName.MONTH, month.bibtexFormat); } } catch (NumberFormatException ex) { // The month part is unparseable, so we ignore it. } } } else if ("KW".equals(lab)) { - if (hm.containsKey("keywords")) { - String kw = hm.get("keywords"); - hm.put("keywords", kw + ", " + val); + if (hm.containsKey(FieldName.KEYWORDS)) { + String kw = hm.get(FieldName.KEYWORDS); + hm.put(FieldName.KEYWORDS, kw + ", " + val); } else { - hm.put("keywords", val); + hm.put(FieldName.KEYWORDS, val); } } else if ("U1".equals(lab) || "U2".equals(lab) || "N1".equals(lab)) { if (!comment.isEmpty()) { diff --git a/src/main/java/net/sf/jabref/importer/fileformat/SilverPlatterImporter.java b/src/main/java/net/sf/jabref/importer/fileformat/SilverPlatterImporter.java index df8b0aa8e87..e0db96ec5a7 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/SilverPlatterImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/SilverPlatterImporter.java @@ -116,12 +116,12 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { h.put(FieldName.ABSTRACT, frest); } else if ("DE".equals(f3)) { String kw = frest.replace("-;", ",").toLowerCase(); - h.put("keywords", kw.substring(0, kw.length() - 1)); + h.put(FieldName.KEYWORDS, kw.substring(0, kw.length() - 1)); } else if ("SO".equals(f3)) { int m = frest.indexOf('.'); if (m >= 0) { String jr = frest.substring(0, m); - h.put("journal", jr.replace("-", " ")); + h.put(FieldName.JOURNAL, jr.replace("-", " ")); frest = frest.substring(m); m = frest.indexOf(';'); if (m >= 5) { @@ -134,8 +134,8 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { if (m >= 0) { String pg = frest.substring(m + 1).trim(); h.put(FieldName.PAGES, pg); - h.put("volume", frest.substring(1, issueIndex).trim()); - h.put("issue", frest.substring(issueIndex + 1, endIssueIndex).trim()); + h.put(FieldName.VOLUME, frest.substring(1, issueIndex).trim()); + h.put(FieldName.ISSUE, frest.substring(issueIndex + 1, endIssueIndex).trim()); } } } @@ -143,7 +143,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { int m = frest.indexOf(':'); if (m >= 0) { String jr = frest.substring(0, m); - h.put("publisher", jr.replace("-", " ").trim()); + h.put(FieldName.PUBLISHER, jr.replace("-", " ").trim()); frest = frest.substring(m); m = frest.indexOf(", "); if ((m + 2) < frest.length()) { @@ -168,7 +168,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { type = "book"; } else if (frest.startsWith("Dissertation")) { type = "phdthesis"; - } else if (frest.toLowerCase().contains("journal")) { + } else if (frest.toLowerCase().contains(FieldName.JOURNAL)) { type = "article"; } else if ("Contribution".equals(frest) || "Chapter".equals(frest)) { type = "incollection"; diff --git a/src/main/java/net/sf/jabref/logic/autocompleter/AutoCompleterFactory.java b/src/main/java/net/sf/jabref/logic/autocompleter/AutoCompleterFactory.java index 99e7ee6f5dc..fbe937b70db 100644 --- a/src/main/java/net/sf/jabref/logic/autocompleter/AutoCompleterFactory.java +++ b/src/main/java/net/sf/jabref/logic/autocompleter/AutoCompleterFactory.java @@ -46,7 +46,7 @@ public AutoCompleter getFor(String fieldName) { return new NameFieldAutoCompleter(fieldName, preferences); } else if (FieldName.CROSSREF.equals(fieldName)) { return new BibtexKeyAutoCompleter(preferences); - } else if ("journal".equals(fieldName) || "publisher".equals(fieldName)) { + } else if (FieldName.JOURNAL.equals(fieldName) || FieldName.PUBLISHER.equals(fieldName)) { return new JournalAutoCompleter(fieldName, preferences, abbreviationLoader); } else { return new DefaultAutoCompleter(fieldName, preferences); diff --git a/src/main/java/net/sf/jabref/logic/bibtex/BibEntryWriter.java b/src/main/java/net/sf/jabref/logic/bibtex/BibEntryWriter.java index dc349209536..a11493a987f 100644 --- a/src/main/java/net/sf/jabref/logic/bibtex/BibEntryWriter.java +++ b/src/main/java/net/sf/jabref/logic/bibtex/BibEntryWriter.java @@ -159,7 +159,7 @@ private void writeField(BibEntry entry, Writer out, String name, int indentation } private int getLengthOfLongestFieldName(BibEntry entry) { - Predicate isNotBibtexKey = field -> !"bibtexkey".equals(field); + Predicate isNotBibtexKey = field -> !BibEntry.KEY_FIELD.equals(field); return entry.getFieldNames().stream().filter(isNotBibtexKey).mapToInt(String::length).max().orElse(0); } diff --git a/src/main/java/net/sf/jabref/logic/bibtex/comparator/FieldComparator.java b/src/main/java/net/sf/jabref/logic/bibtex/comparator/FieldComparator.java index da2cfd9efc1..934e0ed6256 100644 --- a/src/main/java/net/sf/jabref/logic/bibtex/comparator/FieldComparator.java +++ b/src/main/java/net/sf/jabref/logic/bibtex/comparator/FieldComparator.java @@ -101,7 +101,7 @@ private FieldType determineFieldType() { return FieldType.NAME; } else if (FieldName.YEAR.equals(this.field[0])) { return FieldType.YEAR; - } else if("month".equals(this.field[0])) { + } else if(FieldName.MONTH.equals(this.field[0])) { return FieldType.MONTH; } else { return FieldType.OTHER; diff --git a/src/main/java/net/sf/jabref/logic/cleanup/BiblatexCleanup.java b/src/main/java/net/sf/jabref/logic/cleanup/BiblatexCleanup.java index 1cb4cf083e4..26bbed6ca49 100644 --- a/src/main/java/net/sf/jabref/logic/cleanup/BiblatexCleanup.java +++ b/src/main/java/net/sf/jabref/logic/cleanup/BiblatexCleanup.java @@ -52,15 +52,15 @@ public List cleanup(BibEntry entry) { if (date.isEmpty()) { entry.getFieldOrAlias(FieldName.DATE).ifPresent(newDate -> { Optional oldYear = entry.getFieldOptional(FieldName.YEAR); - Optional oldMonth = entry.getFieldOptional("month"); + Optional oldMonth = entry.getFieldOptional(FieldName.MONTH); entry.setField(FieldName.DATE, newDate); entry.clearField(FieldName.YEAR); - entry.clearField("month"); + entry.clearField(FieldName.MONTH); changes.add(new FieldChange(entry, FieldName.DATE, null, newDate)); changes.add(new FieldChange(entry, FieldName.YEAR, oldYear.orElse(null), null)); - changes.add(new FieldChange(entry, "month", oldMonth.orElse(null), null)); + changes.add(new FieldChange(entry, FieldName.MONTH, oldMonth.orElse(null), null)); }); } }); diff --git a/src/main/java/net/sf/jabref/logic/exporter/FieldFormatterCleanups.java b/src/main/java/net/sf/jabref/logic/exporter/FieldFormatterCleanups.java index 1842d31b78b..3a92ad2bfd2 100644 --- a/src/main/java/net/sf/jabref/logic/exporter/FieldFormatterCleanups.java +++ b/src/main/java/net/sf/jabref/logic/exporter/FieldFormatterCleanups.java @@ -37,7 +37,7 @@ public class FieldFormatterCleanups { List defaultFormatters = new ArrayList<>(); defaultFormatters.add(new FieldFormatterCleanup(FieldName.PAGES, new NormalizePagesFormatter())); - defaultFormatters.add(new FieldFormatterCleanup("month", new NormalizeMonthFormatter())); + defaultFormatters.add(new FieldFormatterCleanup(FieldName.MONTH, new NormalizeMonthFormatter())); defaultFormatters.add(new FieldFormatterCleanup("booktitle", new OrdinalsToSuperscriptFormatter())); DEFAULT_SAVE_ACTIONS = new FieldFormatterCleanups(false, defaultFormatters); } diff --git a/src/main/java/net/sf/jabref/logic/exporter/OOCalcDatabase.java b/src/main/java/net/sf/jabref/logic/exporter/OOCalcDatabase.java index c8006ecb0e8..6c60aa6d4ba 100644 --- a/src/main/java/net/sf/jabref/logic/exporter/OOCalcDatabase.java +++ b/src/main/java/net/sf/jabref/logic/exporter/OOCalcDatabase.java @@ -160,10 +160,10 @@ public Document getDOMrepresentation() { addTableCell(result, row, getField(e, BibEntry.KEY_FIELD)); addTableCell(result, row, getField(e, FieldName.AUTHOR));//new AuthorLastFirst().format(getField(e, FieldName.AUTHOR_FIELD))); addTableCell(result, row, new RemoveWhitespace().format(new RemoveBrackets().format(getField(e, FieldName.TITLE)))); - addTableCell(result, row, getField(e, "journal")); - addTableCell(result, row, getField(e, "volume")); - addTableCell(result, row, getField(e, "number")); - addTableCell(result, row, getField(e, "month")); + addTableCell(result, row, getField(e, FieldName.JOURNAL)); + addTableCell(result, row, getField(e, FieldName.VOLUME)); + addTableCell(result, row, getField(e, FieldName.NUMBER)); + addTableCell(result, row, getField(e, FieldName.MONTH)); addTableCell(result, row, getField(e, FieldName.PAGES)); addTableCell(result, row, getField(e, FieldName.YEAR)); addTableCell(result, row, getField(e, "address")); @@ -174,7 +174,7 @@ public Document getDOMrepresentation() { addTableCell(result, row, getField(e, "edition")); addTableCell(result, row, getField(e, "series")); addTableCell(result, row, getField(e, FieldName.EDITOR));//new AuthorLastFirst().format(getField(e, FieldName.EDITOR_FIELD))); - addTableCell(result, row, getField(e, "publisher")); + addTableCell(result, row, getField(e, FieldName.PUBLISHER)); addTableCell(result, row, getField(e, "reporttype")); addTableCell(result, row, getField(e, "howpublished")); addTableCell(result, row, getField(e, "institution")); diff --git a/src/main/java/net/sf/jabref/logic/exporter/OpenDocumentRepresentation.java b/src/main/java/net/sf/jabref/logic/exporter/OpenDocumentRepresentation.java index c3bce641dde..b8dbdc2abd6 100644 --- a/src/main/java/net/sf/jabref/logic/exporter/OpenDocumentRepresentation.java +++ b/src/main/java/net/sf/jabref/logic/exporter/OpenDocumentRepresentation.java @@ -174,22 +174,22 @@ public Document getDOMrepresentation() { addTableCell(result, row, getField(e, FieldName.EDITOR));//new AuthorLastFirst().format(getField(e, FieldName.EDITOR_FIELD))); addTableCell(result, row, getField(e, "howpublished")); addTableCell(result, row, getField(e, "institution")); - addTableCell(result, row, getField(e, "journal")); + addTableCell(result, row, getField(e, FieldName.JOURNAL)); addTableCell(result, row, getField(e, "language")); - addTableCell(result, row, getField(e, "month")); + addTableCell(result, row, getField(e, FieldName.MONTH)); addTableCell(result, row, getField(e, "monthfiled")); addTableCell(result, row, getField(e, "nationality")); addTableCell(result, row, getField(e, "note")); - addTableCell(result, row, getField(e, "number")); + addTableCell(result, row, getField(e, FieldName.NUMBER)); addTableCell(result, row, getField(e, "organization")); addTableCell(result, row, getField(e, FieldName.PAGES)); - addTableCell(result, row, getField(e, "publisher")); + addTableCell(result, row, getField(e, FieldName.PUBLISHER)); addTableCell(result, row, getField(e, "revision")); addTableCell(result, row, getField(e, "school")); addTableCell(result, row, getField(e, "series")); addTableCell(result, row, new RemoveWhitespace().format(new RemoveBrackets().format(getField(e, FieldName.TITLE)))); addTableCell(result, row, getField(e, "reporttype")); - addTableCell(result, row, getField(e, "volume")); + addTableCell(result, row, getField(e, FieldName.VOLUME)); addTableCell(result, row, getField(e, FieldName.YEAR)); addTableCell(result, row, getField(e, "yearfiled")); addTableCell(result, row, getField(e, FieldName.URL)); diff --git a/src/main/java/net/sf/jabref/logic/integrity/IntegrityCheck.java b/src/main/java/net/sf/jabref/logic/integrity/IntegrityCheck.java index 0db5f4eb495..1a2920826f3 100644 --- a/src/main/java/net/sf/jabref/logic/integrity/IntegrityCheck.java +++ b/src/main/java/net/sf/jabref/logic/integrity/IntegrityCheck.java @@ -62,7 +62,7 @@ private List checkBibtexEntry(BibEntry entry) { result.addAll(new UrlChecker().check(entry)); result.addAll(new FileChecker(bibDatabaseContext).check(entry)); result.addAll(new TypeChecker().check(entry)); - result.addAll(new AbbreviationChecker("journal").check(entry)); + result.addAll(new AbbreviationChecker(FieldName.JOURNAL).check(entry)); result.addAll(new AbbreviationChecker("booktitle").check(entry)); result.addAll(new BibStringChecker().check(entry)); result.addAll(new HTMLCharacterChecker().check(entry)); diff --git a/src/main/java/net/sf/jabref/logic/mods/MODSEntry.java b/src/main/java/net/sf/jabref/logic/mods/MODSEntry.java index 7c57ad72f63..abf9d73c0b9 100644 --- a/src/main/java/net/sf/jabref/logic/mods/MODSEntry.java +++ b/src/main/java/net/sf/jabref/logic/mods/MODSEntry.java @@ -88,7 +88,7 @@ private MODSEntry() { public MODSEntry(BibEntry bibtex) { this(); - handledExtensions.add(MODSEntry.BIBTEX + "publisher"); + handledExtensions.add(MODSEntry.BIBTEX + FieldName.PUBLISHER); handledExtensions.add(MODSEntry.BIBTEX + FieldName.TITLE); handledExtensions.add(MODSEntry.BIBTEX + BibEntry.KEY_FIELD); handledExtensions.add(MODSEntry.BIBTEX + "author"); @@ -104,11 +104,11 @@ private void populateFromBibtex(BibEntry bibtex) { } } - if (bibtex.hasField("publisher")) { + if (bibtex.hasField(FieldName.PUBLISHER)) { if (CHARFORMAT) { - publisher = chars.format(bibtex.getField("publisher")); + publisher = chars.format(bibtex.getField(FieldName.PUBLISHER)); } else { - publisher = bibtex.getField("publisher"); + publisher = bibtex.getField(FieldName.PUBLISHER); } } @@ -132,10 +132,10 @@ private void populateFromBibtex(BibEntry bibtex) { host = new MODSEntry(); host.entryType = "relatedItem"; host.title = bibtex.getField("booktitle"); - host.publisher = bibtex.getField("publisher"); - host.number = bibtex.getField("number"); - if (bibtex.hasField("volume")) { - host.volume = bibtex.getField("volume"); + host.publisher = bibtex.getField(FieldName.PUBLISHER); + host.number = bibtex.getField(FieldName.NUMBER); + if (bibtex.hasField(FieldName.VOLUME)) { + host.volume = bibtex.getField(FieldName.VOLUME); } host.issuance = "continuing"; if (bibtex.hasField(FieldName.PAGES)) { @@ -181,7 +181,7 @@ private List getAuthors(String authors) { private static String getDate(BibEntry bibtex) { StringBuilder result = new StringBuilder(); bibtex.getFieldOptional(FieldName.YEAR).ifPresent(result::append); - bibtex.getFieldOptional("month").ifPresent(result.append('-')::append); + bibtex.getFieldOptional(FieldName.MONTH).ifPresent(result.append('-')::append); return result.toString(); } @@ -250,7 +250,7 @@ public Element getDOMrepresentation(Document d) { Element originInfo = d.createElement("originInfo"); mods.appendChild(originInfo); if (this.publisher != null) { - Element publisher = d.createElement("publisher"); + Element publisher = d.createElement(FieldName.PUBLISHER); publisher.appendChild(d.createTextNode(StringUtil.stripNonValidXMLCharacters(this.publisher))); originInfo.appendChild(publisher); } diff --git a/src/main/java/net/sf/jabref/logic/msbib/MSBibMapping.java b/src/main/java/net/sf/jabref/logic/msbib/MSBibMapping.java index 7ec1269e543..89a78d35778 100644 --- a/src/main/java/net/sf/jabref/logic/msbib/MSBibMapping.java +++ b/src/main/java/net/sf/jabref/logic/msbib/MSBibMapping.java @@ -19,18 +19,18 @@ public class MSBibMapping { bibtexToMSBib.put(BibEntry.KEY_FIELD, "Tag"); bibtexToMSBib.put(FieldName.TITLE, "Title"); bibtexToMSBib.put(FieldName.YEAR, "Year"); - bibtexToMSBib.put("month", "Month"); + bibtexToMSBib.put(FieldName.MONTH, "Month"); bibtexToMSBib.put("note", "Comments"); - bibtexToMSBib.put("volume", "Volume"); + bibtexToMSBib.put(FieldName.VOLUME, "Volume"); bibtexToMSBib.put("language", "LCID"); bibtexToMSBib.put("edition", "Edition"); - bibtexToMSBib.put("publisher", "Publisher"); + bibtexToMSBib.put(FieldName.PUBLISHER, "Publisher"); bibtexToMSBib.put("booktitle", "BookTitle"); //bibtexToMSBib.put("booktitle", "ConferenceName"); //bibtexToMSBib.put(FieldName.PAGES, "Pages"); bibtexToMSBib.put("chapter", "ChapterNumber"); - bibtexToMSBib.put("journal", "JournalName"); - bibtexToMSBib.put("number", "Issue"); + bibtexToMSBib.put(FieldName.JOURNAL, "JournalName"); + bibtexToMSBib.put(FieldName.NUMBER, "Issue"); bibtexToMSBib.put("school", "Department"); bibtexToMSBib.put("institution", "Institution"); bibtexToMSBib.put(FieldName.DOI, "DOI"); @@ -38,7 +38,7 @@ public class MSBibMapping { // BibTeX/Biblatex only fields bibtexToMSBib.put("series", BIBTEX_PREFIX + "Series"); bibtexToMSBib.put(FieldName.ABSTRACT, BIBTEX_PREFIX + "Abstract"); - bibtexToMSBib.put("keywords", BIBTEX_PREFIX + "KeyWords"); + bibtexToMSBib.put(FieldName.KEYWORDS, BIBTEX_PREFIX + "KeyWords"); bibtexToMSBib.put(FieldName.CROSSREF, BIBTEX_PREFIX + "CrossRef"); bibtexToMSBib.put("howpublished", BIBTEX_PREFIX + "HowPublished"); bibtexToMSBib.put("affiliation", BIBTEX_PREFIX + "Affiliation"); diff --git a/src/main/java/net/sf/jabref/logic/xmp/XMPUtil.java b/src/main/java/net/sf/jabref/logic/xmp/XMPUtil.java index 4264867083d..c50e16f526b 100644 --- a/src/main/java/net/sf/jabref/logic/xmp/XMPUtil.java +++ b/src/main/java/net/sf/jabref/logic/xmp/XMPUtil.java @@ -273,7 +273,7 @@ public static Optional getBibtexEntryFromDocumentInformation( s = di.getKeywords(); if (s != null) { - entry.setField("keywords", s); + entry.setField(FieldName.KEYWORDS, s); } s = di.getSubject(); @@ -350,7 +350,7 @@ public static Optional getBibtexEntryFromDublinCore(XMPSchemaDublinCor if (c != null) { entry.setField(FieldName.YEAR, String.valueOf(c.get(Calendar.YEAR))); if (date.length() > 4) { - entry.setField("month", MonthUtil.getMonthByIndex(c.get(Calendar.MONTH)).bibtexFormat); + entry.setField(FieldName.MONTH, MonthUtil.getMonthByIndex(c.get(Calendar.MONTH)).bibtexFormat); } } } @@ -677,7 +677,7 @@ private static void writeToDCSchema(XMPSchemaDublinCore dcSchema, continue; } - if ("month".equals(field)) { + if (FieldName.MONTH.equals(field)) { // Dealt with in year continue; } @@ -763,7 +763,7 @@ private static void writeToDCSchema(XMPSchemaDublinCore dcSchema, * * Bibtex-Fields used: doi */ - if ("publisher".equals(field)) { + if (FieldName.PUBLISHER.equals(field)) { String o = entry.getField(field); dcSchema.addPublisher(o); continue; @@ -801,7 +801,7 @@ private static void writeToDCSchema(XMPSchemaDublinCore dcSchema, * * Bibtex-Fields used: doi */ - if ("keywords".equals(field)) { + if (FieldName.KEYWORDS.equals(field)) { String o = entry.getField(field); String[] keywords = o.split(","); for (String keyword : keywords) { @@ -1013,7 +1013,7 @@ private static void writeDocumentInformation(PDDocument document, di.setAuthor(null); } else if (FieldName.TITLE.equals(field)) { di.setTitle(null); - } else if ("keywords".equals(field)) { + } else if (FieldName.KEYWORDS.equals(field)) { di.setKeywords(null); } else if (FieldName.ABSTRACT.equals(field)) { di.setSubject(null); @@ -1027,8 +1027,8 @@ private static void writeDocumentInformation(PDDocument document, di.setAuthor(resolvedEntry.getField(FieldName.AUTHOR)); } else if (FieldName.TITLE.equals(field)) { di.setTitle(resolvedEntry.getField(FieldName.TITLE)); - } else if ("keywords".equals(field)) { - di.setKeywords(resolvedEntry.getField("keywords")); + } else if (FieldName.KEYWORDS.equals(field)) { + di.setKeywords(resolvedEntry.getField(FieldName.KEYWORDS)); } else if (FieldName.ABSTRACT.equals(field)) { di.setSubject(resolvedEntry.getField(FieldName.ABSTRACT)); } else { diff --git a/src/main/java/net/sf/jabref/model/DuplicateCheck.java b/src/main/java/net/sf/jabref/model/DuplicateCheck.java index 6eab6b8f19f..c99f7eb7222 100644 --- a/src/main/java/net/sf/jabref/model/DuplicateCheck.java +++ b/src/main/java/net/sf/jabref/model/DuplicateCheck.java @@ -65,7 +65,7 @@ public class DuplicateCheck { DuplicateCheck.FIELD_WEIGHTS.put(FieldName.AUTHOR, 2.5); DuplicateCheck.FIELD_WEIGHTS.put(FieldName.EDITOR, 2.5); DuplicateCheck.FIELD_WEIGHTS.put(FieldName.TITLE, 3.); - DuplicateCheck.FIELD_WEIGHTS.put("journal", 2.); + DuplicateCheck.FIELD_WEIGHTS.put(FieldName.JOURNAL, 2.); } @@ -169,7 +169,7 @@ private static int compareSingleField(String field, BibEntry one, BibEntry two) return EQUAL; } return NOT_EQUAL; - } else if ("journal".equals(field)) { + } else if (FieldName.JOURNAL.equals(field)) { // We do not attempt to harmonize abbreviation state of the journal names, // but we remove periods from the names in case they are abbreviated with // and without dots: diff --git a/src/main/java/net/sf/jabref/model/entry/BibEntry.java b/src/main/java/net/sf/jabref/model/entry/BibEntry.java index 9fce91e8847..511373cb0cd 100644 --- a/src/main/java/net/sf/jabref/model/entry/BibEntry.java +++ b/src/main/java/net/sf/jabref/model/entry/BibEntry.java @@ -49,7 +49,6 @@ public class BibEntry implements Cloneable { public static final String TYPE_HEADER = "entrytype"; public static final String KEY_FIELD = "bibtexkey"; protected static final String ID_FIELD = "id"; - public static final String KEYWORDS_FIELD = "keywords"; private static final String DEFAULT_TYPE = "misc"; private String id; @@ -263,7 +262,7 @@ public Optional getFieldOrAlias(String name) { if (FieldName.DATE.equals(name)) { Optional year = getFieldOptional(FieldName.YEAR); if (year.isPresent()) { - MonthUtil.Month month = MonthUtil.getMonth(getFieldOptional("month").orElse("")); + MonthUtil.Month month = MonthUtil.getMonth(getFieldOptional(FieldName.MONTH).orElse("")); if (month.isValid()) { return Optional.of(year.get() + '-' + month.twoDigitNumber); } else { @@ -271,7 +270,7 @@ public Optional getFieldOrAlias(String name) { } } } - if (FieldName.YEAR.equals(name) || "month".equals(name)) { + if (FieldName.YEAR.equals(name) || FieldName.MONTH.equals(name)) { Optional date = getFieldOptional(FieldName.DATE); if (!date.isPresent()) { return Optional.empty(); @@ -306,7 +305,7 @@ public Date parse(String source, ParsePosition pos) { if (FieldName.YEAR.equals(name)) { return Optional.of(Integer.toString(calendar.get(Calendar.YEAR))); } - if ("month".equals(name)) { + if (FieldName.MONTH.equals(name)) { return Optional.of(Integer.toString(calendar.get(Calendar.MONTH) + 1)); // Shift by 1 since in this calendar Jan = 0 } } catch (ParseException e) { @@ -509,7 +508,7 @@ public Optional getPublicationDate() { Optional year = getFieldOptional(FieldName.YEAR); - Optional monthString = getFieldOptional("month"); + Optional monthString = getFieldOptional(FieldName.MONTH); if (monthString.isPresent()) { MonthUtil.Month month = MonthUtil.getMonth(monthString.get()); if (month.isValid()) { @@ -539,12 +538,12 @@ public void setChanged(boolean changed) { public Optional putKeywords(Collection keywords, String separator) { Objects.requireNonNull(keywords); - Optional oldValue = this.getFieldOptional(KEYWORDS_FIELD); + Optional oldValue = this.getFieldOptional(FieldName.KEYWORDS); if (keywords.isEmpty()) { // Clear keyword field if (oldValue.isPresent()) { - return this.clearField(KEYWORDS_FIELD); + return this.clearField(FieldName.KEYWORDS); } else { return Optional.empty(); } @@ -552,7 +551,7 @@ public Optional putKeywords(Collection keywords, String sep // Set new keyword field String newValue = String.join(separator, keywords); - return this.setField(KEYWORDS_FIELD, newValue); + return this.setField(FieldName.KEYWORDS, newValue); } /** diff --git a/src/main/java/net/sf/jabref/model/entry/BibLatexEntryTypes.java b/src/main/java/net/sf/jabref/model/entry/BibLatexEntryTypes.java index e5fc80667e9..cd428e972c4 100644 --- a/src/main/java/net/sf/jabref/model/entry/BibLatexEntryTypes.java +++ b/src/main/java/net/sf/jabref/model/entry/BibLatexEntryTypes.java @@ -29,14 +29,14 @@ public class BibLatexEntryTypes { public static final BibLatexEntryType ARTICLE = new BibLatexEntryType() { private final List primaryOptionalFields = Collections.unmodifiableList( - Arrays.asList("subtitle", FieldName.EDITOR, "series", "volume", "number", "eid", "issue", FieldName.PAGES, + Arrays.asList("subtitle", FieldName.EDITOR, "series", FieldName.VOLUME, FieldName.NUMBER, "eid", FieldName.ISSUE, FieldName.PAGES, "note", FieldName.ISSN, FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "journaltitle", "year/date"); + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, FieldName.JOURNALTITLE, "year/date"); addAllOptional("translator", "annotator", "commentator", "subtitle", "titleaddon", FieldName.EDITOR, "editora", "editorb", "editorc", "journalsubtitle", "issuetitle", "issuesubtitle", "language", "origlanguage", - "series", "volume", "number", "eid", "issue", "month", FieldName.PAGES, "version", "note", FieldName.ISSN, + "series", FieldName.VOLUME, FieldName.NUMBER, "eid", FieldName.ISSUE, FieldName.MONTH, FieldName.PAGES, "version", "note", FieldName.ISSN, "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -55,7 +55,7 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections .unmodifiableList(Arrays.asList(FieldName.EDITOR, "subtitle", "titleaddon", "maintitle", - "mainsubtitle", "maintitleaddon", "volume", "edition", "publisher", FieldName.ISBN, "chapter", FieldName.PAGES, + "mainsubtitle", "maintitleaddon", FieldName.VOLUME, "edition", FieldName.PUBLISHER, FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); @@ -63,8 +63,8 @@ public List getPrimaryOptionalFields() { addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "year/date"); addAllOptional(FieldName.EDITOR, "editora", "editorb", "editorc", "translator", "annotator", "commentator", "introduction", "foreword", "afterword", "subtitle", "titleaddon", "maintitle", "mainsubtitle", - "maintitleaddon", "language", "origlanguage", "volume", "part", "edition", "volumes", "series", - "number", "note", "publisher", "location", FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", + "maintitleaddon", "language", "origlanguage", FieldName.VOLUME, "part", "edition", "volumes", "series", + FieldName.NUMBER, "note", FieldName.PUBLISHER, "location", FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -82,14 +82,14 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType MVBOOK = new BibLatexEntryType() { private final List primaryOptionalFields = Collections - .unmodifiableList(Arrays.asList(FieldName.EDITOR, "subtitle", "titleaddon", "edition", "publisher", FieldName.ISBN, "pagetotal", + .unmodifiableList(Arrays.asList(FieldName.EDITOR, "subtitle", "titleaddon", "edition", FieldName.PUBLISHER, FieldName.ISBN, "pagetotal", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "year/date"); addAllOptional(FieldName.EDITOR, "editora", "editorb", "editorc", "translator", "annotator", "commentator", "introduction", "foreword", "afterword", "subtitle", "titleaddon", "language", "origlanguage", - "edition", "volumes", "series", "number", "note", "publisher", "location", FieldName.ISBN, "pagetotal", + "edition", "volumes", "series", FieldName.NUMBER, "note", FieldName.PUBLISHER, "location", FieldName.ISBN, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -108,7 +108,7 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections.unmodifiableList(Arrays .asList("bookauthor", FieldName.EDITOR, "subtitle", "titleaddon", "maintitle", "mainsubtitle", - "maintitleaddon", "booksubtitle", "booktitleaddon", "volume", "edition", "publisher", FieldName.ISBN, + "maintitleaddon", "booksubtitle", "booktitleaddon", FieldName.VOLUME, "edition", FieldName.PUBLISHER, FieldName.ISBN, "chapter", FieldName.PAGES, FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); @@ -117,7 +117,7 @@ public List getPrimaryOptionalFields() { addAllOptional("bookauthor", FieldName.EDITOR, "editora", "editorb", "editorc", "translator", "annotator", "commentator", "introduction", "foreword", "afterword", "subtitle", "titleaddon", "maintitle", "mainsubtitle", "maintitleaddon", "booksubtitle", "booktitleaddon", "language", "origlanguage", - "volume", "part", "edition", "volumes", "series", "number", "note", "publisher", "location", FieldName.ISBN, + FieldName.VOLUME, "part", "edition", "volumes", "series", FieldName.NUMBER, "note", FieldName.PUBLISHER, "location", FieldName.ISBN, "chapter", FieldName.PAGES, "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -209,7 +209,7 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections .unmodifiableList(Arrays.asList("translator", "subtitle", "titleaddon", "maintitle", - "mainsubtitle", "maintitleaddon", "volume", "edition", "publisher", FieldName.ISBN, "chapter", FieldName.PAGES, + "mainsubtitle", "maintitleaddon", FieldName.VOLUME, "edition", FieldName.PUBLISHER, FieldName.ISBN, "chapter", FieldName.PAGES, FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); @@ -217,8 +217,8 @@ public List getPrimaryOptionalFields() { addAllRequired(FieldName.EDITOR, FieldName.TITLE, "year/date"); addAllOptional("editora", "editorb", "editorc", "translator", "annotator", "commentator", "introduction", "foreword", "afterword", "subtitle", "titleaddon", "maintitle", "mainsubtitle", "maintitleaddon", - "language", "origlanguage", "volume", "part", "edition", "volumes", "series", "number", "note", - "publisher", "location", FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, + "language", "origlanguage", FieldName.VOLUME, "part", "edition", "volumes", "series", FieldName.NUMBER, "note", + FieldName.PUBLISHER, "location", FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -236,15 +236,15 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType MVCOLLECTION = new BibLatexEntryType() { private final List primaryOptionalFields = Collections - .unmodifiableList(Arrays.asList("translator", "subtitle", "titleaddon", "edition", "publisher", FieldName.ISBN, + .unmodifiableList(Arrays.asList("translator", "subtitle", "titleaddon", "edition", FieldName.PUBLISHER, FieldName.ISBN, FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { addAllRequired(FieldName.EDITOR, FieldName.TITLE, "year/date"); addAllOptional("editora", "editorb", "editorc", "translator", "annotator", "commentator", "introduction", - "foreword", "afterword", "subtitle", "titleaddon", "language", "origlanguage", "edition", "volumes", "series", "number", "note", - "publisher", "location", FieldName.ISBN, "pagetotal", "addendum", "pubstate", FieldName.DOI, + "foreword", "afterword", "subtitle", "titleaddon", "language", "origlanguage", "edition", "volumes", "series", FieldName.NUMBER, "note", + FieldName.PUBLISHER, "location", FieldName.ISBN, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -263,7 +263,7 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections.unmodifiableList( Arrays.asList("translator", "subtitle", "titleaddon", "maintitle", "mainsubtitle", - "maintitleaddon", "booksubtitle", "booktitleaddon", "volume", "edition", "publisher", FieldName.ISBN, + "maintitleaddon", "booksubtitle", "booktitleaddon", FieldName.VOLUME, "edition", FieldName.PUBLISHER, FieldName.ISBN, "chapter", FieldName.PAGES, FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); @@ -271,8 +271,8 @@ public List getPrimaryOptionalFields() { addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "booktitle", "year/date"); addAllOptional(FieldName.EDITOR, "editora", "editorb", "editorc", "translator", "annotator", "commentator", "introduction", "foreword", "afterword", "subtitle", "titleaddon", "maintitle", "mainsubtitle", "maintitleaddon", - "booksubtitle", "booktitleaddon", "language", "origlanguage", "volume", "part", "edition", - "volumes", "series", "number", "note", "publisher", "location", FieldName.ISBN, "chapter", FieldName.PAGES, + "booksubtitle", "booktitleaddon", "language", "origlanguage", FieldName.VOLUME, "part", "edition", + "volumes", "series", FieldName.NUMBER, "note", FieldName.PUBLISHER, "location", FieldName.ISBN, "chapter", FieldName.PAGES, "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -314,14 +314,14 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType MANUAL = new BibLatexEntryType() { private final List primaryOptionalFields = Collections - .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "edition", "publisher", FieldName.ISBN, + .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "edition", FieldName.PUBLISHER, FieldName.ISBN, "chapter", FieldName.PAGES, FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { addAllRequired("author/editor", FieldName.TITLE, "year/date"); - addAllOptional("subtitle", "titleaddon", "language", "edition", "type", "series", "number", "version", - "note", "organization", "publisher", "location", FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", + addAllOptional("subtitle", "titleaddon", "language", "edition", "type", "series", FieldName.NUMBER, "version", + "note", "organization", FieldName.PUBLISHER, "location", FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -346,7 +346,7 @@ public List getPrimaryOptionalFields() { { addAllRequired("author/editor", FieldName.TITLE, "year/date"); addAllOptional("subtitle", "titleaddon", "language", "howpublished", "type", "version", "note", - "organization", "location", "month", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", + "organization", "location", FieldName.MONTH, "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -369,7 +369,7 @@ public List getPrimaryOptionalFields() { { addAllRequired("author/editor", FieldName.TITLE, "year/date", FieldName.URL); - addAllOptional("subtitle", "titleaddon", "language", "version", "note", "organization", "month", "addendum", "pubstate", "urldate"); + addAllOptional("subtitle", "titleaddon", "language", "version", "note", "organization", FieldName.MONTH, "addendum", "pubstate", "urldate"); } @Override @@ -390,8 +390,8 @@ public List getPrimaryOptionalFields() { { - addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "number", "year/date"); - addAllOptional("holder", "subtitle", "titleaddon", "type", "version", "location", "note", "month", + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, FieldName.NUMBER, "year/date"); + addAllOptional("holder", "subtitle", "titleaddon", "type", "version", "location", "note", FieldName.MONTH, "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -416,7 +416,7 @@ public List getPrimaryOptionalFields() { { addAllRequired(FieldName.EDITOR, FieldName.TITLE, "year/date"); addAllOptional("editora", "editorb", "editorc", "subtitle", "issuetitle", "issuesubtitle", "language", - "series", "volume", "number", "issue", "month", "note", FieldName.ISSN, "addendum", "pubstate", + "series", FieldName.VOLUME, FieldName.NUMBER, FieldName.ISSUE, FieldName.MONTH, "note", FieldName.ISSN, "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -459,15 +459,15 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "maintitle", "mainsubtitle", - "maintitleaddon", "eventtitle", "volume", "publisher", FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", + "maintitleaddon", "eventtitle", FieldName.VOLUME, FieldName.PUBLISHER, FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { addAllRequired(FieldName.TITLE, "year/date"); addAllOptional(FieldName.EDITOR, "subtitle", "titleaddon", "maintitle", "mainsubtitle", "maintitleaddon", "eventtitle", - "eventtitleaddon", "eventdate", "venue", "language", "volume", "part", "volumes", "series", "number", "note", - "organization", "publisher", "location", "month", FieldName.YEAR, FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", + "eventtitleaddon", "eventdate", "venue", "language", FieldName.VOLUME, "part", "volumes", "series", FieldName.NUMBER, "note", + "organization", FieldName.PUBLISHER, "location", FieldName.MONTH, FieldName.YEAR, FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -486,15 +486,15 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "maintitle", "mainsubtitle", - "maintitleaddon", "eventtitle", "volume", "publisher", FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", + "maintitleaddon", "eventtitle", FieldName.VOLUME, FieldName.PUBLISHER, FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { addAllRequired(FieldName.TITLE, "year/date"); addAllOptional(FieldName.EDITOR, "subtitle", "titleaddon", "eventtitle", - "eventtitleaddon", "eventdate", "venue", "language", "volumes", "series", "number", "note", - "organization", "publisher", "location", "month", FieldName.ISBN, "pagetotal", + "eventtitleaddon", "eventdate", "venue", "language", "volumes", "series", FieldName.NUMBER, "note", + "organization", FieldName.PUBLISHER, "location", FieldName.MONTH, FieldName.ISBN, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -513,15 +513,15 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "maintitle", "mainsubtitle", - "maintitleaddon", "booksubtitle", "booktitleaddon", "eventtitle", "volume", "publisher", FieldName.ISBN, + "maintitleaddon", "booksubtitle", "booktitleaddon", "eventtitle", FieldName.VOLUME, FieldName.PUBLISHER, FieldName.ISBN, "chapter", FieldName.PAGES, FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "booktitle", "year/date"); addAllOptional(FieldName.EDITOR, "subtitle", "titleaddon", "maintitle", "mainsubtitle", "maintitleaddon", "booksubtitle", - "booktitleaddon", "eventtitle", "eventtitleaddon", "eventdate", "venue", "language", "volume", "part", "volumes", - "series", "number", "note", "organization", "publisher", "location", "month", FieldName.ISBN, + "booktitleaddon", "eventtitle", "eventtitleaddon", "eventdate", "venue", "language", FieldName.VOLUME, "part", "volumes", + "series", FieldName.NUMBER, "note", "organization", FieldName.PUBLISHER, "location", FieldName.MONTH, FieldName.ISBN, "chapter", FieldName.PAGES, "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -612,13 +612,13 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType REPORT = new BibLatexEntryType() { private final List primaryOptionalFields = Collections - .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "number", "isrn", "chapter", + .unmodifiableList(Arrays.asList("subtitle", "titleaddon", FieldName.NUMBER, "isrn", "chapter", FieldName.PAGES, "pagetotal", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "type", "institution", "year/date"); - addAllOptional("subtitle", "titleaddon", "language", "number", "version", "note", "location", "month", + addAllOptional("subtitle", "titleaddon", "language", FieldName.NUMBER, "version", "note", "location", FieldName.MONTH, "isrn", "chapter", FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -654,7 +654,7 @@ public String getName() { { addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "type", "institution", "year/date"); - addAllOptional("subtitle", "titleaddon", "language", "note", "location", "month", FieldName.ISBN, "chapter", + addAllOptional("subtitle", "titleaddon", "language", "note", "location", FieldName.MONTH, FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -678,7 +678,7 @@ public List getPrimaryOptionalFields() { { addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "year/date"); - addAllOptional("subtitle", "titleaddon", "language", "howpublished", "note", "location", "month", + addAllOptional("subtitle", "titleaddon", "language", "howpublished", "note", "location", FieldName.MONTH, "addendum", "pubstate", FieldName.URL, "urldate"); } @@ -753,7 +753,7 @@ public List getPrimaryOptionalFields() { { // Treated as alias of "THESIS", except "type" field is optional addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "institution", "year/date"); - addAllOptional("type", "subtitle", "titleaddon", "language", "note", "location", "month", FieldName.ISBN, "chapter", + addAllOptional("type", "subtitle", "titleaddon", "language", "note", "location", FieldName.MONTH, FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -779,7 +779,7 @@ public List getPrimaryOptionalFields() { { // Treated as alias of "THESIS", except "type" field is optional addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "institution", "year/date"); - addAllOptional("type", "subtitle", "titleaddon", "language", "note", "location", "month", FieldName.ISBN, "chapter", + addAllOptional("type", "subtitle", "titleaddon", "language", "note", "location", FieldName.MONTH, FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -798,14 +798,14 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType TECHREPORT = new BibLatexEntryType() { private final List primaryOptionalFields = Collections.unmodifiableList( - Arrays.asList("subtitle", "titleaddon", "type", "number", "isrn", "chapter", FieldName.PAGES, + Arrays.asList("subtitle", "titleaddon", "type", FieldName.NUMBER, "isrn", "chapter", FieldName.PAGES, "pagetotal", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { // Treated as alias of "REPORT", except "type" field is optional addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "institution", "year/date"); - addAllOptional("type", "subtitle", "titleaddon", "language", "number", "version", "note", "location", "month", + addAllOptional("type", "subtitle", "titleaddon", "language", FieldName.NUMBER, "version", "note", "location", FieldName.MONTH, "isrn", "chapter", FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } diff --git a/src/main/java/net/sf/jabref/model/entry/BibtexEntryTypes.java b/src/main/java/net/sf/jabref/model/entry/BibtexEntryTypes.java index 6073f264afd..0c906913a55 100644 --- a/src/main/java/net/sf/jabref/model/entry/BibtexEntryTypes.java +++ b/src/main/java/net/sf/jabref/model/entry/BibtexEntryTypes.java @@ -20,8 +20,8 @@ public class BibtexEntryTypes { public static final EntryType ARTICLE = new BibtexEntryType() { { - addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "journal", FieldName.YEAR); - addAllOptional("volume", "number", FieldName.PAGES, "month", "note"); + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, FieldName.JOURNAL, FieldName.YEAR); + addAllOptional(FieldName.VOLUME, FieldName.NUMBER, FieldName.PAGES, FieldName.MONTH, "note"); } @Override @@ -39,8 +39,8 @@ public String getName() { public static final EntryType BOOK = new BibtexEntryType() { { - addAllRequired(FieldName.TITLE, "publisher", FieldName.YEAR, "author/editor"); - addAllOptional("volume", "number", "series", "address", "edition", "month", "note"); + addAllRequired(FieldName.TITLE, FieldName.PUBLISHER, FieldName.YEAR, "author/editor"); + addAllOptional(FieldName.VOLUME, FieldName.NUMBER, "series", "address", "edition", FieldName.MONTH, "note"); } @Override @@ -59,7 +59,7 @@ public String getName() { { addAllRequired(FieldName.TITLE); - addAllOptional(FieldName.AUTHOR, "howpublished", "address", "month", FieldName.YEAR, "note"); + addAllOptional(FieldName.AUTHOR, "howpublished", "address", FieldName.MONTH, FieldName.YEAR, "note"); } @Override @@ -78,8 +78,8 @@ public String getName() { { addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "booktitle", FieldName.YEAR); - addAllOptional(FieldName.EDITOR, "volume", "number", "series", FieldName.PAGES, "address", "month", "organization", - "publisher", "note"); + addAllOptional(FieldName.EDITOR, FieldName.VOLUME, FieldName.NUMBER, "series", FieldName.PAGES, "address", FieldName.MONTH, "organization", + FieldName.PUBLISHER, "note"); } @Override @@ -97,8 +97,8 @@ public String getName() { public static final EntryType INBOOK = new BibtexEntryType() { { - addAllRequired("chapter/pages", FieldName.TITLE, "publisher", FieldName.YEAR, "author/editor"); - addAllOptional("volume", "number", "series", "type", "address", "edition", "month", "note"); + addAllRequired("chapter/pages", FieldName.TITLE, FieldName.PUBLISHER, FieldName.YEAR, "author/editor"); + addAllOptional(FieldName.VOLUME, FieldName.NUMBER, "series", "type", "address", "edition", FieldName.MONTH, "note"); } @Override @@ -115,9 +115,9 @@ public String getName() { public static final EntryType INCOLLECTION = new BibtexEntryType() { { - addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "booktitle", "publisher", FieldName.YEAR); - addAllOptional(FieldName.EDITOR, "volume", "number", "series", "type", "chapter", FieldName.PAGES, "address", "edition", - "month", "note"); + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "booktitle", FieldName.PUBLISHER, FieldName.YEAR); + addAllOptional(FieldName.EDITOR, FieldName.VOLUME, FieldName.NUMBER, "series", "type", "chapter", FieldName.PAGES, "address", "edition", + FieldName.MONTH, "note"); } @Override @@ -136,8 +136,8 @@ public String getName() { { addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "booktitle", FieldName.YEAR); - addAllOptional(FieldName.EDITOR, "volume", "number", "series", FieldName.PAGES, "address", "month", "organization", - "publisher", "note"); + addAllOptional(FieldName.EDITOR, FieldName.VOLUME, FieldName.NUMBER, "series", FieldName.PAGES, "address", FieldName.MONTH, "organization", + FieldName.PUBLISHER, "note"); } @Override @@ -155,7 +155,7 @@ public String getName() { { addAllRequired(FieldName.TITLE); - addAllOptional(FieldName.AUTHOR, "organization", "address", "edition", "month", FieldName.YEAR, "note"); + addAllOptional(FieldName.AUTHOR, "organization", "address", "edition", FieldName.MONTH, FieldName.YEAR, "note"); } @Override @@ -174,7 +174,7 @@ public String getName() { { addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "school", FieldName.YEAR); - addAllOptional("type", "address", "month", "note"); + addAllOptional("type", "address", FieldName.MONTH, "note"); } @Override @@ -192,7 +192,7 @@ public String getName() { public static final EntryType MISC = new BibtexEntryType() { { - addAllOptional(FieldName.AUTHOR, FieldName.TITLE, "howpublished", "month", FieldName.YEAR, "note"); + addAllOptional(FieldName.AUTHOR, FieldName.TITLE, "howpublished", FieldName.MONTH, FieldName.YEAR, "note"); } @Override @@ -211,7 +211,7 @@ public String getName() { { addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "school", FieldName.YEAR); - addAllOptional("type", "address", "month", "note"); + addAllOptional("type", "address", FieldName.MONTH, "note"); } @Override @@ -230,7 +230,7 @@ public String getName() { { addAllRequired(FieldName.TITLE, FieldName.YEAR); - addAllOptional(FieldName.EDITOR, "volume", "number", "series", "address", "publisher", "note", "month", + addAllOptional(FieldName.EDITOR, FieldName.VOLUME, FieldName.NUMBER, "series", "address", FieldName.PUBLISHER, "note", FieldName.MONTH, "organization"); } @@ -250,7 +250,7 @@ public String getName() { { addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "institution", FieldName.YEAR); - addAllOptional("type", "number", "address", "month", "note"); + addAllOptional("type", FieldName.NUMBER, "address", FieldName.MONTH, "note"); } @Override @@ -269,7 +269,7 @@ public String getName() { { addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "note"); - addAllOptional("month", FieldName.YEAR); + addAllOptional(FieldName.MONTH, FieldName.YEAR); } @Override diff --git a/src/main/java/net/sf/jabref/model/entry/EntryConverter.java b/src/main/java/net/sf/jabref/model/entry/EntryConverter.java index 9632455c454..ad48e6e1d32 100644 --- a/src/main/java/net/sf/jabref/model/entry/EntryConverter.java +++ b/src/main/java/net/sf/jabref/model/entry/EntryConverter.java @@ -20,7 +20,7 @@ public class EntryConverter { EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put("address", "location"); EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put("annote", "annotation"); EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put("archiveprefix", "eprinttype"); - EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put("journal", "journaltitle"); + EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put(FieldName.JOURNAL, FieldName.JOURNALTITLE); EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put("key", "sortkey"); EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put("pdf", FieldName.FILE); EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put("primaryclass", "eprintclass"); diff --git a/src/main/java/net/sf/jabref/model/entry/EntryUtil.java b/src/main/java/net/sf/jabref/model/entry/EntryUtil.java index cc0d189edf4..eaa96e409f1 100644 --- a/src/main/java/net/sf/jabref/model/entry/EntryUtil.java +++ b/src/main/java/net/sf/jabref/model/entry/EntryUtil.java @@ -51,7 +51,7 @@ public static Set getSeparatedKeywords(String keywordString) { * @return an List containing the keywords of the entry. An empty list if keywords are null or empty */ public static Set getSeparatedKeywords(BibEntry entry) { - return getSeparatedKeywords(entry.getFieldOptional(BibEntry.KEYWORDS_FIELD).orElse(null)); + return getSeparatedKeywords(entry.getFieldOptional(FieldName.KEYWORDS).orElse(null)); } /** diff --git a/src/main/java/net/sf/jabref/model/entry/FieldName.java b/src/main/java/net/sf/jabref/model/entry/FieldName.java index ead7e99d9f9..5de9895789d 100644 --- a/src/main/java/net/sf/jabref/model/entry/FieldName.java +++ b/src/main/java/net/sf/jabref/model/entry/FieldName.java @@ -13,10 +13,18 @@ public class FieldName { public static final String FOLDER = "folder"; public static final String ISBN = "isbn"; public static final String ISSN = "issn"; + public static final String ISSUE = "issue"; + public static final String JOURNAL = "journal"; + public static final String JOURNALTITLE = "journaltitle"; + public static final String KEYWORDS = "keywords"; + public static final String MONTH = "month"; + public static final String NUMBER = "number"; public static final String PAGES = "pages"; + public static final String PUBLISHER = "publisher"; public static final String REVIEW = "review"; public static final String TITLE = "title"; public static final String URL = "url"; + public static final String VOLUME = "volume"; public static final String YEAR = "year"; diff --git a/src/main/java/net/sf/jabref/model/entry/IEEETranEntryTypes.java b/src/main/java/net/sf/jabref/model/entry/IEEETranEntryTypes.java index 44a65127e24..fe0816f5b17 100644 --- a/src/main/java/net/sf/jabref/model/entry/IEEETranEntryTypes.java +++ b/src/main/java/net/sf/jabref/model/entry/IEEETranEntryTypes.java @@ -20,7 +20,7 @@ public class IEEETranEntryTypes { public static final EntryType ELECTRONIC = new BibtexEntryType() { { - addAllOptional(FieldName.AUTHOR, "month", FieldName.YEAR, FieldName.TITLE, "language", "howpublished", "organization", "address", + addAllOptional(FieldName.AUTHOR, FieldName.MONTH, FieldName.YEAR, FieldName.TITLE, "language", "howpublished", "organization", "address", "note", FieldName.URL); } @@ -59,7 +59,7 @@ public String getName() { { addAllRequired(FieldName.TITLE, FieldName.YEAR); - addAllOptional(FieldName.EDITOR, "language", "series", "volume", "number", "organization", "month", "note", FieldName.URL); + addAllOptional(FieldName.EDITOR, "language", "series", FieldName.VOLUME, FieldName.NUMBER, "organization", FieldName.MONTH, "note", FieldName.URL); } @Override @@ -77,9 +77,9 @@ public String getName() { public static final EntryType PATENT = new BibtexEntryType() { { - addAllRequired("nationality", "number", "year/yearfiled"); - addAllOptional(FieldName.AUTHOR, FieldName.TITLE, "language", "assignee", "address", "type", "number", "day", "dayfiled", - "month", "monthfiled", "note", FieldName.URL); + addAllRequired("nationality", FieldName.NUMBER, "year/yearfiled"); + addAllOptional(FieldName.AUTHOR, FieldName.TITLE, "language", "assignee", "address", "type", FieldName.NUMBER, "day", "dayfiled", + FieldName.MONTH, "monthfiled", "note", FieldName.URL); } @Override @@ -98,7 +98,7 @@ public String getName() { { addAllRequired(FieldName.TITLE, "organization/institution"); - addAllOptional(FieldName.AUTHOR, "language", "howpublished", "type", "number", "revision", "address", "month", + addAllOptional(FieldName.AUTHOR, "language", "howpublished", "type", FieldName.NUMBER, "revision", "address", FieldName.MONTH, FieldName.YEAR, "note", FieldName.URL); } diff --git a/src/main/java/net/sf/jabref/model/entry/InternalBibtexFields.java b/src/main/java/net/sf/jabref/model/entry/InternalBibtexFields.java index c3794481bcf..4f8f4614e07 100644 --- a/src/main/java/net/sf/jabref/model/entry/InternalBibtexFields.java +++ b/src/main/java/net/sf/jabref/model/entry/InternalBibtexFields.java @@ -104,22 +104,22 @@ private InternalBibtexFields(boolean serializeSpecialFields) { add(new BibtexSingleField("howpublished", true, BibtexSingleField.MEDIUM_W)); add(new BibtexSingleField("institution", true, BibtexSingleField.MEDIUM_W)); - dummy = new BibtexSingleField("journal", true, BibtexSingleField.SMALL_W); + dummy = new BibtexSingleField(FieldName.JOURNAL, true, BibtexSingleField.SMALL_W); dummy.setExtras(EnumSet.of(FieldProperties.JOURNAL_NAME)); add(dummy); - dummy = new BibtexSingleField("journaltitle", true, BibtexSingleField.SMALL_W); + dummy = new BibtexSingleField(FieldName.JOURNALTITLE, true, BibtexSingleField.SMALL_W); dummy.setExtras(EnumSet.of(FieldProperties.JOURNAL_NAME)); add(dummy); add(new BibtexSingleField("key", true)); - dummy = new BibtexSingleField("month", true, BibtexSingleField.SMALL_W); + dummy = new BibtexSingleField(FieldName.MONTH, true, BibtexSingleField.SMALL_W); dummy.setExtras(EnumSet.of(FieldProperties.MONTH)); add(dummy); add(new BibtexSingleField("note", true, BibtexSingleField.MEDIUM_W)); - add(new BibtexSingleField("number", true, BibtexSingleField.SMALL_W, 60).setNumeric(true)); + add(new BibtexSingleField(FieldName.NUMBER, true, BibtexSingleField.SMALL_W, 60).setNumeric(true)); add(new BibtexSingleField("organization", true, BibtexSingleField.MEDIUM_W)); add(new BibtexSingleField(FieldName.PAGES, true, BibtexSingleField.SMALL_W)); - add(new BibtexSingleField("publisher", true, BibtexSingleField.MEDIUM_W)); + add(new BibtexSingleField(FieldName.PUBLISHER, true, BibtexSingleField.MEDIUM_W)); add(new BibtexSingleField("school", true, BibtexSingleField.MEDIUM_W)); add(new BibtexSingleField("series", true, BibtexSingleField.SMALL_W)); add(new BibtexSingleField(FieldName.TITLE, true, 400)); @@ -127,7 +127,7 @@ private InternalBibtexFields(boolean serializeSpecialFields) { dummy.getExtras().add(FieldProperties.TYPE); add(dummy); add(new BibtexSingleField("language", true, BibtexSingleField.SMALL_W)); - add(new BibtexSingleField("volume", true, BibtexSingleField.SMALL_W, 60).setNumeric(true)); + add(new BibtexSingleField(FieldName.VOLUME, true, BibtexSingleField.SMALL_W, 60).setNumeric(true)); add(new BibtexSingleField(FieldName.YEAR, true, BibtexSingleField.SMALL_W, 60).setNumeric(true)); // custom fields not displayed at editor, but as columns in the UI @@ -199,7 +199,7 @@ private InternalBibtexFields(boolean serializeSpecialFields) { add(dummy); add(new BibtexSingleField("comment", false, BibtexSingleField.MEDIUM_W)); - add(new BibtexSingleField("keywords", false, BibtexSingleField.SMALL_W)); + add(new BibtexSingleField(FieldName.KEYWORDS, false, BibtexSingleField.SMALL_W)); dummy = new BibtexSingleField(FieldName.FILE, false); dummy.setExtras(EnumSet.of(FieldProperties.FILE_EDITOR)); diff --git a/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java b/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java index 7c1ae32cb1e..255af2dd4a6 100644 --- a/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java @@ -76,6 +76,7 @@ import net.sf.jabref.logic.util.VersionPreferences; import net.sf.jabref.logic.util.strings.StringUtil; import net.sf.jabref.model.database.BibDatabaseMode; +import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.model.entry.CustomEntryType; import net.sf.jabref.model.entry.EntryUtil; import net.sf.jabref.model.entry.FieldName; @@ -361,7 +362,7 @@ public class JabRefPreferences { List activeFormatterCleanups = new ArrayList<>(); activeFormatterCleanups.add(new FieldFormatterCleanup(FieldName.PAGES, new NormalizePagesFormatter())); activeFormatterCleanups.add(new FieldFormatterCleanup(FieldName.DATE, new NormalizeDateFormatter())); - activeFormatterCleanups.add(new FieldFormatterCleanup("month", new NormalizeMonthFormatter())); + activeFormatterCleanups.add(new FieldFormatterCleanup(FieldName.MONTH, new NormalizeMonthFormatter())); activeFormatterCleanups.add(new FieldFormatterCleanup(FieldName.TITLE, new ProtectTermsFormatter())); activeFormatterCleanups.add(new FieldFormatterCleanup(FieldName.TITLE, new UnitsToLatexFormatter())); activeFormatterCleanups.add(new FieldFormatterCleanup(FieldName.TITLE, new LatexCleanupFormatter())); @@ -550,7 +551,7 @@ private JabRefPreferences() { defaults.put(EXPORT_IN_SPECIFIED_ORDER, Boolean.FALSE); // export order: if EXPORT_IN_SPECIFIED_ORDER, then use following criteria - defaults.put(EXPORT_PRIMARY_SORT_FIELD, "bibtexkey"); + defaults.put(EXPORT_PRIMARY_SORT_FIELD, BibEntry.KEY_FIELD); defaults.put(EXPORT_PRIMARY_SORT_DESCENDING, Boolean.FALSE); defaults.put(EXPORT_SECONDARY_SORT_FIELD, FieldName.AUTHOR); defaults.put(EXPORT_SECONDARY_SORT_DESCENDING, Boolean.FALSE); @@ -615,7 +616,7 @@ private JabRefPreferences() { defaults.put(GROUP_INTERSECT_SELECTIONS, Boolean.TRUE); defaults.put(GROUP_INVERT_SELECTIONS, Boolean.FALSE); defaults.put(GROUP_SHOW_OVERLAPPING, Boolean.FALSE); - defaults.put(GROUPS_DEFAULT_FIELD, "keywords"); + defaults.put(GROUPS_DEFAULT_FIELD, FieldName.KEYWORDS); defaults.put(GROUP_SHOW_ICONS, Boolean.TRUE); defaults.put(GROUP_SHOW_DYNAMIC, Boolean.TRUE); defaults.put(GROUP_EXPAND_TREE, Boolean.TRUE); diff --git a/src/main/java/net/sf/jabref/specialfields/SpecialFieldUpdateListener.java b/src/main/java/net/sf/jabref/specialfields/SpecialFieldUpdateListener.java index b5174a5485d..94a042772a3 100644 --- a/src/main/java/net/sf/jabref/specialfields/SpecialFieldUpdateListener.java +++ b/src/main/java/net/sf/jabref/specialfields/SpecialFieldUpdateListener.java @@ -20,6 +20,7 @@ import net.sf.jabref.JabRefGUI; import net.sf.jabref.gui.undo.NamedCompound; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.FieldName; import net.sf.jabref.model.event.FieldChangedEvent; import com.google.common.eventbus.Subscribe; @@ -43,7 +44,7 @@ public void listen(FieldChangedEvent fieldChangedEvent) { // e.g., "keyword = {prio1}, priority = {prio2}" and a change at keyword to prio3 would not succeed. SwingUtilities.invokeLater(() -> { NamedCompound compound = new NamedCompound("SpecialFieldSync"); - if ("keywords".equals(fieldName)) { + if (FieldName.KEYWORDS.equals(fieldName)) { SpecialFieldsUtils.syncSpecialFieldsFromKeywords(entry, compound); SwingUtilities .invokeLater(() -> JabRefGUI.getMainFrame().getCurrentBasePanel().updateEntryEditorIfShowing()); diff --git a/src/main/java/net/sf/jabref/specialfields/SpecialFieldsUtils.java b/src/main/java/net/sf/jabref/specialfields/SpecialFieldsUtils.java index 940cd3302b1..318e887f8aa 100644 --- a/src/main/java/net/sf/jabref/specialfields/SpecialFieldsUtils.java +++ b/src/main/java/net/sf/jabref/specialfields/SpecialFieldsUtils.java @@ -27,9 +27,9 @@ import net.sf.jabref.model.FieldChange; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.model.entry.EntryUtil; +import net.sf.jabref.model.entry.FieldName; import net.sf.jabref.preferences.JabRefPreferences; -import static net.sf.jabref.model.entry.BibEntry.KEYWORDS_FIELD; public class SpecialFieldsUtils { @@ -163,7 +163,7 @@ private static void importKeywordsForField(Set keywordList, SpecialField * @param ce indicates the undo named compound. May be null */ public static void syncSpecialFieldsFromKeywords(BibEntry be, NamedCompound ce) { - if (!be.hasField(KEYWORDS_FIELD)) { + if (!be.hasField(FieldName.KEYWORDS)) { return; } Set keywordList = EntryUtil.getSeparatedKeywords(be); diff --git a/src/test/java/net/sf/jabref/model/entry/EntryUtilTest.java b/src/test/java/net/sf/jabref/model/entry/EntryUtilTest.java index 0c00382b4a7..2774968f898 100644 --- a/src/test/java/net/sf/jabref/model/entry/EntryUtilTest.java +++ b/src/test/java/net/sf/jabref/model/entry/EntryUtilTest.java @@ -28,7 +28,7 @@ public void getSeparatedKeywords() { public void getSeparatedKeywordsEntry() { String keywords = "w1, w2a w2b, w3"; BibEntry entry = new BibEntry(); - entry.setField(BibEntry.KEYWORDS_FIELD, keywords); + entry.setField(FieldName.KEYWORDS, keywords); Set separatedKeywords = EntryUtil.getSeparatedKeywords(entry); Assert.assertEquals(new LinkedHashSet<>(Arrays.asList("w1", "w2a w2b", "w3")), separatedKeywords); }