From 68ea6c871eadc8453006e510072cb7446d9c7e9c Mon Sep 17 00:00:00 2001 From: Linus Dietz Date: Wed, 22 Feb 2017 18:55:57 +0100 Subject: [PATCH 1/2] Added Locale.ROOT to toUpper/toLower Methods --- src/main/java/org/jabref/gui/BasePanel.java | 3 ++- .../org/jabref/gui/GenFieldsCustomizer.java | 3 ++- .../org/jabref/gui/ReplaceStringDialog.java | 3 ++- .../org/jabref/gui/SaveOrderConfigDisplay.java | 3 ++- .../jabref/gui/actions/MassSetFieldAction.java | 3 ++- .../org/jabref/gui/actions/SortTabsAction.java | 3 ++- .../bibtexkeypattern/BibtexKeyPatternPanel.java | 5 +++-- .../gui/customentrytypes/EntryTypeList.java | 3 ++- .../gui/customentrytypes/FieldSetComponent.java | 3 ++- .../org/jabref/gui/desktop/JabRefDesktop.java | 3 ++- .../java/org/jabref/gui/desktop/os/Linux.java | 3 ++- .../gui/entryeditor/FieldExtraComponents.java | 3 ++- .../gui/entryeditor/FileAnnotationTab.java | 3 ++- .../jabref/gui/exporter/ExportFileFilter.java | 3 ++- .../externalfiletype/ExternalFileMenuItem.java | 3 ++- .../gui/externalfiletype/ExternalFileTypes.java | 3 ++- .../org/jabref/gui/groups/AutoGroupDialog.java | 3 ++- .../gui/groups/WarnAssignmentSideEffects.java | 5 +++-- .../gui/importer/EntryFromPDFCreator.java | 3 ++- .../gui/importer/fetcher/IEEEXploreFetcher.java | 3 ++- .../jabref/gui/keyboard/EmacsKeyBindings.java | 9 +++++---- .../org/jabref/gui/maintable/MainTable.java | 7 ++++--- .../maintable/MainTableSelectionListener.java | 3 ++- .../PersistenceTableColumnListener.java | 3 ++- .../jabref/gui/preftabs/TableColumnsTab.java | 7 ++++--- .../org/jabref/gui/preftabs/TablePrefsTab.java | 7 ++++--- .../autocompleter/AbstractAutoCompleter.java | 5 +++-- .../autocompleter/NameFieldAutoCompleter.java | 3 ++- .../org/jabref/logic/bibtex/BibEntryWriter.java | 3 ++- .../comparator/BibtexStringComparator.java | 9 +++++---- .../bibtex/comparator/EntryComparator.java | 9 +++++---- .../org/jabref/logic/bst/BibtexCaseChanger.java | 7 ++++--- .../jabref/logic/bst/BibtexNameFormatter.java | 3 ++- .../jabref/logic/bst/ChangeCaseFunction.java | 3 ++- .../logic/formatter/casechanger/Word.java | 3 ++- .../jabref/logic/importer/MimeTypeDetector.java | 3 ++- .../fileformat/BiblioscapeImporter.java | 3 ++- .../logic/importer/fileformat/BibtexParser.java | 5 +++-- .../logic/importer/fileformat/IsiImporter.java | 9 +++++---- .../importer/fileformat/MrDLibImporter.java | 3 ++- .../importer/fileformat/PdfContentImporter.java | 5 +++-- .../fileformat/SilverPlatterImporter.java | 5 +++-- .../logic/integrity/PersonNamesChecker.java | 3 ++- .../org/jabref/logic/layout/LayoutHelper.java | 3 ++- .../org/jabref/logic/layout/format/Authors.java | 9 +++++---- .../logic/layout/format/Iso690NamesAuthors.java | 12 +++++++----- .../jabref/logic/layout/format/RisMonth.java | 4 +++- .../jabref/logic/layout/format/ToLowerCase.java | 4 +++- .../jabref/logic/layout/format/ToUpperCase.java | 4 +++- .../jabref/logic/net/ProxyAuthenticator.java | 3 ++- .../logic/pdf/EntryAnnotationImporter.java | 3 ++- .../java/org/jabref/logic/util/BuildInfo.java | 7 ++++--- src/main/java/org/jabref/logic/util/OS.java | 4 +++- .../java/org/jabref/logic/util/io/FileUtil.java | 7 ++++--- .../java/org/jabref/model/DuplicateCheck.java | 17 +++++++++-------- src/main/java/org/jabref/model/EntryTypes.java | 15 ++++++++------- .../java/org/jabref/model/entry/AuthorList.java | 2 +- .../jabref/model/entry/AuthorListParser.java | 3 ++- .../org/jabref/model/entry/BibtexString.java | 3 ++- .../search/rules/ContainBasedSearchRule.java | 5 +++-- .../search/rules/RegexBasedSearchRule.java | 3 ++- .../org/jabref/model/strings/StringUtil.java | 9 +++++---- .../java/org/jabref/pdfimport/PdfImporter.java | 3 ++- .../java/org/jabref/shared/DBMSProcessor.java | 2 +- 64 files changed, 185 insertions(+), 118 deletions(-) diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index a163d9c6db1..1c5a3276aab 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -21,6 +21,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -1104,7 +1105,7 @@ public BibEntry newEntry(EntryType type) { // Create an UndoableInsertEntry object. getUndoManager().addEdit(new UndoableInsertEntry(bibDatabaseContext.getDatabase(), be, BasePanel.this)); - output(Localization.lang("Added new '%0' entry.", actualType.getName().toLowerCase())); + output(Localization.lang("Added new '%0' entry.", actualType.getName().toLowerCase(Locale.ROOT))); // We are going to select the new entry. Before that, make sure that we are in // show-entry mode. If we aren't already in that mode, enter the WILL_SHOW_EDITOR diff --git a/src/main/java/org/jabref/gui/GenFieldsCustomizer.java b/src/main/java/org/jabref/gui/GenFieldsCustomizer.java index e3b6b068194..5dade80b8d3 100644 --- a/src/main/java/org/jabref/gui/GenFieldsCustomizer.java +++ b/src/main/java/org/jabref/gui/GenFieldsCustomizer.java @@ -6,6 +6,7 @@ import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; +import java.util.Locale; import javax.swing.AbstractAction; import javax.swing.ActionMap; @@ -131,7 +132,7 @@ private void okActionPerformed() { } Globals.prefs.put((JabRefPreferences.CUSTOM_TAB_NAME + i), parts[0]); - Globals.prefs.put((JabRefPreferences.CUSTOM_TAB_FIELDS + i), parts[1].toLowerCase()); + Globals.prefs.put((JabRefPreferences.CUSTOM_TAB_FIELDS + i), parts[1].toLowerCase(Locale.ROOT)); } Globals.prefs.purgeSeries(JabRefPreferences.CUSTOM_TAB_NAME, i); Globals.prefs.purgeSeries(JabRefPreferences.CUSTOM_TAB_FIELDS, i); diff --git a/src/main/java/org/jabref/gui/ReplaceStringDialog.java b/src/main/java/org/jabref/gui/ReplaceStringDialog.java index 2363debb1f5..ff3068e1cec 100644 --- a/src/main/java/org/jabref/gui/ReplaceStringDialog.java +++ b/src/main/java/org/jabref/gui/ReplaceStringDialog.java @@ -6,6 +6,7 @@ import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.Locale; import javax.swing.AbstractAction; import javax.swing.ActionMap; @@ -59,7 +60,7 @@ public ReplaceStringDialog(JabRefFrame parent) { return; } okPressed = true; - fieldStrings = fieldsField.getText().toLowerCase().split(";"); + fieldStrings = fieldsField.getText().toLowerCase(Locale.ROOT).split(";"); dispose(); }; JButton ok = new JButton(Localization.lang("OK")); diff --git a/src/main/java/org/jabref/gui/SaveOrderConfigDisplay.java b/src/main/java/org/jabref/gui/SaveOrderConfigDisplay.java index 1f837df6c9e..a2d8d023174 100644 --- a/src/main/java/org/jabref/gui/SaveOrderConfigDisplay.java +++ b/src/main/java/org/jabref/gui/SaveOrderConfigDisplay.java @@ -3,6 +3,7 @@ import java.awt.Component; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Objects; import javax.swing.JCheckBox; @@ -104,6 +105,6 @@ public SaveOrderConfig getSaveOrderConfig() { } private String getSelectedItemAsLowerCaseTrim(JComboBox sortBox) { - return sortBox.getSelectedItem().toString().toLowerCase().trim(); + return sortBox.getSelectedItem().toString().toLowerCase(Locale.ROOT).trim(); } } diff --git a/src/main/java/org/jabref/gui/actions/MassSetFieldAction.java b/src/main/java/org/jabref/gui/actions/MassSetFieldAction.java index 0060f86abf6..0c01238ce53 100644 --- a/src/main/java/org/jabref/gui/actions/MassSetFieldAction.java +++ b/src/main/java/org/jabref/gui/actions/MassSetFieldAction.java @@ -4,6 +4,7 @@ import java.awt.event.ActionEvent; import java.util.Collection; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.Set; @@ -223,7 +224,7 @@ public void actionPerformed(ActionEvent e) { toSet = null; } - String[] fields = getFieldNames(((String) field.getSelectedItem()).trim().toLowerCase()); + String[] fields = getFieldNames(((String) field.getSelectedItem()).trim().toLowerCase(Locale.ROOT)); NamedCompound ce = new NamedCompound(Localization.lang("Set field")); if (rename.isSelected()) { if (fields.length > 1) { diff --git a/src/main/java/org/jabref/gui/actions/SortTabsAction.java b/src/main/java/org/jabref/gui/actions/SortTabsAction.java index 46456ef3d74..55f2432b0ce 100644 --- a/src/main/java/org/jabref/gui/actions/SortTabsAction.java +++ b/src/main/java/org/jabref/gui/actions/SortTabsAction.java @@ -2,6 +2,7 @@ import java.awt.event.ActionEvent; import java.util.Comparator; +import java.util.Locale; import java.util.Map; import java.util.TreeMap; @@ -41,6 +42,6 @@ public void actionPerformed(ActionEvent e) { @Override public int compare(String o1, String o2) { - return o1.toLowerCase().compareTo(o2.toLowerCase()); + return o1.toLowerCase(Locale.ROOT).compareTo(o2.toLowerCase(Locale.ROOT)); } } diff --git a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternPanel.java b/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternPanel.java index 3badfe7caac..7451b53787c 100644 --- a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternPanel.java +++ b/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternPanel.java @@ -7,6 +7,7 @@ import java.awt.GridBagLayout; import java.awt.Insets; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import javax.swing.BorderFactory; @@ -111,7 +112,7 @@ private void buildGUI() { } for (EntryType type : EntryTypes.getAllValues(mode)) { - textFields.put(type.getName().toLowerCase(), addEntryType(pan, type, y)); + textFields.put(type.getName().toLowerCase(Locale.ROOT), addEntryType(pan, type, y)); y++; } @@ -194,7 +195,7 @@ private JTextField addEntryType(Container c, EntryType type, int y) { con.anchor = GridBagConstraints.CENTER; con.insets = new Insets(0, 5, 0, 5); gbl.setConstraints(but, con); - but.setActionCommand(type.getName().toLowerCase()); + but.setActionCommand(type.getName().toLowerCase(Locale.ROOT)); but.addActionListener(e -> { JTextField tField = textFields.get(e.getActionCommand()); tField.setText(""); diff --git a/src/main/java/org/jabref/gui/customentrytypes/EntryTypeList.java b/src/main/java/org/jabref/gui/customentrytypes/EntryTypeList.java index e2a63c4154d..b456654cfff 100644 --- a/src/main/java/org/jabref/gui/customentrytypes/EntryTypeList.java +++ b/src/main/java/org/jabref/gui/customentrytypes/EntryTypeList.java @@ -3,6 +3,7 @@ import java.awt.GridBagConstraints; import java.awt.event.ActionListener; import java.util.List; +import java.util.Locale; import java.util.Optional; import javax.swing.JButton; @@ -50,7 +51,7 @@ public EntryTypeList(List fields, BibDatabaseMode mode) { protected void addField(String str) { String s = str.trim(); if (forceLowerCase) { - s = s.toLowerCase(); + s = s.toLowerCase(Locale.ROOT); } if ("".equals(s) || listModel.contains(s)) { return; diff --git a/src/main/java/org/jabref/gui/customentrytypes/FieldSetComponent.java b/src/main/java/org/jabref/gui/customentrytypes/FieldSetComponent.java index 4603cc4cb3e..ab0597f3be1 100644 --- a/src/main/java/org/jabref/gui/customentrytypes/FieldSetComponent.java +++ b/src/main/java/org/jabref/gui/customentrytypes/FieldSetComponent.java @@ -13,6 +13,7 @@ import java.util.Enumeration; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import javax.swing.Box; @@ -235,7 +236,7 @@ public void setFields(List fields) { protected void addField(String str) { String s = str.trim(); if (forceLowerCase) { - s = s.toLowerCase(); + s = s.toLowerCase(Locale.ROOT); } if ("".equals(s) || listModel.contains(s)) { return; diff --git a/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java b/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java index ec72db7efd2..1de93224512 100644 --- a/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java +++ b/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.regex.Pattern; @@ -136,7 +137,7 @@ public static boolean openExternalFileAnyFormat(final BibDatabaseContext databas final Optional type) throws IOException { boolean httpLink = false; - if (REMOTE_LINK_PATTERN.matcher(link.toLowerCase()).matches()) { + if (REMOTE_LINK_PATTERN.matcher(link.toLowerCase(Locale.ROOT)).matches()) { httpLink = true; } diff --git a/src/main/java/org/jabref/gui/desktop/os/Linux.java b/src/main/java/org/jabref/gui/desktop/os/Linux.java index b8f4f57696f..ea0c3c432a1 100644 --- a/src/main/java/org/jabref/gui/desktop/os/Linux.java +++ b/src/main/java/org/jabref/gui/desktop/os/Linux.java @@ -6,6 +6,7 @@ import java.io.InputStreamReader; import java.nio.file.Paths; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.StringJoiner; @@ -49,7 +50,7 @@ public void openFileWithApplication(String filePath, String application) throws @Override public void openFolderAndSelectFile(String filePath) throws IOException { - String desktopSession = System.getenv("DESKTOP_SESSION").toLowerCase(); + String desktopSession = System.getenv("DESKTOP_SESSION").toLowerCase(Locale.ROOT); String cmd; diff --git a/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java b/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java index e6a519b2288..43ec2cf9a38 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java +++ b/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java @@ -8,6 +8,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.Locale; import java.util.Optional; import java.util.Set; @@ -337,7 +338,7 @@ public static Optional getYesNoExtraComponent(FieldEditor fieldEdito final String[] options = {"", "Yes", "No"}; JComboBox yesno = new JComboBox<>(options); yesno.addActionListener(actionEvent -> { - fieldEditor.setText(((String) yesno.getSelectedItem()).toLowerCase()); + fieldEditor.setText(((String) yesno.getSelectedItem()).toLowerCase(Locale.ROOT)); entryEditor.updateField(fieldEditor); }); return Optional.of(yesno); diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.java b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.java index b0ba6a6b9a7..19483c75e4e 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.java @@ -6,6 +6,7 @@ import java.util.Arrays; import java.util.Comparator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.StringJoiner; @@ -168,7 +169,7 @@ private void updateFileNameComboBox() { indexSelectedByComboBox = fileNameComboBox.getSelectedIndex(); } fileNameComboBox.removeAllItems(); - new EntryAnnotationImporter(parent.getEntry()).getFilteredFileList().stream().filter(parsedFileField -> parsedFileField.getLink().toLowerCase().endsWith(".pdf")) + new EntryAnnotationImporter(parent.getEntry()).getFilteredFileList().stream().filter(parsedFileField -> parsedFileField.getLink().toLowerCase(Locale.ROOT).endsWith(".pdf")) .forEach(((parsedField) -> fileNameComboBox.addItem(parsedField.getLink()))); fileNameComboBox.setSelectedIndex(indexSelectedByComboBox); updateShownAnnotations(annotationsOfFiles.get(fileNameComboBox.getSelectedItem().toString())); diff --git a/src/main/java/org/jabref/gui/exporter/ExportFileFilter.java b/src/main/java/org/jabref/gui/exporter/ExportFileFilter.java index db87f47c1aa..88022ce77b3 100644 --- a/src/main/java/org/jabref/gui/exporter/ExportFileFilter.java +++ b/src/main/java/org/jabref/gui/exporter/ExportFileFilter.java @@ -1,6 +1,7 @@ package org.jabref.gui.exporter; import java.io.File; +import java.util.Locale; import javax.swing.filechooser.FileFilter; @@ -37,7 +38,7 @@ public boolean accept(File file) { if (file.isDirectory()) { return true; } else { - return file.getPath().toLowerCase().endsWith(extension); + return file.getPath().toLowerCase(Locale.ROOT).endsWith(extension); } } diff --git a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileMenuItem.java b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileMenuItem.java index a062eb32f98..a283e0fe766 100644 --- a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileMenuItem.java +++ b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileMenuItem.java @@ -4,6 +4,7 @@ import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; +import java.util.Locale; import java.util.Optional; import javax.swing.Icon; @@ -73,7 +74,7 @@ public boolean openLink() { String name = file.getName(); int pos = name.indexOf('.'); String extension = (pos >= 0) && (pos < (name.length() - 1)) ? name.substring(pos + 1) - .trim().toLowerCase() : null; + .trim().toLowerCase(Locale.ROOT) : null; // Now we know the extension, check if it is one we know about: type = ExternalFileTypes.getInstance().getExternalFileTypeByExt(extension); fileType = type; diff --git a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java index 9244461827c..5e24f6e5e04 100644 --- a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java +++ b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.Set; import java.util.TreeSet; @@ -178,7 +179,7 @@ public Optional getExternalFileTypeForName(String filename) { int longestFound = -1; ExternalFileType foundType = null; for (ExternalFileType type : externalFileTypes) { - if (!type.getExtension().isEmpty() && filename.toLowerCase().endsWith(type.getExtension().toLowerCase()) + if (!type.getExtension().isEmpty() && filename.toLowerCase(Locale.ROOT).endsWith(type.getExtension().toLowerCase(Locale.ROOT)) && (type.getExtension().length() > longestFound)) { longestFound = type.getExtension().length(); foundType = type; diff --git a/src/main/java/org/jabref/gui/groups/AutoGroupDialog.java b/src/main/java/org/jabref/gui/groups/AutoGroupDialog.java index 0fe42dd5b6d..ca8628f5ced 100644 --- a/src/main/java/org/jabref/gui/groups/AutoGroupDialog.java +++ b/src/main/java/org/jabref/gui/groups/AutoGroupDialog.java @@ -5,6 +5,7 @@ import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.Set; import java.util.StringTokenizer; @@ -90,7 +91,7 @@ public AutoGroupDialog(JabRefFrame jabrefFrame, BasePanel basePanel, GroupHierarchyType.INCLUDING, Globals.prefs.getKeywordDelimiter())); Set keywords; - String fieldText = field.getText().toLowerCase().trim(); + String fieldText = field.getText().toLowerCase(Locale.ROOT).trim(); if (this.keywords.isSelected()) { if (useCustomDelimiter.isSelected()) { keywords = findDeliminatedWordsInField(panel.getDatabase(), fieldText, diff --git a/src/main/java/org/jabref/gui/groups/WarnAssignmentSideEffects.java b/src/main/java/org/jabref/gui/groups/WarnAssignmentSideEffects.java index 77f83b6c7ea..749a350d135 100644 --- a/src/main/java/org/jabref/gui/groups/WarnAssignmentSideEffects.java +++ b/src/main/java/org/jabref/gui/groups/WarnAssignmentSideEffects.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Locale; import javax.swing.JOptionPane; @@ -30,7 +31,7 @@ public static boolean warnAssignmentSideEffects(List groups, Comp for (AbstractGroup group : groups) { if (group instanceof KeywordGroup) { KeywordGroup keywordGroup = (KeywordGroup) group; - String field = keywordGroup.getSearchField().toLowerCase(); + String field = keywordGroup.getSearchField().toLowerCase(Locale.ROOT); if (FieldName.KEYWORDS.equals(field) || FieldName.GROUPS.equals(field)) { continue; // this is not undesired } @@ -62,7 +63,7 @@ public static boolean warnAssignmentSideEffects(List groups, Comp // if (groups instanceof KeywordGroup) { // KeywordGroup kg = (KeywordGroup) groups; - // String field = kg.getSearchField().toLowerCase(); + // String field = kg.getSearchField().toLowerCase(Locale.ROOT); // if (field.equals("keywords")) // return true; // this is not undesired // for (int i = 0; i < GUIGlobals.ALL_FIELDS.length; ++i) { diff --git a/src/main/java/org/jabref/gui/importer/EntryFromPDFCreator.java b/src/main/java/org/jabref/gui/importer/EntryFromPDFCreator.java index e1be8ded99c..b51cec5860a 100644 --- a/src/main/java/org/jabref/gui/importer/EntryFromPDFCreator.java +++ b/src/main/java/org/jabref/gui/importer/EntryFromPDFCreator.java @@ -7,6 +7,7 @@ import java.util.Calendar; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Optional; import org.jabref.Globals; @@ -50,7 +51,7 @@ private static ExternalFileType getPDFExternalFileType() { */ @Override public boolean accept(File f) { - return (f != null) && f.getName().toUpperCase().endsWith(".PDF"); + return (f != null) && f.getName().toUpperCase(Locale.ROOT).endsWith(".PDF"); } @Override diff --git a/src/main/java/org/jabref/gui/importer/fetcher/IEEEXploreFetcher.java b/src/main/java/org/jabref/gui/importer/fetcher/IEEEXploreFetcher.java index 5109975ddcf..40133e8eff6 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/IEEEXploreFetcher.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/IEEEXploreFetcher.java @@ -9,6 +9,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Objects; import java.util.Optional; import java.util.regex.Matcher; @@ -297,7 +298,7 @@ private BibEntry cleanup(BibEntry entry) { // clean up month entry.getField(FieldName.MONTH).filter(month -> !month.isEmpty()).ifPresent(dirtyMonth -> { String month = dirtyMonth.replace(".", ""); - month = month.toLowerCase(); + month = month.toLowerCase(Locale.ROOT); Matcher mm = MONTH_PATTERN.matcher(month); StringBuilder date = new StringBuilder(month); diff --git a/src/main/java/org/jabref/gui/keyboard/EmacsKeyBindings.java b/src/main/java/org/jabref/gui/keyboard/EmacsKeyBindings.java index 47d7106ba26..3c2afe41a75 100644 --- a/src/main/java/org/jabref/gui/keyboard/EmacsKeyBindings.java +++ b/src/main/java/org/jabref/gui/keyboard/EmacsKeyBindings.java @@ -7,6 +7,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import javax.swing.Action; import javax.swing.JEditorPane; @@ -731,7 +732,7 @@ public void actionPerformed(ActionEvent event) jtc.setSelectionStart(start); jtc.setSelectionEnd(end); String word = jtc.getText(start, end - start); - jtc.replaceSelection(word.toLowerCase()); + jtc.replaceSelection(word.toLowerCase(Locale.ROOT)); /* actual capitalize code */ int offs = Utilities.getWordStart(jtc, start); @@ -747,7 +748,7 @@ public void actionPerformed(ActionEvent event) if (Character.isLetter(c.charAt(0))) { jtc.setSelectionStart(offs); jtc.setSelectionEnd(offs + 1); - jtc.replaceSelection(c.toUpperCase()); + jtc.replaceSelection(c.toUpperCase(Locale.ROOT)); } end = Utilities.getWordEnd(jtc, offs); jtc.setCaretPosition(end); @@ -782,7 +783,7 @@ public void actionPerformed(ActionEvent event) jtc.setSelectionStart(start); jtc.setSelectionEnd(end); String word = jtc.getText(start, end - start); - jtc.replaceSelection(word.toLowerCase()); + jtc.replaceSelection(word.toLowerCase(Locale.ROOT)); jtc.setCaretPosition(end); } catch (BadLocationException ble) { jtc.getToolkit().beep(); @@ -815,7 +816,7 @@ public void actionPerformed(ActionEvent event) jtc.setSelectionStart(start); jtc.setSelectionEnd(end); String word = jtc.getText(start, end - start); - jtc.replaceSelection(word.toUpperCase()); + jtc.replaceSelection(word.toUpperCase(Locale.ROOT)); jtc.setCaretPosition(end); } catch (BadLocationException ble) { jtc.getToolkit().beep(); diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java index e0f4e769fb9..6dfb83bb691 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTable.java +++ b/src/main/java/org/jabref/gui/maintable/MainTable.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.Locale; import java.util.Optional; import javax.swing.AbstractAction; @@ -372,7 +373,7 @@ private List getCurrentSortFields() { //TODO OLD // String name = tableFormat.getColumnType(i); if (name != null) { - fields.add(name.toLowerCase()); + fields.add(name.toLowerCase(Locale.ROOT)); } } return fields; @@ -403,7 +404,7 @@ private void setupComparatorChooser() { } else { comparators = comparatorChooser.getComparatorsForColumn(i); comparators.clear(); - comparators.add(new FieldComparator(tableFormat.getColumnName(i).toLowerCase())); + comparators.add(new FieldComparator(tableFormat.getColumnName(i).toLowerCase(Locale.ROOT))); } } @@ -483,7 +484,7 @@ private CellRendererMode getCellStatus(int row, int col, boolean checkResolved) } Optional type = EntryTypes.getType(be.getType(), panel.getBibDatabaseContext().getMode()); if (type.isPresent()) { - String columnName = getColumnName(col).toLowerCase(); + String columnName = getColumnName(col).toLowerCase(Locale.ROOT); if (columnName.equals(BibEntry.KEY_FIELD) || type.get().getRequiredFieldsFlat().contains(columnName)) { return CellRendererMode.REQUIRED; } diff --git a/src/main/java/org/jabref/gui/maintable/MainTableSelectionListener.java b/src/main/java/org/jabref/gui/maintable/MainTableSelectionListener.java index 19fcac5c5fa..326127b544d 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableSelectionListener.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableSelectionListener.java @@ -8,6 +8,7 @@ import java.awt.event.MouseListener; import java.io.IOException; import java.util.List; +import java.util.Locale; import java.util.Objects; import java.util.Optional; @@ -518,7 +519,7 @@ public void keyTyped(KeyEvent e) { if (o == null) { continue; } - String s = o.toString().toLowerCase(); + String s = o.toString().toLowerCase(Locale.ROOT); if (s.length() >= lastPressedCount) { for (int j = 0; j < lastPressedCount; j++) { if (s.charAt(j) != lastPressed[j]) { diff --git a/src/main/java/org/jabref/gui/maintable/PersistenceTableColumnListener.java b/src/main/java/org/jabref/gui/maintable/PersistenceTableColumnListener.java index cf31b53ebd8..dd2a8da0f6e 100644 --- a/src/main/java/org/jabref/gui/maintable/PersistenceTableColumnListener.java +++ b/src/main/java/org/jabref/gui/maintable/PersistenceTableColumnListener.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Locale; import javax.swing.event.ChangeEvent; import javax.swing.event.ListSelectionEvent; @@ -56,7 +57,7 @@ private void updateColumnPrefs() { if (FieldName.NUMBER_COL.equals(name)) { ncWidth = mainTable.getColumnModel().getColumn(i).getWidth(); } else { - storedColumns.add(name.toLowerCase()); + storedColumns.add(name.toLowerCase(Locale.ROOT)); columnsWidths.add(String.valueOf(mainTable.getColumnModel().getColumn(i).getWidth())); } } diff --git a/src/main/java/org/jabref/gui/preftabs/TableColumnsTab.java b/src/main/java/org/jabref/gui/preftabs/TableColumnsTab.java index 5bb49789ece..9d9ebe993cd 100644 --- a/src/main/java/org/jabref/gui/preftabs/TableColumnsTab.java +++ b/src/main/java/org/jabref/gui/preftabs/TableColumnsTab.java @@ -9,6 +9,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Locale; import javax.swing.AbstractAction; import javax.swing.Action; @@ -617,7 +618,7 @@ public void actionPerformed(ActionEvent e) { for (int i = 1; i < panel.getMainTable().getColumnCount(); i++) { String name = panel.getMainTable().getColumnName(i); if ((name != null) && !name.isEmpty()) { - map.put(name.toLowerCase(), i); + map.put(name.toLowerCase(Locale.ROOT), i); } } Collections.sort(tableRows, (o1, o2) -> { @@ -651,7 +652,7 @@ public void actionPerformed(ActionEvent e) { colSetup.setValueAt(String.valueOf(colMod.getColumn(0).getWidth()), 0, 1); for (int i = 1; i < colMod.getColumnCount(); i++) { try { - String name = panel.getMainTable().getColumnName(i).toLowerCase(); + String name = panel.getMainTable().getColumnName(i).toLowerCase(Locale.ROOT); int width = colMod.getColumn(i).getWidth(); if ((i <= tableRows.size()) && ((String) colSetup.getValueAt(i, 0)).equalsIgnoreCase(name)) { colSetup.setValueAt(String.valueOf(width), i, 1); @@ -770,7 +771,7 @@ public void storeSettings() { prefs.putInt(JabRefPreferences.NUMBER_COL_WIDTH, ncWidth); for (TableRow tr : tableRows) { - names.add(tr.getName().toLowerCase()); + names.add(tr.getName().toLowerCase(Locale.ROOT)); nWidths.add(tr.getLength()); widths.add(String.valueOf(tr.getLength())); } diff --git a/src/main/java/org/jabref/gui/preftabs/TablePrefsTab.java b/src/main/java/org/jabref/gui/preftabs/TablePrefsTab.java index bc822b6b6eb..6d73757e08d 100644 --- a/src/main/java/org/jabref/gui/preftabs/TablePrefsTab.java +++ b/src/main/java/org/jabref/gui/preftabs/TablePrefsTab.java @@ -3,6 +3,7 @@ import java.awt.BorderLayout; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Objects; import javax.swing.BorderFactory; @@ -271,9 +272,9 @@ public void storeSettings() { prefs.putBoolean(JabRefPreferences.TABLE_PRIMARY_SORT_DESCENDING, priDesc.isSelected()); prefs.putBoolean(JabRefPreferences.TABLE_SECONDARY_SORT_DESCENDING, secDesc.isSelected()); prefs.putBoolean(JabRefPreferences.TABLE_TERTIARY_SORT_DESCENDING, terDesc.isSelected()); - prefs.put(JabRefPreferences.TABLE_PRIMARY_SORT_FIELD, priField.getText().toLowerCase().trim()); - prefs.put(JabRefPreferences.TABLE_SECONDARY_SORT_FIELD, secField.getText().toLowerCase().trim()); - prefs.put(JabRefPreferences.TABLE_TERTIARY_SORT_FIELD, terField.getText().toLowerCase().trim()); + prefs.put(JabRefPreferences.TABLE_PRIMARY_SORT_FIELD, priField.getText().toLowerCase(Locale.ROOT).trim()); + prefs.put(JabRefPreferences.TABLE_SECONDARY_SORT_FIELD, secField.getText().toLowerCase(Locale.ROOT).trim()); + prefs.put(JabRefPreferences.TABLE_TERTIARY_SORT_FIELD, terField.getText().toLowerCase(Locale.ROOT).trim()); prefs.putBoolean(JabRefPreferences.FLOAT_MARKED_ENTRIES, floatMarked.isSelected()); // updatefont diff --git a/src/main/java/org/jabref/logic/autocompleter/AbstractAutoCompleter.java b/src/main/java/org/jabref/logic/autocompleter/AbstractAutoCompleter.java index a95de864a39..1ab5745edfe 100644 --- a/src/main/java/org/jabref/logic/autocompleter/AbstractAutoCompleter.java +++ b/src/main/java/org/jabref/logic/autocompleter/AbstractAutoCompleter.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; @@ -55,7 +56,7 @@ public List complete(String toComplete) { if (isTooShortToComplete(toComplete)) { return new ArrayList<>(); } - String lowerCase = toComplete.toLowerCase(); + String lowerCase = toComplete.toLowerCase(Locale.ROOT); if (lowerCase.equals(toComplete)) { // user typed in lower case word -> we do an case-insensitive search @@ -112,7 +113,7 @@ public void addItemToIndex(String word) { // insensitive treatment // first, add the lower cased word to search index // second, add a mapping from the lower cased word to the real word - String lowerCase = word.toLowerCase(); + String lowerCase = word.toLowerCase(Locale.ROOT); indexCaseInsensitive.add(lowerCase); Set set = possibleStringsForSearchString.get(lowerCase); if (set == null) { diff --git a/src/main/java/org/jabref/logic/autocompleter/NameFieldAutoCompleter.java b/src/main/java/org/jabref/logic/autocompleter/NameFieldAutoCompleter.java index 74c98f9ed6a..95b4ecb09e1 100644 --- a/src/main/java/org/jabref/logic/autocompleter/NameFieldAutoCompleter.java +++ b/src/main/java/org/jabref/logic/autocompleter/NameFieldAutoCompleter.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Objects; import org.jabref.model.entry.Author; @@ -93,7 +94,7 @@ public void addBibtexEntry(BibEntry entry) { */ private String determinePrefixAndReturnRemainder(String str, String delimiter) { String result = str; - int index = result.toLowerCase().lastIndexOf(delimiter); + int index = result.toLowerCase(Locale.ROOT).lastIndexOf(delimiter); if (index >= 0) { prefix = result.substring(0, index + delimiter.length()); result = result.substring(index + delimiter.length()); diff --git a/src/main/java/org/jabref/logic/bibtex/BibEntryWriter.java b/src/main/java/org/jabref/logic/bibtex/BibEntryWriter.java index 25f10d7f806..307629665fa 100644 --- a/src/main/java/org/jabref/logic/bibtex/BibEntryWriter.java +++ b/src/main/java/org/jabref/logic/bibtex/BibEntryWriter.java @@ -4,6 +4,7 @@ import java.io.Writer; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.Set; import java.util.TreeSet; @@ -183,6 +184,6 @@ private String getFieldDisplayName(String field, int intendation) { actualField = "UNKNOWN"; } - return actualField.toLowerCase() + StringUtil.repeatSpaces(intendation - actualField.length()) + " = "; + return actualField.toLowerCase(Locale.ROOT) + StringUtil.repeatSpaces(intendation - actualField.length()) + " = "; } } diff --git a/src/main/java/org/jabref/logic/bibtex/comparator/BibtexStringComparator.java b/src/main/java/org/jabref/logic/bibtex/comparator/BibtexStringComparator.java index 42ac89ea948..312a4f51af6 100644 --- a/src/main/java/org/jabref/logic/bibtex/comparator/BibtexStringComparator.java +++ b/src/main/java/org/jabref/logic/bibtex/comparator/BibtexStringComparator.java @@ -1,6 +1,7 @@ package org.jabref.logic.bibtex.comparator; import java.util.Comparator; +import java.util.Locale; import org.jabref.model.entry.BibtexString; @@ -24,8 +25,8 @@ public int compare(BibtexString s1, BibtexString s2) { int res; // First check their names: - String name1 = s1.getName().toLowerCase(); - String name2 = s2.getName().toLowerCase(); + String name1 = s1.getName().toLowerCase(Locale.ROOT); + String name2 = s2.getName().toLowerCase(Locale.ROOT); res = name1.compareTo(name2); @@ -50,8 +51,8 @@ public int compare(BibtexString s1, BibtexString s2) { // Then see if "pre" refers to "post", which is the only // situation when we must change the ordering: - String namePost = post.getName().toLowerCase(); - String textPre = pre.getContent().toLowerCase(); + String namePost = post.getName().toLowerCase(Locale.ROOT); + String textPre = pre.getContent().toLowerCase(Locale.ROOT); // If that is the case, reverse the order found: if (textPre.contains("#" + namePost + "#")) { diff --git a/src/main/java/org/jabref/logic/bibtex/comparator/EntryComparator.java b/src/main/java/org/jabref/logic/bibtex/comparator/EntryComparator.java index 3419646fd07..c8dc54d132b 100644 --- a/src/main/java/org/jabref/logic/bibtex/comparator/EntryComparator.java +++ b/src/main/java/org/jabref/logic/bibtex/comparator/EntryComparator.java @@ -1,6 +1,7 @@ package org.jabref.logic.bibtex.comparator; import java.util.Comparator; +import java.util.Locale; import java.util.Objects; import org.jabref.model.entry.AuthorList; @@ -65,10 +66,10 @@ public int compare(BibEntry e1, BibEntry e2) { // sorted according to last name. if (InternalBibtexFields.getFieldProperties(sortField).contains(FieldProperty.PERSON_NAMES)) { if (f1 != null) { - f1 = AuthorList.fixAuthorForAlphabetization((String) f1).toLowerCase(); + f1 = AuthorList.fixAuthorForAlphabetization((String) f1).toLowerCase(Locale.ROOT); } if (f2 != null) { - f2 = AuthorList.fixAuthorForAlphabetization((String) f2).toLowerCase(); + f2 = AuthorList.fixAuthorForAlphabetization((String) f2).toLowerCase(Locale.ROOT); } } else if (sortField.equals(BibEntry.TYPE_HEADER)) { @@ -111,8 +112,8 @@ public int compare(BibEntry e1, BibEntry e2) { Integer f2AsInteger = Integer.valueOf(f2.toString()); result = -((Integer) f1).compareTo(f2AsInteger); } else { - String ours = ((String) f1).toLowerCase(); - String theirs = ((String) f2).toLowerCase(); + String ours = ((String) f1).toLowerCase(Locale.ROOT); + String theirs = ((String) f2).toLowerCase(Locale.ROOT); int comp = ours.compareTo(theirs); result = -comp; } diff --git a/src/main/java/org/jabref/logic/bst/BibtexCaseChanger.java b/src/main/java/org/jabref/logic/bst/BibtexCaseChanger.java index 086b0ef298b..f929c1ffdb0 100644 --- a/src/main/java/org/jabref/logic/bst/BibtexCaseChanger.java +++ b/src/main/java/org/jabref/logic/bst/BibtexCaseChanger.java @@ -1,5 +1,6 @@ package org.jabref.logic.bst; +import java.util.Locale; import java.util.Optional; import org.apache.commons.logging.Log; @@ -190,17 +191,17 @@ private int convertAccented(char[] c, int start, String s, StringBuilder sb, FOR case TITLE_LOWERS: case ALL_LOWERS: if ("L O OE AE AA".contains(s)) { - sb.append(s.toLowerCase()); + sb.append(s.toLowerCase(Locale.ROOT)); } else { sb.append(s); } break; case ALL_UPPERS: if ("l o oe ae aa".contains(s)) { - sb.append(s.toUpperCase()); + sb.append(s.toUpperCase(Locale.ROOT)); } else if ("i j ss".contains(s)) { sb.deleteCharAt(sb.length() - 1); // Kill backslash - sb.append(s.toUpperCase()); + sb.append(s.toUpperCase(Locale.ROOT)); while ((pos < c.length) && Character.isWhitespace(c[pos])) { pos++; } diff --git a/src/main/java/org/jabref/logic/bst/BibtexNameFormatter.java b/src/main/java/org/jabref/logic/bst/BibtexNameFormatter.java index e2b26917863..bebf017169f 100644 --- a/src/main/java/org/jabref/logic/bst/BibtexNameFormatter.java +++ b/src/main/java/org/jabref/logic/bst/BibtexNameFormatter.java @@ -1,6 +1,7 @@ package org.jabref.logic.bst; import java.util.Arrays; +import java.util.Locale; import java.util.Optional; import java.util.stream.Collectors; @@ -85,7 +86,7 @@ public static String formatName(Author author, String format, Warn warn) { i++; } i--; // unskip last brace (for last i++ at the end) - String control = level1Chars.toString().toLowerCase(); + String control = level1Chars.toString().toLowerCase(Locale.ROOT); if (control.isEmpty()) { continue; diff --git a/src/main/java/org/jabref/logic/bst/ChangeCaseFunction.java b/src/main/java/org/jabref/logic/bst/ChangeCaseFunction.java index f2bc76cd613..ab602be398a 100644 --- a/src/main/java/org/jabref/logic/bst/ChangeCaseFunction.java +++ b/src/main/java/org/jabref/logic/bst/ChangeCaseFunction.java @@ -1,5 +1,6 @@ package org.jabref.logic.bst; +import java.util.Locale; import java.util.Stack; import org.jabref.logic.bst.BibtexCaseChanger.FORMAT_MODE; @@ -57,7 +58,7 @@ public void execute(BstEntry context) { throw new VMException("A string is needed as second parameter for change.case$"); } - char format = ((String) o1).toLowerCase().charAt(0); + char format = ((String) o1).toLowerCase(Locale.ROOT).charAt(0); String s = (String) o2; stack.push(BibtexCaseChanger.changeCase(s, FORMAT_MODE.getFormatModeForBSTFormat(format))); diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/Word.java b/src/main/java/org/jabref/logic/formatter/casechanger/Word.java index 6c17883266e..a5267cce181 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/Word.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/Word.java @@ -3,6 +3,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashSet; +import java.util.Locale; import java.util.Objects; import java.util.Set; @@ -83,7 +84,7 @@ public void toUpperFirst() { public boolean isSmallerWord() { // "word:" is still a small "word" - return SMALLER_WORDS.contains(this.toString().replace(":", "").toLowerCase()); + return SMALLER_WORDS.contains(this.toString().replace(":", "").toLowerCase(Locale.ROOT)); } public boolean isLargerWord() { diff --git a/src/main/java/org/jabref/logic/importer/MimeTypeDetector.java b/src/main/java/org/jabref/logic/importer/MimeTypeDetector.java index 08f38940461..b157b507fa5 100644 --- a/src/main/java/org/jabref/logic/importer/MimeTypeDetector.java +++ b/src/main/java/org/jabref/logic/importer/MimeTypeDetector.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.net.URL; import java.net.URLConnection; +import java.util.Locale; import java.util.Optional; import com.mashape.unirest.http.Unirest; @@ -15,7 +16,7 @@ public class MimeTypeDetector { public static boolean isPdfContentType(String url) { Optional contentType = getMimeType(url); - return contentType.isPresent() && contentType.get().toLowerCase().startsWith("application/pdf"); + return contentType.isPresent() && contentType.get().toLowerCase(Locale.ROOT).startsWith("application/pdf"); } private static Optional getMimeType(String url) { diff --git a/src/main/java/org/jabref/logic/importer/fileformat/BiblioscapeImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/BiblioscapeImporter.java index ef3a4d4f537..e01a4446368 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/BiblioscapeImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/BiblioscapeImporter.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; @@ -191,7 +192,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { if (type[i] == null) { continue; } - type[i] = type[i].toLowerCase(); + type[i] = type[i].toLowerCase(Locale.ROOT); if (type[i].contains("article")) { bibtexType = "article"; } else if (type[i].contains("journal")) { diff --git a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java index 497d0f5e35a..d2d9f8e6e47 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java @@ -13,6 +13,7 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -192,7 +193,7 @@ private ParserResult parseFileContent() throws IOException { skipWhitespace(); // Try to read the entry type - String entryType = parseTextToken().toLowerCase().trim(); + String entryType = parseTextToken().toLowerCase(Locale.ROOT).trim(); if ("preamble".equals(entryType)) { database.setPreamble(parsePreamble()); @@ -557,7 +558,7 @@ private BibEntry parseEntry(String entryType) throws IOException { } private void parseField(BibEntry entry) throws IOException { - String key = parseTextToken().toLowerCase(); + String key = parseTextToken().toLowerCase(Locale.ROOT); skipWhitespace(); consume('='); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/IsiImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/IsiImporter.java index 9396ce3d352..df367b0a028 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/IsiImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/IsiImporter.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.regex.Matcher; @@ -126,7 +127,7 @@ private static void processCapitalization(Map map) { if (map.containsKey(aSubsup)) { String s = map.get(aSubsup); - if (s.toUpperCase().equals(s)) { + if (s.toUpperCase(Locale.ROOT).equals(s)) { s = new TitleCaseFormatter().format(s); map.put(aSubsup, s); } @@ -288,7 +289,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { if ("ER".equals(beg) || "EF".equals(beg) || "VR".equals(beg) || "FN".equals(beg)) { continue; } - hm.put(beg.toLowerCase(), value); + hm.put(beg.toLowerCase(Locale.ROOT), value); } } @@ -337,7 +338,7 @@ public static String parseMonth(String value) { String[] parts = value.split("\\s|\\-"); for (String part1 : parts) { - MonthUtil.Month month = MonthUtil.getMonthByShortName(part1.toLowerCase()); + MonthUtil.Month month = MonthUtil.getMonthByShortName(part1.toLowerCase(Locale.ROOT)); if (month.isValid()) { return month.bibtexFormat; } @@ -385,7 +386,7 @@ public static String isiAuthorConvert(String author) { first = firstParts[i]; // Do we have only uppercase chars? - if (first.toUpperCase().equals(first)) { + if (first.toUpperCase(Locale.ROOT).equals(first)) { first = first.replace(".", ""); for (int j = 0; j < first.length(); j++) { sb.append(first.charAt(j)).append('.'); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java index 286fe06dbcf..cd4b6208a1b 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java @@ -9,6 +9,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.stream.Collectors; import javax.xml.parsers.ParserConfigurationException; @@ -184,7 +185,7 @@ public List getRankedBibEntries() { public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - switch (qName.toLowerCase()) { + switch (qName.toLowerCase(Locale.ROOT)) { case "related_article": currentEntry = new BibEntry(); htmlSnippetSingle = null; diff --git a/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java index 971b04a0e2f..fd387502646 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java @@ -7,6 +7,7 @@ import java.nio.charset.Charset; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Locale; import java.util.Objects; import java.util.Optional; import java.util.regex.Matcher; @@ -256,7 +257,7 @@ public ParserResult importDatabase(Path filePath, Charset defaultEncoding) { } else { // e.g. Copyright (c) 1998 by the Genetics Society of America // future work: get year using RegEx - String lower = curString.toLowerCase(); + String lower = curString.toLowerCase(Locale.ROOT); if (lower.contains("copyright")) { fillCurStringWithNonEmptyLines(); publisher = curString; @@ -321,7 +322,7 @@ public ParserResult importDatabase(Path filePath, Charset defaultEncoding) { fillCurStringWithNonEmptyLines(); keywords = removeNonLettersAtEnd(curString); } else { - String lower = curString.toLowerCase(); + String lower = curString.toLowerCase(Locale.ROOT); int pos = lower.indexOf("technical"); if (pos >= 0) { diff --git a/src/main/java/org/jabref/logic/importer/fileformat/SilverPlatterImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/SilverPlatterImporter.java index 319aec43847..600d56ef32f 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/SilverPlatterImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/SilverPlatterImporter.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.regex.Pattern; @@ -101,7 +102,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } else if ("AB".equals(f3)) { h.put(FieldName.ABSTRACT, frest); } else if ("DE".equals(f3)) { - String kw = frest.replace("-;", ",").toLowerCase(); + String kw = frest.replace("-;", ",").toLowerCase(Locale.ROOT); h.put(FieldName.KEYWORDS, kw.substring(0, kw.length() - 1)); } else if ("SO".equals(f3)) { int m = frest.indexOf('.'); @@ -154,7 +155,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { type = "book"; } else if (frest.startsWith("Dissertation")) { type = "phdthesis"; - } else if (frest.toLowerCase().contains(FieldName.JOURNAL)) { + } else if (frest.toLowerCase(Locale.ROOT).contains(FieldName.JOURNAL)) { type = "article"; } else if ("Contribution".equals(frest) || "Chapter".equals(frest)) { type = "incollection"; diff --git a/src/main/java/org/jabref/logic/integrity/PersonNamesChecker.java b/src/main/java/org/jabref/logic/integrity/PersonNamesChecker.java index 463aa7410a6..be8aa61a797 100644 --- a/src/main/java/org/jabref/logic/integrity/PersonNamesChecker.java +++ b/src/main/java/org/jabref/logic/integrity/PersonNamesChecker.java @@ -1,5 +1,6 @@ package org.jabref.logic.integrity; +import java.util.Locale; import java.util.Optional; import org.jabref.logic.l10n.Localization; @@ -8,7 +9,7 @@ public class PersonNamesChecker implements ValueChecker { @Override public Optional checkValue(String value) { - String valueTrimmedAndLowerCase = value.trim().toLowerCase(); + String valueTrimmedAndLowerCase = value.trim().toLowerCase(Locale.ROOT); if (valueTrimmedAndLowerCase.startsWith("and ") || valueTrimmedAndLowerCase.startsWith(",")) { return Optional.of(Localization.lang("should start with a name")); } else if (valueTrimmedAndLowerCase.endsWith(" and") || valueTrimmedAndLowerCase.endsWith(",")) { diff --git a/src/main/java/org/jabref/logic/layout/LayoutHelper.java b/src/main/java/org/jabref/logic/layout/LayoutHelper.java index 2964f90845e..f4780c24e31 100644 --- a/src/main/java/org/jabref/logic/layout/LayoutHelper.java +++ b/src/main/java/org/jabref/logic/layout/LayoutHelper.java @@ -5,6 +5,7 @@ import java.io.Reader; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Objects; /** @@ -49,7 +50,7 @@ public Layout getLayoutFromText() throws IOException { if ((parsedEntry.i == LayoutHelper.IS_SIMPLE_FIELD) || (parsedEntry.i == LayoutHelper.IS_FIELD_START) || (parsedEntry.i == LayoutHelper.IS_FIELD_END) || (parsedEntry.i == LayoutHelper.IS_GROUP_START) || (parsedEntry.i == LayoutHelper.IS_GROUP_END)) { - parsedEntry.s = parsedEntry.s.trim().toLowerCase(); + parsedEntry.s = parsedEntry.s.trim().toLowerCase(Locale.ROOT); } } diff --git a/src/main/java/org/jabref/logic/layout/format/Authors.java b/src/main/java/org/jabref/logic/layout/format/Authors.java index 00ad59f9d4d..384e22ea67a 100644 --- a/src/main/java/org/jabref/logic/layout/format/Authors.java +++ b/src/main/java/org/jabref/logic/layout/format/Authors.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.regex.Pattern; import org.jabref.logic.layout.AbstractParamLayoutFormatter; @@ -115,7 +116,7 @@ public void setArgument(String arg) { } private void handleArgument(String key, String value) { - if (Authors.AUTHOR_ORDER.contains(key.trim().toLowerCase())) { + if (Authors.AUTHOR_ORDER.contains(key.trim().toLowerCase(Locale.ROOT))) { if (comp(key, "FirstFirst")) { flMode = Authors.FIRST_FIRST; } else if (comp(key, "LastFirst")) { @@ -123,7 +124,7 @@ private void handleArgument(String key, String value) { } else if (comp(key, "LastFirstFirstFirst")) { flMode = Authors.LF_FF; } - } else if (Authors.AUTHOR_ABRV.contains(key.trim().toLowerCase())) { + } else if (Authors.AUTHOR_ABRV.contains(key.trim().toLowerCase(Locale.ROOT))) { if (comp(key, "FullName")) { abbreviate = false; } else if (comp(key, "Initials")) { @@ -141,7 +142,7 @@ private void handleArgument(String key, String value) { abbreviate = true; abbrSpaces = false; } - } else if (Authors.AUTHOR_PUNC.contains(key.trim().toLowerCase())) { + } else if (Authors.AUTHOR_PUNC.contains(key.trim().toLowerCase(Locale.ROOT))) { if (comp(key, "FullPunc")) { abbrDots = true; lastFirstSeparator = ", "; @@ -159,7 +160,7 @@ private void handleArgument(String key, String value) { // AuthorSep = [Comma | And | Colon | Semicolon | sep=] // AuthorLastSep = [And | Comma | Colon | Semicolon | Amp | Oxford | lastsep=] - else if (Authors.SEPARATORS.contains(key.trim().toLowerCase()) || Authors.LAST_SEPARATORS.contains(key.trim().toLowerCase())) { + else if (Authors.SEPARATORS.contains(key.trim().toLowerCase(Locale.ROOT)) || Authors.LAST_SEPARATORS.contains(key.trim().toLowerCase(Locale.ROOT))) { if (comp(key, "Comma")) { if (setSep) { lastSeparator = Authors.COMMA; diff --git a/src/main/java/org/jabref/logic/layout/format/Iso690NamesAuthors.java b/src/main/java/org/jabref/logic/layout/format/Iso690NamesAuthors.java index 8213da80214..41a8278e8d0 100644 --- a/src/main/java/org/jabref/logic/layout/format/Iso690NamesAuthors.java +++ b/src/main/java/org/jabref/logic/layout/format/Iso690NamesAuthors.java @@ -1,5 +1,7 @@ package org.jabref.logic.layout.format; +import java.util.Locale; + import org.jabref.logic.layout.LayoutFormatter; /** @@ -32,13 +34,13 @@ public String format(String s) { String surname; if (author.length == 1) {// Caso 1.0: Sólo un campo - sb.append(author[0].trim().toUpperCase()); + sb.append(author[0].trim().toUpperCase(Locale.ROOT)); } else if (author.length == 2) {// Caso 1.1: Nombre Apellido //primer campo Nombre name = author[0].trim(); //Segundo campo Apellido - surname = author[1].trim().toUpperCase(); + surname = author[1].trim().toUpperCase(Locale.ROOT); //añadimos los campos modificados al string final sb.append(surname); @@ -49,7 +51,7 @@ public String format(String s) { //primer campo Nombre name = author[0].trim(); //Segundo y tercer campo Apellido1 Apellido2 - surname = author[1].trim().toUpperCase() + ' ' + author[2].trim().toUpperCase(); + surname = author[1].trim().toUpperCase(Locale.ROOT) + ' ' + author[2].trim().toUpperCase(Locale.ROOT); //añadimos los campos modificados al string final sb.append(surname); @@ -60,7 +62,7 @@ public String format(String s) { //primer y segundo campo Nombre SegundoNombre name = author[0].trim() + ' ' + author[1].trim(); //tercer y cuarto campo Apellido1 Apellido2 - surname = author[2].trim().toUpperCase() + ' ' + author[3].trim().toUpperCase(); + surname = author[2].trim().toUpperCase(Locale.ROOT) + ' ' + author[3].trim().toUpperCase(Locale.ROOT); //añadimos los campos modificados al string final sb.append(surname); @@ -70,7 +72,7 @@ public String format(String s) { } else { // Caso 2: Apellidos, Nombre // Campo 1 apellidos, lo pasamos a mayusculas - String surname = author[0].trim().toUpperCase(); + String surname = author[0].trim().toUpperCase(Locale.ROOT); // campo 2 nombre String name = author[1].trim(); //añadimos los campos modificados al string final diff --git a/src/main/java/org/jabref/logic/layout/format/RisMonth.java b/src/main/java/org/jabref/logic/layout/format/RisMonth.java index 6035955a107..1b191946c6a 100644 --- a/src/main/java/org/jabref/logic/layout/format/RisMonth.java +++ b/src/main/java/org/jabref/logic/layout/format/RisMonth.java @@ -1,5 +1,7 @@ package org.jabref.logic.layout.format; +import java.util.Locale; + import org.jabref.logic.layout.LayoutFormatter; import org.jabref.model.entry.MonthUtil; @@ -15,7 +17,7 @@ public String format(String month) { if (m.isValid()) { return m.twoDigitNumber; } else { - return month.toLowerCase(); + return month.toLowerCase(Locale.ROOT); } } diff --git a/src/main/java/org/jabref/logic/layout/format/ToLowerCase.java b/src/main/java/org/jabref/logic/layout/format/ToLowerCase.java index 2fbcf85bae0..8dc61700ddf 100644 --- a/src/main/java/org/jabref/logic/layout/format/ToLowerCase.java +++ b/src/main/java/org/jabref/logic/layout/format/ToLowerCase.java @@ -1,5 +1,7 @@ package org.jabref.logic.layout.format; +import java.util.Locale; + import org.jabref.logic.layout.LayoutFormatter; /** @@ -12,6 +14,6 @@ public String format(String fieldText) { if (fieldText == null) { return null; } - return fieldText.toLowerCase(); + return fieldText.toLowerCase(Locale.ROOT); } } diff --git a/src/main/java/org/jabref/logic/layout/format/ToUpperCase.java b/src/main/java/org/jabref/logic/layout/format/ToUpperCase.java index 7b505c08bd3..9dac62573d0 100644 --- a/src/main/java/org/jabref/logic/layout/format/ToUpperCase.java +++ b/src/main/java/org/jabref/logic/layout/format/ToUpperCase.java @@ -1,5 +1,7 @@ package org.jabref.logic.layout.format; +import java.util.Locale; + import org.jabref.logic.layout.LayoutFormatter; /** @@ -13,7 +15,7 @@ public String format(String fieldText) { return null; } - return fieldText.toUpperCase(); + return fieldText.toUpperCase(Locale.ROOT); } } diff --git a/src/main/java/org/jabref/logic/net/ProxyAuthenticator.java b/src/main/java/org/jabref/logic/net/ProxyAuthenticator.java index a3293a0664c..f6e3496e8ce 100644 --- a/src/main/java/org/jabref/logic/net/ProxyAuthenticator.java +++ b/src/main/java/org/jabref/logic/net/ProxyAuthenticator.java @@ -2,13 +2,14 @@ import java.net.Authenticator; import java.net.PasswordAuthentication; +import java.util.Locale; public class ProxyAuthenticator extends Authenticator { @Override protected PasswordAuthentication getPasswordAuthentication() { if (getRequestorType() == RequestorType.PROXY) { - String prot = getRequestingProtocol().toLowerCase(); + String prot = getRequestingProtocol().toLowerCase(Locale.ROOT); String host = System.getProperty(prot + ".proxyHost", ""); String port = System.getProperty(prot + ".proxyPort", "80"); String user = System.getProperty(prot + ".proxyUser", ""); diff --git a/src/main/java/org/jabref/logic/pdf/EntryAnnotationImporter.java b/src/main/java/org/jabref/logic/pdf/EntryAnnotationImporter.java index 49ce9c196d2..e268b136653 100644 --- a/src/main/java/org/jabref/logic/pdf/EntryAnnotationImporter.java +++ b/src/main/java/org/jabref/logic/pdf/EntryAnnotationImporter.java @@ -2,6 +2,7 @@ import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.stream.Collectors; @@ -34,7 +35,7 @@ public EntryAnnotationImporter(BibEntry entry) { */ public List getFilteredFileList() { return FileField.parse(this.entry.getField(FieldName.FILE).get()).stream() - .filter(parsedFileField -> parsedFileField.getLink().toLowerCase().endsWith(".pdf")) + .filter(parsedFileField -> parsedFileField.getLink().toLowerCase(Locale.ROOT).endsWith(".pdf")) .filter(parsedFileField -> !parsedFileField.getLink().contains("www.")).collect(Collectors.toList()); } diff --git a/src/main/java/org/jabref/logic/util/BuildInfo.java b/src/main/java/org/jabref/logic/util/BuildInfo.java index 35f39eda213..cdefe91d88e 100644 --- a/src/main/java/org/jabref/logic/util/BuildInfo.java +++ b/src/main/java/org/jabref/logic/util/BuildInfo.java @@ -4,6 +4,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; +import java.util.Locale; import java.util.Properties; public class BuildInfo { @@ -11,9 +12,9 @@ public class BuildInfo { public static final String UNKNOWN_VERSION = "*unknown*"; public static final String OS = System.getProperty("os.name", UNKNOWN_VERSION); - public static final String OS_VERSION = System.getProperty("os.version", UNKNOWN_VERSION).toLowerCase(); - public static final String OS_ARCH = System.getProperty("os.arch", UNKNOWN_VERSION).toLowerCase(); - public static final String JAVA_VERSION = System.getProperty("java.version", UNKNOWN_VERSION).toLowerCase(); + public static final String OS_VERSION = System.getProperty("os.version", UNKNOWN_VERSION).toLowerCase(Locale.ROOT); + public static final String OS_ARCH = System.getProperty("os.arch", UNKNOWN_VERSION).toLowerCase(Locale.ROOT); + public static final String JAVA_VERSION = System.getProperty("java.version", UNKNOWN_VERSION).toLowerCase(Locale.ROOT); private final Version version; private final String authors; diff --git a/src/main/java/org/jabref/logic/util/OS.java b/src/main/java/org/jabref/logic/util/OS.java index 1ee259e76a3..bcb8db01858 100644 --- a/src/main/java/org/jabref/logic/util/OS.java +++ b/src/main/java/org/jabref/logic/util/OS.java @@ -1,11 +1,13 @@ package org.jabref.logic.util; +import java.util.Locale; + /*** * Operating system (OS) detection */ public class OS { // https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/SystemUtils.html - private static final String OS_NAME = System.getProperty("os.name", "unknown").toLowerCase(); + private static final String OS_NAME = System.getProperty("os.name", "unknown").toLowerCase(Locale.ROOT); public static final boolean LINUX = OS_NAME.startsWith("linux"); public static final boolean WINDOWS = OS_NAME.startsWith("win"); diff --git a/src/main/java/org/jabref/logic/util/io/FileUtil.java b/src/main/java/org/jabref/logic/util/io/FileUtil.java index f1fa7dc3711..5425c598328 100644 --- a/src/main/java/org/jabref/logic/util/io/FileUtil.java +++ b/src/main/java/org/jabref/logic/util/io/FileUtil.java @@ -12,6 +12,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -64,7 +65,7 @@ public static Optional getFileExtension(File file) { public static Optional getFileExtension(String fileName) { int dotPosition = fileName.lastIndexOf('.'); if ((dotPosition > 0) && (dotPosition < (fileName.length() - 1))) { - return Optional.of(fileName.substring(dotPosition + 1).trim().toLowerCase()); + return Optional.of(fileName.substring(dotPosition + 1).trim().toLowerCase(Locale.ROOT)); } else { return Optional.empty(); } @@ -326,8 +327,8 @@ private static File shortenFileName(File fileName, String directory) { String longName; if (OS.WINDOWS) { // case-insensitive matching on Windows - longName = fileName.toString().toLowerCase(); - dir = dir.toLowerCase(); + longName = fileName.toString().toLowerCase(Locale.ROOT); + dir = dir.toLowerCase(Locale.ROOT); } else { longName = fileName.toString(); } diff --git a/src/main/java/org/jabref/model/DuplicateCheck.java b/src/main/java/org/jabref/model/DuplicateCheck.java index 8f623468ac7..143a6769499 100644 --- a/src/main/java/org/jabref/model/DuplicateCheck.java +++ b/src/main/java/org/jabref/model/DuplicateCheck.java @@ -3,6 +3,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -136,8 +137,8 @@ private static int compareSingleField(String field, BibEntry one, BibEntry two) if (InternalBibtexFields.getFieldProperties(field).contains(FieldProperty.PERSON_NAMES)) { // Specific for name fields. // Harmonise case: - String authorOne = AuthorList.fixAuthorLastNameOnlyCommas(stringOne, false).replace(" and ", " ").toLowerCase(); - String authorTwo = AuthorList.fixAuthorLastNameOnlyCommas(stringTwo, false).replace(" and ", " ").toLowerCase(); + String authorOne = AuthorList.fixAuthorLastNameOnlyCommas(stringOne, false).replace(" and ", " ").toLowerCase(Locale.ROOT); + String authorTwo = AuthorList.fixAuthorLastNameOnlyCommas(stringTwo, false).replace(" and ", " ").toLowerCase(Locale.ROOT); double similarity = DuplicateCheck.correlateByWords(authorOne, authorTwo); if (similarity > 0.8) { return EQUAL; @@ -157,16 +158,16 @@ private static int compareSingleField(String field, BibEntry one, BibEntry two) // We do not attempt to harmonize abbreviation state of the journal names, // but we remove periods from the names in case they are abbreviated with // and without dots: - stringOne = stringOne.replace(".", "").toLowerCase(); - stringTwo = stringTwo.replace(".", "").toLowerCase(); + stringOne = stringOne.replace(".", "").toLowerCase(Locale.ROOT); + stringTwo = stringTwo.replace(".", "").toLowerCase(Locale.ROOT); double similarity = DuplicateCheck.correlateByWords(stringOne, stringTwo); if (similarity > 0.8) { return EQUAL; } return NOT_EQUAL; } else { - stringOne = stringOne.toLowerCase(); - stringTwo = stringTwo.toLowerCase(); + stringOne = stringOne.toLowerCase(Locale.ROOT); + stringTwo = stringTwo.toLowerCase(Locale.ROOT); double similarity = DuplicateCheck.correlateByWords(stringOne, stringTwo); if (similarity > 0.8) { return EQUAL; @@ -265,8 +266,8 @@ private static double similarity(String s1, String s2) { * http://stackoverflow.com/questions/955110/similarity-string-comparison-in-java */ private static int editDistance(String s1, String s2) { - String s1LowerCase = s1.toLowerCase(); - String s2LowerCase = s2.toLowerCase(); + String s1LowerCase = s1.toLowerCase(Locale.ROOT); + String s2LowerCase = s2.toLowerCase(Locale.ROOT); int[] costs = new int[s2LowerCase.length() + 1]; for (int i = 0; i <= s1LowerCase.length(); i++) { diff --git a/src/main/java/org/jabref/model/EntryTypes.java b/src/main/java/org/jabref/model/EntryTypes.java index db7be84c45a..812e9c7118a 100644 --- a/src/main/java/org/jabref/model/EntryTypes.java +++ b/src/main/java/org/jabref/model/EntryTypes.java @@ -4,6 +4,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -33,7 +34,7 @@ public InternalEntryTypes(EntryType defaultType, List> entryType for (List list : entryTypes) { for (EntryType type : list) { - ALL_TYPES.put(type.getName().toLowerCase(), type); + ALL_TYPES.put(type.getName().toLowerCase(Locale.ROOT), type); } } STANDARD_TYPES = new TreeMap<>(ALL_TYPES); @@ -44,7 +45,7 @@ public InternalEntryTypes(EntryType defaultType, List> entryType * or null if it does not exist. */ public Optional getType(String name) { - return Optional.ofNullable(ALL_TYPES.get(name.toLowerCase())); + return Optional.ofNullable(ALL_TYPES.get(name.toLowerCase(Locale.ROOT))); } /** @@ -61,11 +62,11 @@ public EntryType getTypeOrDefault(String type) { * name of a type, or null if it does not exist. */ public Optional getStandardType(String name) { - return Optional.ofNullable(STANDARD_TYPES.get(name.toLowerCase())); + return Optional.ofNullable(STANDARD_TYPES.get(name.toLowerCase(Locale.ROOT))); } private void addOrModifyEntryType(EntryType type) { - ALL_TYPES.put(type.getName().toLowerCase(), type); + ALL_TYPES.put(type.getName().toLowerCase(Locale.ROOT), type); } public Set getAllTypes() { @@ -83,7 +84,7 @@ public Collection getAllValues() { * @param name The customized entry type to remove. */ public void removeType(String name) { - String toLowerCase = name.toLowerCase(); + String toLowerCase = name.toLowerCase(Locale.ROOT); if (!ALL_TYPES.get(toLowerCase).equals(STANDARD_TYPES.get(toLowerCase))) { ALL_TYPES.remove(toLowerCase); @@ -239,11 +240,11 @@ public static boolean isEqualNameAndFieldBased(EntryType type1, EntryType type2) } public static boolean isExclusiveBiblatex(String type) { - return filterEntryTypesNames(BiblatexEntryTypes.ALL, isNotIncludedIn(BibtexEntryTypes.ALL)).contains(type.toLowerCase()); + return filterEntryTypesNames(BiblatexEntryTypes.ALL, isNotIncludedIn(BibtexEntryTypes.ALL)).contains(type.toLowerCase(Locale.ROOT)); } private static List filterEntryTypesNames(List types, Predicate predicate) { - return types.stream().filter(predicate).map(type -> type.getName().toLowerCase()).collect(Collectors.toList()); + return types.stream().filter(predicate).map(type -> type.getName().toLowerCase(Locale.ROOT)).collect(Collectors.toList()); } private static Predicate isNotIncludedIn(List collection) { diff --git a/src/main/java/org/jabref/model/entry/AuthorList.java b/src/main/java/org/jabref/model/entry/AuthorList.java index 3fe38b36cb2..2b1556771d9 100644 --- a/src/main/java/org/jabref/model/entry/AuthorList.java +++ b/src/main/java/org/jabref/model/entry/AuthorList.java @@ -191,7 +191,7 @@ public static AuthorList parse(String authors) { Collection avoidIndex = new HashSet<>(); for (int i = 0; i < arrayNameList.size(); i++) { - if (avoidTermsInLowerCase.contains(arrayNameList.get(i).toLowerCase())) { + if (avoidTermsInLowerCase.contains(arrayNameList.get(i).toLowerCase(Locale.ROOT))) { avoidIndex.add(i); valuePartsCount--; } diff --git a/src/main/java/org/jabref/model/entry/AuthorListParser.java b/src/main/java/org/jabref/model/entry/AuthorListParser.java index 6cdb6a7ab3d..a14aaa7f337 100644 --- a/src/main/java/org/jabref/model/entry/AuthorListParser.java +++ b/src/main/java/org/jabref/model/entry/AuthorListParser.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -249,7 +250,7 @@ private Optional getAuthor() { false); String jrPart = jrPartStart < 0 ? null : concatTokens(tokens, jrPartStart, jrPartEnd, OFFSET_TOKEN, false); - if((firstPart != null) && (lastPart != null) && lastPart.equals(lastPart.toUpperCase()) && (lastPart.length() < 5)) { + if((firstPart != null) && (lastPart != null) && lastPart.equals(lastPart.toUpperCase(Locale.ROOT)) && (lastPart.length() < 5)) { // The last part is a small string in complete upper case, so interpret it as initial of the first name // This is the case for example in "Smith SH" which we think of as lastname=Smith and firstname=SH // The length < 5 constraint should allow for "Smith S.H." as input diff --git a/src/main/java/org/jabref/model/entry/BibtexString.java b/src/main/java/org/jabref/model/entry/BibtexString.java index 514bc8bb495..19b9b482d1d 100644 --- a/src/main/java/org/jabref/model/entry/BibtexString.java +++ b/src/main/java/org/jabref/model/entry/BibtexString.java @@ -1,5 +1,6 @@ package org.jabref.model.entry; +import java.util.Locale; import java.util.Objects; /** @@ -58,7 +59,7 @@ public static Type get(String key) { // Second character is not upper case // aStallman -> AUTHOR // asdf -> OTHER - if (!(String.valueOf(key.charAt(1))).toUpperCase().equals(String.valueOf(key.charAt(1)))) { + if (!(String.valueOf(key.charAt(1))).toUpperCase(Locale.ROOT).equals(String.valueOf(key.charAt(1)))) { return OTHER; } for (Type t : Type.values()) { diff --git a/src/main/java/org/jabref/model/search/rules/ContainBasedSearchRule.java b/src/main/java/org/jabref/model/search/rules/ContainBasedSearchRule.java index 750d290d4d2..8b2d542b504 100644 --- a/src/main/java/org/jabref/model/search/rules/ContainBasedSearchRule.java +++ b/src/main/java/org/jabref/model/search/rules/ContainBasedSearchRule.java @@ -2,6 +2,7 @@ import java.util.Iterator; import java.util.List; +import java.util.Locale; import org.jabref.model.entry.BibEntry; @@ -30,7 +31,7 @@ public boolean applyRule(String query, BibEntry bibEntry) { String searchString = query; if (!caseSensitive) { - searchString = searchString.toLowerCase(); + searchString = searchString.toLowerCase(Locale.ROOT); } List unmatchedWords = new SentenceAnalyzer(searchString).getWords(); @@ -38,7 +39,7 @@ public boolean applyRule(String query, BibEntry bibEntry) { for (String fieldKey : bibEntry.getFieldNames()) { String formattedFieldContent = bibEntry.getLatexFreeField(fieldKey).get(); if (!caseSensitive) { - formattedFieldContent = formattedFieldContent.toLowerCase(); + formattedFieldContent = formattedFieldContent.toLowerCase(Locale.ROOT); } Iterator unmatchedWordsIterator = unmatchedWords.iterator(); diff --git a/src/main/java/org/jabref/model/search/rules/RegexBasedSearchRule.java b/src/main/java/org/jabref/model/search/rules/RegexBasedSearchRule.java index 59995a039d2..d12f3c79c2f 100644 --- a/src/main/java/org/jabref/model/search/rules/RegexBasedSearchRule.java +++ b/src/main/java/org/jabref/model/search/rules/RegexBasedSearchRule.java @@ -1,5 +1,6 @@ package org.jabref.model.search.rules; +import java.util.Locale; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -26,7 +27,7 @@ public boolean isCaseSensitive() { public boolean validateSearchStrings(String query) { String searchString = query; if (!caseSensitive) { - searchString = searchString.toLowerCase(); + searchString = searchString.toLowerCase(Locale.ROOT); } try { diff --git a/src/main/java/org/jabref/model/strings/StringUtil.java b/src/main/java/org/jabref/model/strings/StringUtil.java index 4af6720fa3b..c6875b2e88a 100644 --- a/src/main/java/org/jabref/model/strings/StringUtil.java +++ b/src/main/java/org/jabref/model/strings/StringUtil.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.StringTokenizer; @@ -168,7 +169,7 @@ public static String getCorrectFileName(String orgName, String defaultExtension) } - if (orgName.toLowerCase().endsWith("." + defaultExtension.toLowerCase())) { + if (orgName.toLowerCase(Locale.ROOT).endsWith("." + defaultExtension.toLowerCase(Locale.ROOT))) { return orgName; } @@ -687,10 +688,10 @@ public static String stripAccents(String searchQuery) { */ public static String capitalizeFirst(String toCapitalize) { if (toCapitalize.length() > 1) { - return toCapitalize.substring(0, 1).toUpperCase() - + toCapitalize.substring(1, toCapitalize.length()).toLowerCase(); + return toCapitalize.substring(0, 1).toUpperCase(Locale.ROOT) + + toCapitalize.substring(1, toCapitalize.length()).toLowerCase(Locale.ROOT); } else { - return toCapitalize.toUpperCase(); + return toCapitalize.toUpperCase(Locale.ROOT); } } diff --git a/src/main/java/org/jabref/pdfimport/PdfImporter.java b/src/main/java/org/jabref/pdfimport/PdfImporter.java index 0e6d67f4ec8..b3552c8f4c3 100644 --- a/src/main/java/org/jabref/pdfimport/PdfImporter.java +++ b/src/main/java/org/jabref/pdfimport/PdfImporter.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Optional; import javax.swing.JOptionPane; @@ -270,7 +271,7 @@ private Optional createNewEntry() { // Create an UndoableInsertEntry object. panel.getUndoManager().addEdit(new UndoableInsertEntry(panel.getDatabase(), bibEntry, panel)); - panel.output(Localization.lang("Added new") + " '" + type.getName().toLowerCase() + "' " + panel.output(Localization.lang("Added new") + " '" + type.getName().toLowerCase(Locale.ROOT) + "' " + Localization.lang("entry") + "."); // We are going to select the new entry. Before that, make sure that we are in diff --git a/src/main/java/org/jabref/shared/DBMSProcessor.java b/src/main/java/org/jabref/shared/DBMSProcessor.java index 4d7a1da5469..ee1329add77 100644 --- a/src/main/java/org/jabref/shared/DBMSProcessor.java +++ b/src/main/java/org/jabref/shared/DBMSProcessor.java @@ -84,7 +84,7 @@ private boolean checkTableAvailibility(String... tableNames) throws SQLException // ...getTables(null, ...): no restrictions try (ResultSet databaseMetaDataResultSet = databaseMetaData.getTables(null, null, null, null)) { while (databaseMetaDataResultSet.next()) { - String tableName = databaseMetaDataResultSet.getString("TABLE_NAME").toUpperCase(); + String tableName = databaseMetaDataResultSet.getString("TABLE_NAME").toUpperCase(Locale.ROOT); requiredTables.remove(tableName); // Remove matching tables to check requiredTables for emptiness } return requiredTables.isEmpty(); From cbcdfcdf377cb9921c9f12703dcebee6d672326e Mon Sep 17 00:00:00 2001 From: Linus Dietz Date: Mon, 6 Mar 2017 13:25:42 +0100 Subject: [PATCH 2/2] Added the locale to a newly created class --- .../jabref/logic/bibtexkeypattern/BibtexKeyPatternUtil.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtil.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtil.java index 9dcab9407e4..2d696b56534 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtil.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtil.java @@ -776,7 +776,7 @@ private static String camelizeTitle(String title) { String word = titleScanner.next(); // Camelize the word - word = word.substring(0, 1).toUpperCase() + word.substring(1); + word = word.substring(0, 1).toUpperCase(Locale.ROOT) + word.substring(1); if (stringBuilder.length() > 0) { stringBuilder.append(' '); @@ -810,9 +810,9 @@ public static String camelizeSignificantWordsInTitle(String title) { } // We want to capitalize significant words and the first word of the title if (camelize || (stringJoiner.length() == 0)) { - word = word.substring(0, 1).toUpperCase() + word.substring(1); + word = word.substring(0, 1).toUpperCase(Locale.ROOT) + word.substring(1); } else { - word = word.substring(0, 1).toLowerCase() + word.substring(1); + word = word.substring(0, 1).toLowerCase(Locale.ROOT) + word.substring(1); } stringJoiner.add(word);