Skip to content

Commit

Permalink
Merge pull request #266 from oscargus/warningremoval2
Browse files Browse the repository at this point in the history
Removed a number of warnings, added copyright etc
  • Loading branch information
simonharrer committed Oct 29, 2015
2 parents a7dfc10 + 1e86937 commit bb7c0f2
Show file tree
Hide file tree
Showing 91 changed files with 1,281 additions and 1,236 deletions.
21 changes: 18 additions & 3 deletions src/main/java/net/sf/jabref/JabRefExecutorService.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/* Copyright (C) 2003-2015 JabRef contributors.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package net.sf.jabref;

import java.util.concurrent.*;
Expand All @@ -17,7 +32,7 @@ public Thread newThread(Runnable r) {
return thread;
}
});
private final ConcurrentLinkedQueue<Thread> startedThreads = new ConcurrentLinkedQueue<Thread>();
private final ConcurrentLinkedQueue<Thread> startedThreads = new ConcurrentLinkedQueue<>();

private JabRefExecutorService() {}

Expand All @@ -43,7 +58,7 @@ public void executeAndWait(Runnable command) {
future.get();
return;
} catch (InterruptedException ignored) {

// Ignored
} catch (ExecutionException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -107,7 +122,7 @@ private void waitForThreadToFinish(Thread thread) {
startedThreads.remove(thread);
return;
} catch (InterruptedException ignored) {

// Ignored
}
}
}
Expand Down
55 changes: 28 additions & 27 deletions src/main/java/net/sf/jabref/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public class JabRefPreferences {
/**
* HashMap that contains all preferences which are set by default
*/
public final HashMap<String, Object> defaults = new HashMap<String, Object>();
public final HashMap<String, Object> defaults = new HashMap<>();

/* contents of the defaults HashMap that are defined in this class.
/* contents of the defaults HashMap that are defined in this class.
* There are more default parameters in this map which belong to separate preference classes.
*/
public static final String EMACS_PATH = "emacsPath";
Expand Down Expand Up @@ -342,16 +342,16 @@ public class JabRefPreferences {

public String WRAPPED_USERNAME;
public final String MARKING_WITH_NUMBER_PATTERN;

private int SHORTCUT_MASK = -1;

private final Preferences prefs;

private KeyBinds keyBinds = new KeyBinds();
private KeyBinds defaultKeyBinds = new KeyBinds();

private final HashSet<String> putBracesAroundCapitalsFields = new HashSet<String>(4);
private final HashSet<String> nonWrappableFields = new HashSet<String>(5);
private final HashSet<String> putBracesAroundCapitalsFields = new HashSet<>(4);
private final HashSet<String> nonWrappableFields = new HashSet<>(5);
private static GlobalLabelPattern keyPattern;

// Object containing custom export formats:
Expand All @@ -365,7 +365,7 @@ public class JabRefPreferences {
// Object containing info about customized entry editor tabs.
private EntryEditorTabList tabList;
// Map containing all registered external file types:
private final TreeSet<ExternalFileType> externalFileTypes = new TreeSet<ExternalFileType>();
private final TreeSet<ExternalFileType> externalFileTypes = new TreeSet<>();

private final ExternalFileType HTML_FALLBACK_TYPE = new ExternalFileType("URL", "html", "text/html", "", "www", IconTheme.JabRefIcon.WWW.getSmallIcon());

Expand Down Expand Up @@ -412,14 +412,14 @@ private JabRefPreferences() {
LOGGER.info("Could not import preferences from jabref.xml:" + e.getLocalizedMessage(), e);
}

// load user preferences
// load user preferences
prefs = Preferences.userNodeForPackage(JabRef.class);

defaults.put(TEXMAKER_PATH, OS.guessProgramPath("texmaker", "Texmaker"));
defaults.put(WIN_EDT_PATH, OS.guessProgramPath("WinEdt", "WinEdt Team\\WinEdt"));
defaults.put(LATEX_EDITOR_PATH, OS.guessProgramPath("LEd", "LEd"));
defaults.put(TEXSTUDIO_PATH, OS.guessProgramPath("texstudio", "TeXstudio"));

if (OS.OS_X) {
//defaults.put("pdfviewer", "/Applications/Preview.app");
//defaults.put("psviewer", "/Applications/Preview.app");
Expand Down Expand Up @@ -451,7 +451,7 @@ private JabRefPreferences() {
defaults.put(EMACS_PATH, "gnuclient");
defaults.put(EMACS_23, false);
defaults.put(EMACS_ADDITIONAL_PARAMETERS, "-batch -eval");

}
defaults.put(USE_PROXY, Boolean.FALSE);
defaults.put(PROXY_HOSTNAME, "my proxy host");
Expand Down Expand Up @@ -962,7 +962,7 @@ public void putStringArray(String key, String[] value) {

if (value.length > 0) {
StringBuilder linked = new StringBuilder();
for (int i = 0; i < value.length - 1; i++) {
for (int i = 0; i < (value.length - 1); i++) {
linked.append(makeEscape(value[i]));
linked.append(';');
}
Expand All @@ -983,13 +983,14 @@ public String[] getStringArray(String key) {
}

StringReader rd = new StringReader(names);
Vector<String> arr = new Vector<String>();
Vector<String> arr = new Vector<>();
String rs;
try {
while ((rs = getNextUnit(rd)) != null) {
arr.add(rs);
}
} catch (IOException ignored) {
// Ignored
}
String[] res = new String[arr.size()];
for (int i = 0; i < res.length; i++) {
Expand Down Expand Up @@ -1045,10 +1046,10 @@ public void putColor(String key, Color color) {
* @param value The key for this setting.
* @return The RGB values corresponding to this color setting.
*/
private int[] getRgb(String value) {
private static int[] getRgb(String value) {
int[] values = new int[3];
if (value != null && !value.isEmpty()) {

if ((value != null) && !value.isEmpty()) {
String[] elements = value.split(":");
values[0] = Integer.parseInt(elements[0]);
values[1] = Integer.parseInt(elements[1]);
Expand All @@ -1058,7 +1059,7 @@ private int[] getRgb(String value) {
values[1] = 0;
values[2] = 0;
}
return values;
return values;
}

/**
Expand Down Expand Up @@ -1118,7 +1119,7 @@ private KeyStroke getKeyForMac(KeyStroke ks) {
try {
SHORTCUT_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
} catch (Throwable ignored) {

// Ignored
}
}

Expand Down Expand Up @@ -1252,8 +1253,8 @@ private void restoreKeyBindings() {
String[] bindings = getStringArray("bindings");

// Then set up the key bindings HashMap.
if (bindNames == null || bindings == null
|| bindNames.length != bindings.length) {
if ((bindNames == null) || (bindings == null)
|| (bindNames.length != bindings.length)) {
// Nothing defined in Preferences, or something is wrong.
keyBinds = new KeyBinds();
return;
Expand All @@ -1264,7 +1265,7 @@ private void restoreKeyBindings() {
}
}

private String getNextUnit(Reader data) throws IOException {
private static String getNextUnit(Reader data) throws IOException {
// character last read
// -1 if end of stream
// initialization necessary, because of Java compiler
Expand All @@ -1277,7 +1278,7 @@ private String getNextUnit(Reader data) throws IOException {
boolean done = false;

StringBuilder res = new StringBuilder();
while (!done && (c = data.read()) != -1) {
while (!done && ((c = data.read()) != -1)) {
if (c == '\\') {
if (!escape) {
escape = true;
Expand Down Expand Up @@ -1308,12 +1309,12 @@ private String getNextUnit(Reader data) throws IOException {
}
}

private String makeEscape(String s) {
private static String makeEscape(String s) {
StringBuilder sb = new StringBuilder();
int c;
for (int i = 0; i < s.length(); i++) {
c = s.charAt(i);
if (c == '\\' || c == ';') {
if ((c == '\\') || (c == ';')) {
sb.append('\\');
}
sb.append((char) c);
Expand Down Expand Up @@ -1415,7 +1416,7 @@ public ExternalFileType getExternalFileTypeByName(String name) {
*/
public ExternalFileType getExternalFileTypeByExt(String extension) {
for (ExternalFileType type : externalFileTypes) {
if (type.getExtension() != null && type.getExtension().equalsIgnoreCase(extension)) {
if ((type.getExtension() != null) && type.getExtension().equalsIgnoreCase(extension)) {
return type;
}
}
Expand All @@ -1432,7 +1433,7 @@ public ExternalFileType getExternalFileTypeForName(String filename) {
int longestFound = -1;
ExternalFileType foundType = null;
for (ExternalFileType type : externalFileTypes) {
if (type.getExtension() != null && filename.toLowerCase().
if ((type.getExtension() != null) && filename.toLowerCase().
endsWith(type.getExtension().toLowerCase())) {
if (type.getExtension().length() > longestFound) {
longestFound = type.getExtension().length();
Expand All @@ -1452,7 +1453,7 @@ public ExternalFileType getExternalFileTypeForName(String filename) {
*/
public ExternalFileType getExternalFileTypeByMimeType(String mimeType) {
for (ExternalFileType type : externalFileTypes) {
if (type.getMimeType() != null && type.getMimeType().equals(mimeType)) {
if ((type.getMimeType() != null) && type.getMimeType().equals(mimeType)) {
return type;
}
}
Expand All @@ -1473,7 +1474,7 @@ public void setExternalFileTypes(List<ExternalFileType> types) {
// First find a list of the default types:
List<ExternalFileType> defTypes = getDefaultExternalFileTypes();
// Make a list of types that are unchanged:
List<ExternalFileType> unchanged = new ArrayList<ExternalFileType>();
List<ExternalFileType> unchanged = new ArrayList<>();

externalFileTypes.clear();
for (ExternalFileType type : types) {
Expand Down Expand Up @@ -1537,7 +1538,7 @@ public void updateExternalFileTypes() {
// Read the prefs information for file types:
String[][] vals = StringUtil.decodeStringDoubleArray(prefs.get("externalFileTypes", ""));
for (String[] val : vals) {
if (val.length == 2 && val[1].equals(JabRefPreferences.FILE_TYPE_REMOVED_FLAG)) {
if ((val.length == 2) && val[1].equals(JabRefPreferences.FILE_TYPE_REMOVED_FLAG)) {
// This entry indicates that a default entry type should be removed:
ExternalFileType toRemove = null;
for (ExternalFileType type : types) {
Expand Down
Loading

0 comments on commit bb7c0f2

Please sign in to comment.