From 0424fec4a6d71684f56978f61eadd4ceb0652a60 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 4 Apr 2019 20:37:32 +0100 Subject: [PATCH] JAL-3220 j2sIgnore on main methods on test / utility classes --- src/jalview/gui/BlogReader.java | 8 ++-- src/jalview/gui/Console.java | 5 ++- src/jalview/gui/RestServiceEditorPane.java | 12 ++++-- src/jalview/gui/WsJobParameters.java | 7 ++-- src/jalview/io/AppletFormatAdapter.java | 8 ++++ src/jalview/io/IdentifyFile.java | 5 +++ src/jalview/io/NewickFile.java | 10 ++--- src/jalview/io/packed/ParsePackedSet.java | 7 ++-- src/jalview/schemes/ResidueProperties.java | 4 ++ src/jalview/util/GroupUrlLink.java | 9 +++++ src/jalview/ws/jws2/Jws2Discoverer.java | 60 ++++++++++++++-------------- test/jalview/gui/MouseEventDemo.java | 3 ++ test/jalview/ws/SequenceFetcherTest.java | 1 + 13 files changed, 90 insertions(+), 49 deletions(-) diff --git a/src/jalview/gui/BlogReader.java b/src/jalview/gui/BlogReader.java index 9d68af1..c515e6c 100644 --- a/src/jalview/gui/BlogReader.java +++ b/src/jalview/gui/BlogReader.java @@ -219,7 +219,7 @@ public class BlogReader extends JPanel } }; - }; + } private JLabel lblChannels = new JLabel(); @@ -365,7 +365,6 @@ public class BlogReader extends JPanel } catch (Exception x) { } - ; if (chan != null && chan.getItems() != null) { Cache.log.debug("Scanning news items: newsnew=" + newsnew @@ -752,6 +751,10 @@ public class BlogReader extends JPanel } } + /** + * @j2sIgnore + * @param args + */ public static void main(String args[]) { // this tests the detection of new news based on the last read date stored @@ -788,7 +791,6 @@ public class BlogReader extends JPanel } catch (InterruptedException x) { } - ; } while (me.isVisible()); if (me.isNewsNew()) diff --git a/src/jalview/gui/Console.java b/src/jalview/gui/Console.java index 4c019a6..2e88eeb 100644 --- a/src/jalview/gui/Console.java +++ b/src/jalview/gui/Console.java @@ -497,7 +497,6 @@ public class Console extends WindowAdapter } catch (InterruptedException e) { } - ; } } else @@ -633,6 +632,10 @@ public class Console extends WindowAdapter return input; } + /** + * @j2sIgnore + * @param arg + */ public static void main(String[] arg) { new Console().test(); // create console with not reference diff --git a/src/jalview/gui/RestServiceEditorPane.java b/src/jalview/gui/RestServiceEditorPane.java index 2e2593b..cda76d9 100644 --- a/src/jalview/gui/RestServiceEditorPane.java +++ b/src/jalview/gui/RestServiceEditorPane.java @@ -147,9 +147,9 @@ public class RestServiceEditorPane extends GRestServiceEditorPane } - Vector _iparam = new Vector(); + Vector _iparam = new Vector<>(); - Vector _rparam = new Vector(); + Vector _rparam = new Vector<>(); /** * generate an editable URL service string and parameter list using the @@ -351,7 +351,7 @@ public class RestServiceEditorPane extends GRestServiceEditorPane private boolean updateServiceFromGui() { - Map inputTypes = new HashMap(); + Map inputTypes = new HashMap<>(); StringBuffer warnings = new StringBuffer(); for (String its : _iparam) { @@ -455,6 +455,10 @@ public class RestServiceEditorPane extends GRestServiceEditorPane } + /** + * @j2sIgnore + * @param args + */ public static void main(String[] args) { if (args.length == 0) @@ -463,6 +467,7 @@ public class RestServiceEditorPane extends GRestServiceEditorPane { boolean visible = true; + @Override public void run() { boolean nulserv = true; @@ -514,7 +519,6 @@ public class RestServiceEditorPane extends GRestServiceEditorPane } catch (Exception x) { } - ; } visible = true; } diff --git a/src/jalview/gui/WsJobParameters.java b/src/jalview/gui/WsJobParameters.java index 10798f6..976e551 100644 --- a/src/jalview/gui/WsJobParameters.java +++ b/src/jalview/gui/WsJobParameters.java @@ -69,14 +69,13 @@ import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import net.miginfocom.swing.MigLayout; - import compbio.metadata.Argument; import compbio.metadata.Option; import compbio.metadata.Parameter; import compbio.metadata.Preset; import compbio.metadata.PresetManager; import compbio.metadata.RunnerConfig; +import net.miginfocom.swing.MigLayout; /** * job parameter editing/browsing dialog box. User can browse existing settings @@ -959,6 +958,7 @@ public class WsJobParameters extends JPanel implements ItemListener, * testing method - grab a service and parameter set and show the window * * @param args + * @j2sIgnore */ public static void main(String[] args) { @@ -967,7 +967,7 @@ public class WsJobParameters extends JPanel implements ItemListener, int p = 0; if (args.length > 0) { - Vector services = new Vector(); + Vector services = new Vector<>(); services.addElement(args[p++]); Jws2Discoverer.getDiscoverer().setServiceUrls(services); } @@ -1183,7 +1183,6 @@ public class WsJobParameters extends JPanel implements ItemListener, { inter = true; } - ; } jf.dispose(); } diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index 6db04a0..4916bb3 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -159,7 +159,9 @@ public class AppletFormatAdapter this.selectedFile = selectedFile; if (selectedFile != null) + { this.inFile = selectedFile.getPath(); + } this.inFile = file; try { @@ -435,7 +437,9 @@ public class AppletFormatAdapter public static DataSourceType checkProtocol(Object dataObject) { if(dataObject instanceof File) + { return DataSourceType.FILE; + } String data = dataObject.toString(); DataSourceType protocol = DataSourceType.PASTE; @@ -456,6 +460,10 @@ public class AppletFormatAdapter return protocol; } + /** + * @param args + * @j2sIgnore + */ public static void main(String[] args) { int i = 0; diff --git a/src/jalview/io/IdentifyFile.java b/src/jalview/io/IdentifyFile.java index ed67af8..b312474 100755 --- a/src/jalview/io/IdentifyFile.java +++ b/src/jalview/io/IdentifyFile.java @@ -452,6 +452,11 @@ public class IdentifyFile return true; } + /** + * + * @param args + * @j2sIgnore + */ public static void main(String[] args) { for (int i = 0; args != null && i < args.length; i++) diff --git a/src/jalview/io/NewickFile.java b/src/jalview/io/NewickFile.java index 517701b..1e9c5ed 100755 --- a/src/jalview/io/NewickFile.java +++ b/src/jalview/io/NewickFile.java @@ -316,8 +316,6 @@ public class NewickFile extends FileParse continue; } - - ; d++; if (c.right() == null) @@ -417,8 +415,6 @@ public class NewickFile extends FileParse Error = ErrorStringrange(Error, "Unterminated comment", 3, fcp, nf); } - - ; } // Parse simpler field strings String fstring = nf.substring(ncp, fcp); @@ -942,7 +938,11 @@ public class NewickFile extends FileParse } } - // Test + /** + * + * @param args + * @j2sIgnore + */ public static void main(String[] args) { try diff --git a/src/jalview/io/packed/ParsePackedSet.java b/src/jalview/io/packed/ParsePackedSet.java index 1635682..d40446d 100644 --- a/src/jalview/io/packed/ParsePackedSet.java +++ b/src/jalview/io/packed/ParsePackedSet.java @@ -52,7 +52,7 @@ public class ParsePackedSet public Object[] getAlignment(JalviewDataset context, Iterable files) throws Exception { - List rslt = new ArrayList(); + List rslt = new ArrayList<>(); if (context == null) { context = new JalviewDataset(); @@ -151,7 +151,7 @@ public class ParsePackedSet // if not, create one. if (context.featureColours == null) { - context.featureColours = new HashMap(); + context.featureColours = new HashMap<>(); } try { @@ -223,12 +223,13 @@ public class ParsePackedSet * would be created. * * @param args + * @j2sIgnore */ public static void main(String args[]) { // make data providers from the set of keys/files int i = 0; - List dp = new ArrayList(); + List dp = new ArrayList<>(); while ((i + 1) < args.length) { String type = args[i++]; diff --git a/src/jalview/schemes/ResidueProperties.java b/src/jalview/schemes/ResidueProperties.java index d435065..5f84ca0 100755 --- a/src/jalview/schemes/ResidueProperties.java +++ b/src/jalview/schemes/ResidueProperties.java @@ -2278,6 +2278,10 @@ public class ResidueProperties // main method generates perl representation of residue property hash // / cut here + /** + * @j2sIgnore + * @param args + */ public static void main(String[] args) { Hashtable> aaProps = new Hashtable<>(); diff --git a/src/jalview/util/GroupUrlLink.java b/src/jalview/util/GroupUrlLink.java index a26dfbb..67309a0 100644 --- a/src/jalview/util/GroupUrlLink.java +++ b/src/jalview/util/GroupUrlLink.java @@ -36,6 +36,7 @@ public class GroupUrlLink public int urlLength; + @Override public String toString() { return "Generated url is estimated to be too long (" + urlLength @@ -317,10 +318,12 @@ public class GroupUrlLink private String _replaceFor(String token) { for (int i = 0; i < mtch.length; i++) + { if (segs[i] > -1 && mtch[i].equals(token)) { return regexReplace[i]; } + } return null; } @@ -744,6 +747,7 @@ public class GroupUrlLink return r; } + @Override public String toString() { StringBuffer result = new StringBuffer(); @@ -812,6 +816,11 @@ public class GroupUrlLink } } + /** + * + * @param argv + * @j2sIgnore + */ public static void main(String argv[]) { // note - JAL-1383 - these services are all dead diff --git a/src/jalview/ws/jws2/Jws2Discoverer.java b/src/jalview/ws/jws2/Jws2Discoverer.java index 5319eab..516a719 100644 --- a/src/jalview/ws/jws2/Jws2Discoverer.java +++ b/src/jalview/ws/jws2/Jws2Discoverer.java @@ -178,7 +178,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI running = true; // first set up exclusion list if needed - final Set ignoredServices = new HashSet(); + final Set ignoredServices = new HashSet<>(); for (String ignored : Cache .getDefault("IGNORED_JABAWS_SERVICETYPES", "").split("\\|")) { @@ -217,9 +217,9 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { validServiceUrls.removeAllElements(); } - ArrayList svctypes = new ArrayList(); + ArrayList svctypes = new ArrayList<>(); - List qrys = new ArrayList(); + List qrys = new ArrayList<>(); for (final String jwsserver : getServiceUrls()) { JabaWsServerQuery squery = new JabaWsServerQuery(this, jwsserver); @@ -249,7 +249,6 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI } catch (Exception e) { } - ; for (JabaWsServerQuery squery : qrys) { if (squery.isRunning()) @@ -285,7 +284,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI + svctypes.indexOf(svc.serviceType); } jalview.util.QuickSort.sort(spos, svcs); - services = new Vector(); + services = new Vector<>(); for (Jws2Instance svc : svcs) { if (!ignoredServices.contains(svc.serviceType)) @@ -312,7 +311,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { if (services == null) { - services = new Vector(); + services = new Vector<>(); } System.out.println( "Discovered service: " + jwsservers + " " + service.toString()); @@ -329,7 +328,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI service.hasParameters(); if (validServiceUrls == null) { - validServiceUrls = new Vector(); + validServiceUrls = new Vector<>(); } validServiceUrls.add(jwsservers); } @@ -363,10 +362,10 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI * for moment we keep them separate. */ JMenu atpoint; - List enumerableServices = new ArrayList(); + List enumerableServices = new ArrayList<>(); // jws2al.removeAll(); - Map preferredHosts = new HashMap(); - Map> alternates = new HashMap>(); + Map preferredHosts = new HashMap<>(); + Map> alternates = new HashMap<>(); for (Jws2Instance service : services.toArray(new Jws2Instance[0])) { if (!isRecalculable(service.action)) @@ -395,7 +394,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { if (ph == null) { - ph = new ArrayList(); + ph = new ArrayList<>(); } ph.add(service); alternates.put(service.serviceType, ph); @@ -457,7 +456,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI sv.action, sv); changeSupport.firePropertyChange("services", new Vector(), services); - }; + } }).start(); } @@ -483,17 +482,17 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI */ JMenu atpoint; - List hostLabels = new ArrayList(); - Hashtable lasthostFor = new Hashtable(); - Hashtable> hosts = new Hashtable>(); - ArrayList hostlist = new ArrayList(); + List hostLabels = new ArrayList<>(); + Hashtable lasthostFor = new Hashtable<>(); + Hashtable> hosts = new Hashtable<>(); + ArrayList hostlist = new ArrayList<>(); for (Jws2Instance service : enumerableServices) { ArrayList hostservices = hosts.get(service.getHost()); if (hostservices == null) { hosts.put(service.getHost(), - hostservices = new ArrayList()); + hostservices = new ArrayList<>()); hostlist.add(service.getHost()); } hostservices.add(service); @@ -577,16 +576,20 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI } } + /** + * + * @param args + * @j2sIgnore + */ public static void main(String[] args) { if (args.length > 0) { - testUrls = new ArrayList(); + testUrls = new ArrayList<>(); for (String url : args) { testUrls.add(url); } - ; } Thread runner = getDiscoverer() .startDiscoverer(new PropertyChangeListener() @@ -618,7 +621,6 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI } catch (InterruptedException e) { } - ; } try { @@ -685,7 +687,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI // return test urls, if there are any, instead of touching cache return testUrls; } - List urls = new ArrayList(); + List urls = new ArrayList<>(); if (this.preferredUrl != null) { @@ -733,8 +735,8 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI public Vector getServices() { - return (services == null) ? new Vector() - : new Vector(services); + return (services == null) ? new Vector<>() + : new Vector<>(services); } /** @@ -839,7 +841,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { if (urlsWithoutServices == null) { - urlsWithoutServices = new Vector(); + urlsWithoutServices = new Vector<>(); } if ((invalidServiceUrls == null @@ -859,7 +861,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { if (invalidServiceUrls == null) { - invalidServiceUrls = new Vector(); + invalidServiceUrls = new Vector<>(); } if (!invalidServiceUrls.contains(jwsservers)) { @@ -947,7 +949,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI */ public Jws2Instance getPreferredServiceFor(String[] serviceURLs) { - HashSet urls = new HashSet(); + HashSet urls = new HashSet<>(); urls.addAll(Arrays.asList(serviceURLs)); Jws2Instance match = null; if (services != null) @@ -974,7 +976,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI return match; } - Map> preferredServiceMap = new HashMap>();; + Map> preferredServiceMap = new HashMap<>(); /** * get current preferred service of the given type, or global default @@ -1026,12 +1028,12 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI String afid = (af == null) ? "" : af.getViewport().getSequenceSetId(); if (preferredServiceMap == null) { - preferredServiceMap = new HashMap>(); + preferredServiceMap = new HashMap<>(); } Map prefmap = preferredServiceMap.get(afid); if (prefmap == null) { - prefmap = new HashMap(); + prefmap = new HashMap<>(); preferredServiceMap.put(afid, prefmap); } prefmap.put(serviceType, selectedServer.getHost()); diff --git a/test/jalview/gui/MouseEventDemo.java b/test/jalview/gui/MouseEventDemo.java index 6d154de..62320c7 100644 --- a/test/jalview/gui/MouseEventDemo.java +++ b/test/jalview/gui/MouseEventDemo.java @@ -117,6 +117,9 @@ public class MouseEventDemo extends JPanel implements MouseListener static final String NEWLINE = System.getProperty("line.separator"); + /** + * @j2sIgnore + */ public static void main(String[] args) { // Schedule a job for the event dispatch thread: diff --git a/test/jalview/ws/SequenceFetcherTest.java b/test/jalview/ws/SequenceFetcherTest.java index 0b501ee..6683d6c 100644 --- a/test/jalview/ws/SequenceFetcherTest.java +++ b/test/jalview/ws/SequenceFetcherTest.java @@ -49,6 +49,7 @@ public class SequenceFetcherTest * simple run method to test dbsources. * * @param argv + * @j2sIgnore */ public static void main(String[] argv) { -- 1.7.10.2