Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Locale.ROOT to toUpper/toLower Methods #2584

Merged
merged 4 commits into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/GenFieldsCustomizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/ReplaceStringDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/SaveOrderConfigDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -104,6 +105,6 @@ public SaveOrderConfig getSaveOrderConfig() {
}

private String getSelectedItemAsLowerCaseTrim(JComboBox<String> sortBox) {
return sortBox.getSelectedItem().toString().toLowerCase().trim();
return sortBox.getSelectedItem().toString().toLowerCase(Locale.ROOT).trim();
}
}
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/actions/MassSetFieldAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/actions/SortTabsAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++;
}

Expand Down Expand Up @@ -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("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,7 +51,7 @@ public EntryTypeList(List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -235,7 +236,7 @@ public void setFields(List<String> 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;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/desktop/JabRefDesktop.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -136,7 +137,7 @@ public static boolean openExternalFileAnyFormat(final BibDatabaseContext databas
final Optional<ExternalFileType> 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;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/desktop/os/Linux.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -337,7 +338,7 @@ public static Optional<JComponent> getYesNoExtraComponent(FieldEditor fieldEdito
final String[] options = {"", "Yes", "No"};
JComboBox<String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()));
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/exporter/ExportFileFilter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.exporter;

import java.io.File;
import java.util.Locale;

import javax.swing.filechooser.FileFilter;

Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -178,7 +179,7 @@ public Optional<ExternalFileType> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

import javax.swing.JOptionPane;

Expand All @@ -30,7 +31,7 @@ public static boolean warnAssignmentSideEffects(List<AbstractGroup> 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
}
Expand Down Expand Up @@ -62,7 +63,7 @@ public static boolean warnAssignmentSideEffects(List<AbstractGroup> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/jabref/gui/keyboard/EmacsKeyBindings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Loading