From 3b22bba806892d546e7b89a6bf619ff4fdd4604f Mon Sep 17 00:00:00 2001 From: Simon Harrer Date: Wed, 25 Feb 2015 16:39:08 +0100 Subject: [PATCH] Automated improvements by IntelliJ IDEA analysis checks. - Organize Imports - Simplify Conditionals - Replace for with foreach loop - Make access to statisch methods on classes instead of instances - Remove uneccessary StringBuffer/Builder - use Strings instead --- src/main/java/net/sf/jabref/BibtexEntry.java | 14 +- src/main/java/net/sf/jabref/EntryEditor.java | 8 +- src/main/java/net/sf/jabref/FileTab.java | 3 - .../sf/jabref/FindUnlinkedFilesDialog.java | 13 +- src/main/java/net/sf/jabref/GUIGlobals.java | 1 - src/main/java/net/sf/jabref/JabRefFrame.java | 2 +- src/main/java/net/sf/jabref/JabRefMain.java | 2 +- .../java/net/sf/jabref/TableColumnsTab.java | 10 +- .../java/net/sf/jabref/UnknownEntryType.java | 2 - src/main/java/net/sf/jabref/bst/VM.java | 1 - .../net/sf/jabref/collab/StringAddChange.java | 12 +- .../sf/jabref/collab/StringRemoveChange.java | 12 +- .../net/sf/jabref/export/FileActions.java | 4 +- .../net/sf/jabref/export/IExportFormat.java | 1 - .../sf/jabref/export/layout/LayoutHelper.java | 4 - .../external/FileLinksUpgradeWarning.java | 14 +- .../net/sf/jabref/external/IconSelection.java | 2 - .../net/sf/jabref/external/PushToWinEdt.java | 6 +- .../net/sf/jabref/groups/KeywordGroup.java | 17 +-- .../java/net/sf/jabref/gui/CleanUpAction.java | 2 +- .../jabref/gui/DatabasePropertiesDialog.java | 2 +- .../net/sf/jabref/gui/MainTableFormat.java | 4 +- .../gui/MainTableSelectionListener.java | 7 +- .../gui/PreventDraggingJTableHeader.java | 1 - .../sf/jabref/imports/IEEEXploreFetcher.java | 1 - .../jabref/imports/MedlinePlainImporter.java | 126 ++++++++---------- .../net/sf/jabref/imports/OAI2Fetcher.java | 9 +- .../net/sf/jabref/imports/RisImporter.java | 1 - .../net/sf/jabref/imports/SPIRESFetcher.java | 22 +-- .../net/sf/jabref/oo/AutoDetectPaths.java | 11 +- 30 files changed, 105 insertions(+), 209 deletions(-) diff --git a/src/main/java/net/sf/jabref/BibtexEntry.java b/src/main/java/net/sf/jabref/BibtexEntry.java index 80381542d63..f9d861a7074 100644 --- a/src/main/java/net/sf/jabref/BibtexEntry.java +++ b/src/main/java/net/sf/jabref/BibtexEntry.java @@ -640,17 +640,17 @@ private void writeUnsorted(Writer out, FieldFormatter ff, boolean write) throws boolean hasWritten = false; // Write required fields first. String[] s = getRequiredFields(); - if (s != null) for (int i=0; i deprecatedFields = new HashSet(entry.FieldAliasesOldToNew.keySet()); + Set deprecatedFields = new HashSet(BibtexEntry.FieldAliasesOldToNew.keySet()); deprecatedFields.add("year"); deprecatedFields.add("month"); String[] optionalFieldsNotPrimaryOrDeprecated = Util.getRemainder(entry.getOptionalFields(), @@ -273,8 +271,8 @@ private void setupFieldPanels() { for(String field : entry.getOptionalFields()) { optionalFieldsAndAliases.add(field); - if(entry.FieldAliasesNewToOld.containsKey(field)) - optionalFieldsAndAliases.add(entry.FieldAliasesNewToOld.get(field)); + if(BibtexEntry.FieldAliasesNewToOld.containsKey(field)) + optionalFieldsAndAliases.add(BibtexEntry.FieldAliasesNewToOld.get(field)); } // Get all optional fields which are deprecated diff --git a/src/main/java/net/sf/jabref/FileTab.java b/src/main/java/net/sf/jabref/FileTab.java index a14512162bd..336916d3857 100644 --- a/src/main/java/net/sf/jabref/FileTab.java +++ b/src/main/java/net/sf/jabref/FileTab.java @@ -16,11 +16,8 @@ package net.sf.jabref; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Enumeration; -import java.util.Iterator; import javax.swing.*; import javax.swing.event.ChangeListener; diff --git a/src/main/java/net/sf/jabref/FindUnlinkedFilesDialog.java b/src/main/java/net/sf/jabref/FindUnlinkedFilesDialog.java index 09972dba143..06f3b0fba66 100644 --- a/src/main/java/net/sf/jabref/FindUnlinkedFilesDialog.java +++ b/src/main/java/net/sf/jabref/FindUnlinkedFilesDialog.java @@ -561,17 +561,8 @@ public void stateChanged(ChangeEvent e) { protected void importFinishedHandler(int count, List errors) { if (errors != null && errors.size() > 0) { - - StringBuilder warningInfo = new StringBuilder(); - warningInfo.append("The import finished with warnings:\n"); - warningInfo.append("There "); - warningInfo.append(errors.size() > 1 ? "were " : "was "); - warningInfo.append(errors.size()); - warningInfo.append(errors.size() > 1 ? " files" : " file"); - warningInfo.append(errors.size() > 1 ? " which" : " that"); - warningInfo.append(" could not be imported."); - - JOptionPane.showMessageDialog(this, warningInfo.toString(), + + JOptionPane.showMessageDialog(this, "The import finished with warnings:\n" + "There " + (errors.size() > 1 ? "were " : "was ") + errors.size() + (errors.size() > 1 ? " files" : " file") + (errors.size() > 1 ? " which" : " that") + " could not be imported.", Globals.lang("Warning"), JOptionPane.WARNING_MESSAGE); } diff --git a/src/main/java/net/sf/jabref/GUIGlobals.java b/src/main/java/net/sf/jabref/GUIGlobals.java index ac7bd9c2bf7..7205badc54a 100644 --- a/src/main/java/net/sf/jabref/GUIGlobals.java +++ b/src/main/java/net/sf/jabref/GUIGlobals.java @@ -27,7 +27,6 @@ import javax.swing.ImageIcon; import javax.swing.JLabel; -import javax.swing.SwingConstants; import net.sf.jabref.external.ExternalFileType; diff --git a/src/main/java/net/sf/jabref/JabRefFrame.java b/src/main/java/net/sf/jabref/JabRefFrame.java index 2e002802e2c..cc4bdd48c1e 100644 --- a/src/main/java/net/sf/jabref/JabRefFrame.java +++ b/src/main/java/net/sf/jabref/JabRefFrame.java @@ -879,7 +879,7 @@ private void macOSXRegistration() { } registerMethod = osxAdapter.getDeclaredMethod("setFileHandler", defArgs); if (registerMethod != null) { - Object[] args = {this, thisClass.getDeclaredMethod("openAction", new Class[] { String.class })}; + Object[] args = {this, thisClass.getDeclaredMethod("openAction", String.class)}; registerMethod.invoke(osxAdapter, args); } } diff --git a/src/main/java/net/sf/jabref/JabRefMain.java b/src/main/java/net/sf/jabref/JabRefMain.java index 7a0c056f245..ab7a924a273 100644 --- a/src/main/java/net/sf/jabref/JabRefMain.java +++ b/src/main/java/net/sf/jabref/JabRefMain.java @@ -79,7 +79,7 @@ public static void main(String[] args) { // We need to load this class dynamically, or otherwise the Java // runtime would crash while loading JabRefMain itself. Method method = Class.forName("net.sf.jabref.JabRef").getMethod( - "main", new Class[] { args.getClass() }); + "main", args.getClass()); method.invoke(null, new Object[] { args }); } catch (InvocationTargetException e) { diff --git a/src/main/java/net/sf/jabref/TableColumnsTab.java b/src/main/java/net/sf/jabref/TableColumnsTab.java index 5dc5a90860b..aad3f1d11ed 100644 --- a/src/main/java/net/sf/jabref/TableColumnsTab.java +++ b/src/main/java/net/sf/jabref/TableColumnsTab.java @@ -337,9 +337,9 @@ public void setValues() { int[] indicesToSelect = new int[listSize]; for(int i=0;i

"); - sb.append(Globals.lang("Added string")); - sb.append("

"); - sb.append(Globals.lang("Label")).append(":

"); - sb.append(string.getName()); - sb.append("

"); - sb.append(Globals.lang("Content")).append(":

"); - sb.append(string.getContent()); - sb.append(""); - tp.setText(sb.toString()); + tp.setText("

" + Globals.lang("Added string") + "

" + Globals.lang("Label") + ":

" + string.getName() + "

" + Globals.lang("Content") + ":

" + string.getContent() + ""); } diff --git a/src/main/java/net/sf/jabref/collab/StringRemoveChange.java b/src/main/java/net/sf/jabref/collab/StringRemoveChange.java index 130b9bef28a..3df67d6e4ab 100644 --- a/src/main/java/net/sf/jabref/collab/StringRemoveChange.java +++ b/src/main/java/net/sf/jabref/collab/StringRemoveChange.java @@ -40,17 +40,7 @@ public StringRemoveChange(BibtexString string, BibtexString tmpString, BibtexStr this.string = string; this.inMem = inMem; // Holds the version in memory. Check if it has been modified...? - StringBuffer sb = new StringBuffer(); - sb.append("

"); - sb.append(Globals.lang("Removed string")); - sb.append("

"); - sb.append(Globals.lang("Label")).append(":

"); - sb.append(string.getName()); - sb.append("

"); - sb.append(Globals.lang("Content")).append(":

"); - sb.append(string.getContent()); - sb.append(""); - tp.setText(sb.toString()); + tp.setText("

" + Globals.lang("Removed string") + "

" + Globals.lang("Label") + ":

" + string.getName() + "

" + Globals.lang("Content") + ":

" + string.getContent() + ""); } diff --git a/src/main/java/net/sf/jabref/export/FileActions.java b/src/main/java/net/sf/jabref/export/FileActions.java index a180b31e736..fa007457de8 100644 --- a/src/main/java/net/sf/jabref/export/FileActions.java +++ b/src/main/java/net/sf/jabref/export/FileActions.java @@ -301,8 +301,8 @@ public SaveSettings(boolean isSaveOperation, MetaData metaData) { if (storedSaveOrderConfig != null) { // follow the metaData SaveOrderConfig saveOrderConfig = new SaveOrderConfig(storedSaveOrderConfig); - assert (saveOrderConfig.saveInOriginalOrder == false); - assert (saveOrderConfig.saveInSpecifiedOrder == true); + assert (!saveOrderConfig.saveInOriginalOrder); + assert (saveOrderConfig.saveInSpecifiedOrder); pri = saveOrderConfig.sortCriteria[0].field; sec = saveOrderConfig.sortCriteria[1].field; ter = saveOrderConfig.sortCriteria[2].field; diff --git a/src/main/java/net/sf/jabref/export/IExportFormat.java b/src/main/java/net/sf/jabref/export/IExportFormat.java index b05e3c21c98..da572dd46b7 100644 --- a/src/main/java/net/sf/jabref/export/IExportFormat.java +++ b/src/main/java/net/sf/jabref/export/IExportFormat.java @@ -18,7 +18,6 @@ import net.sf.jabref.BibtexDatabase; import net.sf.jabref.MetaData; -import java.io.Writer; import java.util.Set; import javax.swing.filechooser.FileFilter; diff --git a/src/main/java/net/sf/jabref/export/layout/LayoutHelper.java b/src/main/java/net/sf/jabref/export/layout/LayoutHelper.java index e974789c02f..907373ec824 100644 --- a/src/main/java/net/sf/jabref/export/layout/LayoutHelper.java +++ b/src/main/java/net/sf/jabref/export/layout/LayoutHelper.java @@ -20,12 +20,8 @@ import java.io.Reader; import java.util.Vector; -import javax.swing.JOptionPane; - import net.sf.jabref.Globals; -import com.sun.star.ui.GlobalAcceleratorConfiguration; - /** * Helper class to get a Layout object. diff --git a/src/main/java/net/sf/jabref/external/FileLinksUpgradeWarning.java b/src/main/java/net/sf/jabref/external/FileLinksUpgradeWarning.java index 63f4d740859..da26695c700 100644 --- a/src/main/java/net/sf/jabref/external/FileLinksUpgradeWarning.java +++ b/src/main/java/net/sf/jabref/external/FileLinksUpgradeWarning.java @@ -87,19 +87,11 @@ public void performAction(BasePanel panel, ParserResult pr) { JCheckBox doNotShowDialog = new JCheckBox(Globals.lang("Do not show these options in the future"), false); - StringBuilder sb = new StringBuilder(""); - sb.append(Globals.lang("This database was written using an older version of JabRef.")); - sb.append("
"); - sb.append(Globals.lang("The current version features a new way of handling links to external files.
" - +"To take advantage of this, your links must be changed into the new format, and
" - +"JabRef must be configured to show the new links.")); - sb.append("

"); - sb.append(Globals.lang("Do you want JabRef to do the following operations?")); - sb.append(""); - JPanel message = new JPanel(); DefaultFormBuilder b = new DefaultFormBuilder(new FormLayout("left:pref", ""), message); - b.append(new JLabel(sb.toString())); + b.append(new JLabel("" + Globals.lang("This database was written using an older version of JabRef.") + "
" + Globals.lang("The current version features a new way of handling links to external files.
" + + "To take advantage of this, your links must be changed into the new format, and
" + + "JabRef must be configured to show the new links.") + "

" + Globals.lang("Do you want JabRef to do the following operations?") + "")); b.nextLine(); if (offerChangeSettings) { b.append(changeSettings); diff --git a/src/main/java/net/sf/jabref/external/IconSelection.java b/src/main/java/net/sf/jabref/external/IconSelection.java index e14dc6422b3..b022b02d7fd 100644 --- a/src/main/java/net/sf/jabref/external/IconSelection.java +++ b/src/main/java/net/sf/jabref/external/IconSelection.java @@ -19,8 +19,6 @@ import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; import java.util.*; import javax.swing.*; diff --git a/src/main/java/net/sf/jabref/external/PushToWinEdt.java b/src/main/java/net/sf/jabref/external/PushToWinEdt.java index aeb0051a935..09d72bddb1f 100644 --- a/src/main/java/net/sf/jabref/external/PushToWinEdt.java +++ b/src/main/java/net/sf/jabref/external/PushToWinEdt.java @@ -63,11 +63,7 @@ public void pushEntries(BibtexDatabase database, BibtexEntry[] entries, String k } try { - StringBuffer toSend = new StringBuffer("\"[InsText('") - .append(Globals.prefs.get("citeCommandWinEdt")).append("{") - .append(keyString.replaceAll("'", "''")) - .append("}');]\""); - Runtime.getRuntime().exec(new String[] {winEdt, toSend.toString()}); + Runtime.getRuntime().exec(new String[] {winEdt, "\"[InsText('" + Globals.prefs.get("citeCommandWinEdt") + "{" + keyString.replaceAll("'", "''") + "}');]\""}); } diff --git a/src/main/java/net/sf/jabref/groups/KeywordGroup.java b/src/main/java/net/sf/jabref/groups/KeywordGroup.java index 2dd623d9c1e..e3715345c7b 100644 --- a/src/main/java/net/sf/jabref/groups/KeywordGroup.java +++ b/src/main/java/net/sf/jabref/groups/KeywordGroup.java @@ -17,7 +17,6 @@ import java.util.Map; import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; import javax.swing.undo.AbstractUndoableEdit; @@ -339,19 +338,16 @@ public String getDescription() { public static String getDescriptionForPreview(String field, String expr, boolean caseSensitive, boolean regExp) { - StringBuffer sb = new StringBuffer(); - sb.append(regExp ? Globals.lang( + return (regExp ? Globals.lang( "This group contains entries whose %0 field contains the regular expression %1", field, Util.quoteForHTML(expr)) : Globals.lang( - "This group contains entries whose %0 field contains the keyword %1", - field, Util.quoteForHTML(expr))); - sb.append(" (").append(caseSensitive ? Globals.lang("case sensitive") - : Globals.lang("case insensitive")).append("). "); - sb.append(regExp ? Globals.lang( + "This group contains entries whose %0 field contains the keyword %1", + field, Util.quoteForHTML(expr))) + " (" + (caseSensitive ? Globals.lang("case sensitive") + : Globals.lang("case insensitive")) + "). " + (regExp ? Globals.lang( "Entries cannot be manually assigned to or removed from this group.") : Globals.lang( - "Additionally, entries whose %0 field does not contain " + "Additionally, entries whose %0 field does not contain " + "%1 can be assigned manually to this group by selecting them " + "then using either drag and drop or the context menu. " + "This process adds the term %1 to " @@ -360,8 +356,7 @@ public static String getDescriptionForPreview(String field, String expr, + "then using the context menu. " + "This process removes the term %1 from " + "each entry's %0 field.", - field, Util.quoteForHTML(expr))); - return sb.toString(); + field, Util.quoteForHTML(expr))); } public String getShortDescription() { diff --git a/src/main/java/net/sf/jabref/gui/CleanUpAction.java b/src/main/java/net/sf/jabref/gui/CleanUpAction.java index 83cb4420584..2d17841960f 100644 --- a/src/main/java/net/sf/jabref/gui/CleanUpAction.java +++ b/src/main/java/net/sf/jabref/gui/CleanUpAction.java @@ -652,7 +652,7 @@ private void doConvertLaTeX(BibtexEntry entry, NamedCompound ce) { */ private void doConvertToBiblatex(BibtexEntry entry, NamedCompound ce) { - for (Map.Entry alias : entry.FieldAliasesOldToNew.entrySet()) { + for (Map.Entry alias : BibtexEntry.FieldAliasesOldToNew.entrySet()) { String oldFieldName = alias.getKey(); String newFieldName = alias.getValue(); String oldValue = entry.getField(oldFieldName); diff --git a/src/main/java/net/sf/jabref/gui/DatabasePropertiesDialog.java b/src/main/java/net/sf/jabref/gui/DatabasePropertiesDialog.java index c0b15e294a2..0e0aa811540 100644 --- a/src/main/java/net/sf/jabref/gui/DatabasePropertiesDialog.java +++ b/src/main/java/net/sf/jabref/gui/DatabasePropertiesDialog.java @@ -307,7 +307,7 @@ public void setValues() { saveInOriginalOrder.setSelected(true); selected = false; } else { - assert (saveOrderConfig.saveInSpecifiedOrder == true); + assert (saveOrderConfig.saveInSpecifiedOrder); saveInSpecifiedOrder.setSelected(true); selected = true; } diff --git a/src/main/java/net/sf/jabref/gui/MainTableFormat.java b/src/main/java/net/sf/jabref/gui/MainTableFormat.java index 1158b3e9ba2..e93f2101017 100644 --- a/src/main/java/net/sf/jabref/gui/MainTableFormat.java +++ b/src/main/java/net/sf/jabref/gui/MainTableFormat.java @@ -413,8 +413,8 @@ public void updateTableFormat() { if (Globals.prefs.getBoolean("extraFileColumns")) { String[] desiredColumns = Globals.prefs.getStringArray("listOfFileColumns"); - for(int i=0;i importEntries(InputStream stream, OutputPrinter status) } String[] entries = sb.toString().replaceAll("\u2013", "-").replaceAll("\u2014", "--").replaceAll("\u2015", "--").split("\\n\\n"); - for (int i = 0; i < entries.length; i++){ + for (String entry1 : entries) { - if (entries[i].trim().length() == 0) + if (entry1.trim().length() == 0) continue; String type = "", author = "", editor = "", comment = ""; HashMap hm = new HashMap(); - String[] fields = entries[i].split("\n"); + String[] fields = entry1.split("\n"); + + for (int j = 0; j < fields.length; j++) { + if (fields[j].equals("")) + continue; - for (int j = 0; j < fields.length; j++){ - if(fields[j].equals("")) - continue; - StringBuffer current = new StringBuffer(fields[j]); boolean done = false; - - while (!done && (j < fields.length-1)) { - if(fields[j+1].length() <=4 ) - System.out.println("aaa"); - if (fields[j+1].charAt(4) != '-') { + + while (!done && (j < fields.length - 1)) { + if (fields[j + 1].length() <= 4) + System.out.println("aaa"); + if (fields[j + 1].charAt(4) != '-') { if ((current.length() > 0) - && !Character.isWhitespace(current.charAt(current.length()-1))) + && !Character.isWhitespace(current.charAt(current.length() - 1))) current.append(' '); - current.append(fields[j+1].trim()); + current.append(fields[j + 1].trim()); j++; } else done = true; } String entry = current.toString(); - + String lab = entry.substring(0, entry.indexOf('-')).trim(); - String val = entry.substring(entry.indexOf('-')+1).trim(); - if (lab.equals("PT")){ - val = val.toLowerCase(); + String val = entry.substring(entry.indexOf('-') + 1).trim(); + if (lab.equals("PT")) { + val = val.toLowerCase(); if (val.equals("BOOK")) type = "book"; - else if (val.equals("journal article") - || val.equals("classical article") - || val.equals("corrected and republished article") - || val.equals("historical article") - || val.equals("introductory journal article") - || val.equals("newspaper article")) type = "article"; + else if (val.equals("journal article") + || val.equals("classical article") + || val.equals("corrected and republished article") + || val.equals("historical article") + || val.equals("introductory journal article") + || val.equals("newspaper article")) type = "article"; else if (val.equals("clinical conference") - || val.equals("consensus development conference") - || val.equals("consensus development conference, NIH")) type = "conference"; + || val.equals("consensus development conference") + || val.equals("consensus development conference, NIH")) type = "conference"; else if (val.equals("technical report")) type = "techreport"; else if (val.equals("editorial")) type = "inproceedings";//"incollection";"inbook"; else if (val.equals("overall")) type = "proceedings"; - else if(type.equals("")) type = "other"; - - }else if (lab.equals("TI")) { + else if (type.equals("")) type = "other"; + + } else if (lab.equals("TI")) { String oldVal = hm.get("title"); if (oldVal == null) hm.put("title", val); else { if (oldVal.endsWith(":") || oldVal.endsWith(".") || oldVal.endsWith("?")) - hm.put("title", oldVal+" "+val); + hm.put("title", oldVal + " " + val); else - hm.put("title", oldVal+": "+val); + hm.put("title", oldVal + ": " + val); } } - // = - // val; + // = + // val; else if (lab.equals("BTI") || lab.equals("CTI")) { hm.put("booktitle", val); - } - else if (lab.equals("FAU")) { + } else if (lab.equals("FAU")) { if (author.equals("")) // don't add " and " for the first author author = val; else author += " and " + val; - } - else if (lab.equals("FED")){ + } else if (lab.equals("FED")) { if (editor.equals("")) // don't add " and " for the first editor editor = val; else editor += " and " + val; - } - else if (lab.equals("JT")) { + } else if (lab.equals("JT")) { if (type.equals("inproceedings")) hm.put("booktitle", val); else hm.put("journal", val); - } + } else if (lab.equals("PG")) + hm.put("pages", val); - else if (lab.equals("PG")) - hm.put("pages", val); - // else if (lab.equals("STAT")) { // if (val.equals("MEDLINE")) // hm.put("publisher", "PubMed"); @@ -190,8 +185,8 @@ else if (lab.equals("PL")) hm.put("address", val); else if (lab.equals("IS")) hm.put("issn", val); - else if (lab.equals("VI")) - hm.put("volume", val); + else if (lab.equals("VI")) + hm.put("volume", val); // else if (lab.equals("")) // hm.put("number", val); else if (lab.equals("AB")) { @@ -199,40 +194,36 @@ else if (lab.equals("AB")) { if (oldAb == null) hm.put("abstract", val); else - hm.put("abstract", oldAb+"\n"+val); - } - else if ((lab.equals("DP"))) { + hm.put("abstract", oldAb + "\n" + val); + } else if ((lab.equals("DP"))) { String[] parts = val.split(" "); hm.put("year", parts[0]); if ((parts.length > 1) && (parts[1].length() > 0)) { - hm.put("month", parts[1]); + hm.put("month", parts[1]); } - } - - else if (lab.equals("MH") || lab.equals("OT")){ + } else if (lab.equals("MH") || lab.equals("OT")) { if (!hm.containsKey("keywords")) hm.put("keywords", val); - else{ + else { String kw = hm.get("keywords"); hm.put("keywords", kw + ", " + val); } - } - else if (lab.equals("CON") || lab.equals("CIN") || lab.equals("EIN") - || lab.equals("EFR") || lab.equals("CRI") || lab.equals("CRF") - || lab.equals("PRIN") || lab.equals("PROF") || lab.equals("RPI") - || lab.equals("RPF") || lab.equals("RIN") || lab.equals("ROF") - || lab.equals("UIN") || lab.equals("UOF") || lab.equals("SPIN") - || lab.equals("ORI")) { + } else if (lab.equals("CON") || lab.equals("CIN") || lab.equals("EIN") + || lab.equals("EFR") || lab.equals("CRI") || lab.equals("CRF") + || lab.equals("PRIN") || lab.equals("PROF") || lab.equals("RPI") + || lab.equals("RPF") || lab.equals("RIN") || lab.equals("ROF") + || lab.equals("UIN") || lab.equals("UOF") || lab.equals("SPIN") + || lab.equals("ORI")) { if (comment.length() > 0) - comment = comment+"\n"; - comment = comment+val; + comment = comment + "\n"; + comment = comment + val; } // // Added ID import 2005.12.01, Morten Alver: // else if (lab.equals("ID")) // hm.put("refid", val); // // Added doi import (sciencedirect.com) 2011.01.10, Alexander Hug - else if (lab.equals("AID")){ + else if (lab.equals("AID")) { String doi = val; - if (doi.startsWith("doi:")){ + if (doi.startsWith("doi:")) { doi = doi.replaceAll("(?i)doi:", "").trim(); hm.put("doi", doi); } @@ -250,19 +241,18 @@ else if (lab.equals("AID")){ if (comment.length() > 0) { hm.put("comment", comment); } - + BibtexEntry b = new BibtexEntry(BibtexFields.DEFAULT_BIBTEXENTRY_ID, Globals .getEntryType(type)); // id assumes an existing database so don't // Remove empty fields: ArrayList toRemove = new ArrayList(); - for (Iterator it = hm.keySet().iterator(); it.hasNext();) { - Object key = it.next(); + for (String key : hm.keySet()) { String content = hm.get(key); if ((content == null) || (content.trim().length() == 0)) toRemove.add(key); } - for (Iterator iterator = toRemove.iterator(); iterator.hasNext();) { + for (Iterator iterator = toRemove.iterator(); iterator.hasNext(); ) { hm.remove(iterator.next()); } diff --git a/src/main/java/net/sf/jabref/imports/OAI2Fetcher.java b/src/main/java/net/sf/jabref/imports/OAI2Fetcher.java index 16c25bb3b2f..f88f74ba44e 100644 --- a/src/main/java/net/sf/jabref/imports/OAI2Fetcher.java +++ b/src/main/java/net/sf/jabref/imports/OAI2Fetcher.java @@ -150,14 +150,7 @@ public String constructUrl(String key) { } catch (UnsupportedEncodingException e) { return ""; } - StringBuffer sb = new StringBuffer("http://").append(oai2Host).append("/"); - sb.append(oai2Script).append("?"); - sb.append("verb=GetRecord"); - sb.append("&identifier="); - sb.append(oai2PrefixIdentifier); - sb.append(identifier); - sb.append("&metadataPrefix=").append(oai2MetaDataPrefix); - return sb.toString(); + return "http://" + oai2Host + "/" + oai2Script + "?" + "verb=GetRecord" + "&identifier=" + oai2PrefixIdentifier + identifier + "&metadataPrefix=" + oai2MetaDataPrefix; } /** diff --git a/src/main/java/net/sf/jabref/imports/RisImporter.java b/src/main/java/net/sf/jabref/imports/RisImporter.java index c492af43b7d..5057b32bdf7 100644 --- a/src/main/java/net/sf/jabref/imports/RisImporter.java +++ b/src/main/java/net/sf/jabref/imports/RisImporter.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import net.sf.jabref.BibtexEntry; import net.sf.jabref.Globals; diff --git a/src/main/java/net/sf/jabref/imports/SPIRESFetcher.java b/src/main/java/net/sf/jabref/imports/SPIRESFetcher.java index 5160aedb8c0..e18af615240 100644 --- a/src/main/java/net/sf/jabref/imports/SPIRESFetcher.java +++ b/src/main/java/net/sf/jabref/imports/SPIRESFetcher.java @@ -66,13 +66,7 @@ public String constructUrl(String key) { } catch (UnsupportedEncodingException e) { return ""; } - StringBuffer sb = new StringBuffer("http://").append(spiresHost) - .append("/"); - sb.append("spires/find/hep/www").append("?"); - sb.append("rawcmd=find+"); - sb.append(identifier); - sb.append("&FORMAT=WWWBRIEFBIBTEX&SEQUENCE="); - return sb.toString(); + return "http://" + spiresHost + "/" + "spires/find/hep/www" + "?" + "rawcmd=find+" + identifier + "&FORMAT=WWWBRIEFBIBTEX&SEQUENCE="; } /** @@ -91,12 +85,7 @@ public static String constructUrlFromSlaccitation(String slaccitation) { key = URLEncoder.encode(key, "UTF-8"); } catch (UnsupportedEncodingException ignored) { } - StringBuffer sb = new StringBuffer("http://").append(spiresHost) - .append("/"); - sb.append("spires/find/hep/www").append("?"); - sb.append("rawcmd=find+").append(cmd).append("+"); - sb.append(key); - return sb.toString(); + return "http://" + spiresHost + "/" + "spires/find/hep/www" + "?" + "rawcmd=find+" + cmd + "+" + key; } /** @@ -112,12 +101,7 @@ public static String constructUrlFromEprint(String eprint) { } catch (UnsupportedEncodingException e) { return ""; } - StringBuffer sb = new StringBuffer("http://").append(spiresHost) - .append("/"); - sb.append("spires/find/hep/www").append("?"); - sb.append("rawcmd=find+eprint+"); - sb.append(key); - return sb.toString(); + return "http://" + spiresHost + "/" + "spires/find/hep/www" + "?" + "rawcmd=find+eprint+" + key; } /** diff --git a/src/main/java/net/sf/jabref/oo/AutoDetectPaths.java b/src/main/java/net/sf/jabref/oo/AutoDetectPaths.java index 24944ad081a..2728a2e9b35 100644 --- a/src/main/java/net/sf/jabref/oo/AutoDetectPaths.java +++ b/src/main/java/net/sf/jabref/oo/AutoDetectPaths.java @@ -267,14 +267,9 @@ public static boolean checkAutoDetectedPaths() { if (Globals.prefs.hasKey("ooUnoilPath") && Globals.prefs.hasKey("ooJurtPath") && Globals.prefs.hasKey("ooExecutablePath")) { - if (new File(Globals.prefs.get("ooUnoilPath"), "unoil.jar").exists() - && new File(Globals.prefs.get("ooJurtPath"), "jurt.jar").exists() - && new File(Globals.prefs.get("ooExecutablePath")).exists()) { - return true; - } - else { - return false; - } + return new File(Globals.prefs.get("ooUnoilPath"), "unoil.jar").exists() + && new File(Globals.prefs.get("ooJurtPath"), "jurt.jar").exists() + && new File(Globals.prefs.get("ooExecutablePath")).exists(); } else return false; }