From bf50d38a80cd297485e3dc03ad55bebd136726e4 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Wed, 20 Jul 2016 08:12:22 +0200 Subject: [PATCH] Renamed and added more constants --- .../net/sf/jabref/BibDatabaseContext.java | 2 +- src/main/java/net/sf/jabref/MetaData.java | 6 +- .../net/sf/jabref/collab/ChangeScanner.java | 2 +- .../sf/jabref/external/AttachFileAction.java | 8 +- .../net/sf/jabref/external/AutoSetLinks.java | 6 +- .../jabref/external/DroppedFileHandler.java | 6 +- .../jabref/external/FindFullTextAction.java | 8 +- .../jabref/external/SynchronizeFileField.java | 10 +- .../TransferableFileLinkSelection.java | 2 +- .../sf/jabref/external/WriteXMPAction.java | 4 +- .../external/WriteXMPEntryEditorAction.java | 4 +- .../java/net/sf/jabref/gui/BasePanel.java | 18 +- .../sf/jabref/gui/ContentSelectorDialog2.java | 2 +- .../java/net/sf/jabref/gui/GUIGlobals.java | 8 +- .../sf/jabref/gui/ImportInspectionDialog.java | 32 +-- .../java/net/sf/jabref/gui/PreviewPanel.java | 2 +- .../gui/cleanup/CleanupPresetPanel.java | 2 +- .../sf/jabref/gui/desktop/JabRefDesktop.java | 20 +- .../jabref/gui/entryeditor/EntryEditor.java | 2 +- .../gui/entryeditor/FieldExtraComponents.java | 2 +- .../gui/fieldeditors/FieldNameLabel.java | 8 +- .../sf/jabref/gui/groups/AutoGroupDialog.java | 8 +- .../sf/jabref/gui/maintable/MainTable.java | 2 +- .../jabref/gui/maintable/MainTableFormat.java | 4 +- .../maintable/MainTableSelectionListener.java | 8 +- .../maintable/SpecialMainTableColumns.java | 10 +- .../sf/jabref/gui/menus/RightClickMenu.java | 12 +- .../gui/mergeentries/MergeEntryDOIDialog.java | 2 +- .../sf/jabref/gui/openoffice/OOBibBase.java | 8 +- .../gui/openoffice/StyleSelectDialog.java | 8 +- .../gui/openoffice/UndefinedBibtexEntry.java | 2 +- .../net/sf/jabref/gui/preftabs/FileTab.java | 4 +- .../jabref/gui/preftabs/PreviewPrefsTab.java | 12 +- .../gui/search/SearchResultsDialog.java | 26 +-- .../jabref/importer/DatabaseFileLookup.java | 2 +- .../jabref/importer/EntryFromFileCreator.java | 6 +- .../jabref/importer/EntryFromPDFCreator.java | 4 +- .../net/sf/jabref/importer/OAI2Handler.java | 22 +- .../importer/fetcher/ACMPortalFetcher.java | 10 +- .../jabref/importer/fetcher/ADSFetcher.java | 4 +- .../importer/fetcher/CiteSeerXFetcher.java | 8 +- .../sf/jabref/importer/fetcher/CrossRef.java | 10 +- .../fetcher/CrossrefFetcherEvaluator.java | 2 +- .../importer/fetcher/DOItoBibTeXFetcher.java | 5 +- .../importer/fetcher/DiVAtoBibTeXFetcher.java | 5 +- .../sf/jabref/importer/fetcher/GVKParser.java | 16 +- .../fetcher/GoogleScholarFetcher.java | 8 +- .../importer/fetcher/IEEEXploreFetcher.java | 40 ++-- .../importer/fetcher/ISBNtoBibTeXFetcher.java | 5 +- .../jabref/importer/fetcher/OAI2Fetcher.java | 2 +- .../fileformat/BiblioscapeImporter.java | 18 +- .../importer/fileformat/CopacImporter.java | 8 +- .../importer/fileformat/EndnoteImporter.java | 22 +- .../importer/fileformat/FreeCiteImporter.java | 10 +- .../importer/fileformat/InspecImporter.java | 12 +- .../importer/fileformat/IsiImporter.java | 20 +- .../importer/fileformat/JSONEntryParser.java | 38 +-- .../importer/fileformat/MedlineHandler.java | 16 +- .../fileformat/MedlinePlainImporter.java | 28 +-- .../importer/fileformat/OvidImporter.java | 52 ++--- .../fileformat/PdfContentImporter.java | 16 +- .../importer/fileformat/RepecNepImporter.java | 10 +- .../importer/fileformat/RisImporter.java | 30 +-- .../fileformat/SilverPlatterImporter.java | 18 +- .../net/sf/jabref/logic/TypedBibEntry.java | 8 +- .../autocompleter/AutoCompleterFactory.java | 4 +- .../sf/jabref/logic/auxparser/AuxParser.java | 3 +- .../logic/bibtex/FieldContentParser.java | 4 +- .../comparator/CrossRefEntryComparator.java | 8 +- .../bibtex/comparator/FieldComparator.java | 2 +- src/main/java/net/sf/jabref/logic/bst/VM.java | 5 +- .../jabref/logic/cleanup/BiblatexCleanup.java | 14 +- .../sf/jabref/logic/cleanup/DoiCleanup.java | 16 +- .../logic/cleanup/FileLinksCleanup.java | 6 +- .../cleanup/UpgradePdfPsToFileCleanup.java | 6 +- .../exporter/FieldFormatterCleanups.java | 7 +- .../jabref/logic/exporter/OOCalcDatabase.java | 18 +- .../exporter/OpenDocumentRepresentation.java | 18 +- .../net/sf/jabref/logic/fulltext/ACS.java | 2 +- .../net/sf/jabref/logic/fulltext/ArXiv.java | 2 +- .../jabref/logic/fulltext/DoiResolution.java | 2 +- .../jabref/logic/fulltext/FindFullText.java | 4 +- .../jabref/logic/fulltext/GoogleScholar.java | 5 +- .../net/sf/jabref/logic/fulltext/IEEE.java | 4 +- .../jabref/logic/fulltext/ScienceDirect.java | 2 +- .../jabref/logic/fulltext/SpringerLink.java | 2 +- .../jabref/logic/integrity/ISBNChecker.java | 8 +- .../jabref/logic/integrity/ISSNChecker.java | 8 +- .../logic/integrity/IntegrityCheck.java | 32 +-- .../logic/labelpattern/LabelPatternUtil.java | 38 +-- .../layout/format/CreateDocBookAuthors.java | 2 +- .../layout/format/CreateDocBookEditors.java | 2 +- .../jabref/logic/layout/format/FileLink.java | 2 +- .../logic/layout/format/WrapFileLinks.java | 2 +- .../net/sf/jabref/logic/mods/MODSEntry.java | 18 +- .../jabref/logic/msbib/BibTeXConverter.java | 12 +- .../sf/jabref/logic/msbib/MSBibConverter.java | 40 ++-- .../sf/jabref/logic/msbib/MSBibMapping.java | 14 +- .../jabref/logic/openoffice/OOBibStyle.java | 2 +- .../net/sf/jabref/logic/util/io/FileUtil.java | 2 +- .../sf/jabref/logic/xmp/XMPSchemaBibtex.java | 4 +- .../java/net/sf/jabref/logic/xmp/XMPUtil.java | 42 ++-- .../migrations/FileLinksUpgradeWarning.java | 8 +- .../migrations/PreferencesMigrations.java | 16 +- .../net/sf/jabref/model/DuplicateCheck.java | 8 +- .../sf/jabref/model/database/BibDatabase.java | 3 +- .../net/sf/jabref/model/entry/BibEntry.java | 20 +- .../model/entry/BibLatexEntryTypes.java | 220 +++++++++--------- .../jabref/model/entry/BibtexEntryTypes.java | 44 ++-- .../sf/jabref/model/entry/EntryConverter.java | 2 +- .../net/sf/jabref/model/entry/FieldName.java | 27 ++- .../model/entry/IEEETranEntryTypes.java | 18 +- .../model/entry/InternalBibtexFields.java | 26 +-- .../net/sf/jabref/pdfimport/PdfImporter.java | 2 +- .../jabref/preferences/JabRefPreferences.java | 28 +-- 115 files changed, 752 insertions(+), 747 deletions(-) diff --git a/src/main/java/net/sf/jabref/BibDatabaseContext.java b/src/main/java/net/sf/jabref/BibDatabaseContext.java index 9c6f99a32f9a..c3a381950642 100644 --- a/src/main/java/net/sf/jabref/BibDatabaseContext.java +++ b/src/main/java/net/sf/jabref/BibDatabaseContext.java @@ -178,6 +178,6 @@ private String getFileDirectoryPath(String directoryName) { } public List getFileDirectory() { - return getFileDirectory(FieldName.FILE_FIELD); + return getFileDirectory(FieldName.FILE); } } diff --git a/src/main/java/net/sf/jabref/MetaData.java b/src/main/java/net/sf/jabref/MetaData.java index c8d8573fd85d..25dfa6c6fab0 100644 --- a/src/main/java/net/sf/jabref/MetaData.java +++ b/src/main/java/net/sf/jabref/MetaData.java @@ -58,7 +58,7 @@ public class MetaData implements Iterable { private static final String DATABASE_TYPE = "databaseType"; private static final String GROUPSTREE = "groupstree"; - private static final String FILE_DIRECTORY = FieldName.FILE_FIELD + Globals.DIR_SUFFIX; + private static final String FILE_DIRECTORY = FieldName.FILE + Globals.DIR_SUFFIX; public static final String SELECTOR_META_PREFIX = "selector_"; private static final String PROTECTED_FLAG_META = "protectedFlag"; @@ -128,10 +128,10 @@ public Optional getSaveOrderConfig() { */ public void initializeNewDatabase() { metaData.put(SELECTOR_META_PREFIX + "keywords", new Vector<>()); - metaData.put(SELECTOR_META_PREFIX + FieldName.AUTHOR_FIELD, 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.REVIEW_FIELD, new Vector<>()); + metaData.put(SELECTOR_META_PREFIX + FieldName.REVIEW, new Vector<>()); } /** diff --git a/src/main/java/net/sf/jabref/collab/ChangeScanner.java b/src/main/java/net/sf/jabref/collab/ChangeScanner.java index 9dd07a88dc8e..87cd4fea27f7 100644 --- a/src/main/java/net/sf/jabref/collab/ChangeScanner.java +++ b/src/main/java/net/sf/jabref/collab/ChangeScanner.java @@ -61,7 +61,7 @@ public class ChangeScanner implements Runnable { - private static final String[] SORT_BY = new String[] {FieldName.YEAR_FIELD, FieldName.AUTHOR_FIELD, "title"}; + private static final String[] SORT_BY = new String[] {FieldName.YEAR, FieldName.AUTHOR, FieldName.TITLE}; private final File f; diff --git a/src/main/java/net/sf/jabref/external/AttachFileAction.java b/src/main/java/net/sf/jabref/external/AttachFileAction.java index 91a94f738620..8429df582212 100644 --- a/src/main/java/net/sf/jabref/external/AttachFileAction.java +++ b/src/main/java/net/sf/jabref/external/AttachFileAction.java @@ -39,13 +39,13 @@ public void action() { editor.setVisible(true, true); if (editor.okPressed()) { FileListTableModel model = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(model::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(model::setContent); model.addEntry(model.getRowCount(), flEntry); String newVal = model.getStringRepresentation(); - UndoableFieldChange ce = new UndoableFieldChange(entry, FieldName.FILE_FIELD, - entry.getFieldOptional(FieldName.FILE_FIELD).orElse(null), newVal); - entry.setField(FieldName.FILE_FIELD, newVal); + UndoableFieldChange ce = new UndoableFieldChange(entry, FieldName.FILE, + entry.getFieldOptional(FieldName.FILE).orElse(null), newVal); + entry.setField(FieldName.FILE, newVal); panel.getUndoManager().addEdit(ce); panel.markBaseChanged(); } diff --git a/src/main/java/net/sf/jabref/external/AutoSetLinks.java b/src/main/java/net/sf/jabref/external/AutoSetLinks.java index ac648375f1c0..64848c282fa8 100644 --- a/src/main/java/net/sf/jabref/external/AutoSetLinks.java +++ b/src/main/java/net/sf/jabref/external/AutoSetLinks.java @@ -112,7 +112,7 @@ public void run() { // Iterate over the entries: for (Entry> entryFilePair : result.entrySet()) { FileListTableModel tableModel; - Optional oldVal = entryFilePair.getKey().getFieldOptional(FieldName.FILE_FIELD); + Optional oldVal = entryFilePair.getKey().getFieldOptional(FieldName.FILE); if (singleTableModel == null) { tableModel = new FileListTableModel(); oldVal.ifPresent(tableModel::setContent); @@ -153,12 +153,12 @@ public void run() { if (ce != null) { // store undo information UndoableFieldChange change = new UndoableFieldChange(entryFilePair.getKey(), - FieldName.FILE_FIELD, oldVal.orElse(null), newVal); + FieldName.FILE, oldVal.orElse(null), newVal); ce.addEdit(change); } // hack: if table model is given, do NOT modify entry if (singleTableModel == null) { - entryFilePair.getKey().setField(FieldName.FILE_FIELD, newVal); + entryFilePair.getKey().setField(FieldName.FILE, newVal); } if (changedEntries != null) { changedEntries.add(entryFilePair.getKey()); diff --git a/src/main/java/net/sf/jabref/external/DroppedFileHandler.java b/src/main/java/net/sf/jabref/external/DroppedFileHandler.java index c2003bbe5fda..0479631d917b 100644 --- a/src/main/java/net/sf/jabref/external/DroppedFileHandler.java +++ b/src/main/java/net/sf/jabref/external/DroppedFileHandler.java @@ -396,7 +396,7 @@ private boolean showLinkMoveCopyRenameDialog(String linkFileName, ExternalFileTy private void doLink(BibEntry entry, ExternalFileType fileType, String filename, boolean avoidDuplicate, NamedCompound edits) { - Optional oldValue = entry.getFieldOptional(FieldName.FILE_FIELD); + Optional oldValue = entry.getFieldOptional(FieldName.FILE); FileListTableModel tm = new FileListTableModel(); oldValue.ifPresent(tm::setContent); @@ -442,8 +442,8 @@ private void doLink(BibEntry entry, ExternalFileType fileType, String filename, tm.addEntry(tm.getRowCount(), new FileListEntry("", filename, fileType)); String newValue = tm.getStringRepresentation(); - UndoableFieldChange edit = new UndoableFieldChange(entry, FieldName.FILE_FIELD, oldValue.orElse(null), newValue); - entry.setField(FieldName.FILE_FIELD, newValue); + UndoableFieldChange edit = new UndoableFieldChange(entry, FieldName.FILE, oldValue.orElse(null), newValue); + entry.setField(FieldName.FILE, newValue); if (edits == null) { panel.getUndoManager().addEdit(edit); diff --git a/src/main/java/net/sf/jabref/external/FindFullTextAction.java b/src/main/java/net/sf/jabref/external/FindFullTextAction.java index e54eb6973414..f48c440de456 100644 --- a/src/main/java/net/sf/jabref/external/FindFullTextAction.java +++ b/src/main/java/net/sf/jabref/external/FindFullTextAction.java @@ -80,12 +80,12 @@ public void update() { try { def.download(result.get(), file -> { FileListTableModel tm = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(tm::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(tm::setContent); tm.addEntry(tm.getRowCount(), file); String newValue = tm.getStringRepresentation(); - UndoableFieldChange edit = new UndoableFieldChange(entry, FieldName.FILE_FIELD, - entry.getFieldOptional(FieldName.FILE_FIELD).orElse(null), newValue); - entry.setField(FieldName.FILE_FIELD, newValue); + UndoableFieldChange edit = new UndoableFieldChange(entry, FieldName.FILE, + entry.getFieldOptional(FieldName.FILE).orElse(null), newValue); + entry.setField(FieldName.FILE, newValue); basePanel.getUndoManager().addEdit(edit); basePanel.markBaseChanged(); }); diff --git a/src/main/java/net/sf/jabref/external/SynchronizeFileField.java b/src/main/java/net/sf/jabref/external/SynchronizeFileField.java index 4520b6a745a3..0a798fb1ab29 100644 --- a/src/main/java/net/sf/jabref/external/SynchronizeFileField.java +++ b/src/main/java/net/sf/jabref/external/SynchronizeFileField.java @@ -145,7 +145,7 @@ public void run() { boolean removeAllBroken = false; mainLoop: for (BibEntry aSel : sel) { panel.frame().setProgressBarValue(progress++); - final Optional old = aSel.getFieldOptional(FieldName.FILE_FIELD); + final Optional old = aSel.getFieldOptional(FieldName.FILE); // Check if a extension is set: if (old.isPresent() && !(old.get().isEmpty())) { FileListTableModel tableModel = new FileListTableModel(); @@ -255,11 +255,11 @@ public void run() { // The table has been modified. Store the change: String toSet = tableModel.getStringRepresentation(); if (toSet.isEmpty()) { - ce.addEdit(new UndoableFieldChange(aSel, FieldName.FILE_FIELD, old.orElse(null), null)); - aSel.clearField(FieldName.FILE_FIELD); + ce.addEdit(new UndoableFieldChange(aSel, FieldName.FILE, old.orElse(null), null)); + aSel.clearField(FieldName.FILE); } else { - ce.addEdit(new UndoableFieldChange(aSel, FieldName.FILE_FIELD, old.orElse(null), toSet)); - aSel.setField(FieldName.FILE_FIELD, toSet); + ce.addEdit(new UndoableFieldChange(aSel, FieldName.FILE, old.orElse(null), toSet)); + aSel.setField(FieldName.FILE, toSet); } changedEntries.add(aSel); } diff --git a/src/main/java/net/sf/jabref/external/TransferableFileLinkSelection.java b/src/main/java/net/sf/jabref/external/TransferableFileLinkSelection.java index 16c1efbc695b..b78d327c9d63 100644 --- a/src/main/java/net/sf/jabref/external/TransferableFileLinkSelection.java +++ b/src/main/java/net/sf/jabref/external/TransferableFileLinkSelection.java @@ -44,7 +44,7 @@ public class TransferableFileLinkSelection implements Transferable { public TransferableFileLinkSelection(BasePanel panel, List selection) { FileListTableModel tm = new FileListTableModel(); - selection.get(0).getFieldOptional(FieldName.FILE_FIELD).ifPresent(tm::setContent); + selection.get(0).getFieldOptional(FieldName.FILE).ifPresent(tm::setContent); if (tm.getRowCount() > 0) { // Find the default directory for this field type, if any: List dirs = panel.getBibDatabaseContext().getFileDirectory(); diff --git a/src/main/java/net/sf/jabref/external/WriteXMPAction.java b/src/main/java/net/sf/jabref/external/WriteXMPAction.java index 1c1e69230e30..d69fb185fe09 100644 --- a/src/main/java/net/sf/jabref/external/WriteXMPAction.java +++ b/src/main/java/net/sf/jabref/external/WriteXMPAction.java @@ -139,9 +139,9 @@ public void run() { .ifPresent(files::add)); // Then check the "file" field: List dirs = panel.getBibDatabaseContext().getFileDirectory(); - if (entry.hasField(FieldName.FILE_FIELD)) { + if (entry.hasField(FieldName.FILE)) { FileListTableModel tm = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(tm::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(tm::setContent); for (int j = 0; j < tm.getRowCount(); j++) { FileListEntry flEntry = tm.getEntry(j); if ((flEntry.type.isPresent()) && "pdf".equalsIgnoreCase(flEntry.type.get().getName())) { diff --git a/src/main/java/net/sf/jabref/external/WriteXMPEntryEditorAction.java b/src/main/java/net/sf/jabref/external/WriteXMPEntryEditorAction.java index e45ff3570fff..d4366c247066 100644 --- a/src/main/java/net/sf/jabref/external/WriteXMPEntryEditorAction.java +++ b/src/main/java/net/sf/jabref/external/WriteXMPEntryEditorAction.java @@ -73,9 +73,9 @@ public void actionPerformed(ActionEvent actionEvent) { // Then check the "file" field: List dirs = panel.getBibDatabaseContext().getFileDirectory(); - if (entry.hasField(FieldName.FILE_FIELD)) { + if (entry.hasField(FieldName.FILE)) { FileListTableModel tm = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(tm::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(tm::setContent); for (int j = 0; j < tm.getRowCount(); j++) { FileListEntry flEntry = tm.getEntry(j); if ((flEntry.type.isPresent()) && "pdf".equalsIgnoreCase(flEntry.type.get().getName())) { diff --git a/src/main/java/net/sf/jabref/gui/BasePanel.java b/src/main/java/net/sf/jabref/gui/BasePanel.java index 8d2064c914b1..9e8e4c8839a4 100644 --- a/src/main/java/net/sf/jabref/gui/BasePanel.java +++ b/src/main/java/net/sf/jabref/gui/BasePanel.java @@ -1035,13 +1035,13 @@ private void openExternalFile() { } final BibEntry entry = bes.get(0); - if (!entry.hasField(FieldName.FILE_FIELD)) { + if (!entry.hasField(FieldName.FILE)) { // no bibtex field new SearchAndOpenFile(entry, BasePanel.this).searchAndOpen(); return; } FileListTableModel tableModel = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(tableModel::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(tableModel::setContent); if (tableModel.getRowCount() == 0) { // content in bibtex field is not readable new SearchAndOpenFile(entry, BasePanel.this).searchAndOpen(); @@ -2064,11 +2064,11 @@ private class OpenURLAction implements BaseAction { public void action() { final List bes = mainTable.getSelectedEntries(); if (bes.size() == 1) { - String field = FieldName.DOI_FIELD; - Optional link = bes.get(0).getFieldOptional(FieldName.DOI_FIELD); - if (bes.get(0).hasField(FieldName.URL_FIELD)) { - link = bes.get(0).getFieldOptional(FieldName.URL_FIELD); - field = FieldName.URL_FIELD; + String field = FieldName.DOI; + Optional link = bes.get(0).getFieldOptional(FieldName.DOI); + if (bes.get(0).hasField(FieldName.URL)) { + link = bes.get(0).getFieldOptional(FieldName.URL); + field = FieldName.URL; } if (link.isPresent()) { try { @@ -2082,10 +2082,10 @@ public void action() { // Look for web links in the "file" field as a fallback: FileListEntry entry = null; FileListTableModel tm = new FileListTableModel(); - bes.get(0).getFieldOptional(FieldName.FILE_FIELD).ifPresent(tm::setContent); + bes.get(0).getFieldOptional(FieldName.FILE).ifPresent(tm::setContent); for (int i = 0; i < tm.getRowCount(); i++) { FileListEntry flEntry = tm.getEntry(i); - if (FieldName.URL_FIELD.equalsIgnoreCase(flEntry.type.get().getName()) + if (FieldName.URL.equalsIgnoreCase(flEntry.type.get().getName()) || PS_FIELD.equalsIgnoreCase(flEntry.type.get().getName()) || PDF_FIELD.equalsIgnoreCase(flEntry.type.get().getName())) { entry = flEntry; diff --git a/src/main/java/net/sf/jabref/gui/ContentSelectorDialog2.java b/src/main/java/net/sf/jabref/gui/ContentSelectorDialog2.java index 527a25caaba6..7fc85b95459c 100644 --- a/src/main/java/net/sf/jabref/gui/ContentSelectorDialog2.java +++ b/src/main/java/net/sf/jabref/gui/ContentSelectorDialog2.java @@ -321,7 +321,7 @@ private void setupFieldSelector() { } if (contents.isEmpty()) { // if nothing was added, put the default fields (as described in the help) - fieldListModel.addElement(FieldName.AUTHOR_FIELD); + fieldListModel.addElement(FieldName.AUTHOR); fieldListModel.addElement("journal"); fieldListModel.addElement("keywords"); fieldListModel.addElement("publisher"); diff --git a/src/main/java/net/sf/jabref/gui/GUIGlobals.java b/src/main/java/net/sf/jabref/gui/GUIGlobals.java index ff6dd1ede7a5..8f1ed9552bcb 100644 --- a/src/main/java/net/sf/jabref/gui/GUIGlobals.java +++ b/src/main/java/net/sf/jabref/gui/GUIGlobals.java @@ -101,7 +101,7 @@ public static void init() { label = new JLabel(IconTheme.JabRefIcon.WWW.getSmallIcon()); label.setToolTipText(Localization.lang("Open") + " URL"); - GUIGlobals.TABLE_ICONS.put(FieldName.URL_FIELD, label); + GUIGlobals.TABLE_ICONS.put(FieldName.URL, label); label = new JLabel(IconTheme.JabRefIcon.WWW.getSmallIcon()); label.setToolTipText(Localization.lang("Open") + " CiteSeer URL"); @@ -113,7 +113,7 @@ public static void init() { label = new JLabel(IconTheme.JabRefIcon.DOI.getSmallIcon()); label.setToolTipText(Localization.lang("Open") + " DOI " + Localization.lang("web link")); - GUIGlobals.TABLE_ICONS.put(FieldName.DOI_FIELD, label); + GUIGlobals.TABLE_ICONS.put(FieldName.DOI, label); label = new JLabel(IconTheme.JabRefIcon.FILE.getSmallIcon()); label.setToolTipText(Localization.lang("Open") + " PS"); @@ -121,11 +121,11 @@ public static void init() { label = new JLabel(IconTheme.JabRefIcon.FOLDER.getSmallIcon()); label.setToolTipText(Localization.lang("Open folder")); - GUIGlobals.TABLE_ICONS.put(FieldName.FOLDER_FIELD, label); + GUIGlobals.TABLE_ICONS.put(FieldName.FOLDER, label); label = new JLabel(IconTheme.JabRefIcon.FILE.getSmallIcon()); label.setToolTipText(Localization.lang("Open file")); - GUIGlobals.TABLE_ICONS.put(FieldName.FILE_FIELD, label); + GUIGlobals.TABLE_ICONS.put(FieldName.FILE, label); for (ExternalFileType fileType : ExternalFileTypes.getInstance().getExternalFileTypeSelection()) { label = new JLabel(fileType.getIcon()); diff --git a/src/main/java/net/sf/jabref/gui/ImportInspectionDialog.java b/src/main/java/net/sf/jabref/gui/ImportInspectionDialog.java index 4c82c9ff1c3b..4e09e52a7db9 100644 --- a/src/main/java/net/sf/jabref/gui/ImportInspectionDialog.java +++ b/src/main/java/net/sf/jabref/gui/ImportInspectionDialog.java @@ -179,12 +179,12 @@ public class ImportInspectionDialog extends JDialog implements ImportInspector, private final JLabel duplLabel = new JLabel(IconTheme.JabRefIcon.DUPLICATE.getSmallIcon()); private final JLabel fileLabel = new JLabel(IconTheme.JabRefIcon.FILE.getSmallIcon()); private final JLabel urlLabel = new JLabel(IconTheme.JabRefIcon.WWW.getSmallIcon()); - private static final List INSPECTION_FIELDS = Arrays.asList(FieldName.AUTHOR_FIELD, "title", FieldName.YEAR_FIELD, BibEntry.KEY_FIELD); + private static final List INSPECTION_FIELDS = Arrays.asList(FieldName.AUTHOR, FieldName.TITLE, FieldName.YEAR, BibEntry.KEY_FIELD); private static final int DUPL_COL = 1; private static final int FILE_COL = 2; private static final int URL_COL = 3; private static final int PAD = 4; - private static final String URL_FIELD = FieldName.URL_FIELD; + private static final String URL_FIELD = FieldName.URL; /** @@ -906,9 +906,9 @@ public void mouseClicked(MouseEvent e) { BibEntry entry = sortedList.get(row); if (col == FILE_COL) { - if (entry.hasField(FieldName.FILE_FIELD)) { + if (entry.hasField(FieldName.FILE)) { FileListTableModel tableModel = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(tableModel::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(tableModel::setContent); if (tableModel.getRowCount() == 0) { return; } @@ -963,7 +963,7 @@ private void showFileFieldMenu(MouseEvent e) { JPopupMenu menu = new JPopupMenu(); int count = 0; FileListTableModel fileList = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(fileList::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(fileList::setContent); // If there are one or more links, open the first one: for (int i = 0; i < fileList.getRowCount(); i++) { FileListEntry flEntry = fileList.getEntry(i); @@ -1185,11 +1185,11 @@ public void actionPerformed(ActionEvent actionEvent) { public void downloadComplete(FileListEntry file) { ImportInspectionDialog.this.toFront(); // Hack FileListTableModel localModel = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(localModel::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(localModel::setContent); localModel.addEntry(localModel.getRowCount(), file); entries.getReadWriteLock().writeLock().lock(); try { - entry.setField(FieldName.FILE_FIELD, localModel.getStringRepresentation()); + entry.setField(FieldName.FILE, localModel.getStringRepresentation()); } finally { entries.getReadWriteLock().writeLock().unlock(); } @@ -1221,7 +1221,7 @@ public void actionPerformed(ActionEvent actionEvent) { } } final FileListTableModel localModel = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(localModel::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(localModel::setContent); // We have a static utility method for searching for all relevant // links: JDialog diag = new JDialog(ImportInspectionDialog.this, true); @@ -1231,7 +1231,7 @@ public void actionPerformed(ActionEvent actionEvent) { entries.getReadWriteLock().writeLock().lock(); try { - entry.setField(FieldName.FILE_FIELD, localModel.getStringRepresentation()); + entry.setField(FieldName.FILE, localModel.getStringRepresentation()); } finally { entries.getReadWriteLock().writeLock().unlock(); } @@ -1263,11 +1263,11 @@ public void actionPerformed(ActionEvent actionEvent) { editor.setVisible(true, true); if (editor.okPressed()) { FileListTableModel localModel = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(localModel::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(localModel::setContent); localModel.addEntry(localModel.getRowCount(), flEntry); entries.getReadWriteLock().writeLock().lock(); try { - entry.setField(FieldName.FILE_FIELD, localModel.getStringRepresentation()); + entry.setField(FieldName.FILE, localModel.getStringRepresentation()); } finally { entries.getReadWriteLock().writeLock().unlock(); } @@ -1279,11 +1279,11 @@ public void actionPerformed(ActionEvent actionEvent) { public void downloadComplete(FileListEntry file) { ImportInspectionDialog.this.toFront(); // Hack FileListTableModel localModel = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(localModel::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(localModel::setContent); localModel.addEntry(localModel.getRowCount(), file); entries.getReadWriteLock().writeLock().lock(); try { - entry.setField(FieldName.FILE_FIELD, localModel.getStringRepresentation()); + entry.setField(FieldName.FILE, localModel.getStringRepresentation()); } finally { entries.getReadWriteLock().writeLock().unlock(); } @@ -1306,7 +1306,7 @@ private void setupComparatorChooser() { comparators = comparatorChooser.getComparatorsForColumn(i); comparators.clear(); if (i == FILE_COL) { - comparators.add(new IconComparator(Collections.singletonList(FieldName.FILE_FIELD))); + comparators.add(new IconComparator(Collections.singletonList(FieldName.FILE))); } else if (i == URL_COL) { comparators.add(new IconComparator(Collections.singletonList(URL_FIELD))); } @@ -1424,9 +1424,9 @@ public Object getColumnValue(BibEntry entry, int i) { case DUPL_COL: return entry.isGroupHit() ? duplLabel : null; case FILE_COL: - if (entry.hasField(FieldName.FILE_FIELD)) { + if (entry.hasField(FieldName.FILE)) { FileListTableModel model = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(model::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(model::setContent); fileLabel.setToolTipText(model.getToolTipHTMLRepresentation()); if (model.getRowCount() > 0) { fileLabel.setIcon(model.getEntry(0).type.get().getIcon()); diff --git a/src/main/java/net/sf/jabref/gui/PreviewPanel.java b/src/main/java/net/sf/jabref/gui/PreviewPanel.java index 2e6df7e63279..768e76d86f81 100644 --- a/src/main/java/net/sf/jabref/gui/PreviewPanel.java +++ b/src/main/java/net/sf/jabref/gui/PreviewPanel.java @@ -241,7 +241,7 @@ public Dimension getPreferredScrollableViewportSize() { .isPresent()) { try { String address = hyperlinkEvent.getURL().toString(); - JabRefDesktop.openExternalViewer(PreviewPanel.this.databaseContext.get(), address, FieldName.URL_FIELD); + JabRefDesktop.openExternalViewer(PreviewPanel.this.databaseContext.get(), address, FieldName.URL); } catch (IOException e) { LOGGER.warn("Could not open external viewer", e); } diff --git a/src/main/java/net/sf/jabref/gui/cleanup/CleanupPresetPanel.java b/src/main/java/net/sf/jabref/gui/cleanup/CleanupPresetPanel.java index 5be435506098..67f1b962c78d 100644 --- a/src/main/java/net/sf/jabref/gui/cleanup/CleanupPresetPanel.java +++ b/src/main/java/net/sf/jabref/gui/cleanup/CleanupPresetPanel.java @@ -61,7 +61,7 @@ private void init() { event -> cleanUpRenamePDFonlyRelativePaths.setEnabled(cleanUpRenamePDF.isSelected())); cleanUpRenamePDFonlyRelativePaths = new JCheckBox(Localization.lang("Rename only PDFs having a relative path")); cleanUpUpgradeExternalLinks = new JCheckBox( - Localization.lang("Upgrade external PDF/PS links to use the '%0' field.", FieldName.FILE_FIELD)); + Localization.lang("Upgrade external PDF/PS links to use the '%0' field.", FieldName.FILE)); cleanUpBibLatex = new JCheckBox(Localization.lang( "Convert to BibLatex format (for example, move the value of the 'journal' field to 'journaltitle')")); diff --git a/src/main/java/net/sf/jabref/gui/desktop/JabRefDesktop.java b/src/main/java/net/sf/jabref/gui/desktop/JabRefDesktop.java index 43f4961b2830..338a3cd4038a 100644 --- a/src/main/java/net/sf/jabref/gui/desktop/JabRefDesktop.java +++ b/src/main/java/net/sf/jabref/gui/desktop/JabRefDesktop.java @@ -26,6 +26,7 @@ import javax.swing.JOptionPane; import net.sf.jabref.BibDatabaseContext; +import net.sf.jabref.Globals; import net.sf.jabref.JabRefGUI; import net.sf.jabref.external.ExternalFileType; import net.sf.jabref.external.ExternalFileTypeEntryEditor; @@ -95,15 +96,15 @@ public static void openExternalViewer(BibDatabaseContext databaseContext, String fieldName = "ps"; } } - } else if (FieldName.DOI_FIELD.equals(fieldName)) { + } else if (FieldName.DOI.equals(fieldName)) { Optional doiUrl = DOI.build(link); if (doiUrl.isPresent()) { link = doiUrl.get().getURIAsASCIIString(); } // should be opened in browser - fieldName = FieldName.URL_FIELD; + fieldName = FieldName.URL; } else if ("eprint".equals(fieldName)) { - fieldName = FieldName.URL_FIELD; + fieldName = FieldName.URL; // Check to see if link field already contains a well formated URL if (!link.startsWith("http://")) { @@ -111,7 +112,7 @@ public static void openExternalViewer(BibDatabaseContext databaseContext, String } } - if (FieldName.URL_FIELD.equals(fieldName)) { // html + if (FieldName.URL.equals(fieldName)) { // html try { openBrowser(link); } catch (IOException e) { @@ -228,7 +229,7 @@ public static boolean openExternalFileUnknown(JabRefFrame frame, BibEntry entry, // User wants to change the type of this link. // First get a model of all file links for this entry: FileListTableModel tModel = new FileListTableModel(); - Optional oldValue = entry.getFieldOptional(FieldName.FILE_FIELD); + Optional oldValue = entry.getFieldOptional(FieldName.FILE); oldValue.ifPresent(tModel::setContent); FileListEntry flEntry = null; // Then find which one we are looking at: @@ -249,14 +250,9 @@ public static boolean openExternalFileUnknown(JabRefFrame frame, BibEntry entry, if (editor.okPressed()) { // Store the changes and add an undo edit: String newValue = tModel.getStringRepresentation(); -<<<<<<< 90044ac423016f8b5931ea6a4067ff314ed3047a - UndoableFieldChange ce = new UndoableFieldChange(entry, Globals.FILE_FIELD, oldValue.orElse(null), + UndoableFieldChange ce = new UndoableFieldChange(entry, FieldName.FILE, oldValue.orElse(null), newValue); - entry.setField(Globals.FILE_FIELD, newValue); -======= - UndoableFieldChange ce = new UndoableFieldChange(entry, FieldName.FILE_FIELD, oldValue, newValue); - entry.setField(FieldName.FILE_FIELD, newValue); ->>>>>>> Added model.entry.FieldName that contains field name constants + entry.setField(FieldName.FILE, newValue); frame.getCurrentBasePanel().getUndoManager().addEdit(ce); frame.getCurrentBasePanel().markBaseChanged(); // Finally, open the link: 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 258675619adc..ee2c5f55b828 100644 --- a/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java @@ -261,7 +261,7 @@ private void setupFieldPanels() { addOptionalTab(type); Set deprecatedFields = new HashSet<>(EntryConverter.FIELD_ALIASES_TEX_TO_LTX.keySet()); - deprecatedFields.add(FieldName.YEAR_FIELD); + deprecatedFields.add(FieldName.YEAR); deprecatedFields.add("month"); List secondaryOptionalFields = type.getSecondaryOptionalFields(); List optionalFieldsNotPrimaryOrDeprecated = new ArrayList<>(secondaryOptionalFields); diff --git a/src/main/java/net/sf/jabref/gui/entryeditor/FieldExtraComponents.java b/src/main/java/net/sf/jabref/gui/entryeditor/FieldExtraComponents.java index 41c268dffd59..f12a5804ea03 100644 --- a/src/main/java/net/sf/jabref/gui/entryeditor/FieldExtraComponents.java +++ b/src/main/java/net/sf/jabref/gui/entryeditor/FieldExtraComponents.java @@ -190,7 +190,7 @@ public static Optional getDoiExtraComponent(BasePanel panel, EntryEd doiButton.addActionListener(actionEvent -> { Optional doi = DOI.fromBibEntry(entryEditor.getEntry()); if (doi.isPresent()) { - entryEditor.getEntry().setField(FieldName.DOI_FIELD, doi.get().getDOI()); + entryEditor.getEntry().setField(FieldName.DOI, doi.get().getDOI()); } else { panel.frame().setStatus(Localization.lang("No DOI found")); } diff --git a/src/main/java/net/sf/jabref/gui/fieldeditors/FieldNameLabel.java b/src/main/java/net/sf/jabref/gui/fieldeditors/FieldNameLabel.java index dd6c76c04421..89c854092cf2 100644 --- a/src/main/java/net/sf/jabref/gui/fieldeditors/FieldNameLabel.java +++ b/src/main/java/net/sf/jabref/gui/fieldeditors/FieldNameLabel.java @@ -49,15 +49,15 @@ public void paintComponent(Graphics g) { private static String getFieldNameLabelText(String fieldName) { // selected terms should be uppercase - if(FieldName.ISBN_FIELD.equalsIgnoreCase(fieldName)) { + if(FieldName.ISBN.equalsIgnoreCase(fieldName)) { return " ISBN "; - } else if (FieldName.URL_FIELD.equalsIgnoreCase(fieldName)){ + } else if (FieldName.URL.equalsIgnoreCase(fieldName)){ return " URL "; } else if ("uri".equalsIgnoreCase(fieldName)) { return " URI "; - } else if (FieldName.ISSN_FIELD.equalsIgnoreCase(fieldName)) { + } else if (FieldName.ISSN.equalsIgnoreCase(fieldName)) { return " ISSN "; - } else if(FieldName.DOI_FIELD.equalsIgnoreCase(fieldName)) { + } else if(FieldName.DOI.equalsIgnoreCase(fieldName)) { return " DOI "; } else if("isrn".equalsIgnoreCase(fieldName)) { return " ISRN "; diff --git a/src/main/java/net/sf/jabref/gui/groups/AutoGroupDialog.java b/src/main/java/net/sf/jabref/gui/groups/AutoGroupDialog.java index 2f9bf0b11857..d2c319917ad6 100644 --- a/src/main/java/net/sf/jabref/gui/groups/AutoGroupDialog.java +++ b/src/main/java/net/sf/jabref/gui/groups/AutoGroupDialog.java @@ -110,14 +110,14 @@ public void actionPerformed(ActionEvent e) { } } else if (authors.isSelected()) { List fields = new ArrayList<>(2); - fields.add(FieldName.AUTHOR_FIELD); + fields.add(FieldName.AUTHOR); hs = GroupsUtil.findAuthorLastNames(panel.getDatabase(), fields); - fieldText = FieldName.AUTHOR_FIELD; + fieldText = FieldName.AUTHOR; } else { // editors.isSelected() as it is a radio button group. List fields = new ArrayList<>(2); - fields.add(FieldName.EDITOR_FIELD); + fields.add(FieldName.EDITOR); hs = GroupsUtil.findAuthorLastNames(panel.getDatabase(), fields); - fieldText = FieldName.EDITOR_FIELD; + fieldText = FieldName.EDITOR; } for (String keyword : hs) { diff --git a/src/main/java/net/sf/jabref/gui/maintable/MainTable.java b/src/main/java/net/sf/jabref/gui/maintable/MainTable.java index 28b83e5509e7..98dba92fda21 100644 --- a/src/main/java/net/sf/jabref/gui/maintable/MainTable.java +++ b/src/main/java/net/sf/jabref/gui/maintable/MainTable.java @@ -500,7 +500,7 @@ public int findEntry(BibEntry entry) { */ public boolean isFileColumn(int modelIndex) { return (tableFormat.getTableColumn(modelIndex) != null) && tableFormat.getTableColumn(modelIndex) - .getBibtexFields().contains(FieldName.FILE_FIELD); + .getBibtexFields().contains(FieldName.FILE); } private boolean matches(int row, Matcher m) { diff --git a/src/main/java/net/sf/jabref/gui/maintable/MainTableFormat.java b/src/main/java/net/sf/jabref/gui/maintable/MainTableFormat.java index 03064324b992..92105340a819 100644 --- a/src/main/java/net/sf/jabref/gui/maintable/MainTableFormat.java +++ b/src/main/java/net/sf/jabref/gui/maintable/MainTableFormat.java @@ -39,8 +39,8 @@ public class MainTableFormat implements TableFormat { // Values to gather iconImages for those columns // These values are also used to put a heading into the table; see getColumnName(int) - private static final List URL_FIRST = Arrays.asList(FieldName.URL_FIELD, FieldName.DOI_FIELD); - private static final List DOI_FIRST = Arrays.asList(FieldName.DOI_FIELD, FieldName.URL_FIELD); + private static final List URL_FIRST = Arrays.asList(FieldName.URL, FieldName.DOI); + private static final List DOI_FIRST = Arrays.asList(FieldName.DOI, FieldName.URL); private static final List ARXIV = Collections.singletonList("eprint"); private final BibDatabase database; diff --git a/src/main/java/net/sf/jabref/gui/maintable/MainTableSelectionListener.java b/src/main/java/net/sf/jabref/gui/maintable/MainTableSelectionListener.java index 187e2f7bc4b2..8068fa6933ff 100644 --- a/src/main/java/net/sf/jabref/gui/maintable/MainTableSelectionListener.java +++ b/src/main/java/net/sf/jabref/gui/maintable/MainTableSelectionListener.java @@ -297,7 +297,7 @@ public void mouseClicked(MouseEvent e) { // See if this is a simple file link field, or if it is a file-list // field that can specify a list of links: - if (fieldName.equals(FieldName.FILE_FIELD)) { + if (fieldName.equals(FieldName.FILE)) { // We use a FileListTableModel to parse the field content: FileListTableModel fileList = new FileListTableModel(); @@ -337,8 +337,8 @@ public void mouseClicked(MouseEvent e) { } } }); - } else if (modelColumn.getBibtexFields().contains("crossref")) { // Clicking on crossref column - tableRows.get(row).getFieldOptional("crossref") + } else if (modelColumn.getBibtexFields().contains(FieldName.CROSSREF)) { // Clicking on crossref column + tableRows.get(row).getFieldOptional(FieldName.CROSSREF) .ifPresent(crossref -> panel.getDatabase().getEntryByKey(crossref).ifPresent(entry -> panel.highlightEntry(entry))); } } @@ -401,7 +401,7 @@ private void showIconRightClickMenu(MouseEvent e, int row, MainTableColumn colum // field that can specify a list of links: if(!column.getBibtexFields().isEmpty()) { for(String field : column.getBibtexFields()) { - if (FieldName.FILE_FIELD.equals(field)) { + if (FieldName.FILE.equals(field)) { // We use a FileListTableModel to parse the field content: FileListTableModel fileList = new FileListTableModel(); entry.getFieldOptional(field).ifPresent(fileList::setContent); diff --git a/src/main/java/net/sf/jabref/gui/maintable/SpecialMainTableColumns.java b/src/main/java/net/sf/jabref/gui/maintable/SpecialMainTableColumns.java index 1ab7389458b5..74a0ed39aaac 100644 --- a/src/main/java/net/sf/jabref/gui/maintable/SpecialMainTableColumns.java +++ b/src/main/java/net/sf/jabref/gui/maintable/SpecialMainTableColumns.java @@ -99,14 +99,14 @@ public Object getColumnValue(BibEntry entry) { new JLabel(Quality.getInstance().getRepresentingIcon())); - public static final MainTableColumn FILE_COLUMN = new MainTableColumn(FieldName.FILE_FIELD, - Collections.singletonList(FieldName.FILE_FIELD), new JLabel(IconTheme.JabRefIcon.FILE.getSmallIcon())) { + public static final MainTableColumn FILE_COLUMN = new MainTableColumn(FieldName.FILE, + Collections.singletonList(FieldName.FILE), new JLabel(IconTheme.JabRefIcon.FILE.getSmallIcon())) { @Override public Object getColumnValue(BibEntry entry) { // We use a FileListTableModel to parse the field content: FileListTableModel fileList = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(fileList::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(fileList::setContent); if (fileList.getRowCount() > 1) { return new JLabel(IconTheme.JabRefIcon.FILE_MULTIPLE.getSmallIcon()); } else if (fileList.getRowCount() == 1) { @@ -167,7 +167,7 @@ public static MainTableColumn createFileIconColumn(String externalFileTypeName) - return new MainTableColumn(externalFileTypeName, Collections.singletonList(FieldName.FILE_FIELD), new JLabel()) { + return new MainTableColumn(externalFileTypeName, Collections.singletonList(FieldName.FILE), new JLabel()) { @Override public boolean isFileFilter() { @@ -185,7 +185,7 @@ public Object getColumnValue(BibEntry entry) { boolean iconFound = false; JLabel iconLabel = null; FileListTableModel fileList = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(fileList::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(fileList::setContent); for (int i = 0; i < fileList.getRowCount(); i++) { if ((fileList.getEntry(i).type.isPresent()) && externalFileTypeName.equalsIgnoreCase(fileList.getEntry(i).type.get().getName())) { diff --git a/src/main/java/net/sf/jabref/gui/menus/RightClickMenu.java b/src/main/java/net/sf/jabref/gui/menus/RightClickMenu.java index df19a9630b2b..8103793f7b32 100644 --- a/src/main/java/net/sf/jabref/gui/menus/RightClickMenu.java +++ b/src/main/java/net/sf/jabref/gui/menus/RightClickMenu.java @@ -157,7 +157,7 @@ public RightClickMenu(JabRefFrame frame, BasePanel panel) { add(new GeneralAction(Actions.OPEN_FOLDER, Localization.lang("Open folder")) { { - if (!isFieldSetForSelectedEntry(FieldName.FILE_FIELD)) { + if (!isFieldSetForSelectedEntry(FieldName.FILE)) { this.setEnabled(false); } } @@ -165,7 +165,7 @@ public RightClickMenu(JabRefFrame frame, BasePanel panel) { add(new GeneralAction(Actions.OPEN_EXTERNAL_FILE, Localization.lang("Open file"), getFileIconForSelectedEntry()) { { - if (!isFieldSetForSelectedEntry(FieldName.FILE_FIELD)) { + if (!isFieldSetForSelectedEntry(FieldName.FILE)) { this.setEnabled(false); } } @@ -173,7 +173,7 @@ public RightClickMenu(JabRefFrame frame, BasePanel panel) { add(new GeneralAction(Actions.OPEN_URL, Localization.lang("Open URL or DOI"), IconTheme.JabRefIcon.WWW.getSmallIcon()) { { - if(!(isFieldSetForSelectedEntry(FieldName.URL_FIELD) || isFieldSetForSelectedEntry(FieldName.DOI_FIELD))) { + if(!(isFieldSetForSelectedEntry(FieldName.URL) || isFieldSetForSelectedEntry(FieldName.DOI))) { this.setEnabled(false); } } @@ -185,7 +185,7 @@ public RightClickMenu(JabRefFrame frame, BasePanel panel) { add(new GeneralAction(Actions.MERGE_DOI, Localization.lang("Get BibTeX data from DOI")) { { - if (!(isFieldSetForSelectedEntry(FieldName.DOI_FIELD))) { + if (!(isFieldSetForSelectedEntry(FieldName.DOI))) { this.setEnabled(false); } } @@ -280,8 +280,8 @@ private boolean isFieldSetForSelectedEntry(String fieldname) { private Icon getFileIconForSelectedEntry() { if (panel.getMainTable().getSelectedRowCount() == 1) { BibEntry entry = panel.getMainTable().getSelected().get(0); - if(entry.hasField(FieldName.FILE_FIELD)) { - JLabel label = FileListTableModel.getFirstLabel(entry.getFieldOptional(FieldName.FILE_FIELD).get()); + if(entry.hasField(FieldName.FILE)) { + JLabel label = FileListTableModel.getFirstLabel(entry.getFieldOptional(FieldName.FILE).get()); if (label != null) { return label.getIcon(); } diff --git a/src/main/java/net/sf/jabref/gui/mergeentries/MergeEntryDOIDialog.java b/src/main/java/net/sf/jabref/gui/mergeentries/MergeEntryDOIDialog.java index 813be79b78af..0c3e2b77b0ae 100644 --- a/src/main/java/net/sf/jabref/gui/mergeentries/MergeEntryDOIDialog.java +++ b/src/main/java/net/sf/jabref/gui/mergeentries/MergeEntryDOIDialog.java @@ -74,7 +74,7 @@ public MergeEntryDOIDialog(BasePanel panel) { this.originalEntry = panel.getSelectedEntries().get(0); panel.output(Localization.lang("Fetching info based on DOI")); - Optional doi = this.originalEntry.getFieldOptional(FieldName.DOI_FIELD); + Optional doi = this.originalEntry.getFieldOptional(FieldName.DOI); if (doi.isPresent()) { this.doiEntry = doiFetcher.getEntryFromDOI(doi.get()).orElse(null); diff --git a/src/main/java/net/sf/jabref/gui/openoffice/OOBibBase.java b/src/main/java/net/sf/jabref/gui/openoffice/OOBibBase.java index 6cad20477f8c..3ec5e3d9cc66 100644 --- a/src/main/java/net/sf/jabref/gui/openoffice/OOBibBase.java +++ b/src/main/java/net/sf/jabref/gui/openoffice/OOBibBase.java @@ -135,9 +135,9 @@ class OOBibBase { private final boolean atEnd; private final Comparator entryComparator; private final Comparator yearAuthorTitleComparator; - private final FieldComparator authComp = new FieldComparator(FieldName.AUTHOR_FIELD); - private final FieldComparator yearComp = new FieldComparator(FieldName.YEAR_FIELD); - private final FieldComparator titleComp = new FieldComparator("title"); + private final FieldComparator authComp = new FieldComparator(FieldName.AUTHOR); + private final FieldComparator yearComp = new FieldComparator(FieldName.YEAR); + private final FieldComparator titleComp = new FieldComparator(FieldName.TITLE); private final List> authorYearTitleList = new ArrayList<>(3); private final List> yearAuthorTitleList = new ArrayList<>(3); @@ -1215,7 +1215,7 @@ public void combineCiteMarkers(List databases, OOBibStyle style) th } } } - Collections.sort(entries, new FieldComparator(FieldName.YEAR_FIELD)); + Collections.sort(entries, new FieldComparator(FieldName.YEAR)); String keyString = String.join(",", entries.stream().map(BibEntry::getCiteKey).collect(Collectors.toList())); // Insert bookmark: 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 ed414e86a0bf..e22eafc01e30 100644 --- a/src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java +++ b/src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java @@ -373,11 +373,11 @@ private Optional getSelectedStyle() { } private void setupPrevEntry() { - prevEntry.setField(FieldName.AUTHOR_FIELD, "Smith, Bill and Jones, Bob and Williams, Jeff"); - prevEntry.setField(FieldName.EDITOR_FIELD, "Taylor, Phil"); - prevEntry.setField("title", "Title of the test entry for reference styles"); + 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.YEAR_FIELD, "2008"); + prevEntry.setField(FieldName.YEAR, "2008"); prevEntry.setField("journal", "BibTeX journal"); prevEntry.setField("publisher", "JabRef publishing"); prevEntry.setField("address", "Trondheim"); diff --git a/src/main/java/net/sf/jabref/gui/openoffice/UndefinedBibtexEntry.java b/src/main/java/net/sf/jabref/gui/openoffice/UndefinedBibtexEntry.java index 9e454e67ada5..fae53bfa2b0e 100644 --- a/src/main/java/net/sf/jabref/gui/openoffice/UndefinedBibtexEntry.java +++ b/src/main/java/net/sf/jabref/gui/openoffice/UndefinedBibtexEntry.java @@ -32,7 +32,7 @@ class UndefinedBibtexEntry extends BibEntry { public UndefinedBibtexEntry(String key) { super(IdGenerator.next()); this.key = key; - setField(FieldName.AUTHOR_FIELD, OOBibStyle.UNDEFINED_CITATION_MARKER); + setField(FieldName.AUTHOR, OOBibStyle.UNDEFINED_CITATION_MARKER); } public String getKey() { diff --git a/src/main/java/net/sf/jabref/gui/preftabs/FileTab.java b/src/main/java/net/sf/jabref/gui/preftabs/FileTab.java index 508ead6f2172..fbd93aeac6d6 100644 --- a/src/main/java/net/sf/jabref/gui/preftabs/FileTab.java +++ b/src/main/java/net/sf/jabref/gui/preftabs/FileTab.java @@ -200,7 +200,7 @@ public FileTab(JabRefFrame frame, JabRefPreferences prefs) { @Override public void setValues() { - fileDir.setText(prefs.get(FieldName.FILE_FIELD + Globals.DIR_SUFFIX)); + fileDir.setText(prefs.get(FieldName.FILE + Globals.DIR_SUFFIX)); bibLocAsPrimaryDir.setSelected(prefs.getBoolean(JabRefPreferences.BIB_LOC_AS_PRIMARY_DIR)); runAutoFileSearch.setSelected(prefs.getBoolean(JabRefPreferences.RUN_AUTOMATIC_FILE_SEARCH)); allowFileAutoOpenBrowse.setSelected(prefs.getBoolean(JabRefPreferences.ALLOW_FILE_AUTO_OPEN_BROWSE)); @@ -241,7 +241,7 @@ public void setValues() { @Override public void storeSettings() { - prefs.put(FieldName.FILE_FIELD + Globals.DIR_SUFFIX, fileDir.getText()); + prefs.put(FieldName.FILE + Globals.DIR_SUFFIX, fileDir.getText()); prefs.putBoolean(JabRefPreferences.BIB_LOC_AS_PRIMARY_DIR, bibLocAsPrimaryDir.isSelected()); prefs.putBoolean(JabRefPreferences.RUN_AUTOMATIC_FILE_SEARCH, runAutoFileSearch.isSelected()); prefs.putBoolean(JabRefPreferences.ALLOW_FILE_AUTO_OPEN_BROWSE, allowFileAutoOpenBrowse.isSelected()); 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 cd11f98102d5..ccbb504101f1 100644 --- a/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java +++ b/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java @@ -191,20 +191,20 @@ private static BibEntry getTestEntry() { } PreviewPrefsTab.entry = new BibEntry(IdGenerator.next(), "article"); PreviewPrefsTab.entry.setCiteKey("conceicao1997"); - PreviewPrefsTab.entry.setField(FieldName.AUTHOR_FIELD, + PreviewPrefsTab.entry.setField(FieldName.AUTHOR, "Luis E. C. Conceic{\\~a}o and Terje van der Meeren and Johan A. J. Verreth and M S. Evjen and D. F. Houlihan and H. J. Fyhn"); - PreviewPrefsTab.entry.setField("title", + 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_FIELD, "1997"); + 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("pdf", "conceicao1997.pdf"); - PreviewPrefsTab.entry.setField("pages", "255--265"); + PreviewPrefsTab.entry.setField(FieldName.PAGES, "255--265"); PreviewPrefsTab.entry.setField("keywords", "energetics, artemia, metabolism, amino acid, turbot"); - PreviewPrefsTab.entry.setField(FieldName.URL_FIELD, "http://ejournals.ebsco.com/direct.asp?ArticleID=TYY4NT82XA9H7R8PFPPV"); - PreviewPrefsTab.entry.setField(FieldName.ABSTRACT_FIELD, + 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 " + "on the free amino acid (FAA) pool, the rate of protein turnover, the flux of amino acids, and " + "their relation to growth of larval turbot (Scophthalmus maximus L.) from first feeding until " 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 8266344f72bd..5ac62ad3ef26 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_FIELD, "title", FieldName.YEAR_FIELD, "journal" + FieldName.AUTHOR, FieldName.TITLE, FieldName.YEAR, "journal" }; private static final int FILE_COL = 0; private static final int URL_COL = 1; @@ -131,7 +131,7 @@ private void init(String title) { .get(JabRefPreferences.PREVIEW_1); preview = new PreviewPanel(null, null, layoutFile); - sortedEntries = new SortedList<>(entries, new EntryComparator(false, true, FieldName.AUTHOR_FIELD)); + sortedEntries = new SortedList<>(entries, new EntryComparator(false, true, FieldName.AUTHOR)); model = (DefaultEventTableModel) GlazedListsSwing.eventTableModelWithThreadProxyList(sortedEntries, new EntryTableFormat()); entryTable = new JTable(model); @@ -239,9 +239,9 @@ private void setupComparatorChooser(TableComparatorChooser comparatorC comparators = comparatorChooser.getComparatorsForColumn(i); comparators.clear(); if (i == FILE_COL) { - comparators.add(new IconComparator(Collections.singletonList(FieldName.FILE_FIELD))); + comparators.add(new IconComparator(Collections.singletonList(FieldName.FILE))); } else if (i == URL_COL) { - comparators.add(new IconComparator(Collections.singletonList(FieldName.URL_FIELD))); + comparators.add(new IconComparator(Collections.singletonList(FieldName.URL))); } } @@ -347,9 +347,9 @@ public void mouseClicked(MouseEvent e) { BasePanel p = entryHome.get(entry); switch (col) { case FILE_COL: - if (entry.hasField(FieldName.FILE_FIELD)) { + if (entry.hasField(FieldName.FILE)) { FileListTableModel tableModel = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(tableModel::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(tableModel::setContent); if (tableModel.getRowCount() == 0) { return; } @@ -359,8 +359,8 @@ public void mouseClicked(MouseEvent e) { } break; case URL_COL: - entry.getFieldOptional(FieldName.URL_FIELD).ifPresent(link -> { try { - JabRefDesktop.openExternalViewer(p.getBibDatabaseContext(), link, FieldName.URL_FIELD); + entry.getFieldOptional(FieldName.URL).ifPresent(link -> { try { + JabRefDesktop.openExternalViewer(p.getBibDatabaseContext(), link, FieldName.URL); } catch (IOException ex) { LOGGER.warn("Could not open viewer", ex); } @@ -389,7 +389,7 @@ public void processPopupTrigger(MouseEvent e) { if (col == FILE_COL) { // We use a FileListTableModel to parse the field content: FileListTableModel fileList = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(fileList::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(fileList::setContent); // If there are one or more links, open the first one: for (int i = 0; i < fileList.getRowCount(); i++) { FileListEntry flEntry = fileList.getEntry(i); @@ -457,9 +457,9 @@ public Object getColumnValue(BibEntry entry, int column) { if (column < PAD) { switch (column) { case FILE_COL: - if (entry.hasField(FieldName.FILE_FIELD)) { + if (entry.hasField(FieldName.FILE)) { FileListTableModel tmpModel = new FileListTableModel(); - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(tmpModel::setContent); + entry.getFieldOptional(FieldName.FILE).ifPresent(tmpModel::setContent); fileLabel.setToolTipText(tmpModel.getToolTipHTMLRepresentation()); if (tmpModel.getRowCount() > 0) { if (tmpModel.getEntry(0).type.isPresent()) { @@ -473,8 +473,8 @@ public Object getColumnValue(BibEntry entry, int column) { return null; } case URL_COL: - if (entry.hasField(FieldName.URL_FIELD)) { - urlLabel.setToolTipText(entry.getFieldOptional(FieldName.URL_FIELD).get()); + if (entry.hasField(FieldName.URL)) { + urlLabel.setToolTipText(entry.getFieldOptional(FieldName.URL).get()); return urlLabel; } else { return null; diff --git a/src/main/java/net/sf/jabref/importer/DatabaseFileLookup.java b/src/main/java/net/sf/jabref/importer/DatabaseFileLookup.java index 06162d6391c5..7f57212264c0 100644 --- a/src/main/java/net/sf/jabref/importer/DatabaseFileLookup.java +++ b/src/main/java/net/sf/jabref/importer/DatabaseFileLookup.java @@ -80,7 +80,7 @@ public boolean lookupDatabase(File file) { private List parseFileField(BibEntry entry) { Objects.requireNonNull(entry); - List entries = FileField.parse(entry.getFieldOptional(FieldName.FILE_FIELD).orElse(null)); + List entries = FileField.parse(entry.getFieldOptional(FieldName.FILE).orElse(null)); List fileLinks = new ArrayList<>(); for (ParsedFileField field : entries) { diff --git a/src/main/java/net/sf/jabref/importer/EntryFromFileCreator.java b/src/main/java/net/sf/jabref/importer/EntryFromFileCreator.java index d13f575c642d..3910db9d53db 100644 --- a/src/main/java/net/sf/jabref/importer/EntryFromFileCreator.java +++ b/src/main/java/net/sf/jabref/importer/EntryFromFileCreator.java @@ -111,8 +111,8 @@ public Optional createEntry(File f, boolean addPathTokensAsKeywords) { appendToField(newEntry.get(), "keywords", extractPathesToKeyWordsfield(f.getAbsolutePath())); } - if (!newEntry.get().hasField("title")) { - newEntry.get().setField("title", f.getName()); + if (!newEntry.get().hasField(FieldName.TITLE)) { + newEntry.get().setField(FieldName.TITLE, f.getName()); } addFileInfo(newEntry.get(), f); @@ -162,7 +162,7 @@ private void addFileInfo(BibEntry entry, File file) { FileListTableModel model = new FileListTableModel(); model.addEntry(0, fileListEntry); - entry.setField(FieldName.FILE_FIELD, model.getStringRepresentation()); + entry.setField(FieldName.FILE, model.getStringRepresentation()); } protected void appendToField(BibEntry entry, String field, String value) { diff --git a/src/main/java/net/sf/jabref/importer/EntryFromPDFCreator.java b/src/main/java/net/sf/jabref/importer/EntryFromPDFCreator.java index 49b2efd4add1..2b78cd1a70b0 100644 --- a/src/main/java/net/sf/jabref/importer/EntryFromPDFCreator.java +++ b/src/main/java/net/sf/jabref/importer/EntryFromPDFCreator.java @@ -69,8 +69,8 @@ protected Optional createBibtexEntry(File pdfFile) { /*addEntryDataFromPDDocumentInformation(pdfFile, entry); addEntryDataFromXMP(pdfFile, entry); - if (entry.getField("title") == null) { - entry.setField("title", pdfFile.getName()); + if (entry.getField(FieldName.TITLE) == null) { + entry.setField(FieldName.TITLE, pdfFile.getName()); } return entry;*/ diff --git a/src/main/java/net/sf/jabref/importer/OAI2Handler.java b/src/main/java/net/sf/jabref/importer/OAI2Handler.java index 2e25cfbc8489..df8522881b77 100644 --- a/src/main/java/net/sf/jabref/importer/OAI2Handler.java +++ b/src/main/java/net/sf/jabref/importer/OAI2Handler.java @@ -86,28 +86,28 @@ public void endElement(String uri, String localName, String qualifiedName) throw entry.setField("volume", volume); String year = content.replaceFirst(".*?\\(", ""); year = year.replaceFirst("\\).*", ""); - entry.setField(FieldName.YEAR_FIELD, year); + entry.setField(FieldName.YEAR, year); String pages = content.replaceFirst(journal, ""); pages = pages.replaceFirst(volume, ""); pages = pages.replaceFirst("\\(" + year + "\\)", ""); pages = pages.replace(" ", ""); - entry.setField("pages", pages); + entry.setField(FieldName.PAGES, pages); } else if ("datestamp".equals(qualifiedName)) { - Optional year = entry.getFieldOptional(FieldName.YEAR_FIELD); + Optional year = entry.getFieldOptional(FieldName.YEAR); if (!year.isPresent() || year.get().isEmpty()) { - entry.setField(FieldName.YEAR_FIELD, content.replaceFirst("-.*", "")); + entry.setField(FieldName.YEAR, content.replaceFirst("-.*", "")); } - } else if ("title".equals(qualifiedName)) { - entry.setField("title", content); + } else if (FieldName.TITLE.equals(qualifiedName)) { + entry.setField(FieldName.TITLE, content); } else if ("abstract".equals(qualifiedName)) { - entry.setField(FieldName.ABSTRACT_FIELD, content); + entry.setField(FieldName.ABSTRACT, content); } else if ("comments".equals(qualifiedName)) { entry.setField("comments", content); } else if ("report-no".equals(qualifiedName)) { entry.setField("reportno", content); - } else if(FieldName.DOI_FIELD.equals(qualifiedName)) { - entry.setField(FieldName.DOI_FIELD, content); - } else if (FieldName.AUTHOR_FIELD.equals(qualifiedName)) { + } else if(FieldName.DOI.equals(qualifiedName)) { + entry.setField(FieldName.DOI, content); + } else if (FieldName.AUTHOR.equals(qualifiedName)) { String author = forenames + " " + keyname; if (authors.length() > 0) { authors.append(" and "); @@ -118,7 +118,7 @@ public void endElement(String uri, String localName, String qualifiedName) throw @Override public void endDocument() throws SAXException { - entry.setField(FieldName.AUTHOR_FIELD, authors.toString()); + entry.setField(FieldName.AUTHOR, authors.toString()); } } diff --git a/src/main/java/net/sf/jabref/importer/fetcher/ACMPortalFetcher.java b/src/main/java/net/sf/jabref/importer/fetcher/ACMPortalFetcher.java index a96288031d1f..44fcaf7b6726 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/ACMPortalFetcher.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/ACMPortalFetcher.java @@ -197,7 +197,7 @@ public void getEntries(Map selection, ImportInspector inspector if (selentry.getValue()) { downloadEntryBibTeX(selentry.getKey(), fetchAbstract).ifPresent(entry -> { // Convert from HTML and optionally add curly brackets around key words to keep the case - entry.getFieldOptional("title").ifPresent(title -> { + entry.getFieldOptional(FieldName.TITLE).ifPresent(title -> { title = title.replace("\\&", "&").replace("\\#", "#"); title = convertHTMLChars(title); @@ -210,11 +210,11 @@ public void getEntries(Map selection, ImportInspector inspector if (Globals.prefs.getBoolean(JabRefPreferences.USE_CASE_KEEPER_ON_SEARCH)) { title = protectTermsFormatter.format(title); } - entry.setField("title", title); + entry.setField(FieldName.TITLE, title); }); - entry.getFieldOptional(FieldName.ABSTRACT_FIELD) - .ifPresent(abstr -> entry.setField(FieldName.ABSTRACT_FIELD, convertHTMLChars(abstr))); + entry.getFieldOptional(FieldName.ABSTRACT) + .ifPresent(abstr -> entry.setField(FieldName.ABSTRACT, convertHTMLChars(abstr))); inspector.addEntry(entry); }); } @@ -356,7 +356,7 @@ private static Optional downloadEntryBibTeX(String id, boolean downloa Matcher absM = ACMPortalFetcher.ABSTRACT_PATTERN.matcher(page); if (absM.find()) { - entry.setField(FieldName.ABSTRACT_FIELD, absM.group(1).trim()); + entry.setField(FieldName.ABSTRACT, absM.group(1).trim()); } Thread.sleep(ACMPortalFetcher.WAIT_TIME);//wait between requests or you will be blocked by ACM } diff --git a/src/main/java/net/sf/jabref/importer/fetcher/ADSFetcher.java b/src/main/java/net/sf/jabref/importer/fetcher/ADSFetcher.java index ba2b34d72601..b8818deab06f 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/ADSFetcher.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/ADSFetcher.java @@ -160,7 +160,7 @@ private void importADSAbstract(String key, BibEntry entry, OutputPrinter status) while (reader.hasNext()) { reader.next(); if (reader.isStartElement() && - FieldName.ABSTRACT_FIELD.equals(reader.getLocalName())) { + FieldName.ABSTRACT.equals(reader.getLocalName())) { isAbstract = true; } if (isAbstract && reader.isCharacters()) { @@ -172,7 +172,7 @@ private void importADSAbstract(String key, BibEntry entry, OutputPrinter status) } String abstractText = abstractSB.toString(); abstractText = abstractText.replace("\n", " "); - entry.setField(FieldName.ABSTRACT_FIELD, abstractText); + entry.setField(FieldName.ABSTRACT, abstractText); } catch (XMLStreamException e) { status.showMessage(Localization.lang("An Error occurred while parsing abstract"), getTitle(), JOptionPane.ERROR_MESSAGE); diff --git a/src/main/java/net/sf/jabref/importer/fetcher/CiteSeerXFetcher.java b/src/main/java/net/sf/jabref/importer/fetcher/CiteSeerXFetcher.java index f1d9527fb9b4..b1f8e14876e7 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/CiteSeerXFetcher.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/CiteSeerXFetcher.java @@ -147,25 +147,25 @@ private static BibEntry getSingleCitation(String urlString) throws IOException { Matcher m = CiteSeerXFetcher.TITLE_PATTERN.matcher(cont); if (m.find()) { BibEntry entry = new BibEntry(IdGenerator.next()); - entry.setField("title", m.group(1)); + entry.setField(FieldName.TITLE, m.group(1)); // Find authors: m = CiteSeerXFetcher.AUTHOR_PATTERN.matcher(cont); if (m.find()) { String authors = m.group(1); - entry.setField(FieldName.AUTHOR_FIELD, new NormalizeNamesFormatter().format(authors)); + entry.setField(FieldName.AUTHOR, new NormalizeNamesFormatter().format(authors)); } // Find year: m = CiteSeerXFetcher.YEAR_PATTERN.matcher(cont); if (m.find()) { - entry.setField(FieldName.YEAR_FIELD, m.group(1)); + entry.setField(FieldName.YEAR, m.group(1)); } // Find abstract: m = CiteSeerXFetcher.ABSTRACT_PATTERN.matcher(cont); if (m.find()) { - entry.setField(FieldName.ABSTRACT_FIELD, m.group(1)); + entry.setField(FieldName.ABSTRACT, m.group(1)); } return entry; diff --git a/src/main/java/net/sf/jabref/importer/fetcher/CrossRef.java b/src/main/java/net/sf/jabref/importer/fetcher/CrossRef.java index 5289d926915e..f0896597ad3b 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/CrossRef.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/CrossRef.java @@ -38,7 +38,7 @@ public static Optional findDOI(BibEntry entry) { Optional doi = Optional.empty(); // title is minimum requirement - Optional title = entry.getFieldOptional("title"); + Optional title = entry.getFieldOptional(FieldName.TITLE); if (!title.isPresent() || title.get().isEmpty()) { return doi; @@ -68,14 +68,14 @@ public static Optional findDOI(BibEntry entry) { private static String enhanceQuery(String query, BibEntry entry) { StringBuilder enhancedQuery = new StringBuilder(query); // author - entry.getFieldOptional(FieldName.AUTHOR_FIELD).ifPresent(author -> { + entry.getFieldOptional(FieldName.AUTHOR).ifPresent(author -> { if (!author.isEmpty()) { enhancedQuery.append('+').append(author); } }); // year - entry.getFieldOptional(FieldName.YEAR_FIELD).ifPresent(year -> { + entry.getFieldOptional(FieldName.YEAR).ifPresent(year -> { if (!year.isEmpty()) { enhancedQuery.append('+').append(year); } @@ -86,7 +86,7 @@ private static String enhanceQuery(String query, BibEntry entry) { private static boolean checkValidity(BibEntry entry, JSONArray result) { // TODO: use latex-free version instead in the future - final String entryTitle = removeLaTeX(entry.getField("title")); + final String entryTitle = removeLaTeX(entry.getField(FieldName.TITLE)); // currently only title-based // title: [ "How the Mind Hurts and Heals the Body." ] @@ -94,7 +94,7 @@ private static boolean checkValidity(BibEntry entry, JSONArray result) { try { // title JSONObject data = result.getJSONObject(0); - String dataTitle = data.getJSONArray("title").getString(0); + String dataTitle = data.getJSONArray(FieldName.TITLE).getString(0); if (editDistanceIgnoreCase(entryTitle, dataTitle) <= METRIC_THRESHOLD) { return true; diff --git a/src/main/java/net/sf/jabref/importer/fetcher/CrossrefFetcherEvaluator.java b/src/main/java/net/sf/jabref/importer/fetcher/CrossrefFetcherEvaluator.java index c0fb4ddf9209..1ed90271712d 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/CrossrefFetcherEvaluator.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/CrossrefFetcherEvaluator.java @@ -47,7 +47,7 @@ public static void main(String[] args) throws IOException, InterruptedException @Override public void run() { - Optional origDOI = entry.getFieldOptional(FieldName.DOI_FIELD).flatMap(DOI::build); + Optional origDOI = entry.getFieldOptional(FieldName.DOI).flatMap(DOI::build); if (origDOI.isPresent()) { dois.incrementAndGet(); Optional crossrefDOI = CrossRef.findDOI(entry); diff --git a/src/main/java/net/sf/jabref/importer/fetcher/DOItoBibTeXFetcher.java b/src/main/java/net/sf/jabref/importer/fetcher/DOItoBibTeXFetcher.java index 9634b42bef56..ed05b13c537e 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/DOItoBibTeXFetcher.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/DOItoBibTeXFetcher.java @@ -21,6 +21,7 @@ import net.sf.jabref.logic.net.URLDownload; import net.sf.jabref.logic.util.DOI; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.FieldName; import net.sf.jabref.preferences.JabRefPreferences; import org.apache.commons.logging.Log; @@ -115,7 +116,7 @@ public Optional getEntryFromDOI(String doiStr, ParserResult parserResu private void formatTitleField(BibEntry entry) { // Optionally add curly brackets around key words to keep the case - entry.getFieldOptional("title").ifPresent(title -> { + entry.getFieldOptional(FieldName.TITLE).ifPresent(title -> { // Unit formatting if (Globals.prefs.getBoolean(JabRefPreferences.USE_UNIT_FORMATTER_ON_SEARCH)) { title = unitsToLatexFormatter.format(title); @@ -125,7 +126,7 @@ private void formatTitleField(BibEntry entry) { if (Globals.prefs.getBoolean(JabRefPreferences.USE_CASE_KEEPER_ON_SEARCH)) { title = protectTermsFormatter.format(title); } - entry.setField("title", title); + entry.setField(FieldName.TITLE, title); }); } diff --git a/src/main/java/net/sf/jabref/importer/fetcher/DiVAtoBibTeXFetcher.java b/src/main/java/net/sf/jabref/importer/fetcher/DiVAtoBibTeXFetcher.java index 1c77211087d4..49e91cda1c71 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/DiVAtoBibTeXFetcher.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/DiVAtoBibTeXFetcher.java @@ -36,6 +36,7 @@ import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.net.URLDownload; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.FieldName; import net.sf.jabref.preferences.JabRefPreferences; import org.apache.commons.logging.Log; @@ -95,7 +96,7 @@ public boolean processQuery(String query, ImportInspector inspector, OutputPrint BibEntry entry = BibtexParser.singleFromString(bibtexString); if (entry != null) { // Optionally add curly brackets around key words to keep the case - entry.getFieldOptional("title").ifPresent(title -> { + entry.getFieldOptional(FieldName.TITLE).ifPresent(title -> { // Unit formatting if (Globals.prefs.getBoolean(JabRefPreferences.USE_UNIT_FORMATTER_ON_SEARCH)) { title = unitsToLatexFormatter.format(title); @@ -105,7 +106,7 @@ public boolean processQuery(String query, ImportInspector inspector, OutputPrint if (Globals.prefs.getBoolean(JabRefPreferences.USE_CASE_KEEPER_ON_SEARCH)) { title = protectTermsFormatter.format(title); } - entry.setField("title", title); + entry.setField(FieldName.TITLE, title); }); entry.getFieldOptional("institution").ifPresent( 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 87c671c08904..1ab9af461bb9 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/GVKParser.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/GVKParser.java @@ -365,13 +365,13 @@ private BibEntry parseEntry(Element e) { // Zuordnung der Felder in Abhängigkeit vom Dokumenttyp if (author != null) { - result.setField(FieldName.AUTHOR_FIELD, author); + result.setField(FieldName.AUTHOR, author); } if (editor != null) { - result.setField(FieldName.EDITOR_FIELD, editor); + result.setField(FieldName.EDITOR, editor); } if (title != null) { - result.setField("title", title); + result.setField(FieldName.TITLE, title); } if (!Strings.isNullOrEmpty(subtitle)) { // ensure that first letter is an upper case letter @@ -388,7 +388,7 @@ private BibEntry parseEntry(Element e) { result.setField("publisher", publisher); } if (year != null) { - result.setField(FieldName.YEAR_FIELD, year); + result.setField(FieldName.YEAR, year); } if (address != null) { result.setField("address", address); @@ -400,10 +400,10 @@ private BibEntry parseEntry(Element e) { result.setField("edition", edition); } if (isbn != null) { - result.setField(FieldName.ISBN_FIELD, isbn); + result.setField(FieldName.ISBN, isbn); } if (issn != null) { - result.setField(FieldName.ISSN_FIELD, issn); + result.setField(FieldName.ISSN, issn); } if (number != null) { result.setField("number", number); @@ -412,7 +412,7 @@ private BibEntry parseEntry(Element e) { result.setField("pagetotal", pagetotal); } if (pages != null) { - result.setField("pages", pages); + result.setField(FieldName.PAGES, pages); } if (volume != null) { result.setField("volume", volume); @@ -424,7 +424,7 @@ private BibEntry parseEntry(Element e) { result.setField("ppn_GVK", ppn); } if (url != null) { - result.setField(FieldName.URL_FIELD, url); + result.setField(FieldName.URL, url); } if (note != null) { result.setField("note", note); diff --git a/src/main/java/net/sf/jabref/importer/fetcher/GoogleScholarFetcher.java b/src/main/java/net/sf/jabref/importer/fetcher/GoogleScholarFetcher.java index d0e9f289fcc6..5c33925e30b9 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/GoogleScholarFetcher.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/GoogleScholarFetcher.java @@ -277,20 +277,20 @@ private BibEntry downloadEntry(String link) throws IOException { entry.clearField(BibEntry.KEY_FIELD); // If the entry's url field is not set, and we have stored an url for this // entry, set it: - if (!entry.hasField(FieldName.URL_FIELD)) { + if (!entry.hasField(FieldName.URL)) { String storedUrl = entryLinks.get(link); if (storedUrl != null) { - entry.setField(FieldName.URL_FIELD, storedUrl); + entry.setField(FieldName.URL, storedUrl); } } // Clean up some remaining HTML code from Elsevier(?) papers // Search for: Poincare algebra // to see an example - entry.getFieldOptional("title").ifPresent(title -> { + entry.getFieldOptional(FieldName.TITLE).ifPresent(title -> { String newtitle = title.replaceAll("<.?i>([^<]*)", "$1"); if (!newtitle.equals(title)) { - entry.setField("title", newtitle); + entry.setField(FieldName.TITLE, newtitle); } }); return entry; 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 d10df439f0ed..0cce39ce67a2 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/IEEEXploreFetcher.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/IEEEXploreFetcher.java @@ -269,8 +269,8 @@ private BibEntry cleanup(BibEntry entry) { } // clean up title - if (entry.hasField("title")) { - String title = entry.getField("title"); + if (entry.hasField(FieldName.TITLE)) { + String title = entry.getField(FieldName.TITLE); // USe the alt-text and replace image links title = title.replaceAll("[ ]?img src=[^ ]+ alt=\"([^\"]+)\">[ ]?", "\\$$1\\$"); // Try to sort out most of the /spl / conversions @@ -298,12 +298,12 @@ private BibEntry cleanup(BibEntry entry) { title = protectTermsFormatter.format(title); } // Write back - entry.setField("title", title); + entry.setField(FieldName.TITLE, title); } // clean up author - if (entry.hasField(FieldName.AUTHOR_FIELD)) { - String author = entry.getField(FieldName.AUTHOR_FIELD); + if (entry.hasField(FieldName.AUTHOR)) { + String author = entry.getField(FieldName.AUTHOR); author = author.replaceAll("\\s+", " "); //reorder the "Jr." "Sr." etc to the correct ordering @@ -318,7 +318,7 @@ private BibEntry cleanup(BibEntry entry) { .replace(" ,", ",").replace(" ", " "); author = author.replaceAll("[ ,;]+$", ""); //TODO: remove trailing commas - entry.setField(FieldName.AUTHOR_FIELD, author); + entry.setField(FieldName.AUTHOR, author); } // clean up month @@ -356,14 +356,14 @@ private BibEntry cleanup(BibEntry entry) { } // clean up pages - if (entry.hasField("pages")) { - String pages = entry.getField("pages"); + if (entry.hasField(FieldName.PAGES)) { + String pages = entry.getField(FieldName.PAGES); String[] pageNumbers = pages.split("-"); if (pageNumbers.length == 2) { if (pageNumbers[0].equals(pageNumbers[1])) {// single page - entry.setField("pages", pageNumbers[0]); + entry.setField(FieldName.PAGES, pageNumbers[0]); } else { - entry.setField("pages", pages.replace("-", "--")); + entry.setField(FieldName.PAGES, pages.replace("-", "--")); } } } @@ -383,9 +383,9 @@ private BibEntry cleanup(BibEntry entry) { int ind = fullName.indexOf(": Accepted for future publication"); if (ind > 0) { fullName = fullName.substring(0, ind); - entry.setField(FieldName.YEAR_FIELD, "to be published"); + entry.setField(FieldName.YEAR, "to be published"); entry.clearField("month"); - entry.clearField("pages"); + entry.clearField(FieldName.PAGES); entry.clearField("number"); } String[] parts = fullName.split("[\\[\\]]"); //[see also...], [legacy...] @@ -395,9 +395,9 @@ private BibEntry cleanup(BibEntry entry) { } String note = entry.getField("note"); if ("Early Access".equals(note)) { - entry.setField(FieldName.YEAR_FIELD, "to be published"); + entry.setField(FieldName.YEAR, "to be published"); entry.clearField("month"); - entry.clearField("pages"); + entry.clearField(FieldName.PAGES); entry.clearField("number"); } } else { @@ -472,7 +472,7 @@ private BibEntry cleanup(BibEntry entry) { fullName = fullName.trim(); fullName = fullName.replaceAll("^[tT]he ", "").replaceAll("^\\d{4} ", "").replaceAll("[,.]$", ""); - String year = entry.getField(FieldName.YEAR_FIELD); + String year = entry.getField(FieldName.YEAR); if (year != null) { fullName = fullName.replaceAll(", " + year + "\\.?", ""); } @@ -486,8 +486,8 @@ private BibEntry cleanup(BibEntry entry) { } // clean up abstract - if (entry.hasField(FieldName.ABSTRACT_FIELD)) { - String abstr = entry.getField(FieldName.ABSTRACT_FIELD); + if (entry.hasField(FieldName.ABSTRACT)) { + String abstr = entry.getField(FieldName.ABSTRACT); // Try to sort out most of the /spl / conversions // Deal with this specific nested type first abstr = abstr.replaceAll("/sub /spl infin//", "\\$_\\\\infty\\$"); @@ -502,12 +502,12 @@ private BibEntry cleanup(BibEntry entry) { // Replace \infin with \infty abstr = abstr.replace("\\infin", "\\infty"); // Write back - entry.setField(FieldName.ABSTRACT_FIELD, abstr); + entry.setField(FieldName.ABSTRACT, abstr); } // Clean up url - entry.getFieldOptional(FieldName.URL_FIELD) - .ifPresent(url -> entry.setField(FieldName.URL_FIELD, "http://ieeexplore.ieee.org" + url.replace("tp=&", ""))); + entry.getFieldOptional(FieldName.URL) + .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", diff --git a/src/main/java/net/sf/jabref/importer/fetcher/ISBNtoBibTeXFetcher.java b/src/main/java/net/sf/jabref/importer/fetcher/ISBNtoBibTeXFetcher.java index 3c9949d76bc3..8cfc6a58b5b7 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/ISBNtoBibTeXFetcher.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/ISBNtoBibTeXFetcher.java @@ -35,6 +35,7 @@ import net.sf.jabref.logic.formatter.casechanger.ProtectTermsFormatter; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.FieldName; import net.sf.jabref.preferences.JabRefPreferences; import org.apache.commons.logging.Log; @@ -90,7 +91,7 @@ public boolean processQuery(String query, ImportInspector inspector, OutputPrint BibEntry entry = BibtexParser.singleFromString(bibtexString); if (entry != null) { // Optionally add curly brackets around key words to keep the case - entry.getFieldOptional("title").ifPresent(title -> { + entry.getFieldOptional(FieldName.TITLE).ifPresent(title -> { // Unit formatting if (Globals.prefs.getBoolean(JabRefPreferences.USE_UNIT_FORMATTER_ON_SEARCH)) { title = unitsToLatexFormatter.format(title); @@ -100,7 +101,7 @@ public boolean processQuery(String query, ImportInspector inspector, OutputPrint if (Globals.prefs.getBoolean(JabRefPreferences.USE_CASE_KEEPER_ON_SEARCH)) { title = protectTermsFormatter.format(title); } - entry.setField("title", title); + entry.setField(FieldName.TITLE, title); }); inspector.addEntry(entry); return true; 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 f12849a94471..6c7ee5f03ff9 100644 --- a/src/main/java/net/sf/jabref/importer/fetcher/OAI2Fetcher.java +++ b/src/main/java/net/sf/jabref/importer/fetcher/OAI2Fetcher.java @@ -207,7 +207,7 @@ public BibEntry importOai2Entry(String key) { } if (fixedKey.matches("\\d\\d\\d\\d\\..*")) { - be.setField(FieldName.YEAR_FIELD, "20" + fixedKey.substring(0, 2)); + be.setField(FieldName.YEAR, "20" + fixedKey.substring(0, 2)); int monthNumber = Integer.parseInt(fixedKey.substring(2, 4)); MonthUtil.Month month = MonthUtil.getMonthByNumber(monthNumber); 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 6b36911d4a0b..ca0c1d43785e 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/BiblioscapeImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/BiblioscapeImporter.java @@ -83,7 +83,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { // add item for (Map.Entry entry : lines.entrySet()) { if ("AU".equals(entry.getKey())) { - hm.put(FieldName.AUTHOR_FIELD, entry.getValue() + hm.put(FieldName.AUTHOR, entry.getValue() .toString()); } else if ("TI".equals(entry.getKey())) { titleTI = entry.getValue() @@ -92,7 +92,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { titleST = entry.getValue() .toString(); } else if ("YP".equals(entry.getKey())) { - hm.put(FieldName.YEAR_FIELD, entry + hm.put(FieldName.YEAR, entry .getValue().toString()); } else if ("VL".equals(entry.getKey())) { hm.put("volume", entry @@ -143,10 +143,10 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { comments .add("Quaternary Title: " + entry.getValue()); } else if ("IS".equals(entry.getKey())) { - hm.put(FieldName.ISBN_FIELD, entry + hm.put(FieldName.ISBN, entry .getValue().toString()); } else if ("AB".equals(entry.getKey())) { - hm.put(FieldName.ABSTRACT_FIELD, entry + hm.put(FieldName.ABSTRACT, entry .getValue().toString()); } else if ("AD".equals(entry.getKey())) { address = entry.getValue() @@ -159,7 +159,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { .toString(); } else if ("UR".equals(entry.getKey()) || "AT".equals(entry.getKey())) { String s = entry.getValue().toString().trim(); - hm.put(s.startsWith("http://") || s.startsWith("ftp://") ? FieldName.URL_FIELD + hm.put(s.startsWith("http://") || s.startsWith("ftp://") ? FieldName.URL : "pdf", entry.getValue().toString()); } else if ("C1".equals(entry.getKey())) { comments.add("Custom1: " @@ -235,14 +235,14 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { hm.put("journal", titleST); } if (titleTI != null) { - hm.put("title", titleTI); + hm.put(FieldName.TITLE, titleTI); } } else if ("inbook".equals(bibtexType)) { if (titleST != null) { hm.put("booktitle", titleST); } if (titleTI != null) { - hm.put("title", titleTI); + hm.put(FieldName.TITLE, titleTI); } } else { if (titleST != null) { @@ -251,13 +251,13 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { // happen, I // think if (titleTI != null) { - hm.put("title", titleTI); + hm.put(FieldName.TITLE, titleTI); } } // concatenate pages if ((pages[0] != null) || (pages[1] != null)) { - hm.put("pages", (pages[0] == null ? "" : pages[0]) + (pages[1] == null ? "" : "--" + pages[1])); + hm.put(FieldName.PAGES, (pages[0] == null ? "" : pages[0]) + (pages[1] == null ? "" : "--" + pages[1])); } // concatenate address and country 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 66f470059cdd..7c94b7b853a0 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/CopacImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/CopacImporter.java @@ -124,17 +124,17 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { String code = line.substring(0, 4); if ("TI- ".equals(code)) { - setOrAppend(b, "title", line.substring(4).trim(), ", "); + setOrAppend(b, FieldName.TITLE, line.substring(4).trim(), ", "); } else if ("AU- ".equals(code)) { - setOrAppend(b, FieldName.AUTHOR_FIELD, line.substring(4).trim(), " and "); + setOrAppend(b, FieldName.AUTHOR, line.substring(4).trim(), " and "); } else if ("PY- ".equals(code)) { - setOrAppend(b, FieldName.YEAR_FIELD, line.substring(4).trim(), ", "); + setOrAppend(b, FieldName.YEAR, line.substring(4).trim(), ", "); } else if ("PU- ".equals(code)) { setOrAppend(b, "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_FIELD, line.substring(4).trim(), ", "); + setOrAppend(b, FieldName.ISBN, line.substring(4).trim(), ", "); } else if ("KW- ".equals(code)) { setOrAppend(b, "keywords", line.substring(4).trim(), ", "); } else if ("NT- ".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 7eaf4143c587..f2a50fbc3670 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/EndnoteImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/EndnoteImporter.java @@ -149,7 +149,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { editor += " and " + val; } } else if ("T".equals(prefix)) { - hm.put("title", val); + hm.put(FieldName.TITLE, val); } else if ("0".equals(prefix)) { if (val.indexOf("Journal") == 0) { type = "article"; @@ -176,9 +176,9 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } else if ("C".equals(prefix)) { hm.put("address", val); } else if ("D".equals(prefix)) { - hm.put(FieldName.YEAR_FIELD, val); + hm.put(FieldName.YEAR, val); } else if ("8".equals(prefix)) { - hm.put(FieldName.DATE_FIELD, val); + hm.put(FieldName.DATE, val); } else if ("J".equals(prefix)) { // "Alternate journal. Let's set it only if no journal // has been set with %B. @@ -203,19 +203,19 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } // replace single dash page ranges (23-45) with double dashes (23--45): else if ("P".equals(prefix)) { - hm.put("pages", val.replaceAll("([0-9]) *- *([0-9])", "$1--$2")); + hm.put(FieldName.PAGES, val.replaceAll("([0-9]) *- *([0-9])", "$1--$2")); } else if ("V".equals(prefix)) { hm.put("volume", val); } else if ("N".equals(prefix)) { hm.put("number", val); } else if ("U".equals(prefix)) { - hm.put(FieldName.URL_FIELD, val); + hm.put(FieldName.URL, val); } else if ("R".equals(prefix)) { String doi = val; if (doi.startsWith("doi:")) { doi = doi.substring(4); } - hm.put(FieldName.DOI_FIELD, doi); + hm.put(FieldName.DOI, doi); } else if ("O".equals(prefix)) { // Notes may contain Article number if (val.startsWith("Artn")) { @@ -227,7 +227,7 @@ else if ("P".equals(prefix)) { } else if ("K".equals(prefix)) { hm.put("keywords", val); } else if ("X".equals(prefix)) { - hm.put(FieldName.ABSTRACT_FIELD, val); + hm.put(FieldName.ABSTRACT, val); } else if ("9".equals(prefix)) { if (val.indexOf("Ph.D.") == 0) { type = "phdthesis"; @@ -249,14 +249,14 @@ else if ("P".equals(prefix)) { //fixauthorscomma if (!"".equals(author)) { - hm.put(FieldName.AUTHOR_FIELD, fixAuthor(author)); + hm.put(FieldName.AUTHOR, fixAuthor(author)); } if (!"".equals(editor)) { - hm.put(FieldName.EDITOR_FIELD, fixAuthor(editor)); + hm.put(FieldName.EDITOR, fixAuthor(editor)); } //if pages missing and article number given, use the article number - if (((hm.get("pages") == null) || "-".equals(hm.get("pages"))) && !"".equals(artnum)) { - hm.put("pages", artnum); + if (((hm.get(FieldName.PAGES) == null) || "-".equals(hm.get(FieldName.PAGES))) && !"".equals(artnum)) { + hm.put(FieldName.PAGES, artnum); } BibEntry b = new BibEntry(DEFAULT_BIBTEXENTRY_ID, type); // id assumes an existing database so don't 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 30f105812248..75ab875fff45 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/FreeCiteImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/FreeCiteImporter.java @@ -153,7 +153,7 @@ public ParserResult importEntries(String text) { // current tag is either begin:author or // end:authors } - e.setField(FieldName.AUTHOR_FIELD, sb.toString()); + e.setField(FieldName.AUTHOR, sb.toString()); } else if ("journal".equals(ln)) { // we guess that the entry is a journal // the alternative way is to parse @@ -166,16 +166,16 @@ public ParserResult importEntries(String text) { type = BibtexEntryTypes.TECHREPORT; // the content of the "tech" field seems to contain the number of the technical report e.setField("number", parser.getElementText()); - } else if (FieldName.DOI_FIELD.equals(ln) + } else if (FieldName.DOI.equals(ln) || "institution".equals(ln) || "location".equals(ln) || "number".equals(ln) || "note".equals(ln) - || "title".equals(ln) - || "pages".equals(ln) + || FieldName.TITLE.equals(ln) + || FieldName.PAGES.equals(ln) || "publisher".equals(ln) || "volume".equals(ln) - || FieldName.YEAR_FIELD.equals(ln)) { + || FieldName.YEAR.equals(ln)) { e.setField(ln, parser.getElementText()); } else if ("booktitle".equals(ln)) { String booktitle = parser.getElementText(); 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 3bbc911c378a..3f68cd8e97c8 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/InspecImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/InspecImporter.java @@ -92,14 +92,14 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { String f3 = s.substring(0, 2); String frest = s.substring(5); if ("TI".equals(f3)) { - h.put("title", frest); + h.put(FieldName.TITLE, frest); } else if ("PY".equals(f3)) { - h.put(FieldName.YEAR_FIELD, frest); + h.put(FieldName.YEAR, frest); } else if ("AU".equals(f3)) { - h.put(FieldName.AUTHOR_FIELD, + h.put(FieldName.AUTHOR, AuthorList.fixAuthorLastNameFirst(frest.replace(",-", ", ").replace(";", " and "))); } else if ("AB".equals(f3)) { - h.put(FieldName.ABSTRACT_FIELD, frest); + h.put(FieldName.ABSTRACT, frest); } else if ("ID".equals(f3)) { h.put("keywords", frest); } else if ("SO".equals(f3)) { @@ -111,12 +111,12 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { m = frest.indexOf(';'); if (m >= 5) { String yr = frest.substring(m - 5, m).trim(); - h.put(FieldName.YEAR_FIELD, yr); + h.put(FieldName.YEAR, yr); frest = frest.substring(m); m = frest.indexOf(':'); if (m >= 0) { String pg = frest.substring(m + 1).trim(); - h.put("pages", pg); + h.put(FieldName.PAGES, pg); String vol = frest.substring(1, m).trim(); h.put("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 665b2196896a..947d6c460ffe 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/IsiImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/IsiImporter.java @@ -102,7 +102,7 @@ public boolean isRecognizedFormat(BufferedReader reader) throws IOException { public static void processSubSup(Map map) { - String[] subsup = {"title", FieldName.ABSTRACT_FIELD, FieldName.REVIEW_FIELD, "notes"}; + String[] subsup = {FieldName.TITLE, FieldName.ABSTRACT, FieldName.REVIEW, "notes"}; for (String aSubsup : subsup) { if (map.containsKey(aSubsup)) { @@ -133,7 +133,7 @@ public static void processSubSup(Map map) { private static void processCapitalization(Map map) { - String[] subsup = {"title", "journal", "publisher"}; + String[] subsup = {FieldName.TITLE, "journal", "publisher"}; for (String aSubsup : subsup) { @@ -232,13 +232,13 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { String author = IsiImporter.isiAuthorsConvert(value.replace("EOLEOL", " and ")); // if there is already someone there then append with "and" - if (hm.get(FieldName.AUTHOR_FIELD) != null) { - author = hm.get(FieldName.AUTHOR_FIELD) + " and " + author; + if (hm.get(FieldName.AUTHOR) != null) { + author = hm.get(FieldName.AUTHOR) + " and " + author; } - hm.put(FieldName.AUTHOR_FIELD, author); + hm.put(FieldName.AUTHOR, author); } else if ("TI".equals(beg)) { - hm.put("title", value.replace("EOLEOL", " ")); + hm.put(FieldName.TITLE, value.replace("EOLEOL", " ")); } else if ("SO".equals(beg) || "JA".equals(beg)) { hm.put("journal", value.replace("EOLEOL", " ")); } else if ("ID".equals(beg) || "KW".equals(beg)) { @@ -253,7 +253,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { hm.put("keywords", existingKeywords); } else if ("AB".equals(beg)) { - hm.put(FieldName.ABSTRACT_FIELD, value.replace("EOLEOL", " ")); + hm.put(FieldName.ABSTRACT, value.replace("EOLEOL", " ")); } else if ("BP".equals(beg) || "BR".equals(beg) || "SP".equals(beg)) { pages = value; } else if ("EP".equals(beg)) { @@ -272,13 +272,13 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } else if ("IS".equals(beg)) { hm.put("number", value); } else if ("PY".equals(beg)) { - hm.put(FieldName.YEAR_FIELD, value); + hm.put(FieldName.YEAR, value); } else if ("VL".equals(beg)) { hm.put("volume", value); } else if ("PU".equals(beg)) { hm.put("publisher", value); } else if ("DI".equals(beg)) { - hm.put(FieldName.DOI_FIELD, value); + hm.put(FieldName.DOI, value); } else if ("PD".equals(beg)) { String month = IsiImporter.parseMonth(value); @@ -307,7 +307,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } if (!"".equals(pages)) { - hm.put("pages", pages); + hm.put(FieldName.PAGES, pages); } // Skip empty entries 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 836c20760d4e..441061e11fbc 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/JSONEntryParser.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/JSONEntryParser.java @@ -43,7 +43,7 @@ public class JSONEntryParser { */ public BibEntry parseBibJSONtoBibtex(JSONObject bibJsonEntry) { // Fields that are directly accessible at the top level BibJson object - String[] singleFieldStrings = {FieldName.YEAR_FIELD, "title", FieldName.ABSTRACT_FIELD, "month"}; + String[] singleFieldStrings = {FieldName.YEAR, FieldName.TITLE, FieldName.ABSTRACT, "month"}; // Fields that are accessible in the journal part of the BibJson object String[] journalSingleFieldStrings = {"publisher", "number", "volume"}; @@ -64,7 +64,7 @@ public BibEntry parseBibJSONtoBibtex(JSONObject bibJsonEntry) { LOGGER.info("Empty author name."); } } - entry.setField(FieldName.AUTHOR_FIELD, String.join(" and ", authorList)); + entry.setField(FieldName.AUTHOR, String.join(" and ", authorList)); } else { LOGGER.info("No author found."); } @@ -79,10 +79,10 @@ public BibEntry parseBibJSONtoBibtex(JSONObject bibJsonEntry) { // Page numbers if (bibJsonEntry.has("start_page")) { if (bibJsonEntry.has("end_page")) { - entry.setField("pages", + entry.setField(FieldName.PAGES, bibJsonEntry.getString("start_page") + "--" + bibJsonEntry.getString("end_page")); } else { - entry.setField("pages", bibJsonEntry.getString("start_page")); + entry.setField(FieldName.PAGES, bibJsonEntry.getString("start_page")); } } @@ -123,11 +123,11 @@ public BibEntry parseBibJSONtoBibtex(JSONObject bibJsonEntry) { for (int i = 0; i < identifiers.length(); i++) { String type = identifiers.getJSONObject(i).getString("type"); if ("doi".equals(type)) { - entry.setField(FieldName.DOI_FIELD, identifiers.getJSONObject(i).getString("id")); + entry.setField(FieldName.DOI, identifiers.getJSONObject(i).getString("id")); } else if ("pissn".equals(type)) { - entry.setField(FieldName.ISSN_FIELD, identifiers.getJSONObject(i).getString("id")); + entry.setField(FieldName.ISSN, identifiers.getJSONObject(i).getString("id")); } else if ("eissn".equals(type)) { - entry.setField(FieldName.ISSN_FIELD, identifiers.getJSONObject(i).getString("id")); + entry.setField(FieldName.ISSN, identifiers.getJSONObject(i).getString("id")); } } } @@ -139,7 +139,7 @@ public BibEntry parseBibJSONtoBibtex(JSONObject bibJsonEntry) { if (links.getJSONObject(i).has("type")) { String type = links.getJSONObject(i).getString("type"); if ("fulltext".equals(type) && links.getJSONObject(i).has("url")) { - entry.setField(FieldName.URL_FIELD, links.getJSONObject(i).getString("url")); + entry.setField(FieldName.URL, links.getJSONObject(i).getString("url")); } } } @@ -156,7 +156,7 @@ 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_FIELD, "volume", FieldName.ABSTRACT_FIELD, FieldName.DOI_FIELD, "title", "number", + String[] singleFieldStrings = {FieldName.ISSN, "volume", FieldName.ABSTRACT, FieldName.DOI, FieldName.TITLE, "number", "publisher"}; BibEntry entry = new BibEntry(); @@ -172,7 +172,7 @@ public static BibEntry parseSpringerJSONtoBibtex(JSONObject springerJsonEntry) { // Probably book chapter or from proceeding, go for book chapter entry.setType("incollection"); nametype = "booktitle"; - entry.setField(FieldName.ISBN_FIELD, isbn); + entry.setField(FieldName.ISBN, isbn); } // Authors @@ -186,7 +186,7 @@ public static BibEntry parseSpringerJSONtoBibtex(JSONObject springerJsonEntry) { LOGGER.info("Empty author name."); } } - entry.setField(FieldName.AUTHOR_FIELD, String.join(" and ", authorList)); + entry.setField(FieldName.AUTHOR, String.join(" and ", authorList)); } else { LOGGER.info("No author found."); } @@ -204,10 +204,10 @@ public static BibEntry parseSpringerJSONtoBibtex(JSONObject springerJsonEntry) { // Page numbers if (springerJsonEntry.has("startingPage") && !(springerJsonEntry.getString("startingPage").isEmpty())) { if (springerJsonEntry.has("endPage") && !(springerJsonEntry.getString("endPage").isEmpty())) { - entry.setField("pages", + entry.setField(FieldName.PAGES, springerJsonEntry.getString("startingPage") + "--" + springerJsonEntry.getString("endPage")); } else { - entry.setField("pages", springerJsonEntry.getString("startingPage")); + entry.setField(FieldName.PAGES, springerJsonEntry.getString("startingPage")); } } @@ -220,25 +220,25 @@ public static BibEntry parseSpringerJSONtoBibtex(JSONObject springerJsonEntry) { if (springerJsonEntry.has("url")) { JSONArray urlarray = springerJsonEntry.optJSONArray("url"); if (urlarray == null) { - entry.setField(FieldName.URL_FIELD, springerJsonEntry.optString("url")); + entry.setField(FieldName.URL, springerJsonEntry.optString("url")); } else { - entry.setField(FieldName.URL_FIELD, urlarray.getJSONObject(0).optString("value")); + entry.setField(FieldName.URL, urlarray.getJSONObject(0).optString("value")); } } // Date if (springerJsonEntry.has("publicationDate")) { String date = springerJsonEntry.getString("publicationDate"); - entry.setField(FieldName.DATE_FIELD, date); // For BibLatex + entry.setField(FieldName.DATE, date); // For BibLatex String[] dateparts = date.split("-"); - entry.setField(FieldName.YEAR_FIELD, dateparts[0]); + entry.setField(FieldName.YEAR, dateparts[0]); entry.setField("month", MonthUtil.getMonthByNumber(Integer.parseInt(dateparts[1])).bibtexFormat); } // Clean up abstract (often starting with Abstract) - entry.getFieldOptional(FieldName.ABSTRACT_FIELD).ifPresent(abstractContents -> { + entry.getFieldOptional(FieldName.ABSTRACT).ifPresent(abstractContents -> { if (abstractContents.startsWith("Abstract")) { - entry.setField(FieldName.ABSTRACT_FIELD, abstractContents.substring(8)); + entry.setField(FieldName.ABSTRACT, abstractContents.substring(8)); } }); 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 fecbb79241e7..04d96a7622b7 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/MedlineHandler.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/MedlineHandler.java @@ -175,7 +175,7 @@ else if ("URL".equals(localName)) { } else if ("ArticleId".equals(localName)) { for (int i = 0; i < atts.getLength(); i++) { String value = atts.getValue(i); - if (FieldName.DOI_FIELD.equals(value)) { + if (FieldName.DOI.equals(value)) { inDoi = true; } else if ("pii".equals(value)) { inPii = true; @@ -228,23 +228,23 @@ public void endElement(String uri, String localName, String qName) { BibEntry b = new BibEntry(IdGenerator.next(), "article"); // id assumes an existing database so don't create one here if (!"".equals(author)) { - b.setField(FieldName.AUTHOR_FIELD, + b.setField(FieldName.AUTHOR, MedlineHandler.UNICODE_CONVERTER.format(author)); author = ""; } if (!"".equals(title)) { - b.setField("title", MedlineHandler.UNICODE_CONVERTER.format(title)); + b.setField(FieldName.TITLE, MedlineHandler.UNICODE_CONVERTER.format(title)); } // if (!title.equals("")) b.setField("title",Util.replaceSpecialCharacters(title)); if (!"".equals(journal)) { b.setField("journal", journal); } if (!"".equals(year)) { - b.setField(FieldName.YEAR_FIELD, year); + b.setField(FieldName.YEAR, year); } // PENDING jeffrey.kuhn@yale.edu 2005-05-27 : added call to fixPageRange if (!"".equals(page)) { - b.setField("pages", fixPageRange(page)); + b.setField(FieldName.PAGES, fixPageRange(page)); } if (!"".equals(volume)) { b.setField("volume", volume); @@ -256,7 +256,7 @@ public void endElement(String uri, String localName, String qName) { b.setField("medline-pst", pst); } if (!"".equals(abstractText)) { - b.setField(FieldName.ABSTRACT_FIELD, abstractText.replace("%", "\\%")); + b.setField(FieldName.ABSTRACT, abstractText.replace("%", "\\%")); } if (!"".equals(keywords)) { b.setField("keywords", keywords); @@ -270,8 +270,8 @@ public void endElement(String uri, String localName, String qName) { } if (!"".equals(doi)) { - b.setField(FieldName.DOI_FIELD, doi); - b.setField(FieldName.URL_FIELD, "http://dx.doi.org/" + doi); + b.setField(FieldName.DOI, doi); + b.setField(FieldName.URL, "http://dx.doi.org/" + doi); } if (!"".equals(pii)) { b.setField("pii", pii); 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 83b62cc8d32d..2ac838f924c9 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/MedlinePlainImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/MedlinePlainImporter.java @@ -156,7 +156,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { //store the fields in a map Map hashMap = new HashMap<>(); - hashMap.put("PG", "pages"); + hashMap.put("PG", FieldName.PAGES); hashMap.put("PL", "address"); hashMap.put("PHST", "history"); hashMap.put("PST", "publication-status"); @@ -214,8 +214,8 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { comment = comment + value; } } - fixAuthors(fields, author, FieldName.AUTHOR_FIELD); - fixAuthors(fields, editor, FieldName.EDITOR_FIELD); + fixAuthors(fields, author, FieldName.AUTHOR); + fixAuthors(fields, editor, FieldName.EDITOR); if (!comment.isEmpty()) { fields.put("comment", comment); } @@ -275,7 +275,7 @@ private String addSourceType(String value, String type) { private void addStandardNumber(Map hm, String lab, String value) { if ("IS".equals(lab)) { - String key = FieldName.ISSN_FIELD; + String key = FieldName.ISSN; //it is possible to have two issn, one for electronic and for print //if there are two then it comes at the end in brackets (electronic) or (print) //so search for the brackets @@ -289,7 +289,7 @@ private void addStandardNumber(Map hm, String lab, String value) hm.put(key, value); } } else if ("ISBN".equals(lab)) { - hm.put(FieldName.ISBN_FIELD, value); + hm.put(FieldName.ISBN, value); } } @@ -306,7 +306,7 @@ private void addIDs(Map hm, String lab, String value) { String idValue = value; if (value.startsWith("doi:")) { idValue = idValue.replaceAll("(?i)doi:", "").trim(); - key = FieldName.DOI_FIELD; + key = FieldName.DOI; } else if (value.indexOf('[') > 0) { int startOfIdentifier = value.indexOf('['); int endOfIdentifier = value.indexOf(']'); @@ -330,14 +330,14 @@ private void addIDs(Map hm, String lab, String value) { private void addTitles(Map hm, String lab, String val, String type) { if ("TI".equals(lab)) { - String oldVal = hm.get("title"); + String oldVal = hm.get(FieldName.TITLE); if (oldVal == null) { - hm.put("title", val); + hm.put(FieldName.TITLE, val); } else { if (oldVal.endsWith(":") || oldVal.endsWith(".") || oldVal.endsWith("?")) { - hm.put("title", oldVal + " " + val); + hm.put(FieldName.TITLE, oldVal + " " + val); } else { - hm.put("title", oldVal + ": " + val); + hm.put(FieldName.TITLE, oldVal + ": " + val); } } } else if ("BTI".equals(lab) || "CTI".equals(lab)) { @@ -372,11 +372,11 @@ private void addAbstract(Map hm, String lab, String value) { } else { abstractValue = value; } - String oldAb = hm.get(FieldName.ABSTRACT_FIELD); + String oldAb = hm.get(FieldName.ABSTRACT); if (oldAb == null) { - hm.put(FieldName.ABSTRACT_FIELD, abstractValue); + hm.put(FieldName.ABSTRACT, abstractValue); } else { - hm.put(FieldName.ABSTRACT_FIELD, oldAb + Globals.NEWLINE + abstractValue); + hm.put(FieldName.ABSTRACT, oldAb + Globals.NEWLINE + abstractValue); } } else if ("OAB".equals(lab) || "OABL".equals(lab)) { hm.put("other-abstract", value); @@ -396,7 +396,7 @@ private void addDates(Map hm, String lab, String val) { hm.put("revised", val); } else if ("DP".equals(lab)) { String[] parts = val.split(" "); - hm.put(FieldName.YEAR_FIELD, parts[0]); + hm.put(FieldName.YEAR, parts[0]); if ((parts.length > 1) && !parts[1].isEmpty()) { hm.put("month", parts[1]); } 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 ea19e36fdf28..730fb8c2e3ae 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/OvidImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/OvidImporter.java @@ -121,14 +121,14 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } if (isAuthor) { - h.put(FieldName.AUTHOR_FIELD, content); + h.put(FieldName.AUTHOR, content); } else if (fieldName.startsWith("Title")) { content = content.replaceAll("\\[.+\\]", "").trim(); if (content.endsWith(".")) { content = content.substring(0, content.length() - 1); } - h.put("title", content); + h.put(FieldName.TITLE, content); } else if (fieldName.startsWith("Chapter Title")) { h.put("chaptertitle", content); } else if (fieldName.startsWith("Source")) { @@ -137,43 +137,43 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { h.put("journal", matcher.group(1)); h.put("volume", matcher.group(2)); h.put("issue", matcher.group(3)); - h.put("pages", matcher.group(4)); - h.put(FieldName.YEAR_FIELD, matcher.group(5)); + 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("pages", matcher.group(3)); - h.put(FieldName.YEAR_FIELD, matcher.group(4)); + 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.YEAR_FIELD, matcher.group(5)); - h.put("pages", matcher.group(6)); + h.put(FieldName.YEAR, matcher.group(5)); + h.put(FieldName.PAGES, matcher.group(6)); } else if ((matcher = OvidImporter.INCOLLECTION_PATTERN.matcher(content)).find()) { - h.put(FieldName.EDITOR_FIELD, matcher.group(1).replace(" (Ed)", "")); - h.put(FieldName.YEAR_FIELD, matcher.group(2)); + h.put(FieldName.EDITOR, matcher.group(1).replace(" (Ed)", "")); + h.put(FieldName.YEAR, matcher.group(2)); h.put("booktitle", matcher.group(3)); - h.put("pages", matcher.group(4)); + h.put(FieldName.PAGES, matcher.group(4)); h.put("address", matcher.group(5)); h.put("publisher", matcher.group(6)); } else if ((matcher = OvidImporter.BOOK_PATTERN.matcher(content)).find()) { - h.put(FieldName.YEAR_FIELD, matcher.group(1)); - h.put("pages", matcher.group(2)); + 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)); } // Add double hyphens to page ranges: - if (h.get("pages") != null) { - h.put("pages", h.get("pages").replace("-", "--")); + if (h.get(FieldName.PAGES) != null) { + h.put(FieldName.PAGES, h.get(FieldName.PAGES).replace("-", "--")); } } else if ("Abstract".equals(fieldName)) { - h.put(FieldName.ABSTRACT_FIELD, content); + h.put(FieldName.ABSTRACT, content); } else if ("Publication Type".equals(fieldName)) { if (content.contains("Book")) { @@ -189,28 +189,28 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { content = content.replace(";", ",").replace(" ", " "); h.put("keywords", content); } else if (fieldName.startsWith("ISSN")) { - h.put(FieldName.ISSN_FIELD, content); + h.put(FieldName.ISSN, content); } else if (fieldName.startsWith("DOI Number")) { - h.put(FieldName.DOI_FIELD, content); + h.put(FieldName.DOI, content); } } // Now we need to check if a book entry has given editors in the author field; // if so, rearrange: - String auth = h.get(FieldName.AUTHOR_FIELD); + String auth = h.get(FieldName.AUTHOR); if ((auth != null) && auth.contains(" [Ed]")) { - h.remove(FieldName.AUTHOR_FIELD); - h.put(FieldName.EDITOR_FIELD, auth.replace(" [Ed]", "")); + h.remove(FieldName.AUTHOR); + h.put(FieldName.EDITOR, auth.replace(" [Ed]", "")); } // Rearrange names properly: - auth = h.get(FieldName.AUTHOR_FIELD); + auth = h.get(FieldName.AUTHOR); if (auth != null) { - h.put(FieldName.AUTHOR_FIELD, fixNames(auth)); + h.put(FieldName.AUTHOR, fixNames(auth)); } - auth = h.get(FieldName.EDITOR_FIELD); + auth = h.get(FieldName.EDITOR); if (auth != null) { - h.put(FieldName.EDITOR_FIELD, fixNames(auth)); + h.put(FieldName.EDITOR, fixNames(auth)); } // Set the entrytype properly: @@ -220,7 +220,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { // This means we have an "incollection" entry. entryType = "incollection"; // Move the "chaptertitle" to just "title": - h.put("title", h.remove("chaptertitle")); + h.put(FieldName.TITLE, h.remove("chaptertitle")); } BibEntry b = new BibEntry(IdGenerator.next(), entryType); b.setField(h); 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 7d0faa7a33eb..a575794277bc 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/PdfContentImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/PdfContentImporter.java @@ -390,7 +390,7 @@ public ParserResult importDatabase(Path filePath, Charset defaultEncoding) { if (DOI == null) { pos = curString.indexOf("DOI"); if (pos < 0) { - pos = curString.indexOf(FieldName.DOI_FIELD); + pos = curString.indexOf(FieldName.DOI); } if (pos >= 0) { pos += 3; @@ -443,25 +443,25 @@ public ParserResult importDatabase(Path filePath, Charset defaultEncoding) { // TODO: institution parsing missing if (author != null) { - entry.setField(FieldName.AUTHOR_FIELD, author); + entry.setField(FieldName.AUTHOR, author); } if (editor != null) { - entry.setField(FieldName.EDITOR_FIELD, editor); + entry.setField(FieldName.EDITOR, editor); } if (abstractT != null) { - entry.setField(FieldName.ABSTRACT_FIELD, abstractT); + entry.setField(FieldName.ABSTRACT, abstractT); } if (!Strings.isNullOrEmpty(keywords)) { entry.setField("keywords", keywords); } if (title != null) { - entry.setField("title", title); + entry.setField(FieldName.TITLE, title); } if (conference != null) { entry.setField("booktitle", conference); } if (DOI != null) { - entry.setField(FieldName.DOI_FIELD, DOI); + entry.setField(FieldName.DOI, DOI); } if (series != null) { entry.setField("series", series); @@ -473,10 +473,10 @@ public ParserResult importDatabase(Path filePath, Charset defaultEncoding) { entry.setField("number", number); } if (pages != null) { - entry.setField("pages", pages); + entry.setField(FieldName.PAGES, pages); } if (year != null) { - entry.setField(FieldName.YEAR_FIELD, year); + entry.setField(FieldName.YEAR, year); } if (publisher != null) { entry.setField("publisher", publisher); 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 dced1dde2da9..45a89a38f30c 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/RepecNepImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/RepecNepImporter.java @@ -256,7 +256,7 @@ private String readMultipleLines(BufferedReader in) throws IOException { private void parseTitleString(BibEntry be, BufferedReader in) throws IOException { // skip article number this.lastLine = this.lastLine.substring(this.lastLine.indexOf('.') + 1, this.lastLine.length()); - be.setField("title", readMultipleLines(in)); + be.setField(FieldName.TITLE, readMultipleLines(in)); } /** @@ -306,7 +306,7 @@ private void parseAuthors(BibEntry be, BufferedReader in) throws IOException { } if (!authors.isEmpty()) { - be.setField(FieldName.AUTHOR_FIELD, String.join(" and ", authors)); + be.setField(FieldName.AUTHOR, String.join(" and ", authors)); } if (institutions.length() > 0) { be.setField("institution", institutions.toString()); @@ -323,7 +323,7 @@ private void parseAbstract(BibEntry be, BufferedReader in) throws IOException { String theabstract = readMultipleLines(in); if (!"".equals(theabstract)) { - be.setField(FieldName.ABSTRACT_FIELD, theabstract); + be.setField(FieldName.ABSTRACT, theabstract); } } @@ -375,7 +375,7 @@ private void parseAdditionalFields(BibEntry be, boolean multilineUrlFieldAllowed Calendar cal = new GregorianCalendar(); cal.setTime(date == null ? new Date() : date); - be.setField(FieldName.YEAR_FIELD, String.valueOf(cal.get(Calendar.YEAR))); + 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)); } @@ -392,7 +392,7 @@ private void parseAdditionalFields(BibEntry be, boolean multilineUrlFieldAllowed content = this.lastLine; readLine(in); } - be.setField(FieldName.URL_FIELD, content); + be.setField(FieldName.URL, content); // authors field } else if (keyword.startsWith("By")) { 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 2f670b723421..e6be2fe94756 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/RisImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/RisImporter.java @@ -135,17 +135,17 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { type = "other"; } } else if ("T1".equals(lab) || "TI".equals(lab)) { - String oldVal = hm.get("title"); + String oldVal = hm.get(FieldName.TITLE); if (oldVal == null) { - hm.put("title", val); + hm.put(FieldName.TITLE, val); } else { if (oldVal.endsWith(":") || oldVal.endsWith(".") || oldVal.endsWith("?")) { - hm.put("title", oldVal + " " + val); + hm.put(FieldName.TITLE, oldVal + " " + val); } else { - hm.put("title", oldVal + ": " + val); + hm.put(FieldName.TITLE, oldVal + ": " + val); } } - hm.put("title", hm.get("title").replaceAll("\\s+", " ")); // Normalize whitespaces + hm.put(FieldName.TITLE, hm.get(FieldName.TITLE).replaceAll("\\s+", " ")); // Normalize whitespaces } else if ("T2".equals(lab) || "BT".equals(lab)) { hm.put("booktitle", val); } else if ("T3".equals(lab)) { @@ -184,23 +184,23 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { endPage = "--" + endPage; } } else if ("SN".equals(lab)) { - hm.put(FieldName.ISSN_FIELD, val); + hm.put(FieldName.ISSN, val); } else if ("VL".equals(lab)) { hm.put("volume", val); } else if ("IS".equals(lab)) { hm.put("number", val); } else if ("N2".equals(lab) || "AB".equals(lab)) { - String oldAb = hm.get(FieldName.ABSTRACT_FIELD); + String oldAb = hm.get(FieldName.ABSTRACT); if (oldAb == null) { - hm.put(FieldName.ABSTRACT_FIELD, val); + hm.put(FieldName.ABSTRACT, val); } else { - hm.put(FieldName.ABSTRACT_FIELD, oldAb + Globals.NEWLINE + val); + hm.put(FieldName.ABSTRACT, oldAb + Globals.NEWLINE + val); } } else if ("UR".equals(lab)) { - hm.put(FieldName.URL_FIELD, val); + hm.put(FieldName.URL, val); } else if (("Y1".equals(lab) || "PY".equals(lab)) && (val.length() >= 4)) { String[] parts = val.split("/"); - hm.put(FieldName.YEAR_FIELD, parts[0]); + hm.put(FieldName.YEAR, parts[0]); if ((parts.length > 1) && !parts[1].isEmpty()) { try { @@ -233,24 +233,24 @@ else if ("ID".equals(lab)) { String doi = val; if (doi.startsWith("doi:")) { doi = doi.replaceAll("(?i)doi:", "").trim(); - hm.put(FieldName.DOI_FIELD, doi); + hm.put(FieldName.DOI, doi); } } } // fix authors if (!author.isEmpty()) { author = AuthorList.fixAuthorLastNameFirst(author); - hm.put(FieldName.AUTHOR_FIELD, author); + hm.put(FieldName.AUTHOR, author); } if (!editor.isEmpty()) { editor = AuthorList.fixAuthorLastNameFirst(editor); - hm.put(FieldName.EDITOR_FIELD, editor); + hm.put(FieldName.EDITOR, editor); } if (!comment.isEmpty()) { hm.put("comment", comment); } - hm.put("pages", startPage + endPage); + hm.put(FieldName.PAGES, startPage + endPage); } BibEntry b = new BibEntry(DEFAULT_BIBTEXENTRY_ID, type); // id assumes an existing database so don't 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 21f0ebc1bd36..df8b0aa8e874 100644 --- a/src/main/java/net/sf/jabref/importer/fileformat/SilverPlatterImporter.java +++ b/src/main/java/net/sf/jabref/importer/fileformat/SilverPlatterImporter.java @@ -101,19 +101,19 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { String f3 = field.substring(0, 2); String frest = field.substring(5); if ("TI".equals(f3)) { - h.put("title", frest); + h.put(FieldName.TITLE, frest); } else if ("AU".equals(f3)) { if (frest.trim().endsWith("(ed)")) { String ed = frest.trim(); ed = ed.substring(0, ed.length() - 4); - h.put(FieldName.EDITOR_FIELD, + h.put(FieldName.EDITOR, AuthorList.fixAuthorLastNameFirst(ed.replace(",-", ", ").replace(";", " and "))); } else { - h.put(FieldName.AUTHOR_FIELD, + h.put(FieldName.AUTHOR, AuthorList.fixAuthorLastNameFirst(frest.replace(",-", ", ").replace(";", " and "))); } } else if ("AB".equals(f3)) { - h.put(FieldName.ABSTRACT_FIELD, frest); + h.put(FieldName.ABSTRACT, frest); } else if ("DE".equals(f3)) { String kw = frest.replace("-;", ",").toLowerCase(); h.put("keywords", kw.substring(0, kw.length() - 1)); @@ -126,14 +126,14 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { m = frest.indexOf(';'); if (m >= 5) { String yr = frest.substring(m - 5, m).trim(); - h.put(FieldName.YEAR_FIELD, yr); + h.put(FieldName.YEAR, yr); frest = frest.substring(m); m = frest.indexOf(':'); int issueIndex = frest.indexOf('('); int endIssueIndex = frest.indexOf(')'); if (m >= 0) { String pg = frest.substring(m + 1).trim(); - h.put("pages", pg); + h.put(FieldName.PAGES, pg); h.put("volume", frest.substring(1, issueIndex).trim()); h.put("issue", frest.substring(issueIndex + 1, endIssueIndex).trim()); } @@ -150,7 +150,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { String yr = frest.substring(m + 2).trim(); try { Integer.parseInt(yr); - h.put(FieldName.YEAR_FIELD, yr); + h.put(FieldName.YEAR, yr); } catch (NumberFormatException ex) { // Let's assume that this wasn't a number, since it // couldn't be parsed as an integer. @@ -182,12 +182,12 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } if (isChapter) { - Object titleO = h.get("title"); + Object titleO = h.get(FieldName.TITLE); if (titleO != null) { String title = ((String) titleO).trim(); int inPos = title.indexOf("\" in "); if (inPos > 1) { - h.put("title", title.substring(0, inPos)); + h.put(FieldName.TITLE, title.substring(0, inPos)); } } diff --git a/src/main/java/net/sf/jabref/logic/TypedBibEntry.java b/src/main/java/net/sf/jabref/logic/TypedBibEntry.java index 7ba671a25e74..e684e00d8998 100644 --- a/src/main/java/net/sf/jabref/logic/TypedBibEntry.java +++ b/src/main/java/net/sf/jabref/logic/TypedBibEntry.java @@ -88,7 +88,7 @@ public String getTypeForDisplay() { */ public List getFiles() { //Extract the path - Optional oldValue = entry.getFieldOptional(FieldName.FILE_FIELD); + Optional oldValue = entry.getFieldOptional(FieldName.FILE); if (!oldValue.isPresent()) { return new ArrayList<>(); } @@ -98,14 +98,14 @@ public List getFiles() { public Optional setFiles(List files) { - Optional oldValue = entry.getFieldOptional(FieldName.FILE_FIELD); + Optional oldValue = entry.getFieldOptional(FieldName.FILE); String newValue = FileField.getStringRepresentation(files); if(oldValue.isPresent() && oldValue.get().equals(newValue)) { return Optional.empty(); } - entry.setField(FieldName.FILE_FIELD, newValue); - return Optional.of(new FieldChange(entry, FieldName.FILE_FIELD, oldValue.orElse(""), newValue)); + entry.setField(FieldName.FILE, newValue); + return Optional.of(new FieldChange(entry, FieldName.FILE, oldValue.orElse(""), newValue)); } } 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 8c07d0a3c4b5..99e7ee6f5dc9 100644 --- a/src/main/java/net/sf/jabref/logic/autocompleter/AutoCompleterFactory.java +++ b/src/main/java/net/sf/jabref/logic/autocompleter/AutoCompleterFactory.java @@ -44,7 +44,7 @@ public AutoCompleter getFor(String fieldName) { if (InternalBibtexFields.getFieldExtras(fieldName).contains(FieldProperties.PERSON_NAMES)) { return new NameFieldAutoCompleter(fieldName, preferences); - } else if ("crossref".equals(fieldName)) { + } else if (FieldName.CROSSREF.equals(fieldName)) { return new BibtexKeyAutoCompleter(preferences); } else if ("journal".equals(fieldName) || "publisher".equals(fieldName)) { return new JournalAutoCompleter(fieldName, preferences, abbreviationLoader); @@ -54,7 +54,7 @@ public AutoCompleter getFor(String fieldName) { } public AutoCompleter getPersonAutoCompleter() { - return new NameFieldAutoCompleter(Arrays.asList(FieldName.AUTHOR_FIELD, FieldName.EDITOR_FIELD), true, preferences); + return new NameFieldAutoCompleter(Arrays.asList(FieldName.AUTHOR, FieldName.EDITOR), true, preferences); } } diff --git a/src/main/java/net/sf/jabref/logic/auxparser/AuxParser.java b/src/main/java/net/sf/jabref/logic/auxparser/AuxParser.java index 0c3778fe4d81..f59a8774734d 100644 --- a/src/main/java/net/sf/jabref/logic/auxparser/AuxParser.java +++ b/src/main/java/net/sf/jabref/logic/auxparser/AuxParser.java @@ -14,6 +14,7 @@ import net.sf.jabref.model.database.BibDatabase; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.FieldName; import net.sf.jabref.model.entry.IdGenerator; import org.apache.commons.logging.Log; @@ -148,7 +149,7 @@ private void resolveTags(AuxParserResult result) { * Resolves and adds CrossRef entries */ private void resolveCrossReferences(BibEntry entry, AuxParserResult result) { - entry.getFieldOptional("crossref").ifPresent(crossref -> { + entry.getFieldOptional(FieldName.CROSSREF).ifPresent(crossref -> { if (!result.getUniqueKeys().contains(crossref)) { Optional refEntry = masterDatabase.getEntryByKey(crossref); diff --git a/src/main/java/net/sf/jabref/logic/bibtex/FieldContentParser.java b/src/main/java/net/sf/jabref/logic/bibtex/FieldContentParser.java index d3928b8fe242..982c6049789a 100644 --- a/src/main/java/net/sf/jabref/logic/bibtex/FieldContentParser.java +++ b/src/main/java/net/sf/jabref/logic/bibtex/FieldContentParser.java @@ -36,8 +36,8 @@ public class FieldContentParser { public FieldContentParser(FieldContentParserPreferences prefs) { multiLineFields = new HashSet<>(); // the following two are also coded in net.sf.jabref.logic.bibtex.LatexFieldFormatter.format(String, String) - multiLineFields.add(FieldName.ABSTRACT_FIELD); - multiLineFields.add(FieldName.REVIEW_FIELD); + multiLineFields.add(FieldName.ABSTRACT); + multiLineFields.add(FieldName.REVIEW); // the file field should not be formatted, therefore we treat it as a multi line field multiLineFields.addAll(prefs.getNonWrappableFields()); } diff --git a/src/main/java/net/sf/jabref/logic/bibtex/comparator/CrossRefEntryComparator.java b/src/main/java/net/sf/jabref/logic/bibtex/comparator/CrossRefEntryComparator.java index bc7ecb4c35b3..8b1880914487 100644 --- a/src/main/java/net/sf/jabref/logic/bibtex/comparator/CrossRefEntryComparator.java +++ b/src/main/java/net/sf/jabref/logic/bibtex/comparator/CrossRefEntryComparator.java @@ -18,6 +18,7 @@ import java.util.Comparator; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.FieldName; /** * Compares Bibtex entries based on their 'crossref' fields. Entries including @@ -27,14 +28,11 @@ */ public class CrossRefEntryComparator implements Comparator { - private static final String CROSS_REF_FIELD = "crossref"; - - @Override public int compare(BibEntry e1, BibEntry e2) { - Boolean b1 = e1.hasField(CrossRefEntryComparator.CROSS_REF_FIELD); - Boolean b2 = e2.hasField(CrossRefEntryComparator.CROSS_REF_FIELD); + Boolean b1 = e1.hasField(FieldName.CROSSREF); + Boolean b2 = e2.hasField(FieldName.CROSSREF); if ((!b1) && (!b2)) { return 0; // secComparator.compare(e1, e2); 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 4201ccbcf0a6..da2cfd9efc1a 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 @@ -99,7 +99,7 @@ private FieldType determineFieldType() { return FieldType.TYPE; } else if (InternalBibtexFields.getFieldExtras(this.field[0]).contains(FieldProperties.PERSON_NAMES)) { return FieldType.NAME; - } else if (FieldName.YEAR_FIELD.equals(this.field[0])) { + } else if (FieldName.YEAR.equals(this.field[0])) { return FieldType.YEAR; } else if("month".equals(this.field[0])) { return FieldType.MONTH; diff --git a/src/main/java/net/sf/jabref/logic/bst/VM.java b/src/main/java/net/sf/jabref/logic/bst/VM.java index a5722551a461..ee4ad7303b21 100644 --- a/src/main/java/net/sf/jabref/logic/bst/VM.java +++ b/src/main/java/net/sf/jabref/logic/bst/VM.java @@ -31,6 +31,7 @@ import net.sf.jabref.model.database.BibDatabase; import net.sf.jabref.model.entry.AuthorList; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.FieldName; import org.antlr.runtime.ANTLRFileStream; import org.antlr.runtime.ANTLRStringStream; @@ -940,8 +941,8 @@ private void read() { } for (BstEntry e : entries) { - if (!e.getFields().containsKey("crossref")) { - e.getFields().put("crossref", null); + if (!e.getFields().containsKey(FieldName.CROSSREF)) { + e.getFields().put(FieldName.CROSSREF, null); } } } 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 969034eee861..1cb4cf083e42 100644 --- a/src/main/java/net/sf/jabref/logic/cleanup/BiblatexCleanup.java +++ b/src/main/java/net/sf/jabref/logic/cleanup/BiblatexCleanup.java @@ -48,18 +48,18 @@ public List cleanup(BibEntry entry) { } // Dates: create date out of year and month, save it and delete old fields - entry.getFieldOptional(FieldName.DATE_FIELD).ifPresent(date -> { + entry.getFieldOptional(FieldName.DATE).ifPresent(date -> { if (date.isEmpty()) { - entry.getFieldOrAlias(FieldName.DATE_FIELD).ifPresent(newDate -> { - Optional oldYear = entry.getFieldOptional(FieldName.YEAR_FIELD); + entry.getFieldOrAlias(FieldName.DATE).ifPresent(newDate -> { + Optional oldYear = entry.getFieldOptional(FieldName.YEAR); Optional oldMonth = entry.getFieldOptional("month"); - entry.setField(FieldName.DATE_FIELD, newDate); - entry.clearField(FieldName.YEAR_FIELD); + entry.setField(FieldName.DATE, newDate); + entry.clearField(FieldName.YEAR); entry.clearField("month"); - changes.add(new FieldChange(entry, FieldName.DATE_FIELD, null, newDate)); - changes.add(new FieldChange(entry, FieldName.YEAR_FIELD, oldYear.orElse(null), null)); + 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)); }); } diff --git a/src/main/java/net/sf/jabref/logic/cleanup/DoiCleanup.java b/src/main/java/net/sf/jabref/logic/cleanup/DoiCleanup.java index faade81eefda..98004464d4b4 100644 --- a/src/main/java/net/sf/jabref/logic/cleanup/DoiCleanup.java +++ b/src/main/java/net/sf/jabref/logic/cleanup/DoiCleanup.java @@ -32,7 +32,7 @@ public class DoiCleanup implements CleanupJob { /** * Fields to check for DOIs. */ - private static final String[] FIELDS = {"note", FieldName.URL_FIELD, "ee"}; + private static final String[] FIELDS = {"note", FieldName.URL, "ee"}; @Override public List cleanup(BibEntry entry) { @@ -40,17 +40,17 @@ public List cleanup(BibEntry entry) { List changes = new ArrayList<>(); // First check if the Doi Field is empty - if (entry.hasField(FieldName.DOI_FIELD)) { - String doiFieldValue = entry.getField(FieldName.DOI_FIELD); + if (entry.hasField(FieldName.DOI)) { + String doiFieldValue = entry.getField(FieldName.DOI); Optional doi = DOI.build(doiFieldValue); if (doi.isPresent()) { String newValue = doi.get().getDOI(); if (!doiFieldValue.equals(newValue)) { - entry.setField(FieldName.DOI_FIELD, newValue); + entry.setField(FieldName.DOI, newValue); - FieldChange change = new FieldChange(entry, FieldName.DOI_FIELD, doiFieldValue, newValue); + FieldChange change = new FieldChange(entry, FieldName.DOI, doiFieldValue, newValue); changes.add(change); } @@ -66,12 +66,12 @@ public List cleanup(BibEntry entry) { if (doi.isPresent()) { // update Doi - String oldValue = entry.getField(FieldName.DOI_FIELD); + String oldValue = entry.getField(FieldName.DOI); String newValue = doi.get().getDOI(); - entry.setField(FieldName.DOI_FIELD, newValue); + entry.setField(FieldName.DOI, newValue); - FieldChange change = new FieldChange(entry, FieldName.DOI_FIELD, oldValue, newValue); + FieldChange change = new FieldChange(entry, FieldName.DOI, oldValue, newValue); changes.add(change); removeFieldValue(entry, field, changes); diff --git a/src/main/java/net/sf/jabref/logic/cleanup/FileLinksCleanup.java b/src/main/java/net/sf/jabref/logic/cleanup/FileLinksCleanup.java index 5acbe991dd3b..91737e907591 100644 --- a/src/main/java/net/sf/jabref/logic/cleanup/FileLinksCleanup.java +++ b/src/main/java/net/sf/jabref/logic/cleanup/FileLinksCleanup.java @@ -30,7 +30,7 @@ public class FileLinksCleanup implements CleanupJob { @Override public List cleanup(BibEntry entry) { - Optional oldValue = entry.getFieldOptional(FieldName.FILE_FIELD); + Optional oldValue = entry.getFieldOptional(FieldName.FILE); if (!oldValue.isPresent()) { return Collections.emptyList(); } @@ -40,8 +40,8 @@ public List cleanup(BibEntry entry) { // Parsing automatically moves a single description to link, so we just need to write the fileList back again String newValue = FileField.getStringRepresentation(fileList); if (!oldValue.get().equals(newValue)) { - entry.setField(FieldName.FILE_FIELD, newValue); - FieldChange change = new FieldChange(entry, FieldName.FILE_FIELD, oldValue.get(), newValue); + entry.setField(FieldName.FILE, newValue); + FieldChange change = new FieldChange(entry, FieldName.FILE, oldValue.get(), newValue); return Collections.singletonList(change); } return Collections.emptyList(); diff --git a/src/main/java/net/sf/jabref/logic/cleanup/UpgradePdfPsToFileCleanup.java b/src/main/java/net/sf/jabref/logic/cleanup/UpgradePdfPsToFileCleanup.java index bf17c1d607fa..9600af247cf2 100644 --- a/src/main/java/net/sf/jabref/logic/cleanup/UpgradePdfPsToFileCleanup.java +++ b/src/main/java/net/sf/jabref/logic/cleanup/UpgradePdfPsToFileCleanup.java @@ -42,7 +42,7 @@ public List cleanup(BibEntry entry) { List changes = new ArrayList<>(); // If there are already links in the file field, keep those on top: - String oldFileContent = entry.getField(FieldName.FILE_FIELD); + String oldFileContent = entry.getField(FieldName.FILE); List fileList = new ArrayList<>(FileField.parse(oldFileContent)); int oldItemCount = fileList.size(); @@ -63,8 +63,8 @@ public List cleanup(BibEntry entry) { if (fileList.size() != oldItemCount) { String newValue = FileField.getStringRepresentation(fileList); - entry.setField(FieldName.FILE_FIELD, newValue); - changes.add(new FieldChange(entry, FieldName.FILE_FIELD, oldFileContent, newValue)); + entry.setField(FieldName.FILE, newValue); + changes.add(new FieldChange(entry, FieldName.FILE, oldFileContent, newValue)); } return changes; 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 2b18076d37eb..1842d31b78b2 100644 --- a/src/main/java/net/sf/jabref/logic/exporter/FieldFormatterCleanups.java +++ b/src/main/java/net/sf/jabref/logic/exporter/FieldFormatterCleanups.java @@ -19,6 +19,7 @@ import net.sf.jabref.logic.util.strings.StringUtil; import net.sf.jabref.model.FieldChange; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.FieldName; public class FieldFormatterCleanups { @@ -26,7 +27,7 @@ public class FieldFormatterCleanups { private static List availableFormatters; - private boolean enabled; + private final boolean enabled; public static final FieldFormatterCleanups DEFAULT_SAVE_ACTIONS; @@ -35,7 +36,7 @@ public class FieldFormatterCleanups { availableFormatters.addAll(Formatters.ALL); List defaultFormatters = new ArrayList<>(); - defaultFormatters.add(new FieldFormatterCleanup("pages", new NormalizePagesFormatter())); + defaultFormatters.add(new FieldFormatterCleanup(FieldName.PAGES, new NormalizePagesFormatter())); defaultFormatters.add(new FieldFormatterCleanup("month", new NormalizeMonthFormatter())); defaultFormatters.add(new FieldFormatterCleanup("booktitle", new OrdinalsToSuperscriptFormatter())); DEFAULT_SAVE_ACTIONS = new FieldFormatterCleanups(false, defaultFormatters); @@ -214,7 +215,7 @@ public List getAsStringList() { public static FieldFormatterCleanups parse(List formatterMetaList) { - if (formatterMetaList != null && formatterMetaList.size() >= 2) { + if ((formatterMetaList != null) && (formatterMetaList.size() >= 2)) { boolean enablementStatus = "enabled".equals(formatterMetaList.get(0)); String formatterString = formatterMetaList.get(1); return new FieldFormatterCleanups(enablementStatus, formatterString); 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 8e328e342396..c8006ecb0e8c 100644 --- a/src/main/java/net/sf/jabref/logic/exporter/OOCalcDatabase.java +++ b/src/main/java/net/sf/jabref/logic/exporter/OOCalcDatabase.java @@ -52,8 +52,8 @@ class OOCalcDatabase { public OOCalcDatabase(BibDatabase bibtex, List entries) { // Make a list of comparators for sorting the entries: List comparators = new ArrayList<>(); - comparators.add(new FieldComparator(FieldName.AUTHOR_FIELD)); - comparators.add(new FieldComparator(FieldName.YEAR_FIELD)); + comparators.add(new FieldComparator(FieldName.AUTHOR)); + comparators.add(new FieldComparator(FieldName.YEAR)); comparators.add(new FieldComparator(BibEntry.KEY_FIELD)); // Use glazed lists to get a sorted view of the entries: List entryList = new ArrayList<>(); @@ -156,24 +156,24 @@ public Document getDOMrepresentation() { for (BibEntry e : entries) { row = result.createElement("table:table-row"); addTableCell(result, row, new GetOpenOfficeType().format(e.getType())); - addTableCell(result, row, getField(e, FieldName.ISBN_FIELD)); + addTableCell(result, row, getField(e, FieldName.ISBN)); addTableCell(result, row, getField(e, BibEntry.KEY_FIELD)); - addTableCell(result, row, getField(e, FieldName.AUTHOR_FIELD));//new AuthorLastFirst().format(getField(e, FieldName.AUTHOR_FIELD))); - addTableCell(result, row, new RemoveWhitespace().format(new RemoveBrackets().format(getField(e, "title")))); + 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, "pages")); - addTableCell(result, row, getField(e, FieldName.YEAR_FIELD)); + addTableCell(result, row, getField(e, FieldName.PAGES)); + addTableCell(result, row, getField(e, FieldName.YEAR)); addTableCell(result, row, getField(e, "address")); addTableCell(result, row, getField(e, "note")); - addTableCell(result, row, getField(e, FieldName.URL_FIELD)); + addTableCell(result, row, getField(e, FieldName.URL)); addTableCell(result, row, getField(e, "booktitle")); addTableCell(result, row, getField(e, "chapter")); addTableCell(result, row, getField(e, "edition")); addTableCell(result, row, getField(e, "series")); - addTableCell(result, row, getField(e, FieldName.EDITOR_FIELD));//new AuthorLastFirst().format(getField(e, FieldName.EDITOR_FIELD))); + 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, "reporttype")); addTableCell(result, row, getField(e, "howpublished")); 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 3d67aa009066..c3bce641dde9 100644 --- a/src/main/java/net/sf/jabref/logic/exporter/OpenDocumentRepresentation.java +++ b/src/main/java/net/sf/jabref/logic/exporter/OpenDocumentRepresentation.java @@ -54,8 +54,8 @@ public OpenDocumentRepresentation(BibDatabase database, List entries) this.database = database; // Make a list of comparators for sorting the entries: List comparators = new ArrayList<>(); - comparators.add(new FieldComparator(FieldName.AUTHOR_FIELD)); - comparators.add(new FieldComparator(FieldName.YEAR_FIELD)); + comparators.add(new FieldComparator(FieldName.AUTHOR)); + comparators.add(new FieldComparator(FieldName.YEAR)); comparators.add(new FieldComparator(BibEntry.KEY_FIELD)); // Use glazed lists to get a sorted view of the entries: List entryList = new ArrayList<>(); @@ -165,13 +165,13 @@ public Document getDOMrepresentation() { addTableCell(result, row, getField(e, "address")); addTableCell(result, row, getField(e, "assignee")); addTableCell(result, row, getField(e, "annote")); - addTableCell(result, row, getField(e, FieldName.AUTHOR_FIELD));//new AuthorLastFirst().format(getField(e, FieldName.AUTHOR_FIELD))); + addTableCell(result, row, getField(e, FieldName.AUTHOR));//new AuthorLastFirst().format(getField(e, FieldName.AUTHOR_FIELD))); addTableCell(result, row, getField(e, "booktitle")); addTableCell(result, row, getField(e, "chapter")); addTableCell(result, row, getField(e, "day")); addTableCell(result, row, getField(e, "dayfiled")); addTableCell(result, row, getField(e, "edition")); - addTableCell(result, row, getField(e, FieldName.EDITOR_FIELD));//new AuthorLastFirst().format(getField(e, FieldName.EDITOR_FIELD))); + 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")); @@ -182,23 +182,23 @@ public Document getDOMrepresentation() { addTableCell(result, row, getField(e, "note")); addTableCell(result, row, getField(e, "number")); addTableCell(result, row, getField(e, "organization")); - addTableCell(result, row, getField(e, "pages")); + addTableCell(result, row, getField(e, FieldName.PAGES)); addTableCell(result, row, getField(e, "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, "title")))); + 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.YEAR_FIELD)); + addTableCell(result, row, getField(e, FieldName.YEAR)); addTableCell(result, row, getField(e, "yearfiled")); - addTableCell(result, row, getField(e, FieldName.URL_FIELD)); + addTableCell(result, row, getField(e, FieldName.URL)); addTableCell(result, row, ""); addTableCell(result, row, ""); addTableCell(result, row, ""); addTableCell(result, row, ""); addTableCell(result, row, ""); - addTableCell(result, row, getField(e, FieldName.ISBN_FIELD)); + addTableCell(result, row, getField(e, FieldName.ISBN)); table.appendChild(row); } diff --git a/src/main/java/net/sf/jabref/logic/fulltext/ACS.java b/src/main/java/net/sf/jabref/logic/fulltext/ACS.java index eae51c3ac6e4..97c8ad144227 100644 --- a/src/main/java/net/sf/jabref/logic/fulltext/ACS.java +++ b/src/main/java/net/sf/jabref/logic/fulltext/ACS.java @@ -39,7 +39,7 @@ public Optional findFullText(BibEntry entry) throws IOException { Optional pdfLink = Optional.empty(); // DOI search - Optional doi = entry.getFieldOptional(FieldName.DOI_FIELD).flatMap(DOI::build); + Optional doi = entry.getFieldOptional(FieldName.DOI).flatMap(DOI::build); if(doi.isPresent()) { String source = String.format(SOURCE, doi.get().getDOI()); diff --git a/src/main/java/net/sf/jabref/logic/fulltext/ArXiv.java b/src/main/java/net/sf/jabref/logic/fulltext/ArXiv.java index d9c444a0b5f4..6532c0a3930c 100644 --- a/src/main/java/net/sf/jabref/logic/fulltext/ArXiv.java +++ b/src/main/java/net/sf/jabref/logic/fulltext/ArXiv.java @@ -41,7 +41,7 @@ public Optional findFullText(BibEntry entry) throws IOException { Optional pdfLink = Optional.empty(); // 1. DOI - Optional doi = entry.getFieldOptional(FieldName.DOI_FIELD).flatMap(DOI::build); + Optional doi = entry.getFieldOptional(FieldName.DOI).flatMap(DOI::build); // 2. Eprint Optional eprint = entry.getFieldOptional("eprint"); diff --git a/src/main/java/net/sf/jabref/logic/fulltext/DoiResolution.java b/src/main/java/net/sf/jabref/logic/fulltext/DoiResolution.java index c2278cc83b5f..d0ffe6af655f 100644 --- a/src/main/java/net/sf/jabref/logic/fulltext/DoiResolution.java +++ b/src/main/java/net/sf/jabref/logic/fulltext/DoiResolution.java @@ -45,7 +45,7 @@ public Optional findFullText(BibEntry entry) throws IOException { Objects.requireNonNull(entry); Optional pdfLink = Optional.empty(); - Optional doi = entry.getFieldOptional(FieldName.DOI_FIELD).flatMap(DOI::build); + Optional doi = entry.getFieldOptional(FieldName.DOI).flatMap(DOI::build); if(doi.isPresent()) { String sciLink = doi.get().getURIAsASCIIString(); diff --git a/src/main/java/net/sf/jabref/logic/fulltext/FindFullText.java b/src/main/java/net/sf/jabref/logic/fulltext/FindFullText.java index 00bb3bc3bd35..cf9672676e3b 100644 --- a/src/main/java/net/sf/jabref/logic/fulltext/FindFullText.java +++ b/src/main/java/net/sf/jabref/logic/fulltext/FindFullText.java @@ -42,10 +42,10 @@ public FindFullText(List fetcher) { public Optional findFullTextPDF(BibEntry entry) { // for accuracy, fetch DOI first but do not modify entry BibEntry clonedEntry = (BibEntry) entry.clone(); - Optional doi = clonedEntry.getFieldOptional(FieldName.DOI_FIELD); + Optional doi = clonedEntry.getFieldOptional(FieldName.DOI); if (!doi.isPresent() || !DOI.build(doi.get()).isPresent()) { - CrossRef.findDOI(clonedEntry).ifPresent(e -> clonedEntry.setField(FieldName.DOI_FIELD, e.getDOI())); + CrossRef.findDOI(clonedEntry).ifPresent(e -> clonedEntry.setField(FieldName.DOI, e.getDOI())); } for (FullTextFinder finder : finders) { diff --git a/src/main/java/net/sf/jabref/logic/fulltext/GoogleScholar.java b/src/main/java/net/sf/jabref/logic/fulltext/GoogleScholar.java index 4ca6152fbfec..a3a2647b2123 100644 --- a/src/main/java/net/sf/jabref/logic/fulltext/GoogleScholar.java +++ b/src/main/java/net/sf/jabref/logic/fulltext/GoogleScholar.java @@ -8,6 +8,7 @@ import java.util.Optional; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.FieldName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -30,12 +31,12 @@ public Optional findFullText(BibEntry entry) throws IOException { Optional pdfLink = Optional.empty(); // Search in title - if (!entry.hasField("title")) { + if (!entry.hasField(FieldName.TITLE)) { return pdfLink; } String url = String.format(SEARCH_URL, - URLEncoder.encode(entry.getFieldOptional("title").orElse(null), StandardCharsets.UTF_8.name())); + URLEncoder.encode(entry.getFieldOptional(FieldName.TITLE).orElse(null), StandardCharsets.UTF_8.name())); Document doc = Jsoup.connect(url) .userAgent("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0") // don't identify as a crawler diff --git a/src/main/java/net/sf/jabref/logic/fulltext/IEEE.java b/src/main/java/net/sf/jabref/logic/fulltext/IEEE.java index f79772753868..b4262d9730a6 100644 --- a/src/main/java/net/sf/jabref/logic/fulltext/IEEE.java +++ b/src/main/java/net/sf/jabref/logic/fulltext/IEEE.java @@ -37,7 +37,7 @@ public Optional findFullText(BibEntry entry) throws IOException { String stampString = ""; // Try URL first -- will primarily work for entries from the old IEEE search - Optional urlString = entry.getFieldOptional(FieldName.URL_FIELD); + Optional urlString = entry.getFieldOptional(FieldName.URL); if (urlString.isPresent()) { // Is the URL a direct link to IEEE? Matcher matcher = STAMP_PATTERN.matcher(urlString.get()); @@ -49,7 +49,7 @@ public Optional findFullText(BibEntry entry) throws IOException { // If not, try DOI if (stampString.isEmpty()) { - Optional doi = entry.getFieldOptional(FieldName.DOI_FIELD).flatMap(DOI::build); + Optional doi = entry.getFieldOptional(FieldName.DOI).flatMap(DOI::build); if (doi.isPresent() && doi.get().getDOI().startsWith(IEEE_DOI) && doi.get().getURI().isPresent()) { // Download the HTML page from IEEE String resolvedDOIPage = new URLDownload(doi.get().getURI().get().toURL()) diff --git a/src/main/java/net/sf/jabref/logic/fulltext/ScienceDirect.java b/src/main/java/net/sf/jabref/logic/fulltext/ScienceDirect.java index 569298fa5f5a..a7036577859c 100644 --- a/src/main/java/net/sf/jabref/logic/fulltext/ScienceDirect.java +++ b/src/main/java/net/sf/jabref/logic/fulltext/ScienceDirect.java @@ -53,7 +53,7 @@ public Optional findFullText(BibEntry entry) throws IOException { Optional pdfLink = Optional.empty(); // Try unique DOI first - Optional doi = entry.getFieldOptional(FieldName.DOI_FIELD).flatMap(DOI::build); + Optional doi = entry.getFieldOptional(FieldName.DOI).flatMap(DOI::build); if(doi.isPresent()) { // Available in catalog? diff --git a/src/main/java/net/sf/jabref/logic/fulltext/SpringerLink.java b/src/main/java/net/sf/jabref/logic/fulltext/SpringerLink.java index 48d683030238..4136bd469fde 100644 --- a/src/main/java/net/sf/jabref/logic/fulltext/SpringerLink.java +++ b/src/main/java/net/sf/jabref/logic/fulltext/SpringerLink.java @@ -50,7 +50,7 @@ public Optional findFullText(BibEntry entry) throws IOException { Optional pdfLink = Optional.empty(); // Try unique DOI first - Optional doi = entry.getFieldOptional(FieldName.DOI_FIELD).flatMap(DOI::build); + Optional doi = entry.getFieldOptional(FieldName.DOI).flatMap(DOI::build); if(doi.isPresent()) { // Available in catalog? diff --git a/src/main/java/net/sf/jabref/logic/integrity/ISBNChecker.java b/src/main/java/net/sf/jabref/logic/integrity/ISBNChecker.java index 44cbd4fe8f8c..81642f3a570d 100644 --- a/src/main/java/net/sf/jabref/logic/integrity/ISBNChecker.java +++ b/src/main/java/net/sf/jabref/logic/integrity/ISBNChecker.java @@ -15,21 +15,21 @@ public class ISBNChecker implements Checker { @Override public List check(BibEntry entry) { - if (!entry.hasField(FieldName.ISBN_FIELD)) { + if (!entry.hasField(FieldName.ISBN)) { return Collections.emptyList(); } // Check that the ISBN is on the correct form - ISBN isbn = new ISBN(entry.getFieldOptional(FieldName.ISBN_FIELD).get()); + ISBN isbn = new ISBN(entry.getFieldOptional(FieldName.ISBN).get()); if (!isbn.isValidFormat()) { return Collections.singletonList( - new IntegrityMessage(Localization.lang("incorrect format"), entry, FieldName.ISBN_FIELD)); + new IntegrityMessage(Localization.lang("incorrect format"), entry, FieldName.ISBN)); } if (!isbn.isValidChecksum()) { return Collections - .singletonList(new IntegrityMessage(Localization.lang("incorrect control digit"), entry, FieldName.ISBN_FIELD)); + .singletonList(new IntegrityMessage(Localization.lang("incorrect control digit"), entry, FieldName.ISBN)); } return Collections.emptyList(); diff --git a/src/main/java/net/sf/jabref/logic/integrity/ISSNChecker.java b/src/main/java/net/sf/jabref/logic/integrity/ISSNChecker.java index c4b2ab79a241..d08cc2f49440 100644 --- a/src/main/java/net/sf/jabref/logic/integrity/ISSNChecker.java +++ b/src/main/java/net/sf/jabref/logic/integrity/ISSNChecker.java @@ -17,16 +17,16 @@ public class ISSNChecker implements Checker { @Override public List check(BibEntry entry) { - if (!entry.hasField(FieldName.ISSN_FIELD)) { + if (!entry.hasField(FieldName.ISSN)) { return Collections.emptyList(); } // Check that the ISSN is on the correct form - String issn = entry.getFieldOptional(FieldName.ISSN_FIELD).get().trim(); + String issn = entry.getFieldOptional(FieldName.ISSN).get().trim(); Matcher issnMatcher = ISSN_PATTERN.matcher(issn); if (!issnMatcher.matches()) { return Collections.singletonList( - new IntegrityMessage(Localization.lang("incorrect format"), entry, FieldName.ISSN_FIELD)); + new IntegrityMessage(Localization.lang("incorrect format"), entry, FieldName.ISSN)); } // Check that the control digit is correct, see e.g. https://en.wikipedia.org/wiki/International_Standard_Serial_Number @@ -45,7 +45,7 @@ public List check(BibEntry entry) { return Collections.emptyList(); } else { return Collections - .singletonList(new IntegrityMessage(Localization.lang("incorrect control digit"), entry, FieldName.ISSN_FIELD)); + .singletonList(new IntegrityMessage(Localization.lang("incorrect control digit"), entry, FieldName.ISSN)); } } 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 361005f63aba..0db5f4eb4954 100644 --- a/src/main/java/net/sf/jabref/logic/integrity/IntegrityCheck.java +++ b/src/main/java/net/sf/jabref/logic/integrity/IntegrityCheck.java @@ -57,7 +57,7 @@ private List checkBibtexEntry(BibEntry entry) { result.addAll(new BiblatexPagesChecker().check(entry)); } - result.addAll(new BracketChecker("title").check(entry)); + result.addAll(new BracketChecker(FieldName.TITLE).check(entry)); result.addAll(new YearChecker().check(entry)); result.addAll(new UrlChecker().check(entry)); result.addAll(new FileChecker(bibDatabaseContext).check(entry)); @@ -83,13 +83,13 @@ private static class TypeChecker implements Checker { @Override public List check(BibEntry entry) { - Optional value = entry.getFieldOptional("pages"); + Optional value = entry.getFieldOptional(FieldName.PAGES); if (!value.isPresent()) { return Collections.emptyList(); } if ("proceedings".equalsIgnoreCase(entry.getType())) { - return Collections.singletonList(new IntegrityMessage(Localization.lang("wrong entry type as proceedings has page numbers"), entry, "pages")); + return Collections.singletonList(new IntegrityMessage(Localization.lang("wrong entry type as proceedings has page numbers"), entry, FieldName.PAGES)); } return Collections.emptyList(); @@ -147,7 +147,7 @@ private FileChecker(BibDatabaseContext context) { @Override public List check(BibEntry entry) { - Optional value = entry.getFieldOptional(FieldName.FILE_FIELD); + Optional value = entry.getFieldOptional(FieldName.FILE); if (!value.isPresent()) { return Collections.emptyList(); } @@ -161,7 +161,7 @@ public List check(BibEntry entry) { if ((!file.isPresent()) || !file.get().exists()) { return Collections.singletonList( new IntegrityMessage(Localization.lang("link should refer to a correct file path"), entry, - FieldName.FILE_FIELD)); + FieldName.FILE)); } } @@ -173,13 +173,13 @@ private static class UrlChecker implements Checker { @Override public List check(BibEntry entry) { - Optional value = entry.getFieldOptional(FieldName.URL_FIELD); + Optional value = entry.getFieldOptional(FieldName.URL); if (!value.isPresent()) { return Collections.emptyList(); } if (!value.get().contains("://")) { - return Collections.singletonList(new IntegrityMessage(Localization.lang("should contain a protocol") + ": http[s]://, file://, ftp://, ...", entry, FieldName.URL_FIELD)); + return Collections.singletonList(new IntegrityMessage(Localization.lang("should contain a protocol") + ": http[s]://, file://, ftp://, ...", entry, FieldName.URL)); } return Collections.emptyList(); @@ -255,7 +255,7 @@ private static class TitleChecker implements Checker { @Override public List check(BibEntry entry) { - Optional value = entry.getFieldOptional("title"); + Optional value = entry.getFieldOptional(FieldName.TITLE); if (!value.isPresent()) { return Collections.emptyList(); } @@ -282,7 +282,7 @@ public List check(BibEntry entry) { boolean hasCapitalLettersThatBibtexWillConvertToSmallerOnes = HAS_CAPITAL_LETTERS.test(valueOnlySpacesWithinCurlyBraces); if (hasCapitalLettersThatBibtexWillConvertToSmallerOnes) { - return Collections.singletonList(new IntegrityMessage(Localization.lang("large capitals are not masked using curly brackets {}"), entry, "title")); + return Collections.singletonList(new IntegrityMessage(Localization.lang("large capitals are not masked using curly brackets {}"), entry, FieldName.TITLE)); } return Collections.emptyList(); @@ -298,13 +298,13 @@ private static class YearChecker implements Checker { */ @Override public List check(BibEntry entry) { - Optional value = entry.getFieldOptional(FieldName.YEAR_FIELD); + Optional value = entry.getFieldOptional(FieldName.YEAR); if (!value.isPresent()) { return Collections.emptyList(); } if (!CONTAINS_FOUR_DIGIT.test(value.get().trim())) { - return Collections.singletonList(new IntegrityMessage(Localization.lang("should contain a four digit number"), entry, FieldName.YEAR_FIELD)); + return Collections.singletonList(new IntegrityMessage(Localization.lang("should contain a four digit number"), entry, FieldName.YEAR)); } return Collections.emptyList(); @@ -339,13 +339,13 @@ private static class PagesChecker implements Checker { */ @Override public List check(BibEntry entry) { - Optional value = entry.getFieldOptional("pages"); + Optional value = entry.getFieldOptional(FieldName.PAGES); if (!value.isPresent()) { return Collections.emptyList(); } if (!VALID_PAGE_NUMBER.test(value.get().trim())) { - return Collections.singletonList(new IntegrityMessage(Localization.lang("should contain a valid page number range"), entry, "pages")); + return Collections.singletonList(new IntegrityMessage(Localization.lang("should contain a valid page number range"), entry, FieldName.PAGES)); } return Collections.emptyList(); @@ -376,13 +376,13 @@ private static class BiblatexPagesChecker implements Checker { */ @Override public List check(BibEntry entry) { - Optional value = entry.getFieldOptional("pages"); + Optional value = entry.getFieldOptional(FieldName.PAGES); if (!value.isPresent()) { return Collections.emptyList(); } if (!VALID_PAGE_NUMBER.test(value.get().trim())) { - return Collections.singletonList(new IntegrityMessage(Localization.lang("should contain a valid page number range"), entry, "pages")); + return Collections.singletonList(new IntegrityMessage(Localization.lang("should contain a valid page number range"), entry, FieldName.PAGES)); } return Collections.emptyList(); @@ -404,7 +404,7 @@ public List check(BibEntry entry) { Map fields = entry.getFieldMap(); // the url field should not be checked for hashes, as they are legal in this field - fields.remove(FieldName.URL_FIELD); + fields.remove(FieldName.URL); for (Map.Entry field : fields.entrySet()) { Matcher hashMatcher = UNESCAPED_HASH.matcher(field.getValue()); diff --git a/src/main/java/net/sf/jabref/logic/labelpattern/LabelPatternUtil.java b/src/main/java/net/sf/jabref/logic/labelpattern/LabelPatternUtil.java index 325151bda6ba..88467cb77f43 100644 --- a/src/main/java/net/sf/jabref/logic/labelpattern/LabelPatternUtil.java +++ b/src/main/java/net/sf/jabref/logic/labelpattern/LabelPatternUtil.java @@ -603,7 +603,7 @@ public static String makeLabel(BibEntry entry, String value) { * form "pureauth..." which does not do this fallback * substitution of editor. */ - String authString = entry.getField(FieldName.AUTHOR_FIELD); + String authString = entry.getField(FieldName.AUTHOR); if (authString != null) { authString = normalize(database.resolveForStrings(authString)); } @@ -615,7 +615,7 @@ public static String makeLabel(BibEntry entry, String value) { } if ((authString == null) || authString.isEmpty()) { - authString = entry.getField(FieldName.EDITOR_FIELD); + authString = entry.getField(FieldName.EDITOR); if (authString == null) { authString = ""; } else { @@ -689,39 +689,39 @@ else if ("authorLast".equals(val)) { // Gather all markers starting with "ed" here, so we // don't have to check all the time. if ("edtr".equals(val)) { - return firstAuthor(entry.getField(FieldName.EDITOR_FIELD)); + return firstAuthor(entry.getField(FieldName.EDITOR)); } else if ("edtrForeIni".equals(val)) { - return firstAuthorForenameInitials(entry.getField(FieldName.EDITOR_FIELD)); + return firstAuthorForenameInitials(entry.getField(FieldName.EDITOR)); } else if ("editors".equals(val)) { - return allAuthors(entry.getField(FieldName.EDITOR_FIELD)); + return allAuthors(entry.getField(FieldName.EDITOR)); // Last author's last name } else if ("editorLast".equals(val)) { - return lastAuthor(entry.getField(FieldName.EDITOR_FIELD)); + return lastAuthor(entry.getField(FieldName.EDITOR)); } else if ("editorLastForeIni".equals(val)) { - return lastAuthorForenameInitials(entry.getField(FieldName.EDITOR_FIELD)); + return lastAuthorForenameInitials(entry.getField(FieldName.EDITOR)); } else if ("editorIni".equals(val)) { - return oneAuthorPlusIni(entry.getField(FieldName.EDITOR_FIELD)); + return oneAuthorPlusIni(entry.getField(FieldName.EDITOR)); } else if (val.matches("edtrIni[\\d]+")) { int num = Integer.parseInt(val.substring(7)); - String s = authIniN(entry.getField(FieldName.EDITOR_FIELD), num); + String s = authIniN(entry.getField(FieldName.EDITOR), num); return s == null ? "" : s; } else if (val.matches("edtr[\\d]+_[\\d]+")) { String[] nums = val.substring(4).split("_"); - String s = authNofMth(entry.getField(FieldName.EDITOR_FIELD), + String s = authNofMth(entry.getField(FieldName.EDITOR), Integer.parseInt(nums[0]), Integer.parseInt(nums[1]) - 1); return s == null ? "" : s; } else if ("edtr.edtr.ea".equals(val)) { - String s = authAuthEa(entry.getField(FieldName.EDITOR_FIELD)); + String s = authAuthEa(entry.getField(FieldName.EDITOR)); return s == null ? "" : s; } else if ("edtrshort".equals(val)) { - String s = authshort(entry.getField(FieldName.EDITOR_FIELD)); + String s = authshort(entry.getField(FieldName.EDITOR)); return s == null ? "" : s; } // authN. First N chars of the first author's last // name. else if (val.matches("edtr\\d+")) { - String fa = firstAuthor(entry.getField(FieldName.EDITOR_FIELD)); + String fa = firstAuthor(entry.getField(FieldName.EDITOR)); if (fa == null) { return ""; } @@ -736,17 +736,17 @@ else if (val.matches("edtr\\d+")) { return getField(entry, val); } } else if ("firstpage".equals(val)) { - return firstPage(entry.getField("pages")); + return firstPage(entry.getField(FieldName.PAGES)); } else if ("lastpage".equals(val)) { - return lastPage(entry.getField("pages")); + return lastPage(entry.getField(FieldName.PAGES)); } else if ("shorttitle".equals(val)) { - return getTitleWords(3, entry.getField("title")); + return getTitleWords(3, entry.getField(FieldName.TITLE)); } else if ("shorttitleINI".equals(val)) { - return keepLettersAndDigitsOnly(applyModifiers(getTitleWordsWithSpaces(3, entry.getField("title")), new String[] {"abbr"}, 0)); + return keepLettersAndDigitsOnly(applyModifiers(getTitleWordsWithSpaces(3, entry.getField(FieldName.TITLE)), new String[] {"abbr"}, 0)); } else if ("veryshorttitle".equals(val)) { - return getTitleWords(1, entry.getField("title")); + return getTitleWords(1, entry.getField(FieldName.TITLE)); } else if ("shortyear".equals(val)) { - String ss = entry.getFieldOrAlias(FieldName.YEAR_FIELD).orElse(""); + String ss = entry.getFieldOrAlias(FieldName.YEAR).orElse(""); if (ss.isEmpty()) { return ss; } else if (ss.startsWith("in") || ss.startsWith("sub")) { diff --git a/src/main/java/net/sf/jabref/logic/layout/format/CreateDocBookAuthors.java b/src/main/java/net/sf/jabref/logic/layout/format/CreateDocBookAuthors.java index 1d2917e185c6..d9ed690eabb1 100644 --- a/src/main/java/net/sf/jabref/logic/layout/format/CreateDocBookAuthors.java +++ b/src/main/java/net/sf/jabref/logic/layout/format/CreateDocBookAuthors.java @@ -56,7 +56,7 @@ public String format(String fieldText) { AuthorList al = AuthorList.parse(fieldText); - addBody(sb, al, FieldName.AUTHOR_FIELD); + addBody(sb, al, FieldName.AUTHOR); return sb.toString(); } diff --git a/src/main/java/net/sf/jabref/logic/layout/format/CreateDocBookEditors.java b/src/main/java/net/sf/jabref/logic/layout/format/CreateDocBookEditors.java index 8719dde548c5..396808bf3cfe 100644 --- a/src/main/java/net/sf/jabref/logic/layout/format/CreateDocBookEditors.java +++ b/src/main/java/net/sf/jabref/logic/layout/format/CreateDocBookEditors.java @@ -49,7 +49,7 @@ public String format(String fieldText) { // L.Xue StringBuilder sb = new StringBuilder(100); AuthorList al = AuthorList.parse(fieldText); - addBody(sb, al, FieldName.EDITOR_FIELD); + addBody(sb, al, FieldName.EDITOR); return sb.toString(); } diff --git a/src/main/java/net/sf/jabref/logic/layout/format/FileLink.java b/src/main/java/net/sf/jabref/logic/layout/format/FileLink.java index d7504fe56b78..3c161db06529 100644 --- a/src/main/java/net/sf/jabref/logic/layout/format/FileLink.java +++ b/src/main/java/net/sf/jabref/logic/layout/format/FileLink.java @@ -83,7 +83,7 @@ public String format(String field) { // ugly hack, the export routine has set a global variable before // starting the export, which contains the database's file directory: if (prefs.fileDirForDatabase == null) { - dirs = Collections.singletonList(prefs.get(FieldName.FILE_FIELD + Globals.DIR_SUFFIX)); + dirs = Collections.singletonList(prefs.get(FieldName.FILE + Globals.DIR_SUFFIX)); } else { dirs = prefs.fileDirForDatabase; } diff --git a/src/main/java/net/sf/jabref/logic/layout/format/WrapFileLinks.java b/src/main/java/net/sf/jabref/logic/layout/format/WrapFileLinks.java index 783f063315b9..592ca3b4ec56 100644 --- a/src/main/java/net/sf/jabref/logic/layout/format/WrapFileLinks.java +++ b/src/main/java/net/sf/jabref/logic/layout/format/WrapFileLinks.java @@ -179,7 +179,7 @@ public String format(String field) { // ugly hack, the export routine has set a global variable before // starting the export, which contains the database's file directory: if (prefs.fileDirForDatabase == null) { - dirs = Collections.singletonList(prefs.get(FieldName.FILE_FIELD + Globals.DIR_SUFFIX)); + dirs = Collections.singletonList(prefs.get(FieldName.FILE + Globals.DIR_SUFFIX)); } else { dirs = prefs.fileDirForDatabase; } 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 6bb39007e7f1..7c57ad72f630 100644 --- a/src/main/java/net/sf/jabref/logic/mods/MODSEntry.java +++ b/src/main/java/net/sf/jabref/logic/mods/MODSEntry.java @@ -89,18 +89,18 @@ private MODSEntry() { public MODSEntry(BibEntry bibtex) { this(); handledExtensions.add(MODSEntry.BIBTEX + "publisher"); - handledExtensions.add(MODSEntry.BIBTEX + "title"); + handledExtensions.add(MODSEntry.BIBTEX + FieldName.TITLE); handledExtensions.add(MODSEntry.BIBTEX + BibEntry.KEY_FIELD); handledExtensions.add(MODSEntry.BIBTEX + "author"); populateFromBibtex(bibtex); } private void populateFromBibtex(BibEntry bibtex) { - if (bibtex.hasField("title")) { + if (bibtex.hasField(FieldName.TITLE)) { if (CHARFORMAT) { - title = chars.format(bibtex.getField("title")); + title = chars.format(bibtex.getField(FieldName.TITLE)); } else { - title = bibtex.getField("title"); + title = bibtex.getField(FieldName.TITLE); } } @@ -125,8 +125,8 @@ private void populateFromBibtex(BibEntry bibtex) { date = getDate(bibtex); genre = getMODSgenre(bibtex); - if (bibtex.hasField(FieldName.AUTHOR_FIELD)) { - authors = getAuthors(bibtex.getField(FieldName.AUTHOR_FIELD)); + if (bibtex.hasField(FieldName.AUTHOR)) { + authors = getAuthors(bibtex.getField(FieldName.AUTHOR)); } if ("article".equals(bibtex.getType()) || "inproceedings".equals(bibtex.getType())) { host = new MODSEntry(); @@ -138,8 +138,8 @@ private void populateFromBibtex(BibEntry bibtex) { host.volume = bibtex.getField("volume"); } host.issuance = "continuing"; - if (bibtex.hasField("pages")) { - host.pages = new PageNumbers(bibtex.getField("pages")); + if (bibtex.hasField(FieldName.PAGES)) { + host.pages = new PageNumbers(bibtex.getField(FieldName.PAGES)); } } @@ -180,7 +180,7 @@ private List getAuthors(String authors) { /* construct a MODS date object */ private static String getDate(BibEntry bibtex) { StringBuilder result = new StringBuilder(); - bibtex.getFieldOptional(FieldName.YEAR_FIELD).ifPresent(result::append); + bibtex.getFieldOptional(FieldName.YEAR).ifPresent(result::append); bibtex.getFieldOptional("month").ifPresent(result.append('-')::append); return result.toString(); } diff --git a/src/main/java/net/sf/jabref/logic/msbib/BibTeXConverter.java b/src/main/java/net/sf/jabref/logic/msbib/BibTeXConverter.java index f3981a476443..acd7292073f8 100644 --- a/src/main/java/net/sf/jabref/logic/msbib/BibTeXConverter.java +++ b/src/main/java/net/sf/jabref/logic/msbib/BibTeXConverter.java @@ -43,9 +43,9 @@ public static BibEntry convert(MSBibEntry entry) { fieldValues.put("language", MSBibMapping.getLanguage(lcid)); } - addAuthor(fieldValues, FieldName.AUTHOR_FIELD, entry.authors); + addAuthor(fieldValues, FieldName.AUTHOR, entry.authors); addAuthor(fieldValues, MSBIB_PREFIX + "bookauthor", entry.bookAuthors); - addAuthor(fieldValues, FieldName.EDITOR_FIELD, entry.editors); + addAuthor(fieldValues, FieldName.EDITOR, entry.editors); addAuthor(fieldValues, MSBIB_PREFIX + "translator", entry.translators); addAuthor(fieldValues, MSBIB_PREFIX + "producername", entry.producerNames); addAuthor(fieldValues, MSBIB_PREFIX + "composer", entry.composers); @@ -60,7 +60,7 @@ public static BibEntry convert(MSBibEntry entry) { addAuthor(fieldValues, MSBIB_PREFIX + "counsel", entry.counsels); if (entry.pages != null) { - fieldValues.put("pages", entry.pages.toString("--")); + fieldValues.put(FieldName.PAGES, entry.pages.toString("--")); } parseStandardNumber(entry.standardNumber, fieldValues); @@ -104,10 +104,10 @@ private static void parseStandardNumber(String standardNum, Map if (standardNum == null) { return; } - parseSingleStandardNumber("ISBN", FieldName.ISBN_FIELD, standardNum, map); - parseSingleStandardNumber("ISSN", FieldName.ISSN_FIELD, standardNum, map); + parseSingleStandardNumber("ISBN", FieldName.ISBN, standardNum, map); + parseSingleStandardNumber("ISSN", FieldName.ISSN, standardNum, map); parseSingleStandardNumber("LCCN", "lccn", standardNum, map); parseSingleStandardNumber("MRN", "mrnumber", standardNum, map); - parseSingleStandardNumber("DOI", FieldName.DOI_FIELD, standardNum, map); + parseSingleStandardNumber("DOI", FieldName.DOI, standardNum, map); } } diff --git a/src/main/java/net/sf/jabref/logic/msbib/MSBibConverter.java b/src/main/java/net/sf/jabref/logic/msbib/MSBibConverter.java index c765413c4dfe..95506884b93c 100644 --- a/src/main/java/net/sf/jabref/logic/msbib/MSBibConverter.java +++ b/src/main/java/net/sf/jabref/logic/msbib/MSBibConverter.java @@ -36,8 +36,8 @@ public static MSBibEntry convert(BibEntry entry) { result.conferenceName = entry.getField("booktitle"); } - if (entry.hasField("pages")) { - result.pages = new PageNumbers(entry.getField("pages")); + if (entry.hasField(FieldName.PAGES)) { + result.pages = new PageNumbers(entry.getField(FieldName.PAGES)); } if (entry.hasField(MSBIB_PREFIX + "accessed")) { @@ -45,13 +45,13 @@ public static MSBibEntry convert(BibEntry entry) { } // TODO: currently this can never happen - if ("SoundRecording".equals(msbibType) && (entry.hasField("title"))) { - result.albumTitle = entry.getField("title"); + if ("SoundRecording".equals(msbibType) && (entry.hasField(FieldName.TITLE))) { + result.albumTitle = entry.getField(FieldName.TITLE); } // TODO: currently this can never happen - if ("Interview".equals(msbibType) && (entry.hasField("title"))) { - result.broadcastTitle = entry.getField("title"); + if ("Interview".equals(msbibType) && (entry.hasField(FieldName.TITLE))) { + result.broadcastTitle = entry.getField(FieldName.TITLE); } // Value must be converted @@ -60,11 +60,11 @@ public static MSBibEntry convert(BibEntry entry) { } result.standardNumber = ""; - if (entry.hasField(FieldName.ISBN_FIELD)) { - result.standardNumber += " ISBN: " + entry.getField(FieldName.ISBN_FIELD); + if (entry.hasField(FieldName.ISBN)) { + result.standardNumber += " ISBN: " + entry.getField(FieldName.ISBN); } - if (entry.hasField(FieldName.ISSN_FIELD)) { - result.standardNumber += " ISSN: " + entry.getField(FieldName.ISSN_FIELD); + if (entry.hasField(FieldName.ISSN)) { + result.standardNumber += " ISSN: " + entry.getField(FieldName.ISSN); } if (entry.hasField("lccn")) { result.standardNumber += " LCCN: " + entry.getField("lccn"); @@ -72,8 +72,8 @@ public static MSBibEntry convert(BibEntry entry) { if (entry.hasField("mrnumber")) { result.standardNumber += " MRN: " + entry.getField("mrnumber"); } - if (entry.hasField(FieldName.DOI_FIELD)) { - result.standardNumber += " DOI: " + entry.getField(FieldName.DOI_FIELD); + if (entry.hasField(FieldName.DOI)) { + result.standardNumber += " DOI: " + entry.getField(FieldName.DOI); } if (result.standardNumber.isEmpty()) { result.standardNumber = null; @@ -99,21 +99,21 @@ public static MSBibEntry convert(BibEntry entry) { // TODO: currently this can never happen if (("InternetSite".equals(msbibType) || "DocumentFromInternetSite".equals(msbibType)) - && (entry.hasField("title"))) { - result.internetSiteTitle = entry.getField("title"); + && (entry.hasField(FieldName.TITLE))) { + result.internetSiteTitle = entry.getField(FieldName.TITLE); } // TODO: currently only Misc can happen if (("ElectronicSource".equals(msbibType) || "Art".equals(msbibType) || "Misc".equals(msbibType)) - && (entry.hasField("title"))) { - result.publicationTitle = entry.getField("title"); + && (entry.hasField(FieldName.TITLE))) { + result.publicationTitle = entry.getField(FieldName.TITLE); } - if (entry.hasField(FieldName.AUTHOR_FIELD)) { - result.authors = getAuthors(entry.getField(FieldName.AUTHOR_FIELD)); + if (entry.hasField(FieldName.AUTHOR)) { + result.authors = getAuthors(entry.getField(FieldName.AUTHOR)); } - if (entry.hasField(FieldName.EDITOR_FIELD)) { - result.editors = getAuthors(entry.getField(FieldName.EDITOR_FIELD)); + if (entry.hasField(FieldName.EDITOR)) { + result.editors = getAuthors(entry.getField(FieldName.EDITOR)); } return result; 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 5ea602249673..7ec1269e543d 100644 --- a/src/main/java/net/sf/jabref/logic/msbib/MSBibMapping.java +++ b/src/main/java/net/sf/jabref/logic/msbib/MSBibMapping.java @@ -17,8 +17,8 @@ public class MSBibMapping { static { bibtexToMSBib.put(BibEntry.KEY_FIELD, "Tag"); - bibtexToMSBib.put("title", "Title"); - bibtexToMSBib.put(FieldName.YEAR_FIELD, "Year"); + bibtexToMSBib.put(FieldName.TITLE, "Title"); + bibtexToMSBib.put(FieldName.YEAR, "Year"); bibtexToMSBib.put("month", "Month"); bibtexToMSBib.put("note", "Comments"); bibtexToMSBib.put("volume", "Volume"); @@ -27,19 +27,19 @@ public class MSBibMapping { bibtexToMSBib.put("publisher", "Publisher"); bibtexToMSBib.put("booktitle", "BookTitle"); //bibtexToMSBib.put("booktitle", "ConferenceName"); - //bibtexToMSBib.put("pages", "Pages"); + //bibtexToMSBib.put(FieldName.PAGES, "Pages"); bibtexToMSBib.put("chapter", "ChapterNumber"); bibtexToMSBib.put("journal", "JournalName"); bibtexToMSBib.put("number", "Issue"); bibtexToMSBib.put("school", "Department"); bibtexToMSBib.put("institution", "Institution"); - bibtexToMSBib.put(FieldName.DOI_FIELD, "DOI"); - bibtexToMSBib.put(FieldName.URL_FIELD, "URL"); + bibtexToMSBib.put(FieldName.DOI, "DOI"); + bibtexToMSBib.put(FieldName.URL, "URL"); // BibTeX/Biblatex only fields bibtexToMSBib.put("series", BIBTEX_PREFIX + "Series"); - bibtexToMSBib.put(FieldName.ABSTRACT_FIELD, BIBTEX_PREFIX + "Abstract"); + bibtexToMSBib.put(FieldName.ABSTRACT, BIBTEX_PREFIX + "Abstract"); bibtexToMSBib.put("keywords", BIBTEX_PREFIX + "KeyWords"); - bibtexToMSBib.put("crossref", BIBTEX_PREFIX + "CrossRef"); + bibtexToMSBib.put(FieldName.CROSSREF, BIBTEX_PREFIX + "CrossRef"); bibtexToMSBib.put("howpublished", BIBTEX_PREFIX + "HowPublished"); bibtexToMSBib.put("affiliation", BIBTEX_PREFIX + "Affiliation"); bibtexToMSBib.put("contents", BIBTEX_PREFIX + "Contents"); diff --git a/src/main/java/net/sf/jabref/logic/openoffice/OOBibStyle.java b/src/main/java/net/sf/jabref/logic/openoffice/OOBibStyle.java index ee2e97c1a72e..488d1412042c 100644 --- a/src/main/java/net/sf/jabref/logic/openoffice/OOBibStyle.java +++ b/src/main/java/net/sf/jabref/logic/openoffice/OOBibStyle.java @@ -190,7 +190,7 @@ private void setDefaultProperties() { // Set default properties for the citation marker: citProperties.put(AUTHOR_FIELD, "author/editor"); - citProperties.put(YEAR_FIELD, FieldName.YEAR_FIELD); + citProperties.put(YEAR_FIELD, FieldName.YEAR); citProperties.put(MAX_AUTHORS, 3); citProperties.put(MAX_AUTHORS_FIRST, -1); citProperties.put(AUTHOR_SEPARATOR, ", "); diff --git a/src/main/java/net/sf/jabref/logic/util/io/FileUtil.java b/src/main/java/net/sf/jabref/logic/util/io/FileUtil.java index 8a112f69df27..550ef8e8f302 100644 --- a/src/main/java/net/sf/jabref/logic/util/io/FileUtil.java +++ b/src/main/java/net/sf/jabref/logic/util/io/FileUtil.java @@ -373,7 +373,7 @@ public static List getListOfLinkedFiles(List bes, List f List result = new ArrayList<>(); for (BibEntry entry : bes) { - entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(fileField -> { + entry.getFieldOptional(FieldName.FILE).ifPresent(fileField -> { List fileList = FileField.parse(fileField); for (ParsedFileField file : fileList) { expandFilename(file.getLink(), fileDirs).ifPresent(result::add); diff --git a/src/main/java/net/sf/jabref/logic/xmp/XMPSchemaBibtex.java b/src/main/java/net/sf/jabref/logic/xmp/XMPSchemaBibtex.java index 42044bd13aa7..e5bb44522eb6 100644 --- a/src/main/java/net/sf/jabref/logic/xmp/XMPSchemaBibtex.java +++ b/src/main/java/net/sf/jabref/logic/xmp/XMPSchemaBibtex.java @@ -54,9 +54,9 @@ public class XMPSchemaBibtex extends XMPSchema { static { - XMPSchemaBibtex.PRESERVE_WHITE_SPACE.add(FieldName.ABSTRACT_FIELD); + XMPSchemaBibtex.PRESERVE_WHITE_SPACE.add(FieldName.ABSTRACT); XMPSchemaBibtex.PRESERVE_WHITE_SPACE.add("note"); - XMPSchemaBibtex.PRESERVE_WHITE_SPACE.add(FieldName.REVIEW_FIELD); + XMPSchemaBibtex.PRESERVE_WHITE_SPACE.add(FieldName.REVIEW); } /** 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 99d2789d903f..4264867083dc 100644 --- a/src/main/java/net/sf/jabref/logic/xmp/XMPUtil.java +++ b/src/main/java/net/sf/jabref/logic/xmp/XMPUtil.java @@ -263,12 +263,12 @@ public static Optional getBibtexEntryFromDocumentInformation( String s = di.getAuthor(); if (s != null) { - entry.setField(FieldName.AUTHOR_FIELD, s); + entry.setField(FieldName.AUTHOR, s); } s = di.getTitle(); if (s != null) { - entry.setField("title", s); + entry.setField(FieldName.TITLE, s); } s = di.getKeywords(); @@ -278,7 +278,7 @@ public static Optional getBibtexEntryFromDocumentInformation( s = di.getSubject(); if (s != null) { - entry.setField(FieldName.ABSTRACT_FIELD, s); + entry.setField(FieldName.ABSTRACT, s); } COSDictionary dict = di.getDictionary(); @@ -324,7 +324,7 @@ public static Optional getBibtexEntryFromDublinCore(XMPSchemaDublinCor */ List contributors = dcSchema.getContributors(); if ((contributors != null) && !contributors.isEmpty()) { - entry.setField(FieldName.EDITOR_FIELD, String.join(" and ", contributors)); + entry.setField(FieldName.EDITOR, String.join(" and ", contributors)); } /** @@ -332,7 +332,7 @@ public static Optional getBibtexEntryFromDublinCore(XMPSchemaDublinCor */ List creators = dcSchema.getCreators(); if ((creators != null) && !creators.isEmpty()) { - entry.setField(FieldName.AUTHOR_FIELD, String.join(" and ", creators)); + entry.setField(FieldName.AUTHOR, String.join(" and ", creators)); } /** @@ -348,7 +348,7 @@ public static Optional getBibtexEntryFromDublinCore(XMPSchemaDublinCor // Ignored } if (c != null) { - entry.setField(FieldName.YEAR_FIELD, String.valueOf(c.get(Calendar.YEAR))); + entry.setField(FieldName.YEAR, String.valueOf(c.get(Calendar.YEAR))); if (date.length() > 4) { entry.setField("month", MonthUtil.getMonthByIndex(c.get(Calendar.MONTH)).bibtexFormat); } @@ -360,7 +360,7 @@ public static Optional getBibtexEntryFromDublinCore(XMPSchemaDublinCor */ String s = dcSchema.getDescription(); if (s != null) { - entry.setField(FieldName.ABSTRACT_FIELD, s); + entry.setField(FieldName.ABSTRACT, s); } /** @@ -368,7 +368,7 @@ public static Optional getBibtexEntryFromDublinCore(XMPSchemaDublinCor */ s = dcSchema.getIdentifier(); if (s != null) { - entry.setField(FieldName.DOI_FIELD, s); + entry.setField(FieldName.DOI, s); } /** @@ -427,7 +427,7 @@ public static Optional getBibtexEntryFromDublinCore(XMPSchemaDublinCor */ s = dcSchema.getTitle(); if (s != null) { - entry.setField("title", s); + entry.setField(FieldName.TITLE, s); } /** @@ -619,7 +619,7 @@ private static void writeToDCSchema(XMPSchemaDublinCore dcSchema, continue; } - if (FieldName.EDITOR_FIELD.equals(field)) { + if (FieldName.EDITOR.equals(field)) { String authors = resolvedEntry.getField(field); /** @@ -682,7 +682,7 @@ private static void writeToDCSchema(XMPSchemaDublinCore dcSchema, continue; } - if (FieldName.YEAR_FIELD.equals(field)) { + if (FieldName.YEAR.equals(field)) { /** * Year + Month -> Date @@ -716,7 +716,7 @@ private static void writeToDCSchema(XMPSchemaDublinCore dcSchema, * * Bibtex-Fields used: abstract */ - if (FieldName.ABSTRACT_FIELD.equals(field)) { + if (FieldName.ABSTRACT.equals(field)) { String o = resolvedEntry.getField(field); dcSchema.setDescription(o); continue; @@ -735,7 +735,7 @@ private static void writeToDCSchema(XMPSchemaDublinCore dcSchema, * * Bibtex-Fields used: doi */ - if (FieldName.DOI_FIELD.equals(field)) { + if (FieldName.DOI.equals(field)) { String o = resolvedEntry.getField(field); dcSchema.setIdentifier(o); continue; @@ -825,7 +825,7 @@ private static void writeToDCSchema(XMPSchemaDublinCore dcSchema, * * Bibtex-Fields used: title */ - if ("title".equals(field)) { + if (FieldName.TITLE.equals(field)) { String o = entry.getField(field); dcSchema.setTitle(o); continue; @@ -1011,11 +1011,11 @@ private static void writeDocumentInformation(PDDocument document, // erase field instead of adding it if ("author".equals(field)) { di.setAuthor(null); - } else if ("title".equals(field)) { + } else if (FieldName.TITLE.equals(field)) { di.setTitle(null); } else if ("keywords".equals(field)) { di.setKeywords(null); - } else if (FieldName.ABSTRACT_FIELD.equals(field)) { + } else if (FieldName.ABSTRACT.equals(field)) { di.setSubject(null); } else { di.setCustomMetadataValue("bibtex/" + field, null); @@ -1024,13 +1024,13 @@ private static void writeDocumentInformation(PDDocument document, } if ("author".equals(field)) { - di.setAuthor(resolvedEntry.getField(FieldName.AUTHOR_FIELD)); - } else if ("title".equals(field)) { - di.setTitle(resolvedEntry.getField("title")); + 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.ABSTRACT_FIELD.equals(field)) { - di.setSubject(resolvedEntry.getField(FieldName.ABSTRACT_FIELD)); + } else if (FieldName.ABSTRACT.equals(field)) { + di.setSubject(resolvedEntry.getField(FieldName.ABSTRACT)); } else { di.setCustomMetadataValue("bibtex/" + field, resolvedEntry.getField(field)); } diff --git a/src/main/java/net/sf/jabref/migrations/FileLinksUpgradeWarning.java b/src/main/java/net/sf/jabref/migrations/FileLinksUpgradeWarning.java index d1612fc7d874..857b34e934d4 100644 --- a/src/main/java/net/sf/jabref/migrations/FileLinksUpgradeWarning.java +++ b/src/main/java/net/sf/jabref/migrations/FileLinksUpgradeWarning.java @@ -78,7 +78,7 @@ public boolean isActionNecessary(ParserResult pr) { // Only offer to upgrade links if the pdf/ps fields are used: offerChangeDatabase = linksFound(pr.getDatabase(), FileLinksUpgradeWarning.FIELDS_TO_LOOK_FOR); // If the "file" directory is not set, offer to migrate pdf/ps dir: - offerSetFileDir = !Globals.prefs.hasKey(FieldName.FILE_FIELD + Globals.DIR_SUFFIX) + offerSetFileDir = !Globals.prefs.hasKey(FieldName.FILE + Globals.DIR_SUFFIX) && (Globals.prefs.hasKey("pdfDirectory") || Globals.prefs.hasKey("psDirectory")); // First check if this warning is disabled: @@ -200,7 +200,7 @@ private void makeChanges(BasePanel panel, ParserResult pr, boolean upgradePrefs, } if (fileDir != null) { - Globals.prefs.put(FieldName.FILE_FIELD + Globals.DIR_SUFFIX, fileDir); + Globals.prefs.put(FieldName.FILE + Globals.DIR_SUFFIX, fileDir); } if (upgradePrefs) { @@ -215,7 +215,7 @@ private void makeChanges(BasePanel panel, ParserResult pr, boolean upgradePrefs, if (!gfs.isEmpty()) { sb.append(';'); } - sb.append(FieldName.FILE_FIELD); + sb.append(FieldName.FILE); Globals.prefs.put(JabRefPreferences.CUSTOM_TAB_FIELDS + "0", sb.toString()); Globals.prefs.updateEntryEditorTabList(); panel.frame().removeCachedEntryEditors(); @@ -230,7 +230,7 @@ private boolean showsFileInGenFields() { outer: for (int i = 0; i < tabList.getTabCount(); i++) { List fields = tabList.getTabFields(i); for (String field : fields) { - if (field.equals(FieldName.FILE_FIELD)) { + if (field.equals(FieldName.FILE)) { found = true; break outer; } diff --git a/src/main/java/net/sf/jabref/migrations/PreferencesMigrations.java b/src/main/java/net/sf/jabref/migrations/PreferencesMigrations.java index fc51286d1e1e..2d684ac8e836 100644 --- a/src/main/java/net/sf/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/net/sf/jabref/migrations/PreferencesMigrations.java @@ -18,10 +18,10 @@ public static void replaceAbstractField() { // Jabref 1.55 moves the abstract to its own tab. String genFields = Globals.prefs.get(JabRefPreferences.GENERAL_FIELDS); - if (genFields.contains(FieldName.ABSTRACT_FIELD)) { + if (genFields.contains(FieldName.ABSTRACT)) { String newGen; - if (FieldName.ABSTRACT_FIELD.equals(genFields)) { + if (FieldName.ABSTRACT.equals(genFields)) { newGen = ""; } else if (genFields.contains(";abstract;")) { newGen = genFields.replace(";abstract;", ";"); @@ -87,18 +87,18 @@ public static void upgradeSortOrder() { if (prefs.get(JabRefPreferences.EXPORT_IN_SPECIFIED_ORDER, null) == null) { if (prefs.getBoolean("exportInStandardOrder", false)) { prefs.putBoolean(JabRefPreferences.EXPORT_IN_SPECIFIED_ORDER, true); - prefs.put(JabRefPreferences.EXPORT_PRIMARY_SORT_FIELD, FieldName.AUTHOR_FIELD); - prefs.put(JabRefPreferences.EXPORT_SECONDARY_SORT_FIELD, FieldName.EDITOR_FIELD); - prefs.put(JabRefPreferences.EXPORT_TERTIARY_SORT_FIELD, FieldName.YEAR_FIELD); + prefs.put(JabRefPreferences.EXPORT_PRIMARY_SORT_FIELD, FieldName.AUTHOR); + prefs.put(JabRefPreferences.EXPORT_SECONDARY_SORT_FIELD, FieldName.EDITOR); + prefs.put(JabRefPreferences.EXPORT_TERTIARY_SORT_FIELD, FieldName.YEAR); prefs.putBoolean(JabRefPreferences.EXPORT_PRIMARY_SORT_DESCENDING, false); prefs.putBoolean(JabRefPreferences.EXPORT_SECONDARY_SORT_DESCENDING, false); prefs.putBoolean(JabRefPreferences.EXPORT_TERTIARY_SORT_DESCENDING, false); } else if (prefs.getBoolean("exportInTitleOrder", false)) { // exportInTitleOrder => title, author, editor prefs.putBoolean(JabRefPreferences.EXPORT_IN_SPECIFIED_ORDER, true); - prefs.put(JabRefPreferences.EXPORT_PRIMARY_SORT_FIELD, "title"); - prefs.put(JabRefPreferences.EXPORT_SECONDARY_SORT_FIELD, FieldName.AUTHOR_FIELD); - prefs.put(JabRefPreferences.EXPORT_TERTIARY_SORT_FIELD, FieldName.EDITOR_FIELD); + prefs.put(JabRefPreferences.EXPORT_PRIMARY_SORT_FIELD, FieldName.TITLE); + prefs.put(JabRefPreferences.EXPORT_SECONDARY_SORT_FIELD, FieldName.AUTHOR); + prefs.put(JabRefPreferences.EXPORT_TERTIARY_SORT_FIELD, FieldName.EDITOR); prefs.putBoolean(JabRefPreferences.EXPORT_PRIMARY_SORT_DESCENDING, false); prefs.putBoolean(JabRefPreferences.EXPORT_SECONDARY_SORT_DESCENDING, false); prefs.putBoolean(JabRefPreferences.EXPORT_TERTIARY_SORT_DESCENDING, false); diff --git a/src/main/java/net/sf/jabref/model/DuplicateCheck.java b/src/main/java/net/sf/jabref/model/DuplicateCheck.java index ac7009c9346d..6eab6b8f19fd 100644 --- a/src/main/java/net/sf/jabref/model/DuplicateCheck.java +++ b/src/main/java/net/sf/jabref/model/DuplicateCheck.java @@ -62,9 +62,9 @@ public class DuplicateCheck { static { - DuplicateCheck.FIELD_WEIGHTS.put(FieldName.AUTHOR_FIELD, 2.5); - DuplicateCheck.FIELD_WEIGHTS.put(FieldName.EDITOR_FIELD, 2.5); - DuplicateCheck.FIELD_WEIGHTS.put("title", 3.); + 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.); } @@ -159,7 +159,7 @@ private static int compareSingleField(String field, BibEntry one, BibEntry two) return EQUAL; } return NOT_EQUAL; - } else if ("pages".equals(field)) { + } else if (FieldName.PAGES.equals(field)) { // Pages can be given with a variety of delimiters, "-", "--", " - ", " -- ". // We do a replace to harmonize these to a simple "-": // After this, a simple test for equality should be enough: diff --git a/src/main/java/net/sf/jabref/model/database/BibDatabase.java b/src/main/java/net/sf/jabref/model/database/BibDatabase.java index 20905246f84f..5ea3c93cd242 100644 --- a/src/main/java/net/sf/jabref/model/database/BibDatabase.java +++ b/src/main/java/net/sf/jabref/model/database/BibDatabase.java @@ -46,6 +46,7 @@ import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.model.entry.BibtexString; import net.sf.jabref.model.entry.EntryUtil; +import net.sf.jabref.model.entry.FieldName; import net.sf.jabref.model.entry.InternalBibtexFields; import net.sf.jabref.model.entry.MonthUtil; import net.sf.jabref.model.event.EntryAddedEvent; @@ -515,7 +516,7 @@ public static String getResolvedField(String field, BibEntry entry, BibDatabase // If this field is not set, and the entry has a crossref, try to look up the // field in the referred entry: Do not do this for the bibtex key. if (!result.isPresent() && (database != null) && !field.equals(BibEntry.KEY_FIELD)) { - Optional crossrefKey = entry.getFieldOptional("crossref"); + Optional crossrefKey = entry.getFieldOptional(FieldName.CROSSREF); if (crossrefKey.isPresent()) { Optional referred = database.getEntryByKey(crossrefKey.get()); if (referred.isPresent()) { 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 c40aac4cfc71..9fce91e88473 100644 --- a/src/main/java/net/sf/jabref/model/entry/BibEntry.java +++ b/src/main/java/net/sf/jabref/model/entry/BibEntry.java @@ -260,8 +260,8 @@ public Optional getFieldOrAlias(String name) { } // Finally, handle dates - if (FieldName.DATE_FIELD.equals(name)) { - Optional year = getFieldOptional(FieldName.YEAR_FIELD); + if (FieldName.DATE.equals(name)) { + Optional year = getFieldOptional(FieldName.YEAR); if (year.isPresent()) { MonthUtil.Month month = MonthUtil.getMonth(getFieldOptional("month").orElse("")); if (month.isValid()) { @@ -271,8 +271,8 @@ public Optional getFieldOrAlias(String name) { } } } - if (FieldName.YEAR_FIELD.equals(name) || "month".equals(name)) { - Optional date = getFieldOptional(FieldName.DATE_FIELD); + if (FieldName.YEAR.equals(name) || "month".equals(name)) { + Optional date = getFieldOptional(FieldName.DATE); if (!date.isPresent()) { return Optional.empty(); } @@ -303,7 +303,7 @@ public Date parse(String source, ParsePosition pos) { Date parsedDate = df.parse(date.get()); Calendar calendar = Calendar.getInstance(); calendar.setTime(parsedDate); - if (FieldName.YEAR_FIELD.equals(name)) { + if (FieldName.YEAR.equals(name)) { return Optional.of(Integer.toString(calendar.get(Calendar.YEAR))); } if ("month".equals(name)) { @@ -317,7 +317,7 @@ public Date parse(String source, ParsePosition pos) { Date parsedDate = df.parse(date.get()); Calendar calendar = Calendar.getInstance(); calendar.setTime(parsedDate); - if (FieldName.YEAR_FIELD.equals(name)) { + if (FieldName.YEAR.equals(name)) { return Optional.of(Integer.toString(calendar.get(Calendar.YEAR))); } } catch (ParseException e2) { @@ -487,8 +487,8 @@ public void setGroupHit(boolean groupHit) { * Author1, Author2: Title (Year) */ public String getAuthorTitleYear(int maxCharacters) { - String[] s = new String[] {getFieldOptional(FieldName.AUTHOR_FIELD).orElse("N/A"), getFieldOptional("title").orElse("N/A"), - getFieldOptional(FieldName.YEAR_FIELD).orElse("N/A")}; + String[] s = new String[] {getFieldOptional(FieldName.AUTHOR).orElse("N/A"), getFieldOptional(FieldName.TITLE).orElse("N/A"), + getFieldOptional(FieldName.YEAR).orElse("N/A")}; String text = s[0] + ": \"" + s[1] + "\" (" + s[2] + ')'; if ((maxCharacters <= 0) || (text.length() <= maxCharacters)) { @@ -503,11 +503,11 @@ public String getAuthorTitleYear(int maxCharacters) { * @return will return the publication date of the entry or null if no year was found. */ public Optional getPublicationDate() { - if (!hasField(FieldName.YEAR_FIELD)) { + if (!hasField(FieldName.YEAR)) { return Optional.empty(); } - Optional year = getFieldOptional(FieldName.YEAR_FIELD); + Optional year = getFieldOptional(FieldName.YEAR); Optional monthString = getFieldOptional("month"); if (monthString.isPresent()) { 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 10cd3bc417ac..e5fc80667e9e 100644 --- a/src/main/java/net/sf/jabref/model/entry/BibLatexEntryTypes.java +++ b/src/main/java/net/sf/jabref/model/entry/BibLatexEntryTypes.java @@ -29,15 +29,15 @@ public class BibLatexEntryTypes { public static final BibLatexEntryType ARTICLE = new BibLatexEntryType() { private final List primaryOptionalFields = Collections.unmodifiableList( - Arrays.asList("subtitle", FieldName.EDITOR_FIELD, "series", "volume", "number", "eid", "issue", "pages", - "note", FieldName.ISSN_FIELD, FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + Arrays.asList("subtitle", FieldName.EDITOR, "series", "volume", "number", "eid", "issue", FieldName.PAGES, + "note", FieldName.ISSN, FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "journaltitle", "year/date"); - addAllOptional("translator", "annotator", "commentator", "subtitle", "titleaddon", FieldName.EDITOR_FIELD, "editora", + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "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", "pages", "version", "note", FieldName.ISSN_FIELD, - "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate"); + "series", "volume", "number", "eid", "issue", "month", FieldName.PAGES, "version", "note", FieldName.ISSN, + "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @Override @@ -54,18 +54,18 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType BOOK = new BibLatexEntryType() { private final List primaryOptionalFields = Collections - .unmodifiableList(Arrays.asList(FieldName.EDITOR_FIELD, "subtitle", "titleaddon", "maintitle", - "mainsubtitle", "maintitleaddon", "volume", "edition", "publisher", FieldName.ISBN_FIELD, "chapter", "pages", - "pagetotal", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + .unmodifiableList(Arrays.asList(FieldName.EDITOR, "subtitle", "titleaddon", "maintitle", + "mainsubtitle", "maintitleaddon", "volume", "edition", "publisher", FieldName.ISBN, "chapter", FieldName.PAGES, + "pagetotal", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "year/date"); - addAllOptional(FieldName.EDITOR_FIELD, "editora", "editorb", "editorc", "translator", "annotator", "commentator", + 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_FIELD, "chapter", "pages", "pagetotal", - "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate"); + "number", "note", "publisher", "location", FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", + "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @Override @@ -82,15 +82,15 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType MVBOOK = new BibLatexEntryType() { private final List primaryOptionalFields = Collections - .unmodifiableList(Arrays.asList(FieldName.EDITOR_FIELD, "subtitle", "titleaddon", "edition", "publisher", FieldName.ISBN_FIELD, "pagetotal", - FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + .unmodifiableList(Arrays.asList(FieldName.EDITOR, "subtitle", "titleaddon", "edition", "publisher", FieldName.ISBN, "pagetotal", + FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "year/date"); - addAllOptional(FieldName.EDITOR_FIELD, "editora", "editorb", "editorc", "translator", "annotator", "commentator", + 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_FIELD, "pagetotal", - "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate"); + "edition", "volumes", "series", "number", "note", "publisher", "location", FieldName.ISBN, "pagetotal", + "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @Override @@ -107,18 +107,18 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType INBOOK = new BibLatexEntryType() { private final List primaryOptionalFields = Collections.unmodifiableList(Arrays - .asList("bookauthor", FieldName.EDITOR_FIELD, "subtitle", "titleaddon", "maintitle", "mainsubtitle", - "maintitleaddon", "booksubtitle", "booktitleaddon", "volume", "edition", "publisher", FieldName.ISBN_FIELD, - "chapter", "pages", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + .asList("bookauthor", FieldName.EDITOR, "subtitle", "titleaddon", "maintitle", "mainsubtitle", + "maintitleaddon", "booksubtitle", "booktitleaddon", "volume", "edition", "publisher", FieldName.ISBN, + "chapter", FieldName.PAGES, FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "booktitle", "year/date"); - addAllOptional("bookauthor", FieldName.EDITOR_FIELD, "editora", "editorb", "editorc", "translator", "annotator", + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "booktitle", "year/date"); + 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_FIELD, - "chapter", "pages", "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, + "volume", "part", "edition", "volumes", "series", "number", "note", "publisher", "location", FieldName.ISBN, + "chapter", FieldName.PAGES, "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -185,13 +185,13 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "howpublished", "chapter", - "pages", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + FieldName.PAGES, FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired("author/editor", "title", "year/date"); + addAllRequired("author/editor", FieldName.TITLE, "year/date"); addAllOptional("subtitle", "titleaddon", "language", "howpublished", "type", "note", "location", "chapter", - "pages", "pagetotal", "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", - FieldName.URL_FIELD, "urldate"); + FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", + FieldName.URL, "urldate"); } @Override @@ -209,17 +209,17 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections .unmodifiableList(Arrays.asList("translator", "subtitle", "titleaddon", "maintitle", - "mainsubtitle", "maintitleaddon", "volume", "edition", "publisher", FieldName.ISBN_FIELD, "chapter", "pages", - FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + "mainsubtitle", "maintitleaddon", "volume", "edition", "publisher", FieldName.ISBN, "chapter", FieldName.PAGES, + FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired(FieldName.EDITOR_FIELD, "title", "year/date"); + 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_FIELD, "chapter", "pages", "pagetotal", "addendum", "pubstate", FieldName.DOI_FIELD, - "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate"); + "publisher", "location", FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, + "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @Override @@ -236,16 +236,16 @@ 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_FIELD, - FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + .unmodifiableList(Arrays.asList("translator", "subtitle", "titleaddon", "edition", "publisher", FieldName.ISBN, + FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired(FieldName.EDITOR_FIELD, "title", "year/date"); + 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_FIELD, "pagetotal", "addendum", "pubstate", FieldName.DOI_FIELD, - "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate"); + "publisher", "location", FieldName.ISBN, "pagetotal", "addendum", "pubstate", FieldName.DOI, + "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @Override @@ -263,17 +263,17 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections.unmodifiableList( Arrays.asList("translator", "subtitle", "titleaddon", "maintitle", "mainsubtitle", - "maintitleaddon", "booksubtitle", "booktitleaddon", "volume", "edition", "publisher", FieldName.ISBN_FIELD, - "chapter", "pages", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + "maintitleaddon", "booksubtitle", "booktitleaddon", "volume", "edition", "publisher", FieldName.ISBN, + "chapter", FieldName.PAGES, FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "booktitle", "year/date"); - addAllOptional(FieldName.EDITOR_FIELD, "editora", "editorb", "editorc", "translator", "annotator", "commentator", "introduction", + 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_FIELD, "chapter", "pages", - "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate"); + "volumes", "series", "number", "note", "publisher", "location", FieldName.ISBN, "chapter", FieldName.PAGES, + "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @Override @@ -314,15 +314,15 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType MANUAL = new BibLatexEntryType() { private final List primaryOptionalFields = Collections - .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "edition", "publisher", FieldName.ISBN_FIELD, - "chapter", "pages", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "edition", "publisher", FieldName.ISBN, + "chapter", FieldName.PAGES, FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired("author/editor", "title", "year/date"); + addAllRequired("author/editor", FieldName.TITLE, "year/date"); addAllOptional("subtitle", "titleaddon", "language", "edition", "type", "series", "number", "version", - "note", "organization", "publisher", "location", FieldName.ISBN_FIELD, "chapter", "pages", "pagetotal", - "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate"); + "note", "organization", "publisher", "location", FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", + "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @Override @@ -340,14 +340,14 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "howpublished", "location", - FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired("author/editor", "title", "year/date"); + addAllRequired("author/editor", FieldName.TITLE, "year/date"); addAllOptional("subtitle", "titleaddon", "language", "howpublished", "type", "version", "note", - "organization", "location", "month", "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", - "eprinttype", FieldName.URL_FIELD, "urldate"); + "organization", "location", "month", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", + "eprinttype", FieldName.URL, "urldate"); } @Override @@ -368,7 +368,7 @@ public List getPrimaryOptionalFields() { { - addAllRequired("author/editor", "title", "year/date", FieldName.URL_FIELD); + addAllRequired("author/editor", FieldName.TITLE, "year/date", FieldName.URL); addAllOptional("subtitle", "titleaddon", "language", "version", "note", "organization", "month", "addendum", "pubstate", "urldate"); } @@ -386,13 +386,13 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType PATENT = new BibLatexEntryType() { private final List primaryOptionalFields = Collections.unmodifiableList(Arrays.asList("holder", - "subtitle", "titleaddon", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + "subtitle", "titleaddon", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "number", "year/date"); + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "number", "year/date"); addAllOptional("holder", "subtitle", "titleaddon", "type", "version", "location", "note", "month", - "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate"); + "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @Override @@ -409,15 +409,15 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType PERIODICAL = new BibLatexEntryType() { private final List primaryOptionalFields = Collections - .unmodifiableList(Arrays.asList("subtitle", "issuetitle", "issuesubtitle", FieldName.ISSN_FIELD, FieldName.DOI_FIELD, - "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + .unmodifiableList(Arrays.asList("subtitle", "issuetitle", "issuesubtitle", FieldName.ISSN, FieldName.DOI, + "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired(FieldName.EDITOR_FIELD, "title", "year/date"); + addAllRequired(FieldName.EDITOR, FieldName.TITLE, "year/date"); addAllOptional("editora", "editorb", "editorc", "subtitle", "issuetitle", "issuesubtitle", "language", - "series", "volume", "number", "issue", "month", "note", FieldName.ISSN_FIELD, "addendum", "pubstate", - FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate"); + "series", "volume", "number", "issue", "month", "note", FieldName.ISSN, "addendum", "pubstate", + FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @Override @@ -459,16 +459,16 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "maintitle", "mainsubtitle", - "maintitleaddon", "eventtitle", "volume", "publisher", FieldName.ISBN_FIELD, "chapter", "pages", "pagetotal", - FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + "maintitleaddon", "eventtitle", "volume", "publisher", FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", + FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired("title", "year/date"); - addAllOptional(FieldName.EDITOR_FIELD, "subtitle", "titleaddon", "maintitle", "mainsubtitle", "maintitleaddon", "eventtitle", + 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_FIELD, FieldName.ISBN_FIELD, "chapter", "pages", "pagetotal", - "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate"); + "organization", "publisher", "location", "month", FieldName.YEAR, FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", + "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @Override @@ -486,16 +486,16 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "maintitle", "mainsubtitle", - "maintitleaddon", "eventtitle", "volume", "publisher", FieldName.ISBN_FIELD, "chapter", "pages", "pagetotal", - FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + "maintitleaddon", "eventtitle", "volume", "publisher", FieldName.ISBN, "chapter", FieldName.PAGES, "pagetotal", + FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired("title", "year/date"); - addAllOptional(FieldName.EDITOR_FIELD, "subtitle", "titleaddon", "eventtitle", + 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_FIELD, "pagetotal", - "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate"); + "organization", "publisher", "location", "month", FieldName.ISBN, "pagetotal", + "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @Override @@ -513,16 +513,16 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "maintitle", "mainsubtitle", - "maintitleaddon", "booksubtitle", "booktitleaddon", "eventtitle", "volume", "publisher", FieldName.ISBN_FIELD, - "chapter", "pages", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + "maintitleaddon", "booksubtitle", "booktitleaddon", "eventtitle", "volume", "publisher", FieldName.ISBN, + "chapter", FieldName.PAGES, FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "booktitle", "year/date"); - addAllOptional(FieldName.EDITOR_FIELD, "subtitle", "titleaddon", "maintitle", "mainsubtitle", "maintitleaddon", "booksubtitle", + 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_FIELD, - "chapter", "pages", "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, + "series", "number", "note", "organization", "publisher", "location", "month", FieldName.ISBN, + "chapter", FieldName.PAGES, "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -613,14 +613,14 @@ public List getPrimaryOptionalFields() { private final List primaryOptionalFields = Collections .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "number", "isrn", "chapter", - "pages", "pagetotal", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + FieldName.PAGES, "pagetotal", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "type", "institution", "year/date"); + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "type", "institution", "year/date"); addAllOptional("subtitle", "titleaddon", "language", "number", "version", "note", "location", "month", - "isrn", "chapter", "pages", "pagetotal", "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", - "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate"); + "isrn", "chapter", FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", + "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @Override @@ -636,7 +636,7 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType SET = new BibLatexEntryType() { { - addAllRequired("entryset", "crossref"); + addAllRequired("entryset", FieldName.CROSSREF); } @Override @@ -648,14 +648,14 @@ public String getName() { public static final BibLatexEntryType THESIS = new BibLatexEntryType() { private final List primaryOptionalFields = Collections - .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "chapter", "pages", "pagetotal", - FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "chapter", FieldName.PAGES, "pagetotal", + FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "type", "institution", "year/date"); - addAllOptional("subtitle", "titleaddon", "language", "note", "location", "month", FieldName.ISBN_FIELD, "chapter", - "pages", "pagetotal", "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "type", "institution", "year/date"); + addAllOptional("subtitle", "titleaddon", "language", "note", "location", "month", FieldName.ISBN, "chapter", + FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -673,13 +673,13 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType UNPUBLISHED = new BibLatexEntryType() { private final List primaryOptionalFields = Collections.unmodifiableList( - Arrays.asList("subtitle", "titleaddon", "howpublished", "pubstate", FieldName.URL_FIELD, "urldate")); + Arrays.asList("subtitle", "titleaddon", "howpublished", "pubstate", FieldName.URL, "urldate")); { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "year/date"); + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "year/date"); addAllOptional("subtitle", "titleaddon", "language", "howpublished", "note", "location", "month", - "addendum", "pubstate", FieldName.URL_FIELD, "urldate"); + "addendum", "pubstate", FieldName.URL, "urldate"); } @Override @@ -746,15 +746,15 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType MASTERSTHESIS = new BibLatexEntryType() { private final List primaryOptionalFields = Collections - .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "type", "chapter", "pages", - "pagetotal", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "type", "chapter", FieldName.PAGES, + "pagetotal", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { // Treated as alias of "THESIS", except "type" field is optional - addAllRequired(FieldName.AUTHOR_FIELD, "title", "institution", "year/date"); - addAllOptional("type", "subtitle", "titleaddon", "language", "note", "location", "month", FieldName.ISBN_FIELD, "chapter", - "pages", "pagetotal", "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "institution", "year/date"); + addAllOptional("type", "subtitle", "titleaddon", "language", "note", "location", "month", FieldName.ISBN, "chapter", + FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -772,15 +772,15 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType PHDTHESIS = new BibLatexEntryType() { private final List primaryOptionalFields = Collections - .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "type", "chapter", "pages", - "pagetotal", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + .unmodifiableList(Arrays.asList("subtitle", "titleaddon", "type", "chapter", FieldName.PAGES, + "pagetotal", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate")); { // Treated as alias of "THESIS", except "type" field is optional - addAllRequired(FieldName.AUTHOR_FIELD, "title", "institution", "year/date"); - addAllOptional("type", "subtitle", "titleaddon", "language", "note", "location", "month", FieldName.ISBN_FIELD, "chapter", - "pages", "pagetotal", "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "institution", "year/date"); + addAllOptional("type", "subtitle", "titleaddon", "language", "note", "location", "month", FieldName.ISBN, "chapter", + FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @@ -798,16 +798,16 @@ public List getPrimaryOptionalFields() { public static final BibLatexEntryType TECHREPORT = new BibLatexEntryType() { private final List primaryOptionalFields = Collections.unmodifiableList( - Arrays.asList("subtitle", "titleaddon", "type", "number", "isrn", "chapter", "pages", - "pagetotal", FieldName.DOI_FIELD, "eprint", "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate")); + Arrays.asList("subtitle", "titleaddon", "type", "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_FIELD, "title", "institution", "year/date"); + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "institution", "year/date"); addAllOptional("type", "subtitle", "titleaddon", "language", "number", "version", "note", "location", "month", - "isrn", "chapter", "pages", "pagetotal", "addendum", "pubstate", FieldName.DOI_FIELD, "eprint", - "eprintclass", "eprinttype", FieldName.URL_FIELD, "urldate"); + "isrn", "chapter", FieldName.PAGES, "pagetotal", "addendum", "pubstate", FieldName.DOI, "eprint", + "eprintclass", "eprinttype", FieldName.URL, "urldate"); } @Override 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 ea986003f7c0..6073f264afd7 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_FIELD, "title", "journal", FieldName.YEAR_FIELD); - addAllOptional("volume", "number", "pages", "month", "note"); + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "journal", FieldName.YEAR); + addAllOptional("volume", "number", FieldName.PAGES, "month", "note"); } @Override @@ -39,7 +39,7 @@ public String getName() { public static final EntryType BOOK = new BibtexEntryType() { { - addAllRequired("title", "publisher", FieldName.YEAR_FIELD, "author/editor"); + addAllRequired(FieldName.TITLE, "publisher", FieldName.YEAR, "author/editor"); addAllOptional("volume", "number", "series", "address", "edition", "month", "note"); } @@ -58,8 +58,8 @@ public String getName() { public static final EntryType BOOKLET = new BibtexEntryType() { { - addAllRequired("title"); - addAllOptional(FieldName.AUTHOR_FIELD, "howpublished", "address", "month", FieldName.YEAR_FIELD, "note"); + addAllRequired(FieldName.TITLE); + addAllOptional(FieldName.AUTHOR, "howpublished", "address", "month", FieldName.YEAR, "note"); } @Override @@ -77,8 +77,8 @@ public String getName() { public static final EntryType CONFERENCE = new BibtexEntryType() { { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "booktitle", FieldName.YEAR_FIELD); - addAllOptional(FieldName.EDITOR_FIELD, "volume", "number", "series", "pages", "address", "month", "organization", + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "booktitle", FieldName.YEAR); + addAllOptional(FieldName.EDITOR, "volume", "number", "series", FieldName.PAGES, "address", "month", "organization", "publisher", "note"); } @@ -97,7 +97,7 @@ public String getName() { public static final EntryType INBOOK = new BibtexEntryType() { { - addAllRequired("chapter/pages", "title", "publisher", FieldName.YEAR_FIELD, "author/editor"); + addAllRequired("chapter/pages", FieldName.TITLE, "publisher", FieldName.YEAR, "author/editor"); addAllOptional("volume", "number", "series", "type", "address", "edition", "month", "note"); } @@ -115,8 +115,8 @@ public String getName() { public static final EntryType INCOLLECTION = new BibtexEntryType() { { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "booktitle", "publisher", FieldName.YEAR_FIELD); - addAllOptional(FieldName.EDITOR_FIELD, "volume", "number", "series", "type", "chapter", "pages", "address", "edition", + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "booktitle", "publisher", FieldName.YEAR); + addAllOptional(FieldName.EDITOR, "volume", "number", "series", "type", "chapter", FieldName.PAGES, "address", "edition", "month", "note"); } @@ -135,8 +135,8 @@ public String getName() { public static final EntryType INPROCEEDINGS = new BibtexEntryType() { { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "booktitle", FieldName.YEAR_FIELD); - addAllOptional(FieldName.EDITOR_FIELD, "volume", "number", "series", "pages", "address", "month", "organization", + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "booktitle", FieldName.YEAR); + addAllOptional(FieldName.EDITOR, "volume", "number", "series", FieldName.PAGES, "address", "month", "organization", "publisher", "note"); } @@ -154,8 +154,8 @@ public String getName() { public static final EntryType MANUAL = new BibtexEntryType() { { - addAllRequired("title"); - addAllOptional(FieldName.AUTHOR_FIELD, "organization", "address", "edition", "month", FieldName.YEAR_FIELD, "note"); + addAllRequired(FieldName.TITLE); + addAllOptional(FieldName.AUTHOR, "organization", "address", "edition", "month", FieldName.YEAR, "note"); } @Override @@ -173,7 +173,7 @@ public String getName() { public static final EntryType MASTERSTHESIS = new BibtexEntryType() { { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "school", FieldName.YEAR_FIELD); + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "school", FieldName.YEAR); addAllOptional("type", "address", "month", "note"); } @@ -192,7 +192,7 @@ public String getName() { public static final EntryType MISC = new BibtexEntryType() { { - addAllOptional(FieldName.AUTHOR_FIELD, "title", "howpublished", "month", FieldName.YEAR_FIELD, "note"); + addAllOptional(FieldName.AUTHOR, FieldName.TITLE, "howpublished", "month", FieldName.YEAR, "note"); } @Override @@ -210,7 +210,7 @@ public String getName() { public static final EntryType PHDTHESIS = new BibtexEntryType() { { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "school", FieldName.YEAR_FIELD); + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "school", FieldName.YEAR); addAllOptional("type", "address", "month", "note"); } @@ -229,8 +229,8 @@ public String getName() { public static final EntryType PROCEEDINGS = new BibtexEntryType() { { - addAllRequired("title", FieldName.YEAR_FIELD); - addAllOptional(FieldName.EDITOR_FIELD, "volume", "number", "series", "address", "publisher", "note", "month", + addAllRequired(FieldName.TITLE, FieldName.YEAR); + addAllOptional(FieldName.EDITOR, "volume", "number", "series", "address", "publisher", "note", "month", "organization"); } @@ -249,7 +249,7 @@ public String getName() { public static final EntryType TECHREPORT = new BibtexEntryType() { { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "institution", FieldName.YEAR_FIELD); + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "institution", FieldName.YEAR); addAllOptional("type", "number", "address", "month", "note"); } @@ -268,8 +268,8 @@ public String getName() { public static final EntryType UNPUBLISHED = new BibtexEntryType() { { - addAllRequired(FieldName.AUTHOR_FIELD, "title", "note"); - addAllOptional("month", FieldName.YEAR_FIELD); + addAllRequired(FieldName.AUTHOR, FieldName.TITLE, "note"); + addAllOptional("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 f91fc805fed5..9632455c4542 100644 --- a/src/main/java/net/sf/jabref/model/entry/EntryConverter.java +++ b/src/main/java/net/sf/jabref/model/entry/EntryConverter.java @@ -22,7 +22,7 @@ public class EntryConverter { 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("key", "sortkey"); - EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put("pdf", FieldName.FILE_FIELD); + EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put("pdf", FieldName.FILE); EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put("primaryclass", "eprintclass"); EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put("school", "institution"); 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 a2e322f7d146..ead7e99d9f9b 100644 --- a/src/main/java/net/sf/jabref/model/entry/FieldName.java +++ b/src/main/java/net/sf/jabref/model/entry/FieldName.java @@ -3,18 +3,21 @@ public class FieldName { - public static final String ABSTRACT_FIELD = "abstract"; - public static final String AUTHOR_FIELD = "author"; - public static final String DATE_FIELD = "date"; - public static final String DOI_FIELD = "doi"; - public static final String EDITOR_FIELD = "editor"; - public static final String FILE_FIELD = "file"; - public static final String FOLDER_FIELD = "folder"; - public static final String ISBN_FIELD = "isbn"; - public static final String ISSN_FIELD = "issn"; - public static final String REVIEW_FIELD = "review"; - public static final String URL_FIELD = "url"; - public static final String YEAR_FIELD = "year"; + public static final String ABSTRACT = "abstract"; + public static final String AUTHOR = "author"; + public static final String CROSSREF = "crossref"; + public static final String DATE = "date"; + public static final String DOI = "doi"; + public static final String EDITOR = "editor"; + public static final String FILE = "file"; + public static final String FOLDER = "folder"; + public static final String ISBN = "isbn"; + public static final String ISSN = "issn"; + public static final String PAGES = "pages"; + public static final String REVIEW = "review"; + public static final String TITLE = "title"; + public static final String URL = "url"; + 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 8a3ac5a4b981..44a65127e241 100644 --- a/src/main/java/net/sf/jabref/model/entry/IEEETranEntryTypes.java +++ b/src/main/java/net/sf/jabref/model/entry/IEEETranEntryTypes.java @@ -20,8 +20,8 @@ public class IEEETranEntryTypes { public static final EntryType ELECTRONIC = new BibtexEntryType() { { - addAllOptional(FieldName.AUTHOR_FIELD, "month", FieldName.YEAR_FIELD, "title", "language", "howpublished", "organization", "address", - "note", FieldName.URL_FIELD); + addAllOptional(FieldName.AUTHOR, "month", FieldName.YEAR, FieldName.TITLE, "language", "howpublished", "organization", "address", + "note", FieldName.URL); } @@ -58,8 +58,8 @@ public String getName() { public static final EntryType PERIODICAL = new BibtexEntryType() { { - addAllRequired("title", FieldName.YEAR_FIELD); - addAllOptional(FieldName.EDITOR_FIELD, "language", "series", "volume", "number", "organization", "month", "note", FieldName.URL_FIELD); + addAllRequired(FieldName.TITLE, FieldName.YEAR); + addAllOptional(FieldName.EDITOR, "language", "series", "volume", "number", "organization", "month", "note", FieldName.URL); } @Override @@ -78,8 +78,8 @@ public String getName() { { addAllRequired("nationality", "number", "year/yearfiled"); - addAllOptional(FieldName.AUTHOR_FIELD, "title", "language", "assignee", "address", "type", "number", "day", "dayfiled", - "month", "monthfiled", "note", FieldName.URL_FIELD); + addAllOptional(FieldName.AUTHOR, FieldName.TITLE, "language", "assignee", "address", "type", "number", "day", "dayfiled", + "month", "monthfiled", "note", FieldName.URL); } @Override @@ -97,9 +97,9 @@ public String getName() { public static final EntryType STANDARD = new BibtexEntryType() { { - addAllRequired("title", "organization/institution"); - addAllOptional(FieldName.AUTHOR_FIELD, "language", "howpublished", "type", "number", "revision", "address", "month", - FieldName.YEAR_FIELD, "note", FieldName.URL_FIELD); + addAllRequired(FieldName.TITLE, "organization/institution"); + addAllOptional(FieldName.AUTHOR, "language", "howpublished", "type", "number", "revision", "address", "month", + FieldName.YEAR, "note", FieldName.URL); } @Override 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 f2fc07dee769..c3794481bcfe 100644 --- a/src/main/java/net/sf/jabref/model/entry/InternalBibtexFields.java +++ b/src/main/java/net/sf/jabref/model/entry/InternalBibtexFields.java @@ -68,8 +68,8 @@ public class InternalBibtexFields { "ctlnames_show_etal", "ctlalt_stretch_factor"); public static final List IEEETRANBSTCTL_YES_NO_FIELDS = Arrays.asList("ctluse_article_number", "ctluse_paper", "ctluse_url", "ctluse_forced_etal", "ctluse_alt_spacing", "ctldash_repeated_names"); - public static final List BIBLATEX_DATE_FIELDS = Arrays.asList(FieldName.DATE_FIELD, "eventdate", "origdate", "urldate"); - public static final List BIBLATEX_PERSON_NAME_FIELDS = Arrays.asList(FieldName.AUTHOR_FIELD, FieldName.EDITOR_FIELD, "editora", + public static final List BIBLATEX_DATE_FIELDS = Arrays.asList(FieldName.DATE, "eventdate", "origdate", "urldate"); + public static final List BIBLATEX_PERSON_NAME_FIELDS = Arrays.asList(FieldName.AUTHOR, FieldName.EDITOR, "editora", "editorb", "editorc", "translator", "annotator", "commentator", "introduction", "foreword", "afterword", "bookauthor", "holder", "shortauthor", "shorteditor", "sortname"); public static final List BIBLATEX_EDITOR_TYPE_FIELDS = Arrays.asList("editortype", "editoratype", @@ -93,14 +93,14 @@ private InternalBibtexFields(boolean serializeSpecialFields) { // but may be used by others that produce an annotated bibliography. // http://www.ecst.csuchico.edu/~jacobsd/bib/formats/bibtex.html add(new BibtexSingleField("annote", true, BibtexSingleField.LARGE_W)); - add(new BibtexSingleField(FieldName.AUTHOR_FIELD, true, BibtexSingleField.MEDIUM_W, 280)); + add(new BibtexSingleField(FieldName.AUTHOR, true, BibtexSingleField.MEDIUM_W, 280)); add(new BibtexSingleField("booktitle", true, 175)); add(new BibtexSingleField("chapter", true, BibtexSingleField.SMALL_W)); - dummy = new BibtexSingleField("crossref", true, BibtexSingleField.SMALL_W); + dummy = new BibtexSingleField(FieldName.CROSSREF, true, BibtexSingleField.SMALL_W); dummy.setExtras(EnumSet.of(FieldProperties.CROSSREF)); add(dummy); add(new BibtexSingleField("edition", true, BibtexSingleField.SMALL_W)); - add(new BibtexSingleField(FieldName.EDITOR_FIELD, true, BibtexSingleField.MEDIUM_W, 280)); + add(new BibtexSingleField(FieldName.EDITOR, true, BibtexSingleField.MEDIUM_W, 280)); add(new BibtexSingleField("howpublished", true, BibtexSingleField.MEDIUM_W)); add(new BibtexSingleField("institution", true, BibtexSingleField.MEDIUM_W)); @@ -118,17 +118,17 @@ private InternalBibtexFields(boolean serializeSpecialFields) { add(new BibtexSingleField("note", true, BibtexSingleField.MEDIUM_W)); add(new BibtexSingleField("number", true, BibtexSingleField.SMALL_W, 60).setNumeric(true)); add(new BibtexSingleField("organization", true, BibtexSingleField.MEDIUM_W)); - add(new BibtexSingleField("pages", true, BibtexSingleField.SMALL_W)); + add(new BibtexSingleField(FieldName.PAGES, true, BibtexSingleField.SMALL_W)); add(new BibtexSingleField("publisher", true, BibtexSingleField.MEDIUM_W)); add(new BibtexSingleField("school", true, BibtexSingleField.MEDIUM_W)); add(new BibtexSingleField("series", true, BibtexSingleField.SMALL_W)); - add(new BibtexSingleField("title", true, 400)); + add(new BibtexSingleField(FieldName.TITLE, true, 400)); dummy = new BibtexSingleField("type", true, BibtexSingleField.SMALL_W); 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.YEAR_FIELD, 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 dummy = new BibtexSingleField(SpecialFieldsUtils.FIELDNAME_RANKING, false); @@ -179,12 +179,12 @@ private InternalBibtexFields(boolean serializeSpecialFields) { dummy.setPrivate(); add(dummy); - dummy = new BibtexSingleField(FieldName.DOI_FIELD, true, BibtexSingleField.SMALL_W); + dummy = new BibtexSingleField(FieldName.DOI, true, BibtexSingleField.SMALL_W); dummy.setExtras(EnumSet.of(FieldProperties.DOI)); add(dummy); add(new BibtexSingleField("eid", true, BibtexSingleField.SMALL_W)); - dummy = new BibtexSingleField(FieldName.DATE_FIELD, true); + dummy = new BibtexSingleField(FieldName.DATE, true); dummy.setPrivate(); add(dummy); @@ -192,16 +192,16 @@ private InternalBibtexFields(boolean serializeSpecialFields) { // additional fields ------------------------------------------------------ add(new BibtexSingleField("location", false)); - add(new BibtexSingleField(FieldName.ABSTRACT_FIELD, false, BibtexSingleField.LARGE_W, 400)); + add(new BibtexSingleField(FieldName.ABSTRACT, false, BibtexSingleField.LARGE_W, 400)); - dummy = new BibtexSingleField(FieldName.URL_FIELD, false, BibtexSingleField.SMALL_W); + dummy = new BibtexSingleField(FieldName.URL, false, BibtexSingleField.SMALL_W); dummy.setExtras(EnumSet.of(FieldProperties.EXTERNAL)); add(dummy); add(new BibtexSingleField("comment", false, BibtexSingleField.MEDIUM_W)); add(new BibtexSingleField("keywords", false, BibtexSingleField.SMALL_W)); - dummy = new BibtexSingleField(FieldName.FILE_FIELD, false); + dummy = new BibtexSingleField(FieldName.FILE, false); dummy.setExtras(EnumSet.of(FieldProperties.FILE_EDITOR)); add(dummy); diff --git a/src/main/java/net/sf/jabref/pdfimport/PdfImporter.java b/src/main/java/net/sf/jabref/pdfimport/PdfImporter.java index 62a5c9c75bb6..0b8e1e778676 100644 --- a/src/main/java/net/sf/jabref/pdfimport/PdfImporter.java +++ b/src/main/java/net/sf/jabref/pdfimport/PdfImporter.java @@ -216,7 +216,7 @@ private void doXMPImport(String fileName, List res) { tm.addEntry(0, new FileListEntry(toLink.getName(), FileUtil.shortenFileName(toLink, dirsS).getPath(), ExternalFileTypes.getInstance().getExternalFileTypeByName("PDF"))); - entry.setField(FieldName.FILE_FIELD, tm.getStringRepresentation()); + entry.setField(FieldName.FILE, tm.getStringRepresentation()); res.add(entry); } diff --git a/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java b/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java index 38e9f341ed61..7c1ae32cb1e8 100644 --- a/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java @@ -359,13 +359,13 @@ public class JabRefPreferences { CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX); List activeFormatterCleanups = new ArrayList<>(); - activeFormatterCleanups.add(new FieldFormatterCleanup("pages", new NormalizePagesFormatter())); - activeFormatterCleanups.add(new FieldFormatterCleanup(FieldName.DATE_FIELD, new NormalizeDateFormatter())); + 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("title", new ProtectTermsFormatter())); - activeFormatterCleanups.add(new FieldFormatterCleanup("title", new UnitsToLatexFormatter())); - activeFormatterCleanups.add(new FieldFormatterCleanup("title", new LatexCleanupFormatter())); - activeFormatterCleanups.add(new FieldFormatterCleanup("title", new HtmlToLatexFormatter())); + activeFormatterCleanups.add(new FieldFormatterCleanup(FieldName.TITLE, new ProtectTermsFormatter())); + activeFormatterCleanups.add(new FieldFormatterCleanup(FieldName.TITLE, new UnitsToLatexFormatter())); + activeFormatterCleanups.add(new FieldFormatterCleanup(FieldName.TITLE, new LatexCleanupFormatter())); + activeFormatterCleanups.add(new FieldFormatterCleanup(FieldName.TITLE, new HtmlToLatexFormatter())); FieldFormatterCleanups formatterCleanups = new FieldFormatterCleanups(true, activeFormatterCleanups); CLEANUP_DEFAULT_PRESET = new CleanupPreset(EnumSet.complementOf(deactivedJobs), formatterCleanups); } @@ -536,11 +536,11 @@ private JabRefPreferences() { defaults.put(LANGUAGE, Locale.getDefault().getLanguage()); // Sorting preferences - defaults.put(TABLE_PRIMARY_SORT_FIELD, FieldName.AUTHOR_FIELD); + defaults.put(TABLE_PRIMARY_SORT_FIELD, FieldName.AUTHOR); defaults.put(TABLE_PRIMARY_SORT_DESCENDING, Boolean.FALSE); - defaults.put(TABLE_SECONDARY_SORT_FIELD, FieldName.YEAR_FIELD); + defaults.put(TABLE_SECONDARY_SORT_FIELD, FieldName.YEAR); defaults.put(TABLE_SECONDARY_SORT_DESCENDING, Boolean.TRUE); - defaults.put(TABLE_TERTIARY_SORT_FIELD, "title"); + defaults.put(TABLE_TERTIARY_SORT_FIELD, FieldName.TITLE); defaults.put(TABLE_TERTIARY_SORT_DESCENDING, Boolean.FALSE); defaults.put(REFORMAT_FILE_ON_SAVE_AND_EXPORT, Boolean.FALSE); @@ -552,9 +552,9 @@ private JabRefPreferences() { // export order: if EXPORT_IN_SPECIFIED_ORDER, then use following criteria defaults.put(EXPORT_PRIMARY_SORT_FIELD, "bibtexkey"); defaults.put(EXPORT_PRIMARY_SORT_DESCENDING, Boolean.FALSE); - defaults.put(EXPORT_SECONDARY_SORT_FIELD, FieldName.AUTHOR_FIELD); + defaults.put(EXPORT_SECONDARY_SORT_FIELD, FieldName.AUTHOR); defaults.put(EXPORT_SECONDARY_SORT_DESCENDING, Boolean.FALSE); - defaults.put(EXPORT_TERTIARY_SORT_FIELD, "title"); + defaults.put(EXPORT_TERTIARY_SORT_FIELD, FieldName.TITLE); defaults.put(EXPORT_TERTIARY_SORT_DESCENDING, Boolean.TRUE); defaults.put(NEWLINE, System.lineSeparator()); @@ -770,7 +770,7 @@ private JabRefPreferences() { // TODO: Currently not possible to edit this setting: defaults.put(PREVIEW_PRINT_BUTTON, Boolean.FALSE); - defaults.put(DO_NOT_RESOLVE_STRINGS_FOR, FieldName.URL_FIELD); + defaults.put(DO_NOT_RESOLVE_STRINGS_FOR, FieldName.URL); defaults.put(RESOLVE_STRINGS_ALL_FIELDS, Boolean.FALSE); defaults.put(NON_WRAPPABLE_FIELDS, "pdf;ps;url;doi;file"); defaults.put(GENERATE_KEYS_AFTER_INSPECTION, Boolean.TRUE); @@ -913,11 +913,11 @@ public void setLanguageDependentDefaultValues() { + "comment;owner;timestamp"); // Entry editor tab 1: - defaults.put(CUSTOM_TAB_FIELDS + "_def1", FieldName.ABSTRACT_FIELD); + defaults.put(CUSTOM_TAB_FIELDS + "_def1", FieldName.ABSTRACT); defaults.put(CUSTOM_TAB_NAME + "_def1", Localization.lang("Abstract")); // Entry editor tab 2: Review Field - used for research comments, etc. - defaults.put(CUSTOM_TAB_FIELDS + "_def2", FieldName.REVIEW_FIELD); + defaults.put(CUSTOM_TAB_FIELDS + "_def2", FieldName.REVIEW); defaults.put(CUSTOM_TAB_NAME + "_def2", Localization.lang("Review")); defaults.put(EMAIL_SUBJECT, Localization.lang("References"));