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

Removed a number of warnings, added copyright etc #266

Merged
merged 2 commits into from
Oct 29, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 @@ -343,16 +343,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 @@ -366,7 +366,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 @@ -413,14 +413,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 @@ -452,7 +452,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 @@ -964,7 +964,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 @@ -985,13 +985,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 @@ -1047,10 +1048,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 @@ -1060,7 +1061,7 @@ private int[] getRgb(String value) {
values[1] = 0;
values[2] = 0;
}
return values;
return values;
}

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

// Ignored
}
}

Expand Down Expand Up @@ -1254,8 +1255,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 @@ -1266,7 +1267,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 @@ -1279,7 +1280,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 @@ -1310,12 +1311,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 @@ -1417,7 +1418,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 @@ -1434,7 +1435,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 @@ -1454,7 +1455,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 @@ -1475,7 +1476,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 @@ -1539,7 +1540,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