X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Furls%2FIdentifiersUrlProvider.java;h=c298639253029a0df96f3b6278f95a2634f7c9f8;hb=baca3e1d25692175ab0d6e392427c0ff97534c37;hp=0dab7198e2fff8c617d09be7c63bb60d7bdf7a3c;hpb=8e7cf85a7f61f425e808cac53ead7bc27e402242;p=jalview.git diff --git a/src/jalview/urls/IdentifiersUrlProvider.java b/src/jalview/urls/IdentifiersUrlProvider.java index 0dab719..c298639 100644 --- a/src/jalview/urls/IdentifiersUrlProvider.java +++ b/src/jalview/urls/IdentifiersUrlProvider.java @@ -63,7 +63,7 @@ public class IdentifiersUrlProvider extends UrlProviderImpl public IdentifiersUrlProvider(String cachedUrlList) { urls = readIdentifiers(IdOrgSettings.getDownloadLocation()); - selectedUrls = new ArrayList(); + selectedUrls = new ArrayList<>(); checkSelectionMatchesUrls(cachedUrlList); } @@ -75,19 +75,20 @@ public class IdentifiersUrlProvider extends UrlProviderImpl * @return hashmap of identifiers.org data, keyed by MIRIAM id */ @SuppressWarnings("unchecked") -private HashMap readIdentifiers(String idFileName) + private HashMap readIdentifiers(String idFileName) { // identifiers.org data - HashMap idData = new HashMap(); + HashMap idData = new HashMap<>(); String errorMessage = null; try { - // NOTE: THIS WILL FAIL IN SWINGJS BECAUSE IT INVOLVES A FILE READER - + // NOTE: THIS WILL FAIL IN SWINGJS BECAUSE IT INVOLVES A FILE READER + FileReader reader = new FileReader(idFileName); String key = ""; - Map obj = (Map) JSONUtils.parse(reader); + Map obj = (Map) JSONUtils + .parse(reader); if (obj.containsKey(ID_ORG_KEY)) { key = ID_ORG_KEY; @@ -98,7 +99,7 @@ private HashMap readIdentifiers(String idFileName) } else { - System.out.println( + jalview.bin.Console.outPrintln( "Unexpected key returned from identifiers jalview service"); return idData; } @@ -119,16 +120,21 @@ private HashMap readIdentifiers(String idFileName) } catch (IOException | ParseException e) { // unnecessary e.printStackTrace(); - // Note how in JavaScript we can grab the first bytes from any file reader. + // Note how in JavaScript we can grab the first bytes from any file + // reader. // Typical report here is "NetworkError" because the file does not exist. - // "https://." is coming from System.getProperty("user.home"), but this could + // "https://." is coming from System.getProperty("user.home"), but this + // could // be set by the page developer to anything, of course. - errorMessage = (/** @j2sNative String.fromCharCode.apply(null, reader.$in.is.buf.slice(0,12)) || */e.toString()); + errorMessage = e.toString(); idData.clear(); } // BH 2018 -- added more valuable report if (errorMessage != null) - System.err.println("IdentifiersUrlProvider: cannot read " + idFileName + ": " + errorMessage); + { + jalview.bin.Console.errPrintln("IdentifiersUrlProvider: cannot read " + idFileName + + ": " + errorMessage); + } return idData; } @@ -193,7 +199,7 @@ private HashMap readIdentifiers(String idFileName) @Override public List getLinksForMenu() { - List links = new ArrayList(); + List links = new ArrayList<>(); for (String key : selectedUrls) { links.add(urls.get(key).toStringWithTarget()); @@ -210,7 +216,7 @@ private HashMap readIdentifiers(String idFileName) @Override public void setUrlData(List links) { - selectedUrls = new ArrayList(); + selectedUrls = new ArrayList<>(); Iterator it = links.iterator(); while (it.hasNext())