From 1a754f9f78f3e9ebaf459c438df6a32c35884161 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 9 Oct 2015 10:44:55 -0500 Subject: [PATCH 0001/1208] Avoid NPE when plugin cannot be instantiated When there is a problem creating a wrapper plugin, we should just skip it -- not crash and burn. Closes #195. Thanks to Jonathan Hale for catching this. --- src/main/java/org/scijava/plugin/AbstractWrapperService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/plugin/AbstractWrapperService.java b/src/main/java/org/scijava/plugin/AbstractWrapperService.java index 85e2cea88..4e6910e59 100644 --- a/src/main/java/org/scijava/plugin/AbstractWrapperService.java +++ b/src/main/java/org/scijava/plugin/AbstractWrapperService.java @@ -78,7 +78,7 @@ public boolean supports(final DT data) { private PT findWrapper(final D data) { for (final PluginInfo plugin : getPlugins()) { final PT instance = getPluginService().createInstance(plugin); - if (instance.supports(data)) return instance; + if (instance != null && instance.supports(data)) return instance; } return null; } From 1d690c20ea1e8d49671ccb23f63aac71debef7e2 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 9 Oct 2015 21:25:04 -0500 Subject: [PATCH 0002/1208] Add a unit test for PluginInfo Right now, it just verifies that names are populated correctly. Prompted by exploratory work toward solving imagej/imagej-ops#122. --- .../org/scijava/plugin/PluginInfoTest.java | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/test/java/org/scijava/plugin/PluginInfoTest.java diff --git a/src/test/java/org/scijava/plugin/PluginInfoTest.java b/src/test/java/org/scijava/plugin/PluginInfoTest.java new file mode 100644 index 000000000..602be97c9 --- /dev/null +++ b/src/test/java/org/scijava/plugin/PluginInfoTest.java @@ -0,0 +1,93 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.plugin; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; + +import java.util.List; + +import org.junit.Test; +import org.scijava.Context; +import org.scijava.InstantiableException; +import org.scijava.Priority; + +/** + * Tests {@link PluginInfo}. + * + * @author Curtis Rueden + */ +public class PluginInfoTest { + + @Test + public void testNames() throws InstantiableException { + final Context context = new Context(true); + final PluginIndex pluginIndex = context.getPluginIndex(); + + final List> infos = pluginIndex.get(IceCream.class); + assertEquals(3, infos.size()); + + assertPlugin(Chocolate.class, IceCream.class, "chocolate", infos.get(0)); + assertPlugin(Vanilla.class, IceCream.class, "vanilla", infos.get(1)); + assertPlugin(Flavorless.class, IceCream.class, "", infos.get(2)); + } + + private void assertPlugin(Class pluginClass, Class pluginType, + String name, PluginInfo info) throws InstantiableException + { + assertSame(pluginClass, info.loadClass()); + assertSame(pluginType, info.getPluginType()); + assertEquals(name, info.getName()); + } + + public static interface IceCream extends SciJavaPlugin { + // NB: Marker interface. + } + + @Plugin(type = IceCream.class, priority = Priority.VERY_LOW_PRIORITY) + public static class Flavorless implements SciJavaPlugin { + // NB: No implementation needed. + } + + @Plugin(type = IceCream.class, name = "vanilla", + priority = Priority.LOW_PRIORITY) + public static class Vanilla implements SciJavaPlugin { + // NB: No implementation needed. + } + + @Plugin(type = IceCream.class, name = "chocolate", + priority = Priority.VERY_HIGH_PRIORITY) + public static class Chocolate implements IceCream { + // NB: No implementation needed. + } + +} From 6738b967f09470873a4bffb84e0d2dbb0c107ac4 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 16 Oct 2015 15:17:23 -0500 Subject: [PATCH 0003/1208] XML: expose cdata extraction as a utility method It is helpful for painlessly extracting CDATA from a Node. --- src/main/java/org/scijava/util/XML.java | 28 +++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/scijava/util/XML.java b/src/main/java/org/scijava/util/XML.java index 70a94474d..f1de67af1 100644 --- a/src/main/java/org/scijava/util/XML.java +++ b/src/main/java/org/scijava/util/XML.java @@ -181,7 +181,7 @@ public Document getDocument() { public String cdata(final String expression) { final NodeList nodes = xpath(expression); if (nodes == null || nodes.getLength() == 0) return null; - return getCData(nodes.item(0)); + return cdata(nodes.item(0)); } /** Obtains the nodes identified by the given XPath expression. */ @@ -212,6 +212,20 @@ public String toString() { } } + // -- Utility methods -- + + /** Gets the CData beneath the given node. */ + public static String cdata(final Node item) { + final NodeList children = item.getChildNodes(); + if (children == null || children.getLength() == 0) return null; + for (int i = 0; i < children.getLength(); i++) { + final Node child = children.item(i); + if (child.getNodeType() != Node.TEXT_NODE) continue; + return child.getNodeValue(); + } + return null; + } + // -- Helper methods -- /** Loads an XML document from the given file. */ @@ -252,18 +266,6 @@ private static DocumentBuilder createBuilder() return DocumentBuilderFactory.newInstance().newDocumentBuilder(); } - /** Gets the CData beneath the given node. */ - private static String getCData(final Node item) { - final NodeList children = item.getChildNodes(); - if (children == null || children.getLength() == 0) return null; - for (int i = 0; i < children.getLength(); i++) { - final Node child = children.item(i); - if (child.getNodeType() != Node.TEXT_NODE) continue; - return child.getNodeValue(); - } - return null; - } - /** Converts the given DOM to a string. */ private static String dumpXML(final Document doc) throws TransformerException From 5e0bf6de5a429a2e3df6cda369c6f48827da8ed6 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 16 Oct 2015 15:18:14 -0500 Subject: [PATCH 0004/1208] XML: add method to get list of elements via xpath It is nice to be able to painlessly write an xpath expression which you know will return a list of elements. --- src/main/java/org/scijava/util/XML.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/org/scijava/util/XML.java b/src/main/java/org/scijava/util/XML.java index f1de67af1..2036b68e7 100644 --- a/src/main/java/org/scijava/util/XML.java +++ b/src/main/java/org/scijava/util/XML.java @@ -39,6 +39,7 @@ import java.io.PrintStream; import java.io.StringWriter; import java.net.URL; +import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -56,6 +57,7 @@ import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; +import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; @@ -184,6 +186,19 @@ public String cdata(final String expression) { return cdata(nodes.item(0)); } + /** Obtains the elements identified by the given XPath expression. */ + public ArrayList elements(final String expression) { + final NodeList nodes = xpath(expression); + final ArrayList elements = new ArrayList(); + if (nodes != null) { + for (int i=0; i Date: Fri, 16 Oct 2015 15:38:20 -0500 Subject: [PATCH 0005/1208] POM: add accessors for parent GAV info --- src/main/java/org/scijava/util/POM.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/util/POM.java b/src/main/java/org/scijava/util/POM.java index 3df922752..3fd2d25d5 100644 --- a/src/main/java/org/scijava/util/POM.java +++ b/src/main/java/org/scijava/util/POM.java @@ -84,11 +84,26 @@ public POM(final String s) throws ParserConfigurationException, SAXException, // -- POM methods -- + /** Gets the POM's parent groupId. */ + public String getParentGroupId() { + return cdata("//project/parent/groupId"); + } + + /** Gets the POM's parent artifactId. */ + public String getParentArtifactId() { + return cdata("//project/parent/artifactId"); + } + + /** Gets the POM's parent artifactId. */ + public String getParentVersion() { + return cdata("//project/parent/version"); + } + /** Gets the POM's groupId. */ public String getGroupId() { final String groupId = cdata("//project/groupId"); if (groupId != null) return groupId; - return cdata("//project/parent/groupId"); + return getParentGroupId(); } /** Gets the POM's artifactId. */ @@ -191,7 +206,7 @@ public String getVersion() { synchronized (this) { if (version == null) { version = cdata("//project/version"); - if (version == null) version = cdata("//project/parent/version"); + if (version == null) version = getParentVersion(); } } } From 7a22aca5b3b1cdc5fb2ba43d396e609f9f141b67 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 16 Oct 2015 15:38:40 -0500 Subject: [PATCH 0006/1208] XML: add cdata utility method for element children It makes it much more convenient to ask for, say, the value of the one and only "id" element beneath the specified "developer" element. --- src/main/java/org/scijava/util/XML.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/scijava/util/XML.java b/src/main/java/org/scijava/util/XML.java index 2036b68e7..5487f4ddb 100644 --- a/src/main/java/org/scijava/util/XML.java +++ b/src/main/java/org/scijava/util/XML.java @@ -241,6 +241,13 @@ public static String cdata(final Node item) { return null; } + /** Gets the CData beneath the given element's specified child. */ + public static String cdata(final Element el, final String child) { + NodeList children = el.getElementsByTagName(child); + if (children == null || children.getLength() == 0) return null; + return cdata(children.item(0)); + } + // -- Helper methods -- /** Loads an XML document from the given file. */ From 25e9524ca43b613fe06b44839f877702589ffc86 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 16 Oct 2015 15:39:43 -0500 Subject: [PATCH 0007/1208] POMTest: beef up the tests Now we check all the currently existing accessors, as well as the cdata, xpath and elements methods inherited from XML. --- src/test/java/org/scijava/util/POMTest.java | 70 +++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/test/java/org/scijava/util/POMTest.java b/src/test/java/org/scijava/util/POMTest.java index cd495fb4f..4140d7dae 100644 --- a/src/test/java/org/scijava/util/POMTest.java +++ b/src/test/java/org/scijava/util/POMTest.java @@ -31,9 +31,20 @@ package org.scijava.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; + +import javax.xml.parsers.ParserConfigurationException; + import org.junit.Test; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; /** * Tests methods of {@link POM}. @@ -73,4 +84,63 @@ public void testCompareVersions() { assertTrue(POM.compareVersions("2.0.0", "2.0.0-beta-1") > 0); } + @Test + public void testAccessors() throws ParserConfigurationException, + SAXException, IOException + { + final POM pom = new POM(new File("pom.xml")); + assertEquals("org.scijava", pom.getParentGroupId()); + assertEquals("pom-scijava", pom.getParentArtifactId()); + assertNotNull(pom.getParentVersion()); + assertEquals("org.scijava", pom.getGroupId()); + assertEquals("scijava-common", pom.getArtifactId()); + assertNotNull(pom.getVersion()); + assertEquals("Jenkins", pom.getCIManagementSystem()); + final String ciManagementURL = pom.getCIManagementURL(); + assertEquals("http://jenkins.imagej.net/job/SciJava-common/", + ciManagementURL); + assertEquals("GitHub Issues", pom.getIssueManagementSystem()); + final String issueManagementURL = pom.getIssueManagementURL(); + assertEquals("https://github.com/scijava/scijava-common/issues", + issueManagementURL); + assertNull(pom.getOrganizationName()); + assertNull(pom.getOrganizationURL()); + assertTrue(pom.getPath().endsWith("pom.xml")); + assertTrue(pom.getProjectDescription().startsWith( + "SciJava Common is a shared library for SciJava software.")); + assertEquals("2009", pom.getProjectInceptionYear()); + assertEquals("SciJava Common", pom.getProjectName()); + assertEquals("http://scijava.org/", pom.getProjectURL()); + final String scmConnection = pom.getSCMConnection(); + assertEquals("scm:git:git://github.com/scijava/scijava-common", + scmConnection); + final String scmDeveloperConnection = pom.getSCMDeveloperConnection(); + assertEquals("scm:git:git@github.com:scijava/scijava-common", + scmDeveloperConnection); + assertNotNull(pom.getSCMTag()); // won't be HEAD for release tags + assertEquals("https://github.com/scijava/scijava-common", pom.getSCMURL()); + } + + @Test + public void testCdata() throws ParserConfigurationException, + SAXException, IOException + { + final POM pom = new POM(new File("pom.xml")); + assertEquals("repo", pom.cdata("//project/licenses/license/distribution")); + assertEquals("http://scijava.org/", pom.cdata("//project/url")); + } + + @Test + public void testElements() throws ParserConfigurationException, + SAXException, IOException + { + final POM pom = new POM(new File("pom.xml")); + final ArrayList developers = + pom.elements("//project/developers/developer"); + assertEquals(3, developers.size()); + assertEquals("ctrueden", XML.cdata(developers.get(0), "id")); + assertEquals("dscho", XML.cdata(developers.get(1), "id")); + assertEquals("hinerm", XML.cdata(developers.get(2), "id")); + } + } From 12a62dd4042054cc75f2fbe4b7251d997f0697af Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 16 Oct 2015 16:02:58 -0500 Subject: [PATCH 0008/1208] XML: refactor NodeList -> elements logic Now there is a static utility method for painlessly extracting a list of Element objects from a given NodeList. --- src/main/java/org/scijava/util/XML.java | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/scijava/util/XML.java b/src/main/java/org/scijava/util/XML.java index 5487f4ddb..40ea351c9 100644 --- a/src/main/java/org/scijava/util/XML.java +++ b/src/main/java/org/scijava/util/XML.java @@ -188,15 +188,7 @@ public String cdata(final String expression) { /** Obtains the elements identified by the given XPath expression. */ public ArrayList elements(final String expression) { - final NodeList nodes = xpath(expression); - final ArrayList elements = new ArrayList(); - if (nodes != null) { - for (int i=0; i elements(final NodeList nodes) { + final ArrayList elements = new ArrayList(); + if (nodes != null) { + for (int i=0; i Date: Fri, 16 Oct 2015 16:04:23 -0500 Subject: [PATCH 0009/1208] XML: add utility method to get child elements When you have an element, and want all child elements with the given tag name, you can now call this handy new static utility method. --- src/main/java/org/scijava/util/XML.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/scijava/util/XML.java b/src/main/java/org/scijava/util/XML.java index 40ea351c9..9a82a2a6e 100644 --- a/src/main/java/org/scijava/util/XML.java +++ b/src/main/java/org/scijava/util/XML.java @@ -252,6 +252,13 @@ public static ArrayList elements(final NodeList nodes) { return elements; } + /** Gets the given element's specified child elements. */ + public static ArrayList + elements(final Element el, final String child) + { + return elements(el.getElementsByTagName(child)); + } + // -- Helper methods -- /** Loads an XML document from the given file. */ From 4a0c4be7a1b08e9d5fad884d2e9e82c7b3611206 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 16 Oct 2015 16:30:55 -0500 Subject: [PATCH 0010/1208] Bump to pom-scijava parent 8.4.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index aada3996f..23d2e191c 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.scijava pom-scijava - 8.2.0 + 8.4.0 From 577a7d9145ff35af92892019e19e868fb0bdd91d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 16 Oct 2015 16:32:58 -0500 Subject: [PATCH 0011/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 23d2e191c..6b1ba7c7c 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.47.1-SNAPSHOT + 2.48.1-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From aeccb5774cc2f68bbcb812201e36db073df6f798 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Sat, 17 Oct 2015 21:22:51 -0500 Subject: [PATCH 0012/1208] Add support for enums as multiple choice items Thanks to Christian Dietz for reminding me. --- src/main/java/org/scijava/command/CommandModuleItem.java | 9 ++++++--- src/main/java/org/scijava/module/AbstractModuleItem.java | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/scijava/command/CommandModuleItem.java b/src/main/java/org/scijava/command/CommandModuleItem.java index a952a9947..e0f45dfeb 100644 --- a/src/main/java/org/scijava/command/CommandModuleItem.java +++ b/src/main/java/org/scijava/command/CommandModuleItem.java @@ -155,11 +155,14 @@ public int getColumnCount() { @Override public List getChoices() { - final ArrayList choices = new ArrayList(); + final String[] choices = getParameter().choices(); + if (choices.length == 0) return super.getChoices(); + + final ArrayList choiceList = new ArrayList(); for (final String choice : getParameter().choices()) { - choices.add(tValue(choice)); + choiceList.add(tValue(choice)); } - return choices; + return choiceList; } // -- BasicDetails methods -- diff --git a/src/main/java/org/scijava/module/AbstractModuleItem.java b/src/main/java/org/scijava/module/AbstractModuleItem.java index 678c08b3e..0ae2f9206 100644 --- a/src/main/java/org/scijava/module/AbstractModuleItem.java +++ b/src/main/java/org/scijava/module/AbstractModuleItem.java @@ -32,6 +32,7 @@ package org.scijava.module; import java.lang.reflect.Type; +import java.util.Arrays; import java.util.List; import org.scijava.AbstractBasicDetails; @@ -258,7 +259,8 @@ public int getColumnCount() { @Override public List getChoices() { - return null; + final T[] choices = getType().getEnumConstants(); + return choices == null ? null : Arrays.asList(choices); } @Override From b9e07b1ea6cf661a2201151aee1c7b33a6eb963f Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 29 Oct 2015 16:25:20 -0500 Subject: [PATCH 0013/1208] Manifest: split out JarURLConnection logic This will be useful momentarily. --- src/main/java/org/scijava/util/Manifest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/util/Manifest.java b/src/main/java/org/scijava/util/Manifest.java index 6af56872e..61c958ed4 100644 --- a/src/main/java/org/scijava/util/Manifest.java +++ b/src/main/java/org/scijava/util/Manifest.java @@ -31,6 +31,8 @@ package org.scijava.util; +import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.net.JarURLConnection; import java.net.URL; @@ -134,13 +136,16 @@ public Map getAll() { /** Gets the JAR manifest associated with the given class. */ public static Manifest getManifest(final Class c) { try { - // try to grab manifest from the JAR - final URL location = new URL("jar:" + ClassUtils.getLocation(c) + "!/"); - return new Manifest(((JarURLConnection)location.openConnection()).getManifest()); + return getManifest(new URL("jar:" + ClassUtils.getLocation(c) + "!/")); } catch (final IOException e) { return null; } } + private static Manifest getManifest(final URL jarURL) throws IOException { + final JarURLConnection conn = (JarURLConnection) jarURL.openConnection(); + return new Manifest(conn.getManifest()); + } + } From 97e88a36e554370769eeb93455c703657576081b Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 29 Oct 2015 16:25:41 -0500 Subject: [PATCH 0014/1208] Manifest: add more static creation methods One such allows creation from an org.scijava.util.XML object. Another enables creation from a JAR file on disk. --- src/main/java/org/scijava/util/Manifest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/org/scijava/util/Manifest.java b/src/main/java/org/scijava/util/Manifest.java index 61c958ed4..88f45b3b8 100644 --- a/src/main/java/org/scijava/util/Manifest.java +++ b/src/main/java/org/scijava/util/Manifest.java @@ -143,6 +143,23 @@ public static Manifest getManifest(final Class c) { } } + /** + * Gets the JAR manifest associated with the given XML document. Assumes the + * XML document was loaded as a resource from inside a JAR. + */ + public static Manifest getManifest(final XML xml) throws IOException { + final String path = xml.getPath(); + if (path == null || !path.startsWith("file:")) return null; + final int dotJAR = path.indexOf(".jar!/"); + return getManifest(new File(path.substring(5, dotJAR + 4))); + } + + /** Gets the JAR manifest associated with the given JAR file. */ + public static Manifest getManifest(final File jarFile) throws IOException { + if (!jarFile.exists()) throw new FileNotFoundException(); + return getManifest(new URL("jar:file:" + jarFile.getAbsolutePath() + "!/")); + } + private static Manifest getManifest(final URL jarURL) throws IOException { final JarURLConnection conn = (JarURLConnection) jarURL.openConnection(); return new Manifest(conn.getManifest()); From fa5eb7e329b10960cdde5196a2c8bd22dc9974e1 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 4 Nov 2015 13:03:14 -0600 Subject: [PATCH 0015/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6b1ba7c7c..c7dbd6169 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.48.1-SNAPSHOT + 2.49.1-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From 9b9e794a8652a20646c96cb802aed7ab5db188d8 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 9 Nov 2015 13:12:15 -0600 Subject: [PATCH 0016/1208] Add Jonathan Hale to mailmap --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index 902cb036c..dd6dafd07 100644 --- a/.mailmap +++ b/.mailmap @@ -2,4 +2,5 @@ Barry DeZonia Christian Dietz Johannes Schindelin Johannes Schindelin +Jonathan Hale Mark Hiner From da9f56210425475bc992377e17025c51245ba2d3 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 9 Nov 2015 14:21:00 -0600 Subject: [PATCH 0017/1208] ScriptFinderTest: avoid hardcoding indices Let's use arrays instead, with for loops, for easier editing later. --- .../org/scijava/script/ScriptFinderTest.java | 119 ++++++++++-------- 1 file changed, 67 insertions(+), 52 deletions(-) diff --git a/src/test/java/org/scijava/script/ScriptFinderTest.java b/src/test/java/org/scijava/script/ScriptFinderTest.java index 6f805c607..d5626e993 100644 --- a/src/test/java/org/scijava/script/ScriptFinderTest.java +++ b/src/test/java/org/scijava/script/ScriptFinderTest.java @@ -66,18 +66,23 @@ public class ScriptFinderTest { @BeforeClass public static void setUp() throws IOException { scriptsDir = TestUtils.createTemporaryDirectory("script-finder-"); - TestUtils.createPath(scriptsDir, "ignored.foo"); - TestUtils.createPath(scriptsDir, "Scripts/quick.foo"); - TestUtils.createPath(scriptsDir, "Scripts/brown.foo"); - TestUtils.createPath(scriptsDir, "Scripts/fox.foo"); - TestUtils.createPath(scriptsDir, "Scripts/The_Lazy_Dog.foo"); - TestUtils.createPath(scriptsDir, "Math/add.foo"); - TestUtils.createPath(scriptsDir, "Math/subtract.foo"); - TestUtils.createPath(scriptsDir, "Math/multiply.foo"); - TestUtils.createPath(scriptsDir, "Math/divide.foo"); - TestUtils.createPath(scriptsDir, "Math/Trig/cos.foo"); - TestUtils.createPath(scriptsDir, "Math/Trig/sin.foo"); - TestUtils.createPath(scriptsDir, "Math/Trig/tan.foo"); + final String[] scriptPaths = { // + "ignored.foo", // + "Scripts/quick.foo", // + "Scripts/brown.foo", // + "Scripts/fox.foo", // + "Scripts/The_Lazy_Dog.foo", // + "Math/add.foo", // + "Math/subtract.foo", // + "Math/multiply.foo", // + "Math/divide.foo", // + "Math/Trig/cos.foo", // + "Math/Trig/sin.foo", // + "Math/Trig/tan.foo", // + }; + for (final String scriptPath : scriptPaths) { + TestUtils.createPath(scriptsDir, scriptPath); + } } @AfterClass @@ -94,18 +99,20 @@ public void testFindScripts() { final ArrayList scripts = findScripts(scriptService); - assertEquals(11, scripts.size()); - assertMenuPath("Scripts > The Lazy Dog", scripts, 0); - assertMenuPath("Math > add", scripts, 1); - assertMenuPath("Scripts > brown", scripts, 2); - assertMenuPath("Math > Trig > cos", scripts, 3); - assertMenuPath("Math > divide", scripts, 4); - assertMenuPath("Scripts > fox", scripts, 5); - assertMenuPath("Math > multiply", scripts, 6); - assertMenuPath("Scripts > quick", scripts, 7); - assertMenuPath("Math > Trig > sin", scripts, 8); - assertMenuPath("Math > subtract", scripts, 9); - assertMenuPath("Math > Trig > tan", scripts, 10); + final String[] expected = { // + "Scripts > The Lazy Dog", // + "Math > add", // + "Scripts > brown", // + "Math > Trig > cos", // + "Math > divide", // + "Scripts > fox", // + "Math > multiply", // + "Scripts > quick", // + "Math > Trig > sin", // + "Math > subtract", // + "Math > Trig > tan", // + }; + assertMenuPaths(expected, scripts); } /** @@ -124,19 +131,21 @@ public void testMenuPrefixes() { final ArrayList scripts = findScripts(scriptService); - assertEquals(12, scripts.size()); - assertMenuPath("Foo > Bar > Scripts > The Lazy Dog", scripts, 0); - assertMenuPath("Foo > Bar > Math > add", scripts, 1); - assertMenuPath("Foo > Bar > Scripts > brown", scripts, 2); - assertMenuPath("Foo > Bar > Math > Trig > cos", scripts, 3); - assertMenuPath("Foo > Bar > Math > divide", scripts, 4); - assertMenuPath("Foo > Bar > Scripts > fox", scripts, 5); - assertMenuPath("Foo > Bar > ignored", scripts, 6); - assertMenuPath("Foo > Bar > Math > multiply", scripts, 7); - assertMenuPath("Foo > Bar > Scripts > quick", scripts, 8); - assertMenuPath("Foo > Bar > Math > Trig > sin", scripts, 9); - assertMenuPath("Foo > Bar > Math > subtract", scripts, 10); - assertMenuPath("Foo > Bar > Math > Trig > tan", scripts, 11); + final String[] expected = { // + "Foo > Bar > Scripts > The Lazy Dog", // + "Foo > Bar > Math > add", // + "Foo > Bar > Scripts > brown", // + "Foo > Bar > Math > Trig > cos", // + "Foo > Bar > Math > divide", // + "Foo > Bar > Scripts > fox", // + "Foo > Bar > ignored", // + "Foo > Bar > Math > multiply", // + "Foo > Bar > Scripts > quick", // + "Foo > Bar > Math > Trig > sin", // + "Foo > Bar > Math > subtract", // + "Foo > Bar > Math > Trig > tan", // + }; + assertMenuPaths(expected, scripts); } /** @@ -155,18 +164,20 @@ public void testOverlappingDirectories() { final ArrayList scripts = findScripts(scriptService); - assertEquals(11, scripts.size()); - assertMenuPath("Plugins > The Lazy Dog", scripts, 0); - assertMenuPath("Math > add", scripts, 1); - assertMenuPath("Plugins > brown", scripts, 2); - assertMenuPath("Math > Trig > cos", scripts, 3); - assertMenuPath("Math > divide", scripts, 4); - assertMenuPath("Plugins > fox", scripts, 5); - assertMenuPath("Math > multiply", scripts, 6); - assertMenuPath("Plugins > quick", scripts, 7); - assertMenuPath("Math > Trig > sin", scripts, 8); - assertMenuPath("Math > subtract", scripts, 9); - assertMenuPath("Math > Trig > tan", scripts, 10); + final String[] expected = { // + "Plugins > The Lazy Dog", // + "Math > add", // + "Plugins > brown", // + "Math > Trig > cos", // + "Math > divide", // + "Plugins > fox", // + "Math > multiply", // + "Plugins > quick", // + "Math > Trig > sin", // + "Math > subtract", // + "Math > Trig > tan", // + }; + assertMenuPaths(expected, scripts); } // -- Helper methods -- @@ -188,10 +199,14 @@ private ArrayList findScripts(final ScriptService scriptService) { return scripts; } - private void assertMenuPath(final String menuString, - final ArrayList scripts, final int i) + private void assertMenuPaths(final String[] expected, + final ArrayList scripts) { - assertEquals(menuString, scripts.get(i).getMenuPath().getMenuString()); + assertEquals(expected.length, scripts.size()); + for (int i=0; i Date: Wed, 11 Nov 2015 15:21:29 -0600 Subject: [PATCH 0018/1208] POM: remove redundant mailingLists section --- pom.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pom.xml b/pom.xml index c7dbd6169..f1559fc89 100644 --- a/pom.xml +++ b/pom.xml @@ -101,16 +101,6 @@ Jay Warrick - - - SciJava - https://groups.google.com/group/scijava - https://groups.google.com/group/scijava - scijava@googlegroups.com - https://groups.google.com/group/scijava - - - scm:git:git://github.com/scijava/scijava-common scm:git:git@github.com:scijava/scijava-common From 125f1fd9d440d747bc15370d65d9430f4214c032 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 11 Nov 2015 15:54:37 -0600 Subject: [PATCH 0019/1208] POM: Update developers and contributors See: http://imagej.net/Team --- pom.xml | 75 ++++++++++----------- src/test/java/org/scijava/util/POMTest.java | 5 +- 2 files changed, 39 insertions(+), 41 deletions(-) diff --git a/pom.xml b/pom.xml index f1559fc89..7b7cfe7eb 100644 --- a/pom.xml +++ b/pom.xml @@ -33,21 +33,12 @@ UW-Madison LOCI http://loci.wisc.edu/ - architect - developer - - -6 - - - dscho - Johannes Schindelin - schindelin@wisc.edu - http://loci.wisc.edu/people/johannes-schindelin - UW-Madison LOCI - http://loci.wisc.edu/ - - architect + lead developer + debugger + reviewer + support + maintainer -6 @@ -59,46 +50,54 @@ UW-Madison LOCI http://loci.wisc.edu/ + lead developer + debugger + reviewer + support + maintainer -6 + + Johannes Schindelin + http://imagej.net/User:Schindelin + dscho + Barry DeZonia - http://loci.wisc.edu/people/barry-dezonia - UW-Madison LOCI - http://loci.wisc.edu/ - - developer - - -6 + http://imagej.net/User:Bdezonia + bdezonia Lee Kamentsky - leek@broadinstitute.org - http://www.broadinstitute.org/~leek/ - Broad Institute of MIT and Harvard - http://www.broadinstitute.org/ - - developer - - -5 + http://imagej.net/User:Leek + LeeKamentsky Christian Dietz - christian.dietz@uni-konstanz.de - http://www.informatik.uni-konstanz.de/berthold/mitglieder/christian-dietz/ - University of Konstanz - http://www.informatik.uni-konstanz.de/ - - developer - - +1 + http://imagej.net/User:Dietzc + dietzc + + + Gabriel Einsdorf + gab1one + + + Jonathan Hale + Squareys + + + Kevin Mader + kmader + + + Jay Warrick + jaywarrick - Jay Warrick diff --git a/src/test/java/org/scijava/util/POMTest.java b/src/test/java/org/scijava/util/POMTest.java index 4140d7dae..d44c18a02 100644 --- a/src/test/java/org/scijava/util/POMTest.java +++ b/src/test/java/org/scijava/util/POMTest.java @@ -137,10 +137,9 @@ public void testElements() throws ParserConfigurationException, final POM pom = new POM(new File("pom.xml")); final ArrayList developers = pom.elements("//project/developers/developer"); - assertEquals(3, developers.size()); + assertEquals(2, developers.size()); assertEquals("ctrueden", XML.cdata(developers.get(0), "id")); - assertEquals("dscho", XML.cdata(developers.get(1), "id")); - assertEquals("hinerm", XML.cdata(developers.get(2), "id")); + assertEquals("hinerm", XML.cdata(developers.get(1), "id")); } } From af3701dc45c618be1e2ca2332b9e9d1ae04ef186 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 11 Nov 2015 16:00:37 -0600 Subject: [PATCH 0020/1208] mailmap: fix shortlog for ImageJ Jenkins --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index dd6dafd07..e5a0e733c 100644 --- a/.mailmap +++ b/.mailmap @@ -1,5 +1,6 @@ Barry DeZonia Christian Dietz +ImageJ Jenkins Johannes Schindelin Johannes Schindelin Jonathan Hale From 9890a3f16e6d3fc165c1eab6dfad1af5f82cee3a Mon Sep 17 00:00:00 2001 From: The Gitter Badger Date: Thu, 12 Nov 2015 21:44:33 +0000 Subject: [PATCH 0021/1208] Add Gitter badge --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d046a41e6..62c5c7194 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,6 @@ plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both [ImageJ](https://github.com/imagej/imagej) and [SCIFIO](https://github.com/scifio/scifio). + + +[![Join the chat at https://gitter.im/scijava/scijava-common](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/scijava/scijava-common?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) \ No newline at end of file From 7ec75c52269bfda91cb21d6157cda2d468231dfd Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 12 Nov 2015 15:49:06 -0600 Subject: [PATCH 0022/1208] README: fix location of Gitter badge --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 62c5c7194..5f8b5ca0c 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ [![](http://jenkins.imagej.net/job/SciJava-common/lastBuild/badge/icon)](http://jenkins.imagej.net/job/SciJava-common/) +[![Join the chat at https://gitter.im/scijava/scijava-common](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/scijava/scijava-common?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) SciJava Common is a common library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both [ImageJ](https://github.com/imagej/imagej) and [SCIFIO](https://github.com/scifio/scifio). - - -[![Join the chat at https://gitter.im/scijava/scijava-common](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/scijava/scijava-common?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) \ No newline at end of file From eece780833bc74656ae937e456f7082cc07d1275 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 13 Nov 2015 13:31:56 -0600 Subject: [PATCH 0023/1208] FileUtils: refactor version pattern matching Hopefully it is a little less arcane now, if more verbose. --- src/main/java/org/scijava/util/FileUtils.java | 53 +++++++++++++++---- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/scijava/util/FileUtils.java b/src/main/java/org/scijava/util/FileUtils.java index f2bff441d..1c199118e 100644 --- a/src/main/java/org/scijava/util/FileUtils.java +++ b/src/main/java/org/scijava/util/FileUtils.java @@ -70,6 +70,9 @@ public final class FileUtils { public static final String SHORTENER_SLASH = "/"; public static final String SHORTENER_ELLIPSE = "..."; + /** A regular expression to match filenames containing version information. */ + private static final Pattern VERSION_PATTERN = buildVersionPattern(); + private FileUtils() { // prevent instantiation of utility class } @@ -170,13 +173,8 @@ public static void writeFile(final File file, final byte[] bytes) } } - /** A regular expression to match filenames containing version information. */ - private final static Pattern versionPattern = - Pattern - .compile("(.+?)(-\\d+(\\.\\d+|\\d{7})+[a-z]?\\d?(-[A-Za-z0-9.]+?|\\.GA)*?)?((-(swing|swt|shaded|sources|javadoc|native|linux-x86|linux-x86_64|macosx-x86_64|windows-x86|windows-x86_64|android-arm|android-x86))?(\\.jar(-[a-z]*)?))"); - public static String stripFilenameVersion(final String filename) { - final Matcher matcher = versionPattern.matcher(filename); + final Matcher matcher = VERSION_PATTERN.matcher(filename); if (!matcher.matches()) return filename; return matcher.group(1) + matcher.group(5); } @@ -191,7 +189,7 @@ public static String stripFilenameVersion(final String filename) { public static File[] getAllVersions(final File directory, final String filename) { - final Matcher matcher = versionPattern.matcher(filename); + final Matcher matcher = VERSION_PATTERN.matcher(filename); if (!matcher.matches()) { final File file = new File(directory, filename); return file.exists() ? new File[] { file } : null; @@ -203,7 +201,7 @@ public static File[] getAllVersions(final File directory, @Override public boolean accept(final File dir, final String name) { if (!name.startsWith(baseName)) return false; - final Matcher matcher2 = versionPattern.matcher(name); + final Matcher matcher2 = VERSION_PATTERN.matcher(name); return matcher2.matches() && baseName.equals(matcher2.group(1)) && equals(classifier, matcher2.group(6)); } @@ -609,6 +607,43 @@ else if (protocol.equals("jar")) { return result; } + // -- Helper methods -- + + /** Builds the {@link #VERSION_PATTERN} constant. */ + private static Pattern buildVersionPattern() { + final String version = + "\\d+(\\.\\d+|\\d{7})+[a-z]?\\d?(-[A-Za-z0-9.]+?|\\.GA)*?"; + final String suffix = "\\.jar(-[a-z]*)?"; + return Pattern.compile("(.+?)(-" + version + ")?((-(" + classifiers() + + "))?(" + suffix + "))"); + } + + /** Helper method of {@link #buildVersionPattern()}. */ + private static String classifiers() { + final String[] classifiers = { + "swing", + "swt", + "shaded", + "sources", + "javadoc", + "native", + "linux-x86", + "linux-x86_64", + "macosx-x86_64", + "windows-x86", + "windows-x86_64", + "android-arm", + "android-x86", + }; + final StringBuilder sb = new StringBuilder("("); + for (final String classifier : classifiers) { + if (sb.length() > 1) sb.append("|"); + sb.append(classifier); + } + sb.append(")"); + return sb.toString(); + } + // -- Deprecated methods -- /** @@ -620,7 +655,7 @@ else if (protocol.equals("jar")) { */ @Deprecated public static Matcher matchVersionedFilename(final String filename) { - return versionPattern.matcher(filename); + return VERSION_PATTERN.matcher(filename); } } From eebecfabe255b6f48222569a316589ecc54298ca Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 13 Nov 2015 13:34:22 -0600 Subject: [PATCH 0024/1208] FileUtils: make native patterns more compact This also supports more platform/architecture combinations. --- src/main/java/org/scijava/util/FileUtils.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/scijava/util/FileUtils.java b/src/main/java/org/scijava/util/FileUtils.java index 1c199118e..c79ec3b8a 100644 --- a/src/main/java/org/scijava/util/FileUtils.java +++ b/src/main/java/org/scijava/util/FileUtils.java @@ -627,13 +627,8 @@ private static String classifiers() { "sources", "javadoc", "native", - "linux-x86", - "linux-x86_64", - "macosx-x86_64", - "windows-x86", - "windows-x86_64", - "android-arm", - "android-x86", + "(android|linux|macosx|windows)-" + + "(arm|x86|x86_64)", }; final StringBuilder sb = new StringBuilder("("); for (final String classifier : classifiers) { From 9bf10d53ddf5711312eb37af714cf31a2b0bfb16 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 13 Nov 2015 13:36:05 -0600 Subject: [PATCH 0025/1208] FileUtils: add more platforms and architectures These will come in handy shortly, to support jogamp artifacts. --- src/main/java/org/scijava/util/FileUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/util/FileUtils.java b/src/main/java/org/scijava/util/FileUtils.java index c79ec3b8a..5968df249 100644 --- a/src/main/java/org/scijava/util/FileUtils.java +++ b/src/main/java/org/scijava/util/FileUtils.java @@ -627,8 +627,8 @@ private static String classifiers() { "sources", "javadoc", "native", - "(android|linux|macosx|windows)-" + - "(arm|x86|x86_64)", + "(android|linux|macosx|solaris|windows)-" + + "(aarch64|amd64|arm|armv6|armv6hf|i586|universal|x86|x86_64)", }; final StringBuilder sb = new StringBuilder("("); for (final String classifier : classifiers) { From 8097e5282e3994f105896eb92792ed4678f55e4a Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 13 Nov 2015 13:37:11 -0600 Subject: [PATCH 0026/1208] FileUtils: allow optional "natives-" prefix This is necessary to support jogamp artifacts, such as: * gluegen-rt-2.3.0-natives-android-armv6.jar * gluegen-rt-2.3.0-natives-linux-amd64.jar * gluegen-rt-2.3.0-natives-macosx-universal.jar * gluegen-rt-2.3.0-natives-windows-i586.jar --- src/main/java/org/scijava/util/FileUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/util/FileUtils.java b/src/main/java/org/scijava/util/FileUtils.java index 5968df249..8a7dbba07 100644 --- a/src/main/java/org/scijava/util/FileUtils.java +++ b/src/main/java/org/scijava/util/FileUtils.java @@ -627,7 +627,7 @@ private static String classifiers() { "sources", "javadoc", "native", - "(android|linux|macosx|solaris|windows)-" + + "(natives-)?(android|linux|macosx|solaris|windows)-" + "(aarch64|amd64|arm|armv6|armv6hf|i586|universal|x86|x86_64)", }; final StringBuilder sb = new StringBuilder("("); From 3914efc52adf25daba19361f5f6b174a4a92c1bb Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 13 Nov 2015 13:47:11 -0600 Subject: [PATCH 0027/1208] FileUtilsTest: test jogamp-style platform jars --- src/test/java/org/scijava/util/FileUtilsTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/org/scijava/util/FileUtilsTest.java b/src/test/java/org/scijava/util/FileUtilsTest.java index cbec12492..88111372c 100644 --- a/src/test/java/org/scijava/util/FileUtilsTest.java +++ b/src/test/java/org/scijava/util/FileUtilsTest.java @@ -299,6 +299,18 @@ public void testStripVersionFromFilename() { assertEquals("jars/ffmpeg-android-x86.jar", FileUtils.stripFilenameVersion("jars/ffmpeg-2.6.1-0.11-android-x86.jar")); assertEquals("jars/ffmpeg-android-arm.jar", FileUtils.stripFilenameVersion("jars/ffmpeg-2.6.1-0.11-android-arm.jar")); + // Test the jogamp style of native binary .jars + assertEquals("jars/jogl-all-natives-android-aarch64.jar", FileUtils.stripFilenameVersion("jars/jogl-all-2.3.0-natives-android-aarch64.jar")); + assertEquals("jars/jogl-all-natives-android-armv6.jar", FileUtils.stripFilenameVersion("jars/jogl-all-2.3.0-natives-android-armv6.jar")); + assertEquals("jars/jogl-all-natives-linux-amd64.jar", FileUtils.stripFilenameVersion("jars/jogl-all-2.3.0-natives-linux-amd64.jar")); + assertEquals("jars/jogl-all-natives-linux-armv6.jar", FileUtils.stripFilenameVersion("jars/jogl-all-2.3.0-natives-linux-armv6.jar")); + assertEquals("jars/jogl-all-natives-linux-armv6hf.jar", FileUtils.stripFilenameVersion("jars/jogl-all-2.3.0-natives-linux-armv6hf.jar")); + assertEquals("jars/jogl-all-natives-linux-i586.jar", FileUtils.stripFilenameVersion("jars/jogl-all-2.3.0-natives-linux-i586.jar")); + assertEquals("jars/jogl-all-natives-macosx-universal.jar", FileUtils.stripFilenameVersion("jars/jogl-all-2.3.0-natives-macosx-universal.jar")); + assertEquals("jars/jogl-all-natives-solaris-amd64.jar", FileUtils.stripFilenameVersion("jars/jogl-all-2.3.0-natives-solaris-amd64.jar")); + assertEquals("jars/jogl-all-natives-solaris-i586.jar", FileUtils.stripFilenameVersion("jars/jogl-all-2.3.0-natives-solaris-i586.jar")); + assertEquals("jars/jogl-all-natives-windows-amd64.jar", FileUtils.stripFilenameVersion("jars/jogl-all-2.3.0-natives-windows-amd64.jar")); + assertEquals("jars/jogl-all-natives-windows-i586.jar", FileUtils.stripFilenameVersion("jars/jogl-all-2.3.0-natives-windows-i586.jar")); } @Test From 0c2608399d775d2f5ef7318cb85f18dbf9915158 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 16 Nov 2015 12:00:02 -0600 Subject: [PATCH 0028/1208] Tag EventHistory as a core SciJava service --- src/main/java/org/scijava/event/EventHistory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/event/EventHistory.java b/src/main/java/org/scijava/event/EventHistory.java index be6e1b6fb..128a5b469 100644 --- a/src/main/java/org/scijava/event/EventHistory.java +++ b/src/main/java/org/scijava/event/EventHistory.java @@ -34,14 +34,14 @@ import java.util.Set; -import org.scijava.service.Service; +import org.scijava.service.SciJavaService; /** * Interface for service that keeps a history of SciJava events. * * @author Curtis Rueden */ -public interface EventHistory extends Service { +public interface EventHistory extends SciJavaService { /** Activates or deactivates event history tracking. */ void setActive(boolean active); From e73ce62043374adc5107f9d7c767d196b050cd7d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 16 Nov 2015 14:52:03 -0600 Subject: [PATCH 0029/1208] Ensure all core services are SciJavaServices This will prevent issues like b811a4d49683e8e5b0e344d7451365ed26fc447f from going uncaught in the future. --- .../java/org/scijava/ContextCreationTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/java/org/scijava/ContextCreationTest.java b/src/test/java/org/scijava/ContextCreationTest.java index e12f1daa1..d015c3853 100644 --- a/src/test/java/org/scijava/ContextCreationTest.java +++ b/src/test/java/org/scijava/ContextCreationTest.java @@ -47,6 +47,7 @@ import org.scijava.plugin.PluginInfo; import org.scijava.plugin.SciJavaPlugin; import org.scijava.service.AbstractService; +import org.scijava.service.SciJavaService; import org.scijava.service.Service; import org.scijava.thread.ThreadService; @@ -107,6 +108,26 @@ public void testFull() { verifyServiceOrder(expected, context); } + /** + * Tests that a new fully populated {@link Context} has exactly the same + * {@link Service}s available as one created with only {@link SciJavaService} + * implementations. + *

+ * In other words: tests that all {@link Service}s implemented in SciJava + * Common are tagged with the {@link SciJavaService} interface. + *

+ */ + @Test + public void testSciJavaServices() { + final Context full = new Context(); + final Context sciJava = new Context(SciJavaService.class); + for (final Service s : full.getServiceIndex()) { + final Class c = s.getClass(); + final Service sjs = sciJava.getService(c); + if (sjs == null) fail("Not a SciJavaService? " + s.getClass().getName()); + } + } + /** * Tests that dependent {@link Service}s are automatically created and * populated in downstream {@link Service} classes. From 835645cd05725e1a3029bb475632cad7cdb99d0d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 19 Nov 2015 08:31:36 -0600 Subject: [PATCH 0030/1208] POM: bump parent to pom-scijava 9.0.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7b7cfe7eb..d9583272c 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.scijava pom-scijava - 8.4.0 + 9.0.0 From 62e4592da99b5944cff33b6f1ca44e36bc71b714 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 19 Nov 2015 08:33:07 -0600 Subject: [PATCH 0031/1208] POM: remove excess whitespace This makes tidy-maven-plugin happy. --- pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pom.xml b/pom.xml index d9583272c..a08dc8a9b 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,6 @@ SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. http://scijava.org/ 2009 - Simplified BSD License @@ -60,7 +59,6 @@ -6 - Johannes Schindelin @@ -106,12 +104,10 @@ HEAD https://github.com/scijava/scijava-common
- GitHub Issues https://github.com/scijava/scijava-common/issues - Jenkins http://jenkins.imagej.net/job/SciJava-common/ @@ -230,5 +226,4 @@ Institute of Molecular Cell Biology and Genetics. - From 9732b113b16c81470439a5aead309bd14b7cfff7 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 19 Nov 2015 11:31:24 -0600 Subject: [PATCH 0032/1208] POM: Flag myself as the founder --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index a08dc8a9b..f82e95c8e 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,7 @@ UW-Madison LOCI http://loci.wisc.edu/ + founder lead developer debugger From 97d617246a797a2b555bf7c6d188c622e1aadb9c Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 19 Nov 2015 11:58:08 -0600 Subject: [PATCH 0033/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f82e95c8e..dbb01116c 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.49.1-SNAPSHOT + 2.49.2-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From 233c1b2979275d3f7f715577bb6ce7701672f735 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 20 Nov 2015 10:26:52 -0600 Subject: [PATCH 0034/1208] ScriptInfoTest: clean up code style --- src/test/java/org/scijava/script/ScriptInfoTest.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/scijava/script/ScriptInfoTest.java b/src/test/java/org/scijava/script/ScriptInfoTest.java index c36b4abb8..70619b2d9 100644 --- a/src/test/java/org/scijava/script/ScriptInfoTest.java +++ b/src/test/java/org/scijava/script/ScriptInfoTest.java @@ -135,13 +135,12 @@ public void testReaderSanity() throws Exception { "% @LogService log\n" + // "% @OUTPUT Integer output"; - ScriptInfo info = new ScriptInfo(context, "hello.bsizes", new StringReader( - script)); - BufferedReader reader1 = info.getReader(); - BufferedReader reader2 = info.getReader(); + final ScriptInfo info = + new ScriptInfo(context, "hello.bsizes", new StringReader(script)); + final BufferedReader reader1 = info.getReader(); + final BufferedReader reader2 = info.getReader(); - assertEquals("Readers are not independent.", reader1.read(), reader2 - .read()); + assertEquals("Readers are not independent.", reader1.read(), reader2.read()); } From a45b0576cc9a5122d80507ccce6fcf4ccef914fc Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 20 Nov 2015 11:09:39 -0600 Subject: [PATCH 0035/1208] ScriptInfoTest: add test for script param parsing It is just a few down-the-middle tests right now. But much better than before, which was practically nothing. --- .../org/scijava/script/ScriptInfoTest.java | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/test/java/org/scijava/script/ScriptInfoTest.java b/src/test/java/org/scijava/script/ScriptInfoTest.java index 70619b2d9..23ffb5d53 100644 --- a/src/test/java/org/scijava/script/ScriptInfoTest.java +++ b/src/test/java/org/scijava/script/ScriptInfoTest.java @@ -32,6 +32,7 @@ package org.scijava.script; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -53,6 +54,9 @@ import org.junit.BeforeClass; import org.junit.Test; import org.scijava.Context; +import org.scijava.ItemIO; +import org.scijava.log.LogService; +import org.scijava.module.ModuleItem; import org.scijava.plugin.Plugin; import org.scijava.test.TestUtils; import org.scijava.util.DigestUtils; @@ -125,6 +129,75 @@ public void testVersion() throws IOException { FileUtils.deleteRecursively(tmpDir); } + /** + * Tests {@link ScriptInfo} parameter declarations, including + * {@link ScriptInfo#inputs()}, {@link ScriptInfo#outputs()}, + * {@link ScriptInfo#getInput(String)} and + * {@link ScriptInfo#getOutput(String)}. + */ + @Test + public void testParameters() { + final String script = "" + // + "% @LogService(required = false) log\n" + // + "% @int(label=\"Slider Value\", softMin=5, softMax=15, " + // + "stepSize=3, value=11, style=\"slider\") sliderValue\n" + // + "% @BOTH java.lang.StringBuilder buffer"; + + final ScriptInfo info = + new ScriptInfo(context, "params.bsizes", new StringReader(script)); + + final ModuleItem log = info.getInput("log"); + assertItem("log", LogService.class, null, ItemIO.INPUT, false, true, null, + null, null, null, null, null, null, null, log); + + final ModuleItem sliderValue = info.getInput("sliderValue"); + assertItem("sliderValue", int.class, "Slider Value", ItemIO.INPUT, true, + true, null, "slider", 11, null, null, 5, 15, 3, sliderValue); + + final ModuleItem buffer = info.getOutput("buffer"); + assertItem("buffer", StringBuilder.class, null, ItemIO.BOTH, true, true, + null, null, null, null, null, null, null, null, buffer); + + final ModuleItem result = info.getOutput("result"); + assertItem("result", Object.class, null, ItemIO.OUTPUT, true, true, null, + null, null, null, null, null, null, null, result); + + int inputCount = 0; + final ModuleItem[] inputs = { log, sliderValue, buffer }; + for (final ModuleItem inItem : info.inputs()) { + assertSame(inputs[inputCount++], inItem); + } + + int outputCount = 0; + final ModuleItem[] outputs = { buffer, result }; + for (final ModuleItem outItem : info.outputs()) { + assertSame(outputs[outputCount++], outItem); + } + } + + private void assertItem(final String name, final Class type, + final String label, final ItemIO ioType, final boolean required, + final boolean persist, final String persistKey, final String style, + final Object value, final Object min, final Object max, + final Object softMin, final Object softMax, final Number stepSize, + final ModuleItem item) + { + assertEquals(name, item.getName()); + assertSame(type, item.getType()); + assertEquals(label, item.getLabel()); + assertSame(ioType, item.getIOType()); + assertEquals(required, item.isRequired()); + assertEquals(persist, item.isPersisted()); + assertEquals(persistKey, item.getPersistKey()); + assertEquals(style, item.getWidgetStyle()); + assertEquals(value, item.getDefaultValue()); + assertEquals(min, item.getMinimumValue()); + assertEquals(max, item.getMaximumValue()); + assertEquals(softMin, item.getSoftMinimum()); + assertEquals(softMax, item.getSoftMaximum()); +// assertEquals(stepSize, item.getStepSize()); + } + /** * Ensures the ScriptInfos Reader can be reused for multiple executions of the * script. From c0ffe3956e8ccc08cc633ade9b00bb31a43f0de2 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 20 Nov 2015 11:14:09 -0600 Subject: [PATCH 0036/1208] ScriptInfo: add support for stepSize attribute It's probably still a little hacky, since stepSize is typed as Number rather than T. But it should work OK in normal circumstances. --- src/main/java/org/scijava/script/ScriptInfo.java | 10 ++++++++-- src/test/java/org/scijava/script/ScriptInfoTest.java | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index 67f67ea62..ffc40391f 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -472,8 +472,14 @@ else if ("softMin".equalsIgnoreCase(key)) { item.setSoftMinimum(convertService.convert(value, item.getType())); } else if ("stepSize".equalsIgnoreCase(key)) { - // FIXME - item.setStepSize(convertService.convert(value, Number.class)); + try { + final double stepSize = Double.parseDouble(value); + item.setStepSize(stepSize); + } + catch (final NumberFormatException exc) { + log.warn("Script parameter " + item.getName() + + " has an invalid stepSize: " + value); + } } else if ("style".equalsIgnoreCase(key)) { item.setWidgetStyle(value); diff --git a/src/test/java/org/scijava/script/ScriptInfoTest.java b/src/test/java/org/scijava/script/ScriptInfoTest.java index 23ffb5d53..b87a4fb15 100644 --- a/src/test/java/org/scijava/script/ScriptInfoTest.java +++ b/src/test/java/org/scijava/script/ScriptInfoTest.java @@ -152,7 +152,7 @@ public void testParameters() { final ModuleItem sliderValue = info.getInput("sliderValue"); assertItem("sliderValue", int.class, "Slider Value", ItemIO.INPUT, true, - true, null, "slider", 11, null, null, 5, 15, 3, sliderValue); + true, null, "slider", 11, null, null, 5, 15, 3.0, sliderValue); final ModuleItem buffer = info.getOutput("buffer"); assertItem("buffer", StringBuilder.class, null, ItemIO.BOTH, true, true, @@ -195,7 +195,7 @@ private void assertItem(final String name, final Class type, assertEquals(max, item.getMaximumValue()); assertEquals(softMin, item.getSoftMinimum()); assertEquals(softMax, item.getSoftMaximum()); -// assertEquals(stepSize, item.getStepSize()); + assertEquals(stepSize, item.getStepSize()); } /** From 4a01d97621caf593be66d4d033041ab4528bd074 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 20 Nov 2015 13:44:11 -0600 Subject: [PATCH 0037/1208] DefaultModuleService: do not persist default value This makes iterative script development slightly more convenient. Thanks to Leon Yang for the idea. --- .../java/org/scijava/module/DefaultModuleService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/scijava/module/DefaultModuleService.java b/src/main/java/org/scijava/module/DefaultModuleService.java index dcdebc5de..0c2d70925 100644 --- a/src/main/java/org/scijava/module/DefaultModuleService.java +++ b/src/main/java/org/scijava/module/DefaultModuleService.java @@ -60,6 +60,7 @@ import org.scijava.service.Service; import org.scijava.thread.ThreadService; import org.scijava.util.ClassUtils; +import org.scijava.util.MiscUtils; /** * Default service for keeping track of and executing available modules. @@ -266,6 +267,13 @@ public ModuleItem getSingleOutput(final Module module, public void save(final ModuleItem item, final T value) { if (!item.isPersisted()) return; + if (MiscUtils.equal(item.getDefaultValue(), value)) { + // NB: Do not persist the value if it is the default. + // This is nice if the default value might change later, + // such as when iteratively developing a script. + return; + } + final String sValue = value == null ? "" : value.toString(); // do not persist if object cannot be converted back from a string From 032cb8565ac8fbd3be53677d6a92902ee8cf5b4c Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 24 Nov 2015 10:18:34 -0600 Subject: [PATCH 0038/1208] Make OptionsPlugin abstract It was never intended to be instantiated, but rather extended. Closes #208. --- src/main/java/org/scijava/options/OptionsPlugin.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/options/OptionsPlugin.java b/src/main/java/org/scijava/options/OptionsPlugin.java index 2d03eb1b5..cd84b14d1 100644 --- a/src/main/java/org/scijava/options/OptionsPlugin.java +++ b/src/main/java/org/scijava/options/OptionsPlugin.java @@ -71,7 +71,9 @@ * @author Barry DeZonia * @author Curtis Rueden */ -public class OptionsPlugin extends DynamicCommand implements SingletonPlugin { +public abstract class OptionsPlugin extends DynamicCommand implements + SingletonPlugin +{ // -- Parameters -- From eca2a95b3f6de1c22aaafecb324c39346334ce9f Mon Sep 17 00:00:00 2001 From: LeonYang5114 Date: Wed, 25 Nov 2015 10:10:24 -0600 Subject: [PATCH 0039/1208] Fix bug of ignoring the step size of a parameter The step size attribute of a parameter is always ignored because there is no converter that converts String to Number. The bug is fixed by parsing the String to double. Similar bug exists in the script editor and has been fixed. See also: c0ffe39 #205 --- src/main/java/org/scijava/command/CommandModuleItem.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/command/CommandModuleItem.java b/src/main/java/org/scijava/command/CommandModuleItem.java index e0f45dfeb..de14eaa9a 100644 --- a/src/main/java/org/scijava/command/CommandModuleItem.java +++ b/src/main/java/org/scijava/command/CommandModuleItem.java @@ -145,7 +145,14 @@ public T getMaximumValue() { @Override public Number getStepSize() { - return tValue(getParameter().stepSize(), Number.class); + final String value = getParameter().stepSize(); + try { + final double stepSize = Double.parseDouble(value); + return stepSize; + } + catch (final NumberFormatException exc) { + return tValue(value, Number.class); + } } @Override From fdf7494d97c5f1062f5ae458bd4e1c34748a627c Mon Sep 17 00:00:00 2001 From: LeonYang5114 Date: Wed, 25 Nov 2015 10:11:03 -0600 Subject: [PATCH 0040/1208] Add test for step size of a command's parameter --- src/test/java/org/scijava/command/InvalidCommandTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/scijava/command/InvalidCommandTest.java b/src/test/java/org/scijava/command/InvalidCommandTest.java index da2fb86a4..73a68cbe2 100644 --- a/src/test/java/org/scijava/command/InvalidCommandTest.java +++ b/src/test/java/org/scijava/command/InvalidCommandTest.java @@ -71,6 +71,10 @@ public void testValid() { final List problems = info.getProblems(); assertNotNull(problems); assertEquals(0, problems.size()); + + final Number stepSize = info.getInput("x").getStepSize(); + assertNotNull(stepSize); + assertEquals(10, stepSize.intValue()); } @Test @@ -101,7 +105,7 @@ public void testInvalid() { @Plugin(type = Command.class) public static class ValidCommand implements Command { - @Parameter + @Parameter(stepSize = "10") private double x; @Parameter(type = ItemIO.OUTPUT) From 45ab6cf22dc3c33400bc40a17885e968f4eaa8ad Mon Sep 17 00:00:00 2001 From: LeonYang5114 Date: Wed, 25 Nov 2015 10:16:20 -0600 Subject: [PATCH 0041/1208] Add empty option for not-required parameter in Widget For command parameter that is not required but candidate options exist, DefaultWidgetModel gave no empty option to be chosen from, which force the user to use the potentially invalid values. --- src/main/java/org/scijava/widget/DefaultWidgetModel.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/widget/DefaultWidgetModel.java b/src/main/java/org/scijava/widget/DefaultWidgetModel.java index bbd715b3d..328e4eb27 100644 --- a/src/main/java/org/scijava/widget/DefaultWidgetModel.java +++ b/src/main/java/org/scijava/widget/DefaultWidgetModel.java @@ -83,6 +83,8 @@ public DefaultWidgetModel(final Context context, final InputPanel inputPan this.module = module; this.item = item; this.objectPool = objectPool; + if (!item.isRequired()) + this.objectPool.add(0, null); convertedObjects = new WeakHashMap(); } @@ -306,8 +308,10 @@ private Object ensureValidObject(final Object value) { /** Ensures the value is on the given list. */ private Object ensureValid(final Object value, final List list) { + if (value == null) + return list.contains(null); for (final Object o : list) { - if (o.equals(value)) return value; // value is valid + if (value.equals(o)) return value; // value is valid // check if value was converted and cached final Object convertedValue = convertedObjects.get(o); if (convertedValue != null && value.equals(convertedValue)) { From 14aa08f3ddcc845ab6ad89ce6f197d5de90fff54 Mon Sep 17 00:00:00 2001 From: LeonYang5114 Date: Wed, 25 Nov 2015 10:04:02 -0600 Subject: [PATCH 0042/1208] Fix bug of overwriting pre-assigned values The DefaultValuePreprocessor overwrote the value of the module's corresponding item even if the item is pre-assigned with some value. Now it checks if the item is primitive or if it is non-null before setting the default value. See also: --- .../org/scijava/module/process/DefaultValuePreprocessor.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java b/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java index a4ee85713..a795cee4a 100644 --- a/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java +++ b/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java @@ -37,6 +37,8 @@ import org.scijava.module.ModuleService; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; +import org.scijava.util.ConversionUtils; +import org.scijava.util.MiscUtils; /** * A preprocessor plugin that populates default parameter values. @@ -70,6 +72,8 @@ private void assignDefaultValue(final Module module, final ModuleItem item) { if (module.isResolved(item.getName())) return; + final T nullValue = ConversionUtils.getNullValue(item.getType()); + if (MiscUtils.equal(item.getValue(module), nullValue)) return; final T defaultValue = moduleService.getDefaultValue(item); if (defaultValue == null) return; item.setValue(module, defaultValue); From 1933a52e9109648e17189a58753332b7118cc481 Mon Sep 17 00:00:00 2001 From: LeonYang5114 Date: Wed, 25 Nov 2015 17:01:19 -0600 Subject: [PATCH 0043/1208] Remove unnecessary method call --- src/main/java/org/scijava/command/CommandModuleItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/command/CommandModuleItem.java b/src/main/java/org/scijava/command/CommandModuleItem.java index e0f45dfeb..1af834e89 100644 --- a/src/main/java/org/scijava/command/CommandModuleItem.java +++ b/src/main/java/org/scijava/command/CommandModuleItem.java @@ -159,7 +159,7 @@ public List getChoices() { if (choices.length == 0) return super.getChoices(); final ArrayList choiceList = new ArrayList(); - for (final String choice : getParameter().choices()) { + for (final String choice : choices) { choiceList.add(tValue(choice)); } return choiceList; From c0ebfe30a0dd594c8a9adabfb13e17b643e512b8 Mon Sep 17 00:00:00 2001 From: Gabriel Einsdorf Date: Wed, 2 Dec 2015 16:20:00 -0600 Subject: [PATCH 0044/1208] Add @Override annotation to method missing it. --- src/main/java/org/scijava/util/MersenneTwisterFast.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/scijava/util/MersenneTwisterFast.java b/src/main/java/org/scijava/util/MersenneTwisterFast.java index 9c89eaea9..f8eb8cf24 100644 --- a/src/main/java/org/scijava/util/MersenneTwisterFast.java +++ b/src/main/java/org/scijava/util/MersenneTwisterFast.java @@ -229,6 +229,7 @@ public strictfp class MersenneTwisterFast implements Serializable, Cloneable private boolean __haveNextNextGaussian; /* We're overriding all internal data, to my knowledge, so this should be okay */ + @Override public Object clone() { try From 9b96272bcff75c58aaa5414952a7fdf92bbc07fa Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 3 Dec 2015 13:34:03 -0600 Subject: [PATCH 0045/1208] Add a FIXME See also #213. --- src/main/java/org/scijava/command/CommandModuleItem.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/scijava/command/CommandModuleItem.java b/src/main/java/org/scijava/command/CommandModuleItem.java index 58fd4bb2a..31fe5842f 100644 --- a/src/main/java/org/scijava/command/CommandModuleItem.java +++ b/src/main/java/org/scijava/command/CommandModuleItem.java @@ -145,6 +145,7 @@ public T getMaximumValue() { @Override public Number getStepSize() { + // FIXME: stepSize should be typed on T, not Number! final String value = getParameter().stepSize(); try { final double stepSize = Double.parseDouble(value); From 35875af94876137dec23053ddabb0fcb3770f06e Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 3 Dec 2015 20:01:16 -0600 Subject: [PATCH 0046/1208] Add Maven Central shield to the README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5f8b5ca0c..68ac93496 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![](https://img.shields.io/maven-central/v/org.scijava/scijava-common.svg)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.scijava%22%20AND%20a%3A%22scijava-common%22) [![](http://jenkins.imagej.net/job/SciJava-common/lastBuild/badge/icon)](http://jenkins.imagej.net/job/SciJava-common/) [![Join the chat at https://gitter.im/scijava/scijava-common](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/scijava/scijava-common?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) From cfd81502daf02c3dc22cd1ba84a45d7926abc2c4 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 4 Dec 2015 15:35:17 -0600 Subject: [PATCH 0047/1208] Context: add ctor for _real_ emptiness The Context(boolean) constructor creates contexts without services, but which still have the full PluginIndex. This change (thanks to @gab1one) provides a more aggressive sort of emptiness, completely devoid of any plugins whatsoever. --- src/main/java/org/scijava/Context.java | 36 ++++++++++++++++++++------ 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/scijava/Context.java b/src/main/java/org/scijava/Context.java index a533f3858..c3e02d9dc 100644 --- a/src/main/java/org/scijava/Context.java +++ b/src/main/java/org/scijava/Context.java @@ -110,14 +110,25 @@ public Context() { /** * Creates a new SciJava application context. * - * @param empty If true, the context will be empty; otherwise, it will be - * initialized with all available services. - * @see #Context(Collection, PluginIndex, boolean) + * @param empty If true, the context will be empty of services; otherwise, it + * will be initialized with all available services. + * @see #Context(boolean, boolean) */ - @SuppressWarnings("unchecked") public Context(final boolean empty) { - this(empty ? Collections.> emptyList() : Arrays - .> asList(Service.class)); + this(empty, false); + } + + /** + * Creates a new SciJava application context. + * + * @param noServices If true, the context will contain no services; otherwise, + * it will be initialized with all available services. + * @param noPlugins If true, the context will contain no plugins; otherwise, + * it will be initialized with all available plugins. + * @see #Context(Collection, PluginIndex, boolean) + */ + public Context(final boolean noServices, final boolean noPlugins) { + this(services(noServices), plugins(noPlugins)); } /** @@ -195,9 +206,8 @@ public Context(final Collection> serviceClasses, * result in a default plugin index being constructed and used. * @see #Context(Collection, PluginIndex, boolean) */ - @SuppressWarnings("unchecked") public Context(final PluginIndex pluginIndex) { - this(Arrays.> asList(Service.class), pluginIndex); + this(services(false), pluginIndex); } /** @@ -510,6 +520,16 @@ private String createMissingServiceMessage( return msg.toString(); } + private static PluginIndex plugins(final boolean empty) { + return empty ? new PluginIndex(null) : null; + } + + @SuppressWarnings("unchecked") + private static List> services(final boolean empty) { + if (empty) return Collections.> emptyList(); + return Arrays.> asList(Service.class); + } + private static boolean strict() { return !"false".equals(System.getProperty(STRICT_PROPERTY)); } From dbc00b52689731f82615863a2bbb417322361806 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 4 Dec 2015 15:42:47 -0600 Subject: [PATCH 0048/1208] ContextCreationTest: add empty plugins test --- src/test/java/org/scijava/ContextCreationTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/org/scijava/ContextCreationTest.java b/src/test/java/org/scijava/ContextCreationTest.java index d015c3853..d9ebd1979 100644 --- a/src/test/java/org/scijava/ContextCreationTest.java +++ b/src/test/java/org/scijava/ContextCreationTest.java @@ -32,6 +32,7 @@ package org.scijava; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; @@ -63,6 +64,17 @@ public class ContextCreationTest { public void testEmpty() { final Context context = new Context(true); assertTrue(context.getServiceIndex().isEmpty()); + assertFalse(context.getPluginIndex().isEmpty()); + } + + /** + * Tests {@link Context#Context(boolean, boolean)} with {@code (true, true)}. + */ + @Test + public void testNoPlugins() { + final Context context = new Context(true, true); + assertTrue(context.getServiceIndex().isEmpty()); + assertTrue(context.getPluginIndex().isEmpty()); } /** From d2fecd2982e6757431dd3239a0a7c64ae6664dba Mon Sep 17 00:00:00 2001 From: Gabriel Einsdorf Date: Sat, 5 Dec 2015 20:45:14 -0600 Subject: [PATCH 0049/1208] Only try to load services if required. If the serviceClasses Collection is empty, there is no reason to create a ServiceHelper. --- src/main/java/org/scijava/Context.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/Context.java b/src/main/java/org/scijava/Context.java index c3e02d9dc..1fb063b23 100644 --- a/src/main/java/org/scijava/Context.java +++ b/src/main/java/org/scijava/Context.java @@ -272,9 +272,11 @@ public Context(final Collection> serviceClasses, setStrict(strict); - final ServiceHelper serviceHelper = - new ServiceHelper(this, serviceClasses, strict); - serviceHelper.loadServices(); + if (!serviceClasses.isEmpty()){ + final ServiceHelper serviceHelper = + new ServiceHelper(this, serviceClasses, strict); + serviceHelper.loadServices(); + } } // -- Context methods -- From d342895593a82058be0577b6e7ea8380b9f3daf7 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 7 Dec 2015 13:27:32 -0600 Subject: [PATCH 0050/1208] POM: bump parent to pom-scijava 9.1.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dbb01116c..b00b9ae3b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.scijava pom-scijava - 9.0.0 + 9.1.0 From 9ad849d0f4bcbb99b6beb692627a3f7a0539c2b3 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 7 Dec 2015 13:30:06 -0600 Subject: [PATCH 0051/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b00b9ae3b..0ca4e49e1 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.49.2-SNAPSHOT + 2.50.1-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From b71dc5c1a1e5a6fda3013cdbad6c9313933f7946 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 8 Dec 2015 09:51:12 -0600 Subject: [PATCH 0052/1208] Support cancelation during module initialization Thanks to Richard Domander for pointing out this limitation. See: https://gitter.im/fiji/fiji/archives/2015/12/08 --- .../scijava/module/process/InitPreprocessor.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/org/scijava/module/process/InitPreprocessor.java b/src/main/java/org/scijava/module/process/InitPreprocessor.java index 3a723d21a..8e9c03a7d 100644 --- a/src/main/java/org/scijava/module/process/InitPreprocessor.java +++ b/src/main/java/org/scijava/module/process/InitPreprocessor.java @@ -31,6 +31,7 @@ package org.scijava.module.process; +import org.scijava.Cancelable; import org.scijava.Priority; import org.scijava.log.LogService; import org.scijava.module.MethodCallException; @@ -58,6 +59,7 @@ public class InitPreprocessor extends AbstractPreprocessorPlugin { public void process(final Module module) { try { module.initialize(); + if (isCanceled(module)) cancel(getCancelReason(module)); } catch (final MethodCallException exc) { if (log != null) log.error(exc); @@ -66,4 +68,16 @@ public void process(final Module module) { } } + // -- Helper methods -- + + private boolean isCanceled(final Module module) { + return module instanceof Cancelable && ((Cancelable) module).isCanceled(); + } + + private String getCancelReason(final Module module) { + if (!(module instanceof Cancelable)) return null; + final String cancelReason = ((Cancelable) module).getCancelReason(); + return cancelReason == null ? "" : cancelReason; + } + } From 7c20295facbd820139e04d0b521a42cdc8fcbd29 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 9 Dec 2015 13:41:45 -0600 Subject: [PATCH 0053/1208] ClassUtils: clean up CacheMap Improves the javadoc, adding more information and fixing refactoring artifacts (such as references to Field or Method in the general base class) --- .../java/org/scijava/util/ClassUtils.java | 67 +++++++++++-------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/scijava/util/ClassUtils.java b/src/main/java/org/scijava/util/ClassUtils.java index 2d189bf16..8c7b5ff66 100644 --- a/src/main/java/org/scijava/util/ClassUtils.java +++ b/src/main/java/org/scijava/util/ClassUtils.java @@ -758,33 +758,43 @@ public static Type getGenericType(final Field field, final Class type) { // -- Helper classes -- /** - * Convenience class to further type narrow {@link CacheMap} to {@link Field} - * s. + * Convenience class for a {@link CacheMap} that stores annotated + * {@link Field}s. */ private static class FieldCache extends CacheMap {} /** - * Convenience class to further type narrow {@link CacheMap} to {@link Method} - * s. + * Convenience class for a {@link CacheMap} that stores annotated + * {@link Method}s. */ private static class MethodCache extends CacheMap {} /** * Convenience class for {@code Map > Map > List} hierarchy. Cleans up * generics and contains helper methods for traversing the two map levels. + *

+ * The intent for this class is to allow subclasses to specify the generic + * parameter ultimately referenced by the at the end of these maps. + *

+ *

+ * The first map key is a base class, presumably with various types of + * annotations. The second map key is the annotation class, for example + * {@link Method} or {@link Field}. The list then contains all instances of + * the annotated type within the original base class. + *

* - * @param - {@link AnnotatedElement} {@link List} ultimately referenced by - * this map + * @param - The type of {@link AnnotatedElement} contained by the + * {@link List} ultimately referenced by these {@link Map}s */ private static class CacheMap extends HashMap, Map, List>> { /** - * @param c Base class - * @param annotationClass Annotation type - * @return Cached list of Methods in the base class with the specified - * annotation, or null if a cached list does not exist. + * @param c Base class of interest + * @param annotationClass {@link Annotation type within the base class + * @return A {@link List} of instances in the base class with the specified + * {@link Annotation}, or null if a cached list does not exist. */ public List getList(final Class c, final Class annotationClass) @@ -798,16 +808,16 @@ public List getList(final Class c, } /** - * Populates the provided list with {@link Method} entries of the given base - * class which are annotated with the specified annotation type. + * Creates a {@code base class > annotation > list of elements} mapping to + * the provided list, creating the intermediate map if needed. * - * @param c Base class - * @param annotationClass Annotation type - * @param annotatedMethods Method list to populate + * @param c Base class of interest + * @param annotationClass {@link Annotation} type of interest + * @param annotatedElements List of {@link AnnotatedElement}s to map */ public void putList(final Class c, final Class annotationClass, - final List annotatedMethods) + final List annotatedElements) { Map, List> map = get(c); if (map == null) { @@ -815,27 +825,28 @@ public void putList(final Class c, put(c, map); } - map.put(annotationClass, annotatedMethods); + map.put(annotationClass, annotatedElements); } /** - * As {@link #getList(Class, Class)} but ensures an array is created and - * mapped, if it doesn't already exist. + * Generates mappings as in {@link #putList(Class, Class, List)}, but also + * creates the {@link List} if it doesn't already exist. Returns the final + * list at this mapping, for external population. * - * @param c Base class - * @param annotationClass Annotation type - * @return Cached list of Fields in the base class with the specified - * annotation. + * @param c Base class of interest + * @param annotationClass {@link Annotation} type of interest + * @return Cached list of {@link AnnotatedElement}s in the base class with + * the specified {@link Annotation}. */ public List makeList(final Class c, final Class annotationClass) { - List methods = getList(c, annotationClass); - if (methods == null) { - methods = new ArrayList(); - putList(c, annotationClass, methods); + List elements = getList(c, annotationClass); + if (elements == null) { + elements = new ArrayList(); + putList(c, annotationClass, elements); } - return methods; + return elements; } } From f6f3d8466c9b7185052e572043645e1d15996e85 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 7 Dec 2015 21:08:42 -0600 Subject: [PATCH 0054/1208] ClassUtils: trap more class loading errors No class loading error should crash the thread, ever. Ops just switched to Java 8. Unfortunately, this change crashed the context startup in the following way: java.lang.UnsupportedClassVersionError: net/imagej/ops/DefaultNamespaceService : Unsupported major.minor version 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at org.scijava.util.ClassUtils.loadClass(ClassUtils.java:164) at org.scijava.plugin.PluginInfo.loadClass(PluginInfo.java:283) at org.scijava.plugin.PluginInfo.getIdentifier(PluginInfo.java:320) at org.scijava.AbstractUIDetails.getTitle(AbstractUIDetails.java:108) at org.scijava.AbstractUIDetails.compareTo(AbstractUIDetails.java:237) at org.scijava.AbstractUIDetails.compareTo(AbstractUIDetails.java:43) at java.util.ComparableTimSort.binarySort(ComparableTimSort.java:232) at java.util.ComparableTimSort.sort(ComparableTimSort.java:176) at java.util.ComparableTimSort.sort(ComparableTimSort.java:146) at java.util.Arrays.sort(Arrays.java:472) at java.util.Collections.sort(Collections.java:155) at org.scijava.object.SortedObjectIndex.mergeAfterSorting(SortedObjectIndex.java:97) at org.scijava.object.SortedObjectIndex.addAll(SortedObjectIndex.java:83) at org.scijava.plugin.PluginIndex.discover(PluginIndex.java:108) at org.scijava.Context.(Context.java:261) --- src/main/java/org/scijava/util/ClassUtils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/util/ClassUtils.java b/src/main/java/org/scijava/util/ClassUtils.java index 8c7b5ff66..61b9cbc29 100644 --- a/src/main/java/org/scijava/util/ClassUtils.java +++ b/src/main/java/org/scijava/util/ClassUtils.java @@ -163,7 +163,11 @@ public static Class loadClass(final String name, : classLoader; return cl.loadClass(className); } - catch (final ClassNotFoundException e) { + catch (final Throwable t) { + // NB: Do not allow any failure to load the class to crash us. + // Not ClassNotFoundException. + // Not NoClassDefFoundError. + // Not UnsupportedClassVersionError! return null; } } From 52acc853ed1dd77b9b487f0d3c9cfac45f7fbd6d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 7 Dec 2015 22:07:08 -0600 Subject: [PATCH 0055/1208] ClassUtils: be defensive when caching annotations This avoids the following exception when injecting the application context into the ImageJ gateway: java.lang.UnsupportedClassVersionError: net/imagej/ops/OpService : Unsupported major.minor version 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2625) at java.lang.Class.getDeclaredMethods(Class.java:1868) at org.scijava.util.ClassUtils.cacheAnnotatedObjects(ClassUtils.java:507) at org.scijava.Context.inject(Context.java:377) at org.scijava.AbstractContextual.setContext(AbstractContextual.java:68) at org.scijava.AbstractGateway.(AbstractGateway.java:85) at net.imagej.ImageJ.(ImageJ.java:90) --- .../java/org/scijava/util/ClassUtils.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/scijava/util/ClassUtils.java b/src/main/java/org/scijava/util/ClassUtils.java index 61b9cbc29..0b82ccaa8 100644 --- a/src/main/java/org/scijava/util/ClassUtils.java +++ b/src/main/java/org/scijava/util/ClassUtils.java @@ -358,7 +358,7 @@ public static List getAnnotatedMethods( cachedMethods = methodCache.getList(c, annotationClass); } - methods.addAll(cachedMethods); + if (cachedMethods != null) methods.addAll(cachedMethods); } /** @@ -501,15 +501,20 @@ else if (methodCache.getList(scannedClass, annotationClass) != null) { final Class objectClass = query.get(annotationClass); - // Methods - if (Method.class.isAssignableFrom(objectClass)) { - populateCache(scannedClass, inherited, annotationClass, methodCache, - scannedClass.getDeclaredMethods()); + try { + // Methods + if (Method.class.isAssignableFrom(objectClass)) { + populateCache(scannedClass, inherited, annotationClass, methodCache, + scannedClass.getDeclaredMethods()); + } + // Fields + else if (Field.class.isAssignableFrom(objectClass)) { + populateCache(scannedClass, inherited, annotationClass, fieldCache, + scannedClass.getDeclaredFields()); + } } - // Fields - else if (Field.class.isAssignableFrom(objectClass)) { - populateCache(scannedClass, inherited, annotationClass, fieldCache, - scannedClass.getDeclaredFields()); + catch (final Throwable t) { + // NB: No action needed? } } } From ccaaa6ad6a30e86a1068ac04af57d5c72c334cd1 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 9 Dec 2015 14:37:11 -0600 Subject: [PATCH 0056/1208] DefaultConverter: fix bug converting to Collection It is straightforward to convert from a Collection subclass (e.g., ArrayList) to a Collection. It is just a simple cast. This bug prevented such casts from taking place, due to over-eager precedence of Collection-specific handling. We really need to rewrite this stuff; see: https://github.com/scijava/scijava-common/issues/109 --- .../java/org/scijava/convert/DefaultConverter.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/scijava/convert/DefaultConverter.java b/src/main/java/org/scijava/convert/DefaultConverter.java index c86a4f28e..561dd3c5f 100644 --- a/src/main/java/org/scijava/convert/DefaultConverter.java +++ b/src/main/java/org/scijava/convert/DefaultConverter.java @@ -294,13 +294,15 @@ private Collection createCollection(final Class type) { @Override @Deprecated public boolean canConvert(final Class src, final Type dest) { - + // Handle array types, including generic array types. if (isArray(dest)) return true; - + // Handle parameterized collection types. - if (dest instanceof ParameterizedType && isCollection(dest)) { - return createCollection(GenericUtils.getClass(dest)) != null; + if (dest instanceof ParameterizedType && isCollection(dest) && + createCollection(GenericUtils.getClass(dest)) != null) + { + return true; } return super.canConvert(src, dest); From 867ab9c6378d9b293a7a9195c87e6eca5ffabaec Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 9 Dec 2015 14:42:08 -0600 Subject: [PATCH 0057/1208] ConverterTest: Add a test for generic Collections This is a regression test for the bug-fix in d40759d32010f86114ed099f8c425a246ad7bc3a. --- .../java/org/scijava/convert/ConverterTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/test/java/org/scijava/convert/ConverterTest.java b/src/test/java/org/scijava/convert/ConverterTest.java index c982d7475..de75c9f3e 100644 --- a/src/test/java/org/scijava/convert/ConverterTest.java +++ b/src/test/java/org/scijava/convert/ConverterTest.java @@ -35,10 +35,14 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.lang.reflect.Field; import java.lang.reflect.Type; import java.util.ArrayList; +import java.util.Collection; import org.junit.Test; +import org.scijava.util.ClassUtils; +import org.scijava.util.GenericUtils; /** * Tests individual {@link Converter}s. @@ -49,6 +53,7 @@ *

* * @author Mark Hiner + * @author Curtis Rueden */ public class ConverterTest { @@ -83,6 +88,18 @@ public void testCanConvert() { assertTrue(nc.canConvert(Integer.class, Number.class)); } + @SuppressWarnings("unused") + private Collection collection; + + @Test + public void testCanConvertToGenericCollection() { + final DefaultConverter dc = new DefaultConverter(); + + final Field destField = ClassUtils.getField(getClass(), "collection"); + final Type destType = GenericUtils.getFieldType(destField, getClass()); + assertTrue(dc.canConvert(ArrayList.class, destType)); + } + private static class NumberConverter extends AbstractConverter { @SuppressWarnings("unchecked") From c3c1a943aa894fa3ee0f5d8cd113e737ec711ece Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Fri, 11 Dec 2015 08:26:14 -0600 Subject: [PATCH 0058/1208] ClassUtils: fix AnnotatedObject refs AnnotatedObject doesn't exist; they're AnnotatedElements. --- src/main/java/org/scijava/util/ClassUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/util/ClassUtils.java b/src/main/java/org/scijava/util/ClassUtils.java index 0b82ccaa8..d73a82e26 100644 --- a/src/main/java/org/scijava/util/ClassUtils.java +++ b/src/main/java/org/scijava/util/ClassUtils.java @@ -415,16 +415,16 @@ public static void getAnnotatedFields( /** * This method scans the provided class, its superclasses and interfaces for - * all supported {@link Annotation} : {@link AnnotatedObject} pairs. + * all supported {@link Annotation} : {@link AnnotatedElement} pairs. * These are then cached to remove the need for future queries. *

- * By combining multiple {@code Annotation : AnnotatedObject} pairs in one + * By combining multiple {@code Annotation : AnnotatedElement} pairs in one * query, we can limit the number of times a class's superclass and interface * hierarchy are traversed. *

* * @param scannedClass Class to scan - * @param query Pairs of {@link Annotation} and {@link AnnotatedObject}s to + * @param query Pairs of {@link Annotation} and {@link AnnotatedElement}s to * discover. */ public static void cacheAnnotatedObjects(final Class scannedClass, From d062d5b9c1bbf36b183269905d29de96e9512430 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Fri, 11 Dec 2015 09:14:34 -0600 Subject: [PATCH 0059/1208] ClassUtils: fix javadoc Now up-to-date with ImageJ eclipse prefs. --- src/main/java/org/scijava/util/ClassUtils.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/scijava/util/ClassUtils.java b/src/main/java/org/scijava/util/ClassUtils.java index d73a82e26..2a8d1a564 100644 --- a/src/main/java/org/scijava/util/ClassUtils.java +++ b/src/main/java/org/scijava/util/ClassUtils.java @@ -574,7 +574,9 @@ public static void setValue(final Field field, final Object instance, // the given value needs to be converted to a compatible type final Type fieldType = GenericUtils.getFieldType(field, instance.getClass()); - compatibleValue = ConversionUtils.convert(value, fieldType); + @SuppressWarnings("deprecation") + final Object convertedValue = ConversionUtils.convert(value, fieldType); + compatibleValue = convertedValue; } field.set(instance, compatibleValue); } @@ -770,13 +772,17 @@ public static Type getGenericType(final Field field, final Class type) { * Convenience class for a {@link CacheMap} that stores annotated * {@link Field}s. */ - private static class FieldCache extends CacheMap {} + private static class FieldCache extends CacheMap { + // Trivial subclass to narrow generic params + } /** * Convenience class for a {@link CacheMap} that stores annotated * {@link Method}s. */ - private static class MethodCache extends CacheMap {} + private static class MethodCache extends CacheMap { + // Trivial subclass to narrow generic params + } /** * Convenience class for {@code Map > Map > List} hierarchy. Cleans up @@ -801,7 +807,7 @@ private static class CacheMap extends /** * @param c Base class of interest - * @param annotationClass {@link Annotation type within the base class + * @param annotationClass {@link Annotation} type within the base class * @return A {@link List} of instances in the base class with the specified * {@link Annotation}, or null if a cached list does not exist. */ From b5333a16b75795afe0e8fa906a65b868f92b0850 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 15 Dec 2015 11:46:15 -0600 Subject: [PATCH 0060/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0ca4e49e1..c7b74d33e 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.50.1-SNAPSHOT + 2.50.2-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From 5f1b644f820b61358d2f6339f9c2ca6cf3f4552d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 15 Jan 2016 13:17:10 +0100 Subject: [PATCH 0061/1208] DefaultPrefService: add other authors Grant and I originally developed much of this code as a static utility class called Prefs. --- src/main/java/org/scijava/prefs/DefaultPrefService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/scijava/prefs/DefaultPrefService.java b/src/main/java/org/scijava/prefs/DefaultPrefService.java index b4f909b27..5c0ec2897 100644 --- a/src/main/java/org/scijava/prefs/DefaultPrefService.java +++ b/src/main/java/org/scijava/prefs/DefaultPrefService.java @@ -48,6 +48,8 @@ * disk using the Java {@link Preferences} API. * * @author Mark Hiner + * @author Curtis Rueden + * @author Grant Harris */ @Plugin(type = Service.class) public class DefaultPrefService extends AbstractPrefService { From 1078b603b9386ce2563ca62639eadf69073389c1 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 15 Jan 2016 13:18:32 +0100 Subject: [PATCH 0062/1208] DefaultPrefService: remove obsolete TODO --- .../java/org/scijava/prefs/DefaultPrefService.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main/java/org/scijava/prefs/DefaultPrefService.java b/src/main/java/org/scijava/prefs/DefaultPrefService.java index 5c0ec2897..9e666e444 100644 --- a/src/main/java/org/scijava/prefs/DefaultPrefService.java +++ b/src/main/java/org/scijava/prefs/DefaultPrefService.java @@ -54,16 +54,6 @@ @Plugin(type = Service.class) public class DefaultPrefService extends AbstractPrefService { - // TODO - with the conversion from a static utility class to a service, we - // have unfortunately lost some power to adapt behavior to individual data - // types - either the whole service is superceded, or it's not. For example, - // see the saveValue/loadValue of the ModuleItem class, where each item could - // decide how it was saved and loaded. - // Thus it would be nice to refactor this service to use the Handler pattern, - // such that there would just be a few base put/get methods that delegated - // to appropriate handlers. Then the handlers of a single type could be - // provided and overridden. - // -- Global preferences -- @Override From 5d4b849493b3220a41e32144d453c6156242061f Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 15 Jan 2016 13:28:28 +0100 Subject: [PATCH 0063/1208] DefaultPrefService: wrap all Preferences access This encapsulates direct usage of the java.util.prefs API to: 1) a SmartPrefs class with many of the same methods (and a few new ones) 2) four remaining private helper methods of DefaultPrefService itself. We no longer explicitly import java.util.prefs at the top of the class, to make it easier to verify that the _only_ usages are as stated above. The SmartPrefs class wraps a java.util.prefs.Preferences object, providing much of the same API, as well as some new convenience API matching that of the PrefService itself (notably: collections). This change paves the way for more fine-grained control over our exact usage of the Preferences API. In particular, see bug-fix in next commit. --- .../org/scijava/prefs/DefaultPrefService.java | 418 +++++++++++------- 1 file changed, 247 insertions(+), 171 deletions(-) diff --git a/src/main/java/org/scijava/prefs/DefaultPrefService.java b/src/main/java/org/scijava/prefs/DefaultPrefService.java index 9e666e444..623e0cb4b 100644 --- a/src/main/java/org/scijava/prefs/DefaultPrefService.java +++ b/src/main/java/org/scijava/prefs/DefaultPrefService.java @@ -37,15 +37,15 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.prefs.BackingStoreException; -import java.util.prefs.Preferences; +import org.scijava.log.LogService; +import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; import org.scijava.service.Service; /** * Default {@link PrefService} implementation, which persists preferences to - * disk using the Java {@link Preferences} API. + * disk using the {@link java.util.prefs.Preferences} API. * * @author Mark Hiner * @author Curtis Rueden @@ -54,6 +54,9 @@ @Plugin(type = Service.class) public class DefaultPrefService extends AbstractPrefService { + @Parameter(required = false) + private LogService log; + // -- Global preferences -- @Override @@ -202,12 +205,7 @@ public void put(final Class c, final String name, final long value) { @Override public void clear(final Class c) { - try { - prefs(c).clear(); - } - catch (final BackingStoreException e) { - // do nothing - } + prefs(c).clear(); } // -- Other/unsorted -- @@ -217,13 +215,8 @@ public void clear(final Class c) { @Override public void clearAll() { - try { - for (final String name : allPrefs()) - prefs(name).removeNode(); - } - catch (final BackingStoreException e) { - // do nothing - } + for (final String name : allPrefs()) + prefs(name).removeNode(); } @Override @@ -233,26 +226,22 @@ public void clear(final String key) { @Override public void clear(final Class prefClass, final String key) { - final Preferences preferences = prefs(prefClass); - clear(preferences, key); + prefs(prefClass).clear(key); } @Override public void clear(final String absolutePath, final String key) { - final Preferences preferences = prefs(absolutePath); - clear(preferences, key); + prefs(absolutePath).clear(key); } @Override public void remove(final Class prefClass, final String key) { - final Preferences preferences = prefs(prefClass); - remove(preferences, key); + prefs(prefClass).remove(key); } @Override public void remove(final String absolutePath, final String key) { - final Preferences preferences = prefs(absolutePath); - remove(preferences, key); + prefs(absolutePath).remove(key); } @Override @@ -264,28 +253,24 @@ public void putMap(final Map map, final String key) { public void putMap(final Class prefClass, final Map map, final String key) { - final Preferences preferences = prefs(prefClass); - putMap(preferences.node(key), map); + prefs(prefClass).node(key).putMap(map); } @Override public void putMap(final String absolutePath, final Map map, final String key) { - final Preferences preferences = prefs(absolutePath); - putMap(preferences.node(key), map); + prefs(absolutePath).node(key).putMap(map); } @Override public void putMap(final Class prefClass, final Map map) { - final Preferences preferences = prefs(prefClass); - putMap(preferences, map); + prefs(prefClass).putMap(map); } @Override public void putMap(final String absolutePath, final Map map) { - final Preferences preferences = prefs(absolutePath); - putMap(preferences, map); + prefs(absolutePath).putMap(map); } @Override @@ -296,22 +281,19 @@ public Map getMap(final String key) { @Override public Map getMap(final Class prefClass, final String key) { - final Preferences preferences = prefs(prefClass); - return getMap(preferences.node(key)); + return prefs(prefClass).node(key).getMap(); } @Override public Map getMap(final String absolutePath, final String key) { - final Preferences preferences = prefs(absolutePath); - return getMap(preferences.node(key)); + return prefs(absolutePath).node(key).getMap(); } @Override public Map getMap(final Class prefClass) { - final Preferences preferences = prefs(prefClass); - return getMap(preferences); + return prefs(prefClass).getMap(); } @Override @@ -323,28 +305,24 @@ public void putList(final List list, final String key) { public void putList(final Class prefClass, final List list, final String key) { - final Preferences preferences = prefs(prefClass); - putList(preferences.node(key), list); + prefs(prefClass).node(key).putList(list); } @Override public void putList(final String absolutePath, final List list, final String key) { - final Preferences preferences = prefs(absolutePath); - putList(preferences.node(key), list); + prefs(absolutePath).node(key).putList(list); } @Override public void putList(final Class prefClass, final List list) { - final Preferences preferences = prefs(prefClass); - putList(preferences, list); + prefs(prefClass).putList(list); } @Override public void putList(final String absolutePath, final List list) { - final Preferences preferences = prefs(absolutePath); - putList(preferences, list); + prefs(absolutePath).putList(list); } @Override @@ -354,20 +332,17 @@ public List getList(final String key) { @Override public List getList(final Class prefClass, final String key) { - final Preferences preferences = prefs(prefClass); - return getList(preferences.node(key)); + return prefs(prefClass).node(key).getList(); } @Override public List getList(final String absolutePath, final String key) { - final Preferences preferences = prefs(absolutePath); - return getList(preferences.node(key)); + return prefs(absolutePath).node(key).getList(); } @Override public List getList(final Class prefClass) { - final Preferences preferences = prefs(prefClass); - return getList(preferences); + return prefs(prefClass).getList(); } @Override @@ -377,8 +352,7 @@ public Iterable getIterable(final String key) { @Override public Iterable getIterable(final Class prefClass, final String key) { - final Preferences preferences = prefs(prefClass); - return getIterable(preferences.node(key)); + return prefs(prefClass).node(key).getIterable(); } @Override @@ -388,159 +362,261 @@ public void putIterable(final Iterable iterable, final String key) { @Override public void putIterable(final Class prefClass, final Iterable iterable, final String key) { - final Preferences preferences = prefs(prefClass); - putIterable(preferences.node(key), iterable); + prefs(prefClass).node(key).node(key).putIterable(iterable); } // -- Helper methods -- - private void clear(final Preferences preferences, final String key) { - try { - if (preferences.nodeExists(key)) { - preferences.node(key).clear(); - } - } - catch (final BackingStoreException bse) { - bse.printStackTrace(); - } + private static String key(final Class c, final String name) { + return c == null ? name : c.getSimpleName() + "." + name; + } + + private SmartPrefs prefs(final Class c) { + return new SmartPrefs(java.util.prefs.Preferences.userNodeForPackage( + c == null ? PrefService.class : c), log); + } + + private SmartPrefs prefs(final String absolutePath) { + return new SmartPrefs(java.util.prefs.Preferences.userRoot().node( + absolutePath), log); } - private void remove(final Preferences preferences, final String key) { + private String[] allPrefs() { try { - if (preferences.nodeExists(key)) { - preferences.node(key).removeNode(); - } + return java.util.prefs.Preferences.userRoot().childrenNames(); } - catch (final BackingStoreException bse) { - bse.printStackTrace(); + catch (java.util.prefs.BackingStoreException exc) { + log.error(exc); + return new String[0]; } } - private void putMap(final Preferences preferences, - final Map map) - { - if (preferences == null) { - throw new IllegalArgumentException("Preferences not set."); + // -- Helper classes -- + + /** + * Smart wrapper around {@link java.util.prefs.Preferences} which + * encapsulates, improves and enhances its behavior. + */ + private static class SmartPrefs { + + private final java.util.prefs.Preferences p; + private final LogService log; + + public SmartPrefs(final java.util.prefs.Preferences p, + final LogService log) + { + this.p = p; + this.log = log; } - final Iterator> iter = map.entrySet().iterator(); - while (iter.hasNext()) { - final Entry entry = iter.next(); - final Object value = entry.getValue(); - preferences.put(entry.getKey().toString(), value == null ? null : value - .toString()); + + // -- SmartPrefs methods -- + + public void clear(final String key) { + if (nodeExists(key)) node(key).clear(); } - } + public void remove(final String key) { + if (nodeExists(key)) node(key).removeNode(); + } + + public void putMap(final Map map) { + final Iterator> iter = map.entrySet().iterator(); + while (iter.hasNext()) { + final Entry entry = iter.next(); + final String key = entry.getKey().toString(); + final Object value = entry.getValue(); + put(key, value); + } - private Map getMap(final Preferences preferences) { - if (preferences == null) { - throw new IllegalArgumentException("Preferences not set."); } - final Map map = new HashMap(); - try { - final String[] keys = preferences.keys(); + + public Map getMap() { + final Map map = new HashMap(); + final String[] keys = keys(); for (int index = 0; index < keys.length; index++) { - map.put(keys[index], preferences.get(keys[index], null)); + map.put(keys[index], get(keys[index])); + } + return map; + } + + public void putList(final List list) { + for (int index = 0; list != null && index < list.size(); index++) { + final Object value = list.get(index); + put("" + index, value); } } - catch (final BackingStoreException bse) { - bse.printStackTrace(); + + public List getList() { + final List list = new ArrayList(); + for (int index = 0; index < 1000; index++) { + final String value = get("" + index); + if (value == null) { + break; + } + list.add(value); + } + return list; } - return map; - } - private void putList(final Preferences preferences, final List list) { - if (preferences == null) { - throw new IllegalArgumentException("Preferences not set."); + public void putIterable(final Iterable iterable) { + int index = 0; + for (final String value : iterable) { + put("" + index++, value); + } } - for (int index = 0; list != null && index < list.size(); index++) { - final Object value = list.get(index); - preferences.put("" + index, value == null ? null : value.toString()); + + public Iterable getIterable() { + return new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + private String value; + private int index; + { + findNext(); + } + + @Override + public String next() { + final String result = value; + findNext(); + return result; + } + + @Override + public boolean hasNext() { + return value != null; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + private void findNext() { + if (index < 0) return; + value = get("" + index); + index = value == null ? -1 : index + 1; + } + }; + } + }; + } + + // -- Adapted Preferences methods -- + + /** @see java.util.prefs.Preferences#put */ + public void put(final String key, final Object value) { + p.put(key, value == null ? null : value.toString()); + } + + /** @see java.util.prefs.Preferences#get(String, String) */ + public String get(final String key) { + return get(key, null); } - } - private List getList(final Preferences preferences) { - if (preferences == null) { - throw new IllegalArgumentException("Preferences not set."); + /** @see java.util.prefs.Preferences#get(String, String) */ + public String get(final String key, final String def) { + return p.get(key, def); } - final List list = new ArrayList(); - for (int index = 0; index < 1000; index++) { - final String value = preferences.get("" + index, null); - if (value == null) { - break; + + /** @see java.util.prefs.Preferences#clear() */ + public void clear() { + try { + p.clear(); + } + catch (java.util.prefs.BackingStoreException exc) { + log.error(exc); } - list.add(value); } - return list; - } - private void putIterable(final Preferences preferences, - final Iterable iterable) - { - if (preferences == null) { - throw new IllegalArgumentException("Preferences not set."); + /** @see java.util.prefs.Preferences#putInt(String, int) */ + public void putInt(final String key, final int value) { + p.putInt(key, value); } - int index = 0; - for (final String value : iterable) { - preferences.put("" + index++, value == null ? null : value.toString()); + + /** @see java.util.prefs.Preferences#getInt(String, int) */ + public int getInt(final String key, final int def) { + return p.getInt(key, def); } - } - private Iterable getIterable(final Preferences preferences) - { - if (preferences == null) { - throw new IllegalArgumentException("Preferences not set."); + /** @see java.util.prefs.Preferences#putLong(String, long) */ + public void putLong(final String key, final long value) { + p.putLong(key, value); + } + + /** @see java.util.prefs.Preferences#getLong(String, long) */ + public long getLong(final String key, final long def) { + return p.getLong(key, def); + } + + /** @see java.util.prefs.Preferences#putBoolean(String, boolean) */ + public void putBoolean(final String key, final boolean value) { + p.putBoolean(key, value); + } + + /** @see java.util.prefs.Preferences#getFloat(String, float) */ + public boolean getBoolean(final String key, final boolean def) { + return p.getBoolean(key, def); + } + + /** @see java.util.prefs.Preferences#putFloat(String, float) */ + public void putFloat(final String key, final float value) { + p.putFloat(key, value); + } + + /** @see java.util.prefs.Preferences#getFloat(String, float) */ + public float getFloat(final String key, final float def) { + return p.getFloat(key, def); } - return new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - private String value; - private int index; - { - findNext(); - } - - @Override - public String next() { - final String result = value; - findNext(); - return result; - } - - @Override - public boolean hasNext() { - return value != null; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - private void findNext() { - if (index < 0) return; - value = preferences.get("" + index, null); - index = value == null ? -1 : index + 1; - } - }; + + /** @see java.util.prefs.Preferences#putDouble(String, double) */ + public void putDouble(final String key, final double value) { + p.putDouble(key, value); + } + + /** @see java.util.prefs.Preferences#getDouble(String, double) */ + public double getDouble(final String key, final double def) { + return p.getDouble(key, def); + } + + /** @see java.util.prefs.Preferences#keys() */ + public String[] keys() { + try { + return p.keys(); } - }; - } + catch (final java.util.prefs.BackingStoreException exc) { + log.error(exc); + return new String[0]; + } + } - private Preferences prefs(final Class c) { - return Preferences.userNodeForPackage(c == null ? PrefService.class : c); - } + /** @see java.util.prefs.Preferences#node(String) */ + public SmartPrefs node(final String pathName) { + return new SmartPrefs(p.node(pathName), log); + } - private String[] allPrefs() throws BackingStoreException { - return Preferences.userRoot().childrenNames(); - } + /** @see java.util.prefs.Preferences#nodeExists(String) */ + public boolean nodeExists(final String pathName) { + try { + return p.nodeExists(pathName); + } + catch (final java.util.prefs.BackingStoreException exc) { + log.error(exc); + return false; + } + } - private Preferences prefs(final String absolutePath) { - return Preferences.userRoot().node(absolutePath); - } + /** @see java.util.prefs.Preferences#removeNode() */ + public void removeNode() { + try { + p.removeNode(); + } + catch (final java.util.prefs.BackingStoreException exc) { + log.error(exc); + } + } - private String key(final Class c, final String name) { - return c == null ? name : c.getSimpleName() + "." + name; } + } From 39e3b21b15575f2cf0ecf5eea17efdcb1068ee84 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 15 Jan 2016 13:53:24 +0100 Subject: [PATCH 0064/1208] DefaultPrefService: fix bug with keys >80 chars The Java Preferences API does not allow keys greater than 80 characters long (the Preferences.MAX_KEY_LENGTH constant). As a workaround, we limit the key length internally, using the last 77 characters of the string prepending with "..." to suggest this occurred. This means, of course, that two keys with identical latter 77 characters will now stomp each other. But there is little we can do aside from using hashes or some such, which would mangle the keys too much IMHO (configuration files on disk would be incomprehensible, for example). The fix is also incomplete when it comes to persisting maps: if you have a map with such long keys, they will be mangled when restored. But I do not have enough time and energy to address that right now. Tripped over by Kyle Harrington. --- .../org/scijava/prefs/DefaultPrefService.java | 57 ++++++++++++++----- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/scijava/prefs/DefaultPrefService.java b/src/main/java/org/scijava/prefs/DefaultPrefService.java index 623e0cb4b..a5f2c05da 100644 --- a/src/main/java/org/scijava/prefs/DefaultPrefService.java +++ b/src/main/java/org/scijava/prefs/DefaultPrefService.java @@ -507,7 +507,7 @@ private void findNext() { /** @see java.util.prefs.Preferences#put */ public void put(final String key, final Object value) { - p.put(key, value == null ? null : value.toString()); + p.put(safeKey(key), value == null ? null : value.toString()); } /** @see java.util.prefs.Preferences#get(String, String) */ @@ -517,7 +517,7 @@ public String get(final String key) { /** @see java.util.prefs.Preferences#get(String, String) */ public String get(final String key, final String def) { - return p.get(key, def); + return p.get(safeKey(key), def); } /** @see java.util.prefs.Preferences#clear() */ @@ -532,58 +532,62 @@ public void clear() { /** @see java.util.prefs.Preferences#putInt(String, int) */ public void putInt(final String key, final int value) { - p.putInt(key, value); + p.putInt(safeKey(key), value); } /** @see java.util.prefs.Preferences#getInt(String, int) */ public int getInt(final String key, final int def) { - return p.getInt(key, def); + return p.getInt(safeKey(key), def); } /** @see java.util.prefs.Preferences#putLong(String, long) */ public void putLong(final String key, final long value) { - p.putLong(key, value); + p.putLong(safeKey(key), value); } /** @see java.util.prefs.Preferences#getLong(String, long) */ public long getLong(final String key, final long def) { - return p.getLong(key, def); + return p.getLong(safeKey(key), def); } /** @see java.util.prefs.Preferences#putBoolean(String, boolean) */ public void putBoolean(final String key, final boolean value) { - p.putBoolean(key, value); + p.putBoolean(safeKey(key), value); } /** @see java.util.prefs.Preferences#getFloat(String, float) */ public boolean getBoolean(final String key, final boolean def) { - return p.getBoolean(key, def); + return p.getBoolean(safeKey(key), def); } /** @see java.util.prefs.Preferences#putFloat(String, float) */ public void putFloat(final String key, final float value) { - p.putFloat(key, value); + p.putFloat(safeKey(key), value); } /** @see java.util.prefs.Preferences#getFloat(String, float) */ public float getFloat(final String key, final float def) { - return p.getFloat(key, def); + return p.getFloat(safeKey(key), def); } /** @see java.util.prefs.Preferences#putDouble(String, double) */ public void putDouble(final String key, final double value) { - p.putDouble(key, value); + p.putDouble(safeKey(key), value); } /** @see java.util.prefs.Preferences#getDouble(String, double) */ public double getDouble(final String key, final double def) { - return p.getDouble(key, def); + return p.getDouble(safeKey(key), def); } /** @see java.util.prefs.Preferences#keys() */ public String[] keys() { try { - return p.keys(); + final String[] keys = p.keys(); + for (int i = 0; i < keys.length; i++) { + keys[i] = safeKey(keys[i]); + } + return keys; } catch (final java.util.prefs.BackingStoreException exc) { log.error(exc); @@ -617,6 +621,33 @@ public void removeNode() { } } + // -- Helper methods -- + + private String safeKey(final String key) { + return makeSafe(key, java.util.prefs.Preferences.MAX_KEY_LENGTH); + } + + /** + * This method limits the given string to the specified maximum length using + * its latter characters prepended with "..." as needed. + *

+ * This is necessary because the Java Preferences API does not allow: + *

+ *
    + *
  • Keys longer than {@link java.util.prefs.Preferences#MAX_KEY_LENGTH} + *
  • + *
  • Values longer than + * {@link java.util.prefs.Preferences#MAX_VALUE_LENGTH}
  • + *
  • Node names longer than + * {@link java.util.prefs.Preferences#MAX_NAME_LENGTH}
  • + *
+ */ + private String makeSafe(final String s, final int max) { + final int len = s.length(); + if (len < max) return s; + return "..." + s.substring(len - max + 3, len); + } + } } From 7330e082079ce11cd3c13998f3086b4424329231 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 15 Jan 2016 13:36:59 +0100 Subject: [PATCH 0065/1208] PrefServiceTest: add a test for keys >80 chars The Java Preferences API does not support these; let's make sure they (largely) work anyway. --- .../org/scijava/prefs/PrefServiceTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/test/java/org/scijava/prefs/PrefServiceTest.java b/src/test/java/org/scijava/prefs/PrefServiceTest.java index a0b1f5270..c923ea4e9 100644 --- a/src/test/java/org/scijava/prefs/PrefServiceTest.java +++ b/src/test/java/org/scijava/prefs/PrefServiceTest.java @@ -175,4 +175,24 @@ public void testList() { assertEquals(recentFiles, result); } + /** + * The Java Preferences API does not support keys longer than 80 characters. + * Let's test that our service does not fall victim to this limitation. + */ + @Test + public void testLongKeys() { + final String longKey = "" + // + "abcdefghijklmnopqrstuvwxyz" + // + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // + "0123456789" + // + "9876543210" + // + "ZYXWVUTSRQPONMLKJIHGFEDCBA" + // + "zyxwvutsrqponmlkjihgfedcba"; + final String lyrics = + "Now I know my ABC's. Next time won't you sing with me?"; + prefService.put(longKey, lyrics); + final String recovered = prefService.get(longKey); + assertEquals(lyrics, recovered); + } + } From de4226db3e9a45e86ceab3d14ee57a1f9c2d4d95 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 15 Jan 2016 14:01:31 +0100 Subject: [PATCH 0066/1208] DefaultPrefService: protect vs other long strings This is analogous to the protection against overlong keys; the Preferences API also has limits on values and node names. --- .../org/scijava/prefs/DefaultPrefService.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/prefs/DefaultPrefService.java b/src/main/java/org/scijava/prefs/DefaultPrefService.java index a5f2c05da..94acd501c 100644 --- a/src/main/java/org/scijava/prefs/DefaultPrefService.java +++ b/src/main/java/org/scijava/prefs/DefaultPrefService.java @@ -507,7 +507,7 @@ private void findNext() { /** @see java.util.prefs.Preferences#put */ public void put(final String key, final Object value) { - p.put(safeKey(key), value == null ? null : value.toString()); + p.put(safeKey(key), safeValue(value)); } /** @see java.util.prefs.Preferences#get(String, String) */ @@ -597,13 +597,13 @@ public String[] keys() { /** @see java.util.prefs.Preferences#node(String) */ public SmartPrefs node(final String pathName) { - return new SmartPrefs(p.node(pathName), log); + return new SmartPrefs(p.node(safeName(pathName)), log); } /** @see java.util.prefs.Preferences#nodeExists(String) */ public boolean nodeExists(final String pathName) { try { - return p.nodeExists(pathName); + return p.nodeExists(safeName(pathName)); } catch (final java.util.prefs.BackingStoreException exc) { log.error(exc); @@ -627,6 +627,16 @@ private String safeKey(final String key) { return makeSafe(key, java.util.prefs.Preferences.MAX_KEY_LENGTH); } + private String safeValue(final Object value) { + if (value == null) return null; + return makeSafe(value.toString(), + java.util.prefs.Preferences.MAX_VALUE_LENGTH); + } + + private String safeName(final String name) { + return makeSafe(name, java.util.prefs.Preferences.MAX_NAME_LENGTH); + } + /** * This method limits the given string to the specified maximum length using * its latter characters prepended with "..." as needed. From 584b53898754cdcf7cf262e2a4e7cf5d38e50e15 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 15 Jan 2016 14:13:35 +0100 Subject: [PATCH 0067/1208] DefaultPrefService: guard against null LogService --- .../java/org/scijava/prefs/DefaultPrefService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/prefs/DefaultPrefService.java b/src/main/java/org/scijava/prefs/DefaultPrefService.java index 94acd501c..7b90821ea 100644 --- a/src/main/java/org/scijava/prefs/DefaultPrefService.java +++ b/src/main/java/org/scijava/prefs/DefaultPrefService.java @@ -386,7 +386,7 @@ private String[] allPrefs() { return java.util.prefs.Preferences.userRoot().childrenNames(); } catch (java.util.prefs.BackingStoreException exc) { - log.error(exc); + if (log != null) log.error(exc); return new String[0]; } } @@ -526,7 +526,7 @@ public void clear() { p.clear(); } catch (java.util.prefs.BackingStoreException exc) { - log.error(exc); + if (log != null) log.error(exc); } } @@ -590,7 +590,7 @@ public String[] keys() { return keys; } catch (final java.util.prefs.BackingStoreException exc) { - log.error(exc); + if (log != null) log.error(exc); return new String[0]; } } @@ -606,7 +606,7 @@ public boolean nodeExists(final String pathName) { return p.nodeExists(safeName(pathName)); } catch (final java.util.prefs.BackingStoreException exc) { - log.error(exc); + if (log != null) log.error(exc); return false; } } @@ -617,7 +617,7 @@ public void removeNode() { p.removeNode(); } catch (final java.util.prefs.BackingStoreException exc) { - log.error(exc); + if (log != null) log.error(exc); } } From 6db9fe07f4432754e4a458c7748eb37b273310b7 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Sat, 16 Jan 2016 08:42:57 -0600 Subject: [PATCH 0068/1208] Create CastingConverter Extract trivial casting logic from DefaultConverter to a new dedicated (high priority) CastingConverter. Fixes issues when trying to convert to, say, Object. --- .../org/scijava/convert/CastingConverter.java | 90 +++++++++++++++++++ .../org/scijava/convert/DefaultConverter.java | 11 --- 2 files changed, 90 insertions(+), 11 deletions(-) create mode 100644 src/main/java/org/scijava/convert/CastingConverter.java diff --git a/src/main/java/org/scijava/convert/CastingConverter.java b/src/main/java/org/scijava/convert/CastingConverter.java new file mode 100644 index 000000000..d849d5cd4 --- /dev/null +++ b/src/main/java/org/scijava/convert/CastingConverter.java @@ -0,0 +1,90 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package org.scijava.convert; + +import org.scijava.Priority; +import org.scijava.plugin.Plugin; +import org.scijava.util.ClassUtils; +import org.scijava.util.ConversionUtils; +import org.scijava.util.GenericUtils; + +/** + * Minimal {@link Converter} implementation to do direct casting. + * + * @author Mark Hiner hinerm at gmail.com + */ +@Plugin(type = Converter.class, priority = Priority.FIRST_PRIORITY - 1) +public class CastingConverter extends AbstractConverter { + + @SuppressWarnings("deprecation") + @Override + public boolean canConvert(final Object src, final Class dest) { + return ClassUtils.canCast(src, dest); + } + + @Override + public boolean canConvert(final Class src, final Class dest) { + // OK if the existing object can be casted + if (ConversionUtils.canCast(src, dest)) + return true; + + return false; + } + + @SuppressWarnings("unchecked") + @Override + public T convert(final Object src, final Class dest) { + // NB: Regardless of whether the destination type is an array or + // collection, + // we still want to cast directly if doing so is possible. But note that + // in + // general, this check does not detect cases of incompatible generic + // parameter types. If this limitation becomes a problem in the future + // we + // can extend the logic here to provide additional signatures of canCast + // which operate on Types in general rather than only Classes. However, + // the + // logic could become complex very quickly in various subclassing cases, + // generic parameters resolved vs. propagated, etc. + final Class c = GenericUtils.getClass(dest); + return (T) ConversionUtils.cast(src, c); + } + + @Override + public Class getOutputType() { + return Object.class; + } + + @Override + public Class getInputType() { + return Object.class; + } +} diff --git a/src/main/java/org/scijava/convert/DefaultConverter.java b/src/main/java/org/scijava/convert/DefaultConverter.java index 561dd3c5f..4aa872960 100644 --- a/src/main/java/org/scijava/convert/DefaultConverter.java +++ b/src/main/java/org/scijava/convert/DefaultConverter.java @@ -61,17 +61,6 @@ public class DefaultConverter extends AbstractConverter { @Override public Object convert(final Object src, final Type dest) { - // NB: Regardless of whether the destination type is an array or collection, - // we still want to cast directly if doing so is possible. But note that in - // general, this check does not detect cases of incompatible generic - // parameter types. If this limitation becomes a problem in the future we - // can extend the logic here to provide additional signatures of canCast - // which operate on Types in general rather than only Classes. However, the - // logic could become complex very quickly in various subclassing cases, - // generic parameters resolved vs. propagated, etc. - final Class c = GenericUtils.getClass(dest); - if (c != null && ConversionUtils.canCast(src, c)) return ConversionUtils - .cast(src, c); // Handle array types, including generic array types. if (isArray(dest)) { From ee8dd3adaec10ee7e0ce7ca66ddf1d64e49ccbf1 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Sun, 17 Jan 2016 18:00:56 +0100 Subject: [PATCH 0069/1208] Context: allow multi-injection in non-strict mode With scijava.context.strict set to false (i.e.: strict=false flag of the Context), injecting an object multiple times is now allowed. This avoids the dreaded "Context already injected" exception which is thrown, for example, when reusing an op with a second module. This commit is dedicated to Christian Dietz! --- src/main/java/org/scijava/Context.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/Context.java b/src/main/java/org/scijava/Context.java index c3e02d9dc..a60ff4dd0 100644 --- a/src/main/java/org/scijava/Context.java +++ b/src/main/java/org/scijava/Context.java @@ -436,7 +436,7 @@ private void inject(final Field f, final Object o) { final Class type = f.getType(); if (Service.class.isAssignableFrom(type)) { final Service existingService = (Service) ClassUtils.getValue(f, o); - if (existingService != null) { + if (strict && existingService != null) { throw new IllegalStateException("Context already injected: " + f.getDeclaringClass().getName() + "#" + f.getName()); } @@ -450,14 +450,24 @@ private void inject(final Field f, final Object o) { throw new IllegalArgumentException( createMissingServiceMessage(serviceType)); } + if (existingService != null && existingService != service) { + // NB: Can only happen in non-strict mode. + throw new IllegalStateException("Mismatched context: " + + f.getDeclaringClass().getName() + "#" + f.getName()); + } ClassUtils.setValue(f, o, service); } else if (Context.class.isAssignableFrom(type) && type.isInstance(this)) { final Context existingContext = (Context) ClassUtils.getValue(f, o); - if (existingContext != null) { + if (strict && existingContext != null) { throw new IllegalStateException("Context already injected: " + f.getDeclaringClass().getName() + "#" + f.getName()); } + if (existingContext != null && existingContext != this) { + // NB: Can only happen in non-strict mode. + throw new IllegalStateException("Mismatched context: " + + f.getDeclaringClass().getName() + "#" + f.getName()); + } // populate Context parameter ClassUtils.setValue(f, o, this); From 88d3cab189d1fd68b2065e0e109cbb18ef48e0b0 Mon Sep 17 00:00:00 2001 From: Gabriel Einsdorf Date: Mon, 18 Jan 2016 13:04:13 -0600 Subject: [PATCH 0070/1208] Use List instead of Iterable as returntype of the ModuleInfo methods returning list of ModuleItems. ``inputs()`` and ``outputs()`` used to return Iterable> this made random access on a Module's in and outputs painful. This restriction is not needed as the implementations of ModuleInfo already return a List. --- src/main/java/org/scijava/command/CommandInfo.java | 4 ++-- src/main/java/org/scijava/module/AbstractModuleInfo.java | 4 ++-- src/main/java/org/scijava/module/ModuleInfo.java | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/scijava/command/CommandInfo.java b/src/main/java/org/scijava/command/CommandInfo.java index 3cc61e6ec..cb391eb47 100644 --- a/src/main/java/org/scijava/command/CommandInfo.java +++ b/src/main/java/org/scijava/command/CommandInfo.java @@ -279,13 +279,13 @@ public CommandModuleItem getOutput(final String name, } @Override - public Iterable> inputs() { + public List> inputs() { parseParams(); return Collections.unmodifiableList(inputList); } @Override - public Iterable> outputs() { + public List> outputs() { parseParams(); return Collections.unmodifiableList(outputList); } diff --git a/src/main/java/org/scijava/module/AbstractModuleInfo.java b/src/main/java/org/scijava/module/AbstractModuleInfo.java index 551664197..cd85e75cc 100644 --- a/src/main/java/org/scijava/module/AbstractModuleInfo.java +++ b/src/main/java/org/scijava/module/AbstractModuleInfo.java @@ -99,12 +99,12 @@ public ModuleItem getOutput(final String name, final Class type) { } @Override - public Iterable> inputs() { + public List> inputs() { return Collections.unmodifiableList(inputList()); } @Override - public Iterable> outputs() { + public List> outputs() { return Collections.unmodifiableList(outputList()); } diff --git a/src/main/java/org/scijava/module/ModuleInfo.java b/src/main/java/org/scijava/module/ModuleInfo.java index f55541d82..6e644fa27 100644 --- a/src/main/java/org/scijava/module/ModuleInfo.java +++ b/src/main/java/org/scijava/module/ModuleInfo.java @@ -31,6 +31,8 @@ package org.scijava.module; +import java.util.List; + import org.scijava.UIDetails; import org.scijava.Validated; import org.scijava.event.EventService; @@ -74,10 +76,10 @@ public interface ModuleInfo extends UIDetails, Validated { ModuleItem getOutput(String name, Class type); /** Gets the list of input items. */ - Iterable> inputs(); + List> inputs(); /** Gets the list of output items. */ - Iterable> outputs(); + List> outputs(); /** * Gets the fully qualified name of the class containing the module's actual From 4bef9fe97570f71d31e821ced38bb6da83faf0f3 Mon Sep 17 00:00:00 2001 From: Gabriel Einsdorf Date: Tue, 19 Jan 2016 16:15:52 -0600 Subject: [PATCH 0071/1208] Bytecode analyser cleanup - Add documentation link for constant pool - order tags for readability --- src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java b/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java index 8c42da122..95d03a5cd 100644 --- a/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java +++ b/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java @@ -107,6 +107,8 @@ private double getDoubleConstant(final int index) { getU4(offset + 5)); } + // See https://en.wikipedia.org/wiki/Java_class_file#The_constant_pool for the + // meaning of the offsets behind these numbers private void getConstantPoolOffsets() { final int poolCount = getU2(8) - 1; poolOffsets = new int[poolCount]; @@ -115,8 +117,8 @@ private void getConstantPoolOffsets() { poolOffsets[i] = offset; final int tag = getU1(offset); if (tag == 7 || tag == 8) offset += 3; - else if (tag == 9 || tag == 10 || tag == 11 || tag == 3 || tag == 4 || - tag == 12) offset += 5; + else if (tag == 3 || tag == 4 || tag == 9 || tag == 10 + || tag == 11 || tag == 12) offset += 5; else if (tag == 5 || tag == 6) { poolOffsets[++i] = offset; offset += 9; From 4a4b18551f3f3346ede0af6cfe72329462961ffc Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 20 Jan 2016 13:20:54 +0100 Subject: [PATCH 0072/1208] Gateway: add a getShortName for use with scripting When the gateway is a variable somewhere, it is convenient for its name to be as short as possible. E.g.: * "SciJava" can be "sj" * "ImageJ" can be "ij" It is handy for each gateway to self-suggest such a name. --- src/main/java/org/scijava/AbstractGateway.java | 5 +++++ src/main/java/org/scijava/Gateway.java | 6 ++++++ src/main/java/org/scijava/SciJava.java | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/src/main/java/org/scijava/AbstractGateway.java b/src/main/java/org/scijava/AbstractGateway.java index a915e3953..8027649ce 100644 --- a/src/main/java/org/scijava/AbstractGateway.java +++ b/src/main/java/org/scijava/AbstractGateway.java @@ -87,6 +87,11 @@ public AbstractGateway(final String appName, final Context context) { // -- Gateway methods -- + @Override + public String getShortName() { + return getClass().getName().toLowerCase(); + } + @Override public S get(final Class serviceClass) { return context().service(serviceClass); diff --git a/src/main/java/org/scijava/Gateway.java b/src/main/java/org/scijava/Gateway.java index 9a191ec2c..7df6a81cc 100644 --- a/src/main/java/org/scijava/Gateway.java +++ b/src/main/java/org/scijava/Gateway.java @@ -118,6 +118,12 @@ */ public interface Gateway extends RichPlugin, Versioned { + /** + * Gets a very succinct name for use referring to this gateway, e.g. as a + * variable name for scripting. + */ + String getShortName(); + /** * Returns an implementation of the requested {@link Service}, if it exists in * the underlying {@link Context}. diff --git a/src/main/java/org/scijava/SciJava.java b/src/main/java/org/scijava/SciJava.java index ee7a94eaf..e342ef380 100644 --- a/src/main/java/org/scijava/SciJava.java +++ b/src/main/java/org/scijava/SciJava.java @@ -112,4 +112,11 @@ public SciJava(final Context context) { super(SciJavaApp.NAME, context); } + // -- Gateway methods -- + + @Override + public String getShortName() { + return "sj"; + } + } From d87844f9483266ae6d4102741aeca3837129d1d5 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 26 Jan 2016 11:18:19 -0600 Subject: [PATCH 0073/1208] ClassUtils: add @return to loadClass javadoc --- src/main/java/org/scijava/util/ClassUtils.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/scijava/util/ClassUtils.java b/src/main/java/org/scijava/util/ClassUtils.java index 2a8d1a564..118aef1a7 100644 --- a/src/main/java/org/scijava/util/ClassUtils.java +++ b/src/main/java/org/scijava/util/ClassUtils.java @@ -93,6 +93,7 @@ private ClassUtils() { * Loads the class with the given name, using the current thread's context * class loader, or null if it cannot be loaded. * + * @return The loaded class, or null if the class could not be loaded. * @see #loadClass(String, ClassLoader) */ public static Class loadClass(final String className) { @@ -118,6 +119,7 @@ public static Class loadClass(final String className) { * @param name The name of the class to load. * @param classLoader The class loader with which to load the class; if null, * the current thread's context class loader will be used. + * @return The loaded class, or null if the class could not be loaded. */ public static Class loadClass(final String name, final ClassLoader classLoader) From 77a91280cf07d05a74321f3b98771cbc43ae6dd0 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 27 Jan 2016 12:34:45 -0600 Subject: [PATCH 0074/1208] POM: update to pom-scijava 9.3.0 This allows us to remove the Eclipse lifecycle configuration for the exec-maven-plugin, since it is declared in pom-scijava now. --- pom.xml | 47 +---------------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/pom.xml b/pom.xml index c7b74d33e..7d04f78fb 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.scijava pom-scijava - 9.1.0 + 9.3.0 @@ -182,49 +182,4 @@ Institute of Molecular Cell Biology and Genetics. - - - - only-eclipse - - - m2e.version - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - java - - - - - - - - - - - - - - - From 97306515676492706b24835d5e2927ec2c60e480 Mon Sep 17 00:00:00 2001 From: Gabriel Einsdorf Date: Tue, 19 Jan 2016 16:29:48 -0600 Subject: [PATCH 0075/1208] Add support for java bytecode tags added in java 7 - 15 Method handle - 16 Method type - 18 InvokeDynamic --- src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java b/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java index 95d03a5cd..a9276917a 100644 --- a/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java +++ b/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java @@ -116,9 +116,10 @@ private void getConstantPoolOffsets() { for (int i = 0; i < poolCount; i++) { poolOffsets[i] = offset; final int tag = getU1(offset); - if (tag == 7 || tag == 8) offset += 3; + if (tag == 7 || tag == 8 || tag == 16) offset += 3; + else if (tag == 15) offset += 4; else if (tag == 3 || tag == 4 || tag == 9 || tag == 10 - || tag == 11 || tag == 12) offset += 5; + || tag == 11 || tag == 12 || tag == 18) offset += 5; else if (tag == 5 || tag == 6) { poolOffsets[++i] = offset; offset += 9; From 3d6a2bf7c68f53a5886fc07cf9bf950e96c1a099 Mon Sep 17 00:00:00 2001 From: Gabriel Einsdorf Date: Tue, 19 Jan 2016 16:59:38 -0600 Subject: [PATCH 0076/1208] Update tests for changes in ByteCodeAnalyzer The tests now require java 8. --- pom.xml | 6 +++++- .../java/org/scijava/annotations/AnnotatedD.java | 13 +++++++++++++ .../scijava/annotations/DirectoryIndexerTest.java | 2 +- .../org/scijava/annotations/EclipseHelperTest.java | 4 ++-- 4 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/test/java/org/scijava/annotations/AnnotatedD.java diff --git a/pom.xml b/pom.xml index c7b74d33e..2dade57d0 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.scijava pom-scijava - 9.1.0 + 9.3.0 @@ -114,6 +114,10 @@ http://jenkins.imagej.net/job/SciJava-common/ + + 1.8 + + diff --git a/src/test/java/org/scijava/annotations/AnnotatedD.java b/src/test/java/org/scijava/annotations/AnnotatedD.java new file mode 100644 index 000000000..936bca914 --- /dev/null +++ b/src/test/java/org/scijava/annotations/AnnotatedD.java @@ -0,0 +1,13 @@ +package org.scijava.annotations; + +import java.util.ArrayList; +import java.util.List; + +@Simple(string1 = "adfd") +public class AnnotatedD { + + public AnnotatedD() { + List list = new ArrayList<>(); + list.stream().reduce(String::concat).get(); + } +} diff --git a/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java b/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java index 1f8452062..9d09d1a55 100644 --- a/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java +++ b/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java @@ -122,7 +122,7 @@ public void testRepeatedClassPathElements() throws Exception { assertFalse(seen.contains(name)); seen.add(name); } - assertEquals(2, seen.size()); + assertEquals(3, seen.size()); } public static void diff --git a/src/test/java/org/scijava/annotations/EclipseHelperTest.java b/src/test/java/org/scijava/annotations/EclipseHelperTest.java index 2e8bd1f86..fc51b10f9 100644 --- a/src/test/java/org/scijava/annotations/EclipseHelperTest.java +++ b/src/test/java/org/scijava/annotations/EclipseHelperTest.java @@ -71,7 +71,7 @@ public void testSkipIndexGeneration() throws Exception { public void testIndexing() throws Exception { final File dir = createTemporaryDirectory("eclipse-test-"); copyClasses(dir, Complex.class, Simple.class, Fruit.class, - AnnotatedA.class, AnnotatedB.class, AnnotatedC.class); + AnnotatedA.class, AnnotatedB.class, AnnotatedC.class, AnnotatedD.class); final File jsonDir = new File(dir, Index.INDEX_PREFIX); for (final Class clazz : new Class[] { Complex.class, Simple.class }) { @@ -104,7 +104,7 @@ public Class loadClass(final String className) // deleted jsonDir.setLastModified(123456789); for (final Class clazz : new Class[] { AnnotatedA.class, - AnnotatedB.class, AnnotatedC.class }) + AnnotatedB.class, AnnotatedC.class, AnnotatedD.class }) { assertTrue(new File(dir, DirectoryIndexerTest.getResourcePath(clazz)) .delete()); From b13f977f69e4ac54247b2293bd1d56703084298a Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 3 Feb 2016 09:47:52 -0600 Subject: [PATCH 0077/1208] ConsoleServiceTest: reduce FooArgument aggression It claimed to support everything, which hosed any other unit tests leaning on the ConsoleService. --- src/test/java/org/scijava/console/ConsoleServiceTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/java/org/scijava/console/ConsoleServiceTest.java b/src/test/java/org/scijava/console/ConsoleServiceTest.java index 601a6ea1a..3716c0ca2 100644 --- a/src/test/java/org/scijava/console/ConsoleServiceTest.java +++ b/src/test/java/org/scijava/console/ConsoleServiceTest.java @@ -220,6 +220,10 @@ public void handle(final LinkedList args) { argsHandled = true; } + @Override + public boolean supports(final LinkedList args) { + return !args.isEmpty() && args.getFirst().equals("--foo"); + } } private static class OutputTracker implements OutputListener { From 1e491a08c287800dc72fc1dd185cfd1d70bfd38f Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 2 Feb 2016 22:54:51 -0600 Subject: [PATCH 0078/1208] Add a service for executing main methods --- pom.xml | 2 +- .../org/scijava/main/DefaultMainService.java | 122 ++++++++++++++++++ .../java/org/scijava/main/MainService.java | 69 ++++++++++ 3 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/scijava/main/DefaultMainService.java create mode 100644 src/main/java/org/scijava/main/MainService.java diff --git a/pom.xml b/pom.xml index 8df053aee..fedd6a8ed 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.50.2-SNAPSHOT + 2.51.0-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. diff --git a/src/main/java/org/scijava/main/DefaultMainService.java b/src/main/java/org/scijava/main/DefaultMainService.java new file mode 100644 index 000000000..9b56e45b2 --- /dev/null +++ b/src/main/java/org/scijava/main/DefaultMainService.java @@ -0,0 +1,122 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.main; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +import org.scijava.log.LogService; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; +import org.scijava.service.AbstractService; +import org.scijava.service.Service; +import org.scijava.util.ClassUtils; + +/** + * Default implementation of {@link MainService}. + * + * @author Curtis Rueden + */ +@Plugin(type = Service.class) +public class DefaultMainService extends AbstractService implements MainService { + + @Parameter(required = false) + private LogService log; + + private final List
mains = new ArrayList
(); + + @Override + public int execMains() { + int mainCount = 0; + for (final Main main : mains) { + main.exec(); + mainCount++; + } + return mainCount; + } + + @Override + public void addMain(final String className, final String... args) { + mains.add(new DefaultMain(className, args)); + } + + @Override + public Main[] getMains() { + return mains.toArray(new Main[mains.size()]); + } + + // -- Helper classes -- + + /** Default implementation of {@link MainService.Main}. */ + private class DefaultMain implements Main { + private String className; + private String[] args; + + public DefaultMain(final String className, final String... args) { + this.className = className; + this.args = args.clone(); + } + + @Override + public String className() { + return className; + } + + @Override + public String[] args() { + return args; + } + + @Override + public void exec() { + try { + final Class mainClass = ClassUtils.loadClass(className); + final Method main = mainClass.getMethod("main", String[].class); + main.invoke(null, new Object[] { args }); + } + catch (final NoSuchMethodException exc) { + if (log != null) { + log.error("No main method for class: " + className, exc); + } + } + catch (final IllegalAccessException exc) { + if (log != null) log.error(exc); + } + catch (final InvocationTargetException exc) { + if (log != null) log.error(exc); + } + } + } + +} diff --git a/src/main/java/org/scijava/main/MainService.java b/src/main/java/org/scijava/main/MainService.java new file mode 100644 index 000000000..ee99373c3 --- /dev/null +++ b/src/main/java/org/scijava/main/MainService.java @@ -0,0 +1,69 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.main; + +import org.scijava.service.SciJavaService; + +/** + * Interface for services which manage dynamic execution of main methods. + * + * @author Curtis Rueden + */ +public interface MainService extends SciJavaService { + + /** + * Executes registered main classes, in the order they were registered. + * + * @return The number of main methods which were executed. + */ + int execMains(); + + /** Registers a main class to be executed by {@link #execMains()}. */ + void addMain(final String className, final String... args); + + /** Gets the registered main classes to execute. */ + Main[] getMains(); + + /** Data structure containing main class and argument values. */ + interface Main { + + /** Gets the name of the class containing the {@code main} method to run. */ + String className(); + + /** Gets the arguments to pass to the class's {@code main} method. */ + String[] args(); + + /** Runs the {@code main} method with the associated arguments. */ + void exec(); + } + +} From 09e8a7d9883425a6a481d08459ba1cefe4355033 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 3 Feb 2016 07:57:53 -0600 Subject: [PATCH 0079/1208] Gateway: add MainService accessor --- src/main/java/org/scijava/AbstractGateway.java | 6 ++++++ src/main/java/org/scijava/Gateway.java | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/org/scijava/AbstractGateway.java b/src/main/java/org/scijava/AbstractGateway.java index 8027649ce..6e558530f 100644 --- a/src/main/java/org/scijava/AbstractGateway.java +++ b/src/main/java/org/scijava/AbstractGateway.java @@ -45,6 +45,7 @@ import org.scijava.io.IOService; import org.scijava.io.RecentFileService; import org.scijava.log.LogService; +import org.scijava.main.MainService; import org.scijava.menu.MenuService; import org.scijava.module.ModuleService; import org.scijava.object.ObjectService; @@ -163,6 +164,11 @@ public LogService log() { return get(LogService.class); } + @Override + public MainService main() { + return get(MainService.class); + } + @Override public MenuService menu() { return get(MenuService.class); diff --git a/src/main/java/org/scijava/Gateway.java b/src/main/java/org/scijava/Gateway.java index 7df6a81cc..9a71bf025 100644 --- a/src/main/java/org/scijava/Gateway.java +++ b/src/main/java/org/scijava/Gateway.java @@ -43,6 +43,7 @@ import org.scijava.io.IOService; import org.scijava.io.RecentFileService; import org.scijava.log.LogService; +import org.scijava.main.MainService; import org.scijava.menu.MenuService; import org.scijava.module.ModuleService; import org.scijava.object.ObjectService; @@ -226,6 +227,13 @@ public interface Gateway extends RichPlugin, Versioned { */ LogService log(); + /** + * Gets this application context's {@link MainService}. + * + * @return The {@link MainService} of this application context. + */ + MainService main(); + /** * Gets this application context's {@link MenuService}. * From b372a8c2ce1949bca68914065f9c4d10a73d4237 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 2 Feb 2016 22:55:10 -0600 Subject: [PATCH 0080/1208] Add support for the --main argument Using --main-class also works, for partial backwards compatibility. This feature leans on the new MainService to do most of the work. --- .../scijava/main/console/MainArgument.java | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/main/java/org/scijava/main/console/MainArgument.java diff --git a/src/main/java/org/scijava/main/console/MainArgument.java b/src/main/java/org/scijava/main/console/MainArgument.java new file mode 100644 index 000000000..2ed60c713 --- /dev/null +++ b/src/main/java/org/scijava/main/console/MainArgument.java @@ -0,0 +1,99 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.main.console; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +import org.scijava.console.AbstractConsoleArgument; +import org.scijava.console.ConsoleArgument; +import org.scijava.log.LogService; +import org.scijava.main.MainService; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; + +/** + * Handles the {@code --main} command line argument, which launches an + * alternative main class. + * + * @author Curtis Rueden + */ +@Plugin(type = ConsoleArgument.class) +public class MainArgument extends AbstractConsoleArgument { + + @Parameter(required = false) + private MainService mainService; + + @Parameter(required = false) + private LogService log; + + // -- ConsoleArgument methods -- + + @Override + public void handle(final LinkedList args) { + if (!supports(args)) return; + + args.removeFirst(); // --main / --main-class + final String className = args.removeFirst(); + + final List argList = new ArrayList(); + while (!args.isEmpty() && !isMainFlag(args) && !isSeparator(args)) { + argList.add(args.removeFirst()); + } + if (isSeparator(args)) args.removeFirst(); // remove the -- separator + final String[] mainArgs = argList.toArray(new String[argList.size()]); + + mainService.addMain(className, mainArgs); + } + + // -- Typed methods -- + + @Override + public boolean supports(final LinkedList args) { + return mainService != null && isMainFlag(args); + } + + // -- Helper methods -- + + private boolean isMainFlag(final LinkedList args) { + if (args == null || args.isEmpty()) return false; + final String arg = args.getFirst(); + return arg.equals("--main") || arg.equals("--main-class"); + } + + private boolean isSeparator(final LinkedList args) { + if (args == null || args.isEmpty()) return false; + return args.getFirst().equals("--"); + } + +} From c2c87f36bd7fa4e1006588257e28da7db72febc0 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 3 Feb 2016 09:40:18 -0600 Subject: [PATCH 0081/1208] Add tests for the MainService --- .../org/scijava/main/MainServiceTest.java | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 src/test/java/org/scijava/main/MainServiceTest.java diff --git a/src/test/java/org/scijava/main/MainServiceTest.java b/src/test/java/org/scijava/main/MainServiceTest.java new file mode 100644 index 000000000..f62871f03 --- /dev/null +++ b/src/test/java/org/scijava/main/MainServiceTest.java @@ -0,0 +1,143 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.main; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.scijava.Context; +import org.scijava.console.ConsoleService; +import org.scijava.main.console.MainArgument; + +/** + * Tests {@link MainService}. + * + * @author Curtis Rueden + */ +public class MainServiceTest { + + private MainService mainService; + + @Before + public void setUp() { + MathMain.resultCount = 0; + final Context context = new Context(); + mainService = context.service(MainService.class); + } + + @After + public void tearDown() { + mainService.context().dispose(); + } + + /** + * Tests {@link MainService#execMains()}, + * {@link MainService#addMain(String, String...)} and + * {@link MainService#getMains()}. + */ + @Test + public void testMainService() { + final int mainCount0 = mainService.execMains(); + assertEquals(0, mainCount0); + + mainService.addMain(MathMain.class.getName(), "12.3", "/", "4.56"); + + final int mainCount1 = mainService.execMains(); + assertEquals(1, mainCount1); + assertEquals(System.getProperty(key(0)), "2.697368421052632"); + } + + /** Tests usage of {@link MainService} via {@code --main} CLI arguments. */ + @Test + public void testConsoleArgs() { + assertEquals(0, mainService.getMains().length); + + final ConsoleService consoleService = mainService.context().service( + ConsoleService.class); + consoleService.processArgs("-Dfoo=bar", // + "--main", "org.scijava.main.MainServiceTest$MathMain", "5", "+", "6", // + "--", "-Dwhiz=bang", // + "--main", "org.scijava.main.MainServiceTest$MathMain", "7", "-", "4"); + + final MainService.Main[] m = mainService.getMains(); + assertEquals(2, m.length); + assertEquals("org.scijava.main.MainServiceTest$MathMain", m[0].className()); + assertArrayEquals(new String[] {"5", "+", "6"}, m[0].args()); + assertEquals("org.scijava.main.MainServiceTest$MathMain", m[1].className()); + assertArrayEquals(new String[] {"7", "-", "4"}, m[1].args()); + + final int mainCount = mainService.execMains(); + assertEquals(2, mainCount); + assertEquals(System.getProperty(key(0)), "11.0"); + assertEquals(System.getProperty(key(1)), "3.0"); + + assertEquals(System.getProperty("foo"), "bar"); + assertEquals(System.getProperty("whiz"), "bang"); + } + + // -- Helper methods -- + + private static String key(final int index) { + return MathMain.class.getName() + ":" + index; + } + + // -- Helper classes -- + + private static class MathMain { + private static int resultCount = 0; + @SuppressWarnings("unused") + public static void main(final String[] args) { + if (args.length != 3) { + throw new IllegalArgumentException("Invalid args: " + args); + } + + // compute a result from the arguments + final double operand1 = Double.parseDouble(args[0]); + final String operator = args[1]; + final double operand2 = Double.parseDouble(args[2]); + final double result; + if (operator.equals("+")) result = operand1 + operand2; + else if (operator.equals("-")) result = operand1 - operand2; + else if (operator.equals("*")) result = operand1 * operand2; + else if (operator.equals("/")) result = operand1 / operand2; + else throw new IllegalArgumentException("Unknown operator: " + operator); + + // save the result to a system property, for later checking + final String key = MathMain.class.getName() + ":" + resultCount++; + final String value = "" + result; + System.setProperty(key, value); + } + } +} From bd26730180425933b79d2d8881c0ee85dab53ed0 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 3 Feb 2016 10:11:08 -0600 Subject: [PATCH 0082/1208] ContextCreationTest: add MainService to the mix --- src/test/java/org/scijava/ContextCreationTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/org/scijava/ContextCreationTest.java b/src/test/java/org/scijava/ContextCreationTest.java index d9ebd1979..ef41a7398 100644 --- a/src/test/java/org/scijava/ContextCreationTest.java +++ b/src/test/java/org/scijava/ContextCreationTest.java @@ -97,6 +97,7 @@ public void testFull() { org.scijava.io.DefaultDataHandleService.class, org.scijava.io.DefaultIOService.class, org.scijava.io.DefaultRecentFileService.class, + org.scijava.main.DefaultMainService.class, org.scijava.menu.DefaultMenuService.class, org.scijava.module.DefaultModuleService.class, org.scijava.object.DefaultObjectService.class, From eb765278601a66b36410858054a14d942ef4d8d4 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 3 Feb 2016 10:18:34 -0600 Subject: [PATCH 0083/1208] MainServiceTest: use unique system properties The "foo" system property clashed with the SystemPropertyArgumentTest. --- src/test/java/org/scijava/main/MainServiceTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/scijava/main/MainServiceTest.java b/src/test/java/org/scijava/main/MainServiceTest.java index f62871f03..0b46943c0 100644 --- a/src/test/java/org/scijava/main/MainServiceTest.java +++ b/src/test/java/org/scijava/main/MainServiceTest.java @@ -86,9 +86,9 @@ public void testConsoleArgs() { final ConsoleService consoleService = mainService.context().service( ConsoleService.class); - consoleService.processArgs("-Dfoo=bar", // + consoleService.processArgs("-Dmain.test.foo=bar", // "--main", "org.scijava.main.MainServiceTest$MathMain", "5", "+", "6", // - "--", "-Dwhiz=bang", // + "--", "-Dmain.test.whiz=bang", // "--main", "org.scijava.main.MainServiceTest$MathMain", "7", "-", "4"); final MainService.Main[] m = mainService.getMains(); @@ -103,8 +103,8 @@ public void testConsoleArgs() { assertEquals(System.getProperty(key(0)), "11.0"); assertEquals(System.getProperty(key(1)), "3.0"); - assertEquals(System.getProperty("foo"), "bar"); - assertEquals(System.getProperty("whiz"), "bang"); + assertEquals(System.getProperty("main.test.foo"), "bar"); + assertEquals(System.getProperty("main.test.whiz"), "bang"); } // -- Helper methods -- From 69317b28d4a88faae88c5e24895949cf7d47470e Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 28 Jan 2016 16:00:56 -0600 Subject: [PATCH 0084/1208] DefaultScriptService: fix null context bug For languages created simply by wrapping an existing ScriptEngineFactory from the ScriptEngineManager, no context was ever being injected into the wrapped ScriptLanguage. The ScriptLanguage plugin type extends RichPlugin, which means every plugin instance is supposed to have a non-null context. Hence, this behavior should be considered a bug. Since the ScriptLanguageIndex is context-free, it does not know the context to inject it. So to fix this problem in the least invasive way, we simply have the ScriptService walk the whole list of available ScriptLanguages after initially populating them, injecting the context into any language for which it is still null. --- src/main/java/org/scijava/script/DefaultScriptService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index 646feb111..e1b548e1c 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -351,6 +351,12 @@ private synchronized void initScriptLanguageIndex() { index.add(factory, true); } + // Inject the context into languages which need it: the + // wrapped engine factories from the ScriptEngineManager. + for (final ScriptLanguage language : index) { + if (language.getContext() == null) language.setContext(getContext()); + } + scriptLanguageIndex = index; } From d85efbdb602addbc53240aafa8c06c35482f295d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 28 Jan 2016 14:58:59 -0600 Subject: [PATCH 0085/1208] ScriptInterpreter: return result of the evaluation The ScriptEngine#eval method returns a result. Let's pass it along. --- .../java/org/scijava/script/DefaultScriptInterpreter.java | 4 ++-- src/main/java/org/scijava/script/ScriptInterpreter.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptInterpreter.java b/src/main/java/org/scijava/script/DefaultScriptInterpreter.java index 13fe6ec77..1cfac55f8 100644 --- a/src/main/java/org/scijava/script/DefaultScriptInterpreter.java +++ b/src/main/java/org/scijava/script/DefaultScriptInterpreter.java @@ -83,10 +83,10 @@ public synchronized String walkHistory(final String currentCommand, } @Override - public void eval(final String command) throws ScriptException { + public Object eval(final String command) throws ScriptException { if (history != null) history.add(command); if (engine == null) throw new java.lang.IllegalArgumentException(); - engine.eval(command); + return engine.eval(command); } @Override diff --git a/src/main/java/org/scijava/script/ScriptInterpreter.java b/src/main/java/org/scijava/script/ScriptInterpreter.java index f2821b08b..332073ddf 100644 --- a/src/main/java/org/scijava/script/ScriptInterpreter.java +++ b/src/main/java/org/scijava/script/ScriptInterpreter.java @@ -65,9 +65,10 @@ public interface ScriptInterpreter { * Evaluates a command. * * @param command the command to evaluate + * @return result of the evaluation * @throws ScriptException */ - void eval(String command) throws ScriptException; + Object eval(String command) throws ScriptException; /** * Returns the associated {@link ScriptLanguage}. From 9b77ad34e0d2c4b9abec3b0823e61c7d4e4626a3 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 28 Jan 2016 15:27:04 -0600 Subject: [PATCH 0086/1208] DefaultScriptInterpreter: improve constructors The old constructor is deprecated. There is now a simple constructor taking only the ScriptLanguage, as well as one which allows to manually override the ScriptEngine. The SciJava application context is derived from the ScriptLanguage, and services (notably: the PrefService) are injected from there. The PrefService is now optional, and when it is null, there is no history available. (The code for null History was already in place everywhere -- it just couldn't happen previously due to the explicit "new History" call in the constructor. So now we make use of it.) --- .../script/DefaultScriptInterpreter.java | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptInterpreter.java b/src/main/java/org/scijava/script/DefaultScriptInterpreter.java index 1cfac55f8..c0da50a92 100644 --- a/src/main/java/org/scijava/script/DefaultScriptInterpreter.java +++ b/src/main/java/org/scijava/script/DefaultScriptInterpreter.java @@ -46,21 +46,50 @@ public class DefaultScriptInterpreter implements ScriptInterpreter { private final ScriptEngine engine; private final History history; + @Parameter(required = false) + private PrefService prefs; + /** - * Constructs a new {@link DefaultScriptInterpreter}. - * - * @param scriptService the script service - * @param language the script language + * @deprecated Use {@link #DefaultScriptInterpreter(ScriptLanguage)} instead. */ + @Deprecated + @SuppressWarnings("unused") public DefaultScriptInterpreter(final PrefService prefs, final ScriptService scriptService, final ScriptLanguage language) { + this(language); + } + + /** + * Creates a new script interpreter for the given script language. + * + * @param language {@link ScriptLanguage} of the interpreter + */ + public DefaultScriptInterpreter(final ScriptLanguage language) { + this(language, null); + } + + /** + * Creates a new script interpreter for the given script language, using the + * specified script engine. + * + * @param language {@link ScriptLanguage} of the interpreter + * @param engine {@link ScriptEngine} to use, or null for the specified + * language's default engine + */ + public DefaultScriptInterpreter(final ScriptLanguage language, + final ScriptEngine engine) + { + language.getContext().inject(this); this.language = language; - engine = language.getScriptEngine(); - history = new History(prefs, engine.getClass().getName()); + this.engine = engine == null ? language.getScriptEngine() : engine; + history = prefs == null ? null : + new History(prefs, this.engine.getClass().getName()); readHistory(); } + // -- ScriptInterpreter methods -- + @Override public synchronized void readHistory() { if (history == null) return; From edd3c340deb15ae054a34a0f43469bcebda3abda Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 28 Jan 2016 15:31:57 -0600 Subject: [PATCH 0087/1208] ScriptInterpreter: add getBindings() method This is a convenience method to easily access the engine scope bindings of the script engine. --- .../org/scijava/script/DefaultScriptInterpreter.java | 7 +++++++ src/main/java/org/scijava/script/ScriptInterpreter.java | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/src/main/java/org/scijava/script/DefaultScriptInterpreter.java b/src/main/java/org/scijava/script/DefaultScriptInterpreter.java index c0da50a92..45707f728 100644 --- a/src/main/java/org/scijava/script/DefaultScriptInterpreter.java +++ b/src/main/java/org/scijava/script/DefaultScriptInterpreter.java @@ -30,6 +30,8 @@ */ package org.scijava.script; +import javax.script.Bindings; +import javax.script.ScriptContext; import javax.script.ScriptEngine; import javax.script.ScriptException; @@ -128,4 +130,9 @@ public ScriptEngine getEngine() { return engine; } + @Override + public Bindings getBindings() { + return engine.getBindings(ScriptContext.ENGINE_SCOPE); + } + } diff --git a/src/main/java/org/scijava/script/ScriptInterpreter.java b/src/main/java/org/scijava/script/ScriptInterpreter.java index 332073ddf..3eeece7c9 100644 --- a/src/main/java/org/scijava/script/ScriptInterpreter.java +++ b/src/main/java/org/scijava/script/ScriptInterpreter.java @@ -31,6 +31,8 @@ package org.scijava.script; +import javax.script.Bindings; +import javax.script.ScriptContext; import javax.script.ScriptEngine; import javax.script.ScriptException; @@ -81,4 +83,11 @@ public interface ScriptInterpreter { * @return the script engine */ ScriptEngine getEngine(); + + /** + * Returns the {@link Bindings} of the associated {@link ScriptEngine} at + * {@link ScriptContext#ENGINE_SCOPE} scope. + */ + Bindings getBindings(); + } From 7607c0f5daa23347a143d5b194e01d0219c8b146 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 28 Jan 2016 15:33:50 -0600 Subject: [PATCH 0088/1208] ScriptInterpreter: allow multi-line evaluation This adds new methods designed to support evaluation of multi-line statements which are fed to the interpreter one line at a time. The approach works according to a strategy implemented by Jason Sachs on StackOverflow at: http://stackoverflow.com/a/5598207 This functionality will be useful for improving the behavior of REPL (Read-Eval-Print-Loop) shells backed by this interpreter. --- .../script/DefaultScriptInterpreter.java | 232 +++++++++++++++++- .../org/scijava/script/ScriptInterpreter.java | 43 ++++ 2 files changed, 273 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptInterpreter.java b/src/main/java/org/scijava/script/DefaultScriptInterpreter.java index 45707f728..3eda51bdf 100644 --- a/src/main/java/org/scijava/script/DefaultScriptInterpreter.java +++ b/src/main/java/org/scijava/script/DefaultScriptInterpreter.java @@ -30,17 +30,28 @@ */ package org.scijava.script; +import java.lang.reflect.Method; + import javax.script.Bindings; +import javax.script.Compilable; +import javax.script.CompiledScript; import javax.script.ScriptContext; import javax.script.ScriptEngine; import javax.script.ScriptException; +import org.scijava.log.LogService; +import org.scijava.plugin.Parameter; import org.scijava.prefs.PrefService; /** * The default implementation of a {@link ScriptInterpreter}. + *

+ * Credit to Jason Sachs for the multi-line evaluation (see + * his post on StackOverflow). + *

* * @author Johannes Schindelin + * @author Curtis Rueden */ public class DefaultScriptInterpreter implements ScriptInterpreter { @@ -51,6 +62,13 @@ public class DefaultScriptInterpreter implements ScriptInterpreter { @Parameter(required = false) private PrefService prefs; + @Parameter(required = false) + private LogService log; + + private final StringBuilder buffer; + private int pendingLineCount; + private boolean expectingMoreInput; + /** * @deprecated Use {@link #DefaultScriptInterpreter(ScriptLanguage)} instead. */ @@ -88,6 +106,8 @@ public DefaultScriptInterpreter(final ScriptLanguage language, history = prefs == null ? null : new History(prefs, this.engine.getClass().getName()); readHistory(); + buffer = new StringBuilder(); + reset(); } // -- ScriptInterpreter methods -- @@ -115,11 +135,101 @@ public synchronized String walkHistory(final String currentCommand, @Override public Object eval(final String command) throws ScriptException { - if (history != null) history.add(command); - if (engine == null) throw new java.lang.IllegalArgumentException(); + addToHistory(command); return engine.eval(command); } + /** + * {@inheritDoc} + *

+ * This implementation from Jason Sachs uses the following strategy: + *

+ *
    + *
  • Keep a pending list of input lines not yet evaluated.
  • + *
  • Try compiling (but not evaluating) the pending input lines. + *
      + *
    • If the compilation is OK, we may be able to execute pending input + * lines.
    • + *
    • If the compilation throws an exception, and there is an indication of + * the position (line + column number) of the error, and this matches the end + * of the pending input, then that's a clue that we're expecting more input, + * so swallow the exception and wait for the next line.
    • + *
    • Otherwise, we either don't know where the error is, or it happened + * prior to the end of the pending input, so rethrow the exception.
    • + *
    + *
  • + *
  • If we are not expecting any more input lines, and we only have one line + * of pending input, then evaluate it and restart.
  • + *
  • If we are not expecting any more input lines, and the last one is a + * blank one, and we have more than one line of pending input, then evaluate + * it and restart. Python's interactive shell seems to do this.
  • + *
  • Otherwise, keep reading input lines.
  • + *
+ *

+ * This helps avoid certain problems: + *

+ *
    + *
  • users getting annoyed having to enter extra blank lines after + * single-line inputs
  • + *
  • users entering a long multi-line statement and only find out after the + * fact that there was a syntax error in the 2nd line.
  • + *
+ *

+ * For further details, see SO + * #5584674. + *

+ *

+ */ + @Override + public Object interpret(final String line) throws ScriptException { + if (line.isEmpty()) { + if (!shouldEvaluatePendingInput(true)) return MORE_INPUT_PENDING; + } + + pendingLineCount++; + buffer.append(line); + buffer.append("\n"); + + if (!(engine instanceof Compilable)) { + // Not a compilable language. + // Evaluate directly, with no multi-line statements possible. + try { + return eval(buffer.toString()); + } + finally { + reset(); + } + } + + final CompiledScript cs = tryCompiling(buffer.toString(), + getPendingLineCount(), line.length()); + + if (cs == null) { + // Command did not compile. + // Assume it is incomplete and wait for more input on the next line. + return MORE_INPUT_PENDING; + } + if (!shouldEvaluatePendingInput(line.isEmpty())) { + // We are still expecting more input. + return MORE_INPUT_PENDING; + } + // Command is complete; evaluate the compiled script. + try { + addToHistory(buffer.toString()); + return cs.eval(); + } + finally { + reset(); + } + } + + @Override + public void reset() { + buffer.setLength(0); + pendingLineCount = 0; + expectingMoreInput = false; + } + @Override public ScriptLanguage getLanguage() { return language; @@ -135,4 +245,122 @@ public Bindings getBindings() { return engine.getBindings(ScriptContext.ENGINE_SCOPE); } + @Override + public boolean isReady() { + return buffer.length() == 0; + } + + @Override + public boolean isExpectingMoreInput() { + return expectingMoreInput; + } + + // -- Helper methods -- + + private void addToHistory(final String command) { + if (history != null) history.add(command); + } + + /** + * @return number of lines pending execution + */ + private int getPendingLineCount() { + return pendingLineCount; + } + + /** + * @param lineIsEmpty whether the last line is empty + * @return whether we should evaluate the pending input. The default behavior + * is to evaluate if we only have one line of input, or if the user + * enters a blank line. This behavior should be overridden where + * appropriate. + */ + private boolean shouldEvaluatePendingInput(final boolean lineIsEmpty) { + if (isExpectingMoreInput()) return false; + return getPendingLineCount() == 1 || lineIsEmpty; + } + + private CompiledScript tryCompiling(final String string, final int lineCount, + final int lastLineLength) throws ScriptException + { + CompiledScript result = null; + try { + final Compilable c = (Compilable) engine; + result = c.compile(string); + } + catch (final ScriptException se) { + boolean rethrow = true; + if (se.getCause() != null) { + final Integer col = columnNumber(se); + final Integer line = lineNumber(se); + // swallow the exception if it occurs at the last character + // of the input (we may need to wait for more lines) + if (isLastCharacter(col, line, lineCount, lastLineLength)) { + rethrow = false; + } + else if (log != null && log.isDebug()) { + final String msg = se.getCause().getMessage(); + log.debug("L" + line + " C" + col + "(" + lineCount + "," + + lastLineLength + "): " + msg); + log.debug("in '" + string + "'"); + } + } + + if (rethrow) { + reset(); + throw se; + } + } + + expectingMoreInput = result == null; + return result; + } + + private boolean isLastCharacter(final Integer col, final Integer line, + final int lineCount, final int lastLineLength) + { + if (col == null || line == null) return false; + final int colNo = col.intValue(), lineNo = line.intValue(); + return lineNo == lineCount && colNo == lastLineLength || + lineNo == lineCount + 1 && colNo == 0; + } + + private Integer columnNumber(final ScriptException se) { + if (se.getColumnNumber() >= 0) return se.getColumnNumber(); + return callMethod(se.getCause(), "columnNumber", Integer.class); + } + + private Integer lineNumber(final ScriptException se) { + if (se.getLineNumber() >= 0) return se.getLineNumber(); + return callMethod(se.getCause(), "lineNumber", Integer.class); + } + + private static Method getMethod(final Object object, + final String methodName) + { + try { + return object.getClass().getMethod(methodName); + } + catch (final NoSuchMethodException e) { + // gulp + return null; + } + } + + private static T callMethod(final Object object, final String methodName, + final Class cl) + { + try { + final Method m = getMethod(object, methodName); + if (m != null) { + final Object result = m.invoke(object); + return cl.cast(result); + } + } + catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + } diff --git a/src/main/java/org/scijava/script/ScriptInterpreter.java b/src/main/java/org/scijava/script/ScriptInterpreter.java index 3eeece7c9..7c7e12da7 100644 --- a/src/main/java/org/scijava/script/ScriptInterpreter.java +++ b/src/main/java/org/scijava/script/ScriptInterpreter.java @@ -40,9 +40,16 @@ * The contract for script interpreters. * * @author Johannes Schindelin + * @author Curtis Rueden */ public interface ScriptInterpreter { + /** + * A special object returned by {@link #interpret(String)} when the + * interpreter is expecting additional input before finishing the evaluation. + */ + Object MORE_INPUT_PENDING = new Object(); + /** * Reads the persisted history of the current script interpreter. */ @@ -72,6 +79,26 @@ public interface ScriptInterpreter { */ Object eval(String command) throws ScriptException; + /** + * Interprets the given line of code, which might be part of a multi-line + * statement. + * + * @param line line of code to interpret + * @return value of the line, or {@link #MORE_INPUT_PENDING} if there is still + * pending input + * @throws ScriptException in case of an exception + */ + Object interpret(String line) throws ScriptException; + + /** + * Clears the buffer of not-yet-evaluated lines of code, accumulated from + * previous calls to {@link #interpret}. In other words: start over with a new + * (potentially multi-line) statement, discarding the current partial one. + * + * @see #interpret + */ + void reset(); + /** * Returns the associated {@link ScriptLanguage}. */ @@ -90,4 +117,20 @@ public interface ScriptInterpreter { */ Bindings getBindings(); + /** + * @return whether the interpreter is ready for a brand new statement. + * @see #interpret(String) + */ + boolean isReady(); + + /** + * @return whether the interpreter expects more input. A true value means + * there is definitely more input needed. A false value means no more + * input is needed, but it may not yet be appropriate to evaluate all + * the pending lines. (there's some ambiguity depending on the + * language) + * @see #interpret(String) + */ + boolean isExpectingMoreInput(); + } From cb7067e29930a09d0ce4cee1e391e91d618b7f57 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 21 Jan 2016 15:12:47 +0100 Subject: [PATCH 0089/1208] Add a REPL backed by the script interpreter It's basic, but the language switching feature is pretty snazzy. And it's convenient to have for CLI usage. The main method provides a CLI-based REPL. But the API should enable more sophisticated UIs built around it, as well. --- .../java/org/scijava/script/ScriptREPL.java | 351 ++++++++++++++++++ 1 file changed, 351 insertions(+) create mode 100644 src/main/java/org/scijava/script/ScriptREPL.java diff --git a/src/main/java/org/scijava/script/ScriptREPL.java b/src/main/java/org/scijava/script/ScriptREPL.java new file mode 100644 index 000000000..e3536bd97 --- /dev/null +++ b/src/main/java/org/scijava/script/ScriptREPL.java @@ -0,0 +1,351 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.script; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintStream; +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.List; + +import javax.script.Bindings; + +import org.scijava.Context; +import org.scijava.Gateway; +import org.scijava.log.LogService; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.PluginInfo; +import org.scijava.plugin.PluginService; +import org.scijava.service.Service; + +/** + * A REPL for SciJava script engines, which allows dynamic language switching. + * + * @author Curtis Rueden + */ +public class ScriptREPL { + + private static final String NULL = ""; + + @Parameter + private Context context; + + @Parameter + private ScriptService scriptService; + + @Parameter(required = false) + private PluginService pluginService; + + @Parameter(required = false) + private LogService log; + + private final PrintStream out; + + private ScriptInterpreter interpreter; + + public ScriptREPL(final Context context) { + this(context, System.out); + } + + public ScriptREPL(final Context context, final OutputStream out) { + context.inject(this); + this.out = out instanceof PrintStream ? + (PrintStream) out : new PrintStream(out); + } + + /** Gets the script interpreter for the currently active language. */ + public ScriptInterpreter getInterpreter() { + return interpreter; + } + + /** + * Starts a Read-Eval-Print-Loop from the standard input stream, returning + * when the loop terminates. + */ + public void loop() throws IOException { + loop(System.in); + } + + /** + * Starts a Read-Eval-Print-Loop from the given input stream, returning when + * the loop terminates. + * + * @param in Input stream from which commands are read. + */ + public void loop(final InputStream in) throws IOException { + initialize(); + final BufferedReader bin = new BufferedReader(new InputStreamReader(in)); + while (true) { + prompt(); + final String line = bin.readLine(); + if (line == null) break; + if (!evaluate(line)) return; + } + } + + /** Outputs a greeting, and sets up the initial language of the REPL. */ + public void initialize() { + out.println("Welcome to the SciJava REPL!"); + out.println(); + help(); + out.println("Have fun!"); + out.println(); + lang(scriptService.getLanguages().get(0).getLanguageName()); + populateBindings(interpreter.getBindings()); + } + + /** Outputs the prompt. */ + public void prompt() { + out.print(interpreter.isReady() ? "> " : "\\ "); + } + + /** + * Evaluates the line, including handling of special colon-prefixed REPL + * commands. + * + * @param line The line to evaluate. + * @return False iff the REPL should exit. + */ + public boolean evaluate(final String line) { + final String tLine = line.trim(); + if (tLine.equals(":help")) help(); + else if (tLine.equals(":vars")) vars(); + else if (tLine.equals(":langs")) langs(); + else if (tLine.startsWith(":lang ")) lang(line.substring(6).trim()); + else if (line.trim().equals(":quit")) return false; + else { + // pass the input to the current interpreter for evaluation + try { + final Object result = interpreter.interpret(line); + if (result != ScriptInterpreter.MORE_INPUT_PENDING) { + out.println(s(result)); + } + } + catch (final Throwable exc) { + exc.printStackTrace(out); + } + } + return true; + } + + // -- Commands -- + + /** Prints a usage guide. */ + public void help() { + out.println("Available built-in commands:"); + out.println(); + out.println(" :help | this handy list of commands"); + out.println(" :vars | dump a list of variables"); + out.println(" :lang | switch the active language"); + out.println(" :langs | list available languages"); + out.println(" :quit | exit the REPL"); + out.println(); + out.println("Or type a statement to evaluate it with the active language."); + out.println(); + } + + /** Lists variables in the script context. */ + public void vars() { + final List keys = new ArrayList(); + final List types = new ArrayList(); + final Bindings bindings = interpreter.getBindings(); + for (final String key : bindings.keySet()) { + final Object value = bindings.get(key); + keys.add(key); + types.add(type(value)); + } + printColumns(keys, types); + } + + /** + * Creates a new {@link ScriptInterpreter} to interpret statements, preserving + * existing variables from the previous interpreter. + * + * @param langName The script language of the new interpreter. + * @throws IllegalArgumentException if the requested language is not + * available. + */ + public void lang(final String langName) { + // create the new interpreter + final ScriptLanguage language = scriptService.getLanguageByName(langName); + if (language == null) { + throw new IllegalArgumentException("No such language: " + langName); + } + final ScriptInterpreter newInterpreter = + new DefaultScriptInterpreter(language); + + // preserve state of the previous interpreter + copyBindings(interpreter, newInterpreter); + out.println("language -> " + + newInterpreter.getLanguage().getLanguageName()); + interpreter = newInterpreter; + } + + public void langs() { + final List names = new ArrayList(); + final List versions = new ArrayList(); + final List aliases = new ArrayList(); + for (final ScriptLanguage lang : scriptService.getLanguages()) { + names.add(lang.getLanguageName()); + versions.add(lang.getLanguageVersion()); + aliases.add(lang.getNames()); + } + printColumns(names, versions, aliases); + } + + // -- Main method -- + + public static void main(final String... args) throws Exception { + // make a SciJava application context + final Context context = new Context(); + + // create the script interpreter + final ScriptREPL scriptCLI = new ScriptREPL(context); + + // start the REPL + scriptCLI.loop(); + + // clean up + context.dispose(); + System.exit(0); + } + + // -- Helper methods -- + + /** Populates the bindings with the context + services + gateways. */ + private void populateBindings(final Bindings bindings) { + bindings.put("ctx", context); + for (final Service service : context.getServiceIndex().getAll()) { + final String name = serviceName(service); + bindings.put(name, service); + } + for (final Gateway gateway : gateways()) { + bindings.put(gateway.getShortName(), gateway); + } + } + + /** Transfers variables from one interpreter's bindings to another. */ + private void copyBindings(final ScriptInterpreter src, + final ScriptInterpreter dest) + { + if (src == null) return; // nothing to copy + final Bindings srcBindings = src.getBindings(); + final Bindings destBindings = dest.getBindings(); + for (final String key : src.getBindings().keySet()) { + final Object value = src.getLanguage().decode(srcBindings.get(key)); + destBindings.put(key, value); + } + } + + private List gateways() { + final ArrayList gateways = new ArrayList(); + if (pluginService == null) return gateways; + // HACK: Instantiating a Gateway with the noargs constructor spins + // up a second Context, which is not what we want. Perhaps SJC should + // be changed to prefer a single-argument constructor that accepts a + // Context, before trying the noargs constructor? + // In the meantime, we do it manually here. + final List> infos = + pluginService.getPluginsOfType(Gateway.class); + for (final PluginInfo info : infos) { + try { + final Constructor ctor = + info.loadClass().getConstructor(Context.class); + final Gateway gateway = ctor.newInstance(context); + gateways.add(gateway); + } + catch (final Throwable t) { + if (log != null) log.error(t); + } + } + return gateways; + } + + private String serviceName(final Service service) { + final String serviceName = service.getClass().getSimpleName(); + final String shortName = lowerCamelCase( + serviceName.replaceAll("^(Default)?(.*)Service$", "$2")); + return shortName; + } + + private String type(final Object value) { + if (value == null) return NULL; + final Object decoded = interpreter.getLanguage().decode(value); + if (decoded == null) return NULL; + return "[" + decoded.getClass().getName() + "]"; + } + + private void printColumns(final List... columns) { + final int pad = 2; + + // compute width of each column + final int[] widths = new int[columns.length]; + for (int c = 0; c < columns.length; c++) { + final List list = columns[c]; + for (final Object o : list) { + final String s = s(o); + if (s.length() > widths[c]) widths[c] = s.length(); + } + } + + // output the columns + for (int i = 0; i < columns[0].size(); i++) { + for (int c = 0; c < columns.length; c++) { + final String s = s(columns[c].get(i)); + out.print(s); + for (int p = s.length(); p < widths[c] + pad; p++) { + out.print(' '); + } + } + out.println(); + } + } + + private static String lowerCamelCase(final String s) { + final StringBuilder sb = new StringBuilder(s); + for (int i=0; i= 'A' && c <= 'Z') sb.setCharAt(i, (char) (c - 'A' + 'a')); + else break; + } + return sb.toString(); + } + + private static String s(final Object o) { + return o == null ? NULL : o.toString(); + } + +} From edfc7c53815918672ba708daa5fb45b3d80ea404 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 5 Feb 2016 15:17:43 -0600 Subject: [PATCH 0090/1208] Revert commit "Use List instead of Iterable as returntype of the ModuleInfo methods returning list of ModuleItems." This reverts commit 88d3cab189d1fd68b2065e0e109cbb18ef48e0b0. Unfortunately, this change results in incompatible bytecode, such that downstream callers encounter exceptions like: java.lang.NoSuchMethodError: org.scijava.module.ModuleInfo.inputs()Ljava/lang/Iterable; at net.imagej.ops.NamespacePreprocessor.process(NamespacePreprocessor.java:56) at org.scijava.module.ModuleRunner.preProcess(ModuleRunner.java:104) So this change will need to wait till SciJava Common 3.0.0, sadly. --- src/main/java/org/scijava/command/CommandInfo.java | 4 ++-- src/main/java/org/scijava/module/AbstractModuleInfo.java | 4 ++-- src/main/java/org/scijava/module/ModuleInfo.java | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/scijava/command/CommandInfo.java b/src/main/java/org/scijava/command/CommandInfo.java index cb391eb47..3cc61e6ec 100644 --- a/src/main/java/org/scijava/command/CommandInfo.java +++ b/src/main/java/org/scijava/command/CommandInfo.java @@ -279,13 +279,13 @@ public CommandModuleItem getOutput(final String name, } @Override - public List> inputs() { + public Iterable> inputs() { parseParams(); return Collections.unmodifiableList(inputList); } @Override - public List> outputs() { + public Iterable> outputs() { parseParams(); return Collections.unmodifiableList(outputList); } diff --git a/src/main/java/org/scijava/module/AbstractModuleInfo.java b/src/main/java/org/scijava/module/AbstractModuleInfo.java index cd85e75cc..551664197 100644 --- a/src/main/java/org/scijava/module/AbstractModuleInfo.java +++ b/src/main/java/org/scijava/module/AbstractModuleInfo.java @@ -99,12 +99,12 @@ public ModuleItem getOutput(final String name, final Class type) { } @Override - public List> inputs() { + public Iterable> inputs() { return Collections.unmodifiableList(inputList()); } @Override - public List> outputs() { + public Iterable> outputs() { return Collections.unmodifiableList(outputList()); } diff --git a/src/main/java/org/scijava/module/ModuleInfo.java b/src/main/java/org/scijava/module/ModuleInfo.java index 6e644fa27..f55541d82 100644 --- a/src/main/java/org/scijava/module/ModuleInfo.java +++ b/src/main/java/org/scijava/module/ModuleInfo.java @@ -31,8 +31,6 @@ package org.scijava.module; -import java.util.List; - import org.scijava.UIDetails; import org.scijava.Validated; import org.scijava.event.EventService; @@ -76,10 +74,10 @@ public interface ModuleInfo extends UIDetails, Validated { ModuleItem getOutput(String name, Class type); /** Gets the list of input items. */ - List> inputs(); + Iterable> inputs(); /** Gets the list of output items. */ - List> outputs(); + Iterable> outputs(); /** * Gets the fully qualified name of the class containing the module's actual From 46d898942709e024d934f5b80011cf13e6534ce1 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 5 Feb 2016 15:12:55 -0600 Subject: [PATCH 0091/1208] DefaultWidgetModel: tweak javadoc --- src/main/java/org/scijava/widget/DefaultWidgetModel.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/widget/DefaultWidgetModel.java b/src/main/java/org/scijava/widget/DefaultWidgetModel.java index bbd715b3d..93c287126 100644 --- a/src/main/java/org/scijava/widget/DefaultWidgetModel.java +++ b/src/main/java/org/scijava/widget/DefaultWidgetModel.java @@ -285,7 +285,7 @@ public boolean isInitialized() { // -- Helper methods -- /** - * For multiple choice widgets, ensure the value is a valid choice. + * For multiple choice widgets, ensures the value is a valid choice. * * @see #getChoices() * @see ChoiceWidget @@ -295,7 +295,7 @@ private Object ensureValidChoice(final Object value) { } /** - * For object widgets, ensure the value is a valid object. + * For object widgets, ensures the value is a valid object. * * @see #getObjectPool() * @see ObjectWidget From 4679622b50e31cbc8c2920490dae983ab00aeea8 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 5 Feb 2016 15:13:16 -0600 Subject: [PATCH 0092/1208] DefaultWidgetModel: use default when value is null Before this change, it was up to individual widget implementations to actually respect the default value... and most of them didn't. This change makes respecting the default value automatic! --- src/main/java/org/scijava/widget/DefaultWidgetModel.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/org/scijava/widget/DefaultWidgetModel.java b/src/main/java/org/scijava/widget/DefaultWidgetModel.java index 93c287126..278bf71a9 100644 --- a/src/main/java/org/scijava/widget/DefaultWidgetModel.java +++ b/src/main/java/org/scijava/widget/DefaultWidgetModel.java @@ -44,6 +44,7 @@ import org.scijava.module.MethodCallException; import org.scijava.module.Module; import org.scijava.module.ModuleItem; +import org.scijava.module.ModuleService; import org.scijava.plugin.Parameter; import org.scijava.thread.ThreadService; import org.scijava.util.ClassUtils; @@ -70,6 +71,9 @@ public class DefaultWidgetModel extends AbstractContextual implements WidgetMode @Parameter private ConvertService convertService; + @Parameter + private ModuleService moduleService; + @Parameter(required = false) private LogService log; @@ -84,6 +88,11 @@ public DefaultWidgetModel(final Context context, final InputPanel inputPan this.item = item; this.objectPool = objectPool; convertedObjects = new WeakHashMap(); + + if (item.getValue(module) == null) { + // assign the item's default value as the current value + setValue(moduleService.getDefaultValue(item)); + } } @Override From e759dd8af838b308a069d0a8d3436557fdff8892 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Fri, 12 Feb 2016 10:28:34 -0600 Subject: [PATCH 0093/1208] RunArgument: support scripts When parsing arguments to the --run command line option, check if we were given a valid script name. If so, run the script with the given arguments. --- .../scijava/command/console/RunArgument.java | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/command/console/RunArgument.java b/src/main/java/org/scijava/command/console/RunArgument.java index 6c09e8cc8..469608b59 100644 --- a/src/main/java/org/scijava/command/console/RunArgument.java +++ b/src/main/java/org/scijava/command/console/RunArgument.java @@ -31,20 +31,26 @@ package org.scijava.command.console; +import java.io.File; +import java.util.HashMap; import java.util.LinkedList; +import java.util.Map; import org.scijava.command.CommandInfo; import org.scijava.command.CommandService; import org.scijava.console.AbstractConsoleArgument; import org.scijava.console.ConsoleArgument; +import org.scijava.log.LogService; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; +import org.scijava.script.ScriptService; /** * Handles the {@code --run} command line argument. * * @author Curtis Rueden * @author Johannes Schindelin + * @author Mark Hiner hinerm at gmail.com */ @Plugin(type = ConsoleArgument.class) public class RunArgument extends AbstractConsoleArgument { @@ -52,6 +58,12 @@ public class RunArgument extends AbstractConsoleArgument { @Parameter private CommandService commandService; + @Parameter + private ScriptService scriptService; + + @Parameter + private LogService logService; + // -- ConsoleArgument methods -- @Override @@ -76,6 +88,32 @@ public boolean supports(final LinkedList args) { /** Implements the {@code --run} command line argument. */ private void run(final String commandToRun, final String optionString) { + final Map inputMap = new HashMap(); + + if (!optionString.isEmpty()) { + final String[] pairs = optionString.split(","); + for (final String pair : pairs) { + final String[] split = pair.split("="); + if (split.length != 2) { + logService.error("Parameters must be formatted as a comma-separated list of key=value pairs"); + return; + } + inputMap.put(split[0], split[1]); + } + } + + // first check if this is a script + final File scriptFile = new File(commandToRun); + if (scriptFile.exists() && scriptService.canHandleFile(commandToRun)) { + try { + scriptService.run(scriptFile, true, inputMap); + } catch (final Exception exc) { + logService.error(exc); + } + return; + } + + // Not a script, check if it's a command class CommandInfo info = commandService.getCommand(commandToRun); if (info == null) { // command was not a class name; search for command by title instead @@ -87,9 +125,11 @@ private void run(final String commandToRun, final String optionString) { } } } + + // couldn't find anything to run if (info == null) return; // TODO: parse the optionString a la ImageJ1 - commandService.run(info, true); + commandService.run(info, true, inputMap); } } From 696913021a021d21d6617e82a90799ad31e76a06 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Tue, 16 Feb 2016 07:49:20 -0600 Subject: [PATCH 0094/1208] Happy 2016! --- src/it/apt-test/pom.xml | 2 +- src/it/apt-test/setup.bsh | 2 +- .../org/scijava/annotation/its/Annotated.java | 2 +- .../annotation/its/CustomAnnotation.java | 2 +- src/it/apt-test/verify.bsh | 2 +- src/it/settings.xml | 2 +- .../org/scijava/AbstractBasicDetails.java | 2 +- .../java/org/scijava/AbstractContextual.java | 2 +- .../java/org/scijava/AbstractGateway.java | 2 +- .../java/org/scijava/AbstractUIDetails.java | 2 +- src/main/java/org/scijava/BasicDetails.java | 2 +- src/main/java/org/scijava/Cancelable.java | 2 +- src/main/java/org/scijava/Context.java | 2 +- src/main/java/org/scijava/Contextual.java | 2 +- src/main/java/org/scijava/Disposable.java | 2 +- src/main/java/org/scijava/Gateway.java | 2 +- src/main/java/org/scijava/Identifiable.java | 2 +- src/main/java/org/scijava/Instantiable.java | 2 +- .../org/scijava/InstantiableException.java | 2 +- src/main/java/org/scijava/ItemIO.java | 2 +- src/main/java/org/scijava/ItemVisibility.java | 2 +- src/main/java/org/scijava/Locatable.java | 2 +- src/main/java/org/scijava/MenuEntry.java | 2 +- src/main/java/org/scijava/MenuPath.java | 2 +- src/main/java/org/scijava/Named.java | 2 +- .../org/scijava/NoSuchServiceException.java | 2 +- .../org/scijava/NullContextException.java | 2 +- src/main/java/org/scijava/Optional.java | 2 +- src/main/java/org/scijava/Prioritized.java | 2 +- src/main/java/org/scijava/Priority.java | 2 +- src/main/java/org/scijava/SciJava.java | 2 +- src/main/java/org/scijava/Typed.java | 2 +- src/main/java/org/scijava/UIDetails.java | 2 +- src/main/java/org/scijava/Validated.java | 2 +- .../java/org/scijava/ValidityProblem.java | 2 +- src/main/java/org/scijava/Versioned.java | 2 +- .../annotations/AbstractIndexWriter.java | 2 +- .../annotations/AnnotationCombiner.java | 2 +- .../annotations/AnnotationProcessor.java | 2 +- .../scijava/annotations/ByteCodeAnalyzer.java | 2 +- .../scijava/annotations/DirectoryIndexer.java | 2 +- .../scijava/annotations/EclipseHelper.java | 2 +- .../java/org/scijava/annotations/Index.java | 2 +- .../org/scijava/annotations/IndexItem.java | 2 +- .../org/scijava/annotations/IndexReader.java | 2 +- .../org/scijava/annotations/Indexable.java | 2 +- .../annotations/legacy/LegacyReader.java | 2 +- .../java/org/scijava/app/AbstractApp.java | 2 +- src/main/java/org/scijava/app/App.java | 2 +- src/main/java/org/scijava/app/AppService.java | 2 +- .../org/scijava/app/DefaultAppService.java | 2 +- .../org/scijava/app/DefaultStatusService.java | 2 +- src/main/java/org/scijava/app/SciJavaApp.java | 2 +- .../java/org/scijava/app/StatusService.java | 2 +- .../org/scijava/app/event/StatusEvent.java | 2 +- .../java/org/scijava/cache/CacheService.java | 2 +- .../scijava/cache/DefaultCacheService.java | 2 +- .../java/org/scijava/command/Command.java | 2 +- .../java/org/scijava/command/CommandInfo.java | 2 +- .../org/scijava/command/CommandModule.java | 2 +- .../scijava/command/CommandModuleItem.java | 2 +- .../org/scijava/command/CommandService.java | 2 +- .../org/scijava/command/ContextCommand.java | 2 +- .../command/DefaultCommandService.java | 2 +- .../org/scijava/command/DynamicCommand.java | 2 +- .../scijava/command/DynamicCommandInfo.java | 2 +- .../java/org/scijava/command/Interactive.java | 2 +- .../scijava/command/InteractiveCommand.java | 2 +- .../org/scijava/command/ModuleCommand.java | 2 +- .../java/org/scijava/command/Previewable.java | 2 +- .../scijava/command/UnimplementedCommand.java | 2 +- .../scijava/command/console/RunArgument.java | 2 +- .../console/AbstractConsoleArgument.java | 2 +- .../org/scijava/console/ConsoleArgument.java | 2 +- .../org/scijava/console/ConsoleService.java | 2 +- .../console/DefaultConsoleService.java | 2 +- .../scijava/console/MultiOutputStream.java | 2 +- .../org/scijava/console/MultiPrintStream.java | 2 +- .../java/org/scijava/console/OutputEvent.java | 2 +- .../org/scijava/console/OutputListener.java | 2 +- .../console/SystemPropertyArgument.java | 2 +- .../convert/AbstractConvertService.java | 2 +- .../scijava/convert/AbstractConverter.java | 2 +- .../org/scijava/convert/ArrayConverters.java | 2 +- .../org/scijava/convert/CastingConverter.java | 4 +-- .../scijava/convert/ConversionRequest.java | 2 +- .../org/scijava/convert/ConvertService.java | 2 +- .../java/org/scijava/convert/Converter.java | 2 +- .../convert/DefaultConvertService.java | 2 +- .../org/scijava/convert/DefaultConverter.java | 2 +- .../org/scijava/convert/NullConverter.java | 2 +- .../convert/PrimitiveArrayUnwrapper.java | 2 +- .../convert/PrimitiveArrayWrapper.java | 2 +- .../org/scijava/display/AbstractDisplay.java | 2 +- .../display/ActiveDisplayPreprocessor.java | 2 +- .../org/scijava/display/DefaultDisplay.java | 2 +- .../display/DefaultDisplayService.java | 2 +- .../scijava/display/DefaultTextDisplay.java | 2 +- .../java/org/scijava/display/Display.java | 2 +- .../scijava/display/DisplayPostprocessor.java | 2 +- .../org/scijava/display/DisplayService.java | 2 +- .../java/org/scijava/display/Displayable.java | 2 +- .../java/org/scijava/display/TextDisplay.java | 2 +- .../display/event/DisplayActivatedEvent.java | 2 +- .../display/event/DisplayCreatedEvent.java | 2 +- .../display/event/DisplayDeletedEvent.java | 2 +- .../scijava/display/event/DisplayEvent.java | 2 +- .../display/event/DisplayUpdatedEvent.java | 2 +- .../display/event/input/InputEvent.java | 2 +- .../scijava/display/event/input/KyEvent.java | 2 +- .../display/event/input/KyPressedEvent.java | 2 +- .../display/event/input/KyReleasedEvent.java | 2 +- .../display/event/input/KyTypedEvent.java | 2 +- .../display/event/input/MsButtonEvent.java | 2 +- .../display/event/input/MsClickedEvent.java | 2 +- .../display/event/input/MsDraggedEvent.java | 2 +- .../display/event/input/MsEnteredEvent.java | 2 +- .../scijava/display/event/input/MsEvent.java | 2 +- .../display/event/input/MsExitedEvent.java | 2 +- .../display/event/input/MsMovedEvent.java | 2 +- .../display/event/input/MsPressedEvent.java | 2 +- .../display/event/input/MsReleasedEvent.java | 2 +- .../display/event/input/MsWheelEvent.java | 2 +- .../event/window/WinActivatedEvent.java | 2 +- .../display/event/window/WinClosedEvent.java | 2 +- .../display/event/window/WinClosingEvent.java | 2 +- .../event/window/WinDeactivatedEvent.java | 2 +- .../event/window/WinDeiconifiedEvent.java | 2 +- .../display/event/window/WinEvent.java | 2 +- .../event/window/WinIconifiedEvent.java | 2 +- .../display/event/window/WinOpenedEvent.java | 2 +- .../scijava/event/ContextDisposingEvent.java | 2 +- .../org/scijava/event/DefaultEventBus.java | 2 +- .../scijava/event/DefaultEventHistory.java | 2 +- .../scijava/event/DefaultEventService.java | 2 +- .../java/org/scijava/event/EventDetails.java | 2 +- .../java/org/scijava/event/EventHandler.java | 2 +- .../java/org/scijava/event/EventHistory.java | 2 +- .../scijava/event/EventHistoryListener.java | 2 +- .../java/org/scijava/event/EventService.java | 2 +- .../org/scijava/event/EventSubscriber.java | 2 +- .../java/org/scijava/event/SciJavaEvent.java | 2 +- .../java/org/scijava/input/Accelerator.java | 2 +- .../scijava/input/DefaultInputService.java | 2 +- .../org/scijava/input/InputModifiers.java | 2 +- .../java/org/scijava/input/InputService.java | 2 +- src/main/java/org/scijava/input/KeyCode.java | 2 +- .../java/org/scijava/input/MouseCursor.java | 2 +- .../org/scijava/io/AbstractDataHandle.java | 2 +- .../java/org/scijava/io/AbstractIOPlugin.java | 2 +- .../java/org/scijava/io/AbstractLocation.java | 2 +- .../java/org/scijava/io/BytesLocation.java | 2 +- src/main/java/org/scijava/io/DataHandle.java | 2 +- .../org/scijava/io/DataHandleInputStream.java | 2 +- .../scijava/io/DataHandleOutputStream.java | 2 +- .../org/scijava/io/DataHandleService.java | 2 +- .../scijava/io/DefaultDataHandleService.java | 2 +- .../java/org/scijava/io/DefaultIOService.java | 2 +- .../scijava/io/DefaultRecentFileService.java | 2 +- src/main/java/org/scijava/io/FileHandle.java | 2 +- .../java/org/scijava/io/FileLocation.java | 2 +- src/main/java/org/scijava/io/IOPlugin.java | 2 +- src/main/java/org/scijava/io/IOService.java | 2 +- src/main/java/org/scijava/io/Location.java | 2 +- .../org/scijava/io/RecentFileService.java | 2 +- src/main/java/org/scijava/io/URILocation.java | 2 +- src/main/java/org/scijava/io/URLLocation.java | 2 +- .../org/scijava/io/console/OpenArgument.java | 2 +- .../org/scijava/io/event/DataOpenedEvent.java | 2 +- .../org/scijava/io/event/DataSavedEvent.java | 2 +- .../java/org/scijava/io/event/IOEvent.java | 2 +- .../org/scijava/log/AbstractLogService.java | 2 +- .../log/DefaultUncaughtExceptionHandler.java | 2 +- src/main/java/org/scijava/log/LogService.java | 2 +- .../org/scijava/log/StderrLogService.java | 2 +- .../org/scijava/main/DefaultMainService.java | 2 +- .../java/org/scijava/main/MainService.java | 2 +- .../scijava/main/console/MainArgument.java | 2 +- .../org/scijava/menu/AbstractMenuCreator.java | 2 +- .../org/scijava/menu/DefaultMenuService.java | 2 +- .../java/org/scijava/menu/MenuConstants.java | 2 +- .../java/org/scijava/menu/MenuCreator.java | 2 +- .../java/org/scijava/menu/MenuService.java | 2 +- .../java/org/scijava/menu/ShadowMenu.java | 2 +- .../org/scijava/menu/ShadowMenuIterator.java | 2 +- .../org/scijava/menu/event/MenuEvent.java | 2 +- .../scijava/menu/event/MenusAddedEvent.java | 2 +- .../scijava/menu/event/MenusRemovedEvent.java | 2 +- .../scijava/menu/event/MenusUpdatedEvent.java | 2 +- .../org/scijava/module/AbstractModule.java | 2 +- .../scijava/module/AbstractModuleInfo.java | 2 +- .../scijava/module/AbstractModuleItem.java | 2 +- .../scijava/module/DefaultModuleService.java | 2 +- .../scijava/module/DefaultMutableModule.java | 2 +- .../module/DefaultMutableModuleInfo.java | 2 +- .../module/DefaultMutableModuleItem.java | 2 +- .../scijava/module/MethodCallException.java | 2 +- .../java/org/scijava/module/MethodRef.java | 2 +- src/main/java/org/scijava/module/Module.java | 2 +- .../module/ModuleCanceledException.java | 2 +- .../org/scijava/module/ModuleException.java | 2 +- .../java/org/scijava/module/ModuleIndex.java | 2 +- .../java/org/scijava/module/ModuleInfo.java | 2 +- .../java/org/scijava/module/ModuleItem.java | 2 +- .../java/org/scijava/module/ModuleRunner.java | 2 +- .../org/scijava/module/ModuleService.java | 2 +- .../org/scijava/module/MutableModule.java | 2 +- .../org/scijava/module/MutableModuleInfo.java | 2 +- .../org/scijava/module/MutableModuleItem.java | 2 +- .../module/event/ModuleCanceledEvent.java | 2 +- .../org/scijava/module/event/ModuleEvent.java | 2 +- .../module/event/ModuleExecutedEvent.java | 2 +- .../module/event/ModuleExecutingEvent.java | 2 +- .../module/event/ModuleExecutionEvent.java | 2 +- .../module/event/ModuleFinishedEvent.java | 2 +- .../module/event/ModulePostprocessEvent.java | 2 +- .../module/event/ModulePreprocessEvent.java | 2 +- .../module/event/ModuleProcessEvent.java | 2 +- .../module/event/ModuleStartedEvent.java | 2 +- .../module/event/ModulesAddedEvent.java | 2 +- .../module/event/ModulesListEvent.java | 2 +- .../module/event/ModulesRemovedEvent.java | 2 +- .../module/event/ModulesUpdatedEvent.java | 2 +- .../process/AbstractPostprocessorPlugin.java | 2 +- .../process/AbstractPreprocessorPlugin.java | 2 +- .../AbstractSingleInputPreprocessor.java | 2 +- .../process/CheckInputsPreprocessor.java | 2 +- .../module/process/DebugPostprocessor.java | 2 +- .../module/process/DebugPreprocessor.java | 2 +- .../process/DefaultValuePreprocessor.java | 6 ++-- .../module/process/GatewayPreprocessor.java | 2 +- .../module/process/InitPreprocessor.java | 2 +- .../process/LoadInputsPreprocessor.java | 2 +- .../module/process/ModulePostprocessor.java | 2 +- .../module/process/ModulePreprocessor.java | 2 +- .../module/process/ModuleProcessor.java | 2 +- .../module/process/PostprocessorPlugin.java | 2 +- .../module/process/PreprocessorPlugin.java | 2 +- .../process/SaveInputsPreprocessor.java | 2 +- .../module/process/ServicePreprocessor.java | 2 +- .../module/process/ValidityPreprocessor.java | 2 +- .../scijava/object/DefaultObjectService.java | 2 +- .../java/org/scijava/object/LazyObjects.java | 2 +- .../java/org/scijava/object/ObjectIndex.java | 2 +- .../org/scijava/object/ObjectService.java | 2 +- .../org/scijava/object/SortedObjectIndex.java | 2 +- .../org/scijava/object/event/ListEvent.java | 2 +- .../object/event/ObjectCreatedEvent.java | 2 +- .../object/event/ObjectDeletedEvent.java | 2 +- .../org/scijava/object/event/ObjectEvent.java | 2 +- .../object/event/ObjectModifiedEvent.java | 2 +- .../object/event/ObjectsAddedEvent.java | 2 +- .../object/event/ObjectsListEvent.java | 2 +- .../object/event/ObjectsRemovedEvent.java | 2 +- .../options/DefaultOptionsService.java | 2 +- .../org/scijava/options/OptionsPlugin.java | 2 +- .../org/scijava/options/OptionsService.java | 2 +- .../scijava/options/event/OptionsEvent.java | 2 +- .../scijava/platform/AbstractPlatform.java | 2 +- .../org/scijava/platform/AppEventService.java | 2 +- .../platform/DefaultAppEventService.java | 2 +- .../org/scijava/platform/DefaultPlatform.java | 2 +- .../platform/DefaultPlatformService.java | 2 +- .../java/org/scijava/platform/Platform.java | 2 +- .../org/scijava/platform/PlatformService.java | 2 +- .../scijava/platform/event/AppAboutEvent.java | 2 +- .../scijava/platform/event/AppFocusEvent.java | 2 +- .../platform/event/AppMenusCreatedEvent.java | 2 +- .../platform/event/AppOpenFilesEvent.java | 2 +- .../platform/event/AppPreferencesEvent.java | 2 +- .../scijava/platform/event/AppPrintEvent.java | 2 +- .../scijava/platform/event/AppQuitEvent.java | 2 +- .../platform/event/AppReOpenEvent.java | 2 +- .../platform/event/AppScreenSleepEvent.java | 2 +- .../scijava/platform/event/AppSleepEvent.java | 2 +- .../platform/event/AppSystemSleepEvent.java | 2 +- .../platform/event/AppUserSessionEvent.java | 2 +- .../platform/event/AppVisibleEvent.java | 2 +- .../platform/event/ApplicationEvent.java | 2 +- .../scijava/plugin/AbstractHandlerPlugin.java | 2 +- .../plugin/AbstractHandlerService.java | 2 +- .../org/scijava/plugin/AbstractPTService.java | 2 +- .../scijava/plugin/AbstractRichPlugin.java | 2 +- .../plugin/AbstractSingletonService.java | 2 +- .../scijava/plugin/AbstractTypedPlugin.java | 2 +- .../scijava/plugin/AbstractTypedService.java | 2 +- .../scijava/plugin/AbstractWrapperPlugin.java | 2 +- .../plugin/AbstractWrapperService.java | 2 +- src/main/java/org/scijava/plugin/Attr.java | 2 +- .../scijava/plugin/DefaultPluginFinder.java | 2 +- .../scijava/plugin/DefaultPluginService.java | 2 +- .../org/scijava/plugin/HandlerPlugin.java | 2 +- .../org/scijava/plugin/HandlerService.java | 2 +- .../org/scijava/plugin/HasPluginInfo.java | 2 +- src/main/java/org/scijava/plugin/Menu.java | 2 +- .../java/org/scijava/plugin/PTService.java | 2 +- .../java/org/scijava/plugin/Parameter.java | 2 +- src/main/java/org/scijava/plugin/Plugin.java | 2 +- .../java/org/scijava/plugin/PluginFinder.java | 2 +- .../java/org/scijava/plugin/PluginIndex.java | 2 +- .../java/org/scijava/plugin/PluginInfo.java | 2 +- .../org/scijava/plugin/PluginService.java | 2 +- .../java/org/scijava/plugin/RichPlugin.java | 2 +- .../org/scijava/plugin/SciJavaPlugin.java | 2 +- .../org/scijava/plugin/SingletonPlugin.java | 2 +- .../org/scijava/plugin/SingletonService.java | 2 +- .../org/scijava/plugin/SortablePlugin.java | 2 +- .../java/org/scijava/plugin/TypedPlugin.java | 2 +- .../java/org/scijava/plugin/TypedService.java | 2 +- .../org/scijava/plugin/WrapperPlugin.java | 2 +- .../org/scijava/plugin/WrapperService.java | 2 +- .../plugin/event/PluginsAddedEvent.java | 2 +- .../plugin/event/PluginsListEvent.java | 2 +- .../plugin/event/PluginsRemovedEvent.java | 2 +- .../scijava/prefs/AbstractPrefService.java | 2 +- .../org/scijava/prefs/DefaultPrefService.java | 2 +- .../java/org/scijava/prefs/PrefService.java | 2 +- .../scijava/script/AbstractScriptContext.java | 2 +- .../scijava/script/AbstractScriptEngine.java | 2 +- .../scijava/script/AbstractScriptHeader.java | 2 +- .../script/AbstractScriptLanguage.java | 2 +- .../scijava/script/AdaptedScriptLanguage.java | 2 +- .../org/scijava/script/CodeGenerator.java | 2 +- .../org/scijava/script/CodeGeneratorJava.java | 2 +- .../script/DefaultScriptHeaderService.java | 2 +- .../script/DefaultScriptInterpreter.java | 2 +- .../scijava/script/DefaultScriptService.java | 2 +- src/main/java/org/scijava/script/History.java | 2 +- .../org/scijava/script/InvocationObject.java | 2 +- .../org/scijava/script/ParameterObject.java | 2 +- .../java/org/scijava/script/ScriptFinder.java | 2 +- .../java/org/scijava/script/ScriptHeader.java | 2 +- .../scijava/script/ScriptHeaderService.java | 2 +- .../java/org/scijava/script/ScriptInfo.java | 2 +- .../org/scijava/script/ScriptInterpreter.java | 2 +- .../org/scijava/script/ScriptLanguage.java | 2 +- .../scijava/script/ScriptLanguageIndex.java | 2 +- .../java/org/scijava/script/ScriptModule.java | 2 +- .../org/scijava/script/ScriptService.java | 2 +- .../org/scijava/script/io/ScriptIOPlugin.java | 2 +- .../org/scijava/service/AbstractService.java | 2 +- .../org/scijava/service/SciJavaService.java | 2 +- .../java/org/scijava/service/Service.java | 2 +- .../org/scijava/service/ServiceHelper.java | 2 +- .../org/scijava/service/ServiceIndex.java | 2 +- .../service/event/ServicesLoadedEvent.java | 2 +- src/main/java/org/scijava/test/TestUtils.java | 2 +- .../org/scijava/text/AbstractTextFormat.java | 2 +- .../org/scijava/text/DefaultTextService.java | 2 +- .../java/org/scijava/text/TextFormat.java | 2 +- .../java/org/scijava/text/TextService.java | 2 +- .../org/scijava/text/io/TextIOPlugin.java | 2 +- .../scijava/thread/DefaultThreadService.java | 2 +- .../org/scijava/thread/ThreadService.java | 2 +- .../java/org/scijava/tool/AbstractTool.java | 2 +- .../org/scijava/tool/CustomDrawnTool.java | 2 +- .../org/scijava/tool/DefaultToolService.java | 2 +- src/main/java/org/scijava/tool/DummyTool.java | 2 +- .../java/org/scijava/tool/IconDrawer.java | 2 +- .../java/org/scijava/tool/IconService.java | 2 +- src/main/java/org/scijava/tool/Tool.java | 2 +- .../java/org/scijava/tool/ToolService.java | 2 +- .../tool/event/ToolActivatedEvent.java | 2 +- .../tool/event/ToolDeactivatedEvent.java | 2 +- .../org/scijava/tool/event/ToolEvent.java | 2 +- src/main/java/org/scijava/ui/ARGBPlane.java | 2 +- .../ui/AbstractInputHarvesterPlugin.java | 2 +- .../org/scijava/ui/AbstractUIInputWidget.java | 2 +- .../org/scijava/ui/AbstractUserInterface.java | 2 +- .../java/org/scijava/ui/ApplicationFrame.java | 2 +- src/main/java/org/scijava/ui/Arrangeable.java | 2 +- .../java/org/scijava/ui/CloseConfirmable.java | 2 +- .../java/org/scijava/ui/DefaultUIService.java | 2 +- src/main/java/org/scijava/ui/Desktop.java | 2 +- .../java/org/scijava/ui/DialogPrompt.java | 2 +- .../java/org/scijava/ui/FilePreprocessor.java | 2 +- src/main/java/org/scijava/ui/StatusBar.java | 2 +- .../java/org/scijava/ui/SystemClipboard.java | 2 +- src/main/java/org/scijava/ui/ToolBar.java | 2 +- .../java/org/scijava/ui/UIPreprocessor.java | 2 +- src/main/java/org/scijava/ui/UIService.java | 2 +- .../java/org/scijava/ui/UserInterface.java | 2 +- .../ui/console/AbstractConsolePane.java | 2 +- .../org/scijava/ui/console/ConsolePane.java | 2 +- .../org/scijava/ui/console/UIArgument.java | 2 +- .../ui/dnd/AbstractDragAndDropData.java | 2 +- .../ui/dnd/AbstractDragAndDropHandler.java | 2 +- .../ui/dnd/DefaultDragAndDropData.java | 2 +- .../ui/dnd/DefaultDragAndDropService.java | 2 +- .../org/scijava/ui/dnd/DragAndDropData.java | 2 +- .../scijava/ui/dnd/DragAndDropHandler.java | 2 +- .../scijava/ui/dnd/DragAndDropService.java | 2 +- .../ui/dnd/FileDragAndDropHandler.java | 2 +- .../ui/dnd/ListDragAndDropHandler.java | 2 +- .../java/org/scijava/ui/dnd/MIMEType.java | 2 +- .../ui/dnd/ScriptFileDragAndDropHandler.java | 2 +- .../ui/dnd/event/DragAndDropEvent.java | 2 +- .../scijava/ui/dnd/event/DragEnterEvent.java | 2 +- .../scijava/ui/dnd/event/DragExitEvent.java | 2 +- .../scijava/ui/dnd/event/DragOverEvent.java | 2 +- .../org/scijava/ui/dnd/event/DropEvent.java | 2 +- .../java/org/scijava/ui/event/UIEvent.java | 2 +- .../org/scijava/ui/event/UIShownEvent.java | 2 +- .../ui/viewer/AbstractDisplayViewer.java | 2 +- .../org/scijava/ui/viewer/DisplayPanel.java | 2 +- .../org/scijava/ui/viewer/DisplayViewer.java | 2 +- .../org/scijava/ui/viewer/DisplayWindow.java | 2 +- .../text/AbstractTextDisplayViewer.java | 2 +- .../ui/viewer/text/TextDisplayPanel.java | 2 +- .../ui/viewer/text/TextDisplayViewer.java | 2 +- .../scijava/util/AbstractPrimitiveArray.java | 2 +- src/main/java/org/scijava/util/AppUtils.java | 2 +- .../java/org/scijava/util/ArrayUtils.java | 2 +- src/main/java/org/scijava/util/BoolArray.java | 2 +- src/main/java/org/scijava/util/ByteArray.java | 2 +- src/main/java/org/scijava/util/Bytes.java | 6 ++-- src/main/java/org/scijava/util/CharArray.java | 2 +- .../java/org/scijava/util/CheckSezpoz.java | 2 +- .../java/org/scijava/util/ClassUtils.java | 2 +- src/main/java/org/scijava/util/ColorRGB.java | 2 +- src/main/java/org/scijava/util/ColorRGBA.java | 2 +- src/main/java/org/scijava/util/Colors.java | 2 +- .../org/scijava/util/CombineAnnotations.java | 2 +- src/main/java/org/scijava/util/Combiner.java | 2 +- .../org/scijava/util/ConversionUtils.java | 2 +- .../java/org/scijava/util/DebugUtils.java | 2 +- .../java/org/scijava/util/DigestUtils.java | 2 +- .../java/org/scijava/util/DoubleArray.java | 2 +- src/main/java/org/scijava/util/FileUtils.java | 2 +- .../java/org/scijava/util/FloatArray.java | 2 +- .../java/org/scijava/util/GenericUtils.java | 2 +- src/main/java/org/scijava/util/IntArray.java | 2 +- src/main/java/org/scijava/util/IntCoords.java | 2 +- src/main/java/org/scijava/util/IntRect.java | 2 +- .../java/org/scijava/util/IteratorPlus.java | 2 +- .../org/scijava/util/LastRecentlyUsed.java | 2 +- .../org/scijava/util/LineOutputStream.java | 2 +- src/main/java/org/scijava/util/ListUtils.java | 2 +- src/main/java/org/scijava/util/LongArray.java | 2 +- src/main/java/org/scijava/util/Manifest.java | 2 +- .../org/scijava/util/MersenneTwisterFast.java | 2 +- .../org/scijava/util/MetaInfCombiner.java | 2 +- .../java/org/scijava/util/MirrorWebsite.java | 2 +- src/main/java/org/scijava/util/MiscUtils.java | 2 +- .../java/org/scijava/util/NumberUtils.java | 2 +- .../java/org/scijava/util/ObjectArray.java | 2 +- src/main/java/org/scijava/util/POM.java | 2 +- .../java/org/scijava/util/PlatformUtils.java | 2 +- src/main/java/org/scijava/util/Prefs.java | 2 +- .../java/org/scijava/util/PrimitiveArray.java | 2 +- .../java/org/scijava/util/ProcessUtils.java | 2 +- src/main/java/org/scijava/util/Query.java | 2 +- src/main/java/org/scijava/util/ReadInto.java | 2 +- .../java/org/scijava/util/RealCoords.java | 2 +- src/main/java/org/scijava/util/RealRect.java | 2 +- .../org/scijava/util/ReflectException.java | 2 +- .../org/scijava/util/ReflectedUniverse.java | 2 +- .../org/scijava/util/ServiceCombiner.java | 2 +- .../java/org/scijava/util/ShortArray.java | 2 +- src/main/java/org/scijava/util/Sizable.java | 2 +- .../org/scijava/util/SizableArrayList.java | 2 +- .../java/org/scijava/util/StringMaker.java | 2 +- .../java/org/scijava/util/StringUtils.java | 6 ++-- src/main/java/org/scijava/util/Timing.java | 2 +- .../java/org/scijava/util/TunePlayer.java | 2 +- src/main/java/org/scijava/util/UnitUtils.java | 2 +- .../java/org/scijava/util/VersionUtils.java | 2 +- src/main/java/org/scijava/util/XML.java | 2 +- .../welcome/DefaultWelcomeService.java | 2 +- .../org/scijava/welcome/WelcomeService.java | 2 +- .../scijava/welcome/event/WelcomeEvent.java | 2 +- .../widget/AbstractInputHarvester.java | 2 +- .../scijava/widget/AbstractInputPanel.java | 2 +- .../scijava/widget/AbstractInputWidget.java | 2 +- src/main/java/org/scijava/widget/Button.java | 2 +- .../java/org/scijava/widget/ButtonWidget.java | 2 +- .../java/org/scijava/widget/ChoiceWidget.java | 2 +- .../java/org/scijava/widget/ColorWidget.java | 2 +- .../java/org/scijava/widget/DateWidget.java | 2 +- .../scijava/widget/DefaultWidgetModel.java | 2 +- .../scijava/widget/DefaultWidgetService.java | 2 +- .../java/org/scijava/widget/FileWidget.java | 2 +- .../org/scijava/widget/InputHarvester.java | 2 +- .../java/org/scijava/widget/InputPanel.java | 2 +- .../java/org/scijava/widget/InputWidget.java | 2 +- .../org/scijava/widget/MessageWidget.java | 2 +- .../java/org/scijava/widget/NumberWidget.java | 2 +- .../java/org/scijava/widget/ObjectWidget.java | 2 +- .../java/org/scijava/widget/TextWidget.java | 2 +- .../java/org/scijava/widget/ToggleWidget.java | 2 +- .../java/org/scijava/widget/UIComponent.java | 2 +- .../java/org/scijava/widget/WidgetModel.java | 2 +- .../org/scijava/widget/WidgetService.java | 2 +- .../java/org/scijava/ContextCreationTest.java | 2 +- .../org/scijava/ContextInjectionTest.java | 2 +- .../org/scijava/annotations/AnnotatedA.java | 2 +- .../org/scijava/annotations/AnnotatedB.java | 2 +- .../org/scijava/annotations/AnnotatedC.java | 2 +- .../org/scijava/annotations/AnnotatedD.java | 30 +++++++++++++++++++ .../annotations/AnnotatedInnerClass.java | 2 +- .../java/org/scijava/annotations/Complex.java | 2 +- .../annotations/DirectoryIndexerTest.java | 2 +- .../annotations/EclipseHelperTest.java | 2 +- .../java/org/scijava/annotations/Fruit.java | 2 +- .../org/scijava/annotations/LegacyTest.java | 2 +- .../java/org/scijava/annotations/Simple.java | 2 +- .../scijava/app/DefaultStatusServiceTest.java | 2 +- .../scijava/command/CommandServiceTest.java | 2 +- .../scijava/command/InvalidCommandTest.java | 2 +- .../scijava/console/ConsoleServiceTest.java | 2 +- .../console/SystemPropertyArgumentTest.java | 2 +- .../scijava/convert/ConvertServiceTest.java | 2 +- .../org/scijava/convert/ConverterTest.java | 2 +- .../java/org/scijava/display/DisplayTest.java | 2 +- .../org/scijava/event/EventServiceTest.java | 2 +- .../org/scijava/io/BytesLocationTest.java | 2 +- .../java/org/scijava/io/DataHandleTest.java | 6 ++-- .../java/org/scijava/io/FileHandleTest.java | 6 ++-- .../java/org/scijava/io/FileLocationTest.java | 2 +- .../java/org/scijava/io/URILocationTest.java | 2 +- .../java/org/scijava/io/URLLocationTest.java | 2 +- .../java/org/scijava/log/LogServiceTest.java | 2 +- .../org/scijava/main/MainServiceTest.java | 6 ++-- .../org/scijava/menu/MenuServiceTest.java | 2 +- .../java/org/scijava/menu/ShadowMenuTest.java | 2 +- .../org/scijava/module/ModuleServiceTest.java | 2 +- .../org/scijava/object/ObjectIndexTest.java | 2 +- .../scijava/object/SortedObjectIndexTest.java | 2 +- .../java/org/scijava/options/OptionsTest.java | 2 +- .../org/scijava/plugin/PluginIndexTest.java | 2 +- .../org/scijava/plugin/PluginInfoTest.java | 2 +- .../org/scijava/prefs/PrefServiceTest.java | 2 +- .../script/AbstractScriptLanguageTest.java | 6 ++-- .../org/scijava/script/ScriptEngineTest.java | 2 +- .../org/scijava/script/ScriptFinderTest.java | 2 +- .../org/scijava/script/ScriptInfoTest.java | 2 +- .../org/scijava/script/ScriptServiceTest.java | 2 +- .../org/scijava/service/ServiceIndexTest.java | 2 +- .../java/org/scijava/test/TestUtilsTest.java | 2 +- .../org/scijava/thread/ThreadServiceTest.java | 2 +- .../java/org/scijava/util/AppUtilsTest.java | 2 +- .../java/org/scijava/util/ArrayUtilsTest.java | 7 +++-- .../java/org/scijava/util/BoolArrayTest.java | 2 +- .../java/org/scijava/util/ByteArrayTest.java | 2 +- .../java/org/scijava/util/CharArrayTest.java | 2 +- .../java/org/scijava/util/ClassUtilsTest.java | 2 +- .../java/org/scijava/util/ColorRGBTest.java | 2 +- .../org/scijava/util/ConversionUtilsTest.java | 2 +- .../org/scijava/util/DigestUtilsTest.java | 2 +- .../org/scijava/util/DoubleArrayTest.java | 2 +- .../java/org/scijava/util/FileUtilsTest.java | 2 +- .../java/org/scijava/util/FloatArrayTest.java | 2 +- .../org/scijava/util/GenericUtilsTest.java | 2 +- .../java/org/scijava/util/IntArrayTest.java | 2 +- .../scijava/util/LastRecentlyUsedTest.java | 2 +- .../java/org/scijava/util/LongArrayTest.java | 2 +- .../org/scijava/util/ObjectArrayTest.java | 2 +- src/test/java/org/scijava/util/POMTest.java | 2 +- .../org/scijava/util/PrimitiveArrayTest.java | 2 +- .../org/scijava/util/ProcessUtilsTest.java | 2 +- .../java/org/scijava/util/ShortArrayTest.java | 2 +- .../java/org/scijava/util/UnitUtilsTest.java | 2 +- 562 files changed, 609 insertions(+), 578 deletions(-) diff --git a/src/it/apt-test/pom.xml b/src/it/apt-test/pom.xml index 570cbb5ec..973fa0c14 100644 --- a/src/it/apt-test/pom.xml +++ b/src/it/apt-test/pom.xml @@ -3,7 +3,7 @@ #%L SciJava Common shared library for SciJava software. %% - Copyright (C) 2009 - 2015 Board of Regents of the University of + Copyright (C) 2009 - 2016 Board of Regents of the University of Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck Institute of Molecular Cell Biology and Genetics. %% diff --git a/src/it/apt-test/setup.bsh b/src/it/apt-test/setup.bsh index 82580215d..2b08f010f 100644 --- a/src/it/apt-test/setup.bsh +++ b/src/it/apt-test/setup.bsh @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/it/apt-test/src/main/java/org/scijava/annotation/its/Annotated.java b/src/it/apt-test/src/main/java/org/scijava/annotation/its/Annotated.java index 8b4abd6a7..ff5cdf3e8 100644 --- a/src/it/apt-test/src/main/java/org/scijava/annotation/its/Annotated.java +++ b/src/it/apt-test/src/main/java/org/scijava/annotation/its/Annotated.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/it/apt-test/src/main/java/org/scijava/annotation/its/CustomAnnotation.java b/src/it/apt-test/src/main/java/org/scijava/annotation/its/CustomAnnotation.java index 502f5596e..80c1db3ba 100644 --- a/src/it/apt-test/src/main/java/org/scijava/annotation/its/CustomAnnotation.java +++ b/src/it/apt-test/src/main/java/org/scijava/annotation/its/CustomAnnotation.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/it/apt-test/verify.bsh b/src/it/apt-test/verify.bsh index 2df5895fc..71a9c5efa 100644 --- a/src/it/apt-test/verify.bsh +++ b/src/it/apt-test/verify.bsh @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/it/settings.xml b/src/it/settings.xml index 7e66aef87..c7205a7b0 100644 --- a/src/it/settings.xml +++ b/src/it/settings.xml @@ -3,7 +3,7 @@ #%L SciJava Common shared library for SciJava software. %% - Copyright (C) 2009 - 2015 Board of Regents of the University of + Copyright (C) 2009 - 2016 Board of Regents of the University of Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck Institute of Molecular Cell Biology and Genetics. %% diff --git a/src/main/java/org/scijava/AbstractBasicDetails.java b/src/main/java/org/scijava/AbstractBasicDetails.java index 6688600b2..cfeae9f66 100644 --- a/src/main/java/org/scijava/AbstractBasicDetails.java +++ b/src/main/java/org/scijava/AbstractBasicDetails.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/AbstractContextual.java b/src/main/java/org/scijava/AbstractContextual.java index 74d95ab5d..71afa3108 100644 --- a/src/main/java/org/scijava/AbstractContextual.java +++ b/src/main/java/org/scijava/AbstractContextual.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/AbstractGateway.java b/src/main/java/org/scijava/AbstractGateway.java index 6e558530f..603e6a7a4 100644 --- a/src/main/java/org/scijava/AbstractGateway.java +++ b/src/main/java/org/scijava/AbstractGateway.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/AbstractUIDetails.java b/src/main/java/org/scijava/AbstractUIDetails.java index 409dcefd6..eccfbafe3 100644 --- a/src/main/java/org/scijava/AbstractUIDetails.java +++ b/src/main/java/org/scijava/AbstractUIDetails.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/BasicDetails.java b/src/main/java/org/scijava/BasicDetails.java index 4294428fc..3f061494a 100644 --- a/src/main/java/org/scijava/BasicDetails.java +++ b/src/main/java/org/scijava/BasicDetails.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Cancelable.java b/src/main/java/org/scijava/Cancelable.java index 9ce0ed337..2f738e626 100644 --- a/src/main/java/org/scijava/Cancelable.java +++ b/src/main/java/org/scijava/Cancelable.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Context.java b/src/main/java/org/scijava/Context.java index c3e02d9dc..6f3196c21 100644 --- a/src/main/java/org/scijava/Context.java +++ b/src/main/java/org/scijava/Context.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Contextual.java b/src/main/java/org/scijava/Contextual.java index dfd218345..30729043e 100644 --- a/src/main/java/org/scijava/Contextual.java +++ b/src/main/java/org/scijava/Contextual.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Disposable.java b/src/main/java/org/scijava/Disposable.java index 0d7c4ec38..41b397cb5 100644 --- a/src/main/java/org/scijava/Disposable.java +++ b/src/main/java/org/scijava/Disposable.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Gateway.java b/src/main/java/org/scijava/Gateway.java index 9a71bf025..a034682dd 100644 --- a/src/main/java/org/scijava/Gateway.java +++ b/src/main/java/org/scijava/Gateway.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Identifiable.java b/src/main/java/org/scijava/Identifiable.java index f1afd148c..e057780bb 100644 --- a/src/main/java/org/scijava/Identifiable.java +++ b/src/main/java/org/scijava/Identifiable.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Instantiable.java b/src/main/java/org/scijava/Instantiable.java index 867f29ea2..f3f174aa5 100644 --- a/src/main/java/org/scijava/Instantiable.java +++ b/src/main/java/org/scijava/Instantiable.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/InstantiableException.java b/src/main/java/org/scijava/InstantiableException.java index 43d976e1c..596e59ee9 100644 --- a/src/main/java/org/scijava/InstantiableException.java +++ b/src/main/java/org/scijava/InstantiableException.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ItemIO.java b/src/main/java/org/scijava/ItemIO.java index 6f79e2791..b45f5062e 100644 --- a/src/main/java/org/scijava/ItemIO.java +++ b/src/main/java/org/scijava/ItemIO.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ItemVisibility.java b/src/main/java/org/scijava/ItemVisibility.java index a5ebdfc9c..4055bc8f6 100644 --- a/src/main/java/org/scijava/ItemVisibility.java +++ b/src/main/java/org/scijava/ItemVisibility.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Locatable.java b/src/main/java/org/scijava/Locatable.java index 6cf85f384..3073a9266 100644 --- a/src/main/java/org/scijava/Locatable.java +++ b/src/main/java/org/scijava/Locatable.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/MenuEntry.java b/src/main/java/org/scijava/MenuEntry.java index 8d37b10a8..fa8fb4821 100644 --- a/src/main/java/org/scijava/MenuEntry.java +++ b/src/main/java/org/scijava/MenuEntry.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/MenuPath.java b/src/main/java/org/scijava/MenuPath.java index e44b86899..09b1677c7 100644 --- a/src/main/java/org/scijava/MenuPath.java +++ b/src/main/java/org/scijava/MenuPath.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Named.java b/src/main/java/org/scijava/Named.java index 2f7cac60d..5ddd9cb16 100644 --- a/src/main/java/org/scijava/Named.java +++ b/src/main/java/org/scijava/Named.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/NoSuchServiceException.java b/src/main/java/org/scijava/NoSuchServiceException.java index 225f6242e..09d23663c 100644 --- a/src/main/java/org/scijava/NoSuchServiceException.java +++ b/src/main/java/org/scijava/NoSuchServiceException.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/NullContextException.java b/src/main/java/org/scijava/NullContextException.java index 71a3d344d..acae73049 100644 --- a/src/main/java/org/scijava/NullContextException.java +++ b/src/main/java/org/scijava/NullContextException.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Optional.java b/src/main/java/org/scijava/Optional.java index 16ef8e8b3..dcfc568e3 100644 --- a/src/main/java/org/scijava/Optional.java +++ b/src/main/java/org/scijava/Optional.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Prioritized.java b/src/main/java/org/scijava/Prioritized.java index 57dd7a943..4aafbeb13 100644 --- a/src/main/java/org/scijava/Prioritized.java +++ b/src/main/java/org/scijava/Prioritized.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Priority.java b/src/main/java/org/scijava/Priority.java index af2774e97..2f0c06e29 100644 --- a/src/main/java/org/scijava/Priority.java +++ b/src/main/java/org/scijava/Priority.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/SciJava.java b/src/main/java/org/scijava/SciJava.java index e342ef380..8ae9c8e0c 100644 --- a/src/main/java/org/scijava/SciJava.java +++ b/src/main/java/org/scijava/SciJava.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Typed.java b/src/main/java/org/scijava/Typed.java index 9100a8400..be50d652d 100644 --- a/src/main/java/org/scijava/Typed.java +++ b/src/main/java/org/scijava/Typed.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/UIDetails.java b/src/main/java/org/scijava/UIDetails.java index 47428d198..94e6e5d12 100644 --- a/src/main/java/org/scijava/UIDetails.java +++ b/src/main/java/org/scijava/UIDetails.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Validated.java b/src/main/java/org/scijava/Validated.java index 9512db816..ea17c28ab 100644 --- a/src/main/java/org/scijava/Validated.java +++ b/src/main/java/org/scijava/Validated.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ValidityProblem.java b/src/main/java/org/scijava/ValidityProblem.java index a716e3679..a7f7134e4 100644 --- a/src/main/java/org/scijava/ValidityProblem.java +++ b/src/main/java/org/scijava/ValidityProblem.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/Versioned.java b/src/main/java/org/scijava/Versioned.java index ab3c9069a..793c0fc9d 100644 --- a/src/main/java/org/scijava/Versioned.java +++ b/src/main/java/org/scijava/Versioned.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/annotations/AbstractIndexWriter.java b/src/main/java/org/scijava/annotations/AbstractIndexWriter.java index 27a4f6592..fe58d191f 100644 --- a/src/main/java/org/scijava/annotations/AbstractIndexWriter.java +++ b/src/main/java/org/scijava/annotations/AbstractIndexWriter.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/annotations/AnnotationCombiner.java b/src/main/java/org/scijava/annotations/AnnotationCombiner.java index c224590df..5a5b7c127 100644 --- a/src/main/java/org/scijava/annotations/AnnotationCombiner.java +++ b/src/main/java/org/scijava/annotations/AnnotationCombiner.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/annotations/AnnotationProcessor.java b/src/main/java/org/scijava/annotations/AnnotationProcessor.java index cf473c161..70a54e3e1 100644 --- a/src/main/java/org/scijava/annotations/AnnotationProcessor.java +++ b/src/main/java/org/scijava/annotations/AnnotationProcessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java b/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java index a9276917a..4f752d324 100644 --- a/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java +++ b/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/annotations/DirectoryIndexer.java b/src/main/java/org/scijava/annotations/DirectoryIndexer.java index 133909d4a..5943d9abb 100644 --- a/src/main/java/org/scijava/annotations/DirectoryIndexer.java +++ b/src/main/java/org/scijava/annotations/DirectoryIndexer.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/annotations/EclipseHelper.java b/src/main/java/org/scijava/annotations/EclipseHelper.java index d460d49e5..b2f78d7e3 100644 --- a/src/main/java/org/scijava/annotations/EclipseHelper.java +++ b/src/main/java/org/scijava/annotations/EclipseHelper.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/annotations/Index.java b/src/main/java/org/scijava/annotations/Index.java index 9109f67a9..a6231532f 100644 --- a/src/main/java/org/scijava/annotations/Index.java +++ b/src/main/java/org/scijava/annotations/Index.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/annotations/IndexItem.java b/src/main/java/org/scijava/annotations/IndexItem.java index 0193c4cc5..a413ad57a 100644 --- a/src/main/java/org/scijava/annotations/IndexItem.java +++ b/src/main/java/org/scijava/annotations/IndexItem.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/annotations/IndexReader.java b/src/main/java/org/scijava/annotations/IndexReader.java index 0ba5ee233..5c613748e 100644 --- a/src/main/java/org/scijava/annotations/IndexReader.java +++ b/src/main/java/org/scijava/annotations/IndexReader.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/annotations/Indexable.java b/src/main/java/org/scijava/annotations/Indexable.java index 5486809f4..8204de4d1 100644 --- a/src/main/java/org/scijava/annotations/Indexable.java +++ b/src/main/java/org/scijava/annotations/Indexable.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/annotations/legacy/LegacyReader.java b/src/main/java/org/scijava/annotations/legacy/LegacyReader.java index 51307062d..5bf17928d 100644 --- a/src/main/java/org/scijava/annotations/legacy/LegacyReader.java +++ b/src/main/java/org/scijava/annotations/legacy/LegacyReader.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/app/AbstractApp.java b/src/main/java/org/scijava/app/AbstractApp.java index 0fe3142f0..ff26c35dc 100644 --- a/src/main/java/org/scijava/app/AbstractApp.java +++ b/src/main/java/org/scijava/app/AbstractApp.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/app/App.java b/src/main/java/org/scijava/app/App.java index e4edcca0f..2bfee1844 100644 --- a/src/main/java/org/scijava/app/App.java +++ b/src/main/java/org/scijava/app/App.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/app/AppService.java b/src/main/java/org/scijava/app/AppService.java index fedb50e38..8853b0d56 100644 --- a/src/main/java/org/scijava/app/AppService.java +++ b/src/main/java/org/scijava/app/AppService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/app/DefaultAppService.java b/src/main/java/org/scijava/app/DefaultAppService.java index a68223bef..903e9d283 100644 --- a/src/main/java/org/scijava/app/DefaultAppService.java +++ b/src/main/java/org/scijava/app/DefaultAppService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/app/DefaultStatusService.java b/src/main/java/org/scijava/app/DefaultStatusService.java index 22d481b06..3d15f6252 100644 --- a/src/main/java/org/scijava/app/DefaultStatusService.java +++ b/src/main/java/org/scijava/app/DefaultStatusService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/app/SciJavaApp.java b/src/main/java/org/scijava/app/SciJavaApp.java index 01499f353..97b1f54a5 100644 --- a/src/main/java/org/scijava/app/SciJavaApp.java +++ b/src/main/java/org/scijava/app/SciJavaApp.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/app/StatusService.java b/src/main/java/org/scijava/app/StatusService.java index fde11880a..8ae39845a 100644 --- a/src/main/java/org/scijava/app/StatusService.java +++ b/src/main/java/org/scijava/app/StatusService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/app/event/StatusEvent.java b/src/main/java/org/scijava/app/event/StatusEvent.java index 6edabc536..e6bfbcdb1 100644 --- a/src/main/java/org/scijava/app/event/StatusEvent.java +++ b/src/main/java/org/scijava/app/event/StatusEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/cache/CacheService.java b/src/main/java/org/scijava/cache/CacheService.java index a39a43eea..11981d906 100644 --- a/src/main/java/org/scijava/cache/CacheService.java +++ b/src/main/java/org/scijava/cache/CacheService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/cache/DefaultCacheService.java b/src/main/java/org/scijava/cache/DefaultCacheService.java index 2cf81d4ad..b1b305273 100644 --- a/src/main/java/org/scijava/cache/DefaultCacheService.java +++ b/src/main/java/org/scijava/cache/DefaultCacheService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/Command.java b/src/main/java/org/scijava/command/Command.java index d20e232e2..85f191060 100644 --- a/src/main/java/org/scijava/command/Command.java +++ b/src/main/java/org/scijava/command/Command.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/CommandInfo.java b/src/main/java/org/scijava/command/CommandInfo.java index 3cc61e6ec..49bfdb488 100644 --- a/src/main/java/org/scijava/command/CommandInfo.java +++ b/src/main/java/org/scijava/command/CommandInfo.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/CommandModule.java b/src/main/java/org/scijava/command/CommandModule.java index 7ae33aa2e..d392b6c58 100644 --- a/src/main/java/org/scijava/command/CommandModule.java +++ b/src/main/java/org/scijava/command/CommandModule.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/CommandModuleItem.java b/src/main/java/org/scijava/command/CommandModuleItem.java index 31fe5842f..4844db92d 100644 --- a/src/main/java/org/scijava/command/CommandModuleItem.java +++ b/src/main/java/org/scijava/command/CommandModuleItem.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/CommandService.java b/src/main/java/org/scijava/command/CommandService.java index 4f76f8e93..1659b088e 100644 --- a/src/main/java/org/scijava/command/CommandService.java +++ b/src/main/java/org/scijava/command/CommandService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/ContextCommand.java b/src/main/java/org/scijava/command/ContextCommand.java index e13198833..5d74e3863 100644 --- a/src/main/java/org/scijava/command/ContextCommand.java +++ b/src/main/java/org/scijava/command/ContextCommand.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/DefaultCommandService.java b/src/main/java/org/scijava/command/DefaultCommandService.java index 3246e9afc..71a4054fd 100644 --- a/src/main/java/org/scijava/command/DefaultCommandService.java +++ b/src/main/java/org/scijava/command/DefaultCommandService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/DynamicCommand.java b/src/main/java/org/scijava/command/DynamicCommand.java index ff622847b..dac4df9ee 100644 --- a/src/main/java/org/scijava/command/DynamicCommand.java +++ b/src/main/java/org/scijava/command/DynamicCommand.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/DynamicCommandInfo.java b/src/main/java/org/scijava/command/DynamicCommandInfo.java index 39ac54354..a6b9cc507 100644 --- a/src/main/java/org/scijava/command/DynamicCommandInfo.java +++ b/src/main/java/org/scijava/command/DynamicCommandInfo.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/Interactive.java b/src/main/java/org/scijava/command/Interactive.java index 0ea3369ef..9f8b389b3 100644 --- a/src/main/java/org/scijava/command/Interactive.java +++ b/src/main/java/org/scijava/command/Interactive.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/InteractiveCommand.java b/src/main/java/org/scijava/command/InteractiveCommand.java index b1f14d62a..a1b465ab7 100644 --- a/src/main/java/org/scijava/command/InteractiveCommand.java +++ b/src/main/java/org/scijava/command/InteractiveCommand.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/ModuleCommand.java b/src/main/java/org/scijava/command/ModuleCommand.java index 211f3b5ca..fe3f47561 100644 --- a/src/main/java/org/scijava/command/ModuleCommand.java +++ b/src/main/java/org/scijava/command/ModuleCommand.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/Previewable.java b/src/main/java/org/scijava/command/Previewable.java index fcea8a72e..a853bb355 100644 --- a/src/main/java/org/scijava/command/Previewable.java +++ b/src/main/java/org/scijava/command/Previewable.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/UnimplementedCommand.java b/src/main/java/org/scijava/command/UnimplementedCommand.java index 2565239f0..43c967bb3 100644 --- a/src/main/java/org/scijava/command/UnimplementedCommand.java +++ b/src/main/java/org/scijava/command/UnimplementedCommand.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/command/console/RunArgument.java b/src/main/java/org/scijava/command/console/RunArgument.java index 469608b59..da6f38bfc 100644 --- a/src/main/java/org/scijava/command/console/RunArgument.java +++ b/src/main/java/org/scijava/command/console/RunArgument.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/console/AbstractConsoleArgument.java b/src/main/java/org/scijava/console/AbstractConsoleArgument.java index 4112bfc9b..f6806ab3d 100644 --- a/src/main/java/org/scijava/console/AbstractConsoleArgument.java +++ b/src/main/java/org/scijava/console/AbstractConsoleArgument.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/console/ConsoleArgument.java b/src/main/java/org/scijava/console/ConsoleArgument.java index 4a9232da2..18f3762f3 100644 --- a/src/main/java/org/scijava/console/ConsoleArgument.java +++ b/src/main/java/org/scijava/console/ConsoleArgument.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/console/ConsoleService.java b/src/main/java/org/scijava/console/ConsoleService.java index 51d1d7f0b..77cef9477 100644 --- a/src/main/java/org/scijava/console/ConsoleService.java +++ b/src/main/java/org/scijava/console/ConsoleService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/console/DefaultConsoleService.java b/src/main/java/org/scijava/console/DefaultConsoleService.java index 75821a5db..22483a459 100644 --- a/src/main/java/org/scijava/console/DefaultConsoleService.java +++ b/src/main/java/org/scijava/console/DefaultConsoleService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/console/MultiOutputStream.java b/src/main/java/org/scijava/console/MultiOutputStream.java index 655575082..0b596af93 100644 --- a/src/main/java/org/scijava/console/MultiOutputStream.java +++ b/src/main/java/org/scijava/console/MultiOutputStream.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/console/MultiPrintStream.java b/src/main/java/org/scijava/console/MultiPrintStream.java index 13c2ff1f5..2261c533a 100644 --- a/src/main/java/org/scijava/console/MultiPrintStream.java +++ b/src/main/java/org/scijava/console/MultiPrintStream.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/console/OutputEvent.java b/src/main/java/org/scijava/console/OutputEvent.java index cddafcb19..6d81ebdef 100644 --- a/src/main/java/org/scijava/console/OutputEvent.java +++ b/src/main/java/org/scijava/console/OutputEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/console/OutputListener.java b/src/main/java/org/scijava/console/OutputListener.java index 9c9111374..6636c1ad6 100644 --- a/src/main/java/org/scijava/console/OutputListener.java +++ b/src/main/java/org/scijava/console/OutputListener.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/console/SystemPropertyArgument.java b/src/main/java/org/scijava/console/SystemPropertyArgument.java index f8b968458..8202f8ce9 100644 --- a/src/main/java/org/scijava/console/SystemPropertyArgument.java +++ b/src/main/java/org/scijava/console/SystemPropertyArgument.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/convert/AbstractConvertService.java b/src/main/java/org/scijava/convert/AbstractConvertService.java index 200460a60..3f9a37ef9 100644 --- a/src/main/java/org/scijava/convert/AbstractConvertService.java +++ b/src/main/java/org/scijava/convert/AbstractConvertService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/convert/AbstractConverter.java b/src/main/java/org/scijava/convert/AbstractConverter.java index 26602d0e3..058624d94 100644 --- a/src/main/java/org/scijava/convert/AbstractConverter.java +++ b/src/main/java/org/scijava/convert/AbstractConverter.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/convert/ArrayConverters.java b/src/main/java/org/scijava/convert/ArrayConverters.java index 7971c0872..f2d129cd1 100644 --- a/src/main/java/org/scijava/convert/ArrayConverters.java +++ b/src/main/java/org/scijava/convert/ArrayConverters.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/convert/CastingConverter.java b/src/main/java/org/scijava/convert/CastingConverter.java index d849d5cd4..00ebb1f0b 100644 --- a/src/main/java/org/scijava/convert/CastingConverter.java +++ b/src/main/java/org/scijava/convert/CastingConverter.java @@ -8,13 +8,13 @@ * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/scijava/convert/ConversionRequest.java b/src/main/java/org/scijava/convert/ConversionRequest.java index 4ca2b0fdd..1b0a211f0 100644 --- a/src/main/java/org/scijava/convert/ConversionRequest.java +++ b/src/main/java/org/scijava/convert/ConversionRequest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/convert/ConvertService.java b/src/main/java/org/scijava/convert/ConvertService.java index 3feec3e81..555a270bd 100644 --- a/src/main/java/org/scijava/convert/ConvertService.java +++ b/src/main/java/org/scijava/convert/ConvertService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/convert/Converter.java b/src/main/java/org/scijava/convert/Converter.java index 2ad015dfe..157a7a744 100644 --- a/src/main/java/org/scijava/convert/Converter.java +++ b/src/main/java/org/scijava/convert/Converter.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/convert/DefaultConvertService.java b/src/main/java/org/scijava/convert/DefaultConvertService.java index b28ce6383..1f2318a95 100644 --- a/src/main/java/org/scijava/convert/DefaultConvertService.java +++ b/src/main/java/org/scijava/convert/DefaultConvertService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/convert/DefaultConverter.java b/src/main/java/org/scijava/convert/DefaultConverter.java index 4aa872960..803483dc3 100644 --- a/src/main/java/org/scijava/convert/DefaultConverter.java +++ b/src/main/java/org/scijava/convert/DefaultConverter.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/convert/NullConverter.java b/src/main/java/org/scijava/convert/NullConverter.java index 6eb29874b..f3686ea2f 100644 --- a/src/main/java/org/scijava/convert/NullConverter.java +++ b/src/main/java/org/scijava/convert/NullConverter.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/convert/PrimitiveArrayUnwrapper.java b/src/main/java/org/scijava/convert/PrimitiveArrayUnwrapper.java index 7b63df197..9a821393b 100644 --- a/src/main/java/org/scijava/convert/PrimitiveArrayUnwrapper.java +++ b/src/main/java/org/scijava/convert/PrimitiveArrayUnwrapper.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/convert/PrimitiveArrayWrapper.java b/src/main/java/org/scijava/convert/PrimitiveArrayWrapper.java index 0c3a7992b..a6d421608 100644 --- a/src/main/java/org/scijava/convert/PrimitiveArrayWrapper.java +++ b/src/main/java/org/scijava/convert/PrimitiveArrayWrapper.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/AbstractDisplay.java b/src/main/java/org/scijava/display/AbstractDisplay.java index 9c4d43669..1b84f07b9 100644 --- a/src/main/java/org/scijava/display/AbstractDisplay.java +++ b/src/main/java/org/scijava/display/AbstractDisplay.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/ActiveDisplayPreprocessor.java b/src/main/java/org/scijava/display/ActiveDisplayPreprocessor.java index 09ba6c725..916bc2d0a 100644 --- a/src/main/java/org/scijava/display/ActiveDisplayPreprocessor.java +++ b/src/main/java/org/scijava/display/ActiveDisplayPreprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/DefaultDisplay.java b/src/main/java/org/scijava/display/DefaultDisplay.java index 2041330a6..cad0c02f3 100644 --- a/src/main/java/org/scijava/display/DefaultDisplay.java +++ b/src/main/java/org/scijava/display/DefaultDisplay.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/DefaultDisplayService.java b/src/main/java/org/scijava/display/DefaultDisplayService.java index f193decfb..ec11b5c20 100644 --- a/src/main/java/org/scijava/display/DefaultDisplayService.java +++ b/src/main/java/org/scijava/display/DefaultDisplayService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/DefaultTextDisplay.java b/src/main/java/org/scijava/display/DefaultTextDisplay.java index de8b1cfba..2b5940087 100644 --- a/src/main/java/org/scijava/display/DefaultTextDisplay.java +++ b/src/main/java/org/scijava/display/DefaultTextDisplay.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/Display.java b/src/main/java/org/scijava/display/Display.java index 6405499c1..019a53443 100644 --- a/src/main/java/org/scijava/display/Display.java +++ b/src/main/java/org/scijava/display/Display.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/DisplayPostprocessor.java b/src/main/java/org/scijava/display/DisplayPostprocessor.java index eea4a5c42..092122db3 100644 --- a/src/main/java/org/scijava/display/DisplayPostprocessor.java +++ b/src/main/java/org/scijava/display/DisplayPostprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/DisplayService.java b/src/main/java/org/scijava/display/DisplayService.java index cb2abddbb..98dd2b6da 100644 --- a/src/main/java/org/scijava/display/DisplayService.java +++ b/src/main/java/org/scijava/display/DisplayService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/Displayable.java b/src/main/java/org/scijava/display/Displayable.java index 292e0b53d..ffc22461e 100644 --- a/src/main/java/org/scijava/display/Displayable.java +++ b/src/main/java/org/scijava/display/Displayable.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/TextDisplay.java b/src/main/java/org/scijava/display/TextDisplay.java index 3c06c5ef0..5da87694c 100644 --- a/src/main/java/org/scijava/display/TextDisplay.java +++ b/src/main/java/org/scijava/display/TextDisplay.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/DisplayActivatedEvent.java b/src/main/java/org/scijava/display/event/DisplayActivatedEvent.java index 315f0215f..9a81b32f1 100644 --- a/src/main/java/org/scijava/display/event/DisplayActivatedEvent.java +++ b/src/main/java/org/scijava/display/event/DisplayActivatedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/DisplayCreatedEvent.java b/src/main/java/org/scijava/display/event/DisplayCreatedEvent.java index 6e45ab5ec..c1ef3e70d 100644 --- a/src/main/java/org/scijava/display/event/DisplayCreatedEvent.java +++ b/src/main/java/org/scijava/display/event/DisplayCreatedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/DisplayDeletedEvent.java b/src/main/java/org/scijava/display/event/DisplayDeletedEvent.java index 24a74e2a7..37889a187 100644 --- a/src/main/java/org/scijava/display/event/DisplayDeletedEvent.java +++ b/src/main/java/org/scijava/display/event/DisplayDeletedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/DisplayEvent.java b/src/main/java/org/scijava/display/event/DisplayEvent.java index 4637037b9..12ae2b5de 100644 --- a/src/main/java/org/scijava/display/event/DisplayEvent.java +++ b/src/main/java/org/scijava/display/event/DisplayEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/DisplayUpdatedEvent.java b/src/main/java/org/scijava/display/event/DisplayUpdatedEvent.java index f0e40254d..9fa301481 100644 --- a/src/main/java/org/scijava/display/event/DisplayUpdatedEvent.java +++ b/src/main/java/org/scijava/display/event/DisplayUpdatedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/InputEvent.java b/src/main/java/org/scijava/display/event/input/InputEvent.java index ca46e80e7..7855ae923 100644 --- a/src/main/java/org/scijava/display/event/input/InputEvent.java +++ b/src/main/java/org/scijava/display/event/input/InputEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/KyEvent.java b/src/main/java/org/scijava/display/event/input/KyEvent.java index d31534b81..8892b20a1 100644 --- a/src/main/java/org/scijava/display/event/input/KyEvent.java +++ b/src/main/java/org/scijava/display/event/input/KyEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/KyPressedEvent.java b/src/main/java/org/scijava/display/event/input/KyPressedEvent.java index 28f326837..1d936b33d 100644 --- a/src/main/java/org/scijava/display/event/input/KyPressedEvent.java +++ b/src/main/java/org/scijava/display/event/input/KyPressedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/KyReleasedEvent.java b/src/main/java/org/scijava/display/event/input/KyReleasedEvent.java index 593e557f7..3604fe6b6 100644 --- a/src/main/java/org/scijava/display/event/input/KyReleasedEvent.java +++ b/src/main/java/org/scijava/display/event/input/KyReleasedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/KyTypedEvent.java b/src/main/java/org/scijava/display/event/input/KyTypedEvent.java index 568aec3ba..553a791b6 100644 --- a/src/main/java/org/scijava/display/event/input/KyTypedEvent.java +++ b/src/main/java/org/scijava/display/event/input/KyTypedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/MsButtonEvent.java b/src/main/java/org/scijava/display/event/input/MsButtonEvent.java index bf0a38d98..6a4a41ed6 100644 --- a/src/main/java/org/scijava/display/event/input/MsButtonEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsButtonEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/MsClickedEvent.java b/src/main/java/org/scijava/display/event/input/MsClickedEvent.java index 6d180c2fe..71fefc267 100644 --- a/src/main/java/org/scijava/display/event/input/MsClickedEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsClickedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/MsDraggedEvent.java b/src/main/java/org/scijava/display/event/input/MsDraggedEvent.java index bed510b88..9a2157b06 100644 --- a/src/main/java/org/scijava/display/event/input/MsDraggedEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsDraggedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/MsEnteredEvent.java b/src/main/java/org/scijava/display/event/input/MsEnteredEvent.java index ab1e8843c..e9813d94e 100644 --- a/src/main/java/org/scijava/display/event/input/MsEnteredEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsEnteredEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/MsEvent.java b/src/main/java/org/scijava/display/event/input/MsEvent.java index 61f4614c0..e000e0a09 100644 --- a/src/main/java/org/scijava/display/event/input/MsEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/MsExitedEvent.java b/src/main/java/org/scijava/display/event/input/MsExitedEvent.java index f08d93bb6..eb6ad2716 100644 --- a/src/main/java/org/scijava/display/event/input/MsExitedEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsExitedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/MsMovedEvent.java b/src/main/java/org/scijava/display/event/input/MsMovedEvent.java index 0afc917a7..e5d367ec0 100644 --- a/src/main/java/org/scijava/display/event/input/MsMovedEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsMovedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/MsPressedEvent.java b/src/main/java/org/scijava/display/event/input/MsPressedEvent.java index 841f5c5de..44271958d 100644 --- a/src/main/java/org/scijava/display/event/input/MsPressedEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsPressedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/MsReleasedEvent.java b/src/main/java/org/scijava/display/event/input/MsReleasedEvent.java index 4328779c0..4a7cf0a49 100644 --- a/src/main/java/org/scijava/display/event/input/MsReleasedEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsReleasedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/input/MsWheelEvent.java b/src/main/java/org/scijava/display/event/input/MsWheelEvent.java index 4908ff5d9..d33d2d6d4 100644 --- a/src/main/java/org/scijava/display/event/input/MsWheelEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsWheelEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/window/WinActivatedEvent.java b/src/main/java/org/scijava/display/event/window/WinActivatedEvent.java index 8ee0f7938..8ec498c73 100644 --- a/src/main/java/org/scijava/display/event/window/WinActivatedEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinActivatedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/window/WinClosedEvent.java b/src/main/java/org/scijava/display/event/window/WinClosedEvent.java index 684c9abf4..450883dd4 100644 --- a/src/main/java/org/scijava/display/event/window/WinClosedEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinClosedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/window/WinClosingEvent.java b/src/main/java/org/scijava/display/event/window/WinClosingEvent.java index 51d93a605..b3eedf74e 100644 --- a/src/main/java/org/scijava/display/event/window/WinClosingEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinClosingEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/window/WinDeactivatedEvent.java b/src/main/java/org/scijava/display/event/window/WinDeactivatedEvent.java index 8fb256d7f..3d9f08236 100644 --- a/src/main/java/org/scijava/display/event/window/WinDeactivatedEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinDeactivatedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/window/WinDeiconifiedEvent.java b/src/main/java/org/scijava/display/event/window/WinDeiconifiedEvent.java index d1a58d19c..1f66c2861 100644 --- a/src/main/java/org/scijava/display/event/window/WinDeiconifiedEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinDeiconifiedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/window/WinEvent.java b/src/main/java/org/scijava/display/event/window/WinEvent.java index 8b9bd41c5..af3a4fb21 100644 --- a/src/main/java/org/scijava/display/event/window/WinEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/window/WinIconifiedEvent.java b/src/main/java/org/scijava/display/event/window/WinIconifiedEvent.java index 2333ccd22..740de597b 100644 --- a/src/main/java/org/scijava/display/event/window/WinIconifiedEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinIconifiedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/display/event/window/WinOpenedEvent.java b/src/main/java/org/scijava/display/event/window/WinOpenedEvent.java index 1a3904883..2cc54a73f 100644 --- a/src/main/java/org/scijava/display/event/window/WinOpenedEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinOpenedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/event/ContextDisposingEvent.java b/src/main/java/org/scijava/event/ContextDisposingEvent.java index dfee4e284..7df001f65 100644 --- a/src/main/java/org/scijava/event/ContextDisposingEvent.java +++ b/src/main/java/org/scijava/event/ContextDisposingEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/event/DefaultEventBus.java b/src/main/java/org/scijava/event/DefaultEventBus.java index cfd847797..f9a7fbe14 100644 --- a/src/main/java/org/scijava/event/DefaultEventBus.java +++ b/src/main/java/org/scijava/event/DefaultEventBus.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/event/DefaultEventHistory.java b/src/main/java/org/scijava/event/DefaultEventHistory.java index 72eb38add..541528fcd 100644 --- a/src/main/java/org/scijava/event/DefaultEventHistory.java +++ b/src/main/java/org/scijava/event/DefaultEventHistory.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/event/DefaultEventService.java b/src/main/java/org/scijava/event/DefaultEventService.java index 855cd8fec..3e41c1023 100644 --- a/src/main/java/org/scijava/event/DefaultEventService.java +++ b/src/main/java/org/scijava/event/DefaultEventService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/event/EventDetails.java b/src/main/java/org/scijava/event/EventDetails.java index de79229e0..4f210c0ee 100644 --- a/src/main/java/org/scijava/event/EventDetails.java +++ b/src/main/java/org/scijava/event/EventDetails.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/event/EventHandler.java b/src/main/java/org/scijava/event/EventHandler.java index 93f94c4b5..6fdfb967f 100644 --- a/src/main/java/org/scijava/event/EventHandler.java +++ b/src/main/java/org/scijava/event/EventHandler.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/event/EventHistory.java b/src/main/java/org/scijava/event/EventHistory.java index 128a5b469..8cd782253 100644 --- a/src/main/java/org/scijava/event/EventHistory.java +++ b/src/main/java/org/scijava/event/EventHistory.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/event/EventHistoryListener.java b/src/main/java/org/scijava/event/EventHistoryListener.java index 8d813b798..acf0c07c8 100644 --- a/src/main/java/org/scijava/event/EventHistoryListener.java +++ b/src/main/java/org/scijava/event/EventHistoryListener.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/event/EventService.java b/src/main/java/org/scijava/event/EventService.java index 4f269c36d..fcacb1b46 100644 --- a/src/main/java/org/scijava/event/EventService.java +++ b/src/main/java/org/scijava/event/EventService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/event/EventSubscriber.java b/src/main/java/org/scijava/event/EventSubscriber.java index 7b7ddf9a6..69796fe43 100644 --- a/src/main/java/org/scijava/event/EventSubscriber.java +++ b/src/main/java/org/scijava/event/EventSubscriber.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/event/SciJavaEvent.java b/src/main/java/org/scijava/event/SciJavaEvent.java index f30b9c7fb..13920ce43 100644 --- a/src/main/java/org/scijava/event/SciJavaEvent.java +++ b/src/main/java/org/scijava/event/SciJavaEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/input/Accelerator.java b/src/main/java/org/scijava/input/Accelerator.java index ea745910f..3c83dd0d5 100644 --- a/src/main/java/org/scijava/input/Accelerator.java +++ b/src/main/java/org/scijava/input/Accelerator.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/input/DefaultInputService.java b/src/main/java/org/scijava/input/DefaultInputService.java index 3e2c47495..d806b9042 100644 --- a/src/main/java/org/scijava/input/DefaultInputService.java +++ b/src/main/java/org/scijava/input/DefaultInputService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/input/InputModifiers.java b/src/main/java/org/scijava/input/InputModifiers.java index 0464c301f..f7da0c4b7 100644 --- a/src/main/java/org/scijava/input/InputModifiers.java +++ b/src/main/java/org/scijava/input/InputModifiers.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/input/InputService.java b/src/main/java/org/scijava/input/InputService.java index b0cf29958..467788e0e 100644 --- a/src/main/java/org/scijava/input/InputService.java +++ b/src/main/java/org/scijava/input/InputService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/input/KeyCode.java b/src/main/java/org/scijava/input/KeyCode.java index fe8b8d4a7..a01ff8663 100644 --- a/src/main/java/org/scijava/input/KeyCode.java +++ b/src/main/java/org/scijava/input/KeyCode.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/input/MouseCursor.java b/src/main/java/org/scijava/input/MouseCursor.java index 39e7f3061..f55d0c768 100644 --- a/src/main/java/org/scijava/input/MouseCursor.java +++ b/src/main/java/org/scijava/input/MouseCursor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/AbstractDataHandle.java b/src/main/java/org/scijava/io/AbstractDataHandle.java index cfb917810..64ac47c77 100644 --- a/src/main/java/org/scijava/io/AbstractDataHandle.java +++ b/src/main/java/org/scijava/io/AbstractDataHandle.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/AbstractIOPlugin.java b/src/main/java/org/scijava/io/AbstractIOPlugin.java index 9091ae38f..d7c526ad7 100644 --- a/src/main/java/org/scijava/io/AbstractIOPlugin.java +++ b/src/main/java/org/scijava/io/AbstractIOPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/AbstractLocation.java b/src/main/java/org/scijava/io/AbstractLocation.java index ce0e12ad6..fe40a36d8 100644 --- a/src/main/java/org/scijava/io/AbstractLocation.java +++ b/src/main/java/org/scijava/io/AbstractLocation.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/BytesLocation.java b/src/main/java/org/scijava/io/BytesLocation.java index c58ddb0c6..f0cf50b4b 100644 --- a/src/main/java/org/scijava/io/BytesLocation.java +++ b/src/main/java/org/scijava/io/BytesLocation.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/DataHandle.java b/src/main/java/org/scijava/io/DataHandle.java index 24162ef77..d70be75dd 100644 --- a/src/main/java/org/scijava/io/DataHandle.java +++ b/src/main/java/org/scijava/io/DataHandle.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/DataHandleInputStream.java b/src/main/java/org/scijava/io/DataHandleInputStream.java index 1d341f449..01c013a6b 100644 --- a/src/main/java/org/scijava/io/DataHandleInputStream.java +++ b/src/main/java/org/scijava/io/DataHandleInputStream.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/DataHandleOutputStream.java b/src/main/java/org/scijava/io/DataHandleOutputStream.java index 42ec2d104..4e03766ef 100644 --- a/src/main/java/org/scijava/io/DataHandleOutputStream.java +++ b/src/main/java/org/scijava/io/DataHandleOutputStream.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/DataHandleService.java b/src/main/java/org/scijava/io/DataHandleService.java index eaf93e28c..caec74a59 100644 --- a/src/main/java/org/scijava/io/DataHandleService.java +++ b/src/main/java/org/scijava/io/DataHandleService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/DefaultDataHandleService.java b/src/main/java/org/scijava/io/DefaultDataHandleService.java index 2be00711f..92882cbd1 100644 --- a/src/main/java/org/scijava/io/DefaultDataHandleService.java +++ b/src/main/java/org/scijava/io/DefaultDataHandleService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/DefaultIOService.java b/src/main/java/org/scijava/io/DefaultIOService.java index 2ad822f72..173ebc664 100644 --- a/src/main/java/org/scijava/io/DefaultIOService.java +++ b/src/main/java/org/scijava/io/DefaultIOService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/DefaultRecentFileService.java b/src/main/java/org/scijava/io/DefaultRecentFileService.java index ce0ddd9e6..90a5b0198 100644 --- a/src/main/java/org/scijava/io/DefaultRecentFileService.java +++ b/src/main/java/org/scijava/io/DefaultRecentFileService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/FileHandle.java b/src/main/java/org/scijava/io/FileHandle.java index 045c254fd..53a604f21 100644 --- a/src/main/java/org/scijava/io/FileHandle.java +++ b/src/main/java/org/scijava/io/FileHandle.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/FileLocation.java b/src/main/java/org/scijava/io/FileLocation.java index 757c4b738..7ebb80119 100644 --- a/src/main/java/org/scijava/io/FileLocation.java +++ b/src/main/java/org/scijava/io/FileLocation.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/IOPlugin.java b/src/main/java/org/scijava/io/IOPlugin.java index aacaade90..e000c72ab 100644 --- a/src/main/java/org/scijava/io/IOPlugin.java +++ b/src/main/java/org/scijava/io/IOPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/IOService.java b/src/main/java/org/scijava/io/IOService.java index b82fd0f1e..5f64ba7ad 100644 --- a/src/main/java/org/scijava/io/IOService.java +++ b/src/main/java/org/scijava/io/IOService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/Location.java b/src/main/java/org/scijava/io/Location.java index 4f08be1b9..a02abbf25 100644 --- a/src/main/java/org/scijava/io/Location.java +++ b/src/main/java/org/scijava/io/Location.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/RecentFileService.java b/src/main/java/org/scijava/io/RecentFileService.java index 6f1d606bf..ea6220426 100644 --- a/src/main/java/org/scijava/io/RecentFileService.java +++ b/src/main/java/org/scijava/io/RecentFileService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/URILocation.java b/src/main/java/org/scijava/io/URILocation.java index 87f9e7d4d..cb2d2022c 100644 --- a/src/main/java/org/scijava/io/URILocation.java +++ b/src/main/java/org/scijava/io/URILocation.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/URLLocation.java b/src/main/java/org/scijava/io/URLLocation.java index 4148d668a..54d8fbb06 100644 --- a/src/main/java/org/scijava/io/URLLocation.java +++ b/src/main/java/org/scijava/io/URLLocation.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/console/OpenArgument.java b/src/main/java/org/scijava/io/console/OpenArgument.java index 1f5457e6b..9b271ed4c 100644 --- a/src/main/java/org/scijava/io/console/OpenArgument.java +++ b/src/main/java/org/scijava/io/console/OpenArgument.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/event/DataOpenedEvent.java b/src/main/java/org/scijava/io/event/DataOpenedEvent.java index 03028ecb2..893ad63b6 100644 --- a/src/main/java/org/scijava/io/event/DataOpenedEvent.java +++ b/src/main/java/org/scijava/io/event/DataOpenedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/event/DataSavedEvent.java b/src/main/java/org/scijava/io/event/DataSavedEvent.java index 8f5f2955a..fe911efa9 100644 --- a/src/main/java/org/scijava/io/event/DataSavedEvent.java +++ b/src/main/java/org/scijava/io/event/DataSavedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/io/event/IOEvent.java b/src/main/java/org/scijava/io/event/IOEvent.java index d678ae19c..9140893c2 100644 --- a/src/main/java/org/scijava/io/event/IOEvent.java +++ b/src/main/java/org/scijava/io/event/IOEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/log/AbstractLogService.java b/src/main/java/org/scijava/log/AbstractLogService.java index 96dc08240..135c90dd3 100644 --- a/src/main/java/org/scijava/log/AbstractLogService.java +++ b/src/main/java/org/scijava/log/AbstractLogService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/log/DefaultUncaughtExceptionHandler.java b/src/main/java/org/scijava/log/DefaultUncaughtExceptionHandler.java index 9270e1f9f..6b1dbd7cd 100644 --- a/src/main/java/org/scijava/log/DefaultUncaughtExceptionHandler.java +++ b/src/main/java/org/scijava/log/DefaultUncaughtExceptionHandler.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/log/LogService.java b/src/main/java/org/scijava/log/LogService.java index 190077f0f..e1fae2013 100644 --- a/src/main/java/org/scijava/log/LogService.java +++ b/src/main/java/org/scijava/log/LogService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/log/StderrLogService.java b/src/main/java/org/scijava/log/StderrLogService.java index 9524a5427..5d7fc4688 100644 --- a/src/main/java/org/scijava/log/StderrLogService.java +++ b/src/main/java/org/scijava/log/StderrLogService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/main/DefaultMainService.java b/src/main/java/org/scijava/main/DefaultMainService.java index 9b56e45b2..31de081fd 100644 --- a/src/main/java/org/scijava/main/DefaultMainService.java +++ b/src/main/java/org/scijava/main/DefaultMainService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/main/MainService.java b/src/main/java/org/scijava/main/MainService.java index ee99373c3..fcd15831c 100644 --- a/src/main/java/org/scijava/main/MainService.java +++ b/src/main/java/org/scijava/main/MainService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/main/console/MainArgument.java b/src/main/java/org/scijava/main/console/MainArgument.java index 2ed60c713..45551f2a9 100644 --- a/src/main/java/org/scijava/main/console/MainArgument.java +++ b/src/main/java/org/scijava/main/console/MainArgument.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/menu/AbstractMenuCreator.java b/src/main/java/org/scijava/menu/AbstractMenuCreator.java index 0b5951096..ab476c375 100644 --- a/src/main/java/org/scijava/menu/AbstractMenuCreator.java +++ b/src/main/java/org/scijava/menu/AbstractMenuCreator.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/menu/DefaultMenuService.java b/src/main/java/org/scijava/menu/DefaultMenuService.java index 8072c50f6..d128cca83 100644 --- a/src/main/java/org/scijava/menu/DefaultMenuService.java +++ b/src/main/java/org/scijava/menu/DefaultMenuService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/menu/MenuConstants.java b/src/main/java/org/scijava/menu/MenuConstants.java index 101e1d125..336a1832f 100644 --- a/src/main/java/org/scijava/menu/MenuConstants.java +++ b/src/main/java/org/scijava/menu/MenuConstants.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/menu/MenuCreator.java b/src/main/java/org/scijava/menu/MenuCreator.java index 872efd0a0..45d7c7402 100644 --- a/src/main/java/org/scijava/menu/MenuCreator.java +++ b/src/main/java/org/scijava/menu/MenuCreator.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/menu/MenuService.java b/src/main/java/org/scijava/menu/MenuService.java index 5970c3db8..000ac5bcd 100644 --- a/src/main/java/org/scijava/menu/MenuService.java +++ b/src/main/java/org/scijava/menu/MenuService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/menu/ShadowMenu.java b/src/main/java/org/scijava/menu/ShadowMenu.java index 4ba28d799..a2c87b573 100644 --- a/src/main/java/org/scijava/menu/ShadowMenu.java +++ b/src/main/java/org/scijava/menu/ShadowMenu.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/menu/ShadowMenuIterator.java b/src/main/java/org/scijava/menu/ShadowMenuIterator.java index cb9e48353..884cd5ab5 100644 --- a/src/main/java/org/scijava/menu/ShadowMenuIterator.java +++ b/src/main/java/org/scijava/menu/ShadowMenuIterator.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/menu/event/MenuEvent.java b/src/main/java/org/scijava/menu/event/MenuEvent.java index 2d5ac867b..16c1b5de2 100644 --- a/src/main/java/org/scijava/menu/event/MenuEvent.java +++ b/src/main/java/org/scijava/menu/event/MenuEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/menu/event/MenusAddedEvent.java b/src/main/java/org/scijava/menu/event/MenusAddedEvent.java index a9a7163ad..03d00ae91 100644 --- a/src/main/java/org/scijava/menu/event/MenusAddedEvent.java +++ b/src/main/java/org/scijava/menu/event/MenusAddedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/menu/event/MenusRemovedEvent.java b/src/main/java/org/scijava/menu/event/MenusRemovedEvent.java index b097317e1..3214051df 100644 --- a/src/main/java/org/scijava/menu/event/MenusRemovedEvent.java +++ b/src/main/java/org/scijava/menu/event/MenusRemovedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/menu/event/MenusUpdatedEvent.java b/src/main/java/org/scijava/menu/event/MenusUpdatedEvent.java index 9980be59d..cc6da3099 100644 --- a/src/main/java/org/scijava/menu/event/MenusUpdatedEvent.java +++ b/src/main/java/org/scijava/menu/event/MenusUpdatedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/AbstractModule.java b/src/main/java/org/scijava/module/AbstractModule.java index b4c0c1922..0406bdb71 100644 --- a/src/main/java/org/scijava/module/AbstractModule.java +++ b/src/main/java/org/scijava/module/AbstractModule.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/AbstractModuleInfo.java b/src/main/java/org/scijava/module/AbstractModuleInfo.java index 551664197..1b6461b6b 100644 --- a/src/main/java/org/scijava/module/AbstractModuleInfo.java +++ b/src/main/java/org/scijava/module/AbstractModuleInfo.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/AbstractModuleItem.java b/src/main/java/org/scijava/module/AbstractModuleItem.java index 0ae2f9206..c6d84537d 100644 --- a/src/main/java/org/scijava/module/AbstractModuleItem.java +++ b/src/main/java/org/scijava/module/AbstractModuleItem.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/DefaultModuleService.java b/src/main/java/org/scijava/module/DefaultModuleService.java index dcdebc5de..2bd74928f 100644 --- a/src/main/java/org/scijava/module/DefaultModuleService.java +++ b/src/main/java/org/scijava/module/DefaultModuleService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/DefaultMutableModule.java b/src/main/java/org/scijava/module/DefaultMutableModule.java index 1fa266b0f..e40f54498 100644 --- a/src/main/java/org/scijava/module/DefaultMutableModule.java +++ b/src/main/java/org/scijava/module/DefaultMutableModule.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/DefaultMutableModuleInfo.java b/src/main/java/org/scijava/module/DefaultMutableModuleInfo.java index 630fd311e..7585c16ff 100644 --- a/src/main/java/org/scijava/module/DefaultMutableModuleInfo.java +++ b/src/main/java/org/scijava/module/DefaultMutableModuleInfo.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/DefaultMutableModuleItem.java b/src/main/java/org/scijava/module/DefaultMutableModuleItem.java index 1ff2d6bbe..b833cb34f 100644 --- a/src/main/java/org/scijava/module/DefaultMutableModuleItem.java +++ b/src/main/java/org/scijava/module/DefaultMutableModuleItem.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/MethodCallException.java b/src/main/java/org/scijava/module/MethodCallException.java index 09363f3ca..43a2cccad 100644 --- a/src/main/java/org/scijava/module/MethodCallException.java +++ b/src/main/java/org/scijava/module/MethodCallException.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/MethodRef.java b/src/main/java/org/scijava/module/MethodRef.java index ba7194645..aaca5bbd2 100644 --- a/src/main/java/org/scijava/module/MethodRef.java +++ b/src/main/java/org/scijava/module/MethodRef.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/Module.java b/src/main/java/org/scijava/module/Module.java index 2816a2ddf..275f0d904 100644 --- a/src/main/java/org/scijava/module/Module.java +++ b/src/main/java/org/scijava/module/Module.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/ModuleCanceledException.java b/src/main/java/org/scijava/module/ModuleCanceledException.java index 15a76ab30..8442e20aa 100644 --- a/src/main/java/org/scijava/module/ModuleCanceledException.java +++ b/src/main/java/org/scijava/module/ModuleCanceledException.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/ModuleException.java b/src/main/java/org/scijava/module/ModuleException.java index 6576e5814..e75d47128 100644 --- a/src/main/java/org/scijava/module/ModuleException.java +++ b/src/main/java/org/scijava/module/ModuleException.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/ModuleIndex.java b/src/main/java/org/scijava/module/ModuleIndex.java index eb3fac56a..4131a5ec7 100644 --- a/src/main/java/org/scijava/module/ModuleIndex.java +++ b/src/main/java/org/scijava/module/ModuleIndex.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/ModuleInfo.java b/src/main/java/org/scijava/module/ModuleInfo.java index f55541d82..b17a0548d 100644 --- a/src/main/java/org/scijava/module/ModuleInfo.java +++ b/src/main/java/org/scijava/module/ModuleInfo.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/ModuleItem.java b/src/main/java/org/scijava/module/ModuleItem.java index 1016ce653..087a03c8a 100644 --- a/src/main/java/org/scijava/module/ModuleItem.java +++ b/src/main/java/org/scijava/module/ModuleItem.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/ModuleRunner.java b/src/main/java/org/scijava/module/ModuleRunner.java index e03e8dd73..27fb61347 100644 --- a/src/main/java/org/scijava/module/ModuleRunner.java +++ b/src/main/java/org/scijava/module/ModuleRunner.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/ModuleService.java b/src/main/java/org/scijava/module/ModuleService.java index 3573e2b3e..e49850715 100644 --- a/src/main/java/org/scijava/module/ModuleService.java +++ b/src/main/java/org/scijava/module/ModuleService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/MutableModule.java b/src/main/java/org/scijava/module/MutableModule.java index 189c6cf87..3838b12a3 100644 --- a/src/main/java/org/scijava/module/MutableModule.java +++ b/src/main/java/org/scijava/module/MutableModule.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/MutableModuleInfo.java b/src/main/java/org/scijava/module/MutableModuleInfo.java index 5e57665bd..4de34d722 100644 --- a/src/main/java/org/scijava/module/MutableModuleInfo.java +++ b/src/main/java/org/scijava/module/MutableModuleInfo.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/MutableModuleItem.java b/src/main/java/org/scijava/module/MutableModuleItem.java index efd681ed5..3fd6df99d 100644 --- a/src/main/java/org/scijava/module/MutableModuleItem.java +++ b/src/main/java/org/scijava/module/MutableModuleItem.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/event/ModuleCanceledEvent.java b/src/main/java/org/scijava/module/event/ModuleCanceledEvent.java index 0451da0b1..53d4240e5 100644 --- a/src/main/java/org/scijava/module/event/ModuleCanceledEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleCanceledEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/event/ModuleEvent.java b/src/main/java/org/scijava/module/event/ModuleEvent.java index 6cdc33195..ec8cbc044 100644 --- a/src/main/java/org/scijava/module/event/ModuleEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/event/ModuleExecutedEvent.java b/src/main/java/org/scijava/module/event/ModuleExecutedEvent.java index e84b6a3fa..97d51205d 100644 --- a/src/main/java/org/scijava/module/event/ModuleExecutedEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleExecutedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/event/ModuleExecutingEvent.java b/src/main/java/org/scijava/module/event/ModuleExecutingEvent.java index a1ede59c8..a7927f3b2 100644 --- a/src/main/java/org/scijava/module/event/ModuleExecutingEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleExecutingEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/event/ModuleExecutionEvent.java b/src/main/java/org/scijava/module/event/ModuleExecutionEvent.java index 357732926..ab3e4cdd7 100644 --- a/src/main/java/org/scijava/module/event/ModuleExecutionEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleExecutionEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/event/ModuleFinishedEvent.java b/src/main/java/org/scijava/module/event/ModuleFinishedEvent.java index 847747ac7..b07316001 100644 --- a/src/main/java/org/scijava/module/event/ModuleFinishedEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleFinishedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/event/ModulePostprocessEvent.java b/src/main/java/org/scijava/module/event/ModulePostprocessEvent.java index 501feae67..5cdd679f5 100644 --- a/src/main/java/org/scijava/module/event/ModulePostprocessEvent.java +++ b/src/main/java/org/scijava/module/event/ModulePostprocessEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/event/ModulePreprocessEvent.java b/src/main/java/org/scijava/module/event/ModulePreprocessEvent.java index 8aed828df..ff41de328 100644 --- a/src/main/java/org/scijava/module/event/ModulePreprocessEvent.java +++ b/src/main/java/org/scijava/module/event/ModulePreprocessEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/event/ModuleProcessEvent.java b/src/main/java/org/scijava/module/event/ModuleProcessEvent.java index bb969177d..3aa87b220 100644 --- a/src/main/java/org/scijava/module/event/ModuleProcessEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleProcessEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/event/ModuleStartedEvent.java b/src/main/java/org/scijava/module/event/ModuleStartedEvent.java index 069915064..bd532fb72 100644 --- a/src/main/java/org/scijava/module/event/ModuleStartedEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleStartedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/event/ModulesAddedEvent.java b/src/main/java/org/scijava/module/event/ModulesAddedEvent.java index 9f8714aae..adc9b2a78 100644 --- a/src/main/java/org/scijava/module/event/ModulesAddedEvent.java +++ b/src/main/java/org/scijava/module/event/ModulesAddedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/event/ModulesListEvent.java b/src/main/java/org/scijava/module/event/ModulesListEvent.java index 9e754000b..212903786 100644 --- a/src/main/java/org/scijava/module/event/ModulesListEvent.java +++ b/src/main/java/org/scijava/module/event/ModulesListEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/event/ModulesRemovedEvent.java b/src/main/java/org/scijava/module/event/ModulesRemovedEvent.java index a52cd32b9..dede673ac 100644 --- a/src/main/java/org/scijava/module/event/ModulesRemovedEvent.java +++ b/src/main/java/org/scijava/module/event/ModulesRemovedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/event/ModulesUpdatedEvent.java b/src/main/java/org/scijava/module/event/ModulesUpdatedEvent.java index e75d25ee0..062850923 100644 --- a/src/main/java/org/scijava/module/event/ModulesUpdatedEvent.java +++ b/src/main/java/org/scijava/module/event/ModulesUpdatedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/AbstractPostprocessorPlugin.java b/src/main/java/org/scijava/module/process/AbstractPostprocessorPlugin.java index 1af137a8b..c03d757a5 100644 --- a/src/main/java/org/scijava/module/process/AbstractPostprocessorPlugin.java +++ b/src/main/java/org/scijava/module/process/AbstractPostprocessorPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/AbstractPreprocessorPlugin.java b/src/main/java/org/scijava/module/process/AbstractPreprocessorPlugin.java index 39f957be5..d87bb47d8 100644 --- a/src/main/java/org/scijava/module/process/AbstractPreprocessorPlugin.java +++ b/src/main/java/org/scijava/module/process/AbstractPreprocessorPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/AbstractSingleInputPreprocessor.java b/src/main/java/org/scijava/module/process/AbstractSingleInputPreprocessor.java index 3fc602696..f4eb2e044 100644 --- a/src/main/java/org/scijava/module/process/AbstractSingleInputPreprocessor.java +++ b/src/main/java/org/scijava/module/process/AbstractSingleInputPreprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/CheckInputsPreprocessor.java b/src/main/java/org/scijava/module/process/CheckInputsPreprocessor.java index 7e031019e..db69245aa 100644 --- a/src/main/java/org/scijava/module/process/CheckInputsPreprocessor.java +++ b/src/main/java/org/scijava/module/process/CheckInputsPreprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/DebugPostprocessor.java b/src/main/java/org/scijava/module/process/DebugPostprocessor.java index 6115bb080..6a5274f29 100644 --- a/src/main/java/org/scijava/module/process/DebugPostprocessor.java +++ b/src/main/java/org/scijava/module/process/DebugPostprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/DebugPreprocessor.java b/src/main/java/org/scijava/module/process/DebugPreprocessor.java index ed5218174..7ac9db72a 100644 --- a/src/main/java/org/scijava/module/process/DebugPreprocessor.java +++ b/src/main/java/org/scijava/module/process/DebugPreprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java b/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java index a795cee4a..1422b9422 100644 --- a/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java +++ b/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/scijava/module/process/GatewayPreprocessor.java b/src/main/java/org/scijava/module/process/GatewayPreprocessor.java index 7f805e9c3..6f0ed52c8 100644 --- a/src/main/java/org/scijava/module/process/GatewayPreprocessor.java +++ b/src/main/java/org/scijava/module/process/GatewayPreprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/InitPreprocessor.java b/src/main/java/org/scijava/module/process/InitPreprocessor.java index 8e9c03a7d..2df7a6682 100644 --- a/src/main/java/org/scijava/module/process/InitPreprocessor.java +++ b/src/main/java/org/scijava/module/process/InitPreprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/LoadInputsPreprocessor.java b/src/main/java/org/scijava/module/process/LoadInputsPreprocessor.java index f61f484d5..17d1b736f 100644 --- a/src/main/java/org/scijava/module/process/LoadInputsPreprocessor.java +++ b/src/main/java/org/scijava/module/process/LoadInputsPreprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/ModulePostprocessor.java b/src/main/java/org/scijava/module/process/ModulePostprocessor.java index c25986a4c..4aecdd0c5 100644 --- a/src/main/java/org/scijava/module/process/ModulePostprocessor.java +++ b/src/main/java/org/scijava/module/process/ModulePostprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/ModulePreprocessor.java b/src/main/java/org/scijava/module/process/ModulePreprocessor.java index 555473f3b..6f547bf00 100644 --- a/src/main/java/org/scijava/module/process/ModulePreprocessor.java +++ b/src/main/java/org/scijava/module/process/ModulePreprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/ModuleProcessor.java b/src/main/java/org/scijava/module/process/ModuleProcessor.java index e27c6b891..5deb1f398 100644 --- a/src/main/java/org/scijava/module/process/ModuleProcessor.java +++ b/src/main/java/org/scijava/module/process/ModuleProcessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/PostprocessorPlugin.java b/src/main/java/org/scijava/module/process/PostprocessorPlugin.java index de83e0b01..37bfbcd34 100644 --- a/src/main/java/org/scijava/module/process/PostprocessorPlugin.java +++ b/src/main/java/org/scijava/module/process/PostprocessorPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/PreprocessorPlugin.java b/src/main/java/org/scijava/module/process/PreprocessorPlugin.java index ae66f51d4..1fa632790 100644 --- a/src/main/java/org/scijava/module/process/PreprocessorPlugin.java +++ b/src/main/java/org/scijava/module/process/PreprocessorPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/SaveInputsPreprocessor.java b/src/main/java/org/scijava/module/process/SaveInputsPreprocessor.java index 220027507..6c81a9c4a 100644 --- a/src/main/java/org/scijava/module/process/SaveInputsPreprocessor.java +++ b/src/main/java/org/scijava/module/process/SaveInputsPreprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/ServicePreprocessor.java b/src/main/java/org/scijava/module/process/ServicePreprocessor.java index 127bf992b..69e8f4500 100644 --- a/src/main/java/org/scijava/module/process/ServicePreprocessor.java +++ b/src/main/java/org/scijava/module/process/ServicePreprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/ValidityPreprocessor.java b/src/main/java/org/scijava/module/process/ValidityPreprocessor.java index 918f922d7..a18ef8a9c 100644 --- a/src/main/java/org/scijava/module/process/ValidityPreprocessor.java +++ b/src/main/java/org/scijava/module/process/ValidityPreprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/object/DefaultObjectService.java b/src/main/java/org/scijava/object/DefaultObjectService.java index aee218631..a9d560980 100644 --- a/src/main/java/org/scijava/object/DefaultObjectService.java +++ b/src/main/java/org/scijava/object/DefaultObjectService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/object/LazyObjects.java b/src/main/java/org/scijava/object/LazyObjects.java index 975efa89b..83e9a1efc 100644 --- a/src/main/java/org/scijava/object/LazyObjects.java +++ b/src/main/java/org/scijava/object/LazyObjects.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/object/ObjectIndex.java b/src/main/java/org/scijava/object/ObjectIndex.java index 1baee99ff..a953dbe22 100644 --- a/src/main/java/org/scijava/object/ObjectIndex.java +++ b/src/main/java/org/scijava/object/ObjectIndex.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/object/ObjectService.java b/src/main/java/org/scijava/object/ObjectService.java index d305dbd3f..fd4bf23f5 100644 --- a/src/main/java/org/scijava/object/ObjectService.java +++ b/src/main/java/org/scijava/object/ObjectService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/object/SortedObjectIndex.java b/src/main/java/org/scijava/object/SortedObjectIndex.java index 08639a1fd..2a1bd99db 100644 --- a/src/main/java/org/scijava/object/SortedObjectIndex.java +++ b/src/main/java/org/scijava/object/SortedObjectIndex.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/object/event/ListEvent.java b/src/main/java/org/scijava/object/event/ListEvent.java index 1ea8c046c..753a9a5fa 100644 --- a/src/main/java/org/scijava/object/event/ListEvent.java +++ b/src/main/java/org/scijava/object/event/ListEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/object/event/ObjectCreatedEvent.java b/src/main/java/org/scijava/object/event/ObjectCreatedEvent.java index 41292faeb..eb3804baf 100644 --- a/src/main/java/org/scijava/object/event/ObjectCreatedEvent.java +++ b/src/main/java/org/scijava/object/event/ObjectCreatedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/object/event/ObjectDeletedEvent.java b/src/main/java/org/scijava/object/event/ObjectDeletedEvent.java index c3c0d98f7..09cdf01a6 100644 --- a/src/main/java/org/scijava/object/event/ObjectDeletedEvent.java +++ b/src/main/java/org/scijava/object/event/ObjectDeletedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/object/event/ObjectEvent.java b/src/main/java/org/scijava/object/event/ObjectEvent.java index 0c8d7de4e..dfcc549f1 100644 --- a/src/main/java/org/scijava/object/event/ObjectEvent.java +++ b/src/main/java/org/scijava/object/event/ObjectEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/object/event/ObjectModifiedEvent.java b/src/main/java/org/scijava/object/event/ObjectModifiedEvent.java index 1e9eddb86..83a268634 100644 --- a/src/main/java/org/scijava/object/event/ObjectModifiedEvent.java +++ b/src/main/java/org/scijava/object/event/ObjectModifiedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/object/event/ObjectsAddedEvent.java b/src/main/java/org/scijava/object/event/ObjectsAddedEvent.java index 3082f50fc..b505e49d3 100644 --- a/src/main/java/org/scijava/object/event/ObjectsAddedEvent.java +++ b/src/main/java/org/scijava/object/event/ObjectsAddedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/object/event/ObjectsListEvent.java b/src/main/java/org/scijava/object/event/ObjectsListEvent.java index 549a5e921..598c83866 100644 --- a/src/main/java/org/scijava/object/event/ObjectsListEvent.java +++ b/src/main/java/org/scijava/object/event/ObjectsListEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/object/event/ObjectsRemovedEvent.java b/src/main/java/org/scijava/object/event/ObjectsRemovedEvent.java index 9b9f78c27..c88a8314a 100644 --- a/src/main/java/org/scijava/object/event/ObjectsRemovedEvent.java +++ b/src/main/java/org/scijava/object/event/ObjectsRemovedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/options/DefaultOptionsService.java b/src/main/java/org/scijava/options/DefaultOptionsService.java index d6de6e0c4..a75b24045 100644 --- a/src/main/java/org/scijava/options/DefaultOptionsService.java +++ b/src/main/java/org/scijava/options/DefaultOptionsService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/options/OptionsPlugin.java b/src/main/java/org/scijava/options/OptionsPlugin.java index cd84b14d1..783cf3161 100644 --- a/src/main/java/org/scijava/options/OptionsPlugin.java +++ b/src/main/java/org/scijava/options/OptionsPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/options/OptionsService.java b/src/main/java/org/scijava/options/OptionsService.java index 8e3c0b60e..cec85eda4 100644 --- a/src/main/java/org/scijava/options/OptionsService.java +++ b/src/main/java/org/scijava/options/OptionsService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/options/event/OptionsEvent.java b/src/main/java/org/scijava/options/event/OptionsEvent.java index 30ea0e09d..e57296aa5 100644 --- a/src/main/java/org/scijava/options/event/OptionsEvent.java +++ b/src/main/java/org/scijava/options/event/OptionsEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/AbstractPlatform.java b/src/main/java/org/scijava/platform/AbstractPlatform.java index 6970acc50..922cf39fe 100644 --- a/src/main/java/org/scijava/platform/AbstractPlatform.java +++ b/src/main/java/org/scijava/platform/AbstractPlatform.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/AppEventService.java b/src/main/java/org/scijava/platform/AppEventService.java index 6b4d31a8f..6a55084e4 100644 --- a/src/main/java/org/scijava/platform/AppEventService.java +++ b/src/main/java/org/scijava/platform/AppEventService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/DefaultAppEventService.java b/src/main/java/org/scijava/platform/DefaultAppEventService.java index 43bbcf1cd..d5216ae82 100644 --- a/src/main/java/org/scijava/platform/DefaultAppEventService.java +++ b/src/main/java/org/scijava/platform/DefaultAppEventService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/DefaultPlatform.java b/src/main/java/org/scijava/platform/DefaultPlatform.java index f7bb7b18c..3cda5fabf 100644 --- a/src/main/java/org/scijava/platform/DefaultPlatform.java +++ b/src/main/java/org/scijava/platform/DefaultPlatform.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/DefaultPlatformService.java b/src/main/java/org/scijava/platform/DefaultPlatformService.java index d399caad3..aabd65a1c 100644 --- a/src/main/java/org/scijava/platform/DefaultPlatformService.java +++ b/src/main/java/org/scijava/platform/DefaultPlatformService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/Platform.java b/src/main/java/org/scijava/platform/Platform.java index 8b8f1bf47..329774e9e 100644 --- a/src/main/java/org/scijava/platform/Platform.java +++ b/src/main/java/org/scijava/platform/Platform.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/PlatformService.java b/src/main/java/org/scijava/platform/PlatformService.java index 6a42f6bf3..3cb305b25 100644 --- a/src/main/java/org/scijava/platform/PlatformService.java +++ b/src/main/java/org/scijava/platform/PlatformService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/event/AppAboutEvent.java b/src/main/java/org/scijava/platform/event/AppAboutEvent.java index f8bb85e38..22b9c5e40 100644 --- a/src/main/java/org/scijava/platform/event/AppAboutEvent.java +++ b/src/main/java/org/scijava/platform/event/AppAboutEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/event/AppFocusEvent.java b/src/main/java/org/scijava/platform/event/AppFocusEvent.java index 0dd25f222..b595cc98f 100644 --- a/src/main/java/org/scijava/platform/event/AppFocusEvent.java +++ b/src/main/java/org/scijava/platform/event/AppFocusEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/event/AppMenusCreatedEvent.java b/src/main/java/org/scijava/platform/event/AppMenusCreatedEvent.java index 4adec3e76..d0762cb66 100644 --- a/src/main/java/org/scijava/platform/event/AppMenusCreatedEvent.java +++ b/src/main/java/org/scijava/platform/event/AppMenusCreatedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/event/AppOpenFilesEvent.java b/src/main/java/org/scijava/platform/event/AppOpenFilesEvent.java index b74c97c66..6d0d19c8a 100644 --- a/src/main/java/org/scijava/platform/event/AppOpenFilesEvent.java +++ b/src/main/java/org/scijava/platform/event/AppOpenFilesEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/event/AppPreferencesEvent.java b/src/main/java/org/scijava/platform/event/AppPreferencesEvent.java index f3e95ebda..b11e0eb87 100644 --- a/src/main/java/org/scijava/platform/event/AppPreferencesEvent.java +++ b/src/main/java/org/scijava/platform/event/AppPreferencesEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/event/AppPrintEvent.java b/src/main/java/org/scijava/platform/event/AppPrintEvent.java index 21a377973..a6f3dfa6b 100644 --- a/src/main/java/org/scijava/platform/event/AppPrintEvent.java +++ b/src/main/java/org/scijava/platform/event/AppPrintEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/event/AppQuitEvent.java b/src/main/java/org/scijava/platform/event/AppQuitEvent.java index 69293d35f..be29a6a0e 100644 --- a/src/main/java/org/scijava/platform/event/AppQuitEvent.java +++ b/src/main/java/org/scijava/platform/event/AppQuitEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/event/AppReOpenEvent.java b/src/main/java/org/scijava/platform/event/AppReOpenEvent.java index c0f168c91..71eed3f60 100644 --- a/src/main/java/org/scijava/platform/event/AppReOpenEvent.java +++ b/src/main/java/org/scijava/platform/event/AppReOpenEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/event/AppScreenSleepEvent.java b/src/main/java/org/scijava/platform/event/AppScreenSleepEvent.java index 1a5cdeb61..60b1bc7b5 100644 --- a/src/main/java/org/scijava/platform/event/AppScreenSleepEvent.java +++ b/src/main/java/org/scijava/platform/event/AppScreenSleepEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/event/AppSleepEvent.java b/src/main/java/org/scijava/platform/event/AppSleepEvent.java index 8896089b7..c105f7f5d 100644 --- a/src/main/java/org/scijava/platform/event/AppSleepEvent.java +++ b/src/main/java/org/scijava/platform/event/AppSleepEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/event/AppSystemSleepEvent.java b/src/main/java/org/scijava/platform/event/AppSystemSleepEvent.java index e0b89a317..07cc9fbf8 100644 --- a/src/main/java/org/scijava/platform/event/AppSystemSleepEvent.java +++ b/src/main/java/org/scijava/platform/event/AppSystemSleepEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/event/AppUserSessionEvent.java b/src/main/java/org/scijava/platform/event/AppUserSessionEvent.java index 9575d763c..0ee88d175 100644 --- a/src/main/java/org/scijava/platform/event/AppUserSessionEvent.java +++ b/src/main/java/org/scijava/platform/event/AppUserSessionEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/event/AppVisibleEvent.java b/src/main/java/org/scijava/platform/event/AppVisibleEvent.java index d9826680d..9292e9d2c 100644 --- a/src/main/java/org/scijava/platform/event/AppVisibleEvent.java +++ b/src/main/java/org/scijava/platform/event/AppVisibleEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/platform/event/ApplicationEvent.java b/src/main/java/org/scijava/platform/event/ApplicationEvent.java index 0e56d48e0..1076d9a7b 100644 --- a/src/main/java/org/scijava/platform/event/ApplicationEvent.java +++ b/src/main/java/org/scijava/platform/event/ApplicationEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/AbstractHandlerPlugin.java b/src/main/java/org/scijava/plugin/AbstractHandlerPlugin.java index 8a00c1878..6773ccbbf 100644 --- a/src/main/java/org/scijava/plugin/AbstractHandlerPlugin.java +++ b/src/main/java/org/scijava/plugin/AbstractHandlerPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/AbstractHandlerService.java b/src/main/java/org/scijava/plugin/AbstractHandlerService.java index 2e13897a2..1768f9731 100644 --- a/src/main/java/org/scijava/plugin/AbstractHandlerService.java +++ b/src/main/java/org/scijava/plugin/AbstractHandlerService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/AbstractPTService.java b/src/main/java/org/scijava/plugin/AbstractPTService.java index 9c31eb2fc..4c77c451e 100644 --- a/src/main/java/org/scijava/plugin/AbstractPTService.java +++ b/src/main/java/org/scijava/plugin/AbstractPTService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/AbstractRichPlugin.java b/src/main/java/org/scijava/plugin/AbstractRichPlugin.java index bc720e848..11f88620b 100644 --- a/src/main/java/org/scijava/plugin/AbstractRichPlugin.java +++ b/src/main/java/org/scijava/plugin/AbstractRichPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/AbstractSingletonService.java b/src/main/java/org/scijava/plugin/AbstractSingletonService.java index cc19bacab..f60c76c77 100644 --- a/src/main/java/org/scijava/plugin/AbstractSingletonService.java +++ b/src/main/java/org/scijava/plugin/AbstractSingletonService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/AbstractTypedPlugin.java b/src/main/java/org/scijava/plugin/AbstractTypedPlugin.java index 1498f6491..cda3c8e3b 100644 --- a/src/main/java/org/scijava/plugin/AbstractTypedPlugin.java +++ b/src/main/java/org/scijava/plugin/AbstractTypedPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/AbstractTypedService.java b/src/main/java/org/scijava/plugin/AbstractTypedService.java index cbdb3c4b5..04a444637 100644 --- a/src/main/java/org/scijava/plugin/AbstractTypedService.java +++ b/src/main/java/org/scijava/plugin/AbstractTypedService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/AbstractWrapperPlugin.java b/src/main/java/org/scijava/plugin/AbstractWrapperPlugin.java index e50995bbd..80acfa436 100644 --- a/src/main/java/org/scijava/plugin/AbstractWrapperPlugin.java +++ b/src/main/java/org/scijava/plugin/AbstractWrapperPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/AbstractWrapperService.java b/src/main/java/org/scijava/plugin/AbstractWrapperService.java index 4e6910e59..5254a5a12 100644 --- a/src/main/java/org/scijava/plugin/AbstractWrapperService.java +++ b/src/main/java/org/scijava/plugin/AbstractWrapperService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/Attr.java b/src/main/java/org/scijava/plugin/Attr.java index 73e9156cd..9d7a8a47f 100644 --- a/src/main/java/org/scijava/plugin/Attr.java +++ b/src/main/java/org/scijava/plugin/Attr.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/DefaultPluginFinder.java b/src/main/java/org/scijava/plugin/DefaultPluginFinder.java index cb595ec76..5c5796e75 100644 --- a/src/main/java/org/scijava/plugin/DefaultPluginFinder.java +++ b/src/main/java/org/scijava/plugin/DefaultPluginFinder.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/DefaultPluginService.java b/src/main/java/org/scijava/plugin/DefaultPluginService.java index cc7429149..796870681 100644 --- a/src/main/java/org/scijava/plugin/DefaultPluginService.java +++ b/src/main/java/org/scijava/plugin/DefaultPluginService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/HandlerPlugin.java b/src/main/java/org/scijava/plugin/HandlerPlugin.java index 37bffe6ce..9331331e6 100644 --- a/src/main/java/org/scijava/plugin/HandlerPlugin.java +++ b/src/main/java/org/scijava/plugin/HandlerPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/HandlerService.java b/src/main/java/org/scijava/plugin/HandlerService.java index 53cd7d3d1..ed551a499 100644 --- a/src/main/java/org/scijava/plugin/HandlerService.java +++ b/src/main/java/org/scijava/plugin/HandlerService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/HasPluginInfo.java b/src/main/java/org/scijava/plugin/HasPluginInfo.java index 4915ca8d1..69a2bb81a 100644 --- a/src/main/java/org/scijava/plugin/HasPluginInfo.java +++ b/src/main/java/org/scijava/plugin/HasPluginInfo.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/Menu.java b/src/main/java/org/scijava/plugin/Menu.java index abc746d36..962df19f9 100644 --- a/src/main/java/org/scijava/plugin/Menu.java +++ b/src/main/java/org/scijava/plugin/Menu.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/PTService.java b/src/main/java/org/scijava/plugin/PTService.java index 8abc4be7d..1f3caf9df 100644 --- a/src/main/java/org/scijava/plugin/PTService.java +++ b/src/main/java/org/scijava/plugin/PTService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/Parameter.java b/src/main/java/org/scijava/plugin/Parameter.java index 05ccd809c..84e8eddbf 100644 --- a/src/main/java/org/scijava/plugin/Parameter.java +++ b/src/main/java/org/scijava/plugin/Parameter.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/Plugin.java b/src/main/java/org/scijava/plugin/Plugin.java index f4bca8fd8..7f70f564b 100644 --- a/src/main/java/org/scijava/plugin/Plugin.java +++ b/src/main/java/org/scijava/plugin/Plugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/PluginFinder.java b/src/main/java/org/scijava/plugin/PluginFinder.java index 7267db536..84f3325db 100644 --- a/src/main/java/org/scijava/plugin/PluginFinder.java +++ b/src/main/java/org/scijava/plugin/PluginFinder.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/PluginIndex.java b/src/main/java/org/scijava/plugin/PluginIndex.java index 832cdbc8b..629aa52b5 100644 --- a/src/main/java/org/scijava/plugin/PluginIndex.java +++ b/src/main/java/org/scijava/plugin/PluginIndex.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/PluginInfo.java b/src/main/java/org/scijava/plugin/PluginInfo.java index 2e67873d7..b60843f9b 100644 --- a/src/main/java/org/scijava/plugin/PluginInfo.java +++ b/src/main/java/org/scijava/plugin/PluginInfo.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/PluginService.java b/src/main/java/org/scijava/plugin/PluginService.java index 6cbb5257e..03db44d30 100644 --- a/src/main/java/org/scijava/plugin/PluginService.java +++ b/src/main/java/org/scijava/plugin/PluginService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/RichPlugin.java b/src/main/java/org/scijava/plugin/RichPlugin.java index b64b91ed5..bbe7a304f 100644 --- a/src/main/java/org/scijava/plugin/RichPlugin.java +++ b/src/main/java/org/scijava/plugin/RichPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/SciJavaPlugin.java b/src/main/java/org/scijava/plugin/SciJavaPlugin.java index 72bcb4133..d1f8c22c2 100644 --- a/src/main/java/org/scijava/plugin/SciJavaPlugin.java +++ b/src/main/java/org/scijava/plugin/SciJavaPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/SingletonPlugin.java b/src/main/java/org/scijava/plugin/SingletonPlugin.java index 8b43c3d26..48de6c945 100644 --- a/src/main/java/org/scijava/plugin/SingletonPlugin.java +++ b/src/main/java/org/scijava/plugin/SingletonPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/SingletonService.java b/src/main/java/org/scijava/plugin/SingletonService.java index 86fce11b6..5f22897a2 100644 --- a/src/main/java/org/scijava/plugin/SingletonService.java +++ b/src/main/java/org/scijava/plugin/SingletonService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/SortablePlugin.java b/src/main/java/org/scijava/plugin/SortablePlugin.java index c07a2a098..ef2e60411 100644 --- a/src/main/java/org/scijava/plugin/SortablePlugin.java +++ b/src/main/java/org/scijava/plugin/SortablePlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/TypedPlugin.java b/src/main/java/org/scijava/plugin/TypedPlugin.java index d13fc18cb..ecf27077b 100644 --- a/src/main/java/org/scijava/plugin/TypedPlugin.java +++ b/src/main/java/org/scijava/plugin/TypedPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/TypedService.java b/src/main/java/org/scijava/plugin/TypedService.java index 1db9fa969..86983ddbf 100644 --- a/src/main/java/org/scijava/plugin/TypedService.java +++ b/src/main/java/org/scijava/plugin/TypedService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/WrapperPlugin.java b/src/main/java/org/scijava/plugin/WrapperPlugin.java index 0a1485e8e..062e2c639 100644 --- a/src/main/java/org/scijava/plugin/WrapperPlugin.java +++ b/src/main/java/org/scijava/plugin/WrapperPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/WrapperService.java b/src/main/java/org/scijava/plugin/WrapperService.java index e46882387..0664c95a8 100644 --- a/src/main/java/org/scijava/plugin/WrapperService.java +++ b/src/main/java/org/scijava/plugin/WrapperService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/event/PluginsAddedEvent.java b/src/main/java/org/scijava/plugin/event/PluginsAddedEvent.java index 4c40ef7dd..836074a67 100644 --- a/src/main/java/org/scijava/plugin/event/PluginsAddedEvent.java +++ b/src/main/java/org/scijava/plugin/event/PluginsAddedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/event/PluginsListEvent.java b/src/main/java/org/scijava/plugin/event/PluginsListEvent.java index b59f798bb..0726c81d6 100644 --- a/src/main/java/org/scijava/plugin/event/PluginsListEvent.java +++ b/src/main/java/org/scijava/plugin/event/PluginsListEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/plugin/event/PluginsRemovedEvent.java b/src/main/java/org/scijava/plugin/event/PluginsRemovedEvent.java index bd3c13feb..b6feeaac1 100644 --- a/src/main/java/org/scijava/plugin/event/PluginsRemovedEvent.java +++ b/src/main/java/org/scijava/plugin/event/PluginsRemovedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/prefs/AbstractPrefService.java b/src/main/java/org/scijava/prefs/AbstractPrefService.java index d9f21139a..42c71fbe5 100644 --- a/src/main/java/org/scijava/prefs/AbstractPrefService.java +++ b/src/main/java/org/scijava/prefs/AbstractPrefService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/prefs/DefaultPrefService.java b/src/main/java/org/scijava/prefs/DefaultPrefService.java index 7b90821ea..327706198 100644 --- a/src/main/java/org/scijava/prefs/DefaultPrefService.java +++ b/src/main/java/org/scijava/prefs/DefaultPrefService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/prefs/PrefService.java b/src/main/java/org/scijava/prefs/PrefService.java index ee711aaaa..8b4349bb6 100644 --- a/src/main/java/org/scijava/prefs/PrefService.java +++ b/src/main/java/org/scijava/prefs/PrefService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/AbstractScriptContext.java b/src/main/java/org/scijava/script/AbstractScriptContext.java index 04099dec0..d5cf7ee06 100644 --- a/src/main/java/org/scijava/script/AbstractScriptContext.java +++ b/src/main/java/org/scijava/script/AbstractScriptContext.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/AbstractScriptEngine.java b/src/main/java/org/scijava/script/AbstractScriptEngine.java index 1c40684cd..46382835d 100644 --- a/src/main/java/org/scijava/script/AbstractScriptEngine.java +++ b/src/main/java/org/scijava/script/AbstractScriptEngine.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/AbstractScriptHeader.java b/src/main/java/org/scijava/script/AbstractScriptHeader.java index b48b0f221..a2afb48cc 100644 --- a/src/main/java/org/scijava/script/AbstractScriptHeader.java +++ b/src/main/java/org/scijava/script/AbstractScriptHeader.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/AbstractScriptLanguage.java b/src/main/java/org/scijava/script/AbstractScriptLanguage.java index 1644cec5f..f50965015 100644 --- a/src/main/java/org/scijava/script/AbstractScriptLanguage.java +++ b/src/main/java/org/scijava/script/AbstractScriptLanguage.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/AdaptedScriptLanguage.java b/src/main/java/org/scijava/script/AdaptedScriptLanguage.java index a06ec4147..403bc7693 100644 --- a/src/main/java/org/scijava/script/AdaptedScriptLanguage.java +++ b/src/main/java/org/scijava/script/AdaptedScriptLanguage.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/CodeGenerator.java b/src/main/java/org/scijava/script/CodeGenerator.java index 010846b43..e7f9b6e56 100644 --- a/src/main/java/org/scijava/script/CodeGenerator.java +++ b/src/main/java/org/scijava/script/CodeGenerator.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/CodeGeneratorJava.java b/src/main/java/org/scijava/script/CodeGeneratorJava.java index 4fd1fc21c..de2fc84c2 100644 --- a/src/main/java/org/scijava/script/CodeGeneratorJava.java +++ b/src/main/java/org/scijava/script/CodeGeneratorJava.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/DefaultScriptHeaderService.java b/src/main/java/org/scijava/script/DefaultScriptHeaderService.java index 9230f69ca..5b51ca2f6 100644 --- a/src/main/java/org/scijava/script/DefaultScriptHeaderService.java +++ b/src/main/java/org/scijava/script/DefaultScriptHeaderService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/DefaultScriptInterpreter.java b/src/main/java/org/scijava/script/DefaultScriptInterpreter.java index 13fe6ec77..a0db10893 100644 --- a/src/main/java/org/scijava/script/DefaultScriptInterpreter.java +++ b/src/main/java/org/scijava/script/DefaultScriptInterpreter.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index 646feb111..1883a960a 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/History.java b/src/main/java/org/scijava/script/History.java index 445bffd96..c2fe584bb 100644 --- a/src/main/java/org/scijava/script/History.java +++ b/src/main/java/org/scijava/script/History.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/InvocationObject.java b/src/main/java/org/scijava/script/InvocationObject.java index 6dad3306a..44591f9ec 100644 --- a/src/main/java/org/scijava/script/InvocationObject.java +++ b/src/main/java/org/scijava/script/InvocationObject.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/ParameterObject.java b/src/main/java/org/scijava/script/ParameterObject.java index 790ee172c..80e1e615e 100644 --- a/src/main/java/org/scijava/script/ParameterObject.java +++ b/src/main/java/org/scijava/script/ParameterObject.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/ScriptFinder.java b/src/main/java/org/scijava/script/ScriptFinder.java index 9c7bfc120..f0deabdd9 100644 --- a/src/main/java/org/scijava/script/ScriptFinder.java +++ b/src/main/java/org/scijava/script/ScriptFinder.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/ScriptHeader.java b/src/main/java/org/scijava/script/ScriptHeader.java index db7403d54..b38ead72f 100644 --- a/src/main/java/org/scijava/script/ScriptHeader.java +++ b/src/main/java/org/scijava/script/ScriptHeader.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/ScriptHeaderService.java b/src/main/java/org/scijava/script/ScriptHeaderService.java index 3e6a0b9f0..b87ce51b9 100644 --- a/src/main/java/org/scijava/script/ScriptHeaderService.java +++ b/src/main/java/org/scijava/script/ScriptHeaderService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index ffc40391f..d8af44045 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/ScriptInterpreter.java b/src/main/java/org/scijava/script/ScriptInterpreter.java index f2821b08b..a2c832874 100644 --- a/src/main/java/org/scijava/script/ScriptInterpreter.java +++ b/src/main/java/org/scijava/script/ScriptInterpreter.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/ScriptLanguage.java b/src/main/java/org/scijava/script/ScriptLanguage.java index 6e17b895d..0605e4615 100644 --- a/src/main/java/org/scijava/script/ScriptLanguage.java +++ b/src/main/java/org/scijava/script/ScriptLanguage.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/ScriptLanguageIndex.java b/src/main/java/org/scijava/script/ScriptLanguageIndex.java index 5c853688b..dfae11751 100644 --- a/src/main/java/org/scijava/script/ScriptLanguageIndex.java +++ b/src/main/java/org/scijava/script/ScriptLanguageIndex.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/ScriptModule.java b/src/main/java/org/scijava/script/ScriptModule.java index fc203366f..602545ebe 100644 --- a/src/main/java/org/scijava/script/ScriptModule.java +++ b/src/main/java/org/scijava/script/ScriptModule.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/ScriptService.java b/src/main/java/org/scijava/script/ScriptService.java index cea200a27..629d28fb3 100644 --- a/src/main/java/org/scijava/script/ScriptService.java +++ b/src/main/java/org/scijava/script/ScriptService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/script/io/ScriptIOPlugin.java b/src/main/java/org/scijava/script/io/ScriptIOPlugin.java index 4338b2f0d..18cba6c8c 100644 --- a/src/main/java/org/scijava/script/io/ScriptIOPlugin.java +++ b/src/main/java/org/scijava/script/io/ScriptIOPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/service/AbstractService.java b/src/main/java/org/scijava/service/AbstractService.java index ec37801c5..88f036f21 100644 --- a/src/main/java/org/scijava/service/AbstractService.java +++ b/src/main/java/org/scijava/service/AbstractService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/service/SciJavaService.java b/src/main/java/org/scijava/service/SciJavaService.java index 9d395c80b..a1ea5ee51 100644 --- a/src/main/java/org/scijava/service/SciJavaService.java +++ b/src/main/java/org/scijava/service/SciJavaService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/service/Service.java b/src/main/java/org/scijava/service/Service.java index ce2330db9..140d1377f 100644 --- a/src/main/java/org/scijava/service/Service.java +++ b/src/main/java/org/scijava/service/Service.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/service/ServiceHelper.java b/src/main/java/org/scijava/service/ServiceHelper.java index 025deaac7..f239f811b 100644 --- a/src/main/java/org/scijava/service/ServiceHelper.java +++ b/src/main/java/org/scijava/service/ServiceHelper.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/service/ServiceIndex.java b/src/main/java/org/scijava/service/ServiceIndex.java index ccff39f89..2c39bd946 100644 --- a/src/main/java/org/scijava/service/ServiceIndex.java +++ b/src/main/java/org/scijava/service/ServiceIndex.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/service/event/ServicesLoadedEvent.java b/src/main/java/org/scijava/service/event/ServicesLoadedEvent.java index 44edda8ae..01f23192a 100644 --- a/src/main/java/org/scijava/service/event/ServicesLoadedEvent.java +++ b/src/main/java/org/scijava/service/event/ServicesLoadedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/test/TestUtils.java b/src/main/java/org/scijava/test/TestUtils.java index 31b3ccb29..36b29c72d 100644 --- a/src/main/java/org/scijava/test/TestUtils.java +++ b/src/main/java/org/scijava/test/TestUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/text/AbstractTextFormat.java b/src/main/java/org/scijava/text/AbstractTextFormat.java index 5a25f2045..899f1be9c 100644 --- a/src/main/java/org/scijava/text/AbstractTextFormat.java +++ b/src/main/java/org/scijava/text/AbstractTextFormat.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/text/DefaultTextService.java b/src/main/java/org/scijava/text/DefaultTextService.java index ce804b51a..c4f36d680 100644 --- a/src/main/java/org/scijava/text/DefaultTextService.java +++ b/src/main/java/org/scijava/text/DefaultTextService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/text/TextFormat.java b/src/main/java/org/scijava/text/TextFormat.java index 0b7347db6..20ce9d4ee 100644 --- a/src/main/java/org/scijava/text/TextFormat.java +++ b/src/main/java/org/scijava/text/TextFormat.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/text/TextService.java b/src/main/java/org/scijava/text/TextService.java index 26bbc820d..1703fb0b3 100644 --- a/src/main/java/org/scijava/text/TextService.java +++ b/src/main/java/org/scijava/text/TextService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/text/io/TextIOPlugin.java b/src/main/java/org/scijava/text/io/TextIOPlugin.java index 2dfbee160..e499c943a 100644 --- a/src/main/java/org/scijava/text/io/TextIOPlugin.java +++ b/src/main/java/org/scijava/text/io/TextIOPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/thread/DefaultThreadService.java b/src/main/java/org/scijava/thread/DefaultThreadService.java index 713769fc5..ae136e921 100644 --- a/src/main/java/org/scijava/thread/DefaultThreadService.java +++ b/src/main/java/org/scijava/thread/DefaultThreadService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/thread/ThreadService.java b/src/main/java/org/scijava/thread/ThreadService.java index a8913bb2e..2287c87f2 100644 --- a/src/main/java/org/scijava/thread/ThreadService.java +++ b/src/main/java/org/scijava/thread/ThreadService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/tool/AbstractTool.java b/src/main/java/org/scijava/tool/AbstractTool.java index 0defc847a..b042f4749 100644 --- a/src/main/java/org/scijava/tool/AbstractTool.java +++ b/src/main/java/org/scijava/tool/AbstractTool.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/tool/CustomDrawnTool.java b/src/main/java/org/scijava/tool/CustomDrawnTool.java index 30651696e..3850e5ebf 100644 --- a/src/main/java/org/scijava/tool/CustomDrawnTool.java +++ b/src/main/java/org/scijava/tool/CustomDrawnTool.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/tool/DefaultToolService.java b/src/main/java/org/scijava/tool/DefaultToolService.java index 03efd7521..15cc3fdee 100644 --- a/src/main/java/org/scijava/tool/DefaultToolService.java +++ b/src/main/java/org/scijava/tool/DefaultToolService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/tool/DummyTool.java b/src/main/java/org/scijava/tool/DummyTool.java index 6bb43f6e5..5b729c595 100644 --- a/src/main/java/org/scijava/tool/DummyTool.java +++ b/src/main/java/org/scijava/tool/DummyTool.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/tool/IconDrawer.java b/src/main/java/org/scijava/tool/IconDrawer.java index a824be58b..d4bacb3ba 100644 --- a/src/main/java/org/scijava/tool/IconDrawer.java +++ b/src/main/java/org/scijava/tool/IconDrawer.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/tool/IconService.java b/src/main/java/org/scijava/tool/IconService.java index f58079758..88e8600dc 100644 --- a/src/main/java/org/scijava/tool/IconService.java +++ b/src/main/java/org/scijava/tool/IconService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/tool/Tool.java b/src/main/java/org/scijava/tool/Tool.java index 7a5aa7af7..f0fa67ef7 100644 --- a/src/main/java/org/scijava/tool/Tool.java +++ b/src/main/java/org/scijava/tool/Tool.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/tool/ToolService.java b/src/main/java/org/scijava/tool/ToolService.java index 7d0307e69..c9145bf5e 100644 --- a/src/main/java/org/scijava/tool/ToolService.java +++ b/src/main/java/org/scijava/tool/ToolService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/tool/event/ToolActivatedEvent.java b/src/main/java/org/scijava/tool/event/ToolActivatedEvent.java index 82c8493f5..7c560a73a 100644 --- a/src/main/java/org/scijava/tool/event/ToolActivatedEvent.java +++ b/src/main/java/org/scijava/tool/event/ToolActivatedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/tool/event/ToolDeactivatedEvent.java b/src/main/java/org/scijava/tool/event/ToolDeactivatedEvent.java index 156fe1071..09857e75e 100644 --- a/src/main/java/org/scijava/tool/event/ToolDeactivatedEvent.java +++ b/src/main/java/org/scijava/tool/event/ToolDeactivatedEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/tool/event/ToolEvent.java b/src/main/java/org/scijava/tool/event/ToolEvent.java index 421c6da6c..18427dc01 100644 --- a/src/main/java/org/scijava/tool/event/ToolEvent.java +++ b/src/main/java/org/scijava/tool/event/ToolEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/ARGBPlane.java b/src/main/java/org/scijava/ui/ARGBPlane.java index c21854559..1559bbda9 100644 --- a/src/main/java/org/scijava/ui/ARGBPlane.java +++ b/src/main/java/org/scijava/ui/ARGBPlane.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/AbstractInputHarvesterPlugin.java b/src/main/java/org/scijava/ui/AbstractInputHarvesterPlugin.java index 8d09ab940..a92458a61 100644 --- a/src/main/java/org/scijava/ui/AbstractInputHarvesterPlugin.java +++ b/src/main/java/org/scijava/ui/AbstractInputHarvesterPlugin.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/AbstractUIInputWidget.java b/src/main/java/org/scijava/ui/AbstractUIInputWidget.java index 07ab6238a..deff1ce46 100644 --- a/src/main/java/org/scijava/ui/AbstractUIInputWidget.java +++ b/src/main/java/org/scijava/ui/AbstractUIInputWidget.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/AbstractUserInterface.java b/src/main/java/org/scijava/ui/AbstractUserInterface.java index 8b9f67998..8234027ea 100644 --- a/src/main/java/org/scijava/ui/AbstractUserInterface.java +++ b/src/main/java/org/scijava/ui/AbstractUserInterface.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/ApplicationFrame.java b/src/main/java/org/scijava/ui/ApplicationFrame.java index 0815330b4..4150ee826 100644 --- a/src/main/java/org/scijava/ui/ApplicationFrame.java +++ b/src/main/java/org/scijava/ui/ApplicationFrame.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/Arrangeable.java b/src/main/java/org/scijava/ui/Arrangeable.java index 8c2ec013f..9d21573cb 100644 --- a/src/main/java/org/scijava/ui/Arrangeable.java +++ b/src/main/java/org/scijava/ui/Arrangeable.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/CloseConfirmable.java b/src/main/java/org/scijava/ui/CloseConfirmable.java index 93ea92a45..8df904b3d 100644 --- a/src/main/java/org/scijava/ui/CloseConfirmable.java +++ b/src/main/java/org/scijava/ui/CloseConfirmable.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/DefaultUIService.java b/src/main/java/org/scijava/ui/DefaultUIService.java index fe1609a3c..fd381c41c 100644 --- a/src/main/java/org/scijava/ui/DefaultUIService.java +++ b/src/main/java/org/scijava/ui/DefaultUIService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/Desktop.java b/src/main/java/org/scijava/ui/Desktop.java index d29105dc0..f5d008322 100644 --- a/src/main/java/org/scijava/ui/Desktop.java +++ b/src/main/java/org/scijava/ui/Desktop.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/DialogPrompt.java b/src/main/java/org/scijava/ui/DialogPrompt.java index e67725b63..d09553606 100644 --- a/src/main/java/org/scijava/ui/DialogPrompt.java +++ b/src/main/java/org/scijava/ui/DialogPrompt.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/FilePreprocessor.java b/src/main/java/org/scijava/ui/FilePreprocessor.java index 78e5fdc1b..68ce98c6c 100644 --- a/src/main/java/org/scijava/ui/FilePreprocessor.java +++ b/src/main/java/org/scijava/ui/FilePreprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/StatusBar.java b/src/main/java/org/scijava/ui/StatusBar.java index 924f170fe..731f03b18 100644 --- a/src/main/java/org/scijava/ui/StatusBar.java +++ b/src/main/java/org/scijava/ui/StatusBar.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/SystemClipboard.java b/src/main/java/org/scijava/ui/SystemClipboard.java index 9c562722d..c9303005b 100644 --- a/src/main/java/org/scijava/ui/SystemClipboard.java +++ b/src/main/java/org/scijava/ui/SystemClipboard.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/ToolBar.java b/src/main/java/org/scijava/ui/ToolBar.java index 1edf1bbd2..a6e0f3dbe 100644 --- a/src/main/java/org/scijava/ui/ToolBar.java +++ b/src/main/java/org/scijava/ui/ToolBar.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/UIPreprocessor.java b/src/main/java/org/scijava/ui/UIPreprocessor.java index c56973205..44da9289c 100644 --- a/src/main/java/org/scijava/ui/UIPreprocessor.java +++ b/src/main/java/org/scijava/ui/UIPreprocessor.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/UIService.java b/src/main/java/org/scijava/ui/UIService.java index ed2445790..b5c6a03e7 100644 --- a/src/main/java/org/scijava/ui/UIService.java +++ b/src/main/java/org/scijava/ui/UIService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/UserInterface.java b/src/main/java/org/scijava/ui/UserInterface.java index cf4493a88..32a97c6d6 100644 --- a/src/main/java/org/scijava/ui/UserInterface.java +++ b/src/main/java/org/scijava/ui/UserInterface.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/console/AbstractConsolePane.java b/src/main/java/org/scijava/ui/console/AbstractConsolePane.java index 9a15d05c5..f704ad027 100644 --- a/src/main/java/org/scijava/ui/console/AbstractConsolePane.java +++ b/src/main/java/org/scijava/ui/console/AbstractConsolePane.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/console/ConsolePane.java b/src/main/java/org/scijava/ui/console/ConsolePane.java index 43109e4ac..ec03b3663 100644 --- a/src/main/java/org/scijava/ui/console/ConsolePane.java +++ b/src/main/java/org/scijava/ui/console/ConsolePane.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/console/UIArgument.java b/src/main/java/org/scijava/ui/console/UIArgument.java index f0e4efd8b..018b8059c 100644 --- a/src/main/java/org/scijava/ui/console/UIArgument.java +++ b/src/main/java/org/scijava/ui/console/UIArgument.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropData.java b/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropData.java index 62231d310..89e9ff137 100644 --- a/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropData.java +++ b/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropData.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropHandler.java b/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropHandler.java index 7f56f2db7..9f4e63434 100644 --- a/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropHandler.java +++ b/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropHandler.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropData.java b/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropData.java index ec1a3823d..124229a17 100644 --- a/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropData.java +++ b/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropData.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropService.java b/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropService.java index 61ce6fa5c..21399db2a 100644 --- a/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropService.java +++ b/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/DragAndDropData.java b/src/main/java/org/scijava/ui/dnd/DragAndDropData.java index 748bbeda7..7c707ca09 100644 --- a/src/main/java/org/scijava/ui/dnd/DragAndDropData.java +++ b/src/main/java/org/scijava/ui/dnd/DragAndDropData.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/DragAndDropHandler.java b/src/main/java/org/scijava/ui/dnd/DragAndDropHandler.java index c235d4b80..3fbf71803 100644 --- a/src/main/java/org/scijava/ui/dnd/DragAndDropHandler.java +++ b/src/main/java/org/scijava/ui/dnd/DragAndDropHandler.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/DragAndDropService.java b/src/main/java/org/scijava/ui/dnd/DragAndDropService.java index fc8800256..38c782304 100644 --- a/src/main/java/org/scijava/ui/dnd/DragAndDropService.java +++ b/src/main/java/org/scijava/ui/dnd/DragAndDropService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/FileDragAndDropHandler.java b/src/main/java/org/scijava/ui/dnd/FileDragAndDropHandler.java index e1e2d4603..cbc282026 100644 --- a/src/main/java/org/scijava/ui/dnd/FileDragAndDropHandler.java +++ b/src/main/java/org/scijava/ui/dnd/FileDragAndDropHandler.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/ListDragAndDropHandler.java b/src/main/java/org/scijava/ui/dnd/ListDragAndDropHandler.java index dfc28cc3e..de627cd6d 100644 --- a/src/main/java/org/scijava/ui/dnd/ListDragAndDropHandler.java +++ b/src/main/java/org/scijava/ui/dnd/ListDragAndDropHandler.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/MIMEType.java b/src/main/java/org/scijava/ui/dnd/MIMEType.java index 825f4010a..7cef9096f 100644 --- a/src/main/java/org/scijava/ui/dnd/MIMEType.java +++ b/src/main/java/org/scijava/ui/dnd/MIMEType.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/ScriptFileDragAndDropHandler.java b/src/main/java/org/scijava/ui/dnd/ScriptFileDragAndDropHandler.java index 6e8243dc7..5ac984613 100644 --- a/src/main/java/org/scijava/ui/dnd/ScriptFileDragAndDropHandler.java +++ b/src/main/java/org/scijava/ui/dnd/ScriptFileDragAndDropHandler.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/event/DragAndDropEvent.java b/src/main/java/org/scijava/ui/dnd/event/DragAndDropEvent.java index d6dd5babe..429237d30 100644 --- a/src/main/java/org/scijava/ui/dnd/event/DragAndDropEvent.java +++ b/src/main/java/org/scijava/ui/dnd/event/DragAndDropEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/event/DragEnterEvent.java b/src/main/java/org/scijava/ui/dnd/event/DragEnterEvent.java index 67460dfdd..b092a1a75 100644 --- a/src/main/java/org/scijava/ui/dnd/event/DragEnterEvent.java +++ b/src/main/java/org/scijava/ui/dnd/event/DragEnterEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/event/DragExitEvent.java b/src/main/java/org/scijava/ui/dnd/event/DragExitEvent.java index 330f40b17..198f5265d 100644 --- a/src/main/java/org/scijava/ui/dnd/event/DragExitEvent.java +++ b/src/main/java/org/scijava/ui/dnd/event/DragExitEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/event/DragOverEvent.java b/src/main/java/org/scijava/ui/dnd/event/DragOverEvent.java index e6ad40d23..5bb837d35 100644 --- a/src/main/java/org/scijava/ui/dnd/event/DragOverEvent.java +++ b/src/main/java/org/scijava/ui/dnd/event/DragOverEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/dnd/event/DropEvent.java b/src/main/java/org/scijava/ui/dnd/event/DropEvent.java index 7c399b2b2..cf9ac5de6 100644 --- a/src/main/java/org/scijava/ui/dnd/event/DropEvent.java +++ b/src/main/java/org/scijava/ui/dnd/event/DropEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/event/UIEvent.java b/src/main/java/org/scijava/ui/event/UIEvent.java index fdf07365b..a430604f2 100644 --- a/src/main/java/org/scijava/ui/event/UIEvent.java +++ b/src/main/java/org/scijava/ui/event/UIEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/event/UIShownEvent.java b/src/main/java/org/scijava/ui/event/UIShownEvent.java index 9edfe0688..a397df034 100644 --- a/src/main/java/org/scijava/ui/event/UIShownEvent.java +++ b/src/main/java/org/scijava/ui/event/UIShownEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/viewer/AbstractDisplayViewer.java b/src/main/java/org/scijava/ui/viewer/AbstractDisplayViewer.java index af9c1c843..6e8d1ef1b 100644 --- a/src/main/java/org/scijava/ui/viewer/AbstractDisplayViewer.java +++ b/src/main/java/org/scijava/ui/viewer/AbstractDisplayViewer.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/viewer/DisplayPanel.java b/src/main/java/org/scijava/ui/viewer/DisplayPanel.java index 7f0865e30..cbcf53aeb 100644 --- a/src/main/java/org/scijava/ui/viewer/DisplayPanel.java +++ b/src/main/java/org/scijava/ui/viewer/DisplayPanel.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/viewer/DisplayViewer.java b/src/main/java/org/scijava/ui/viewer/DisplayViewer.java index a53e488c8..557b035a3 100644 --- a/src/main/java/org/scijava/ui/viewer/DisplayViewer.java +++ b/src/main/java/org/scijava/ui/viewer/DisplayViewer.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/viewer/DisplayWindow.java b/src/main/java/org/scijava/ui/viewer/DisplayWindow.java index 626c3bb87..2f0f195db 100644 --- a/src/main/java/org/scijava/ui/viewer/DisplayWindow.java +++ b/src/main/java/org/scijava/ui/viewer/DisplayWindow.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/viewer/text/AbstractTextDisplayViewer.java b/src/main/java/org/scijava/ui/viewer/text/AbstractTextDisplayViewer.java index 28dbb8385..d36b752c1 100644 --- a/src/main/java/org/scijava/ui/viewer/text/AbstractTextDisplayViewer.java +++ b/src/main/java/org/scijava/ui/viewer/text/AbstractTextDisplayViewer.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/viewer/text/TextDisplayPanel.java b/src/main/java/org/scijava/ui/viewer/text/TextDisplayPanel.java index 28eda77cb..4438f34c2 100644 --- a/src/main/java/org/scijava/ui/viewer/text/TextDisplayPanel.java +++ b/src/main/java/org/scijava/ui/viewer/text/TextDisplayPanel.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/ui/viewer/text/TextDisplayViewer.java b/src/main/java/org/scijava/ui/viewer/text/TextDisplayViewer.java index 8bde41996..55953b5fb 100644 --- a/src/main/java/org/scijava/ui/viewer/text/TextDisplayViewer.java +++ b/src/main/java/org/scijava/ui/viewer/text/TextDisplayViewer.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/AbstractPrimitiveArray.java b/src/main/java/org/scijava/util/AbstractPrimitiveArray.java index 96002ca68..a5118d874 100644 --- a/src/main/java/org/scijava/util/AbstractPrimitiveArray.java +++ b/src/main/java/org/scijava/util/AbstractPrimitiveArray.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/AppUtils.java b/src/main/java/org/scijava/util/AppUtils.java index 371552ea4..bd3d79f78 100644 --- a/src/main/java/org/scijava/util/AppUtils.java +++ b/src/main/java/org/scijava/util/AppUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/ArrayUtils.java b/src/main/java/org/scijava/util/ArrayUtils.java index aa2d6d47d..5e415caae 100644 --- a/src/main/java/org/scijava/util/ArrayUtils.java +++ b/src/main/java/org/scijava/util/ArrayUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/BoolArray.java b/src/main/java/org/scijava/util/BoolArray.java index 6d6a096e5..916b0e67b 100644 --- a/src/main/java/org/scijava/util/BoolArray.java +++ b/src/main/java/org/scijava/util/BoolArray.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/ByteArray.java b/src/main/java/org/scijava/util/ByteArray.java index c900d32b6..f0499e138 100644 --- a/src/main/java/org/scijava/util/ByteArray.java +++ b/src/main/java/org/scijava/util/ByteArray.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/Bytes.java b/src/main/java/org/scijava/util/Bytes.java index f82784d57..293e53d7a 100644 --- a/src/main/java/org/scijava/util/Bytes.java +++ b/src/main/java/org/scijava/util/Bytes.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/scijava/util/CharArray.java b/src/main/java/org/scijava/util/CharArray.java index b98b9ab56..4d857ead5 100644 --- a/src/main/java/org/scijava/util/CharArray.java +++ b/src/main/java/org/scijava/util/CharArray.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/CheckSezpoz.java b/src/main/java/org/scijava/util/CheckSezpoz.java index 065291251..f76785999 100644 --- a/src/main/java/org/scijava/util/CheckSezpoz.java +++ b/src/main/java/org/scijava/util/CheckSezpoz.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/ClassUtils.java b/src/main/java/org/scijava/util/ClassUtils.java index 118aef1a7..bf7f4141d 100644 --- a/src/main/java/org/scijava/util/ClassUtils.java +++ b/src/main/java/org/scijava/util/ClassUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/ColorRGB.java b/src/main/java/org/scijava/util/ColorRGB.java index 12a63b156..714946065 100644 --- a/src/main/java/org/scijava/util/ColorRGB.java +++ b/src/main/java/org/scijava/util/ColorRGB.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/ColorRGBA.java b/src/main/java/org/scijava/util/ColorRGBA.java index 3c9e697ea..504e3aa07 100644 --- a/src/main/java/org/scijava/util/ColorRGBA.java +++ b/src/main/java/org/scijava/util/ColorRGBA.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/Colors.java b/src/main/java/org/scijava/util/Colors.java index 2f95e58cb..64eafd8e3 100644 --- a/src/main/java/org/scijava/util/Colors.java +++ b/src/main/java/org/scijava/util/Colors.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/CombineAnnotations.java b/src/main/java/org/scijava/util/CombineAnnotations.java index 32c6ff529..7b7260826 100644 --- a/src/main/java/org/scijava/util/CombineAnnotations.java +++ b/src/main/java/org/scijava/util/CombineAnnotations.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/Combiner.java b/src/main/java/org/scijava/util/Combiner.java index d850acc38..e38565a0d 100644 --- a/src/main/java/org/scijava/util/Combiner.java +++ b/src/main/java/org/scijava/util/Combiner.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/ConversionUtils.java b/src/main/java/org/scijava/util/ConversionUtils.java index c9b3738d4..0f343d157 100644 --- a/src/main/java/org/scijava/util/ConversionUtils.java +++ b/src/main/java/org/scijava/util/ConversionUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/DebugUtils.java b/src/main/java/org/scijava/util/DebugUtils.java index 6fe13882d..869dd34a8 100644 --- a/src/main/java/org/scijava/util/DebugUtils.java +++ b/src/main/java/org/scijava/util/DebugUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/DigestUtils.java b/src/main/java/org/scijava/util/DigestUtils.java index 79fbdd0f9..27b0d1dec 100644 --- a/src/main/java/org/scijava/util/DigestUtils.java +++ b/src/main/java/org/scijava/util/DigestUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/DoubleArray.java b/src/main/java/org/scijava/util/DoubleArray.java index 773dd69d8..bf2337ecf 100644 --- a/src/main/java/org/scijava/util/DoubleArray.java +++ b/src/main/java/org/scijava/util/DoubleArray.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/FileUtils.java b/src/main/java/org/scijava/util/FileUtils.java index 8a7dbba07..06bf48e56 100644 --- a/src/main/java/org/scijava/util/FileUtils.java +++ b/src/main/java/org/scijava/util/FileUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/FloatArray.java b/src/main/java/org/scijava/util/FloatArray.java index c4ab9f2cb..b427d3055 100644 --- a/src/main/java/org/scijava/util/FloatArray.java +++ b/src/main/java/org/scijava/util/FloatArray.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/GenericUtils.java b/src/main/java/org/scijava/util/GenericUtils.java index 9e3898feb..72fc323f2 100644 --- a/src/main/java/org/scijava/util/GenericUtils.java +++ b/src/main/java/org/scijava/util/GenericUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/IntArray.java b/src/main/java/org/scijava/util/IntArray.java index bbc4562c1..b88fe3f6c 100644 --- a/src/main/java/org/scijava/util/IntArray.java +++ b/src/main/java/org/scijava/util/IntArray.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/IntCoords.java b/src/main/java/org/scijava/util/IntCoords.java index a5c411ea8..8480882f7 100644 --- a/src/main/java/org/scijava/util/IntCoords.java +++ b/src/main/java/org/scijava/util/IntCoords.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/IntRect.java b/src/main/java/org/scijava/util/IntRect.java index 61a4cdc97..90362a37d 100644 --- a/src/main/java/org/scijava/util/IntRect.java +++ b/src/main/java/org/scijava/util/IntRect.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/IteratorPlus.java b/src/main/java/org/scijava/util/IteratorPlus.java index 2f382f69a..dc587ecd9 100644 --- a/src/main/java/org/scijava/util/IteratorPlus.java +++ b/src/main/java/org/scijava/util/IteratorPlus.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/LastRecentlyUsed.java b/src/main/java/org/scijava/util/LastRecentlyUsed.java index 93a2dc7ab..88057c527 100644 --- a/src/main/java/org/scijava/util/LastRecentlyUsed.java +++ b/src/main/java/org/scijava/util/LastRecentlyUsed.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/LineOutputStream.java b/src/main/java/org/scijava/util/LineOutputStream.java index cd45e36a4..5afd7f78f 100644 --- a/src/main/java/org/scijava/util/LineOutputStream.java +++ b/src/main/java/org/scijava/util/LineOutputStream.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/ListUtils.java b/src/main/java/org/scijava/util/ListUtils.java index ad7241649..33e8c7985 100644 --- a/src/main/java/org/scijava/util/ListUtils.java +++ b/src/main/java/org/scijava/util/ListUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/LongArray.java b/src/main/java/org/scijava/util/LongArray.java index 2e0028554..f71460601 100644 --- a/src/main/java/org/scijava/util/LongArray.java +++ b/src/main/java/org/scijava/util/LongArray.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/Manifest.java b/src/main/java/org/scijava/util/Manifest.java index 88f45b3b8..3fffeb861 100644 --- a/src/main/java/org/scijava/util/Manifest.java +++ b/src/main/java/org/scijava/util/Manifest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/MersenneTwisterFast.java b/src/main/java/org/scijava/util/MersenneTwisterFast.java index f8eb8cf24..78df195bd 100644 --- a/src/main/java/org/scijava/util/MersenneTwisterFast.java +++ b/src/main/java/org/scijava/util/MersenneTwisterFast.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/MetaInfCombiner.java b/src/main/java/org/scijava/util/MetaInfCombiner.java index 084f36e51..5a73573a9 100644 --- a/src/main/java/org/scijava/util/MetaInfCombiner.java +++ b/src/main/java/org/scijava/util/MetaInfCombiner.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/MirrorWebsite.java b/src/main/java/org/scijava/util/MirrorWebsite.java index 0f0315347..1c1138a4f 100644 --- a/src/main/java/org/scijava/util/MirrorWebsite.java +++ b/src/main/java/org/scijava/util/MirrorWebsite.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/MiscUtils.java b/src/main/java/org/scijava/util/MiscUtils.java index f1f37d85f..47f3e2794 100644 --- a/src/main/java/org/scijava/util/MiscUtils.java +++ b/src/main/java/org/scijava/util/MiscUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/NumberUtils.java b/src/main/java/org/scijava/util/NumberUtils.java index cedce4b60..8189764a0 100644 --- a/src/main/java/org/scijava/util/NumberUtils.java +++ b/src/main/java/org/scijava/util/NumberUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/ObjectArray.java b/src/main/java/org/scijava/util/ObjectArray.java index 3e70244c0..a20352b7a 100644 --- a/src/main/java/org/scijava/util/ObjectArray.java +++ b/src/main/java/org/scijava/util/ObjectArray.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/POM.java b/src/main/java/org/scijava/util/POM.java index 3fd2d25d5..7dc50d507 100644 --- a/src/main/java/org/scijava/util/POM.java +++ b/src/main/java/org/scijava/util/POM.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/PlatformUtils.java b/src/main/java/org/scijava/util/PlatformUtils.java index db8168d0b..ff7fbfa8c 100644 --- a/src/main/java/org/scijava/util/PlatformUtils.java +++ b/src/main/java/org/scijava/util/PlatformUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/Prefs.java b/src/main/java/org/scijava/util/Prefs.java index 0c0ccf850..a526d49ec 100644 --- a/src/main/java/org/scijava/util/Prefs.java +++ b/src/main/java/org/scijava/util/Prefs.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/PrimitiveArray.java b/src/main/java/org/scijava/util/PrimitiveArray.java index 7344fe110..6b1af3128 100644 --- a/src/main/java/org/scijava/util/PrimitiveArray.java +++ b/src/main/java/org/scijava/util/PrimitiveArray.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/ProcessUtils.java b/src/main/java/org/scijava/util/ProcessUtils.java index e3d8c92c3..da30b7c06 100644 --- a/src/main/java/org/scijava/util/ProcessUtils.java +++ b/src/main/java/org/scijava/util/ProcessUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/Query.java b/src/main/java/org/scijava/util/Query.java index 171ac7c6d..e3942d124 100644 --- a/src/main/java/org/scijava/util/Query.java +++ b/src/main/java/org/scijava/util/Query.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/ReadInto.java b/src/main/java/org/scijava/util/ReadInto.java index 402de1296..13b4a9186 100644 --- a/src/main/java/org/scijava/util/ReadInto.java +++ b/src/main/java/org/scijava/util/ReadInto.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/RealCoords.java b/src/main/java/org/scijava/util/RealCoords.java index fb245f22e..5c4e569ea 100644 --- a/src/main/java/org/scijava/util/RealCoords.java +++ b/src/main/java/org/scijava/util/RealCoords.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/RealRect.java b/src/main/java/org/scijava/util/RealRect.java index 2a054b8de..006c233ae 100644 --- a/src/main/java/org/scijava/util/RealRect.java +++ b/src/main/java/org/scijava/util/RealRect.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/ReflectException.java b/src/main/java/org/scijava/util/ReflectException.java index a2bfbe7d9..0d5d6240f 100644 --- a/src/main/java/org/scijava/util/ReflectException.java +++ b/src/main/java/org/scijava/util/ReflectException.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/ReflectedUniverse.java b/src/main/java/org/scijava/util/ReflectedUniverse.java index 2ac045161..968212bfd 100644 --- a/src/main/java/org/scijava/util/ReflectedUniverse.java +++ b/src/main/java/org/scijava/util/ReflectedUniverse.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/ServiceCombiner.java b/src/main/java/org/scijava/util/ServiceCombiner.java index 8f76ed95f..f91e182d9 100644 --- a/src/main/java/org/scijava/util/ServiceCombiner.java +++ b/src/main/java/org/scijava/util/ServiceCombiner.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/ShortArray.java b/src/main/java/org/scijava/util/ShortArray.java index 4023b2110..1db496b8c 100644 --- a/src/main/java/org/scijava/util/ShortArray.java +++ b/src/main/java/org/scijava/util/ShortArray.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/Sizable.java b/src/main/java/org/scijava/util/Sizable.java index 470d6457a..9b55aaeea 100644 --- a/src/main/java/org/scijava/util/Sizable.java +++ b/src/main/java/org/scijava/util/Sizable.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/SizableArrayList.java b/src/main/java/org/scijava/util/SizableArrayList.java index b37a0697a..09f468286 100644 --- a/src/main/java/org/scijava/util/SizableArrayList.java +++ b/src/main/java/org/scijava/util/SizableArrayList.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/StringMaker.java b/src/main/java/org/scijava/util/StringMaker.java index 552e2e80e..6d7fafd1e 100644 --- a/src/main/java/org/scijava/util/StringMaker.java +++ b/src/main/java/org/scijava/util/StringMaker.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/StringUtils.java b/src/main/java/org/scijava/util/StringUtils.java index 817e9d116..1145a409f 100644 --- a/src/main/java/org/scijava/util/StringUtils.java +++ b/src/main/java/org/scijava/util/StringUtils.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/scijava/util/Timing.java b/src/main/java/org/scijava/util/Timing.java index 87e1fd5ca..98f350688 100644 --- a/src/main/java/org/scijava/util/Timing.java +++ b/src/main/java/org/scijava/util/Timing.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/TunePlayer.java b/src/main/java/org/scijava/util/TunePlayer.java index 1730d0383..48f1f511a 100644 --- a/src/main/java/org/scijava/util/TunePlayer.java +++ b/src/main/java/org/scijava/util/TunePlayer.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/UnitUtils.java b/src/main/java/org/scijava/util/UnitUtils.java index 1ea53e2a3..3b400f57a 100644 --- a/src/main/java/org/scijava/util/UnitUtils.java +++ b/src/main/java/org/scijava/util/UnitUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/VersionUtils.java b/src/main/java/org/scijava/util/VersionUtils.java index fe1edb016..b78201336 100644 --- a/src/main/java/org/scijava/util/VersionUtils.java +++ b/src/main/java/org/scijava/util/VersionUtils.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/util/XML.java b/src/main/java/org/scijava/util/XML.java index 9a82a2a6e..79f0cd741 100644 --- a/src/main/java/org/scijava/util/XML.java +++ b/src/main/java/org/scijava/util/XML.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/welcome/DefaultWelcomeService.java b/src/main/java/org/scijava/welcome/DefaultWelcomeService.java index de71efcb7..90d8e1a00 100644 --- a/src/main/java/org/scijava/welcome/DefaultWelcomeService.java +++ b/src/main/java/org/scijava/welcome/DefaultWelcomeService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/welcome/WelcomeService.java b/src/main/java/org/scijava/welcome/WelcomeService.java index 6831ec5f3..4b822c406 100644 --- a/src/main/java/org/scijava/welcome/WelcomeService.java +++ b/src/main/java/org/scijava/welcome/WelcomeService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/welcome/event/WelcomeEvent.java b/src/main/java/org/scijava/welcome/event/WelcomeEvent.java index d92a66d7e..3098adb93 100644 --- a/src/main/java/org/scijava/welcome/event/WelcomeEvent.java +++ b/src/main/java/org/scijava/welcome/event/WelcomeEvent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/AbstractInputHarvester.java b/src/main/java/org/scijava/widget/AbstractInputHarvester.java index bf3acafb0..e3968a1f2 100644 --- a/src/main/java/org/scijava/widget/AbstractInputHarvester.java +++ b/src/main/java/org/scijava/widget/AbstractInputHarvester.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/AbstractInputPanel.java b/src/main/java/org/scijava/widget/AbstractInputPanel.java index c4612649b..e9155aa85 100644 --- a/src/main/java/org/scijava/widget/AbstractInputPanel.java +++ b/src/main/java/org/scijava/widget/AbstractInputPanel.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/AbstractInputWidget.java b/src/main/java/org/scijava/widget/AbstractInputWidget.java index 9b3ef6a0f..7ae6e7eef 100644 --- a/src/main/java/org/scijava/widget/AbstractInputWidget.java +++ b/src/main/java/org/scijava/widget/AbstractInputWidget.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/Button.java b/src/main/java/org/scijava/widget/Button.java index d34a22a47..323793c3a 100644 --- a/src/main/java/org/scijava/widget/Button.java +++ b/src/main/java/org/scijava/widget/Button.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/ButtonWidget.java b/src/main/java/org/scijava/widget/ButtonWidget.java index 4ae0b651e..1bbd8ada6 100644 --- a/src/main/java/org/scijava/widget/ButtonWidget.java +++ b/src/main/java/org/scijava/widget/ButtonWidget.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/ChoiceWidget.java b/src/main/java/org/scijava/widget/ChoiceWidget.java index a574b4bae..e578a3011 100644 --- a/src/main/java/org/scijava/widget/ChoiceWidget.java +++ b/src/main/java/org/scijava/widget/ChoiceWidget.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/ColorWidget.java b/src/main/java/org/scijava/widget/ColorWidget.java index 022f8ac99..7b87694c0 100644 --- a/src/main/java/org/scijava/widget/ColorWidget.java +++ b/src/main/java/org/scijava/widget/ColorWidget.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/DateWidget.java b/src/main/java/org/scijava/widget/DateWidget.java index ae2212e2a..0fc3a0ed0 100644 --- a/src/main/java/org/scijava/widget/DateWidget.java +++ b/src/main/java/org/scijava/widget/DateWidget.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/DefaultWidgetModel.java b/src/main/java/org/scijava/widget/DefaultWidgetModel.java index 278bf71a9..4f5052fb1 100644 --- a/src/main/java/org/scijava/widget/DefaultWidgetModel.java +++ b/src/main/java/org/scijava/widget/DefaultWidgetModel.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/DefaultWidgetService.java b/src/main/java/org/scijava/widget/DefaultWidgetService.java index 518f869d6..fdc6c94a9 100644 --- a/src/main/java/org/scijava/widget/DefaultWidgetService.java +++ b/src/main/java/org/scijava/widget/DefaultWidgetService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/FileWidget.java b/src/main/java/org/scijava/widget/FileWidget.java index bb7de0947..faa979214 100644 --- a/src/main/java/org/scijava/widget/FileWidget.java +++ b/src/main/java/org/scijava/widget/FileWidget.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/InputHarvester.java b/src/main/java/org/scijava/widget/InputHarvester.java index ee5ee8356..d2f57d154 100644 --- a/src/main/java/org/scijava/widget/InputHarvester.java +++ b/src/main/java/org/scijava/widget/InputHarvester.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/InputPanel.java b/src/main/java/org/scijava/widget/InputPanel.java index 07dd0d67f..2ce25cfa9 100644 --- a/src/main/java/org/scijava/widget/InputPanel.java +++ b/src/main/java/org/scijava/widget/InputPanel.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/InputWidget.java b/src/main/java/org/scijava/widget/InputWidget.java index c8c04030a..0b793f47e 100644 --- a/src/main/java/org/scijava/widget/InputWidget.java +++ b/src/main/java/org/scijava/widget/InputWidget.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/MessageWidget.java b/src/main/java/org/scijava/widget/MessageWidget.java index 49d54d928..89096ac6e 100644 --- a/src/main/java/org/scijava/widget/MessageWidget.java +++ b/src/main/java/org/scijava/widget/MessageWidget.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/NumberWidget.java b/src/main/java/org/scijava/widget/NumberWidget.java index bc06fe0ac..a0b1c5a92 100644 --- a/src/main/java/org/scijava/widget/NumberWidget.java +++ b/src/main/java/org/scijava/widget/NumberWidget.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/ObjectWidget.java b/src/main/java/org/scijava/widget/ObjectWidget.java index f399e4178..49d4f47c3 100644 --- a/src/main/java/org/scijava/widget/ObjectWidget.java +++ b/src/main/java/org/scijava/widget/ObjectWidget.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/TextWidget.java b/src/main/java/org/scijava/widget/TextWidget.java index 47c7d419f..c5ffdbcbb 100644 --- a/src/main/java/org/scijava/widget/TextWidget.java +++ b/src/main/java/org/scijava/widget/TextWidget.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/ToggleWidget.java b/src/main/java/org/scijava/widget/ToggleWidget.java index e9d976c91..61682d22f 100644 --- a/src/main/java/org/scijava/widget/ToggleWidget.java +++ b/src/main/java/org/scijava/widget/ToggleWidget.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/UIComponent.java b/src/main/java/org/scijava/widget/UIComponent.java index 0ea3f2a60..3f07a535e 100644 --- a/src/main/java/org/scijava/widget/UIComponent.java +++ b/src/main/java/org/scijava/widget/UIComponent.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/WidgetModel.java b/src/main/java/org/scijava/widget/WidgetModel.java index 16e19373a..ee7968266 100644 --- a/src/main/java/org/scijava/widget/WidgetModel.java +++ b/src/main/java/org/scijava/widget/WidgetModel.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/widget/WidgetService.java b/src/main/java/org/scijava/widget/WidgetService.java index 5147a14aa..e0311419d 100644 --- a/src/main/java/org/scijava/widget/WidgetService.java +++ b/src/main/java/org/scijava/widget/WidgetService.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/ContextCreationTest.java b/src/test/java/org/scijava/ContextCreationTest.java index ef41a7398..be2871145 100644 --- a/src/test/java/org/scijava/ContextCreationTest.java +++ b/src/test/java/org/scijava/ContextCreationTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/ContextInjectionTest.java b/src/test/java/org/scijava/ContextInjectionTest.java index a3e29eeb1..0e09c8dc4 100644 --- a/src/test/java/org/scijava/ContextInjectionTest.java +++ b/src/test/java/org/scijava/ContextInjectionTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/annotations/AnnotatedA.java b/src/test/java/org/scijava/annotations/AnnotatedA.java index c4d02ed7d..48829628e 100644 --- a/src/test/java/org/scijava/annotations/AnnotatedA.java +++ b/src/test/java/org/scijava/annotations/AnnotatedA.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/annotations/AnnotatedB.java b/src/test/java/org/scijava/annotations/AnnotatedB.java index 1dd8ae2b5..424fcc21b 100644 --- a/src/test/java/org/scijava/annotations/AnnotatedB.java +++ b/src/test/java/org/scijava/annotations/AnnotatedB.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/annotations/AnnotatedC.java b/src/test/java/org/scijava/annotations/AnnotatedC.java index 624941e1a..e2c6c7e7c 100644 --- a/src/test/java/org/scijava/annotations/AnnotatedC.java +++ b/src/test/java/org/scijava/annotations/AnnotatedC.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/annotations/AnnotatedD.java b/src/test/java/org/scijava/annotations/AnnotatedD.java index 936bca914..1e7380474 100644 --- a/src/test/java/org/scijava/annotations/AnnotatedD.java +++ b/src/test/java/org/scijava/annotations/AnnotatedD.java @@ -1,3 +1,33 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ package org.scijava.annotations; import java.util.ArrayList; diff --git a/src/test/java/org/scijava/annotations/AnnotatedInnerClass.java b/src/test/java/org/scijava/annotations/AnnotatedInnerClass.java index 9f84217a6..8ca3a1ff8 100644 --- a/src/test/java/org/scijava/annotations/AnnotatedInnerClass.java +++ b/src/test/java/org/scijava/annotations/AnnotatedInnerClass.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/annotations/Complex.java b/src/test/java/org/scijava/annotations/Complex.java index 7282def79..d1a6ce84d 100644 --- a/src/test/java/org/scijava/annotations/Complex.java +++ b/src/test/java/org/scijava/annotations/Complex.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java b/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java index 9d09d1a55..848eec71a 100644 --- a/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java +++ b/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/annotations/EclipseHelperTest.java b/src/test/java/org/scijava/annotations/EclipseHelperTest.java index fc51b10f9..373558b38 100644 --- a/src/test/java/org/scijava/annotations/EclipseHelperTest.java +++ b/src/test/java/org/scijava/annotations/EclipseHelperTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/annotations/Fruit.java b/src/test/java/org/scijava/annotations/Fruit.java index fbeafade7..4f2b9bfdb 100644 --- a/src/test/java/org/scijava/annotations/Fruit.java +++ b/src/test/java/org/scijava/annotations/Fruit.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/annotations/LegacyTest.java b/src/test/java/org/scijava/annotations/LegacyTest.java index 597e5b378..cbcef610b 100644 --- a/src/test/java/org/scijava/annotations/LegacyTest.java +++ b/src/test/java/org/scijava/annotations/LegacyTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/annotations/Simple.java b/src/test/java/org/scijava/annotations/Simple.java index d56bc2cee..a6af80190 100644 --- a/src/test/java/org/scijava/annotations/Simple.java +++ b/src/test/java/org/scijava/annotations/Simple.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/app/DefaultStatusServiceTest.java b/src/test/java/org/scijava/app/DefaultStatusServiceTest.java index cfcbc81db..eca692637 100644 --- a/src/test/java/org/scijava/app/DefaultStatusServiceTest.java +++ b/src/test/java/org/scijava/app/DefaultStatusServiceTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/command/CommandServiceTest.java b/src/test/java/org/scijava/command/CommandServiceTest.java index dd53d29d2..df8f1f565 100644 --- a/src/test/java/org/scijava/command/CommandServiceTest.java +++ b/src/test/java/org/scijava/command/CommandServiceTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/command/InvalidCommandTest.java b/src/test/java/org/scijava/command/InvalidCommandTest.java index 73a68cbe2..30eb59989 100644 --- a/src/test/java/org/scijava/command/InvalidCommandTest.java +++ b/src/test/java/org/scijava/command/InvalidCommandTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/console/ConsoleServiceTest.java b/src/test/java/org/scijava/console/ConsoleServiceTest.java index 3716c0ca2..07440ef33 100644 --- a/src/test/java/org/scijava/console/ConsoleServiceTest.java +++ b/src/test/java/org/scijava/console/ConsoleServiceTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/console/SystemPropertyArgumentTest.java b/src/test/java/org/scijava/console/SystemPropertyArgumentTest.java index 64bbf8d96..03e05e503 100644 --- a/src/test/java/org/scijava/console/SystemPropertyArgumentTest.java +++ b/src/test/java/org/scijava/console/SystemPropertyArgumentTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/convert/ConvertServiceTest.java b/src/test/java/org/scijava/convert/ConvertServiceTest.java index 620e5ca04..18a3deed9 100644 --- a/src/test/java/org/scijava/convert/ConvertServiceTest.java +++ b/src/test/java/org/scijava/convert/ConvertServiceTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/convert/ConverterTest.java b/src/test/java/org/scijava/convert/ConverterTest.java index de75c9f3e..798796def 100644 --- a/src/test/java/org/scijava/convert/ConverterTest.java +++ b/src/test/java/org/scijava/convert/ConverterTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/display/DisplayTest.java b/src/test/java/org/scijava/display/DisplayTest.java index 17e02d96a..ed6ad0d81 100644 --- a/src/test/java/org/scijava/display/DisplayTest.java +++ b/src/test/java/org/scijava/display/DisplayTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/event/EventServiceTest.java b/src/test/java/org/scijava/event/EventServiceTest.java index 5897cf188..ceff9f097 100644 --- a/src/test/java/org/scijava/event/EventServiceTest.java +++ b/src/test/java/org/scijava/event/EventServiceTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/io/BytesLocationTest.java b/src/test/java/org/scijava/io/BytesLocationTest.java index c36de091e..67a0e9716 100644 --- a/src/test/java/org/scijava/io/BytesLocationTest.java +++ b/src/test/java/org/scijava/io/BytesLocationTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/io/DataHandleTest.java b/src/test/java/org/scijava/io/DataHandleTest.java index decc7d29c..a9d0db06b 100644 --- a/src/test/java/org/scijava/io/DataHandleTest.java +++ b/src/test/java/org/scijava/io/DataHandleTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/io/FileHandleTest.java b/src/test/java/org/scijava/io/FileHandleTest.java index d4ad153a2..89d8914f9 100644 --- a/src/test/java/org/scijava/io/FileHandleTest.java +++ b/src/test/java/org/scijava/io/FileHandleTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/io/FileLocationTest.java b/src/test/java/org/scijava/io/FileLocationTest.java index 25b96d2bf..098cdaa54 100644 --- a/src/test/java/org/scijava/io/FileLocationTest.java +++ b/src/test/java/org/scijava/io/FileLocationTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/io/URILocationTest.java b/src/test/java/org/scijava/io/URILocationTest.java index 7a30f154f..ccd9155ac 100644 --- a/src/test/java/org/scijava/io/URILocationTest.java +++ b/src/test/java/org/scijava/io/URILocationTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/io/URLLocationTest.java b/src/test/java/org/scijava/io/URLLocationTest.java index 2e33b142b..69e85135e 100644 --- a/src/test/java/org/scijava/io/URLLocationTest.java +++ b/src/test/java/org/scijava/io/URLLocationTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/log/LogServiceTest.java b/src/test/java/org/scijava/log/LogServiceTest.java index 8373b065c..416069776 100644 --- a/src/test/java/org/scijava/log/LogServiceTest.java +++ b/src/test/java/org/scijava/log/LogServiceTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/main/MainServiceTest.java b/src/test/java/org/scijava/main/MainServiceTest.java index 0b46943c0..fd1382213 100644 --- a/src/test/java/org/scijava/main/MainServiceTest.java +++ b/src/test/java/org/scijava/main/MainServiceTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/menu/MenuServiceTest.java b/src/test/java/org/scijava/menu/MenuServiceTest.java index 92a149283..5e464c741 100644 --- a/src/test/java/org/scijava/menu/MenuServiceTest.java +++ b/src/test/java/org/scijava/menu/MenuServiceTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/menu/ShadowMenuTest.java b/src/test/java/org/scijava/menu/ShadowMenuTest.java index 1d07c4b2c..0e8bf5a58 100644 --- a/src/test/java/org/scijava/menu/ShadowMenuTest.java +++ b/src/test/java/org/scijava/menu/ShadowMenuTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/module/ModuleServiceTest.java b/src/test/java/org/scijava/module/ModuleServiceTest.java index 5e65c34d6..a1276f915 100644 --- a/src/test/java/org/scijava/module/ModuleServiceTest.java +++ b/src/test/java/org/scijava/module/ModuleServiceTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/object/ObjectIndexTest.java b/src/test/java/org/scijava/object/ObjectIndexTest.java index 06d44487f..6d6d33b62 100644 --- a/src/test/java/org/scijava/object/ObjectIndexTest.java +++ b/src/test/java/org/scijava/object/ObjectIndexTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/object/SortedObjectIndexTest.java b/src/test/java/org/scijava/object/SortedObjectIndexTest.java index 62bfe212f..906915352 100644 --- a/src/test/java/org/scijava/object/SortedObjectIndexTest.java +++ b/src/test/java/org/scijava/object/SortedObjectIndexTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/options/OptionsTest.java b/src/test/java/org/scijava/options/OptionsTest.java index 09519b591..9e59fc7e8 100644 --- a/src/test/java/org/scijava/options/OptionsTest.java +++ b/src/test/java/org/scijava/options/OptionsTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/plugin/PluginIndexTest.java b/src/test/java/org/scijava/plugin/PluginIndexTest.java index 1ff650a78..04ffbd149 100644 --- a/src/test/java/org/scijava/plugin/PluginIndexTest.java +++ b/src/test/java/org/scijava/plugin/PluginIndexTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/plugin/PluginInfoTest.java b/src/test/java/org/scijava/plugin/PluginInfoTest.java index 602be97c9..33510e5ec 100644 --- a/src/test/java/org/scijava/plugin/PluginInfoTest.java +++ b/src/test/java/org/scijava/plugin/PluginInfoTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/prefs/PrefServiceTest.java b/src/test/java/org/scijava/prefs/PrefServiceTest.java index c923ea4e9..c217544d8 100644 --- a/src/test/java/org/scijava/prefs/PrefServiceTest.java +++ b/src/test/java/org/scijava/prefs/PrefServiceTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/script/AbstractScriptLanguageTest.java b/src/test/java/org/scijava/script/AbstractScriptLanguageTest.java index 77717de58..00c0aa2d2 100644 --- a/src/test/java/org/scijava/script/AbstractScriptLanguageTest.java +++ b/src/test/java/org/scijava/script/AbstractScriptLanguageTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/script/ScriptEngineTest.java b/src/test/java/org/scijava/script/ScriptEngineTest.java index 167910ab7..4b3a8685f 100644 --- a/src/test/java/org/scijava/script/ScriptEngineTest.java +++ b/src/test/java/org/scijava/script/ScriptEngineTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/script/ScriptFinderTest.java b/src/test/java/org/scijava/script/ScriptFinderTest.java index d5626e993..122da260f 100644 --- a/src/test/java/org/scijava/script/ScriptFinderTest.java +++ b/src/test/java/org/scijava/script/ScriptFinderTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/script/ScriptInfoTest.java b/src/test/java/org/scijava/script/ScriptInfoTest.java index b87a4fb15..df64ad513 100644 --- a/src/test/java/org/scijava/script/ScriptInfoTest.java +++ b/src/test/java/org/scijava/script/ScriptInfoTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/script/ScriptServiceTest.java b/src/test/java/org/scijava/script/ScriptServiceTest.java index 2c49a15e1..60a249232 100644 --- a/src/test/java/org/scijava/script/ScriptServiceTest.java +++ b/src/test/java/org/scijava/script/ScriptServiceTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/service/ServiceIndexTest.java b/src/test/java/org/scijava/service/ServiceIndexTest.java index 9ba7ae354..7629ddcd3 100644 --- a/src/test/java/org/scijava/service/ServiceIndexTest.java +++ b/src/test/java/org/scijava/service/ServiceIndexTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/test/TestUtilsTest.java b/src/test/java/org/scijava/test/TestUtilsTest.java index 3bdcf2f45..1fe7f508d 100644 --- a/src/test/java/org/scijava/test/TestUtilsTest.java +++ b/src/test/java/org/scijava/test/TestUtilsTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/thread/ThreadServiceTest.java b/src/test/java/org/scijava/thread/ThreadServiceTest.java index 23357838c..878ccfc1a 100644 --- a/src/test/java/org/scijava/thread/ThreadServiceTest.java +++ b/src/test/java/org/scijava/thread/ThreadServiceTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/AppUtilsTest.java b/src/test/java/org/scijava/util/AppUtilsTest.java index 76c4b986d..8634a5ca5 100644 --- a/src/test/java/org/scijava/util/AppUtilsTest.java +++ b/src/test/java/org/scijava/util/AppUtilsTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/ArrayUtilsTest.java b/src/test/java/org/scijava/util/ArrayUtilsTest.java index 235f1898d..bd21d71d3 100644 --- a/src/test/java/org/scijava/util/ArrayUtilsTest.java +++ b/src/test/java/org/scijava/util/ArrayUtilsTest.java @@ -1,9 +1,10 @@ /* * #%L - * SCIFIO library for reading and converting scientific file formats. + * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2011 - 2014 Board of Regents of the University of - * Wisconsin-Madison + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/test/java/org/scijava/util/BoolArrayTest.java b/src/test/java/org/scijava/util/BoolArrayTest.java index a52ff6d1e..713fe4f42 100644 --- a/src/test/java/org/scijava/util/BoolArrayTest.java +++ b/src/test/java/org/scijava/util/BoolArrayTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/ByteArrayTest.java b/src/test/java/org/scijava/util/ByteArrayTest.java index 763467633..2540fe5dd 100644 --- a/src/test/java/org/scijava/util/ByteArrayTest.java +++ b/src/test/java/org/scijava/util/ByteArrayTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/CharArrayTest.java b/src/test/java/org/scijava/util/CharArrayTest.java index f204cb080..f8ba039ea 100644 --- a/src/test/java/org/scijava/util/CharArrayTest.java +++ b/src/test/java/org/scijava/util/CharArrayTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/ClassUtilsTest.java b/src/test/java/org/scijava/util/ClassUtilsTest.java index 72d036636..561e5d6c5 100644 --- a/src/test/java/org/scijava/util/ClassUtilsTest.java +++ b/src/test/java/org/scijava/util/ClassUtilsTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/ColorRGBTest.java b/src/test/java/org/scijava/util/ColorRGBTest.java index 467663eec..89d73f52a 100644 --- a/src/test/java/org/scijava/util/ColorRGBTest.java +++ b/src/test/java/org/scijava/util/ColorRGBTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/ConversionUtilsTest.java b/src/test/java/org/scijava/util/ConversionUtilsTest.java index 547f57c12..68d7ced59 100644 --- a/src/test/java/org/scijava/util/ConversionUtilsTest.java +++ b/src/test/java/org/scijava/util/ConversionUtilsTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/DigestUtilsTest.java b/src/test/java/org/scijava/util/DigestUtilsTest.java index 20c74334f..f066f24ed 100644 --- a/src/test/java/org/scijava/util/DigestUtilsTest.java +++ b/src/test/java/org/scijava/util/DigestUtilsTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/DoubleArrayTest.java b/src/test/java/org/scijava/util/DoubleArrayTest.java index f68424b63..717f997a1 100644 --- a/src/test/java/org/scijava/util/DoubleArrayTest.java +++ b/src/test/java/org/scijava/util/DoubleArrayTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/FileUtilsTest.java b/src/test/java/org/scijava/util/FileUtilsTest.java index 88111372c..ad8d51c1a 100644 --- a/src/test/java/org/scijava/util/FileUtilsTest.java +++ b/src/test/java/org/scijava/util/FileUtilsTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/FloatArrayTest.java b/src/test/java/org/scijava/util/FloatArrayTest.java index e9eb4dd96..b5d62c5ce 100644 --- a/src/test/java/org/scijava/util/FloatArrayTest.java +++ b/src/test/java/org/scijava/util/FloatArrayTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/GenericUtilsTest.java b/src/test/java/org/scijava/util/GenericUtilsTest.java index 4fc3fceda..6b0a10939 100644 --- a/src/test/java/org/scijava/util/GenericUtilsTest.java +++ b/src/test/java/org/scijava/util/GenericUtilsTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/IntArrayTest.java b/src/test/java/org/scijava/util/IntArrayTest.java index 3b23dca8e..badb7112e 100644 --- a/src/test/java/org/scijava/util/IntArrayTest.java +++ b/src/test/java/org/scijava/util/IntArrayTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/LastRecentlyUsedTest.java b/src/test/java/org/scijava/util/LastRecentlyUsedTest.java index 5d1001da9..c93cd1875 100644 --- a/src/test/java/org/scijava/util/LastRecentlyUsedTest.java +++ b/src/test/java/org/scijava/util/LastRecentlyUsedTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/LongArrayTest.java b/src/test/java/org/scijava/util/LongArrayTest.java index fc8b72671..c6f6e9237 100644 --- a/src/test/java/org/scijava/util/LongArrayTest.java +++ b/src/test/java/org/scijava/util/LongArrayTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/ObjectArrayTest.java b/src/test/java/org/scijava/util/ObjectArrayTest.java index 845834c7c..b7d651dc6 100644 --- a/src/test/java/org/scijava/util/ObjectArrayTest.java +++ b/src/test/java/org/scijava/util/ObjectArrayTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/POMTest.java b/src/test/java/org/scijava/util/POMTest.java index d44c18a02..e8ad4071c 100644 --- a/src/test/java/org/scijava/util/POMTest.java +++ b/src/test/java/org/scijava/util/POMTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/PrimitiveArrayTest.java b/src/test/java/org/scijava/util/PrimitiveArrayTest.java index cf64e82f7..fb985d03f 100644 --- a/src/test/java/org/scijava/util/PrimitiveArrayTest.java +++ b/src/test/java/org/scijava/util/PrimitiveArrayTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/ProcessUtilsTest.java b/src/test/java/org/scijava/util/ProcessUtilsTest.java index e5041ce85..1ee21a581 100644 --- a/src/test/java/org/scijava/util/ProcessUtilsTest.java +++ b/src/test/java/org/scijava/util/ProcessUtilsTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/ShortArrayTest.java b/src/test/java/org/scijava/util/ShortArrayTest.java index e0b595793..a24e9e90b 100644 --- a/src/test/java/org/scijava/util/ShortArrayTest.java +++ b/src/test/java/org/scijava/util/ShortArrayTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/util/UnitUtilsTest.java b/src/test/java/org/scijava/util/UnitUtilsTest.java index 830a531c1..f584fe72f 100644 --- a/src/test/java/org/scijava/util/UnitUtilsTest.java +++ b/src/test/java/org/scijava/util/UnitUtilsTest.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% From 2252e33a23f02ae145d1a19572b32c169928a37b Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Fri, 12 Feb 2016 12:11:11 -0600 Subject: [PATCH 0095/1208] RunArgument: don't run multithreaded We do not want to run arguments in parallel. When a RunArgument returns we want all work to be done so that cleanup can be performed. --- .../org/scijava/command/console/RunArgument.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/command/console/RunArgument.java b/src/main/java/org/scijava/command/console/RunArgument.java index da6f38bfc..9a5e73c35 100644 --- a/src/main/java/org/scijava/command/console/RunArgument.java +++ b/src/main/java/org/scijava/command/console/RunArgument.java @@ -35,8 +35,11 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; import org.scijava.command.CommandInfo; +import org.scijava.command.CommandModule; import org.scijava.command.CommandService; import org.scijava.console.AbstractConsoleArgument; import org.scijava.console.ConsoleArgument; @@ -106,7 +109,7 @@ private void run(final String commandToRun, final String optionString) { final File scriptFile = new File(commandToRun); if (scriptFile.exists() && scriptService.canHandleFile(commandToRun)) { try { - scriptService.run(scriptFile, true, inputMap); + scriptService.run(scriptFile, true, inputMap).get(); } catch (final Exception exc) { logService.error(exc); } @@ -129,7 +132,10 @@ private void run(final String commandToRun, final String optionString) { // couldn't find anything to run if (info == null) return; // TODO: parse the optionString a la ImageJ1 - commandService.run(info, true, inputMap); + try { + commandService.run(info, true, inputMap).get(); + } catch (final Exception exc) { + logService.error(exc); + } } - } From 7ea047d1d3926f1d8f5856f4a282d9a47295694f Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Fri, 12 Feb 2016 14:21:04 -0600 Subject: [PATCH 0096/1208] UIService: add headless methods Add isHeadless and setHeadless methods to the UIService. These methods delegate directly to the "java.awt.headless" system property. --- src/main/java/org/scijava/ui/DefaultUIService.java | 12 +++++++++++- src/main/java/org/scijava/ui/UIService.java | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/ui/DefaultUIService.java b/src/main/java/org/scijava/ui/DefaultUIService.java index fd381c41c..ebaaf00cd 100644 --- a/src/main/java/org/scijava/ui/DefaultUIService.java +++ b/src/main/java/org/scijava/ui/DefaultUIService.java @@ -203,6 +203,17 @@ public boolean isVisible(final String name) { return ui.isVisible(); } + + @Override + public void setHeadless(final boolean headless) { + System.setProperty("java.awt.headless", String.valueOf(headless)); + } + + @Override + public boolean isHeadless() { + return Boolean.getBoolean("java.awt.headless"); + } + @Override public UserInterface getDefaultUI() { if (defaultUI != null) return defaultUI; @@ -527,5 +538,4 @@ private void addUserInterface(final String name, final UserInterface ui) { private String getTitle() { return appService.getApp().getTitle(); } - } diff --git a/src/main/java/org/scijava/ui/UIService.java b/src/main/java/org/scijava/ui/UIService.java index b5c6a03e7..1fe2bbd79 100644 --- a/src/main/java/org/scijava/ui/UIService.java +++ b/src/main/java/org/scijava/ui/UIService.java @@ -102,6 +102,12 @@ public interface UIService extends SciJavaService { /** Gets whether the UI with the given name or class name is visible. */ boolean isVisible(String name); + /** Sets whether the application is running in headless mode (no UI). */ + void setHeadless(boolean isHeadless); + + /** Gets whether the UI is running in headless mode (no UI). */ + boolean isHeadless(); + /** * Gets the default user interface. * From 51b6e83463bd4e0186d404334b024ed356ba4040 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Fri, 12 Feb 2016 14:59:37 -0600 Subject: [PATCH 0097/1208] Extract handles logic to AbstractConsoleArgument Argument implementations can now declare their minimum size and aliases and let the abstract layer handle the bulk of the matching. --- .../scijava/command/console/RunArgument.java | 16 ++++------ .../console/AbstractConsoleArgument.java | 32 +++++++++++++++++++ .../console/SystemPropertyArgument.java | 8 ++++- .../org/scijava/io/console/OpenArgument.java | 14 ++++---- .../scijava/main/console/MainArgument.java | 16 +++++----- .../org/scijava/ui/console/UIArgument.java | 13 ++++---- .../scijava/console/ConsoleServiceTest.java | 9 +++--- 7 files changed, 69 insertions(+), 39 deletions(-) diff --git a/src/main/java/org/scijava/command/console/RunArgument.java b/src/main/java/org/scijava/command/console/RunArgument.java index 9a5e73c35..e340d09fe 100644 --- a/src/main/java/org/scijava/command/console/RunArgument.java +++ b/src/main/java/org/scijava/command/console/RunArgument.java @@ -35,11 +35,8 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; import org.scijava.command.CommandInfo; -import org.scijava.command.CommandModule; import org.scijava.command.CommandService; import org.scijava.console.AbstractConsoleArgument; import org.scijava.console.ConsoleArgument; @@ -67,6 +64,12 @@ public class RunArgument extends AbstractConsoleArgument { @Parameter private LogService logService; + // -- Constructor -- + + public RunArgument() { + super(2, "--run"); + } + // -- ConsoleArgument methods -- @Override @@ -80,13 +83,6 @@ public void handle(final LinkedList args) { run(commandToRun, optionString); } - // -- Typed methods -- - - @Override - public boolean supports(final LinkedList args) { - return args != null && args.size() >= 2 && args.getFirst().equals("--run"); - } - // -- Helper methods -- /** Implements the {@code --run} command line argument. */ diff --git a/src/main/java/org/scijava/console/AbstractConsoleArgument.java b/src/main/java/org/scijava/console/AbstractConsoleArgument.java index f6806ab3d..0aa170e03 100644 --- a/src/main/java/org/scijava/console/AbstractConsoleArgument.java +++ b/src/main/java/org/scijava/console/AbstractConsoleArgument.java @@ -31,7 +31,9 @@ package org.scijava.console; +import java.util.HashSet; import java.util.LinkedList; +import java.util.Set; import org.scijava.plugin.AbstractHandlerPlugin; @@ -43,13 +45,43 @@ public abstract class AbstractConsoleArgument extends AbstractHandlerPlugin> implements ConsoleArgument { + private int numArgs; + private Set aliasFlags; + + public AbstractConsoleArgument() { + this(1, new String[0]); + } + + public AbstractConsoleArgument(final String... aliases) { + this(1, aliases); + } + + public AbstractConsoleArgument(final int requiredArgs, final String... aliases) { + numArgs = requiredArgs; + aliasFlags = new HashSet(); + for (final String s : aliases) aliasFlags.add(s); + } // -- Typed methods -- + @Override + public boolean supports(final LinkedList args) { + if (args == null || args.size() < numArgs) return false; + return isAlias(args); + } + @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public Class> getType() { return (Class) String.class; } + /** + * @return true if there are no aliases for this {@code ConsoleArgument}, or + * at least one alias matches the first argument in the provided + * list + */ + protected boolean isAlias(final LinkedList args) { + return aliasFlags.isEmpty() || aliasFlags.contains(args.getFirst()); + } } diff --git a/src/main/java/org/scijava/console/SystemPropertyArgument.java b/src/main/java/org/scijava/console/SystemPropertyArgument.java index 8202f8ce9..ad3b94bff 100644 --- a/src/main/java/org/scijava/console/SystemPropertyArgument.java +++ b/src/main/java/org/scijava/console/SystemPropertyArgument.java @@ -49,6 +49,12 @@ public class SystemPropertyArgument extends AbstractConsoleArgument { private static final String SYS_PROP_REGEX = "-D([\\w\\._-]+)(=(.*))?"; private static final Pattern SYS_PROP_PAT = Pattern.compile(SYS_PROP_REGEX); + // -- Constructor -- + + public SystemPropertyArgument() { + super(1); + } + // -- ConsoleArgument methods -- @Override @@ -69,7 +75,7 @@ public void handle(final LinkedList args) { @Override public boolean supports(final LinkedList args) { - if (args == null || args.isEmpty()) return false; + if (!super.supports(args)) return false; final String arg = args.getFirst(); if (!arg.startsWith("-D")) return false; return SYS_PROP_PAT.matcher(arg).matches(); diff --git a/src/main/java/org/scijava/io/console/OpenArgument.java b/src/main/java/org/scijava/io/console/OpenArgument.java index 9b271ed4c..36a4668f1 100644 --- a/src/main/java/org/scijava/io/console/OpenArgument.java +++ b/src/main/java/org/scijava/io/console/OpenArgument.java @@ -59,6 +59,12 @@ public class OpenArgument extends AbstractConsoleArgument { @Parameter private LogService log; + // -- Constructor -- + + public OpenArgument() { + super(2, "--open"); + } + // -- ConsoleArgument methods -- @Override @@ -76,12 +82,4 @@ public void handle(final LinkedList args) { log.error(exc); } } - - // -- Typed methods -- - - @Override - public boolean supports(final LinkedList args) { - return args != null && args.size() >= 2 && args.getFirst().equals("--open"); - } - } diff --git a/src/main/java/org/scijava/main/console/MainArgument.java b/src/main/java/org/scijava/main/console/MainArgument.java index 45551f2a9..152182ae9 100644 --- a/src/main/java/org/scijava/main/console/MainArgument.java +++ b/src/main/java/org/scijava/main/console/MainArgument.java @@ -57,6 +57,12 @@ public class MainArgument extends AbstractConsoleArgument { @Parameter(required = false) private LogService log; + // -- Constructor -- + + public MainArgument() { + super(2, "--main", "--main-class"); + } + // -- ConsoleArgument methods -- @Override @@ -67,7 +73,7 @@ public void handle(final LinkedList args) { final String className = args.removeFirst(); final List argList = new ArrayList(); - while (!args.isEmpty() && !isMainFlag(args) && !isSeparator(args)) { + while (!args.isEmpty() && !isAlias(args) && !isSeparator(args)) { argList.add(args.removeFirst()); } if (isSeparator(args)) args.removeFirst(); // remove the -- separator @@ -80,17 +86,11 @@ public void handle(final LinkedList args) { @Override public boolean supports(final LinkedList args) { - return mainService != null && isMainFlag(args); + return mainService != null && super.supports(args); } // -- Helper methods -- - private boolean isMainFlag(final LinkedList args) { - if (args == null || args.isEmpty()) return false; - final String arg = args.getFirst(); - return arg.equals("--main") || arg.equals("--main-class"); - } - private boolean isSeparator(final LinkedList args) { if (args == null || args.isEmpty()) return false; return args.getFirst().equals("--"); diff --git a/src/main/java/org/scijava/ui/console/UIArgument.java b/src/main/java/org/scijava/ui/console/UIArgument.java index 018b8059c..ca4611406 100644 --- a/src/main/java/org/scijava/ui/console/UIArgument.java +++ b/src/main/java/org/scijava/ui/console/UIArgument.java @@ -55,6 +55,12 @@ public class UIArgument extends AbstractConsoleArgument { @Parameter private LogService log; + // -- Constructor -- + + public UIArgument() { + super(2, "--ui"); + } + // -- ConsoleArgument methods -- @Override @@ -73,11 +79,4 @@ public void handle(final LinkedList args) { } } - // -- Typed methods -- - - @Override - public boolean supports(final LinkedList args) { - return args != null && args.size() >= 2 && args.getFirst().equals("--ui"); - } - } diff --git a/src/test/java/org/scijava/console/ConsoleServiceTest.java b/src/test/java/org/scijava/console/ConsoleServiceTest.java index 07440ef33..992723f8d 100644 --- a/src/test/java/org/scijava/console/ConsoleServiceTest.java +++ b/src/test/java/org/scijava/console/ConsoleServiceTest.java @@ -208,6 +208,10 @@ private void assertOutputEvent(final Source source, final String output, @Plugin(type = ConsoleArgument.class, priority = Priority.HIGH_PRIORITY) public static class FooArgument extends AbstractConsoleArgument { + public FooArgument() { + super(1, "--foo"); + } + private boolean argsHandled; @Override @@ -219,11 +223,6 @@ public void handle(final LinkedList args) { args.clear(); argsHandled = true; } - - @Override - public boolean supports(final LinkedList args) { - return !args.isEmpty() && args.getFirst().equals("--foo"); - } } private static class OutputTracker implements OutputListener { From 17ccc397606a42a1279ccfc6896401d4b51513da Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Fri, 12 Feb 2016 12:12:24 -0600 Subject: [PATCH 0098/1208] Add HeadlessArgument For dealing with the --headless flag --- .../org/scijava/console/HeadlessArgument.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/main/java/org/scijava/console/HeadlessArgument.java diff --git a/src/main/java/org/scijava/console/HeadlessArgument.java b/src/main/java/org/scijava/console/HeadlessArgument.java new file mode 100644 index 000000000..e075c9250 --- /dev/null +++ b/src/main/java/org/scijava/console/HeadlessArgument.java @@ -0,0 +1,76 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package org.scijava.console; + +import java.util.LinkedList; + +import org.scijava.Context; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; +import org.scijava.ui.UIService; + +/** + * Handles the {@code --headless} argument to signal that no UI will be opened + * and the enclosing {@link Context} will not be used after the + * {@link ConsoleService} argument processing is complete. + * + * @author Mark Hiner hinerm at gmail.com + */ +@Plugin(type = ConsoleArgument.class) +public class HeadlessArgument extends AbstractConsoleArgument { + + @Parameter(required = false) + private UIService uiService; + + // -- Constructor -- + + public HeadlessArgument() { + super(1, "--headless"); + } + + // -- ConsoleArgument methods -- + + @Override + public void handle(final LinkedList args) { + if (!supports(args)) return; + + args.removeFirst(); // --headless + + uiService.setHeadless(true); + } + // -- Typed methods -- + + @Override + public boolean supports(final LinkedList args) { + return uiService != null && super.supports(args); + } + +} From ca551badaccd55aef8b7b13db425f49901c9c162 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Tue, 16 Feb 2016 07:55:34 -0600 Subject: [PATCH 0099/1208] Split RunArgument script logic to new class RunArgument now handles commands exclusively, while RunScriptArgument handles scripts. Shared logic between these classes (input mapping) is moved to a ConsoleUtils utility class. --- .../scijava/command/console/RunArgument.java | 76 +++++------ .../org/scijava/console/ConsoleUtils.java | 66 ++++++++++ .../script/console/RunScriptArgument.java | 118 ++++++++++++++++++ 3 files changed, 218 insertions(+), 42 deletions(-) create mode 100644 src/main/java/org/scijava/console/ConsoleUtils.java create mode 100644 src/main/java/org/scijava/script/console/RunScriptArgument.java diff --git a/src/main/java/org/scijava/command/console/RunArgument.java b/src/main/java/org/scijava/command/console/RunArgument.java index e340d09fe..4d99e817a 100644 --- a/src/main/java/org/scijava/command/console/RunArgument.java +++ b/src/main/java/org/scijava/command/console/RunArgument.java @@ -31,8 +31,6 @@ package org.scijava.command.console; -import java.io.File; -import java.util.HashMap; import java.util.LinkedList; import java.util.Map; @@ -40,14 +38,14 @@ import org.scijava.command.CommandService; import org.scijava.console.AbstractConsoleArgument; import org.scijava.console.ConsoleArgument; +import org.scijava.console.ConsoleUtils; import org.scijava.log.LogService; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; -import org.scijava.script.ScriptService; /** * Handles the {@code --run} command line argument. - * + * * @author Curtis Rueden * @author Johannes Schindelin * @author Mark Hiner hinerm at gmail.com @@ -58,61 +56,63 @@ public class RunArgument extends AbstractConsoleArgument { @Parameter private CommandService commandService; - @Parameter - private ScriptService scriptService; - @Parameter private LogService logService; // -- Constructor -- public RunArgument() { - super(2, "--run"); + super(2, "--run", "--class"); } // -- ConsoleArgument methods -- @Override public void handle(final LinkedList args) { - if (!supports(args)) return; + if (!supports(args)) + return; args.removeFirst(); // --run final String commandToRun = args.removeFirst(); - final String optionString = args.isEmpty() ? "" : args.removeFirst(); + final String paramString = args.isEmpty() ? "" : args.removeFirst(); - run(commandToRun, optionString); + run(commandToRun, paramString); + } + + // -- Typed methods -- + + @Override + public boolean supports(final LinkedList args) { + if (!super.supports(args)) + return false; + return getInfo(args.get(1)) != null; } // -- Helper methods -- /** Implements the {@code --run} command line argument. */ private void run(final String commandToRun, final String optionString) { - final Map inputMap = new HashMap(); - - if (!optionString.isEmpty()) { - final String[] pairs = optionString.split(","); - for (final String pair : pairs) { - final String[] split = pair.split("="); - if (split.length != 2) { - logService.error("Parameters must be formatted as a comma-separated list of key=value pairs"); - return; - } - inputMap.put(split[0], split[1]); - } - } + // get the command info + final CommandInfo info = getInfo(commandToRun); - // first check if this is a script - final File scriptFile = new File(commandToRun); - if (scriptFile.exists() && scriptService.canHandleFile(commandToRun)) { - try { - scriptService.run(scriptFile, true, inputMap).get(); - } catch (final Exception exc) { - logService.error(exc); - } + // couldn't find anything to run + if (info == null) return; + + // TODO: parse the optionString a la ImageJ1 + final Map inputMap = ConsoleUtils.parseParameterString(optionString, logService); + + try { + commandService.run(info, true, inputMap).get(); + } catch (final Exception exc) { + logService.error(exc); } + } - // Not a script, check if it's a command class + /** + * Try to convert the given string to a {@link CommandInfo} + */ + private CommandInfo getInfo(final String commandToRun) { CommandInfo info = commandService.getCommand(commandToRun); if (info == null) { // command was not a class name; search for command by title instead @@ -124,14 +124,6 @@ private void run(final String commandToRun, final String optionString) { } } } - - // couldn't find anything to run - if (info == null) return; - // TODO: parse the optionString a la ImageJ1 - try { - commandService.run(info, true, inputMap).get(); - } catch (final Exception exc) { - logService.error(exc); - } + return info; } } diff --git a/src/main/java/org/scijava/console/ConsoleUtils.java b/src/main/java/org/scijava/console/ConsoleUtils.java new file mode 100644 index 000000000..74a75c6f1 --- /dev/null +++ b/src/main/java/org/scijava/console/ConsoleUtils.java @@ -0,0 +1,66 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package org.scijava.console; + +import java.util.HashMap; +import java.util.Map; + +import org.scijava.log.LogService; + +/** + * Helper class for {@link ConsoleArgument}s. + * + * @author Mark Hiner hinerm at gmail.com + */ +public final class ConsoleUtils { + + public static Map parseParameterString(final String parameterString) { + return parseParameterString(parameterString, null); + } + + public static Map parseParameterString(final String parameterString, final LogService logService) { + final Map inputMap = new HashMap(); + + if (!parameterString.isEmpty()) { + final String[] pairs = parameterString.split(","); + for (final String pair : pairs) { + final String[] split = pair.split("="); + if (split.length == 2) + inputMap.put(split[0], split[1]); + else if (logService != null) + logService.error("Parameters must be formatted as a comma-separated list of key=value pairs"); + + } + } + + return inputMap; + } +} diff --git a/src/main/java/org/scijava/script/console/RunScriptArgument.java b/src/main/java/org/scijava/script/console/RunScriptArgument.java new file mode 100644 index 000000000..e8427a67a --- /dev/null +++ b/src/main/java/org/scijava/script/console/RunScriptArgument.java @@ -0,0 +1,118 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package org.scijava.script.console; + +import java.io.File; +import java.util.LinkedList; +import java.util.Map; + +import org.scijava.console.AbstractConsoleArgument; +import org.scijava.console.ConsoleArgument; +import org.scijava.console.ConsoleUtils; +import org.scijava.log.LogService; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; +import org.scijava.script.ScriptService; + +/** + * {@link ConsoleArgument} for executing scripts directly. + * + * @author Mark Hiner hinerm at gmail.com + */ +@Plugin(type = ConsoleArgument.class) +public class RunScriptArgument extends AbstractConsoleArgument { + + @Parameter + private ScriptService scriptService; + + @Parameter + private LogService logService; + + // -- Constructor -- + + public RunScriptArgument() { + super(2, "--run", "--script"); + } + + // -- ConsoleArgument methods -- + + @Override + public void handle(final LinkedList args) { + if (!supports(args)) + return; + + args.removeFirst(); // --run + final String scriptToRun = args.removeFirst(); + final String paramString = args.isEmpty() ? "" : args.removeFirst(); + + run(scriptToRun, paramString); + } + + // -- Typed methods -- + + @Override + public boolean supports(final LinkedList args) { + if (!super.supports(args)) + return false; + return getScript(args.get(1)) != null; + } + + // -- Helper methods -- + + /** + * Run the script + */ + private void run(final String scriptToRun, final String paramString) { + final File script = getScript(scriptToRun); + + // couldn't find anything to run + if (script == null) + return; + + // TODO: parse the optionString a la ImageJ1 + final Map inputMap = ConsoleUtils.parseParameterString(paramString, logService); + + try { + scriptService.run(script, true, inputMap).get(); + } catch (final Exception exc) { + logService.error(exc); + } + } + + /** + * Try to convert the given string to a {@link File} representing a + * supported script type. + */ + private File getScript(final String string) { + final File scriptFile = new File(string); + return scriptFile.exists() && scriptService.canHandleFile(scriptFile) ? scriptFile : null; + } +} From 88775ec6af71a0c6e7dd9a9027b5f5c971e0f917 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Tue, 16 Feb 2016 08:45:33 -0600 Subject: [PATCH 0100/1208] ScriptService: getScript now creates the script To avoid a proliferation of case logic and repeated creation code, ScriptService needs public API that retrieves a cached script and creates it if it doesn't exist. It is not necessary to have both a lookup-only and a lookup-and-create method: if an API consumer wants to check the existence of a ScriptInfo, the containing Collection is accessible. Thus getScript now simply creates the ScriptInfo if it does not already exist. --- src/main/java/org/scijava/script/DefaultScriptService.java | 4 ++-- src/main/java/org/scijava/script/ScriptService.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index 1883a960a..376ff22ae 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -169,7 +169,7 @@ public Collection getScripts() { @Override public ScriptInfo getScript(final File scriptFile) { - return scripts().get(scriptFile); + return getOrCreate(scriptFile); } @Override @@ -455,7 +455,7 @@ private void addAliases(final HashMap> map, * are registered with the service. */ private ScriptInfo getOrCreate(final File file) { - final ScriptInfo info = getScript(file); + final ScriptInfo info = scripts().get(file); if (info != null) return info; return new ScriptInfo(getContext(), file); } diff --git a/src/main/java/org/scijava/script/ScriptService.java b/src/main/java/org/scijava/script/ScriptService.java index 629d28fb3..a9f1f470e 100644 --- a/src/main/java/org/scijava/script/ScriptService.java +++ b/src/main/java/org/scijava/script/ScriptService.java @@ -117,8 +117,8 @@ public interface ScriptService extends SingletonService, Collection getScripts(); /** - * Gets the {@link ScriptInfo} metadata for the script at the given file, or - * null if none. + * Gets the cached {@link ScriptInfo} metadata for the script at the given + * file, creating it if it does not already exist. */ ScriptInfo getScript(File scriptFile); From 1cf0e296b08495d8634e6148fa91ba6f3c30ca0e Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Tue, 16 Feb 2016 08:50:11 -0600 Subject: [PATCH 0101/1208] ConsoleUtils: attempt to match singleton params It is not practical to require users to know the names of script parameters to call the script. If script params are mapped with =, great. If not, we can try to match them with the parameters of the script. NB: this requires that script parameters be written in a reasonable ordering, such that user-supplied params come before system-supplied params. --- .../scijava/command/console/RunArgument.java | 2 +- .../org/scijava/console/ConsoleUtils.java | 22 ++++++++++++++++++- .../script/console/RunScriptArgument.java | 8 ++++--- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/command/console/RunArgument.java b/src/main/java/org/scijava/command/console/RunArgument.java index 4d99e817a..6d44e8b88 100644 --- a/src/main/java/org/scijava/command/console/RunArgument.java +++ b/src/main/java/org/scijava/command/console/RunArgument.java @@ -100,7 +100,7 @@ private void run(final String commandToRun, final String optionString) { return; // TODO: parse the optionString a la ImageJ1 - final Map inputMap = ConsoleUtils.parseParameterString(optionString, logService); + final Map inputMap = ConsoleUtils.parseParameterString(optionString, info, logService); try { commandService.run(info, true, inputMap).get(); diff --git a/src/main/java/org/scijava/console/ConsoleUtils.java b/src/main/java/org/scijava/console/ConsoleUtils.java index 74a75c6f1..3e1557fef 100644 --- a/src/main/java/org/scijava/console/ConsoleUtils.java +++ b/src/main/java/org/scijava/console/ConsoleUtils.java @@ -31,9 +31,13 @@ package org.scijava.console; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; +import org.scijava.command.CommandInfo; import org.scijava.log.LogService; +import org.scijava.module.ModuleInfo; +import org.scijava.module.ModuleItem; /** * Helper class for {@link ConsoleArgument}s. @@ -43,18 +47,33 @@ public final class ConsoleUtils { public static Map parseParameterString(final String parameterString) { - return parseParameterString(parameterString, null); + return parseParameterString(parameterString, (CommandInfo)null); + } + + public static Map parseParameterString(final String parameterString, final ModuleInfo info) { + return parseParameterString(parameterString, info, null); } public static Map parseParameterString(final String parameterString, final LogService logService) { + return parseParameterString(parameterString, null, logService); + } + + public static Map parseParameterString(final String parameterString, final ModuleInfo info, final LogService logService) { final Map inputMap = new HashMap(); if (!parameterString.isEmpty()) { + Iterator> inputs = null; + if (info != null) { + inputs = info.inputs().iterator(); + } final String[] pairs = parameterString.split(","); for (final String pair : pairs) { final String[] split = pair.split("="); if (split.length == 2) inputMap.put(split[0], split[1]); + else if (inputs != null && inputs.hasNext() && split.length == 1) { + inputMap.put(inputs.next().getName(), split[0]); + } else if (logService != null) logService.error("Parameters must be formatted as a comma-separated list of key=value pairs"); @@ -62,5 +81,6 @@ else if (logService != null) } return inputMap; + } } diff --git a/src/main/java/org/scijava/script/console/RunScriptArgument.java b/src/main/java/org/scijava/script/console/RunScriptArgument.java index e8427a67a..5b12156d3 100644 --- a/src/main/java/org/scijava/script/console/RunScriptArgument.java +++ b/src/main/java/org/scijava/script/console/RunScriptArgument.java @@ -40,6 +40,7 @@ import org.scijava.log.LogService; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; +import org.scijava.script.ScriptInfo; import org.scijava.script.ScriptService; /** @@ -97,11 +98,12 @@ private void run(final String scriptToRun, final String paramString) { if (script == null) return; - // TODO: parse the optionString a la ImageJ1 - final Map inputMap = ConsoleUtils.parseParameterString(paramString, logService); + final ScriptInfo info = scriptService.getScript(script); + + final Map inputMap = ConsoleUtils.parseParameterString(paramString, info, logService); try { - scriptService.run(script, true, inputMap).get(); + scriptService.run(info, true, inputMap).get(); } catch (final Exception exc) { logService.error(exc); } From 6913c42c138f7d9556215ba5f1c4f9a29f95b885 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Tue, 16 Feb 2016 09:40:02 -0600 Subject: [PATCH 0102/1208] DisplayPostprocessor: set name if creating display The Display name is not guaranteed to be null by default: it is up to the implementation of each DisplayPlugin. A common case is that the default name will come back as "Untitled-#" if not specified, which will then supercede the requested output name. To avoid this, the DisplayPostprocessor should always pass the default name when creating a display. --- src/main/java/org/scijava/display/DisplayPostprocessor.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/display/DisplayPostprocessor.java b/src/main/java/org/scijava/display/DisplayPostprocessor.java index 092122db3..986a3a458 100644 --- a/src/main/java/org/scijava/display/DisplayPostprocessor.java +++ b/src/main/java/org/scijava/display/DisplayPostprocessor.java @@ -113,13 +113,9 @@ private void handleOutput(final String defaultName, final Object output) { } else { // create a new display for the output - final Display display = displayService.createDisplay(output); + final Display display = displayService.createDisplay(defaultName, output); if (display != null) { displays.add(display); - if (display.getName() == null) { - // set a default name based on the parameter - display.setName(defaultName); - } } } } From 92a9a94391e82b229e0b661d5fd13a80dc56a4db Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 16 Feb 2016 14:58:24 -0600 Subject: [PATCH 0103/1208] SciJavaPlugin: list more plugin types in the doc --- src/main/java/org/scijava/plugin/SciJavaPlugin.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/scijava/plugin/SciJavaPlugin.java b/src/main/java/org/scijava/plugin/SciJavaPlugin.java index d1f8c22c2..001094ba6 100644 --- a/src/main/java/org/scijava/plugin/SciJavaPlugin.java +++ b/src/main/java/org/scijava/plugin/SciJavaPlugin.java @@ -45,8 +45,11 @@ *
  • {@link org.scijava.command.Command} - plugins that are executable. These * plugins typically perform a discrete operation, and are accessible via the * application menus.
  • + *
  • {@link org.scijava.console.ConsoleArgument} - plugins that handle + * arguments passed to the application as command line parameters.
  • *
  • {@link org.scijava.display.Display} - plugins that visualize objects, * often used to display module outputs.
  • + *
  • {@link org.scijava.io.IOPlugin} - plugins that read or write data.
  • *
  • {@link org.scijava.module.process.PreprocessorPlugin} - plugins that * perform preprocessing on modules. A preprocessor plugin is a discoverable * {@link org.scijava.module.process.ModulePreprocessor}.
  • @@ -56,6 +59,8 @@ * {@link org.scijava.module.process.ModulePostprocessor}. *
  • {@link org.scijava.platform.Platform} - plugins for defining * platform-specific behavior.
  • + *
  • {@link org.scijava.script.ScriptLanguage} - plugins that enable executing + * scripts in particular languages as SciJava modules.
  • *
  • {@link org.scijava.service.Service} - plugins that define new API in a * particular area.
  • *
  • {@link org.scijava.tool.Tool} - plugins that map user input (e.g., From 240903732374730f5258bdc5ca882a44dc1ca131 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Tue, 16 Feb 2016 11:11:19 -0600 Subject: [PATCH 0104/1208] Revert "DisplayPostprocessor: set name if creating display" This reverts commit 6913c42c138f7d9556215ba5f1c4f9a29f95b885, which was attempting to a fix a bug actually determined to be in imagej-common. See https://github.com/imagej/imagej-common/commit/c3cf15ad8449e07ae42516f7c35025b0f6e595a0 --- src/main/java/org/scijava/display/DisplayPostprocessor.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/display/DisplayPostprocessor.java b/src/main/java/org/scijava/display/DisplayPostprocessor.java index 986a3a458..092122db3 100644 --- a/src/main/java/org/scijava/display/DisplayPostprocessor.java +++ b/src/main/java/org/scijava/display/DisplayPostprocessor.java @@ -113,9 +113,13 @@ private void handleOutput(final String defaultName, final Object output) { } else { // create a new display for the output - final Display display = displayService.createDisplay(defaultName, output); + final Display display = displayService.createDisplay(output); if (display != null) { displays.add(display); + if (display.getName() == null) { + // set a default name based on the parameter + display.setName(defaultName); + } } } } From 4e876d6b99529a51c2c8199ac72c168a10010d1d Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 17 Feb 2016 12:04:30 -0600 Subject: [PATCH 0105/1208] ConvertService: update getCompatibleInputs docs Add javadoc and move out of deprecated section --- src/main/java/org/scijava/convert/ConvertService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/convert/ConvertService.java b/src/main/java/org/scijava/convert/ConvertService.java index 555a270bd..b678007ff 100644 --- a/src/main/java/org/scijava/convert/ConvertService.java +++ b/src/main/java/org/scijava/convert/ConvertService.java @@ -83,6 +83,12 @@ public interface ConvertService extends */ boolean supports(Object src, Type dest); + /** + * @return A collection of instances that could be converted to the + * specified class. + */ + Collection getCompatibleInputs(Class dest); + // -- Deprecated API -- /** @@ -112,6 +118,4 @@ public interface ConvertService extends */ @Deprecated boolean supports(Class src, Type dest); - - Collection getCompatibleInputs(Class dest); } From 60a94572e8b08dbc1ec7833bdb38497013d88220 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 17 Feb 2016 12:22:49 -0600 Subject: [PATCH 0106/1208] ConvertService: add getCompatibleClasses methods For obtaining collections of compatible input and output classes. --- .../convert/AbstractConvertService.java | 34 +++++++++++++++++++ .../org/scijava/convert/ConvertService.java | 12 +++++++ 2 files changed, 46 insertions(+) diff --git a/src/main/java/org/scijava/convert/AbstractConvertService.java b/src/main/java/org/scijava/convert/AbstractConvertService.java index 3f9a37ef9..e626097b7 100644 --- a/src/main/java/org/scijava/convert/AbstractConvertService.java +++ b/src/main/java/org/scijava/convert/AbstractConvertService.java @@ -32,6 +32,9 @@ package org.scijava.convert; import java.lang.reflect.Type; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; import org.scijava.plugin.AbstractHandlerService; import org.scijava.util.ConversionUtils; @@ -68,10 +71,41 @@ public Object convert(ConversionRequest request) { return handler == null ? null : handler.convert(request); } + @Override + public Collection> getCompatibleInputClasses(Class dest) { + Set> compatibleClasses = new HashSet>(); + + for (Converter converter : getInstances()) { + addIfMatches(dest, converter.getOutputType(), converter.getInputType(), compatibleClasses); + } + + return compatibleClasses; + } + + @Override + public Collection> getCompatibleOutputClasses(Class source) { + Set> compatibleClasses = new HashSet>(); + + for (Converter converter : getInstances()) { + addIfMatches(source, converter.getInputType(), converter.getOutputType(), compatibleClasses); + } + + return compatibleClasses; + } + // -- Service methods -- @Override public void initialize() { ConversionUtils.setDelegateService(this, getPriority()); } + + // -- Helper methods -- + + /** + * Test two classes; if they match, a third class is added to the provided set of classes. + */ + private void addIfMatches(Class c1, Class c2, Class toAdd, Set> classes) { + if (c1 == c2) classes.add(toAdd); + } } diff --git a/src/main/java/org/scijava/convert/ConvertService.java b/src/main/java/org/scijava/convert/ConvertService.java index b678007ff..adb219061 100644 --- a/src/main/java/org/scijava/convert/ConvertService.java +++ b/src/main/java/org/scijava/convert/ConvertService.java @@ -89,6 +89,18 @@ public interface ConvertService extends */ Collection getCompatibleInputs(Class dest); + /** + * @return A collection of all classes that could potentially be converted + * to the specified class. + */ + Collection> getCompatibleInputClasses(Class dest); + + /** + * @return A collection of all classes that could potentially be converted + * from the specified class. + */ + Collection> getCompatibleOutputClasses(Class dest); + // -- Deprecated API -- /** From 4ecbb8d147785fb050298841fa0fd42332cd792d Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 17 Feb 2016 12:24:21 -0600 Subject: [PATCH 0107/1208] Move implementations to AbstractConvertService There was no logic that needed to be specified outside an Abstract layer. --- .../convert/AbstractConvertService.java | 65 +++++++++++++++++ .../convert/DefaultConvertService.java | 73 +------------------ 2 files changed, 66 insertions(+), 72 deletions(-) diff --git a/src/main/java/org/scijava/convert/AbstractConvertService.java b/src/main/java/org/scijava/convert/AbstractConvertService.java index e626097b7..01fef9974 100644 --- a/src/main/java/org/scijava/convert/AbstractConvertService.java +++ b/src/main/java/org/scijava/convert/AbstractConvertService.java @@ -32,8 +32,10 @@ package org.scijava.convert; import java.lang.reflect.Type; +import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import org.scijava.plugin.AbstractHandlerService; @@ -51,6 +53,69 @@ public abstract class AbstractConvertService extends { // -- ConversionService methods -- + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public Class> getPluginType() { + return (Class)Converter.class; + } + + @Override + public Class getType() { + return ConversionRequest.class; + } + + @Override + public Converter getHandler(final Object src, final Class dest) { + return getHandler(new ConversionRequest(src, dest)); + } + + @Override + public Converter getHandler(final Class src, final Class dest) { + return getHandler(new ConversionRequest(src, dest)); + } + + @Override + public Converter getHandler(final Object src, final Type dest) { + return getHandler(new ConversionRequest(src, dest)); + } + + @Override + public Converter getHandler(final Class src, final Type dest) { + return getHandler(new ConversionRequest(src, dest)); + } + + @Override + public boolean supports(final Object src, final Class dest) { + return supports(new ConversionRequest(src, dest)); + } + + @Override + public boolean supports(final Class src, final Class dest) { + return supports(new ConversionRequest(src, dest)); + } + + @Override + public boolean supports(final Object src, final Type dest) { + return supports(new ConversionRequest(src, dest)); + } + + @Override + public boolean supports(final Class src, final Type dest) { + return supports(new ConversionRequest(src, dest)); + } + + @Override + public Collection getCompatibleInputs(Class dest) { + Set objects = new LinkedHashSet(); + + for (final Converter c : getInstances()) { + if (dest.isAssignableFrom(c.getOutputType())) { + c.populateInputCandidates(objects); + } + } + + return new ArrayList(objects); + } @Override public Object convert(Object src, Type dest) { diff --git a/src/main/java/org/scijava/convert/DefaultConvertService.java b/src/main/java/org/scijava/convert/DefaultConvertService.java index 1f2318a95..6249432c7 100644 --- a/src/main/java/org/scijava/convert/DefaultConvertService.java +++ b/src/main/java/org/scijava/convert/DefaultConvertService.java @@ -31,12 +31,6 @@ package org.scijava.convert; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashSet; -import java.util.Set; - import org.scijava.plugin.Plugin; import org.scijava.service.Service; @@ -48,70 +42,5 @@ @Plugin(type = Service.class) public class DefaultConvertService extends AbstractConvertService { - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public Class> getPluginType() { - return (Class)Converter.class; - } - - @Override - public Class getType() { - return ConversionRequest.class; - } - - // -- ConversionService methods -- - - @Override - public Converter getHandler(final Object src, final Class dest) { - return getHandler(new ConversionRequest(src, dest)); - } - - @Override - public Converter getHandler(final Class src, final Class dest) { - return getHandler(new ConversionRequest(src, dest)); - } - - @Override - public Converter getHandler(final Object src, final Type dest) { - return getHandler(new ConversionRequest(src, dest)); - } - - @Override - public Converter getHandler(final Class src, final Type dest) { - return getHandler(new ConversionRequest(src, dest)); - } - - @Override - public boolean supports(final Object src, final Class dest) { - return supports(new ConversionRequest(src, dest)); - } - - @Override - public boolean supports(final Class src, final Class dest) { - return supports(new ConversionRequest(src, dest)); - } - - @Override - public boolean supports(final Object src, final Type dest) { - return supports(new ConversionRequest(src, dest)); - } - - @Override - public boolean supports(final Class src, final Type dest) { - return supports(new ConversionRequest(src, dest)); - } - - @Override - public Collection getCompatibleInputs(Class dest) { - Set objects = new LinkedHashSet(); - - for (final Converter c : getInstances()) { - if (dest.isAssignableFrom(c.getOutputType())) { - c.populateInputCandidates(objects); - } - } - - return new ArrayList(objects); - } + // Trivial implementation } From 1e100de55aeecf64f821d2d8fc2de4c7316c2f30 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 17 Feb 2016 12:25:30 -0600 Subject: [PATCH 0108/1208] Remove convoluted getCompatibleInputs logic Given this method has a return type of Collection, there is no need to use an ordered set or to then build that set into a list. --- src/main/java/org/scijava/convert/AbstractConvertService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/convert/AbstractConvertService.java b/src/main/java/org/scijava/convert/AbstractConvertService.java index 01fef9974..15adab229 100644 --- a/src/main/java/org/scijava/convert/AbstractConvertService.java +++ b/src/main/java/org/scijava/convert/AbstractConvertService.java @@ -106,7 +106,7 @@ public boolean supports(final Class src, final Type dest) { @Override public Collection getCompatibleInputs(Class dest) { - Set objects = new LinkedHashSet(); + Set objects = new HashSet(); for (final Converter c : getInstances()) { if (dest.isAssignableFrom(c.getOutputType())) { @@ -114,7 +114,7 @@ public Collection getCompatibleInputs(Class dest) { } } - return new ArrayList(objects); + return objects; } @Override From 284e1be5bee581eec5adaa703a05d63ca99ace2f Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 17 Feb 2016 12:27:34 -0600 Subject: [PATCH 0109/1208] AbstractConvertService: apply code template --- .../convert/AbstractConvertService.java | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/scijava/convert/AbstractConvertService.java b/src/main/java/org/scijava/convert/AbstractConvertService.java index 15adab229..3db4ba433 100644 --- a/src/main/java/org/scijava/convert/AbstractConvertService.java +++ b/src/main/java/org/scijava/convert/AbstractConvertService.java @@ -32,31 +32,27 @@ package org.scijava.convert; import java.lang.reflect.Type; -import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; -import java.util.LinkedHashSet; import java.util.Set; import org.scijava.plugin.AbstractHandlerService; import org.scijava.util.ConversionUtils; /** - * Abstract superclass for {@link ConvertService} implementations. Sets - * this service as the active delegate service in {@link ConversionUtils}. + * Abstract superclass for {@link ConvertService} implementations. Sets this + * service as the active delegate service in {@link ConversionUtils}. * * @author Mark Hiner */ -public abstract class AbstractConvertService extends - AbstractHandlerService> implements - ConvertService -{ +public abstract class AbstractConvertService extends AbstractHandlerService> + implements ConvertService { // -- ConversionService methods -- @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Class> getPluginType() { - return (Class)Converter.class; + return (Class) Converter.class; } @Override @@ -105,8 +101,8 @@ public boolean supports(final Class src, final Type dest) { } @Override - public Collection getCompatibleInputs(Class dest) { - Set objects = new HashSet(); + public Collection getCompatibleInputs(final Class dest) { + final Set objects = new HashSet(); for (final Converter c : getInstances()) { if (dest.isAssignableFrom(c.getOutputType())) { @@ -118,29 +114,29 @@ public Collection getCompatibleInputs(Class dest) { } @Override - public Object convert(Object src, Type dest) { + public Object convert(final Object src, final Type dest) { return convert(new ConversionRequest(src, dest)); } @Override - public T convert(Object src, Class dest) { + public T convert(final Object src, final Class dest) { // NB: repeated code with convert(ConversionRequest), because the // handler's convert method respects the T provided - Converter handler = getHandler(src, dest); + final Converter handler = getHandler(src, dest); return handler == null ? null : handler.convert(src, dest); } @Override - public Object convert(ConversionRequest request) { - Converter handler = getHandler(request); + public Object convert(final ConversionRequest request) { + final Converter handler = getHandler(request); return handler == null ? null : handler.convert(request); } @Override - public Collection> getCompatibleInputClasses(Class dest) { - Set> compatibleClasses = new HashSet>(); + public Collection> getCompatibleInputClasses(final Class dest) { + final Set> compatibleClasses = new HashSet>(); - for (Converter converter : getInstances()) { + for (final Converter converter : getInstances()) { addIfMatches(dest, converter.getOutputType(), converter.getInputType(), compatibleClasses); } @@ -148,10 +144,10 @@ public Collection> getCompatibleInputClasses(Class dest) { } @Override - public Collection> getCompatibleOutputClasses(Class source) { - Set> compatibleClasses = new HashSet>(); + public Collection> getCompatibleOutputClasses(final Class source) { + final Set> compatibleClasses = new HashSet>(); - for (Converter converter : getInstances()) { + for (final Converter converter : getInstances()) { addIfMatches(source, converter.getInputType(), converter.getOutputType(), compatibleClasses); } @@ -168,9 +164,11 @@ public void initialize() { // -- Helper methods -- /** - * Test two classes; if they match, a third class is added to the provided set of classes. + * Test two classes; if they match, a third class is added to the provided + * set of classes. */ - private void addIfMatches(Class c1, Class c2, Class toAdd, Set> classes) { - if (c1 == c2) classes.add(toAdd); + private void addIfMatches(final Class c1, final Class c2, final Class toAdd, final Set> classes) { + if (c1 == c2) + classes.add(toAdd); } } From 6c2b116b3fb5f1925b6d0ac90884731e12be1e7b Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 17 Feb 2016 12:47:37 -0600 Subject: [PATCH 0110/1208] ModuleService: getSingleIn/Output for classes Add getSingleInput and getSingleOutput methods that can take a collection of classes to match. If there is a single unresolved input that matches any of these classes it will be identified. This enables generalized preprocessors that may want to handle multiple classes with similar logic (e.g. classes that can be easily converted). --- .../scijava/module/DefaultModuleService.java | 45 +++++++++++++++---- .../org/scijava/module/ModuleService.java | 12 +++++ 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/scijava/module/DefaultModuleService.java b/src/main/java/org/scijava/module/DefaultModuleService.java index 2bd74928f..0b6c619d8 100644 --- a/src/main/java/org/scijava/module/DefaultModuleService.java +++ b/src/main/java/org/scijava/module/DefaultModuleService.java @@ -33,8 +33,10 @@ import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -252,14 +254,24 @@ public M waitFor(final Future future) { public ModuleItem getSingleInput(final Module module, final Class type) { - return getSingleItem(module, type, module.getInfo().inputs()); + return getTypedSingleItem(module, type, module.getInfo().inputs()); } @Override public ModuleItem getSingleOutput(final Module module, final Class type) { - return getSingleItem(module, type, module.getInfo().outputs()); + return getTypedSingleItem(module, type, module.getInfo().outputs()); + } + + @Override + public ModuleItem getSingleInput(Module module, Collection> types) { + return getSingleItem(module, types, module.getInfo().inputs()); + } + + @Override + public ModuleItem getSingleOutput(Module module, Collection> types) { + return getSingleItem(module, types, module.getInfo().outputs()); } @Override @@ -431,20 +443,35 @@ private void assignInputs(final Module module, } } - private ModuleItem getSingleItem(final Module module, + private ModuleItem getTypedSingleItem(final Module module, final Class type, final Iterable> items) { - ModuleItem result = null; + Set> types = new HashSet>(); + types.add(type); + @SuppressWarnings("unchecked") + ModuleItem result = (ModuleItem) getSingleItem(module, types, items); + return result; + } + + private ModuleItem getSingleItem(final Module module, + final Collection> types, final Iterable> items) + { + ModuleItem result = null; + for (final ModuleItem item : items) { final String name = item.getName(); final boolean resolved = module.isResolved(name); if (resolved) continue; // skip resolved inputs if (!item.isAutoFill()) continue; // skip unfillable inputs - if (!type.isAssignableFrom(item.getType())) continue; - if (result != null) return null; // multiple matching items - @SuppressWarnings("unchecked") - final ModuleItem typedItem = (ModuleItem) item; - result = typedItem; + final Class itemType = item.getType(); + for (final Class type : types) { + if (type.isAssignableFrom(itemType)) { + if (result != null) return null; // multiple matching module items + result = item; + // This module item matches, so no need to check more classes. + break; + } + } } return result; } diff --git a/src/main/java/org/scijava/module/ModuleService.java b/src/main/java/org/scijava/module/ModuleService.java index e49850715..21ee456cc 100644 --- a/src/main/java/org/scijava/module/ModuleService.java +++ b/src/main/java/org/scijava/module/ModuleService.java @@ -274,6 +274,18 @@ Future run(M module, */ ModuleItem getSingleOutput(Module module, Class type); + /** + * As {@link #getSingleInput(Module, Class)} but will match with a set of + * potential classes, at the cost of generic parameter safety. + */ + ModuleItem getSingleInput(Module module, Collection> types); + + /** + * As {@link #getSingleOutput(Module, Class)} but will match with a set of + * potential classes, at the cost of generic parameter safety. + */ + ModuleItem getSingleOutput(Module module, Collection> types); + /** * Registers the given value for the given {@link ModuleItem} using the * {@link PrefService}. From d0d30ef39723aa428cbd9b8287273454e07e6851 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 18 Feb 2016 11:38:14 -0600 Subject: [PATCH 0111/1208] SciJavaPlugin: add Converter to plugin types list --- src/main/java/org/scijava/plugin/SciJavaPlugin.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/scijava/plugin/SciJavaPlugin.java b/src/main/java/org/scijava/plugin/SciJavaPlugin.java index 001094ba6..86d906c67 100644 --- a/src/main/java/org/scijava/plugin/SciJavaPlugin.java +++ b/src/main/java/org/scijava/plugin/SciJavaPlugin.java @@ -47,6 +47,8 @@ * application menus. *
  • {@link org.scijava.console.ConsoleArgument} - plugins that handle * arguments passed to the application as command line parameters.
  • + *
  • {@link org.scijava.convert.Converter} - plugins which translate objects + * between data types.
  • *
  • {@link org.scijava.display.Display} - plugins that visualize objects, * often used to display module outputs.
  • *
  • {@link org.scijava.io.IOPlugin} - plugins that read or write data.
  • From 04755c9b17035c0b8c3674c39f15c87eb15e97b4 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 22 Feb 2016 13:50:38 -0600 Subject: [PATCH 0112/1208] Gateway: add missing UIService accessor --- src/main/java/org/scijava/AbstractGateway.java | 6 ++++++ src/main/java/org/scijava/Gateway.java | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/org/scijava/AbstractGateway.java b/src/main/java/org/scijava/AbstractGateway.java index 603e6a7a4..d09dfd936 100644 --- a/src/main/java/org/scijava/AbstractGateway.java +++ b/src/main/java/org/scijava/AbstractGateway.java @@ -61,6 +61,7 @@ import org.scijava.thread.ThreadService; import org.scijava.tool.IconService; import org.scijava.tool.ToolService; +import org.scijava.ui.UIService; import org.scijava.widget.WidgetService; /** @@ -233,6 +234,11 @@ public ToolService tool() { return get(ToolService.class); } + @Override + public UIService ui() { + return get(UIService.class); + } + @Override public WidgetService widget() { return get(WidgetService.class); diff --git a/src/main/java/org/scijava/Gateway.java b/src/main/java/org/scijava/Gateway.java index a034682dd..73df53a5a 100644 --- a/src/main/java/org/scijava/Gateway.java +++ b/src/main/java/org/scijava/Gateway.java @@ -59,6 +59,7 @@ import org.scijava.thread.ThreadService; import org.scijava.tool.IconService; import org.scijava.tool.ToolService; +import org.scijava.ui.UIService; import org.scijava.widget.WidgetService; /** @@ -318,6 +319,13 @@ public interface Gateway extends RichPlugin, Versioned { */ ToolService tool(); + /** + * Gets this application context's {@link UIService}. + * + * @return The {@link UIService} of this application context. + */ + UIService ui(); + /** * Gets this application context's {@link WidgetService}. * From 28a2ab40b38517e0e8977a5860be1976fd7b59cc Mon Sep 17 00:00:00 2001 From: Alison Walter Date: Thu, 23 Apr 2015 11:08:09 -0500 Subject: [PATCH 0113/1208] Add new converters for primitive numerical types --- .../org/scijava/convert/NumberConverters.java | 173 ++++++++++++++++++ .../convert/NumberToBigDecimalConverter.java | 62 +++++++ .../convert/NumberToBigIntegerConverter.java | 53 ++++++ .../convert/NumberToDoubleConverter.java | 51 ++++++ .../convert/NumberToFloatConverter.java | 51 ++++++ .../convert/NumberToIntegerConverter.java | 51 ++++++ .../convert/NumberToLongConverter.java | 51 ++++++ .../convert/NumberToNumberConverter.java | 64 +++++++ .../convert/NumberToShortConverter.java | 51 ++++++ 9 files changed, 607 insertions(+) create mode 100644 src/main/java/org/scijava/convert/NumberConverters.java create mode 100644 src/main/java/org/scijava/convert/NumberToBigDecimalConverter.java create mode 100644 src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java create mode 100644 src/main/java/org/scijava/convert/NumberToDoubleConverter.java create mode 100644 src/main/java/org/scijava/convert/NumberToFloatConverter.java create mode 100644 src/main/java/org/scijava/convert/NumberToIntegerConverter.java create mode 100644 src/main/java/org/scijava/convert/NumberToLongConverter.java create mode 100644 src/main/java/org/scijava/convert/NumberToNumberConverter.java create mode 100644 src/main/java/org/scijava/convert/NumberToShortConverter.java diff --git a/src/main/java/org/scijava/convert/NumberConverters.java b/src/main/java/org/scijava/convert/NumberConverters.java new file mode 100644 index 000000000..c8dc7412c --- /dev/null +++ b/src/main/java/org/scijava/convert/NumberConverters.java @@ -0,0 +1,173 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import java.math.BigInteger; + +import org.scijava.plugin.Plugin; + +/** + * Converter plugins that convert from primitive numeric types to other + * primitive numeric types. + * + * @author Alison Walter + */ +public final class NumberConverters { + + private NumberConverters() { + // prevent instantiation of container class + } + + //convert to short + @Plugin(type = Converter.class) + public static class ByteToShortConverter extends NumberToShortConverter { + @Override public Class getInputType() { return Byte.class; } + } + + //convert to int + @Plugin(type = Converter.class) + public static class ByteToIntegerConverter extends NumberToIntegerConverter { + @Override public Class getInputType() { return Byte.class; } + } + + @Plugin(type = Converter.class) + public static class ShortToIntegerConverter extends NumberToIntegerConverter { + @Override public Class getInputType() { return Short.class; } + } + + //convert to long + @Plugin(type = Converter.class) + public static class ByteToLongConverter extends NumberToLongConverter { + @Override public Class getInputType() { return Byte.class; } + } + + @Plugin(type = Converter.class) + public static class ShortToLongConverter extends NumberToLongConverter { + @Override public Class getInputType() { return Short.class; } + } + + @Plugin(type = Converter.class) + public static class IntegerToLongConverter extends NumberToLongConverter { + @Override public Class getInputType() { return Integer.class; } + } + + //convert to float + @Plugin(type = Converter.class) + public static class ByteToFloatConverter extends NumberToFloatConverter { + @Override public Class getInputType() { return Byte.class; } + } + + @Plugin(type = Converter.class) + public static class ShortToFloatConverter extends NumberToFloatConverter { + @Override public Class getInputType() { return Short.class; } + } + + + //convert to double + @Plugin(type = Converter.class) + public static class ByteToDoubleConverter extends NumberToDoubleConverter { + @Override public Class getInputType() { return Byte.class; } + } + + @Plugin(type = Converter.class) + public static class ShortToDoubleConverter extends NumberToDoubleConverter { + @Override public Class getInputType() { return Short.class; } + } + + @Plugin(type = Converter.class) + public static class IntegerToDoubleConverter extends NumberToDoubleConverter { + @Override public Class getInputType() { return Integer.class; } + } + + @Plugin(type = Converter.class) + public static class FloatToDoubleConverter extends NumberToDoubleConverter { + @Override public Class getInputType() { return Float.class; } + } + + //convert to BigInteger + @Plugin(type = Converter.class) + public static class ByteToBigIntegerConverter extends NumberToBigIntegerConverter { + @Override public Class getInputType() { return Byte.class; } + } + + @Plugin(type = Converter.class) + public static class ShortToBigIntegerConverter extends NumberToBigIntegerConverter { + @Override public Class getInputType() { return Short.class; } + } + + @Plugin(type = Converter.class) + public static class IntegerToBigIntegerConverter extends NumberToBigIntegerConverter { + @Override public Class getInputType() { return Integer.class; } + } + + @Plugin(type = Converter.class) + public static class LongToBigIntegerConverter extends NumberToBigIntegerConverter { + @Override public Class getInputType() { return Long.class; } + } + + //convert to BigDecimal + @Plugin(type = Converter.class) + public static class ByteToBigDecimalConverter extends NumberToBigDecimalConverter { + @Override public Class getInputType() { return Byte.class; } + } + + @Plugin(type = Converter.class) + public static class ShortToBigDecimalConverter extends NumberToBigDecimalConverter { + @Override public Class getInputType() { return Short.class; } + } + + @Plugin(type = Converter.class) + public static class IntegerToBigDecimalConverter extends NumberToBigDecimalConverter { + @Override public Class getInputType() { return Integer.class; } + } + + @Plugin(type = Converter.class) + public static class LongToBigDecimalConverter extends NumberToBigDecimalConverter { + @Override public Class getInputType() { return Long.class; } + } + + @Plugin(type = Converter.class) + public static class FloatToBigDecimalConverter extends NumberToBigDecimalConverter { + @Override public Class getInputType() { return Float.class; } + } + + @Plugin(type = Converter.class) + public static class DoubleToBigDecimalConverter extends NumberToBigDecimalConverter { + @Override public Class getInputType() { return Double.class; } + } + + @Plugin(type = Converter.class) + public static class BigIntegerToBigDecimalConverter extends NumberToBigDecimalConverter { + @Override public Class getInputType() { return BigInteger.class; } + } + +} diff --git a/src/main/java/org/scijava/convert/NumberToBigDecimalConverter.java b/src/main/java/org/scijava/convert/NumberToBigDecimalConverter.java new file mode 100644 index 000000000..dca1eed41 --- /dev/null +++ b/src/main/java/org/scijava/convert/NumberToBigDecimalConverter.java @@ -0,0 +1,62 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import java.math.BigDecimal; +import java.math.BigInteger; + +/** + * Converts numbers to BigDecimals. + * + * @author Alison Walter + */ +public abstract class NumberToBigDecimalConverter extends NumberToNumberConverter { + + @Override + public BigDecimal convert(Number n) { + // cannot get doubleValue of a BigInteger + if(BigInteger.class.isInstance(n)){ + return new BigDecimal((BigInteger) n); + } + // Using .doubleValue on a long would cause loss of accuracy + else if(Long.class.isInstance(n)){ + return new BigDecimal(n.longValue()); + } + return new BigDecimal(n.doubleValue()); + } + + @Override + public Class getOutputType() { + return BigDecimal.class; + } + +} \ No newline at end of file diff --git a/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java b/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java new file mode 100644 index 000000000..6b16b21bc --- /dev/null +++ b/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java @@ -0,0 +1,53 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import java.math.BigInteger; + +/** + * Converts numbers to BigIntegers. + * + * @author Alison Walter + */ +public abstract class NumberToBigIntegerConverter extends NumberToNumberConverter { + + @Override + public BigInteger convert(Number n) { + return BigInteger.valueOf(n.longValue()); + } + + @Override + public Class getOutputType() { + return BigInteger.class; + } + +} \ No newline at end of file diff --git a/src/main/java/org/scijava/convert/NumberToDoubleConverter.java b/src/main/java/org/scijava/convert/NumberToDoubleConverter.java new file mode 100644 index 000000000..05fd1ce74 --- /dev/null +++ b/src/main/java/org/scijava/convert/NumberToDoubleConverter.java @@ -0,0 +1,51 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +/** + * Converts numbers to doubles. + * + * @author Alison Walter + */ +public abstract class NumberToDoubleConverter extends NumberToNumberConverter { + + @Override + public Double convert(Number n) { + return n.doubleValue(); + } + + @Override + public Class getOutputType() { + return Double.class; + } + +} diff --git a/src/main/java/org/scijava/convert/NumberToFloatConverter.java b/src/main/java/org/scijava/convert/NumberToFloatConverter.java new file mode 100644 index 000000000..368ab0bd9 --- /dev/null +++ b/src/main/java/org/scijava/convert/NumberToFloatConverter.java @@ -0,0 +1,51 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +/** + * Converts numbers to floats. + * + * @author Alison Walter + */ +public abstract class NumberToFloatConverter extends NumberToNumberConverter { + + @Override + public Float convert(Number n) { + return n.floatValue(); + } + + @Override + public Class getOutputType() { + return Float.class; + } + +} \ No newline at end of file diff --git a/src/main/java/org/scijava/convert/NumberToIntegerConverter.java b/src/main/java/org/scijava/convert/NumberToIntegerConverter.java new file mode 100644 index 000000000..f16a48208 --- /dev/null +++ b/src/main/java/org/scijava/convert/NumberToIntegerConverter.java @@ -0,0 +1,51 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +/** + * Converts numbers to integers. + * + * @author Alison Walter + */ +public abstract class NumberToIntegerConverter extends NumberToNumberConverter { + + @Override + public Integer convert(Number n) { + return n.intValue(); + } + + @Override + public Class getOutputType() { + return Integer.class; + } + +} \ No newline at end of file diff --git a/src/main/java/org/scijava/convert/NumberToLongConverter.java b/src/main/java/org/scijava/convert/NumberToLongConverter.java new file mode 100644 index 000000000..314db3b9e --- /dev/null +++ b/src/main/java/org/scijava/convert/NumberToLongConverter.java @@ -0,0 +1,51 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +/** + * Converts numbers to longs. + * + * @author Alison Walter + */ +public abstract class NumberToLongConverter extends NumberToNumberConverter { + + @Override + public Long convert(Number n) { + return n.longValue(); + } + + @Override + public Class getOutputType() { + return Long.class; + } + +} \ No newline at end of file diff --git a/src/main/java/org/scijava/convert/NumberToNumberConverter.java b/src/main/java/org/scijava/convert/NumberToNumberConverter.java new file mode 100644 index 000000000..8a41b1b3b --- /dev/null +++ b/src/main/java/org/scijava/convert/NumberToNumberConverter.java @@ -0,0 +1,64 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.util.ConversionUtils; + +/** + * Converts numbers to numbers, and throws IllegalArgumentException for null or + * invalid input. + * + * @author Alison Walter + */ +public abstract class NumberToNumberConverter + extends AbstractConverter +{ + + @Override + public T convert(final Object src, final Class dest) { + if (src == null || dest == null) throw new IllegalArgumentException( + "Null input"); + if (!getInputType().isInstance(src)) { + throw new IllegalArgumentException("Expected input of type " + + getInputType().getSimpleName() + ", but got " + + src.getClass().getSimpleName()); + } + if (ConversionUtils.getNonprimitiveType(dest) != getOutputType()) { + throw new IllegalArgumentException( + "Expected output class of " + getOutputType().getSimpleName() + + ", but got " + dest.getSimpleName()); + } + return (T) convert((Number) src); + } + + public abstract O convert(Number n); +} diff --git a/src/main/java/org/scijava/convert/NumberToShortConverter.java b/src/main/java/org/scijava/convert/NumberToShortConverter.java new file mode 100644 index 000000000..133b3cc80 --- /dev/null +++ b/src/main/java/org/scijava/convert/NumberToShortConverter.java @@ -0,0 +1,51 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +/** + * Converts numbers to shorts. + * + * @author Alison Walter + */ +public abstract class NumberToShortConverter extends NumberToNumberConverter { + + @Override + public Short convert(Number n) { + return n.shortValue(); + } + + @Override + public Class getOutputType() { + return Short.class; + } + +} From 601ece4813136b27376abbda69f667a7d6da5994 Mon Sep 17 00:00:00 2001 From: Alison Walter Date: Thu, 23 Apr 2015 11:11:02 -0500 Subject: [PATCH 0114/1208] Add unit tests for primitive number converters --- .../convert/AbstractNumberConverterTests.java | 209 ++++++++++++++++++ .../BigIntegerToBigDecimalConverterTest.java | 60 +++++ .../ByteToBigDecimalConverterTest.java | 57 +++++ .../ByteToBigIntegerConverterTest.java | 58 +++++ .../convert/ByteToDoubleConverterTest.java | 57 +++++ .../convert/ByteToFloatConverterTest.java | 57 +++++ .../convert/ByteToIntegerConverterTest.java | 57 +++++ .../convert/ByteToLongConverterTest.java | 57 +++++ .../convert/ByteToShortConverterTest.java | 58 +++++ .../DoubleToBigDecimalConverterTest.java | 57 +++++ .../FloatToBigDecimalConverterTest.java | 57 +++++ .../convert/FloatToDoubleConverterTest.java | 57 +++++ .../IntegerToBigDecimalConverterTest.java | 58 +++++ .../IntegerToBigIntegerConverterTest.java | 57 +++++ .../convert/IntegerToDoubleConverterTest.java | 57 +++++ .../convert/IntegerToLongConverterTest.java | 57 +++++ .../LongToBigDecimalConverterTest.java | 57 +++++ .../LongToBigIntegerConverterTest.java | 57 +++++ .../convert/NumberToBigDecimalTest.java | 59 +++++ .../convert/NumberToBigIntegerTest.java | 63 ++++++ .../scijava/convert/NumberToDoubleTest.java | 60 +++++ .../scijava/convert/NumberToFloatTest.java | 61 +++++ .../scijava/convert/NumberToIntegerTest.java | 60 +++++ .../org/scijava/convert/NumberToLongTest.java | 60 +++++ .../scijava/convert/NumberToShortTest.java | 57 +++++ .../ShortToBigDecimalConverterTest.java | 57 +++++ .../ShortToBigIntegerConverterTest.java | 57 +++++ .../convert/ShortToDoubleConverterTest.java | 57 +++++ .../convert/ShortToFloatConverterTest.java | 57 +++++ .../convert/ShortToIntegerConverterTest.java | 57 +++++ .../convert/ShortToLongConverterTest.java | 57 +++++ 31 files changed, 1946 insertions(+) create mode 100644 src/test/java/org/scijava/convert/AbstractNumberConverterTests.java create mode 100644 src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java create mode 100644 src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java create mode 100644 src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java create mode 100644 src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java create mode 100644 src/test/java/org/scijava/convert/ByteToFloatConverterTest.java create mode 100644 src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java create mode 100644 src/test/java/org/scijava/convert/ByteToLongConverterTest.java create mode 100644 src/test/java/org/scijava/convert/ByteToShortConverterTest.java create mode 100644 src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java create mode 100644 src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java create mode 100644 src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java create mode 100644 src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java create mode 100644 src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java create mode 100644 src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java create mode 100644 src/test/java/org/scijava/convert/IntegerToLongConverterTest.java create mode 100644 src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java create mode 100644 src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java create mode 100644 src/test/java/org/scijava/convert/NumberToBigDecimalTest.java create mode 100644 src/test/java/org/scijava/convert/NumberToBigIntegerTest.java create mode 100644 src/test/java/org/scijava/convert/NumberToDoubleTest.java create mode 100644 src/test/java/org/scijava/convert/NumberToFloatTest.java create mode 100644 src/test/java/org/scijava/convert/NumberToIntegerTest.java create mode 100644 src/test/java/org/scijava/convert/NumberToLongTest.java create mode 100644 src/test/java/org/scijava/convert/NumberToShortTest.java create mode 100644 src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java create mode 100644 src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java create mode 100644 src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java create mode 100644 src/test/java/org/scijava/convert/ShortToFloatConverterTest.java create mode 100644 src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java create mode 100644 src/test/java/org/scijava/convert/ShortToLongConverterTest.java diff --git a/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java b/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java new file mode 100644 index 000000000..23505adfb --- /dev/null +++ b/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java @@ -0,0 +1,209 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.math.BigDecimal; +import java.math.BigInteger; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +/** + * Tests converter plugins that convert from primitive numeric types to other + * primitive numeric types. + * + * @author Alison Walter + */ +public abstract class AbstractNumberConverterTests { + + protected NumberToNumberConverter converter = getConverter(); + protected Class srcType = converter.getInputType(); + protected Class destType = converter.getOutputType(); + + public abstract Number getSrc(); + + public abstract NumberToNumberConverter getConverter(); + + public abstract Number getExpectedValue(); + + public abstract Number getInvalidInput(); + + public abstract Class getInvalidOutput(); + + /** + * Test case for the wrapper classes + */ + @Test + public void testWrapper() { + final Number src = getSrc(); + final Number expect = getExpectedValue(); + assertTrue(destType.isInstance(converter.convert(src, destType))); + assertEquals(expect, converter.convert(src, destType)); + } + + /** + * Test case for primitive values + */ + @Test + public void testPrimitive() { + final Number src = getSrc(); + final Number expect = getExpectedValue(); + if (!destType.equals(BigInteger.class) && + !destType.equals(BigDecimal.class)) + { + // byte to number converters + if (srcType.equals(Byte.class)) { + final byte b = src.byteValue(); + if (destType.equals(Short.class)) { + final short s = expect.shortValue(); + assertTrue(s == converter.convert(b, short.class)); + } + else if (destType.equals(Integer.class)) { + final int i = expect.intValue(); + assertTrue(i == converter.convert(b, int.class)); + } + else if (destType.equals(Long.class)) { + final long l = expect.longValue(); + assertTrue(l == converter.convert(b, long.class)); + } + else if (destType.equals(Float.class)) { + final float f = expect.floatValue(); + assertTrue(f == converter.convert(b, float.class)); + } + else { + final double d = expect.doubleValue(); + assertTrue(d == converter.convert(b, double.class)); + } + } + // int to number converters + else if (srcType.equals(Integer.class)) { + final int i = src.intValue(); + if (destType.equals(Long.class)) { + final long l = expect.longValue(); + assertTrue(l == converter.convert(i, long.class)); + } + else { + final double d = expect.doubleValue(); + assertTrue(d == converter.convert(i, double.class)); + } + } + // short to number converters + else if (srcType.equals(Short.class)) { + final short s = src.shortValue(); + if (destType.equals(Integer.class)) { + final int i = expect.intValue(); + assertTrue(i == converter.convert(s, int.class)); + } + else if (destType.equals(Long.class)) { + final long l = expect.longValue(); + assertTrue(l == converter.convert(s, long.class)); + } + else if (destType.equals(Float.class)) { + final float f = expect.floatValue(); + assertTrue(f == converter.convert(s, float.class)); + } + else { + final double d = expect.doubleValue(); + assertTrue(d == converter.convert(s, double.class)); + } + } + // float to number converters + else if (srcType.equals(Float.class)) { + final float f = expect.floatValue(); + final double d = expect.doubleValue(); + assertTrue(d == converter.convert(f, double.class)); + } + else { + // longs and doubles can't be converted to anything beside bigInteger + // and big decimal + } + } + else { + // no prim equivalents for BigInteger and BigDecimal + } + } + + /** + * Test case for null input + */ + @Test + public void nullInput() { + iae("Null input", null, null); + } + + /** + * Test case for invalid input class + */ + @Test + public void incorrectInputType() { + final Number input = getInvalidInput(); + final String message = + "Expected input of type " + srcType.getSimpleName() + ", but got " + + input.getClass().getSimpleName(); + iae(message, input, destType); + } + + /** + * Test case for invalid output class + */ + @Test + public void incorrectOutputType() { + final Class output = getInvalidOutput(); + final Number src = getSrc(); + final String message = + "Expected output class of " + destType.getSimpleName() + ", but got " + + output.getSimpleName(); + iae(message, src, output); + } + + @Rule + public ExpectedException exception = ExpectedException.none(); + + // helper methods + protected void + iae(final String message, final Number src, final Class dest) + { + exception(IllegalArgumentException.class, message, src, dest); + } + + protected void exception(final Class excType, + final String message, final Number src, final Class dest) + { + exception.expect(excType); + exception.expectMessage(message); + converter.convert(src, dest); + } +} diff --git a/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java new file mode 100644 index 000000000..b493aa868 --- /dev/null +++ b/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java @@ -0,0 +1,60 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import java.math.BigInteger; + +import org.scijava.convert.NumberConverters.BigIntegerToBigDecimalConverter; + +/** + * Tests {@link BigIntegerToBigDecimalConverter}. + * + * @author Alison Walter + */ +public class BigIntegerToBigDecimalConverterTest extends NumberToBigDecimalTest +{ + + @Override + public Number getSrc() { + return BigInteger.valueOf(7l); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.BigIntegerToBigDecimalConverter(); + } + + @Override + public Number getInvalidInput() { + return new Long(46l); + } +} diff --git a/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java new file mode 100644 index 000000000..50c1ee02f --- /dev/null +++ b/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.ByteToBigDecimalConverter; + +/** + * Tests {@link ByteToBigDecimalConverter}. + * + * @author Alison Walter + */ +public class ByteToBigDecimalConverterTest extends NumberToBigDecimalTest { + + @Override + public Number getSrc() { + return new Byte((byte) 7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ByteToBigDecimalConverter(); + } + + @Override + public Number getInvalidInput() { + return new Short((short) 101); + } +} diff --git a/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java new file mode 100644 index 000000000..58637e90f --- /dev/null +++ b/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java @@ -0,0 +1,58 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.ByteToBigIntegerConverter; + +/** + * Tests {@link ByteToBigIntegerConverter}. + * + * @author Alison Walter + */ +public class ByteToBigIntegerConverterTest extends NumberToBigIntegerTest { + + @Override + public Number getSrc() { + return new Byte((byte) 7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ByteToBigIntegerConverter(); + } + + @Override + public Number getInvalidInput() { + return new Short((short) 101); + } + } + diff --git a/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java b/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java new file mode 100644 index 000000000..e3eb340ed --- /dev/null +++ b/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.ByteToDoubleConverter; + +/** + * Tests {@link ByteToDoubleConverter}. + * + * @author Alison Walter + */ +public class ByteToDoubleConverterTest extends NumberToDoubleTest { + + @Override + public Number getSrc() { + return new Byte((byte) 7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ByteToDoubleConverter(); + } + + @Override + public Number getInvalidInput() { + return new Short((short) 101); + } +} diff --git a/src/test/java/org/scijava/convert/ByteToFloatConverterTest.java b/src/test/java/org/scijava/convert/ByteToFloatConverterTest.java new file mode 100644 index 000000000..0fe7238c1 --- /dev/null +++ b/src/test/java/org/scijava/convert/ByteToFloatConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.ByteToFloatConverter; + +/** + * Tests {@link ByteToFloatConverter}. + * + * @author Alison Walter + */ +public class ByteToFloatConverterTest extends NumberToFloatTest { + + @Override + public Number getSrc() { + return new Byte((byte) 7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ByteToFloatConverter(); + } + + @Override + public Number getInvalidInput() { + return new Double(7.67d); + } +} diff --git a/src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java b/src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java new file mode 100644 index 000000000..972aa84d2 --- /dev/null +++ b/src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.ByteToIntegerConverter; + +/** + * Tests {@link ByteToIntegerConverter}. + * + * @author Alison Walter + */ +public class ByteToIntegerConverterTest extends NumberToIntegerTest { + + @Override + public Number getSrc() { + return new Byte((byte) 7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ByteToIntegerConverter(); + } + + @Override + public Number getInvalidInput() { + return new Long(12l); + } +} diff --git a/src/test/java/org/scijava/convert/ByteToLongConverterTest.java b/src/test/java/org/scijava/convert/ByteToLongConverterTest.java new file mode 100644 index 000000000..f9b849e30 --- /dev/null +++ b/src/test/java/org/scijava/convert/ByteToLongConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.ByteToLongConverter; + +/** + * Tests {@link ByteToLongConverter}. + * + * @author Alison Walter + */ +public class ByteToLongConverterTest extends NumberToLongTest { + + @Override + public Number getSrc() { + return new Byte((byte) 7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ByteToLongConverter(); + } + + @Override + public Number getInvalidInput() { + return new Double(12d); + } +} diff --git a/src/test/java/org/scijava/convert/ByteToShortConverterTest.java b/src/test/java/org/scijava/convert/ByteToShortConverterTest.java new file mode 100644 index 000000000..4033863c1 --- /dev/null +++ b/src/test/java/org/scijava/convert/ByteToShortConverterTest.java @@ -0,0 +1,58 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.ByteToShortConverter; + +/** + * Tests {@link ByteToShortConverter}. + * + * @author Alison Walter + */ +public class ByteToShortConverterTest extends NumberToShortTest { + + @Override + public Number getSrc() { + return new Byte((byte) 7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ByteToShortConverter(); + } + + @Override + public Number getInvalidInput() { + return new Integer(12); + } + +} diff --git a/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java new file mode 100644 index 000000000..be9af7c86 --- /dev/null +++ b/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.DoubleToBigDecimalConverter; + +/** + * Tests {@link DoubleToBigDecimalConverter}. + * + * @author Alison Walter + */ +public class DoubleToBigDecimalConverterTest extends NumberToBigDecimalTest { + + @Override + public Number getSrc() { + return new Double(7.0d); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.DoubleToBigDecimalConverter(); + } + + @Override + public Number getInvalidInput() { + return new Short((short) 7); + } +} diff --git a/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java new file mode 100644 index 000000000..bb8ce3715 --- /dev/null +++ b/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.FloatToBigDecimalConverter; + +/** + * Tests {@link FloatToBigDecimalConverter}. + * + * @author Alison Walter + */ +public class FloatToBigDecimalConverterTest extends NumberToBigDecimalTest { + + @Override + public Number getSrc() { + return new Float(7f); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.FloatToBigDecimalConverter(); + } + + @Override + public Number getInvalidInput() { + return new Integer(394); + } +} diff --git a/src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java b/src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java new file mode 100644 index 000000000..12f9b03cc --- /dev/null +++ b/src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.FloatToDoubleConverter; + +/** + * Tests {@link FloatToDoubleConverter}. + * + * @author Alison Walter + */ +public class FloatToDoubleConverterTest extends NumberToDoubleTest { + + @Override + public Number getSrc() { + return new Float(7.0f); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.FloatToDoubleConverter(); + } + + @Override + public Number getInvalidInput() { + return new Integer(394); + } +} diff --git a/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java new file mode 100644 index 000000000..56a509b7b --- /dev/null +++ b/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java @@ -0,0 +1,58 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.IntegerToBigDecimalConverter; + +/** + * Tests {@link IntegerToBigDecimalConverter}. + * + * @author Alison Walter + */ +public class IntegerToBigDecimalConverterTest extends NumberToBigDecimalTest { + + @Override + public Number getSrc() { + return new Integer(7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.IntegerToBigDecimalConverter(); + } + + @Override + public Number getInvalidInput() { + return new Byte((byte) 2); + } + } + diff --git a/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java new file mode 100644 index 000000000..b6a04d3b8 --- /dev/null +++ b/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.IntegerToBigIntegerConverter; + +/** + * Tests {@link IntegerToBigIntegerConverter}. + * + * @author Alison Walter + */ +public class IntegerToBigIntegerConverterTest extends NumberToBigIntegerTest { + + @Override + public Number getSrc() { + return new Integer(7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.IntegerToBigIntegerConverter(); + } + + @Override + public Number getInvalidInput() { + return new Byte((byte) 2); + } +} diff --git a/src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java b/src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java new file mode 100644 index 000000000..2882d3c1e --- /dev/null +++ b/src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.IntegerToDoubleConverter; + +/** + * Tests {@link IntegerToDoubleConverter}. + * + * @author Alison Walter + */ +public class IntegerToDoubleConverterTest extends NumberToDoubleTest { + + @Override + public Number getSrc() { + return new Integer(7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.IntegerToDoubleConverter(); + } + + @Override + public Number getInvalidInput() { + return new Byte((byte) 2); + } +} diff --git a/src/test/java/org/scijava/convert/IntegerToLongConverterTest.java b/src/test/java/org/scijava/convert/IntegerToLongConverterTest.java new file mode 100644 index 000000000..a7350b569 --- /dev/null +++ b/src/test/java/org/scijava/convert/IntegerToLongConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.IntegerToLongConverter; + +/** + * Tests {@link IntegerToLongConverter}. + * + * @author Alison Walter + */ +public class IntegerToLongConverterTest extends NumberToLongTest { + + @Override + public Number getSrc() { + return new Integer(7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.IntegerToLongConverter(); + } + + @Override + public Number getInvalidInput() { + return new Float(7.67f); + } +} diff --git a/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java new file mode 100644 index 000000000..d7b584279 --- /dev/null +++ b/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.LongToBigDecimalConverter; + +/** + * Tests {@link LongToBigDecimalConverter}. + * + * @author Alison Walter + */ +public class LongToBigDecimalConverterTest extends NumberToBigDecimalTest { + + @Override + public Number getSrc() { + return new Long(7l); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.LongToBigDecimalConverter(); + } + + @Override + public Number getInvalidInput() { + return new Integer(394); + } +} diff --git a/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java new file mode 100644 index 000000000..9ff8a1e81 --- /dev/null +++ b/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.LongToBigIntegerConverter; + +/** + * Tests {@link LongToBigIntegerConverter}. + * + * @author Alison Walter + */ +public class LongToBigIntegerConverterTest extends NumberToBigIntegerTest { + + @Override + public Number getSrc() { + return new Long(7l); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.LongToBigIntegerConverter(); + } + + @Override + public Number getInvalidInput() { + return new Integer(394); + } +} diff --git a/src/test/java/org/scijava/convert/NumberToBigDecimalTest.java b/src/test/java/org/scijava/convert/NumberToBigDecimalTest.java new file mode 100644 index 000000000..09f57d33d --- /dev/null +++ b/src/test/java/org/scijava/convert/NumberToBigDecimalTest.java @@ -0,0 +1,59 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import java.math.BigDecimal; + +/** + * Tests {@link NumberToBigDecimalConverter}. + * + * @author Alison Walter + */ +public abstract class NumberToBigDecimalTest extends AbstractNumberConverterTests{ + @Override + public abstract Number getSrc(); + @Override + public abstract NumberToNumberConverter getConverter(); + @Override + public abstract Number getInvalidInput(); + + @Override + public Number getExpectedValue() { + return new BigDecimal(7d); + } + + @Override + public Class getInvalidOutput() { + return Float.class; + } + +} diff --git a/src/test/java/org/scijava/convert/NumberToBigIntegerTest.java b/src/test/java/org/scijava/convert/NumberToBigIntegerTest.java new file mode 100644 index 000000000..53dc35230 --- /dev/null +++ b/src/test/java/org/scijava/convert/NumberToBigIntegerTest.java @@ -0,0 +1,63 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import java.math.BigInteger; + +/** + * Tests {@link NumberToBigIntegerConverter}. + * + * @author Alison Walter + */ +public abstract class NumberToBigIntegerTest extends + AbstractNumberConverterTests +{ + + @Override + public abstract Number getSrc(); + + @Override + public abstract NumberToNumberConverter getConverter(); + + @Override + public abstract Number getInvalidInput(); + + @Override + public Number getExpectedValue() { + return BigInteger.valueOf(7l); + } + + @Override + public Class getInvalidOutput() { + return Byte.class; + } +} diff --git a/src/test/java/org/scijava/convert/NumberToDoubleTest.java b/src/test/java/org/scijava/convert/NumberToDoubleTest.java new file mode 100644 index 000000000..f1108e461 --- /dev/null +++ b/src/test/java/org/scijava/convert/NumberToDoubleTest.java @@ -0,0 +1,60 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + + +/** + * Tests {@link NumberToDoubleConverter}. + * + * @author Alison Walter + */ +public abstract class NumberToDoubleTest extends AbstractNumberConverterTests { + + @Override + public abstract Number getSrc(); + + @Override + public abstract NumberToNumberConverter getConverter(); + + @Override + public abstract Number getInvalidInput(); + + @Override + public Number getExpectedValue() { + return new Double(7.0d); + } + + @Override + public Class getInvalidOutput() { + return Byte.class; + } +} diff --git a/src/test/java/org/scijava/convert/NumberToFloatTest.java b/src/test/java/org/scijava/convert/NumberToFloatTest.java new file mode 100644 index 000000000..45938573f --- /dev/null +++ b/src/test/java/org/scijava/convert/NumberToFloatTest.java @@ -0,0 +1,61 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + + +/** + * Tests {@link NumberToFloatConverter}. + * + * @author Alison Walter + */ +public abstract class NumberToFloatTest extends AbstractNumberConverterTests { + + @Override + public abstract Number getSrc(); + + @Override + public abstract NumberToNumberConverter getConverter(); + + @Override + public abstract Number getInvalidInput(); + + @Override + public Number getExpectedValue() { + return new Float(7f); + } + + @Override + public Class getInvalidOutput() { + return Long.class; + } +} + diff --git a/src/test/java/org/scijava/convert/NumberToIntegerTest.java b/src/test/java/org/scijava/convert/NumberToIntegerTest.java new file mode 100644 index 000000000..e3b3c7043 --- /dev/null +++ b/src/test/java/org/scijava/convert/NumberToIntegerTest.java @@ -0,0 +1,60 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +/** + * Tests {@link NumberToIntegerConverter}. + * + * @author Alison Walter + */ +public abstract class NumberToIntegerTest extends AbstractNumberConverterTests { + + @Override + public abstract Number getSrc(); + + @Override + public abstract NumberToNumberConverter getConverter(); + + @Override + public abstract Number getInvalidInput(); + + @Override + public Number getExpectedValue() { + return new Integer(7); + } + + @Override + public Class getInvalidOutput() { + return Short.class; + } + +} diff --git a/src/test/java/org/scijava/convert/NumberToLongTest.java b/src/test/java/org/scijava/convert/NumberToLongTest.java new file mode 100644 index 000000000..d35ec3b45 --- /dev/null +++ b/src/test/java/org/scijava/convert/NumberToLongTest.java @@ -0,0 +1,60 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +/** + * Tests {@link NumberToLongConverter}. + * + * @author Alison Walter + */ +public abstract class NumberToLongTest extends AbstractNumberConverterTests { + + @Override + public abstract Number getSrc(); + + @Override + public abstract NumberToNumberConverter getConverter(); + + @Override + public abstract Number getInvalidInput(); + + @Override + public Number getExpectedValue() { + return new Long(7l); + } + + @Override + public Class getInvalidOutput() { + return Float.class; + } + +} diff --git a/src/test/java/org/scijava/convert/NumberToShortTest.java b/src/test/java/org/scijava/convert/NumberToShortTest.java new file mode 100644 index 000000000..ce42892af --- /dev/null +++ b/src/test/java/org/scijava/convert/NumberToShortTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + + +/** + * Tests {@link NumberToShortConverter}. + * + * @author Alison Walter + */ +public abstract class NumberToShortTest extends AbstractNumberConverterTests{ + @Override + public abstract Number getSrc(); + @Override + public abstract NumberToNumberConverter getConverter(); + @Override + public abstract Number getInvalidInput(); + + @Override + public Number getExpectedValue() { + return new Short((short) 7); + } + + @Override + public Class getInvalidOutput() { + return Float.class; + } +} diff --git a/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java new file mode 100644 index 000000000..a38ad653b --- /dev/null +++ b/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.ShortToBigDecimalConverter; + +/** + * Tests {@link ShortToBigDecimalConverter}. + * + * @author Alison Walter + */ +public class ShortToBigDecimalConverterTest extends NumberToBigDecimalTest { + + @Override + public Number getSrc() { + return new Short((short) 7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ShortToBigDecimalConverter(); + } + + @Override + public Number getInvalidInput() { + return new Long(81l); + } +} diff --git a/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java new file mode 100644 index 000000000..2e08e04b8 --- /dev/null +++ b/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.ShortToBigIntegerConverter; + +/** + * Tests {@link ShortToBigIntegerConverter}. + * + * @author Alison Walter + */ +public class ShortToBigIntegerConverterTest extends NumberToBigIntegerTest { + + @Override + public Number getSrc() { + return new Short((short) 7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ShortToBigIntegerConverter(); + } + + @Override + public Number getInvalidInput() { + return new Long(81l); + } +} diff --git a/src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java b/src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java new file mode 100644 index 000000000..e16306f59 --- /dev/null +++ b/src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.ShortToDoubleConverter; + +/** + * Tests {@link ShortToDoubleConverter}. + * + * @author Alison Walter + */ +public class ShortToDoubleConverterTest extends NumberToDoubleTest { + + @Override + public Number getSrc() { + return new Short((short) 7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ShortToDoubleConverter(); + } + + @Override + public Number getInvalidInput() { + return new Long(81l); + } +} diff --git a/src/test/java/org/scijava/convert/ShortToFloatConverterTest.java b/src/test/java/org/scijava/convert/ShortToFloatConverterTest.java new file mode 100644 index 000000000..5cd65d1e9 --- /dev/null +++ b/src/test/java/org/scijava/convert/ShortToFloatConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.ShortToFloatConverter; + +/** + * Tests {@link ShortToFloatConverter}. + * + * @author Alison Walter + */ +public class ShortToFloatConverterTest extends NumberToFloatTest { + + @Override + public Number getSrc() { + return new Short((short) 7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ShortToFloatConverter(); + } + + @Override + public Number getInvalidInput() { + return new Long(89l); + } +} diff --git a/src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java b/src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java new file mode 100644 index 000000000..4743b7912 --- /dev/null +++ b/src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.ShortToIntegerConverter; + +/** + * Tests {@link ShortToIntegerConverter}. + * + * @author Alison Walter + */ +public class ShortToIntegerConverterTest extends NumberToIntegerTest { + + @Override + public Number getSrc() { + return new Short((short) 7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ShortToIntegerConverter(); + } + + @Override + public Number getInvalidInput() { + return new Float(7.67f); + } +} diff --git a/src/test/java/org/scijava/convert/ShortToLongConverterTest.java b/src/test/java/org/scijava/convert/ShortToLongConverterTest.java new file mode 100644 index 000000000..ff2c3fbdc --- /dev/null +++ b/src/test/java/org/scijava/convert/ShortToLongConverterTest.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.convert; + +import org.scijava.convert.NumberConverters.ShortToLongConverter; + +/** + * Tests {@link ShortToLongConverter}. + * + * @author Alison Walter + */ +public class ShortToLongConverterTest extends NumberToLongTest { + + @Override + public Number getSrc() { + return new Short((short) 7); + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ShortToLongConverter(); + } + + @Override + public Number getInvalidInput() { + return new Float(7.67f); + } +} From 93318d2516a60042e884e2d2fe8daa67fb8f5338 Mon Sep 17 00:00:00 2001 From: Alison Walter Date: Thu, 23 Apr 2015 12:02:56 -0500 Subject: [PATCH 0115/1208] Added asBigDecimal and asBigInteger methods --- .../java/org/scijava/util/NumberUtils.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/org/scijava/util/NumberUtils.java b/src/main/java/org/scijava/util/NumberUtils.java index 8189764a0..108610ba3 100644 --- a/src/main/java/org/scijava/util/NumberUtils.java +++ b/src/main/java/org/scijava/util/NumberUtils.java @@ -31,6 +31,9 @@ package org.scijava.util; +import java.math.BigDecimal; +import java.math.BigInteger; + /** * Useful methods for working with {@link Number} objects. @@ -53,6 +56,21 @@ public static Number toNumber(final Object value, final Class type) { return num == null ? null : ConversionUtils.cast(num, Number.class); } + public static BigDecimal asBigDecimal(final Number n) { + // Using .doubleValue on a long or BigInteger would cause loss of accuracy + if(BigInteger.class.isInstance(n)){ + return new BigDecimal((BigInteger) n); + } + else if(Long.class.isInstance(n)){ + return new BigDecimal(n.longValue()); + } + return new BigDecimal(n.doubleValue()); + } + + public static BigInteger asBigInteger(final Number n) { + return BigInteger.valueOf(n.longValue()); + } + public static Number getMinimumNumber(final Class type) { if (ClassUtils.isByte(type)) return Byte.MIN_VALUE; if (ClassUtils.isShort(type)) return Short.MIN_VALUE; From e7a35c95e244968848b7eabf992d8caf5f5b773b Mon Sep 17 00:00:00 2001 From: Alison Walter Date: Thu, 23 Apr 2015 12:06:00 -0500 Subject: [PATCH 0116/1208] Implemented asBigInteger and asBigDecimal in converters --- .../convert/NumberToBigDecimalConverter.java | 13 +++---------- .../convert/NumberToBigIntegerConverter.java | 16 ++++++++++------ 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/scijava/convert/NumberToBigDecimalConverter.java b/src/main/java/org/scijava/convert/NumberToBigDecimalConverter.java index dca1eed41..b18178b1b 100644 --- a/src/main/java/org/scijava/convert/NumberToBigDecimalConverter.java +++ b/src/main/java/org/scijava/convert/NumberToBigDecimalConverter.java @@ -32,7 +32,8 @@ package org.scijava.convert; import java.math.BigDecimal; -import java.math.BigInteger; + +import org.scijava.util.NumberUtils; /** * Converts numbers to BigDecimals. @@ -43,15 +44,7 @@ public abstract class NumberToBigDecimalConverter extends Numb @Override public BigDecimal convert(Number n) { - // cannot get doubleValue of a BigInteger - if(BigInteger.class.isInstance(n)){ - return new BigDecimal((BigInteger) n); - } - // Using .doubleValue on a long would cause loss of accuracy - else if(Long.class.isInstance(n)){ - return new BigDecimal(n.longValue()); - } - return new BigDecimal(n.doubleValue()); + return NumberUtils.asBigDecimal(n); } @Override diff --git a/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java b/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java index 6b16b21bc..b8d0449e2 100644 --- a/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java +++ b/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java @@ -8,13 +8,13 @@ * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -33,16 +33,20 @@ import java.math.BigInteger; +import org.scijava.util.NumberUtils; + /** * Converts numbers to BigIntegers. * * @author Alison Walter */ -public abstract class NumberToBigIntegerConverter extends NumberToNumberConverter { +public abstract class NumberToBigIntegerConverter extends + NumberToNumberConverter +{ @Override - public BigInteger convert(Number n) { - return BigInteger.valueOf(n.longValue()); + public BigInteger convert(final Number n) { + return NumberUtils.asBigInteger(n); } @Override @@ -50,4 +54,4 @@ public Class getOutputType() { return BigInteger.class; } -} \ No newline at end of file +} From 889440263c368978a05b32ba4d977aa5eb00ecdc Mon Sep 17 00:00:00 2001 From: Alison Walter Date: Thu, 23 Apr 2015 12:08:13 -0500 Subject: [PATCH 0117/1208] Added getPrimitiveType method --- .../org/scijava/util/ConversionUtils.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/main/java/org/scijava/util/ConversionUtils.java b/src/main/java/org/scijava/util/ConversionUtils.java index 0f343d157..fdc38de19 100644 --- a/src/main/java/org/scijava/util/ConversionUtils.java +++ b/src/main/java/org/scijava/util/ConversionUtils.java @@ -122,6 +122,41 @@ public static boolean canCast(final Object src, final Class dest) { return src == null || canCast(src.getClass(), dest); } + /** + * Returns the primitive {@link Class} closest to the given type. + *

    + * Specifically, the following type conversions are done: + *

      + *
    • Boolean.class becomes boolean.class
    • + *
    • Byte.class becomes byte.class
    • + *
    • Character.class becomes char.class
    • + *
    • Double.class becomes double.class
    • + *
    • Float.class becomes float.class
    • + *
    • Integer.class becomes int.class
    • + *
    • Long.class becomes long.class
    • + *
    • Short.class becomes short.class
    • + *
    • Void.class becomes void.class
    • + *
    + * All other types are unchanged. + *

    + */ + public static Class getPrimitiveType(final Class type) { + final Class destType; + if (type == Boolean.class) destType = boolean.class; + else if (type == Byte.class) destType = byte.class; + else if (type == Character.class) destType = char.class; + else if (type == Double.class) destType = double.class; + else if (type == Float.class) destType = float.class; + else if (type == Integer.class) destType = int.class; + else if (type == Long.class) destType = long.class; + else if (type == Short.class) destType = short.class; + else if (type == Void.class) destType = void.class; + else destType = type; + @SuppressWarnings("unchecked") + final Class result = (Class) destType; + return result; + } + /** * Returns the non-primitive {@link Class} closest to the given type. *

    From ab408b67f9ed6b2e6fb29bb0e4e28cf987aebaec Mon Sep 17 00:00:00 2001 From: Alison Walter Date: Thu, 23 Apr 2015 12:20:53 -0500 Subject: [PATCH 0118/1208] Changed testPrimitive to use getPrimitiveType method --- .../convert/AbstractNumberConverterTests.java | 79 +------------------ 1 file changed, 3 insertions(+), 76 deletions(-) diff --git a/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java b/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java index 23505adfb..854c99974 100644 --- a/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java +++ b/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java @@ -34,12 +34,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import java.math.BigDecimal; -import java.math.BigInteger; - import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.scijava.util.ConversionUtils; /** * Tests converter plugins that convert from primitive numeric types to other @@ -81,79 +79,8 @@ public void testWrapper() { public void testPrimitive() { final Number src = getSrc(); final Number expect = getExpectedValue(); - if (!destType.equals(BigInteger.class) && - !destType.equals(BigDecimal.class)) - { - // byte to number converters - if (srcType.equals(Byte.class)) { - final byte b = src.byteValue(); - if (destType.equals(Short.class)) { - final short s = expect.shortValue(); - assertTrue(s == converter.convert(b, short.class)); - } - else if (destType.equals(Integer.class)) { - final int i = expect.intValue(); - assertTrue(i == converter.convert(b, int.class)); - } - else if (destType.equals(Long.class)) { - final long l = expect.longValue(); - assertTrue(l == converter.convert(b, long.class)); - } - else if (destType.equals(Float.class)) { - final float f = expect.floatValue(); - assertTrue(f == converter.convert(b, float.class)); - } - else { - final double d = expect.doubleValue(); - assertTrue(d == converter.convert(b, double.class)); - } - } - // int to number converters - else if (srcType.equals(Integer.class)) { - final int i = src.intValue(); - if (destType.equals(Long.class)) { - final long l = expect.longValue(); - assertTrue(l == converter.convert(i, long.class)); - } - else { - final double d = expect.doubleValue(); - assertTrue(d == converter.convert(i, double.class)); - } - } - // short to number converters - else if (srcType.equals(Short.class)) { - final short s = src.shortValue(); - if (destType.equals(Integer.class)) { - final int i = expect.intValue(); - assertTrue(i == converter.convert(s, int.class)); - } - else if (destType.equals(Long.class)) { - final long l = expect.longValue(); - assertTrue(l == converter.convert(s, long.class)); - } - else if (destType.equals(Float.class)) { - final float f = expect.floatValue(); - assertTrue(f == converter.convert(s, float.class)); - } - else { - final double d = expect.doubleValue(); - assertTrue(d == converter.convert(s, double.class)); - } - } - // float to number converters - else if (srcType.equals(Float.class)) { - final float f = expect.floatValue(); - final double d = expect.doubleValue(); - assertTrue(d == converter.convert(f, double.class)); - } - else { - // longs and doubles can't be converted to anything beside bigInteger - // and big decimal - } - } - else { - // no prim equivalents for BigInteger and BigDecimal - } + assertEquals(expect, converter.convert(src, ConversionUtils + .getPrimitiveType(destType))); } /** From e12536696f1be061eafd62d51e8ad05be5db51a5 Mon Sep 17 00:00:00 2001 From: Alison Walter Date: Tue, 28 Apr 2015 10:30:03 -0500 Subject: [PATCH 0119/1208] Modify tests to no longer depend on obsolete files This also narrows the return types as appropriate for each concrete type. --- .../BigIntegerToBigDecimalConverterTest.java | 20 ++++++-- .../ByteToBigDecimalConverterTest.java | 46 +++++++++++------- .../ByteToBigIntegerConverterTest.java | 45 +++++++++++------- .../convert/ByteToDoubleConverterTest.java | 43 ++++++++++------- .../convert/ByteToFloatConverterTest.java | 42 ++++++++++------- .../convert/ByteToIntegerConverterTest.java | 43 ++++++++++------- .../convert/ByteToLongConverterTest.java | 43 ++++++++++------- .../convert/ByteToShortConverterTest.java | 42 ++++++++++------- .../DoubleToBigDecimalConverterTest.java | 46 +++++++++++------- .../FloatToBigDecimalConverterTest.java | 47 ++++++++++++------- .../convert/FloatToDoubleConverterTest.java | 43 ++++++++++------- .../IntegerToBigDecimalConverterTest.java | 45 +++++++++++------- .../IntegerToBigIntegerConverterTest.java | 47 ++++++++++++------- .../convert/IntegerToDoubleConverterTest.java | 43 ++++++++++------- .../convert/IntegerToLongConverterTest.java | 42 ++++++++++------- .../LongToBigDecimalConverterTest.java | 46 +++++++++++------- .../LongToBigIntegerConverterTest.java | 45 +++++++++++------- .../ShortToBigDecimalConverterTest.java | 47 ++++++++++++------- .../ShortToBigIntegerConverterTest.java | 46 +++++++++++------- .../convert/ShortToDoubleConverterTest.java | 42 ++++++++++------- .../convert/ShortToFloatConverterTest.java | 42 ++++++++++------- .../convert/ShortToIntegerConverterTest.java | 43 ++++++++++------- .../convert/ShortToLongConverterTest.java | 43 ++++++++++------- 23 files changed, 635 insertions(+), 356 deletions(-) diff --git a/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java index b493aa868..29205a905 100644 --- a/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java @@ -31,6 +31,7 @@ package org.scijava.convert; +import java.math.BigDecimal; import java.math.BigInteger; import org.scijava.convert.NumberConverters.BigIntegerToBigDecimalConverter; @@ -40,11 +41,12 @@ * * @author Alison Walter */ -public class BigIntegerToBigDecimalConverterTest extends NumberToBigDecimalTest +public class BigIntegerToBigDecimalConverterTest extends + AbstractNumberConverterTests { @Override - public Number getSrc() { + public BigInteger getSrc() { return BigInteger.valueOf(7l); } @@ -54,7 +56,17 @@ public Number getSrc() { } @Override - public Number getInvalidInput() { - return new Long(46l); + public BigDecimal getExpectedValue() { + return new BigDecimal(7d); + } + + @Override + public Long getInvalidInput() { + return 46l; + } + + @Override + public Class getInvalidOutput() { + return Float.class; } } diff --git a/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java index 50c1ee02f..7ca8a2e19 100644 --- a/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java @@ -31,6 +31,8 @@ package org.scijava.convert; +import java.math.BigDecimal; + import org.scijava.convert.NumberConverters.ByteToBigDecimalConverter; /** @@ -38,20 +40,32 @@ * * @author Alison Walter */ -public class ByteToBigDecimalConverterTest extends NumberToBigDecimalTest { - - @Override - public Number getSrc() { - return new Byte((byte) 7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.ByteToBigDecimalConverter(); - } - - @Override - public Number getInvalidInput() { - return new Short((short) 101); - } +public class ByteToBigDecimalConverterTest extends AbstractNumberConverterTests +{ + + @Override + public Byte getSrc() { + return (byte) 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ByteToBigDecimalConverter(); + } + + @Override + public BigDecimal getExpectedValue() { + return new BigDecimal(7d); + } + + @Override + public Short getInvalidInput() { + return (short) 101; + } + + @Override + public Class getInvalidOutput() { + return Float.class; + } + } diff --git a/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java index 58637e90f..871c66956 100644 --- a/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java @@ -31,6 +31,8 @@ package org.scijava.convert; +import java.math.BigInteger; + import org.scijava.convert.NumberConverters.ByteToBigIntegerConverter; /** @@ -38,21 +40,32 @@ * * @author Alison Walter */ -public class ByteToBigIntegerConverterTest extends NumberToBigIntegerTest { - - @Override - public Number getSrc() { - return new Byte((byte) 7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.ByteToBigIntegerConverter(); - } - - @Override - public Number getInvalidInput() { - return new Short((short) 101); - } +public class ByteToBigIntegerConverterTest extends AbstractNumberConverterTests +{ + + @Override + public Byte getSrc() { + return (byte) 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ByteToBigIntegerConverter(); + } + + @Override + public BigInteger getExpectedValue() { + return BigInteger.valueOf(7l); + } + + @Override + public Short getInvalidInput() { + return (short) 101; + } + + @Override + public Class getInvalidOutput() { + return Byte.class; } +} diff --git a/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java b/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java index e3eb340ed..c8ce44631 100644 --- a/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java @@ -38,20 +38,31 @@ * * @author Alison Walter */ -public class ByteToDoubleConverterTest extends NumberToDoubleTest { - - @Override - public Number getSrc() { - return new Byte((byte) 7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.ByteToDoubleConverter(); - } - - @Override - public Number getInvalidInput() { - return new Short((short) 101); - } +public class ByteToDoubleConverterTest extends AbstractNumberConverterTests { + + @Override + public Byte getSrc() { + return (byte) 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ByteToDoubleConverter(); + } + + @Override + public Double getExpectedValue() { + return 7.0d; + } + + @Override + public Short getInvalidInput() { + return (short) 101; + } + + @Override + public Class getInvalidOutput() { + return Byte.class; + } + } diff --git a/src/test/java/org/scijava/convert/ByteToFloatConverterTest.java b/src/test/java/org/scijava/convert/ByteToFloatConverterTest.java index 0fe7238c1..be49e244b 100644 --- a/src/test/java/org/scijava/convert/ByteToFloatConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToFloatConverterTest.java @@ -38,20 +38,30 @@ * * @author Alison Walter */ -public class ByteToFloatConverterTest extends NumberToFloatTest { - - @Override - public Number getSrc() { - return new Byte((byte) 7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.ByteToFloatConverter(); - } - - @Override - public Number getInvalidInput() { - return new Double(7.67d); - } +public class ByteToFloatConverterTest extends AbstractNumberConverterTests { + + @Override + public Byte getSrc() { + return (byte) 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ByteToFloatConverter(); + } + + @Override + public Float getExpectedValue() { + return 7f; + } + + @Override + public Double getInvalidInput() { + return 7.67d; + } + + @Override + public Class getInvalidOutput() { + return Long.class; + } } diff --git a/src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java b/src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java index 972aa84d2..82e8bd95b 100644 --- a/src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java @@ -38,20 +38,31 @@ * * @author Alison Walter */ -public class ByteToIntegerConverterTest extends NumberToIntegerTest { - - @Override - public Number getSrc() { - return new Byte((byte) 7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.ByteToIntegerConverter(); - } - - @Override - public Number getInvalidInput() { - return new Long(12l); - } +public class ByteToIntegerConverterTest extends AbstractNumberConverterTests { + + @Override + public Byte getSrc() { + return (byte) 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ByteToIntegerConverter(); + } + + @Override + public Integer getExpectedValue() { + return 7; + } + + @Override + public Long getInvalidInput() { + return 12l; + } + + @Override + public Class getInvalidOutput() { + return Short.class; + } + } diff --git a/src/test/java/org/scijava/convert/ByteToLongConverterTest.java b/src/test/java/org/scijava/convert/ByteToLongConverterTest.java index f9b849e30..6c14de3ef 100644 --- a/src/test/java/org/scijava/convert/ByteToLongConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToLongConverterTest.java @@ -38,20 +38,31 @@ * * @author Alison Walter */ -public class ByteToLongConverterTest extends NumberToLongTest { - - @Override - public Number getSrc() { - return new Byte((byte) 7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.ByteToLongConverter(); - } - - @Override - public Number getInvalidInput() { - return new Double(12d); - } +public class ByteToLongConverterTest extends AbstractNumberConverterTests { + + @Override + public Byte getSrc() { + return (byte) 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ByteToLongConverter(); + } + + @Override + public Long getExpectedValue() { + return 7l; + } + + @Override + public Double getInvalidInput() { + return 12d; + } + + @Override + public Class getInvalidOutput() { + return Float.class; + } + } diff --git a/src/test/java/org/scijava/convert/ByteToShortConverterTest.java b/src/test/java/org/scijava/convert/ByteToShortConverterTest.java index 4033863c1..4407bb916 100644 --- a/src/test/java/org/scijava/convert/ByteToShortConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToShortConverterTest.java @@ -38,21 +38,31 @@ * * @author Alison Walter */ -public class ByteToShortConverterTest extends NumberToShortTest { - - @Override - public Number getSrc() { - return new Byte((byte) 7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.ByteToShortConverter(); - } - - @Override - public Number getInvalidInput() { - return new Integer(12); - } +public class ByteToShortConverterTest extends AbstractNumberConverterTests { + + @Override + public Byte getSrc() { + return (byte) 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ByteToShortConverter(); + } + + @Override + public Short getExpectedValue() { + return (short) 7; + } + + @Override + public Integer getInvalidInput() { + return 12; + } + + @Override + public Class getInvalidOutput() { + return Float.class; + } } diff --git a/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java index be9af7c86..7c444cbde 100644 --- a/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java @@ -31,6 +31,8 @@ package org.scijava.convert; +import java.math.BigDecimal; + import org.scijava.convert.NumberConverters.DoubleToBigDecimalConverter; /** @@ -38,20 +40,32 @@ * * @author Alison Walter */ -public class DoubleToBigDecimalConverterTest extends NumberToBigDecimalTest { - - @Override - public Number getSrc() { - return new Double(7.0d); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.DoubleToBigDecimalConverter(); - } - - @Override - public Number getInvalidInput() { - return new Short((short) 7); - } +public class DoubleToBigDecimalConverterTest extends + AbstractNumberConverterTests +{ + + @Override + public Double getSrc() { + return 7.0d; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.DoubleToBigDecimalConverter(); + } + + @Override + public BigDecimal getExpectedValue() { + return new BigDecimal(7d); + } + + @Override + public Short getInvalidInput() { + return (short) 7; + } + + @Override + public Class getInvalidOutput() { + return Float.class; + } } diff --git a/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java index bb8ce3715..e30e1c8f8 100644 --- a/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java @@ -31,6 +31,8 @@ package org.scijava.convert; +import java.math.BigDecimal; + import org.scijava.convert.NumberConverters.FloatToBigDecimalConverter; /** @@ -38,20 +40,33 @@ * * @author Alison Walter */ -public class FloatToBigDecimalConverterTest extends NumberToBigDecimalTest { - - @Override - public Number getSrc() { - return new Float(7f); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.FloatToBigDecimalConverter(); - } - - @Override - public Number getInvalidInput() { - return new Integer(394); - } +public class FloatToBigDecimalConverterTest extends + AbstractNumberConverterTests +{ + + @Override + public Float getSrc() { + return 7f; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.FloatToBigDecimalConverter(); + } + + @Override + public BigDecimal getExpectedValue() { + return new BigDecimal(7d); + } + + @Override + public Integer getInvalidInput() { + return 394; + } + + @Override + public Class getInvalidOutput() { + return Float.class; + } + } diff --git a/src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java b/src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java index 12f9b03cc..00bf08c86 100644 --- a/src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java +++ b/src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java @@ -38,20 +38,31 @@ * * @author Alison Walter */ -public class FloatToDoubleConverterTest extends NumberToDoubleTest { - - @Override - public Number getSrc() { - return new Float(7.0f); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.FloatToDoubleConverter(); - } - - @Override - public Number getInvalidInput() { - return new Integer(394); - } +public class FloatToDoubleConverterTest extends AbstractNumberConverterTests { + + @Override + public Float getSrc() { + return 7.0f; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.FloatToDoubleConverter(); + } + + @Override + public Double getExpectedValue() { + return 7.0d; + } + + @Override + public Integer getInvalidInput() { + return 394; + } + + @Override + public Class getInvalidOutput() { + return Byte.class; + } + } diff --git a/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java index 56a509b7b..d4c41e516 100644 --- a/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java @@ -31,6 +31,8 @@ package org.scijava.convert; +import java.math.BigDecimal; + import org.scijava.convert.NumberConverters.IntegerToBigDecimalConverter; /** @@ -38,21 +40,32 @@ * * @author Alison Walter */ -public class IntegerToBigDecimalConverterTest extends NumberToBigDecimalTest { - - @Override - public Number getSrc() { - return new Integer(7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.IntegerToBigDecimalConverter(); - } - - @Override - public Number getInvalidInput() { - return new Byte((byte) 2); - } +public class IntegerToBigDecimalConverterTest extends + AbstractNumberConverterTests +{ + + @Override + public Integer getSrc() { + return 7; } + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.IntegerToBigDecimalConverter(); + } + + @Override + public BigDecimal getExpectedValue() { + return new BigDecimal(7d); + } + + @Override + public Byte getInvalidInput() { + return (byte) 2; + } + + @Override + public Class getInvalidOutput() { + return Float.class; + } +} diff --git a/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java index b6a04d3b8..f6762db3a 100644 --- a/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java @@ -31,6 +31,8 @@ package org.scijava.convert; +import java.math.BigInteger; + import org.scijava.convert.NumberConverters.IntegerToBigIntegerConverter; /** @@ -38,20 +40,33 @@ * * @author Alison Walter */ -public class IntegerToBigIntegerConverterTest extends NumberToBigIntegerTest { - - @Override - public Number getSrc() { - return new Integer(7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.IntegerToBigIntegerConverter(); - } - - @Override - public Number getInvalidInput() { - return new Byte((byte) 2); - } +public class IntegerToBigIntegerConverterTest extends + AbstractNumberConverterTests +{ + + @Override + public Integer getSrc() { + return 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.IntegerToBigIntegerConverter(); + } + + @Override + public BigInteger getExpectedValue() { + return BigInteger.valueOf(7l); + } + + @Override + public Byte getInvalidInput() { + return (byte) 2; + } + + @Override + public Class getInvalidOutput() { + return Byte.class; + } + } diff --git a/src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java b/src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java index 2882d3c1e..23f8db5ef 100644 --- a/src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java +++ b/src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java @@ -38,20 +38,31 @@ * * @author Alison Walter */ -public class IntegerToDoubleConverterTest extends NumberToDoubleTest { - - @Override - public Number getSrc() { - return new Integer(7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.IntegerToDoubleConverter(); - } - - @Override - public Number getInvalidInput() { - return new Byte((byte) 2); - } +public class IntegerToDoubleConverterTest extends AbstractNumberConverterTests { + + @Override + public Integer getSrc() { + return 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.IntegerToDoubleConverter(); + } + + @Override + public Double getExpectedValue() { + return 7.0d; + } + + @Override + public Byte getInvalidInput() { + return (byte) 2; + } + + @Override + public Class getInvalidOutput() { + return Byte.class; + } + } diff --git a/src/test/java/org/scijava/convert/IntegerToLongConverterTest.java b/src/test/java/org/scijava/convert/IntegerToLongConverterTest.java index a7350b569..eb6b7604e 100644 --- a/src/test/java/org/scijava/convert/IntegerToLongConverterTest.java +++ b/src/test/java/org/scijava/convert/IntegerToLongConverterTest.java @@ -38,20 +38,30 @@ * * @author Alison Walter */ -public class IntegerToLongConverterTest extends NumberToLongTest { - - @Override - public Number getSrc() { - return new Integer(7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.IntegerToLongConverter(); - } - - @Override - public Number getInvalidInput() { - return new Float(7.67f); - } +public class IntegerToLongConverterTest extends AbstractNumberConverterTests { + + @Override + public Integer getSrc() { + return 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.IntegerToLongConverter(); + } + + @Override + public Long getExpectedValue() { + return 7l; + } + + @Override + public Float getInvalidInput() { + return 7.67f; + } + + @Override + public Class getInvalidOutput() { + return Float.class; + } } diff --git a/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java index d7b584279..83be6b66e 100644 --- a/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java @@ -31,6 +31,8 @@ package org.scijava.convert; +import java.math.BigDecimal; + import org.scijava.convert.NumberConverters.LongToBigDecimalConverter; /** @@ -38,20 +40,32 @@ * * @author Alison Walter */ -public class LongToBigDecimalConverterTest extends NumberToBigDecimalTest { - - @Override - public Number getSrc() { - return new Long(7l); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.LongToBigDecimalConverter(); - } - - @Override - public Number getInvalidInput() { - return new Integer(394); - } +public class LongToBigDecimalConverterTest extends AbstractNumberConverterTests +{ + + @Override + public Long getSrc() { + return 7l; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.LongToBigDecimalConverter(); + } + + @Override + public BigDecimal getExpectedValue() { + return new BigDecimal(7d); + } + + @Override + public Integer getInvalidInput() { + return 394; + } + + @Override + public Class getInvalidOutput() { + return Float.class; + } + } diff --git a/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java index 9ff8a1e81..678d6770f 100644 --- a/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java @@ -31,6 +31,8 @@ package org.scijava.convert; +import java.math.BigInteger; + import org.scijava.convert.NumberConverters.LongToBigIntegerConverter; /** @@ -38,20 +40,31 @@ * * @author Alison Walter */ -public class LongToBigIntegerConverterTest extends NumberToBigIntegerTest { - - @Override - public Number getSrc() { - return new Long(7l); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.LongToBigIntegerConverter(); - } - - @Override - public Number getInvalidInput() { - return new Integer(394); - } +public class LongToBigIntegerConverterTest extends AbstractNumberConverterTests +{ + + @Override + public Long getSrc() { + return 7l; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.LongToBigIntegerConverter(); + } + + @Override + public BigInteger getExpectedValue() { + return BigInteger.valueOf(7l); + } + + @Override + public Integer getInvalidInput() { + return 394; + } + + @Override + public Class getInvalidOutput() { + return Byte.class; + } } diff --git a/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java index a38ad653b..851968907 100644 --- a/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java @@ -31,6 +31,8 @@ package org.scijava.convert; +import java.math.BigDecimal; + import org.scijava.convert.NumberConverters.ShortToBigDecimalConverter; /** @@ -38,20 +40,33 @@ * * @author Alison Walter */ -public class ShortToBigDecimalConverterTest extends NumberToBigDecimalTest { - - @Override - public Number getSrc() { - return new Short((short) 7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.ShortToBigDecimalConverter(); - } - - @Override - public Number getInvalidInput() { - return new Long(81l); - } +public class ShortToBigDecimalConverterTest extends + AbstractNumberConverterTests +{ + + @Override + public Short getSrc() { + return (short) 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ShortToBigDecimalConverter(); + } + + @Override + public BigDecimal getExpectedValue() { + return new BigDecimal(7d); + } + + @Override + public Long getInvalidInput() { + return 81l; + } + + @Override + public Class getInvalidOutput() { + return Float.class; + } + } diff --git a/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java index 2e08e04b8..f6e9e37a3 100644 --- a/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java @@ -31,6 +31,8 @@ package org.scijava.convert; +import java.math.BigInteger; + import org.scijava.convert.NumberConverters.ShortToBigIntegerConverter; /** @@ -38,20 +40,32 @@ * * @author Alison Walter */ -public class ShortToBigIntegerConverterTest extends NumberToBigIntegerTest { - - @Override - public Number getSrc() { - return new Short((short) 7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.ShortToBigIntegerConverter(); - } - - @Override - public Number getInvalidInput() { - return new Long(81l); - } +public class ShortToBigIntegerConverterTest extends + AbstractNumberConverterTests +{ + + @Override + public Short getSrc() { + return (short) 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ShortToBigIntegerConverter(); + } + + @Override + public BigInteger getExpectedValue() { + return BigInteger.valueOf(7l); + } + + @Override + public Long getInvalidInput() { + return 81l; + } + + @Override + public Class getInvalidOutput() { + return Byte.class; + } } diff --git a/src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java b/src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java index e16306f59..0fdf6c6c3 100644 --- a/src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java @@ -38,20 +38,30 @@ * * @author Alison Walter */ -public class ShortToDoubleConverterTest extends NumberToDoubleTest { - - @Override - public Number getSrc() { - return new Short((short) 7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.ShortToDoubleConverter(); - } - - @Override - public Number getInvalidInput() { - return new Long(81l); - } +public class ShortToDoubleConverterTest extends AbstractNumberConverterTests { + + @Override + public Short getSrc() { + return (short) 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ShortToDoubleConverter(); + } + + @Override + public Double getExpectedValue() { + return 7.0d; + } + + @Override + public Long getInvalidInput() { + return 81l; + } + + @Override + public Class getInvalidOutput() { + return Byte.class; + } } diff --git a/src/test/java/org/scijava/convert/ShortToFloatConverterTest.java b/src/test/java/org/scijava/convert/ShortToFloatConverterTest.java index 5cd65d1e9..e9db0a38b 100644 --- a/src/test/java/org/scijava/convert/ShortToFloatConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToFloatConverterTest.java @@ -38,20 +38,30 @@ * * @author Alison Walter */ -public class ShortToFloatConverterTest extends NumberToFloatTest { - - @Override - public Number getSrc() { - return new Short((short) 7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.ShortToFloatConverter(); - } - - @Override - public Number getInvalidInput() { - return new Long(89l); - } +public class ShortToFloatConverterTest extends AbstractNumberConverterTests { + + @Override + public Short getSrc() { + return (short) 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ShortToFloatConverter(); + } + + @Override + public Float getExpectedValue() { + return 7f; + } + + @Override + public Long getInvalidInput() { + return 89l; + } + + @Override + public Class getInvalidOutput() { + return Long.class; + } } diff --git a/src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java b/src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java index 4743b7912..24033528d 100644 --- a/src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java @@ -38,20 +38,31 @@ * * @author Alison Walter */ -public class ShortToIntegerConverterTest extends NumberToIntegerTest { - - @Override - public Number getSrc() { - return new Short((short) 7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.ShortToIntegerConverter(); - } - - @Override - public Number getInvalidInput() { - return new Float(7.67f); - } +public class ShortToIntegerConverterTest extends AbstractNumberConverterTests { + + @Override + public Short getSrc() { + return (short) 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ShortToIntegerConverter(); + } + + @Override + public Integer getExpectedValue() { + return 7; + } + + @Override + public Float getInvalidInput() { + return 7.67f; + } + + @Override + public Class getInvalidOutput() { + return Short.class; + } + } diff --git a/src/test/java/org/scijava/convert/ShortToLongConverterTest.java b/src/test/java/org/scijava/convert/ShortToLongConverterTest.java index ff2c3fbdc..c1586a412 100644 --- a/src/test/java/org/scijava/convert/ShortToLongConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToLongConverterTest.java @@ -38,20 +38,31 @@ * * @author Alison Walter */ -public class ShortToLongConverterTest extends NumberToLongTest { - - @Override - public Number getSrc() { - return new Short((short) 7); - } - - @Override - public NumberToNumberConverter getConverter() { - return new NumberConverters.ShortToLongConverter(); - } - - @Override - public Number getInvalidInput() { - return new Float(7.67f); - } +public class ShortToLongConverterTest extends AbstractNumberConverterTests { + + @Override + public Short getSrc() { + return (short) 7; + } + + @Override + public NumberToNumberConverter getConverter() { + return new NumberConverters.ShortToLongConverter(); + } + + @Override + public Long getExpectedValue() { + return 7l; + } + + @Override + public Float getInvalidInput() { + return 7.67f; + } + + @Override + public Class getInvalidOutput() { + return Float.class; + } + } From a79d883f367db9c20ab8ef048ebd2087aa2a709b Mon Sep 17 00:00:00 2001 From: Alison Walter Date: Tue, 28 Apr 2015 10:30:03 -0500 Subject: [PATCH 0120/1208] Remove obsolete test files They are redundant with the new more granular test classes. --- .../convert/NumberToBigDecimalTest.java | 59 ----------------- .../convert/NumberToBigIntegerTest.java | 63 ------------------- .../scijava/convert/NumberToDoubleTest.java | 60 ------------------ .../scijava/convert/NumberToFloatTest.java | 61 ------------------ .../scijava/convert/NumberToIntegerTest.java | 60 ------------------ .../org/scijava/convert/NumberToLongTest.java | 60 ------------------ .../scijava/convert/NumberToShortTest.java | 57 ----------------- 7 files changed, 420 deletions(-) delete mode 100644 src/test/java/org/scijava/convert/NumberToBigDecimalTest.java delete mode 100644 src/test/java/org/scijava/convert/NumberToBigIntegerTest.java delete mode 100644 src/test/java/org/scijava/convert/NumberToDoubleTest.java delete mode 100644 src/test/java/org/scijava/convert/NumberToFloatTest.java delete mode 100644 src/test/java/org/scijava/convert/NumberToIntegerTest.java delete mode 100644 src/test/java/org/scijava/convert/NumberToLongTest.java delete mode 100644 src/test/java/org/scijava/convert/NumberToShortTest.java diff --git a/src/test/java/org/scijava/convert/NumberToBigDecimalTest.java b/src/test/java/org/scijava/convert/NumberToBigDecimalTest.java deleted file mode 100644 index 09f57d33d..000000000 --- a/src/test/java/org/scijava/convert/NumberToBigDecimalTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * #%L - * SciJava Common shared library for SciJava software. - * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package org.scijava.convert; - -import java.math.BigDecimal; - -/** - * Tests {@link NumberToBigDecimalConverter}. - * - * @author Alison Walter - */ -public abstract class NumberToBigDecimalTest extends AbstractNumberConverterTests{ - @Override - public abstract Number getSrc(); - @Override - public abstract NumberToNumberConverter getConverter(); - @Override - public abstract Number getInvalidInput(); - - @Override - public Number getExpectedValue() { - return new BigDecimal(7d); - } - - @Override - public Class getInvalidOutput() { - return Float.class; - } - -} diff --git a/src/test/java/org/scijava/convert/NumberToBigIntegerTest.java b/src/test/java/org/scijava/convert/NumberToBigIntegerTest.java deleted file mode 100644 index 53dc35230..000000000 --- a/src/test/java/org/scijava/convert/NumberToBigIntegerTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * #%L - * SciJava Common shared library for SciJava software. - * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package org.scijava.convert; - -import java.math.BigInteger; - -/** - * Tests {@link NumberToBigIntegerConverter}. - * - * @author Alison Walter - */ -public abstract class NumberToBigIntegerTest extends - AbstractNumberConverterTests -{ - - @Override - public abstract Number getSrc(); - - @Override - public abstract NumberToNumberConverter getConverter(); - - @Override - public abstract Number getInvalidInput(); - - @Override - public Number getExpectedValue() { - return BigInteger.valueOf(7l); - } - - @Override - public Class getInvalidOutput() { - return Byte.class; - } -} diff --git a/src/test/java/org/scijava/convert/NumberToDoubleTest.java b/src/test/java/org/scijava/convert/NumberToDoubleTest.java deleted file mode 100644 index f1108e461..000000000 --- a/src/test/java/org/scijava/convert/NumberToDoubleTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * #%L - * SciJava Common shared library for SciJava software. - * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package org.scijava.convert; - - -/** - * Tests {@link NumberToDoubleConverter}. - * - * @author Alison Walter - */ -public abstract class NumberToDoubleTest extends AbstractNumberConverterTests { - - @Override - public abstract Number getSrc(); - - @Override - public abstract NumberToNumberConverter getConverter(); - - @Override - public abstract Number getInvalidInput(); - - @Override - public Number getExpectedValue() { - return new Double(7.0d); - } - - @Override - public Class getInvalidOutput() { - return Byte.class; - } -} diff --git a/src/test/java/org/scijava/convert/NumberToFloatTest.java b/src/test/java/org/scijava/convert/NumberToFloatTest.java deleted file mode 100644 index 45938573f..000000000 --- a/src/test/java/org/scijava/convert/NumberToFloatTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * #%L - * SciJava Common shared library for SciJava software. - * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package org.scijava.convert; - - -/** - * Tests {@link NumberToFloatConverter}. - * - * @author Alison Walter - */ -public abstract class NumberToFloatTest extends AbstractNumberConverterTests { - - @Override - public abstract Number getSrc(); - - @Override - public abstract NumberToNumberConverter getConverter(); - - @Override - public abstract Number getInvalidInput(); - - @Override - public Number getExpectedValue() { - return new Float(7f); - } - - @Override - public Class getInvalidOutput() { - return Long.class; - } -} - diff --git a/src/test/java/org/scijava/convert/NumberToIntegerTest.java b/src/test/java/org/scijava/convert/NumberToIntegerTest.java deleted file mode 100644 index e3b3c7043..000000000 --- a/src/test/java/org/scijava/convert/NumberToIntegerTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * #%L - * SciJava Common shared library for SciJava software. - * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package org.scijava.convert; - -/** - * Tests {@link NumberToIntegerConverter}. - * - * @author Alison Walter - */ -public abstract class NumberToIntegerTest extends AbstractNumberConverterTests { - - @Override - public abstract Number getSrc(); - - @Override - public abstract NumberToNumberConverter getConverter(); - - @Override - public abstract Number getInvalidInput(); - - @Override - public Number getExpectedValue() { - return new Integer(7); - } - - @Override - public Class getInvalidOutput() { - return Short.class; - } - -} diff --git a/src/test/java/org/scijava/convert/NumberToLongTest.java b/src/test/java/org/scijava/convert/NumberToLongTest.java deleted file mode 100644 index d35ec3b45..000000000 --- a/src/test/java/org/scijava/convert/NumberToLongTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * #%L - * SciJava Common shared library for SciJava software. - * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package org.scijava.convert; - -/** - * Tests {@link NumberToLongConverter}. - * - * @author Alison Walter - */ -public abstract class NumberToLongTest extends AbstractNumberConverterTests { - - @Override - public abstract Number getSrc(); - - @Override - public abstract NumberToNumberConverter getConverter(); - - @Override - public abstract Number getInvalidInput(); - - @Override - public Number getExpectedValue() { - return new Long(7l); - } - - @Override - public Class getInvalidOutput() { - return Float.class; - } - -} diff --git a/src/test/java/org/scijava/convert/NumberToShortTest.java b/src/test/java/org/scijava/convert/NumberToShortTest.java deleted file mode 100644 index ce42892af..000000000 --- a/src/test/java/org/scijava/convert/NumberToShortTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * #%L - * SciJava Common shared library for SciJava software. - * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package org.scijava.convert; - - -/** - * Tests {@link NumberToShortConverter}. - * - * @author Alison Walter - */ -public abstract class NumberToShortTest extends AbstractNumberConverterTests{ - @Override - public abstract Number getSrc(); - @Override - public abstract NumberToNumberConverter getConverter(); - @Override - public abstract Number getInvalidInput(); - - @Override - public Number getExpectedValue() { - return new Short((short) 7); - } - - @Override - public Class getInvalidOutput() { - return Float.class; - } -} From 737174507c1eed66028a6536da63fa016c4d2003 Mon Sep 17 00:00:00 2001 From: Alison Walter Date: Thu, 30 Apr 2015 09:31:38 -0500 Subject: [PATCH 0121/1208] Implemented asBigDecimal and asBigInteger in junit tests --- .../scijava/convert/BigIntegerToBigDecimalConverterTest.java | 5 +++-- .../org/scijava/convert/ByteToBigDecimalConverterTest.java | 3 ++- .../org/scijava/convert/ByteToBigIntegerConverterTest.java | 3 ++- .../org/scijava/convert/DoubleToBigDecimalConverterTest.java | 3 ++- .../org/scijava/convert/FloatToBigDecimalConverterTest.java | 3 ++- .../scijava/convert/IntegerToBigDecimalConverterTest.java | 3 ++- .../scijava/convert/IntegerToBigIntegerConverterTest.java | 3 ++- .../org/scijava/convert/LongToBigDecimalConverterTest.java | 3 ++- .../org/scijava/convert/LongToBigIntegerConverterTest.java | 3 ++- .../org/scijava/convert/ShortToBigDecimalConverterTest.java | 3 ++- .../org/scijava/convert/ShortToBigIntegerConverterTest.java | 3 ++- 11 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java index 29205a905..8775bcf74 100644 --- a/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java @@ -35,6 +35,7 @@ import java.math.BigInteger; import org.scijava.convert.NumberConverters.BigIntegerToBigDecimalConverter; +import org.scijava.util.NumberUtils; /** * Tests {@link BigIntegerToBigDecimalConverter}. @@ -47,7 +48,7 @@ public class BigIntegerToBigDecimalConverterTest extends @Override public BigInteger getSrc() { - return BigInteger.valueOf(7l); + return NumberUtils.asBigInteger(7l); } @Override @@ -57,7 +58,7 @@ public BigInteger getSrc() { @Override public BigDecimal getExpectedValue() { - return new BigDecimal(7d); + return NumberUtils.asBigDecimal(7d); } @Override diff --git a/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java index 7ca8a2e19..137857f2b 100644 --- a/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java @@ -34,6 +34,7 @@ import java.math.BigDecimal; import org.scijava.convert.NumberConverters.ByteToBigDecimalConverter; +import org.scijava.util.NumberUtils; /** * Tests {@link ByteToBigDecimalConverter}. @@ -55,7 +56,7 @@ public Byte getSrc() { @Override public BigDecimal getExpectedValue() { - return new BigDecimal(7d); + return NumberUtils.asBigDecimal(7d); } @Override diff --git a/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java index 871c66956..b36aa1dd7 100644 --- a/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java @@ -34,6 +34,7 @@ import java.math.BigInteger; import org.scijava.convert.NumberConverters.ByteToBigIntegerConverter; +import org.scijava.util.NumberUtils; /** * Tests {@link ByteToBigIntegerConverter}. @@ -55,7 +56,7 @@ public Byte getSrc() { @Override public BigInteger getExpectedValue() { - return BigInteger.valueOf(7l); + return NumberUtils.asBigInteger(7l); } @Override diff --git a/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java index 7c444cbde..4172e42a8 100644 --- a/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java @@ -34,6 +34,7 @@ import java.math.BigDecimal; import org.scijava.convert.NumberConverters.DoubleToBigDecimalConverter; +import org.scijava.util.NumberUtils; /** * Tests {@link DoubleToBigDecimalConverter}. @@ -56,7 +57,7 @@ public Double getSrc() { @Override public BigDecimal getExpectedValue() { - return new BigDecimal(7d); + return NumberUtils.asBigDecimal(7d); } @Override diff --git a/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java index e30e1c8f8..8db1d49a4 100644 --- a/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java @@ -34,6 +34,7 @@ import java.math.BigDecimal; import org.scijava.convert.NumberConverters.FloatToBigDecimalConverter; +import org.scijava.util.NumberUtils; /** * Tests {@link FloatToBigDecimalConverter}. @@ -56,7 +57,7 @@ public Float getSrc() { @Override public BigDecimal getExpectedValue() { - return new BigDecimal(7d); + return NumberUtils.asBigDecimal(7d); } @Override diff --git a/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java index d4c41e516..6fd1f64ff 100644 --- a/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java @@ -34,6 +34,7 @@ import java.math.BigDecimal; import org.scijava.convert.NumberConverters.IntegerToBigDecimalConverter; +import org.scijava.util.NumberUtils; /** * Tests {@link IntegerToBigDecimalConverter}. @@ -56,7 +57,7 @@ public Integer getSrc() { @Override public BigDecimal getExpectedValue() { - return new BigDecimal(7d); + return NumberUtils.asBigDecimal(7d); } @Override diff --git a/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java index f6762db3a..21276deac 100644 --- a/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java @@ -34,6 +34,7 @@ import java.math.BigInteger; import org.scijava.convert.NumberConverters.IntegerToBigIntegerConverter; +import org.scijava.util.NumberUtils; /** * Tests {@link IntegerToBigIntegerConverter}. @@ -56,7 +57,7 @@ public Integer getSrc() { @Override public BigInteger getExpectedValue() { - return BigInteger.valueOf(7l); + return NumberUtils.asBigInteger(7l); } @Override diff --git a/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java index 83be6b66e..e28ea2cb1 100644 --- a/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java @@ -34,6 +34,7 @@ import java.math.BigDecimal; import org.scijava.convert.NumberConverters.LongToBigDecimalConverter; +import org.scijava.util.NumberUtils; /** * Tests {@link LongToBigDecimalConverter}. @@ -55,7 +56,7 @@ public Long getSrc() { @Override public BigDecimal getExpectedValue() { - return new BigDecimal(7d); + return NumberUtils.asBigDecimal(7d); } @Override diff --git a/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java index 678d6770f..632f5deaa 100644 --- a/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java @@ -34,6 +34,7 @@ import java.math.BigInteger; import org.scijava.convert.NumberConverters.LongToBigIntegerConverter; +import org.scijava.util.NumberUtils; /** * Tests {@link LongToBigIntegerConverter}. @@ -55,7 +56,7 @@ public Long getSrc() { @Override public BigInteger getExpectedValue() { - return BigInteger.valueOf(7l); + return NumberUtils.asBigInteger(7l); } @Override diff --git a/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java index 851968907..4d1c6caa2 100644 --- a/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java @@ -34,6 +34,7 @@ import java.math.BigDecimal; import org.scijava.convert.NumberConverters.ShortToBigDecimalConverter; +import org.scijava.util.NumberUtils; /** * Tests {@link ShortToBigDecimalConverter}. @@ -56,7 +57,7 @@ public Short getSrc() { @Override public BigDecimal getExpectedValue() { - return new BigDecimal(7d); + return NumberUtils.asBigDecimal(7d); } @Override diff --git a/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java index f6e9e37a3..c920e5d51 100644 --- a/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java @@ -34,6 +34,7 @@ import java.math.BigInteger; import org.scijava.convert.NumberConverters.ShortToBigIntegerConverter; +import org.scijava.util.NumberUtils; /** * Tests {@link ShortToBigIntegerConverter}. @@ -56,7 +57,7 @@ public Short getSrc() { @Override public BigInteger getExpectedValue() { - return BigInteger.valueOf(7l); + return NumberUtils.asBigInteger(7l); } @Override From a95d8260a315dda5e6af73d754fd7a05a28d3981 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Thu, 20 Aug 2015 13:55:27 -0500 Subject: [PATCH 0122/1208] Converters: never pass primitives In the AbstractConverter we should ensure that nonprimitive types are always returned for input/output classes. --- src/main/java/org/scijava/convert/AbstractConverter.java | 6 ++++-- src/test/java/org/scijava/convert/ConvertServiceTest.java | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/convert/AbstractConverter.java b/src/main/java/org/scijava/convert/AbstractConverter.java index 058624d94..00a827aa1 100644 --- a/src/main/java/org/scijava/convert/AbstractConverter.java +++ b/src/main/java/org/scijava/convert/AbstractConverter.java @@ -108,8 +108,10 @@ public boolean canConvert(final Object src, final Class dest) { @Override public boolean canConvert(final Class src, final Class dest) { if (src == null) return false; - return ConversionUtils.canCast(src, getInputType()) && - ConversionUtils.canCast(getOutputType(), dest); + final Class saneSrc = ConversionUtils.getNonprimitiveType(src); + final Class saneDest = ConversionUtils.getNonprimitiveType(dest); + return ConversionUtils.canCast(saneSrc, getInputType()) && + ConversionUtils.canCast(getOutputType(), saneDest); } @Override diff --git a/src/test/java/org/scijava/convert/ConvertServiceTest.java b/src/test/java/org/scijava/convert/ConvertServiceTest.java index 18a3deed9..b2d5fd7fd 100644 --- a/src/test/java/org/scijava/convert/ConvertServiceTest.java +++ b/src/test/java/org/scijava/convert/ConvertServiceTest.java @@ -188,9 +188,9 @@ public void testCanConvert() { assertTrue(convertService.supports(double.class, float.class)); assertTrue(convertService.supports(float.class, double.class)); - // boxing is not reported to work - // TODO: Consider changing this behavior. - assertFalse(convertService.supports(int.class, Number.class)); + // check that boxing works + assertTrue(convertService.supports(int.class, Number.class)); + assertTrue(convertService.supports(Integer.class, double.class)); // can convert anything to string assertTrue(convertService.supports(Object.class, String.class)); From aee1dbcbf46ef0f5a3ad966265d939e1d4f00643 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 22 Feb 2016 14:20:34 -0600 Subject: [PATCH 0123/1208] CastingConverter: fix line breaks of big comment --- .../org/scijava/convert/CastingConverter.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/scijava/convert/CastingConverter.java b/src/main/java/org/scijava/convert/CastingConverter.java index 00ebb1f0b..cdcd86234 100644 --- a/src/main/java/org/scijava/convert/CastingConverter.java +++ b/src/main/java/org/scijava/convert/CastingConverter.java @@ -63,17 +63,14 @@ public boolean canConvert(final Class src, final Class dest) { @Override public T convert(final Object src, final Class dest) { // NB: Regardless of whether the destination type is an array or - // collection, - // we still want to cast directly if doing so is possible. But note that - // in - // general, this check does not detect cases of incompatible generic - // parameter types. If this limitation becomes a problem in the future - // we - // can extend the logic here to provide additional signatures of canCast - // which operate on Types in general rather than only Classes. However, - // the - // logic could become complex very quickly in various subclassing cases, - // generic parameters resolved vs. propagated, etc. + // collection, we still want to cast directly if doing so is possible. + // But note that in general, this check does not detect cases of + // incompatible generic parameter types. If this limitation becomes a + // problem in the future we can extend the logic here to provide + // additional signatures of canCast which operate on Types in general + // rather than only Classes. However, the logic could become complex + // very quickly in various subclassing cases, generic parameters + // resolved vs. propagated, etc. final Class c = GenericUtils.getClass(dest); return (T) ConversionUtils.cast(src, c); } From 839d3edbc36d4e7e13071bb724917669ab449bbc Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 22 Feb 2016 14:20:49 -0600 Subject: [PATCH 0124/1208] CastingConverter: fix priority Writing "FIRST_PRIORITY - 1" is the same as "FIRST_PRIORITY", since that constant equals Double.POSITIVE_INFINITY. --- src/main/java/org/scijava/convert/CastingConverter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/convert/CastingConverter.java b/src/main/java/org/scijava/convert/CastingConverter.java index cdcd86234..395a06435 100644 --- a/src/main/java/org/scijava/convert/CastingConverter.java +++ b/src/main/java/org/scijava/convert/CastingConverter.java @@ -41,7 +41,7 @@ * * @author Mark Hiner hinerm at gmail.com */ -@Plugin(type = Converter.class, priority = Priority.FIRST_PRIORITY - 1) +@Plugin(type = Converter.class, priority = Priority.FIRST_PRIORITY) public class CastingConverter extends AbstractConverter { @SuppressWarnings("deprecation") From 955b22c7bf3835aaf92e3560ee20ecf3fb4b8953 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Mon, 22 Feb 2016 14:21:08 -0600 Subject: [PATCH 0125/1208] ConvertService: Restore LinkedHashSet use Fix breaking in unit test --- src/main/java/org/scijava/convert/AbstractConvertService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/convert/AbstractConvertService.java b/src/main/java/org/scijava/convert/AbstractConvertService.java index 3db4ba433..a0b46cd94 100644 --- a/src/main/java/org/scijava/convert/AbstractConvertService.java +++ b/src/main/java/org/scijava/convert/AbstractConvertService.java @@ -34,6 +34,7 @@ import java.lang.reflect.Type; import java.util.Collection; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import org.scijava.plugin.AbstractHandlerService; @@ -102,7 +103,7 @@ public boolean supports(final Class src, final Type dest) { @Override public Collection getCompatibleInputs(final Class dest) { - final Set objects = new HashSet(); + final Set objects = new LinkedHashSet(); for (final Converter c : getInstances()) { if (dest.isAssignableFrom(c.getOutputType())) { From 0fd01f6b5246821e8636715b0cacfc2d9bed7ec5 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 25 Jun 2014 15:18:21 -0500 Subject: [PATCH 0126/1208] Add API to give explicit file chooser title The method UserInterface#chooseFile(String, File, String) is given a deprecated default implementation in AbstractUserInterface to avoid requiring a major version bump according to SemVer. --- .../org/scijava/ui/AbstractUserInterface.java | 23 +++++++++++++++++++ .../java/org/scijava/ui/DefaultUIService.java | 9 ++++++++ src/main/java/org/scijava/ui/UIService.java | 17 ++++++++++++++ .../java/org/scijava/ui/UserInterface.java | 14 +++++++++++ 4 files changed, 63 insertions(+) diff --git a/src/main/java/org/scijava/ui/AbstractUserInterface.java b/src/main/java/org/scijava/ui/AbstractUserInterface.java index 8234027ea..22a318808 100644 --- a/src/main/java/org/scijava/ui/AbstractUserInterface.java +++ b/src/main/java/org/scijava/ui/AbstractUserInterface.java @@ -31,6 +31,7 @@ package org.scijava.ui; +import java.io.File; import java.util.List; import org.scijava.app.StatusService; @@ -47,6 +48,7 @@ import org.scijava.ui.console.ConsolePane; import org.scijava.ui.viewer.DisplayViewer; import org.scijava.ui.viewer.DisplayWindow; +import org.scijava.widget.FileWidget; /** * Abstract superclass for {@link UserInterface} implementations. @@ -186,6 +188,19 @@ public ConsolePane getConsolePane() { return null; } + @Override + public File chooseFile(final File file, final String style) { + return chooseFile(fileChooserTitle(style), file, style); + } + + @Deprecated + @Override + public File chooseFile(final String title, final File file, + final String style) + { + throw new UnsupportedOperationException("No default implementation."); + } + @Override public void saveLocation() { final ApplicationFrame appFrame = getApplicationFrame(); @@ -216,4 +231,12 @@ protected void createUI() { restoreLocation(); } + /** Gets a default file chooser title to use when none is given. */ + protected String fileChooserTitle(final String style) { + if (style.equals(FileWidget.DIRECTORY_STYLE)) return "Choose a directory"; + if (style.equals(FileWidget.OPEN_STYLE)) return "Open"; + if (style.equals(FileWidget.SAVE_STYLE)) return "Save"; + return "Choose a file"; + } + } diff --git a/src/main/java/org/scijava/ui/DefaultUIService.java b/src/main/java/org/scijava/ui/DefaultUIService.java index ebaaf00cd..61f7644e3 100644 --- a/src/main/java/org/scijava/ui/DefaultUIService.java +++ b/src/main/java/org/scijava/ui/DefaultUIService.java @@ -340,6 +340,15 @@ public File chooseFile(final File file, final String style) { return ui.chooseFile(file, style); } + @Override + public File + chooseFile(final String title, final File file, final String style) + { + final UserInterface ui = getDefaultUI(); + if (ui == null) return null; + return ui.chooseFile(title, file, style); + } + @Override public void showContextMenu(final String menuRoot, final Display display, final int x, final int y) diff --git a/src/main/java/org/scijava/ui/UIService.java b/src/main/java/org/scijava/ui/UIService.java index 1fe2bbd79..787da5810 100644 --- a/src/main/java/org/scijava/ui/UIService.java +++ b/src/main/java/org/scijava/ui/UIService.java @@ -276,6 +276,23 @@ DialogPrompt.Result showDialog(String message, String title, */ File chooseFile(File file, String style); + /** + * Prompts the user to choose a file. + *

    + * The prompt is displayed in the default user interface. + *

    + * + * @param title Title to use in the file chooser dialog. + * @param file The initial value displayed in the file chooser prompt. + * @param style The style of chooser to use: + *
      + *
    • {@link FileWidget#OPEN_STYLE}
    • + *
    • {@link FileWidget#SAVE_STYLE}
    • + *
    • {@link FileWidget#DIRECTORY_STYLE}
    • + *
    + */ + File chooseFile(String title, File file, String style); + /** * Displays a popup context menu for the given display at the specified * position. diff --git a/src/main/java/org/scijava/ui/UserInterface.java b/src/main/java/org/scijava/ui/UserInterface.java index 32a97c6d6..7eadc1cb2 100644 --- a/src/main/java/org/scijava/ui/UserInterface.java +++ b/src/main/java/org/scijava/ui/UserInterface.java @@ -133,6 +133,20 @@ DialogPrompt dialogPrompt(String message, String title, */ File chooseFile(File file, String style); + /** + * Prompts the user to choose a file. + * + * @param title Title to use in the file chooser dialog. + * @param file The initial value displayed in the file chooser prompt. + * @param style The style of chooser to use: + *
      + *
    • {@link FileWidget#OPEN_STYLE}
    • + *
    • {@link FileWidget#SAVE_STYLE}
    • + *
    • {@link FileWidget#DIRECTORY_STYLE}
    • + *
    + */ + File chooseFile(String title, File file, String style); + /** * Displays a popup context menu for the given display at the specified * position. From 8a654598ef252186417751ed137fe5b1ce3b5355 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 23 Feb 2016 11:05:31 -0600 Subject: [PATCH 0127/1208] CommandModule: fix horrible bug in cancelation If your Command implemented Cancelable, then calling cancel(...) from within the command itself (e.g., from an initializer callback) did not actually cancel anything, because the wrapping CommandModule instance did not recognize the cancelation state of its wrapped Command. Now, the CommandModule always leans on its wrapped Command for all cancelation-related operations, unless the Command itself does not implement Cancelable. Noticed by Richard Domander. Thanks to Mark Hiner for help debugging. --- .../java/org/scijava/command/CommandModule.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/command/CommandModule.java b/src/main/java/org/scijava/command/CommandModule.java index d392b6c58..793fde188 100644 --- a/src/main/java/org/scijava/command/CommandModule.java +++ b/src/main/java/org/scijava/command/CommandModule.java @@ -86,7 +86,11 @@ public class CommandModule extends AbstractModule implements Cancelable, @Parameter private Context context; - /** Reason for cancelation, or null if not canceled. */ + /** + * Reason for cancelation, or null if not canceled. Note that this field is + * only relevant if the delegate {@link Command} is not itself + * {@link Cancelable}. + */ private String cancelReason; /** Creates a command module for the given {@link PluginInfo}. */ @@ -205,20 +209,26 @@ public void run() { @Override public boolean isCanceled() { + if (command instanceof Cancelable) { + return ((Cancelable) command).isCanceled(); + } return cancelReason != null; } @Override public void cancel(final String reason) { - cancelReason = reason == null ? "" : reason; if (command instanceof Cancelable) { - // propagate cancelation to the command instance itself ((Cancelable) command).cancel(reason); + return; } + cancelReason = reason == null ? "" : reason; } @Override public String getCancelReason() { + if (command instanceof Cancelable) { + return ((Cancelable) command).getCancelReason(); + } return cancelReason; } From 6156f2221f1c0448376485e7f0937d2f41301866 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 23 Feb 2016 11:58:05 -0600 Subject: [PATCH 0128/1208] Add regression test for CommandModule cancelation This validates the bug-fix in 8a654598ef252186417751ed137fe5b1ce3b5355. --- .../scijava/command/CommandModuleTest.java | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 src/test/java/org/scijava/command/CommandModuleTest.java diff --git a/src/test/java/org/scijava/command/CommandModuleTest.java b/src/test/java/org/scijava/command/CommandModuleTest.java new file mode 100644 index 000000000..49d40bafc --- /dev/null +++ b/src/test/java/org/scijava/command/CommandModuleTest.java @@ -0,0 +1,114 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.command; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.concurrent.ExecutionException; + +import org.junit.Test; +import org.scijava.Cancelable; +import org.scijava.Context; +import org.scijava.module.Module; +import org.scijava.module.process.AbstractPreprocessorPlugin; +import org.scijava.module.process.PreprocessorPlugin; +import org.scijava.plugin.Plugin; + +/** Regression tests for {@link CommandModule}. */ +public class CommandModuleTest { + + @Test + public void testCancelable() throws InterruptedException, ExecutionException { + final Context context = new Context(CommandService.class); + final CommandService commandService = context.service(CommandService.class); + final CommandModule ice = commandService.run(IceCommand.class, true).get(); + final Cancelable c = (Cancelable) ice.getDelegateObject(); + assertTrue(ice.isCanceled()); + assertTrue(c.isCanceled()); + assertEquals("Stop! Collaborate and listen!", ice.getCancelReason()); + assertEquals("Stop! Collaborate and listen!", c.getCancelReason()); + } + + @Test + public void testNotCancelable() throws InterruptedException, + ExecutionException + { + final Context context = new Context(CommandService.class); + final CommandService commandService = context.service(CommandService.class); + final CommandModule fire = commandService.run(FireCommand.class, true).get(); + assertFalse(fire.getDelegateObject() instanceof Cancelable); + assertTrue(fire.isCanceled()); + assertEquals("NO SINGING!", fire.getCancelReason()); + } + + // -- Helper classes -- + + /** A command which implements {@link Cancelable}. */ + @Plugin(type = Command.class, initializer = "init") + public static class IceCommand extends ContextCommand { + + public void init() { + cancel("Stop! Collaborate and listen!"); + } + + @Override + public void run() { + throw new IllegalStateException("Unexpected"); + } + } + + /** A command which does not implement {@link Cancelable}. */ + @Plugin(type = Command.class) + public static class FireCommand implements Command { + + @Override + public void run() { + throw new IllegalStateException("Unexpected"); + } + } + + @Plugin(type = PreprocessorPlugin.class) + public static class CommandCanceler extends AbstractPreprocessorPlugin { + + @Override + public void process(final Module module) { + final Object command = module.getDelegateObject(); + if (command instanceof IceCommand || command instanceof FireCommand) { + // NB: A Monty Python quote which is also a Game of Thrones reference. + // That's right -- we did that. + cancel("NO SINGING!"); + } + } + } +} From b5b50a407b919da20c9e5249e610d246464183f5 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Tue, 23 Feb 2016 14:01:08 -0600 Subject: [PATCH 0129/1208] Bump parent to pom-scijava 9.4.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fedd6a8ed..467dba4c9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.scijava pom-scijava - 9.3.0 + 9.4.0 From 5d9e1bb1e54448940c3026cb26a61798ffc85618 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Tue, 23 Feb 2016 14:16:55 -0600 Subject: [PATCH 0130/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 467dba4c9..bdf34da26 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.51.0-SNAPSHOT + 2.51.1-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From 1a90a15edeb2c7b46e952787cfe5b82d1fd36005 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 23 Feb 2016 15:35:46 -0600 Subject: [PATCH 0131/1208] POM: bump minor version, due to new ScriptREPL API --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bdf34da26..8ac75c7c0 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.51.1-SNAPSHOT + 2.52.0-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From e558c7270c9411acd83c6ef81fb6f05eaeb74cd4 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 24 Feb 2016 08:36:35 -0600 Subject: [PATCH 0132/1208] Bump parent to pom-scijava 9.5.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8ac75c7c0..56d4c73fc 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.scijava pom-scijava - 9.4.0 + 9.5.0 From 837b9de89d52deafc8918e9f0cd80438b49a97bc Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 24 Feb 2016 08:46:26 -0600 Subject: [PATCH 0133/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 56d4c73fc..1c5d63071 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.52.0-SNAPSHOT + 2.52.1-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From 1278e71533982a80f68a3c81248b36e6ef3573d1 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 24 Feb 2016 13:06:15 -0600 Subject: [PATCH 0134/1208] ClassUtils: use consistent method argument name The other loadClass uses "String name" rather than "className" so let's do the same here. --- src/main/java/org/scijava/util/ClassUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/util/ClassUtils.java b/src/main/java/org/scijava/util/ClassUtils.java index bf7f4141d..8065f4f5d 100644 --- a/src/main/java/org/scijava/util/ClassUtils.java +++ b/src/main/java/org/scijava/util/ClassUtils.java @@ -96,8 +96,8 @@ private ClassUtils() { * @return The loaded class, or null if the class could not be loaded. * @see #loadClass(String, ClassLoader) */ - public static Class loadClass(final String className) { - return loadClass(className, null); + public static Class loadClass(final String name) { + return loadClass(name, null); } /** From 684697ecb55742f349abc375aea4ed74910d8562 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 24 Feb 2016 13:07:51 -0600 Subject: [PATCH 0135/1208] ClassUtils: add missing @param field to javadoc --- src/main/java/org/scijava/util/ClassUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/scijava/util/ClassUtils.java b/src/main/java/org/scijava/util/ClassUtils.java index 8065f4f5d..7976ce750 100644 --- a/src/main/java/org/scijava/util/ClassUtils.java +++ b/src/main/java/org/scijava/util/ClassUtils.java @@ -93,6 +93,7 @@ private ClassUtils() { * Loads the class with the given name, using the current thread's context * class loader, or null if it cannot be loaded. * + * @param name The name of the class to load. * @return The loaded class, or null if the class could not be loaded. * @see #loadClass(String, ClassLoader) */ From 7f2683595d71e0c4c81f4105abd5496dba4efc8d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 24 Feb 2016 13:23:44 -0600 Subject: [PATCH 0136/1208] ClassUtils: throw exceptions in loadClass methods We keep the old behavior of returning null, both for convenience and for backwards compatibility. But we add a "boolean quietly" flag which, when set to false, makes the methods throw IllegalArgumentException instead. This avoids problems where downstream code needs to know _why_ a class couldn't be loaded, but the exception was eaten in the loadClass method. --- .../java/org/scijava/util/ClassUtils.java | 53 +++++++++++++++++-- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/util/ClassUtils.java b/src/main/java/org/scijava/util/ClassUtils.java index 7976ce750..2ef416612 100644 --- a/src/main/java/org/scijava/util/ClassUtils.java +++ b/src/main/java/org/scijava/util/ClassUtils.java @@ -95,10 +95,46 @@ private ClassUtils() { * * @param name The name of the class to load. * @return The loaded class, or null if the class could not be loaded. - * @see #loadClass(String, ClassLoader) + * @see #loadClass(String, ClassLoader, boolean) */ public static Class loadClass(final String name) { - return loadClass(name, null); + return loadClass(name, null, true); + } + + /** + * Loads the class with the given name, using the specified + * {@link ClassLoader}, or null if it cannot be loaded. + * + * @param name The name of the class to load. + * @param classLoader The class loader with which to load the class; if null, + * the current thread's context class loader will be used. + * @return The loaded class, or null if the class could not be loaded. + * @see #loadClass(String, ClassLoader, boolean) + */ + public static Class loadClass(final String name, + final ClassLoader classLoader) + { + return loadClass(name, classLoader, true); + } + + /** + * Loads the class with the given name, using the current thread's context + * class loader. + * + * @param className the name of the class to load + * @param quietly Whether to return {@code null} (rather than throwing + * {@link IllegalArgumentException}) if something goes wrong loading + * the class + * @return The loaded class, or {@code null} if the class could not be loaded + * and the {@code quietly} flag is set. + * @see #loadClass(String, ClassLoader, boolean) + * @throws IllegalArgumentException If the class cannot be loaded and the + * {@code quietly} flag is not set. + */ + public static Class loadClass(final String className, + final boolean quietly) + { + return loadClass(className, null, quietly); } /** @@ -120,10 +156,16 @@ public static Class loadClass(final String name) { * @param name The name of the class to load. * @param classLoader The class loader with which to load the class; if null, * the current thread's context class loader will be used. - * @return The loaded class, or null if the class could not be loaded. + * @param quietly Whether to return {@code null} (rather than throwing + * {@link IllegalArgumentException}) if something goes wrong loading + * the class + * @return The loaded class, or {@code null} if the class could not be loaded + * and the {@code quietly} flag is set. + * @throws IllegalArgumentException If the class cannot be loaded and the + * {@code quietly} flag is not set. */ public static Class loadClass(final String name, - final ClassLoader classLoader) + final ClassLoader classLoader, final boolean quietly) { // handle primitive types if (name.equals("Z") || name.equals("boolean")) return boolean.class; @@ -171,7 +213,8 @@ public static Class loadClass(final String name, // Not ClassNotFoundException. // Not NoClassDefFoundError. // Not UnsupportedClassVersionError! - return null; + if (quietly) return null; + throw new IllegalArgumentException("Cannot load class: " + className, t); } } From 6bff68c00c940c2d070e57334f5d578e960c5a65 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 24 Feb 2016 13:56:13 -0600 Subject: [PATCH 0137/1208] ClassUtilsTest: test the failure cases --- src/test/java/org/scijava/util/ClassUtilsTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/org/scijava/util/ClassUtilsTest.java b/src/test/java/org/scijava/util/ClassUtilsTest.java index 561e5d6c5..a32dffe57 100644 --- a/src/test/java/org/scijava/util/ClassUtilsTest.java +++ b/src/test/java/org/scijava/util/ClassUtilsTest.java @@ -116,6 +116,16 @@ public void testLoadClass() { assertLoaded(Number[][].class, "[[Ljava.lang.Number;"); } + @Test + public void testFailureQuiet() { + assertNull(ClassUtils.loadClass("a.non.existent.class")); + } + + @Test(expected = IllegalArgumentException.class) + public void testFailureLoud() { + ClassUtils.loadClass("a.non.existent.class", false); + } + @Test public void testGetArrayClass() { assertSame(boolean[].class, ClassUtils.getArrayClass(boolean.class)); From 7f9576d5912bad2c8deb3474608cca9ff744e9f1 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 24 Feb 2016 14:06:59 -0600 Subject: [PATCH 0138/1208] When class loading fails, chain the reason Several places in SciJava Common call the ClassUtils.loadClass routine. Previously, that routine simply returned null without explanation when the class could not be loaded for any reason. Now, by setting the 'quietly' flag to false, we can do proper exception handling so that the reason for failure is known and can be passed along to the caller. So this commit does that in all the places where it makes sense. This commit is dedicated to Eike Heinz! --- src/main/java/org/scijava/Context.java | 5 +---- .../org/scijava/main/DefaultMainService.java | 5 ++++- .../java/org/scijava/menu/ShadowMenu.java | 19 +++++++++++++------ .../java/org/scijava/plugin/PluginInfo.java | 14 ++++++++------ .../scijava/script/DefaultScriptService.java | 11 +++++++---- 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/scijava/Context.java b/src/main/java/org/scijava/Context.java index b5693b86e..1ec38127f 100644 --- a/src/main/java/org/scijava/Context.java +++ b/src/main/java/org/scijava/Context.java @@ -320,10 +320,7 @@ public S service(final Class c) { * service. */ public Service service(final String className) { - final Class c = ClassUtils.loadClass(className); - if (c == null) { - throw new IllegalArgumentException("No such class: " + className); - } + final Class c = ClassUtils.loadClass(className, false); if (!Service.class.isAssignableFrom(c)) { throw new IllegalArgumentException("Not a service class: " + c.getName()); } diff --git a/src/main/java/org/scijava/main/DefaultMainService.java b/src/main/java/org/scijava/main/DefaultMainService.java index 31de081fd..725eaaa09 100644 --- a/src/main/java/org/scijava/main/DefaultMainService.java +++ b/src/main/java/org/scijava/main/DefaultMainService.java @@ -101,10 +101,13 @@ public String[] args() { @Override public void exec() { try { - final Class mainClass = ClassUtils.loadClass(className); + final Class mainClass = ClassUtils.loadClass(className, false); final Method main = mainClass.getMethod("main", String[].class); main.invoke(null, new Object[] { args }); } + catch (final IllegalArgumentException exc) { + if (log != null) log.error(exc); + } catch (final NoSuchMethodException exc) { if (log != null) { log.error("No main method for class: " + className, exc); diff --git a/src/main/java/org/scijava/menu/ShadowMenu.java b/src/main/java/org/scijava/menu/ShadowMenu.java index a2c87b573..ec9b90b28 100644 --- a/src/main/java/org/scijava/menu/ShadowMenu.java +++ b/src/main/java/org/scijava/menu/ShadowMenu.java @@ -231,13 +231,20 @@ public URL getIconURL() { else return null; } final String className = moduleInfo.getDelegateClassName(); - final Class c = ClassUtils.loadClass(className); - if (c == null) return null; - final URL iconURL = c.getResource(iconPath); - if (iconURL == null) { - if (log != null) log.error("Could not load icon: " + iconPath); + try { + final Class c = ClassUtils.loadClass(className, false); + final URL iconURL = c.getResource(iconPath); + if (iconURL == null) { + if (log != null) log.error("Could not load icon: " + iconPath); + } + return iconURL; + } + catch (final IllegalArgumentException exc) { + final String message = "Could not load icon for class: " + className; + if (log.isDebug()) log.debug(message, exc); + else log.error(message); + return null; } - return iconURL; } /** diff --git a/src/main/java/org/scijava/plugin/PluginInfo.java b/src/main/java/org/scijava/plugin/PluginInfo.java index b60843f9b..a5d4efa01 100644 --- a/src/main/java/org/scijava/plugin/PluginInfo.java +++ b/src/main/java/org/scijava/plugin/PluginInfo.java @@ -280,13 +280,15 @@ public String getClassName() { @Override public Class loadClass() throws InstantiableException { if (pluginClass == null) { - final Class c = ClassUtils.loadClass(className, classLoader); - if (c == null) { - throw new InstantiableException("Class not found: " + className); + try { + final Class c = ClassUtils.loadClass(className, classLoader, false); + @SuppressWarnings("unchecked") + final Class typedClass = (Class) c; + pluginClass = typedClass; + } + catch (final IllegalArgumentException exc) { + throw new InstantiableException("Class not found: " + className, exc); } - @SuppressWarnings("unchecked") - final Class typedClass = (Class) c; - pluginClass = typedClass; } return pluginClass; diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index 7bc916f1f..e04efee2d 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -255,13 +255,16 @@ public synchronized Class lookupClass(final String alias) final Class type = aliasMap().get(alias); if (type != null) return type; - final Class c = ClassUtils.loadClass(alias); - if (c != null) { + try { + final Class c = ClassUtils.loadClass(alias, false); aliasMap().put(alias, c); return c; } - - throw new ScriptException("Unknown type: " + alias); + catch (final IllegalArgumentException exc) { + final ScriptException se = new ScriptException("Unknown type: " + alias); + se.initCause(exc); + throw se; + } } // -- PTService methods -- From 1ddc51edebcf6c6af3bec505a13a649dccf1ae41 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 24 Feb 2016 14:36:54 -0600 Subject: [PATCH 0139/1208] Revert "Add empty option for not-required parameter in Widget" This reverts commit 45ab6cf22dc3c33400bc40a17885e968f4eaa8ad. This will require a revision of how the ObjectPool is handled in widgets, as it currently breaks the javadoc contract (in that if a null value is added to the ObjectPool, the item value is forced to be null). --- src/main/java/org/scijava/widget/DefaultWidgetModel.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/widget/DefaultWidgetModel.java b/src/main/java/org/scijava/widget/DefaultWidgetModel.java index 3e02f907a..4f5052fb1 100644 --- a/src/main/java/org/scijava/widget/DefaultWidgetModel.java +++ b/src/main/java/org/scijava/widget/DefaultWidgetModel.java @@ -87,8 +87,6 @@ public DefaultWidgetModel(final Context context, final InputPanel inputPan this.module = module; this.item = item; this.objectPool = objectPool; - if (!item.isRequired()) - this.objectPool.add(0, null); convertedObjects = new WeakHashMap(); if (item.getValue(module) == null) { @@ -317,10 +315,8 @@ private Object ensureValidObject(final Object value) { /** Ensures the value is on the given list. */ private Object ensureValid(final Object value, final List list) { - if (value == null) - return list.contains(null); for (final Object o : list) { - if (value.equals(o)) return value; // value is valid + if (o.equals(value)) return value; // value is valid // check if value was converted and cached final Object convertedValue = convertedObjects.get(o); if (convertedValue != null && value.equals(convertedValue)) { From 1171f79f46b3427a336da1f6326100c8bd4e86f9 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 24 Feb 2016 14:48:38 -0600 Subject: [PATCH 0140/1208] Bump parent to pom-scijava 9.5.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1c5d63071..406cdba6e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.scijava pom-scijava - 9.5.0 + 9.5.1 From f6732d9296c2e8d6b4d1c9f4010377401ca674fd Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 24 Feb 2016 15:07:43 -0600 Subject: [PATCH 0141/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 406cdba6e..da14e21bc 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.52.1-SNAPSHOT + 2.52.2-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From 3d73fce0cd3d891f7f01cfceb08bce7a7a4d783c Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Fri, 26 Feb 2016 10:28:38 -0600 Subject: [PATCH 0142/1208] ConsoleArguments: rename aliases to flags "Alias" would imply that there is one canonical way to invoke a given ConsoleArgument. --- .../console/AbstractConsoleArgument.java | 26 ++++++++++--------- .../scijava/main/console/MainArgument.java | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/scijava/console/AbstractConsoleArgument.java b/src/main/java/org/scijava/console/AbstractConsoleArgument.java index 0aa170e03..118a9dbe1 100644 --- a/src/main/java/org/scijava/console/AbstractConsoleArgument.java +++ b/src/main/java/org/scijava/console/AbstractConsoleArgument.java @@ -46,20 +46,20 @@ public abstract class AbstractConsoleArgument extends AbstractHandlerPlugin> implements ConsoleArgument { private int numArgs; - private Set aliasFlags; + private Set flags; public AbstractConsoleArgument() { this(1, new String[0]); } - public AbstractConsoleArgument(final String... aliases) { - this(1, aliases); + public AbstractConsoleArgument(final String... flags) { + this(1, flags); } - public AbstractConsoleArgument(final int requiredArgs, final String... aliases) { + public AbstractConsoleArgument(final int requiredArgs, final String... flags) { numArgs = requiredArgs; - aliasFlags = new HashSet(); - for (final String s : aliases) aliasFlags.add(s); + this.flags = new HashSet(); + for (final String s : flags) this.flags.add(s); } // -- Typed methods -- @@ -67,7 +67,7 @@ public AbstractConsoleArgument(final int requiredArgs, final String... aliases) @Override public boolean supports(final LinkedList args) { if (args == null || args.size() < numArgs) return false; - return isAlias(args); + return isFlag(args); } @Override @@ -77,11 +77,13 @@ public Class> getType() { } /** - * @return true if there are no aliases for this {@code ConsoleArgument}, or - * at least one alias matches the first argument in the provided - * list + * Check if the given list of arguments starts with a flag that matches this + * {@link ConsoleArgument}. + * + * @return true iff one of this argument's flags matches the first string in + * the given list, or this argument has no explicit flags. */ - protected boolean isAlias(final LinkedList args) { - return aliasFlags.isEmpty() || aliasFlags.contains(args.getFirst()); + protected boolean isFlag(final LinkedList args) { + return flags.isEmpty() || flags.contains(args.getFirst()); } } diff --git a/src/main/java/org/scijava/main/console/MainArgument.java b/src/main/java/org/scijava/main/console/MainArgument.java index 152182ae9..1311008a7 100644 --- a/src/main/java/org/scijava/main/console/MainArgument.java +++ b/src/main/java/org/scijava/main/console/MainArgument.java @@ -73,7 +73,7 @@ public void handle(final LinkedList args) { final String className = args.removeFirst(); final List argList = new ArrayList(); - while (!args.isEmpty() && !isAlias(args) && !isSeparator(args)) { + while (!args.isEmpty() && !isFlag(args) && !isSeparator(args)) { argList.add(args.removeFirst()); } if (isSeparator(args)) args.removeFirst(); // remove the -- separator From 8e1a5226c898197664d4753291d916598ce08e45 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Fri, 26 Feb 2016 10:39:10 -0600 Subject: [PATCH 0143/1208] Extract ConsoleUtils.hasParam method For checking if a non-flag argument is available --- .../org/scijava/command/console/RunArgument.java | 2 +- src/main/java/org/scijava/console/ConsoleUtils.java | 12 ++++++++++++ .../scijava/script/console/RunScriptArgument.java | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/command/console/RunArgument.java b/src/main/java/org/scijava/command/console/RunArgument.java index 6d44e8b88..59e283dba 100644 --- a/src/main/java/org/scijava/command/console/RunArgument.java +++ b/src/main/java/org/scijava/command/console/RunArgument.java @@ -74,7 +74,7 @@ public void handle(final LinkedList args) { args.removeFirst(); // --run final String commandToRun = args.removeFirst(); - final String paramString = args.isEmpty() ? "" : args.removeFirst(); + final String paramString = ConsoleUtils.hasParam(args) ? "" : args.removeFirst(); run(commandToRun, paramString); } diff --git a/src/main/java/org/scijava/console/ConsoleUtils.java b/src/main/java/org/scijava/console/ConsoleUtils.java index 3e1557fef..cb26cc550 100644 --- a/src/main/java/org/scijava/console/ConsoleUtils.java +++ b/src/main/java/org/scijava/console/ConsoleUtils.java @@ -32,6 +32,7 @@ import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedList; import java.util.Map; import org.scijava.command.CommandInfo; @@ -83,4 +84,15 @@ else if (logService != null) return inputMap; } + + /** + * Test if the next argument is an appropriate parameter to a + * {@link ConsoleArgument}. + * + * @return {@code true} if the first argument of the given list does not + * start with a {@code '-'} character. + */ + public static boolean hasParam(final LinkedList args) { + return !(args.isEmpty() || args.getFirst().startsWith("-")); + } } diff --git a/src/main/java/org/scijava/script/console/RunScriptArgument.java b/src/main/java/org/scijava/script/console/RunScriptArgument.java index 5b12156d3..b7b663968 100644 --- a/src/main/java/org/scijava/script/console/RunScriptArgument.java +++ b/src/main/java/org/scijava/script/console/RunScriptArgument.java @@ -72,7 +72,7 @@ public void handle(final LinkedList args) { args.removeFirst(); // --run final String scriptToRun = args.removeFirst(); - final String paramString = args.isEmpty() ? "" : args.removeFirst(); + final String paramString = ConsoleUtils.hasParam(args) ? "" : args.removeFirst(); run(scriptToRun, paramString); } From 6c1f4e971629e4687b72a6b86fef549995f1ed17 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Fri, 26 Feb 2016 10:46:42 -0600 Subject: [PATCH 0144/1208] ConsoleUtils: Document parseParameterString --- .../java/org/scijava/console/ConsoleUtils.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/org/scijava/console/ConsoleUtils.java b/src/main/java/org/scijava/console/ConsoleUtils.java index cb26cc550..72ccde7fa 100644 --- a/src/main/java/org/scijava/console/ConsoleUtils.java +++ b/src/main/java/org/scijava/console/ConsoleUtils.java @@ -47,18 +47,36 @@ */ public final class ConsoleUtils { + /** + * @see #parseParameterString(String, ModuleInfo, LogService) + */ public static Map parseParameterString(final String parameterString) { return parseParameterString(parameterString, (CommandInfo)null); } + /** + * @see #parseParameterString(String, ModuleInfo, LogService) + */ public static Map parseParameterString(final String parameterString, final ModuleInfo info) { return parseParameterString(parameterString, info, null); } + /** + * @see #parseParameterString(String, ModuleInfo, LogService) + */ public static Map parseParameterString(final String parameterString, final LogService logService) { return parseParameterString(parameterString, null, logService); } + /** + * Helper method for turning a parameter string into a {@code Map} of + * key:value pairs. If a {@link ModuleInfo} is provided, the parameter + * string is assumed to be a comma-separated list of values, ordered + * according to the {@code ModuleInfo's} inputs. Otherwise, the parameter + * string is assumed to be a comma-separated list of "key=value" pairs. + * + * TODO reconcile with attribute parsing of {@link ScriptInfo} + */ public static Map parseParameterString(final String parameterString, final ModuleInfo info, final LogService logService) { final Map inputMap = new HashMap(); From 6fa80b1c0ca0b3536644b8a57ec83a6e10e99568 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 26 Feb 2016 12:20:54 -0600 Subject: [PATCH 0145/1208] Gateway: add a handy launch(String...) method This performs launch operations standard to most SciJava applications. This code migrated from a static method of imagej/imagej: net.imagej.Main.launch(String...) With this change, the standard launch process is accessible to all SciJava applications in a DRY way, while still being configurable for applications with special needs. Typically, such applications will define their own Gateway implementation which extends AbstractGateway; hence, these applications can override launch(String...) to modify their launch behavior. We considered creating a LaunchService with LaunchAction plugins, but it seemed potentially overcomplicated. --- pom.xml | 2 +- src/main/java/org/scijava/AbstractGateway.java | 17 +++++++++++++++++ src/main/java/org/scijava/Gateway.java | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index da14e21bc..9ec636dcc 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.52.2-SNAPSHOT + 2.53.0-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. diff --git a/src/main/java/org/scijava/AbstractGateway.java b/src/main/java/org/scijava/AbstractGateway.java index d09dfd936..202cab0f1 100644 --- a/src/main/java/org/scijava/AbstractGateway.java +++ b/src/main/java/org/scijava/AbstractGateway.java @@ -89,6 +89,23 @@ public AbstractGateway(final String appName, final Context context) { // -- Gateway methods -- + @Override + public void launch(final String... args) { + // parse command line arguments + console().processArgs(args); + + // launch main methods + final int mainCount = main().execMains(); + + // display the user interface (NB: does not block) + if (mainCount == 0 && !ui().isHeadless()) ui().showUI(); + + if (ui().isHeadless()) { + // now that CLI processing/execution is done, we can shut down + getContext().dispose(); + } + } + @Override public String getShortName() { return getClass().getName().toLowerCase(); diff --git a/src/main/java/org/scijava/Gateway.java b/src/main/java/org/scijava/Gateway.java index 73df53a5a..6ef437ea5 100644 --- a/src/main/java/org/scijava/Gateway.java +++ b/src/main/java/org/scijava/Gateway.java @@ -120,6 +120,24 @@ */ public interface Gateway extends RichPlugin, Versioned { + /** + * Perform launch operations associated with this gateway. + *

    + * Typical operations might include: + *

    + *
      + *
    • Handle the given command line arguments using the + * {@link ConsoleService}.
    • + *
    • Execute registered main classes of the {@link MainService}.
    • + *
    • Display the default user interface using the {@link UIService}.
    • + *
    • In some circumstances (e.g., when running headless), dispose the + * context after launch operations are complete.
    • + *
    + * + * @param args The arguments to pass to the application. + */ + void launch(String... args); + /** * Gets a very succinct name for use referring to this gateway, e.g. as a * variable name for scripting. From b6e26190ea04f2d67e81671c1b0a9c31dc2de462 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Fri, 26 Feb 2016 15:10:41 -0600 Subject: [PATCH 0146/1208] DisplayPostprocessor: always name displays --- .../org/scijava/display/DisplayPostprocessor.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/display/DisplayPostprocessor.java b/src/main/java/org/scijava/display/DisplayPostprocessor.java index 092122db3..4d43d0aa5 100644 --- a/src/main/java/org/scijava/display/DisplayPostprocessor.java +++ b/src/main/java/org/scijava/display/DisplayPostprocessor.java @@ -36,6 +36,7 @@ import java.util.List; import java.util.Map; +import org.scijava.Named; import org.scijava.Priority; import org.scijava.log.LogService; import org.scijava.module.Module; @@ -113,13 +114,16 @@ private void handleOutput(final String defaultName, final Object output) { } else { // create a new display for the output - final Display display = displayService.createDisplay(output); + String name = null; + + // TODO rework how displays are named + if (output instanceof Named) name = ((Named)output).getName(); + + if (name == null) name = defaultName; + + final Display display = displayService.createDisplay(name, output); if (display != null) { displays.add(display); - if (display.getName() == null) { - // set a default name based on the parameter - display.setName(defaultName); - } } } } From 3c8cf8299347a6885a3cb19dce4ce66f64357940 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 26 Feb 2016 15:22:22 -0600 Subject: [PATCH 0147/1208] DisplayService: flesh out createDisplay javadoc It is important to note that calling createDisplay publishes a DisplayCreatedEvent, which triggers some actions in other services. --- .../org/scijava/display/DisplayService.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/display/DisplayService.java b/src/main/java/org/scijava/display/DisplayService.java index 98dd2b6da..80915dd74 100644 --- a/src/main/java/org/scijava/display/DisplayService.java +++ b/src/main/java/org/scijava/display/DisplayService.java @@ -33,6 +33,8 @@ import java.util.List; +import org.scijava.display.event.DisplayCreatedEvent; +import org.scijava.display.event.DisplayDeletedEvent; import org.scijava.event.EventService; import org.scijava.object.ObjectService; import org.scijava.plugin.PluginInfo; @@ -114,7 +116,13 @@
    > List> getDisplayPluginsOfType( boolean isUniqueName(String name); /** - * Creates a display for the given object. + * Creates a display for the given object, publishing a + * {@link DisplayCreatedEvent} to notify interested parties. In particular: + *
      + *
    • Visible UIs will respond to this event by showing the display.
    • + *
    • The {@link ObjectService} will add the new display to its index, until + * a corresponding {@link DisplayDeletedEvent} is later published.
    • + *
    * * @param o The object for which a display should be created. The object is * then added to the display. @@ -129,7 +137,13 @@
    > List> getDisplayPluginsOfType( Display createDisplay(Object o); /** - * Creates a display for the given object. + * Creates a display for the given object, publishing a + * {@link DisplayCreatedEvent} to notify interested parties. In particular: + *
      + *
    • Visible UIs will respond to this event by showing the display.
    • + *
    • The {@link ObjectService} will add the new display to its index, until + * a corresponding {@link DisplayDeletedEvent} is later published.
    • + *
    * * @param name The name to be assigned to the display. * @param o The object for which a display should be created. The object is From d9a68ec20ec37b68717297ba61a4db157d25e552 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 26 Feb 2016 15:22:56 -0600 Subject: [PATCH 0148/1208] DisplayService: add a createDisplayQuietly method This method creates a display without publishing a DisplayCreatedEvent. It is the caller's responsibility to deal with ramifications of that. This method is introduced to maintain backwards compatibility with the old behavior. The display framework will probably be substantially redesigned soon, at which point all of this will become moot. But in the meantime, it is handy to be able to create a display without showing it. This commit is dedicated to Richard Domander! --- .../display/DefaultDisplayService.java | 11 ++++++-- .../org/scijava/display/DisplayService.java | 25 +++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/display/DefaultDisplayService.java b/src/main/java/org/scijava/display/DefaultDisplayService.java index ec11b5c20..40f94b786 100644 --- a/src/main/java/org/scijava/display/DefaultDisplayService.java +++ b/src/main/java/org/scijava/display/DefaultDisplayService.java @@ -209,6 +209,15 @@ public Display createDisplay(final Object o) { @Override public Display createDisplay(final String name, final Object o) { + final Display display = createDisplayQuietly(o); + if (display == null) return null; + if (name != null) display.setName(name); + eventService.publish(new DisplayCreatedEvent(display)); + return display; + } + + @Override + public Display createDisplayQuietly(final Object o) { // get available display plugins from the plugin service final List>> displayPlugins = getDisplayPlugins(); @@ -219,8 +228,6 @@ public Display createDisplay(final String name, final Object o) { // TODO: how to handle multiple matches? prompt user with dialog box? if (display.canDisplay(o)) { display.display(o); - if (name != null) display.setName(name); - eventService.publish(new DisplayCreatedEvent(display)); return display; } } diff --git a/src/main/java/org/scijava/display/DisplayService.java b/src/main/java/org/scijava/display/DisplayService.java index 80915dd74..20f0d33e6 100644 --- a/src/main/java/org/scijava/display/DisplayService.java +++ b/src/main/java/org/scijava/display/DisplayService.java @@ -123,6 +123,10 @@
    > List> getDisplayPluginsOfType( *
  • The {@link ObjectService} will add the new display to its index, until * a corresponding {@link DisplayDeletedEvent} is later published.
  • * + *

    + * To create a {@link Display} without publishing an event, see + * {@link #createDisplayQuietly}. + *

    * * @param o The object for which a display should be created. The object is * then added to the display. @@ -144,6 +148,10 @@
    > List> getDisplayPluginsOfType( *
  • The {@link ObjectService} will add the new display to its index, until * a corresponding {@link DisplayDeletedEvent} is later published.
  • * + *

    + * To create a {@link Display} without publishing an event, see + * {@link #createDisplayQuietly}. + *

    * * @param name The name to be assigned to the display. * @param o The object for which a display should be created. The object is @@ -158,4 +166,21 @@
    > List> getDisplayPluginsOfType( */ Display createDisplay(String name, Object o); + /** + * Creates a display for the given object, without publishing a + * {@link DisplayCreatedEvent}. Hence, the display will not be automatically + * shown or tracked. + * + * @param o The object for which a display should be created. The object is + * then added to the display. + * @return Newly created {@code Display} containing the given object. The + * Display is typed with ? rather than T matching the Object because + * it is possible for the Display to be a collection of some other + * sort of object than the one being added. For example, ImageDisplay + * is a {@code Display} with the DataView wrapping a + * Dataset, yet the ImageDisplay supports adding Datasets directly, + * taking care of wrapping them in a DataView as needed. + */ + Display createDisplayQuietly(Object o); + } From b1d102fa7f077b2f3d3d48ffd7b19f21e73e8f98 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Mon, 29 Feb 2016 14:29:09 -0600 Subject: [PATCH 0149/1208] Fix ConsoleUtils.hasParam use If there is a parameter, it should be removed. Fixes issue with unconsumed command-line inputs. --- src/main/java/org/scijava/command/console/RunArgument.java | 2 +- src/main/java/org/scijava/script/console/RunScriptArgument.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/command/console/RunArgument.java b/src/main/java/org/scijava/command/console/RunArgument.java index 59e283dba..aca51500c 100644 --- a/src/main/java/org/scijava/command/console/RunArgument.java +++ b/src/main/java/org/scijava/command/console/RunArgument.java @@ -74,7 +74,7 @@ public void handle(final LinkedList args) { args.removeFirst(); // --run final String commandToRun = args.removeFirst(); - final String paramString = ConsoleUtils.hasParam(args) ? "" : args.removeFirst(); + final String paramString = ConsoleUtils.hasParam(args) ? args.removeFirst() : ""; run(commandToRun, paramString); } diff --git a/src/main/java/org/scijava/script/console/RunScriptArgument.java b/src/main/java/org/scijava/script/console/RunScriptArgument.java index b7b663968..df8c94204 100644 --- a/src/main/java/org/scijava/script/console/RunScriptArgument.java +++ b/src/main/java/org/scijava/script/console/RunScriptArgument.java @@ -72,7 +72,7 @@ public void handle(final LinkedList args) { args.removeFirst(); // --run final String scriptToRun = args.removeFirst(); - final String paramString = ConsoleUtils.hasParam(args) ? "" : args.removeFirst(); + final String paramString = ConsoleUtils.hasParam(args) ? args.removeFirst() : ""; run(scriptToRun, paramString); } From aeefc14ed3f487d52331e306c6fa11bbe17ea62d Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 2 Mar 2016 10:15:19 -0600 Subject: [PATCH 0150/1208] Bump parent to pom-scijava 9.6.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9ec636dcc..4504dc86e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.scijava pom-scijava - 9.5.1 + 9.6.0 From 9aaf422735833a483c09feb38a2afe8ecfc298b6 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 2 Mar 2016 11:55:15 -0600 Subject: [PATCH 0151/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4504dc86e..b897191dc 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.53.0-SNAPSHOT + 2.53.1-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From f9967e17f691cb83c432691f5f6314c76087b173 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 16 Mar 2016 10:19:24 -0500 Subject: [PATCH 0152/1208] AbstractScriptLanguage: avoid NPE on Name Add a check for a null Info, in case a ScriptLanguage is unannotated. --- src/main/java/org/scijava/script/AbstractScriptLanguage.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/script/AbstractScriptLanguage.java b/src/main/java/org/scijava/script/AbstractScriptLanguage.java index f50965015..ee2ffdd03 100644 --- a/src/main/java/org/scijava/script/AbstractScriptLanguage.java +++ b/src/main/java/org/scijava/script/AbstractScriptLanguage.java @@ -38,6 +38,7 @@ import javax.script.ScriptEngineFactory; import org.scijava.plugin.AbstractRichPlugin; +import org.scijava.plugin.PluginInfo; import org.scijava.util.VersionUtils; /** @@ -106,7 +107,9 @@ public String getEngineName() { @Override public String getLanguageName() { - final String name = getInfo().getName(); + String name = null; + final PluginInfo info = getInfo(); + if (info != null) name = info.getName(); return name != null && !name.isEmpty() ? name : inferNameFromClassName(); } From ea8c6471e4d5a723eb0a2f58fd7f3c17d821a8d3 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 24 Mar 2016 08:58:20 -0500 Subject: [PATCH 0153/1208] DefaultUIService: give a hint why no UIs are found Multiple people have now been confused by this error. So let's give a suggestion how to overcome it. See: * http://forum.imagej.net/t/basic-imagej2-question-how-to-open-imagej/1179 * http://forum.imagej.net/t/register-virtual-stack-slices-plugin-hangs-on-macos/1123/12 --- src/main/java/org/scijava/ui/DefaultUIService.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/scijava/ui/DefaultUIService.java b/src/main/java/org/scijava/ui/DefaultUIService.java index 61f7644e3..7f8907dbb 100644 --- a/src/main/java/org/scijava/ui/DefaultUIService.java +++ b/src/main/java/org/scijava/ui/DefaultUIService.java @@ -159,9 +159,7 @@ public void addUI(final String name, final UserInterface ui) { public void showUI() { if (disposed) return; final UserInterface ui = getDefaultUI(); - if (ui == null) { - throw new IllegalStateException("No UIs available."); - } + if (ui == null) throw noUIsAvailableException(); showUI(ui); } @@ -188,9 +186,7 @@ public void showUI(final UserInterface ui) { @Override public boolean isVisible() { final UserInterface ui = getDefaultUI(); - if (ui == null) { - throw new IllegalStateException("No UIs available."); - } + if (ui == null) throw noUIsAvailableException(); return ui.isVisible(); } @@ -547,4 +543,10 @@ private void addUserInterface(final String name, final UserInterface ui) { private String getTitle() { return appService.getApp().getTitle(); } + + private IllegalStateException noUIsAvailableException() { + return new IllegalStateException("No UIs available. " + + "Please add a component containing a UIPlugin " + + "(e.g., scijava-ui-swing) to your class-path."); + } } From 1e9c40d6f77878a522eedd3ac03dda9c0c493f35 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 29 Mar 2016 14:48:16 -0500 Subject: [PATCH 0154/1208] ScriptInfo: make assignAttribute code more compact And hopefully easier to read. This also generalizes it to any Object values, not just String values, which will come in handy shortly. --- .../java/org/scijava/script/ScriptInfo.java | 101 ++++++------------ 1 file changed, 33 insertions(+), 68 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index d8af44045..32dd70e76 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -421,78 +421,43 @@ private void addItem(final String name, final Class type, } private void assignAttribute(final DefaultMutableModuleItem item, - final String key, final String value) throws ScriptException + final String k, final Object v) throws ScriptException { // CTR: There must be an easier way to do this. // Just compile the thing using javac? Or parse via javascript, maybe? - if ("callback".equalsIgnoreCase(key)) { - item.setCallback(value); - } - else if ("choices".equalsIgnoreCase(key)) { + if (is(k, "callback")) item.setCallback(as(v, String.class)); + else if (is(k, "choices")) { // FIXME: Regex above won't handle {a,b,c} syntax. -// item.setChoices(choices); - } - else if ("columns".equalsIgnoreCase(key)) { - item.setColumnCount(convertService.convert(value, int.class)); - } - else if ("description".equalsIgnoreCase(key)) { - item.setDescription(value); - } - else if ("initializer".equalsIgnoreCase(key)) { - item.setInitializer(value); - } - else if ("type".equalsIgnoreCase(key)) { - item.setIOType(convertService.convert(value, ItemIO.class)); - } - else if ("label".equalsIgnoreCase(key)) { - item.setLabel(value); - } - else if ("max".equalsIgnoreCase(key)) { - item.setMaximumValue(convertService.convert(value, item.getType())); - } - else if ("min".equalsIgnoreCase(key)) { - item.setMinimumValue(convertService.convert(value, item.getType())); - } - else if ("name".equalsIgnoreCase(key)) { - item.setName(value); - } - else if ("persist".equalsIgnoreCase(key)) { - item.setPersisted(convertService.convert(value, boolean.class)); - } - else if ("persistKey".equalsIgnoreCase(key)) { - item.setPersistKey(value); - } - else if ("required".equalsIgnoreCase(key)) { - item.setRequired(convertService.convert(value, boolean.class)); - } - else if ("softMax".equalsIgnoreCase(key)) { - item.setSoftMaximum(convertService.convert(value, item.getType())); - } - else if ("softMin".equalsIgnoreCase(key)) { - item.setSoftMinimum(convertService.convert(value, item.getType())); - } - else if ("stepSize".equalsIgnoreCase(key)) { - try { - final double stepSize = Double.parseDouble(value); - item.setStepSize(stepSize); - } - catch (final NumberFormatException exc) { - log.warn("Script parameter " + item.getName() + - " has an invalid stepSize: " + value); - } - } - else if ("style".equalsIgnoreCase(key)) { - item.setWidgetStyle(value); - } - else if ("visibility".equalsIgnoreCase(key)) { - item.setVisibility(convertService.convert(value, ItemVisibility.class)); - } - else if ("value".equalsIgnoreCase(key)) { - item.setDefaultValue(convertService.convert(value, item.getType())); - } - else { - throw new ScriptException("Invalid attribute name: " + key); - } +// item.setChoices(list(v, item.getType())); + } + else if (is(k, "columns")) item.setColumnCount(as(v, int.class)); + else if (is(k, "description")) item.setDescription(as(v, String.class)); + else if (is(k, "initializer")) item.setInitializer(as(v, String.class)); + else if (is(k, "type")) item.setIOType(as(v, ItemIO.class)); + else if (is(k, "label")) item.setLabel(as(v, String.class)); + else if (is(k, "max")) item.setMaximumValue(as(v, item.getType())); + else if (is(k, "min")) item.setMinimumValue(as(v, item.getType())); + else if (is(k, "name")) item.setName(as(v, String.class)); + else if (is(k, "persist")) item.setPersisted(as(v, boolean.class)); + else if (is(k, "persistKey")) item.setPersistKey(as(v, String.class)); + else if (is(k, "required")) item.setRequired(as(v, boolean.class)); + else if (is(k, "softMax")) item.setSoftMaximum(as(v, item.getType())); + else if (is(k, "softMin")) item.setSoftMinimum(as(v, item.getType())); + else if (is(k, "stepSize")) item.setStepSize(as(v, double.class)); + else if (is(k, "style")) item.setWidgetStyle(as(v, String.class)); + else if (is(k, "visibility")) item.setVisibility(as(v, ItemVisibility.class)); + else if (is(k, "value")) item.setDefaultValue(as(v, item.getType())); + else throw new ScriptException("Invalid attribute name: " + k); + } + + /** Super terse comparison helper method. */ + private boolean is(final String key, final String desired) { + return desired.equalsIgnoreCase(key); + } + + /** Super terse conversion helper method. */ + private T as(final Object v, final Class type) { + return convertService.convert(v, type); } /** From dfed65f9f3d34f9e111b32659e0649148f66f67a Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 29 Mar 2016 14:51:21 -0500 Subject: [PATCH 0155/1208] ScriptInfo: generalize attr values to Object This will come in handy shortly when we switch to SJEP. --- src/main/java/org/scijava/script/ScriptInfo.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index 32dd70e76..c2f47ce2c 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -347,7 +347,7 @@ private void parseParam(final String param) throws ScriptException { } private void parseParam(final String param, - final HashMap attrs) throws ScriptException + final HashMap attrs) throws ScriptException { final String[] tokens = param.trim().split("[ \t\n]+"); checkValid(tokens.length >= 1, param); @@ -371,11 +371,11 @@ private void parseParam(final String param, } /** Parses a comma-delimited list of {@code key=value} pairs into a map. */ - private HashMap parseAttrs(final String attrs) + private HashMap parseAttrs(final String attrs) throws ScriptException { // TODO: We probably want to use a real CSV parser. - final HashMap attrsMap = new HashMap(); + final HashMap attrsMap = new HashMap(); for (final String token : attrs.split(",")) { if (token.isEmpty()) continue; final int equals = token.indexOf("="); @@ -402,18 +402,18 @@ private void checkValid(final boolean valid, final String param) /** Adds an output for the value returned by the script itself. */ private void addReturnValue() throws ScriptException { - final HashMap attrs = new HashMap(); + final HashMap attrs = new HashMap(); attrs.put("type", "OUTPUT"); addItem(ScriptModule.RETURN_VALUE, Object.class, attrs); } private void addItem(final String name, final Class type, - final Map attrs) throws ScriptException + final Map attrs) throws ScriptException { final DefaultMutableModuleItem item = new DefaultMutableModuleItem(this, name, type); for (final String key : attrs.keySet()) { - final String value = attrs.get(key); + final Object value = attrs.get(key); assignAttribute(item, key, value); } if (item.isInput()) registerInput(item); From aea2aca34cb9edae99134662878ffc3d5124bfed Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 29 Mar 2016 15:02:50 -0500 Subject: [PATCH 0156/1208] ScriptInfo: use SJEP for more robust attr parsing SJEP version 3.0.0 includes improved support for "group" operators, including parentheses, square brackets and curly braces. And its default expression evaluator aggregates groups into List objects, which can be easily consumed by the ScriptInfo attribute parser. Closes #156. --- pom.xml | 7 +++ .../java/org/scijava/script/ScriptInfo.java | 52 ++++++++++++++----- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index b897191dc..eaf6ea6bc 100644 --- a/pom.xml +++ b/pom.xml @@ -116,9 +116,16 @@ 1.8 + 3.0.0 + + + org.scijava + scijava-expression-parser + + com.googlecode.gentyref diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index c2f47ce2c..5ee896b4c 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -38,8 +38,11 @@ import java.io.Reader; import java.io.StringReader; import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.script.ScriptException; @@ -56,6 +59,8 @@ import org.scijava.module.DefaultMutableModuleItem; import org.scijava.module.ModuleException; import org.scijava.plugin.Parameter; +import org.scijava.sjep.Variable; +import org.scijava.sjep.eval.DefaultEvaluator; import org.scijava.util.DigestUtils; import org.scijava.util.FileUtils; @@ -337,11 +342,11 @@ private void parseParam(final String param) throws ScriptException { if (rParen < lParen) { throw new ScriptException("Invalid parameter: " + param); } - if (lParen < 0) parseParam(param, parseAttrs("")); + if (lParen < 0) parseParam(param, parseAttrs("()")); else { final String cutParam = param.substring(0, lParen) + param.substring(rParen + 1); - final String attrs = param.substring(lParen + 1, rParen); + final String attrs = param.substring(lParen, rParen + 1); parseParam(cutParam, parseAttrs(attrs)); } } @@ -374,20 +379,39 @@ private void parseParam(final String param, private HashMap parseAttrs(final String attrs) throws ScriptException { - // TODO: We probably want to use a real CSV parser. - final HashMap attrsMap = new HashMap(); - for (final String token : attrs.split(",")) { - if (token.isEmpty()) continue; - final int equals = token.indexOf("="); - if (equals < 0) throw new ScriptException("Invalid attribute: " + token); - final String key = token.substring(0, equals).trim(); - String value = token.substring(equals + 1).trim(); - if (value.startsWith("\"") && value.endsWith("\"")) { - value = value.substring(1, value.length() - 1); + // NB: Parse the attributes using the SciJava Expression Parser. + final DefaultEvaluator e = new DefaultEvaluator(); + try { + final Object result = e.evaluate(attrs); + if (result == null) throw new ScriptException("Unparseable attributes"); + final List list; + if (result instanceof List) list = (List) result; + else if (result instanceof Variable) { + list = Collections.singletonList(result); + } + else { + throw new ScriptException("Unexpected attributes type: " + + result.getClass().getName()); + } + + final HashMap attrsMap = new HashMap(); + for (final Object o : list) { + if (o instanceof Variable) { + final Variable v = (Variable) o; + attrsMap.put(v.getToken(), e.value(v)); + } + else { + throw new ScriptException("Invalid attribute: " + o); + } } - attrsMap.put(key, value); + return attrsMap; + } + catch (final IllegalArgumentException exc) { + final ScriptException se = new ScriptException( + "Error parsing attributes"); + se.initCause(exc); + throw se; } - return attrsMap; } private boolean isIOType(final String token) { From ddd4e909d384e33dcf905acb79ea2e8d84ca060a Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 29 Mar 2016 15:40:45 -0500 Subject: [PATCH 0157/1208] ScriptInfo: parse choices attribute Now that we use SJEP, this is straightforward to do. --- src/main/java/org/scijava/script/ScriptInfo.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index 5ee896b4c..fefcbb663 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -38,7 +38,7 @@ import java.io.Reader; import java.io.StringReader; import java.text.SimpleDateFormat; -import java.util.Arrays; +import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; @@ -450,10 +450,7 @@ private void assignAttribute(final DefaultMutableModuleItem item, // CTR: There must be an easier way to do this. // Just compile the thing using javac? Or parse via javascript, maybe? if (is(k, "callback")) item.setCallback(as(v, String.class)); - else if (is(k, "choices")) { - // FIXME: Regex above won't handle {a,b,c} syntax. -// item.setChoices(list(v, item.getType())); - } + else if (is(k, "choices")) item.setChoices(asList(v, item.getType())); else if (is(k, "columns")) item.setColumnCount(as(v, int.class)); else if (is(k, "description")) item.setDescription(as(v, String.class)); else if (is(k, "initializer")) item.setInitializer(as(v, String.class)); @@ -484,6 +481,15 @@ private T as(final Object v, final Class type) { return convertService.convert(v, type); } + private List asList(final Object v, final Class type) { + final ArrayList result = new ArrayList(); + final List list = as(v, List.class); + for (final Object item : list) { + result.add(as(item, type)); + } + return result; + } + /** * Read entire contents of a Reader and return as String. * From cbf405b5cc9d9d7896d58869c2fc02ecb9ac5695 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 29 Mar 2016 15:39:15 -0500 Subject: [PATCH 0158/1208] ScriptInfoTest: also test that choices match Of course, all the parameters currently being tested have no choices. But that will change in the next commit. --- .../java/org/scijava/script/ScriptInfoTest.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/scijava/script/ScriptInfoTest.java b/src/test/java/org/scijava/script/ScriptInfoTest.java index df64ad513..1211b9130 100644 --- a/src/test/java/org/scijava/script/ScriptInfoTest.java +++ b/src/test/java/org/scijava/script/ScriptInfoTest.java @@ -42,6 +42,7 @@ import java.io.Reader; import java.io.StringReader; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -146,21 +147,23 @@ public void testParameters() { final ScriptInfo info = new ScriptInfo(context, "params.bsizes", new StringReader(script)); + final List noChoices = Collections.emptyList(); + final ModuleItem log = info.getInput("log"); assertItem("log", LogService.class, null, ItemIO.INPUT, false, true, null, - null, null, null, null, null, null, null, log); + null, null, null, null, null, null, null, noChoices, log); final ModuleItem sliderValue = info.getInput("sliderValue"); assertItem("sliderValue", int.class, "Slider Value", ItemIO.INPUT, true, - true, null, "slider", 11, null, null, 5, 15, 3.0, sliderValue); + true, null, "slider", 11, null, null, 5, 15, 3.0, noChoices, sliderValue); final ModuleItem buffer = info.getOutput("buffer"); assertItem("buffer", StringBuilder.class, null, ItemIO.BOTH, true, true, - null, null, null, null, null, null, null, null, buffer); + null, null, null, null, null, null, null, null, noChoices, buffer); final ModuleItem result = info.getOutput("result"); assertItem("result", Object.class, null, ItemIO.OUTPUT, true, true, null, - null, null, null, null, null, null, null, result); + null, null, null, null, null, null, null, noChoices, result); int inputCount = 0; final ModuleItem[] inputs = { log, sliderValue, buffer }; @@ -180,7 +183,7 @@ private void assertItem(final String name, final Class type, final boolean persist, final String persistKey, final String style, final Object value, final Object min, final Object max, final Object softMin, final Object softMax, final Number stepSize, - final ModuleItem item) + final List choices, final ModuleItem item) { assertEquals(name, item.getName()); assertSame(type, item.getType()); @@ -196,6 +199,7 @@ private void assertItem(final String name, final Class type, assertEquals(softMin, item.getSoftMinimum()); assertEquals(softMax, item.getSoftMaximum()); assertEquals(stepSize, item.getStepSize()); + assertEquals(choices, item.getChoices()); } /** From 66fc545f7d46a97496ce2b6eb4f0fd5ec79aeaba Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 29 Mar 2016 15:41:23 -0500 Subject: [PATCH 0159/1208] ScriptInfoTest: add a multiple choice parameter Now that we parse the choices attribute, let's test that it works. --- src/test/java/org/scijava/script/ScriptInfoTest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/scijava/script/ScriptInfoTest.java b/src/test/java/org/scijava/script/ScriptInfoTest.java index 1211b9130..887b8d52b 100644 --- a/src/test/java/org/scijava/script/ScriptInfoTest.java +++ b/src/test/java/org/scijava/script/ScriptInfoTest.java @@ -142,6 +142,8 @@ public void testParameters() { "% @LogService(required = false) log\n" + // "% @int(label=\"Slider Value\", softMin=5, softMax=15, " + // "stepSize=3, value=11, style=\"slider\") sliderValue\n" + // + "% @String(persist = false, " + // + "choices={'quick brown fox', 'lazy dog'}) animal\n" + // "% @BOTH java.lang.StringBuilder buffer"; final ScriptInfo info = @@ -157,6 +159,12 @@ public void testParameters() { assertItem("sliderValue", int.class, "Slider Value", ItemIO.INPUT, true, true, null, "slider", 11, null, null, 5, 15, 3.0, noChoices, sliderValue); + final ModuleItem animal = info.getInput("animal"); + final List animalChoices = // + Arrays.asList("quick brown fox", "lazy dog"); + assertItem("animal", String.class, null, ItemIO.INPUT, true, false, + null, null, null, null, null, null, null, null, animalChoices, animal); + final ModuleItem buffer = info.getOutput("buffer"); assertItem("buffer", StringBuilder.class, null, ItemIO.BOTH, true, true, null, null, null, null, null, null, null, null, noChoices, buffer); @@ -166,7 +174,7 @@ public void testParameters() { null, null, null, null, null, null, null, noChoices, result); int inputCount = 0; - final ModuleItem[] inputs = { log, sliderValue, buffer }; + final ModuleItem[] inputs = { log, sliderValue, animal, buffer }; for (final ModuleItem inItem : info.inputs()) { assertSame(inputs[inputCount++], inItem); } From 14e04912fdbce7e1b46515cd09d49a10042fc1d7 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 31 Mar 2016 18:56:36 -0500 Subject: [PATCH 0160/1208] ScriptLanguageIndex: fix gentle language addition When adding a language "gently" (i.e., without ovewriting existing languages), we should be smarter about not overwriting _any_ of the language names or extensions. Otherwise, a lower-priority language can override a higher-priority one with respect to a specific name or extension. --- .../scijava/script/ScriptLanguageIndex.java | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptLanguageIndex.java b/src/main/java/org/scijava/script/ScriptLanguageIndex.java index dfae11751..eb8797612 100644 --- a/src/main/java/org/scijava/script/ScriptLanguageIndex.java +++ b/src/main/java/org/scijava/script/ScriptLanguageIndex.java @@ -75,32 +75,24 @@ public ScriptLanguageIndex(final LogService logService) { } public boolean add(final ScriptEngineFactory factory, final boolean gently) { - final String duplicateName = checkDuplicate(factory); - if (duplicateName != null) { - if (gently) return false; - if (log != null) { - log.warn("Duplicate scripting language '" + - duplicateName + "': existing=" + - byName.get(duplicateName).getClass().getName() + - ", new=" + factory.getClass().getName()); - } - } + boolean result = false; final ScriptLanguage language = wrap(factory); // add language names - byName.put(language.getLanguageName(), language); + result |= put("name", byName, language.getLanguageName(), language, gently); for (final String name : language.getNames()) { - byName.put(name, language); + result |= put("name", byName, name, language, gently); } // add file extensions for (final String extension : language.getExtensions()) { if ("".equals(extension)) continue; - byExtension.put(extension, language); + result |= put("extension", byExtension, extension, language, gently); } - return super.add(language); + result |= super.add(language); + return result; } public ScriptLanguage getByExtension(final String extension) { @@ -137,13 +129,19 @@ public boolean add(final ScriptLanguage language) { // -- Helper methods -- - private String checkDuplicate(final ScriptEngineFactory factory) { - for (final String name : factory.getNames()) { - if (byName.containsKey(name)) { - return name; + private boolean put(final String type, final Map map, + final String key, final ScriptLanguage value, final boolean gently) + { + if (gently && map.containsKey(key)) { + if (log != null) { + log.warn("Not registering " + type + " '" + key + + "' for scripting language " + value.getClass().getName() + + ": existing=" + map.get(key).getClass().getName()); } + return false; } - return null; + map.put(key, value); + return true; } private ScriptLanguage wrap(final ScriptEngineFactory factory) { From 26334909e5869e8e2a8419679810a1f9e4c3b7fa Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 31 Mar 2016 18:59:08 -0500 Subject: [PATCH 0161/1208] DefaultScriptService: always add languages gently Otherwise, lower-priority languages overwrite higher-priority ones! --- src/main/java/org/scijava/script/DefaultScriptService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index e04efee2d..f5ef235fe 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -343,7 +343,7 @@ private synchronized void initScriptLanguageIndex() { // add ScriptLanguage plugins for (final ScriptLanguage language : getInstances()) { - index.add(language, false); + index.add(language, true); } // Now look for the ScriptEngines in javax.scripting. We only do that From f29650e3d52e06518809068de8786896e2a422b4 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 1 Apr 2016 09:55:15 -0500 Subject: [PATCH 0162/1208] DefaultScriptService: do not wrap JSR-223 engines In theory, it was nice to try to expose all available JSR-223 ScriptEngineFactory implementations as SciJava script languages. However, without an associated explicit ScriptLanguage plugin, there are limitations to what the SciJava framework can achieve. And there was related behavior which could be construed as a bug: each SciJava scripting component now exposes its ScriptLanguage as a ScriptEngineFactory via the javax.services mechanism so that it can be used from other JSR-223 applications not built on SJC. This caused them to be discovered and added to the ScriptLanguageIndex twice: once as ScriptLanguage plugins directly, and again as wrapped JSR-223 ScriptEngineFactory implementations. While we could make the ScriptService smarter about this situation, it is easier to simply stop wrapping vanilla JSR-223 ScriptEngineFactory classes, because we have no use cases relying on it. (The only engine I know of which has no associated SciJava scripting component is AppleScript on OS X, and AFAIK, no one writes AppleScript scripts in anger in ImageJ.) --- .../org/scijava/script/DefaultScriptService.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index f5ef235fe..e1317cc58 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -346,20 +346,6 @@ private synchronized void initScriptLanguageIndex() { index.add(language, true); } - // Now look for the ScriptEngines in javax.scripting. We only do that - // now since the javax.scripting framework does not provide all the - // functionality we might want to use in a SciJava application. - final ScriptEngineManager manager = new ScriptEngineManager(); - for (final ScriptEngineFactory factory : manager.getEngineFactories()) { - index.add(factory, true); - } - - // Inject the context into languages which need it: the - // wrapped engine factories from the ScriptEngineManager. - for (final ScriptLanguage language : index) { - if (language.getContext() == null) language.setContext(getContext()); - } - scriptLanguageIndex = index; } From a753c33dad496317ec067244ec1fab5107731481 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 1 Apr 2016 10:46:41 -0500 Subject: [PATCH 0163/1208] ScriptLanguageIndex: clarify add behavior cases When adding a script language to the index, behavior depends on a couple of factors: - whether each key is already in the map - whether that key points to the same value, or different one - whether the gently flag is set We now log what happens in more situations, especially in debug mode. --- .../scijava/script/ScriptLanguageIndex.java | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptLanguageIndex.java b/src/main/java/org/scijava/script/ScriptLanguageIndex.java index eb8797612..3e15a91d8 100644 --- a/src/main/java/org/scijava/script/ScriptLanguageIndex.java +++ b/src/main/java/org/scijava/script/ScriptLanguageIndex.java @@ -132,14 +132,32 @@ public boolean add(final ScriptLanguage language) { private boolean put(final String type, final Map map, final String key, final ScriptLanguage value, final boolean gently) { - if (gently && map.containsKey(key)) { - if (log != null) { - log.warn("Not registering " + type + " '" + key + - "' for scripting language " + value.getClass().getName() + - ": existing=" + map.get(key).getClass().getName()); + final ScriptLanguage existing = map.get(key); + + if (existing == value) { + // Duplicate key/value pair; do not overwrite. + if (log != null && log.isDebug()) { + // In debug mode, warn about the duplicate (since it is atypical). + log.debug(overwriteMessage(false, type, key, value, existing)); } return false; } + + if (existing != null) { + // Conflicting value; behavior depends on mode. + if (gently) { + // Do not overwrite the previous value. + if (log != null && log.isWarn()) { + log.warn(overwriteMessage(false, type, key, value, existing)); + } + return false; + } + if (log != null && log.isDebug()) { + // In debug mode, warn about overwriting. + log.debug(overwriteMessage(true, type, key, value, existing)); + } + } + map.put(key, value); return true; } @@ -149,4 +167,14 @@ private ScriptLanguage wrap(final ScriptEngineFactory factory) { return new AdaptedScriptLanguage(factory); } + /** Helper method of {@link #put}. */ + private String overwriteMessage(final boolean overwrite, final String type, + final String key, final ScriptLanguage proposed, + final ScriptLanguage existing) + { + return (overwrite ? "Overwriting " : "Not overwriting ") + type + // + " '" + key + "':\n\tproposed = " + proposed.getClass().getName() + + "\n\texisting = " + existing.getClass().getName(); + } + } From cb1a16dff204d50362d2a4bd1f6353b86faebbb5 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 1 Apr 2016 10:49:26 -0500 Subject: [PATCH 0164/1208] ScriptLanguageIndex: add javadoc to helper method --- src/main/java/org/scijava/script/ScriptLanguageIndex.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/scijava/script/ScriptLanguageIndex.java b/src/main/java/org/scijava/script/ScriptLanguageIndex.java index 3e15a91d8..4563dbd97 100644 --- a/src/main/java/org/scijava/script/ScriptLanguageIndex.java +++ b/src/main/java/org/scijava/script/ScriptLanguageIndex.java @@ -162,6 +162,7 @@ private boolean put(final String type, final Map map, return true; } + /** Helper method of {@link #add(ScriptEngineFactory, boolean)}. */ private ScriptLanguage wrap(final ScriptEngineFactory factory) { if (factory instanceof ScriptLanguage) return (ScriptLanguage) factory; return new AdaptedScriptLanguage(factory); From 60d5d130aefbc66f000899cce23791e35aac62bd Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 1 Apr 2016 13:42:35 -0500 Subject: [PATCH 0165/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eaf6ea6bc..b26b94caa 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.53.1-SNAPSHOT + 2.53.2-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From a809ffb85b0afb95fb1df52bc0c1f472aa8efd19 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 20:32:18 -0500 Subject: [PATCH 0166/1208] Fix StatusServiceTest Name it consistently with all other service tests. And add the missing class javadoc and @author tag. --- ...efaultStatusServiceTest.java => StatusServiceTest.java} | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) rename src/test/java/org/scijava/app/{DefaultStatusServiceTest.java => StatusServiceTest.java} (98%) diff --git a/src/test/java/org/scijava/app/DefaultStatusServiceTest.java b/src/test/java/org/scijava/app/StatusServiceTest.java similarity index 98% rename from src/test/java/org/scijava/app/DefaultStatusServiceTest.java rename to src/test/java/org/scijava/app/StatusServiceTest.java index eca692637..58a049138 100644 --- a/src/test/java/org/scijava/app/DefaultStatusServiceTest.java +++ b/src/test/java/org/scijava/app/StatusServiceTest.java @@ -48,7 +48,12 @@ import org.scijava.event.EventHandler; import org.scijava.plugin.Parameter; -public class DefaultStatusServiceTest { +/** + * Tests {@link StatusService}. + * + * @author Lee Kamentsky + */ +public class StatusServiceTest { private Context context; private StatusListener statusListener; From 5ebbc0a7710f49d1068d591e8d726c47dd71631c Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 29 Feb 2016 13:45:06 -0600 Subject: [PATCH 0167/1208] Add a service for executing Java classes This code migrated from the JavaService/JavaRunner API of the scijava/scripting-java component. See #226. --- pom.xml | 2 +- .../org/scijava/run/AbstractClassRunner.java | 53 ++++++++++++ .../java/org/scijava/run/ClassRunner.java | 58 +++++++++++++ .../org/scijava/run/DefaultRunService.java | 83 +++++++++++++++++++ src/main/java/org/scijava/run/RunService.java | 51 ++++++++++++ .../java/org/scijava/ContextCreationTest.java | 1 + 6 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/scijava/run/AbstractClassRunner.java create mode 100644 src/main/java/org/scijava/run/ClassRunner.java create mode 100644 src/main/java/org/scijava/run/DefaultRunService.java create mode 100644 src/main/java/org/scijava/run/RunService.java diff --git a/pom.xml b/pom.xml index b26b94caa..86a4aaaaa 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.53.2-SNAPSHOT + 2.54.0-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. diff --git a/src/main/java/org/scijava/run/AbstractClassRunner.java b/src/main/java/org/scijava/run/AbstractClassRunner.java new file mode 100644 index 000000000..1acd7d45d --- /dev/null +++ b/src/main/java/org/scijava/run/AbstractClassRunner.java @@ -0,0 +1,53 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.run; + +import org.scijava.plugin.AbstractHandlerPlugin; + +/** + * Abstract superclass of {@link ClassRunner} implementations. + * + * @author Curtis Rueden + */ +public abstract class AbstractClassRunner extends + AbstractHandlerPlugin> implements ClassRunner +{ + + // -- Typed methods -- + + @Override + @SuppressWarnings({ "rawtypes", "unchecked" }) + public Class> getType() { + return (Class) Class.class; + } + +} diff --git a/src/main/java/org/scijava/run/ClassRunner.java b/src/main/java/org/scijava/run/ClassRunner.java new file mode 100644 index 000000000..ef7d0ffd5 --- /dev/null +++ b/src/main/java/org/scijava/run/ClassRunner.java @@ -0,0 +1,58 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.run; + +import javax.script.ScriptException; + +import org.scijava.plugin.HandlerPlugin; +import org.scijava.plugin.Plugin; + +/** + * A plugin which extends the {@link RunService}'s execution handling. A + * {@link ClassRunner} knows how to execute certain classes, beyond just Java's + * usual {@code main} method. + *

    + * Class runner plugins discoverable at runtime must implement this interface + * and be annotated with @{@link Plugin} with attribute {@link Plugin#type()} = + * {@link ClassRunner}.class. While it possible to create a class runner plugin + * merely by implementing this interface, it is encouraged to instead extend + * {@link AbstractClassRunner}, for convenience. + *

    + * + * @author Curtis Rueden + */ +public interface ClassRunner extends HandlerPlugin> { + + /** Executes the given class. */ + void run(Class c) throws ScriptException; + +} diff --git a/src/main/java/org/scijava/run/DefaultRunService.java b/src/main/java/org/scijava/run/DefaultRunService.java new file mode 100644 index 000000000..687098663 --- /dev/null +++ b/src/main/java/org/scijava/run/DefaultRunService.java @@ -0,0 +1,83 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.run; + +import javax.script.ScriptException; + +import org.scijava.log.LogService; +import org.scijava.plugin.AbstractHandlerService; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; +import org.scijava.service.Service; + +/** + * Default service for managing available {@link ClassRunner} plugins. + * + * @author Curtis Rueden + */ +@Plugin(type = Service.class) +public class DefaultRunService extends + AbstractHandlerService, ClassRunner> implements RunService +{ + + @Parameter + private LogService log; + + // -- RunService methods -- + + @Override + public void run(final Class c) throws ScriptException { + for (final ClassRunner runner : getInstances()) { + if (runner.supports(c)) { + runner.run(c); + return; + } + } + log.error("Unknown class type: " + c.getName()); + } + + // -- PTService methods -- + + @Override + public Class getPluginType() { + return ClassRunner.class; + } + + // -- Typed methods -- + + @Override + @SuppressWarnings({ "rawtypes", "unchecked" }) + public Class> getType() { + return (Class) Class.class; + } + +} diff --git a/src/main/java/org/scijava/run/RunService.java b/src/main/java/org/scijava/run/RunService.java new file mode 100644 index 000000000..e1b8e9c0e --- /dev/null +++ b/src/main/java/org/scijava/run/RunService.java @@ -0,0 +1,51 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.run; + +import javax.script.ScriptException; + +import org.scijava.plugin.HandlerService; +import org.scijava.service.SciJavaService; + +/** + * Interface for service that manages available {@link ClassRunner} plugins. + * + * @author Curtis Rueden + */ +public interface RunService extends + HandlerService, ClassRunner>, SciJavaService +{ + + /** Executes the given class using the most appropriate handler. */ + void run(Class c) throws ScriptException; + +} diff --git a/src/test/java/org/scijava/ContextCreationTest.java b/src/test/java/org/scijava/ContextCreationTest.java index be2871145..e3955a6c7 100644 --- a/src/test/java/org/scijava/ContextCreationTest.java +++ b/src/test/java/org/scijava/ContextCreationTest.java @@ -105,6 +105,7 @@ public void testFull() { org.scijava.platform.DefaultPlatformService.class, org.scijava.plugin.DefaultPluginService.class, org.scijava.prefs.DefaultPrefService.class, + org.scijava.run.DefaultRunService.class, org.scijava.script.DefaultScriptHeaderService.class, org.scijava.text.DefaultTextService.class, org.scijava.thread.DefaultThreadService.class, From 39d5e3b1794954f26c8ad06866267e4a19019a8d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 29 Feb 2016 13:47:51 -0600 Subject: [PATCH 0168/1208] Add a ClassRunner for Command plugins Migrated from the CommandJavaRunner of scijava/scripting-java. --- .../scijava/command/run/CommandRunner.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/main/java/org/scijava/command/run/CommandRunner.java diff --git a/src/main/java/org/scijava/command/run/CommandRunner.java b/src/main/java/org/scijava/command/run/CommandRunner.java new file mode 100644 index 000000000..acd7e60e6 --- /dev/null +++ b/src/main/java/org/scijava/command/run/CommandRunner.java @@ -0,0 +1,76 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.command.run; + +import org.scijava.command.Command; +import org.scijava.command.CommandInfo; +import org.scijava.command.CommandService; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; +import org.scijava.plugin.PluginService; +import org.scijava.run.AbstractClassRunner; +import org.scijava.run.ClassRunner; + +/** + * Runs the given {@link Command} class. + * + * @author Curtis Rueden + */ +@Plugin(type = ClassRunner.class) +public class CommandRunner extends AbstractClassRunner { + + @Parameter + private PluginService pluginService; + + @Parameter + private CommandService commandService; + + // -- ClassRunner methods -- + + @Override + public void run(final Class c) { + @SuppressWarnings("unchecked") + final Class commandClass = (Class) c; + final Plugin annotation = c.getAnnotation(Plugin.class); + final CommandInfo info = new CommandInfo(commandClass, annotation); + pluginService.addPlugin(info); + commandService.run(info, true); + } + + // -- Typed methods -- + + @Override + public boolean supports(final Class c) { + return Command.class.isAssignableFrom(c); + } + +} From 8272eb03c8c9fe53af934a1fca58da5a72aeccdf Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 29 Feb 2016 13:49:41 -0600 Subject: [PATCH 0169/1208] Add a ClassRunner for main methods of classes Migrated from the MainJavaRunner of scijava/scripting-java. --- .../java/org/scijava/main/run/MainRunner.java | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/main/java/org/scijava/main/run/MainRunner.java diff --git a/src/main/java/org/scijava/main/run/MainRunner.java b/src/main/java/org/scijava/main/run/MainRunner.java new file mode 100644 index 000000000..cfdd43b5d --- /dev/null +++ b/src/main/java/org/scijava/main/run/MainRunner.java @@ -0,0 +1,98 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.main.run; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import javax.script.ScriptException; + +import org.scijava.Priority; +import org.scijava.log.LogService; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; +import org.scijava.run.AbstractClassRunner; +import org.scijava.run.ClassRunner; + +/** + * Executes the given class's {@code main} method. + * + * @author Curtis Rueden + */ +@Plugin(type = ClassRunner.class, priority = Priority.LOW_PRIORITY) +public class MainRunner extends AbstractClassRunner { + + @Parameter(required = false) + private LogService log; + + // -- ClassRunner methods -- + + @Override + public void run(final Class c) throws ScriptException { + try { + getMain(c).invoke(null, new Object[] { new String[0] }); + } + catch (final IllegalArgumentException exc) { + throw new ScriptException(exc); + } + catch (final IllegalAccessException exc) { + throw new ScriptException(exc); + } + catch (final InvocationTargetException exc) { + throw new ScriptException(exc); + } + } + + // -- Typed methods -- + + @Override + public boolean supports(final Class c) { + return getMain(c) != null; + } + + // -- Helper methods -- + + private Method getMain(final Class c) { + try { + return c.getMethod("main", String[].class); + } + catch (final SecurityException exc) { + if (log != null) log.debug(exc); + return null; + } + catch (final NoSuchMethodException exc) { + if (log != null) log.debug(exc); + return null; + } + } + +} From ef2adf3646286e42e64930dc5d70b7e4872da094 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 29 Feb 2016 15:20:05 -0600 Subject: [PATCH 0170/1208] RunService: use InvocationTargetException instead The code migrated from scijava/scripting-java used ScriptException. But now that this code is part of core SJC, and is not script-specific anymore, it makes more sense to use InvocationTargetException instead. --- src/main/java/org/scijava/main/run/MainRunner.java | 11 +++-------- src/main/java/org/scijava/run/ClassRunner.java | 4 ++-- src/main/java/org/scijava/run/DefaultRunService.java | 6 +++--- src/main/java/org/scijava/run/RunService.java | 4 ++-- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/scijava/main/run/MainRunner.java b/src/main/java/org/scijava/main/run/MainRunner.java index cfdd43b5d..05d528f93 100644 --- a/src/main/java/org/scijava/main/run/MainRunner.java +++ b/src/main/java/org/scijava/main/run/MainRunner.java @@ -34,8 +34,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import javax.script.ScriptException; - import org.scijava.Priority; import org.scijava.log.LogService; import org.scijava.plugin.Parameter; @@ -57,18 +55,15 @@ public class MainRunner extends AbstractClassRunner { // -- ClassRunner methods -- @Override - public void run(final Class c) throws ScriptException { + public void run(final Class c) throws InvocationTargetException { try { getMain(c).invoke(null, new Object[] { new String[0] }); } catch (final IllegalArgumentException exc) { - throw new ScriptException(exc); + throw new InvocationTargetException(exc); } catch (final IllegalAccessException exc) { - throw new ScriptException(exc); - } - catch (final InvocationTargetException exc) { - throw new ScriptException(exc); + throw new InvocationTargetException(exc); } } diff --git a/src/main/java/org/scijava/run/ClassRunner.java b/src/main/java/org/scijava/run/ClassRunner.java index ef7d0ffd5..9a1ad7302 100644 --- a/src/main/java/org/scijava/run/ClassRunner.java +++ b/src/main/java/org/scijava/run/ClassRunner.java @@ -31,7 +31,7 @@ package org.scijava.run; -import javax.script.ScriptException; +import java.lang.reflect.InvocationTargetException; import org.scijava.plugin.HandlerPlugin; import org.scijava.plugin.Plugin; @@ -53,6 +53,6 @@ public interface ClassRunner extends HandlerPlugin> { /** Executes the given class. */ - void run(Class c) throws ScriptException; + void run(Class c) throws InvocationTargetException; } diff --git a/src/main/java/org/scijava/run/DefaultRunService.java b/src/main/java/org/scijava/run/DefaultRunService.java index 687098663..aac4b1bbb 100644 --- a/src/main/java/org/scijava/run/DefaultRunService.java +++ b/src/main/java/org/scijava/run/DefaultRunService.java @@ -31,7 +31,7 @@ package org.scijava.run; -import javax.script.ScriptException; +import java.lang.reflect.InvocationTargetException; import org.scijava.log.LogService; import org.scijava.plugin.AbstractHandlerService; @@ -55,14 +55,14 @@ public class DefaultRunService extends // -- RunService methods -- @Override - public void run(final Class c) throws ScriptException { + public void run(final Class c) throws InvocationTargetException { for (final ClassRunner runner : getInstances()) { if (runner.supports(c)) { runner.run(c); return; } } - log.error("Unknown class type: " + c.getName()); + throw new IllegalArgumentException("Unknown class type: " + c.getName()); } // -- PTService methods -- diff --git a/src/main/java/org/scijava/run/RunService.java b/src/main/java/org/scijava/run/RunService.java index e1b8e9c0e..0730309e9 100644 --- a/src/main/java/org/scijava/run/RunService.java +++ b/src/main/java/org/scijava/run/RunService.java @@ -31,7 +31,7 @@ package org.scijava.run; -import javax.script.ScriptException; +import java.lang.reflect.InvocationTargetException; import org.scijava.plugin.HandlerService; import org.scijava.service.SciJavaService; @@ -46,6 +46,6 @@ public interface RunService extends { /** Executes the given class using the most appropriate handler. */ - void run(Class c) throws ScriptException; + void run(Class c) throws InvocationTargetException; } From 6dff174797938dbbea95f83ac6745adf3067deca Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 29 Feb 2016 15:26:29 -0600 Subject: [PATCH 0171/1208] RunService: allow passing arguments to executions When running a class, you might want to pass some arguments. To be sure, this is useful for two of our primary use cases: main methods & modules. --- .../scijava/command/run/CommandRunner.java | 4 ++-- .../java/org/scijava/main/run/MainRunner.java | 22 +++++++++++++++++-- .../java/org/scijava/run/ClassRunner.java | 4 ++-- .../org/scijava/run/DefaultRunService.java | 4 +++- src/main/java/org/scijava/run/RunService.java | 7 ++++-- 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/scijava/command/run/CommandRunner.java b/src/main/java/org/scijava/command/run/CommandRunner.java index acd7e60e6..ec085ef96 100644 --- a/src/main/java/org/scijava/command/run/CommandRunner.java +++ b/src/main/java/org/scijava/command/run/CommandRunner.java @@ -57,13 +57,13 @@ public class CommandRunner extends AbstractClassRunner { // -- ClassRunner methods -- @Override - public void run(final Class c) { + public void run(final Class c, final Object... args) { @SuppressWarnings("unchecked") final Class commandClass = (Class) c; final Plugin annotation = c.getAnnotation(Plugin.class); final CommandInfo info = new CommandInfo(commandClass, annotation); pluginService.addPlugin(info); - commandService.run(info, true); + commandService.run(info, true, args); } // -- Typed methods -- diff --git a/src/main/java/org/scijava/main/run/MainRunner.java b/src/main/java/org/scijava/main/run/MainRunner.java index 05d528f93..36d2a6474 100644 --- a/src/main/java/org/scijava/main/run/MainRunner.java +++ b/src/main/java/org/scijava/main/run/MainRunner.java @@ -55,9 +55,12 @@ public class MainRunner extends AbstractClassRunner { // -- ClassRunner methods -- @Override - public void run(final Class c) throws InvocationTargetException { + public void run(final Class c, final Object... args) + throws InvocationTargetException + { + final Object[] sArgs = stringify(args); try { - getMain(c).invoke(null, new Object[] { new String[0] }); + getMain(c).invoke(null, new Object[] { sArgs }); } catch (final IllegalArgumentException exc) { throw new InvocationTargetException(exc); @@ -90,4 +93,19 @@ private Method getMain(final Class c) { } } + /** Ensures each element is a {@link String}. */ + private String[] stringify(final Object... o) { + final String[] s; + if (o == null) s = null; + else { + s = new String[o.length]; + for (int i = 0; i < o.length; i++) { + if (o[i] == null) s[i] = null; + else if (o[i] instanceof String) s[i] = (String) o[i]; + else s[i] = o[i].toString(); + } + } + return s; + } + } diff --git a/src/main/java/org/scijava/run/ClassRunner.java b/src/main/java/org/scijava/run/ClassRunner.java index 9a1ad7302..79e279a1a 100644 --- a/src/main/java/org/scijava/run/ClassRunner.java +++ b/src/main/java/org/scijava/run/ClassRunner.java @@ -52,7 +52,7 @@ */ public interface ClassRunner extends HandlerPlugin> { - /** Executes the given class. */ - void run(Class c) throws InvocationTargetException; + /** Executes the given class, with the specified arguments. */ + void run(Class c, Object... args) throws InvocationTargetException; } diff --git a/src/main/java/org/scijava/run/DefaultRunService.java b/src/main/java/org/scijava/run/DefaultRunService.java index aac4b1bbb..06d76556f 100644 --- a/src/main/java/org/scijava/run/DefaultRunService.java +++ b/src/main/java/org/scijava/run/DefaultRunService.java @@ -55,7 +55,9 @@ public class DefaultRunService extends // -- RunService methods -- @Override - public void run(final Class c) throws InvocationTargetException { + public void run(final Class c, final Object... args) + throws InvocationTargetException + { for (final ClassRunner runner : getInstances()) { if (runner.supports(c)) { runner.run(c); diff --git a/src/main/java/org/scijava/run/RunService.java b/src/main/java/org/scijava/run/RunService.java index 0730309e9..2dec65342 100644 --- a/src/main/java/org/scijava/run/RunService.java +++ b/src/main/java/org/scijava/run/RunService.java @@ -45,7 +45,10 @@ public interface RunService extends HandlerService, ClassRunner>, SciJavaService { - /** Executes the given class using the most appropriate handler. */ - void run(Class c) throws InvocationTargetException; + /** + * Executes the given class using the most appropriate handler, passing the + * given arguments to the execution. + */ + void run(Class c, Object... args) throws InvocationTargetException; } From cd3a2e493a36a3fec4f34668ba16a4bb57514c1f Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 29 Feb 2016 14:46:55 -0600 Subject: [PATCH 0172/1208] ModuleService: add getModuleById method This looks up Identifiable ModuleInfos by their identifiers. Migrated from the ModuleUtils class of the imagej/imagej-omero project. --- .../org/scijava/module/DefaultModuleService.java | 12 ++++++++++++ src/main/java/org/scijava/module/ModuleService.java | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/src/main/java/org/scijava/module/DefaultModuleService.java b/src/main/java/org/scijava/module/DefaultModuleService.java index cee5be523..67b1a1907 100644 --- a/src/main/java/org/scijava/module/DefaultModuleService.java +++ b/src/main/java/org/scijava/module/DefaultModuleService.java @@ -41,6 +41,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import org.scijava.Identifiable; import org.scijava.MenuPath; import org.scijava.Priority; import org.scijava.convert.ConvertService; @@ -140,6 +141,17 @@ public List getModules() { return moduleIndex.getAll(); } + @Override + public ModuleInfo getModuleById(final String id) { + // TODO: Cache identifiers in a hash? + for (final ModuleInfo info : getModules()) { + if (!(info instanceof Identifiable)) continue; + final String infoID = ((Identifiable) info).getIdentifier(); + if (id.equals(infoID)) return info; + } + return null; + } + @Override public ModuleInfo getModuleForAccelerator(final Accelerator acc) { for (final ModuleInfo info : getModules()) { diff --git a/src/main/java/org/scijava/module/ModuleService.java b/src/main/java/org/scijava/module/ModuleService.java index 21ee456cc..6d3613c9e 100644 --- a/src/main/java/org/scijava/module/ModuleService.java +++ b/src/main/java/org/scijava/module/ModuleService.java @@ -36,6 +36,7 @@ import java.util.Map; import java.util.concurrent.Future; +import org.scijava.Identifiable; import org.scijava.Prioritized; import org.scijava.input.Accelerator; import org.scijava.module.process.ModulePostprocessor; @@ -90,6 +91,14 @@ public interface ModuleService extends SciJavaService { /** Gets the list of available modules. */ List getModules(); + /** + * Gets the module with the given identifier string. + * + * @param id The identifier string corresponding to the desired module. + * @return The {@link Identifiable} module with the given identifier. + */ + ModuleInfo getModuleById(String id); + /** * Gets the module for a given keyboard shortcut. * From 8626a3cba2a071c8ea6d84434690e2c54ac5d1fe Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 13:52:41 -0500 Subject: [PATCH 0173/1208] Add a ParseService using SJEP This is a generalization of the code in ScriptInfo#parseAttrs(String). --- .../scijava/parse/DefaultParseService.java | 141 ++++++++++++++++++ src/main/java/org/scijava/parse/Item.java | 53 +++++++ src/main/java/org/scijava/parse/Items.java | 58 +++++++ .../java/org/scijava/parse/ParseService.java | 57 +++++++ .../java/org/scijava/ContextCreationTest.java | 1 + 5 files changed, 310 insertions(+) create mode 100644 src/main/java/org/scijava/parse/DefaultParseService.java create mode 100644 src/main/java/org/scijava/parse/Item.java create mode 100644 src/main/java/org/scijava/parse/Items.java create mode 100644 src/main/java/org/scijava/parse/ParseService.java diff --git a/src/main/java/org/scijava/parse/DefaultParseService.java b/src/main/java/org/scijava/parse/DefaultParseService.java new file mode 100644 index 000000000..4ea6fbaf2 --- /dev/null +++ b/src/main/java/org/scijava/parse/DefaultParseService.java @@ -0,0 +1,141 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.parse; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.scijava.plugin.Plugin; +import org.scijava.service.AbstractService; +import org.scijava.service.Service; +import org.scijava.sjep.Variable; +import org.scijava.sjep.eval.DefaultEvaluator; +import org.scijava.util.ObjectArray; + +/** + * Default service for parsing strings. + * + * @author Curtis Rueden + */ +@Plugin(type = Service.class) +public class DefaultParseService extends AbstractService implements + ParseService +{ + + @Override + public Items parse(final String arg) { + return new ItemsList(arg); + } + + // -- Helper classes -- + + /** + * {@link Items} implementation backed by the + * SciJava + * Expression Parser. + */ + private static class ItemsList extends ObjectArray implements Items { + + public ItemsList(final String arg) { + super(Item.class); + parseItems(arg); + } + + @Override + public Map asMap() { + final LinkedHashMap map = + new LinkedHashMap(); + for (final Item item : this) { + map.put(item.name(), item.value()); + } + return map; + } + + @Override + public boolean isMap() { + for (final Item item : this) { + if (item.name() == null) return false; + } + return true; + } + + @Override + public boolean isList() { + for (final Item item : this) { + if (item.name() != null) return false; + } + return true; + } + + private void parseItems(final String arg) { + final DefaultEvaluator e = new DefaultEvaluator(); + final Object result = e.evaluate("(" + arg + ")"); + if (result == null) { + throw new IllegalStateException("Error parsing string: '" + arg + "'"); + } + final List list; + if (result instanceof List) list = (List) result; + else list = Collections.singletonList(result); + + for (final Object o : list) { + final String name; + final Object value; + if (o instanceof Variable) { + final Variable v = (Variable) o; + name = v.getToken(); + value = e.value(v); + } + else { + name = null; + value = o; + } + add(new Item() { + + @Override + public String name() { + return name; + } + + @Override + public Object value() { + return value; + } + + }); + } + } + + } + +} diff --git a/src/main/java/org/scijava/parse/Item.java b/src/main/java/org/scijava/parse/Item.java new file mode 100644 index 000000000..311227ae7 --- /dev/null +++ b/src/main/java/org/scijava/parse/Item.java @@ -0,0 +1,53 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.parse; + +/** + * An item from the list of parsed items; i.e.: a name/value pair. + *

    + * NB: It is unfortunate that we cannot use {@code javafx.util.Pair}, but it is: + * A) Java 8; and B) part of JavaFX rather than core Java. + *

    + * + * @author Curtis Rueden + */ +public interface Item { + + /** + * Gets the name of the item, or {@code null} if unnamed (i.e., raw value with + * no equals sign). + */ + String name(); + + /** Gets the value of the item. */ + Object value(); +} diff --git a/src/main/java/org/scijava/parse/Items.java b/src/main/java/org/scijava/parse/Items.java new file mode 100644 index 000000000..af1187620 --- /dev/null +++ b/src/main/java/org/scijava/parse/Items.java @@ -0,0 +1,58 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.parse; + +import java.util.List; +import java.util.Map; + +/** + * An ordered list of items, some of which might be key/value pairs, and some of + * which might be raw values. + * + * @author Curtis Rueden + */ +public interface Items extends List { + + /** + * Gets the parsed items as a map. The map will have the same iteration + * order as the original list. + */ + Map asMap(); + + /** Returns true iff all items are named key/value pairs. */ + boolean isMap(); + + /** Returns true iff there are no named key/value pairs among the items. */ + boolean isList(); + +} + diff --git a/src/main/java/org/scijava/parse/ParseService.java b/src/main/java/org/scijava/parse/ParseService.java new file mode 100644 index 000000000..1b64b7d8a --- /dev/null +++ b/src/main/java/org/scijava/parse/ParseService.java @@ -0,0 +1,57 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.parse; + +import org.scijava.service.SciJavaService; + +/** + * Interface for service that parses strings. + * + * @author Curtis Rueden + */ +public interface ParseService extends SciJavaService { + + /** + * Parses a comma-delimited list of data elements. + *

    + * Some data elements might be {@code key=value} pairs, while others might be + * raw values (i.e., no equals sign). + *

    + * + * @param arg The string to parse. + * @return A parsed list of {@link Item}s. + * @throws IllegalArgumentException If the string does not conform to expected + * syntax. + */ + Items parse(String arg); + +} diff --git a/src/test/java/org/scijava/ContextCreationTest.java b/src/test/java/org/scijava/ContextCreationTest.java index e3955a6c7..abbab3c9b 100644 --- a/src/test/java/org/scijava/ContextCreationTest.java +++ b/src/test/java/org/scijava/ContextCreationTest.java @@ -102,6 +102,7 @@ public void testFull() { org.scijava.module.DefaultModuleService.class, org.scijava.object.DefaultObjectService.class, org.scijava.options.DefaultOptionsService.class, + org.scijava.parse.DefaultParseService.class, org.scijava.platform.DefaultPlatformService.class, org.scijava.plugin.DefaultPluginService.class, org.scijava.prefs.DefaultPrefService.class, From 5f82f77fe17a1d680aa5d4335eeff7138c4f7409 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 14:16:55 -0500 Subject: [PATCH 0174/1208] Add unit tests for ParseService --- .../org/scijava/parse/ParseServiceTest.java | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 src/test/java/org/scijava/parse/ParseServiceTest.java diff --git a/src/test/java/org/scijava/parse/ParseServiceTest.java b/src/test/java/org/scijava/parse/ParseServiceTest.java new file mode 100644 index 000000000..80894ef47 --- /dev/null +++ b/src/test/java/org/scijava/parse/ParseServiceTest.java @@ -0,0 +1,137 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.parse; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +import java.util.List; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.scijava.Context; + +/** + * Tests {@link ParseService}. + * + * @author Curtis Rueden + */ +public class ParseServiceTest { + + private ParseService parser; + + @Before + public void setUp() { + final Context context = new Context(ParseService.class); + parser = context.service(ParseService.class); + } + + @After + public void tearDown() { + parser.getContext().dispose(); + } + + /** Tests {@link ParseService#parse(String)}. */ + @Test + public void testEmpty() { + final Items items = parser.parse(""); + assertTrue(items.isEmpty()); + assertTrue(items.isList()); + assertTrue(items.isMap()); + assertMapCorrect(items); + } + + @Test + public void testList() { + final Items items = parser.parse("1,2,3,4,5"); + assertEquals(5, items.size()); + assertTrue(items.isList()); + assertFalse(items.isMap()); + assertSame(1, items.get(0).value()); + assertSame(2, items.get(1).value()); + assertSame(3, items.get(2).value()); + assertSame(4, items.get(3).value()); + assertSame(5, items.get(4).value()); + assertNull(items.get(0).name()); + assertNull(items.get(1).name()); + assertNull(items.get(2).name()); + assertNull(items.get(3).name()); + assertNull(items.get(4).name()); + } + + @Test + public void testMap() { + final Items items = parser.parse( + "foo='bar', animal='Quick brown fox', colors={'red', 'green', 'blue'}"); + assertEquals(3, items.size()); + assertFalse(items.isList()); + assertTrue(items.isMap()); + assertEquals("foo", items.get(0).name()); + assertEquals("bar", items.get(0).value()); + assertEquals("animal", items.get(1).name()); + assertEquals("Quick brown fox", items.get(1).value()); + assertEquals("colors", items.get(2).name()); + final Object colors = items.get(2).value(); + assertTrue(colors instanceof List); + final List colorsList = (List) colors; + assertEquals(3, colorsList.size()); + assertEquals("red", colorsList.get(0)); + assertEquals("green", colorsList.get(1)); + assertEquals("blue", colorsList.get(2)); + + assertMapCorrect(items); + } + + // -- Helper methods -- + + private void assertMapCorrect(final Items items) { + final Map map = items.asMap(); + assertEquals(items.size(), map.size()); + + // test that map contents match + for (final Item item : items) { + assertSame(item.value(), map.get(item.name())); + } + + // test that map iteration order is the same + int index = 0; + for (final Object value : map.values()) { + assertSame("" + index + ":", items.get(index++).value(), value); + } + } + +} From d94e0b8d6bfd750b174008b563206dd3164b6797 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 14:20:51 -0500 Subject: [PATCH 0175/1208] ScriptInfo: lean on the new ParseService --- .../scijava/script/DefaultScriptService.java | 4 ++ .../java/org/scijava/script/ScriptInfo.java | 49 +++---------------- 2 files changed, 12 insertions(+), 41 deletions(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index e1317cc58..db11308bd 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -60,6 +60,7 @@ import org.scijava.module.Module; import org.scijava.module.ModuleService; import org.scijava.object.LazyObjects; +import org.scijava.parse.ParseService; import org.scijava.plugin.AbstractSingletonService; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; @@ -92,6 +93,9 @@ public class DefaultScriptService extends @Parameter private CommandService commandService; + @Parameter + private ParseService parser; + @Parameter private LogService log; diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index fefcbb663..67c028b0a 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -39,7 +39,6 @@ import java.io.StringReader; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -58,9 +57,8 @@ import org.scijava.module.AbstractModuleInfo; import org.scijava.module.DefaultMutableModuleItem; import org.scijava.module.ModuleException; +import org.scijava.parse.ParseService; import org.scijava.plugin.Parameter; -import org.scijava.sjep.Variable; -import org.scijava.sjep.eval.DefaultEvaluator; import org.scijava.util.DigestUtils; import org.scijava.util.FileUtils; @@ -90,6 +88,9 @@ public class ScriptInfo extends AbstractModuleInfo implements Contextual { @Parameter private ScriptService scriptService; + @Parameter + private ParseService parser; + @Parameter private ConvertService convertService; @@ -346,13 +347,13 @@ private void parseParam(final String param) throws ScriptException { else { final String cutParam = param.substring(0, lParen) + param.substring(rParen + 1); - final String attrs = param.substring(lParen, rParen + 1); + final String attrs = param.substring(lParen + 1, rParen); parseParam(cutParam, parseAttrs(attrs)); } } private void parseParam(final String param, - final HashMap attrs) throws ScriptException + final Map attrs) throws ScriptException { final String[] tokens = param.trim().split("[ \t\n]+"); checkValid(tokens.length >= 1, param); @@ -376,42 +377,8 @@ private void parseParam(final String param, } /** Parses a comma-delimited list of {@code key=value} pairs into a map. */ - private HashMap parseAttrs(final String attrs) - throws ScriptException - { - // NB: Parse the attributes using the SciJava Expression Parser. - final DefaultEvaluator e = new DefaultEvaluator(); - try { - final Object result = e.evaluate(attrs); - if (result == null) throw new ScriptException("Unparseable attributes"); - final List list; - if (result instanceof List) list = (List) result; - else if (result instanceof Variable) { - list = Collections.singletonList(result); - } - else { - throw new ScriptException("Unexpected attributes type: " + - result.getClass().getName()); - } - - final HashMap attrsMap = new HashMap(); - for (final Object o : list) { - if (o instanceof Variable) { - final Variable v = (Variable) o; - attrsMap.put(v.getToken(), e.value(v)); - } - else { - throw new ScriptException("Invalid attribute: " + o); - } - } - return attrsMap; - } - catch (final IllegalArgumentException exc) { - final ScriptException se = new ScriptException( - "Error parsing attributes"); - se.initCause(exc); - throw se; - } + private Map parseAttrs(final String attrs) { + return parser.parse(attrs).asMap(); } private boolean isIOType(final String token) { From 09caa26220ae8dcbb061ce15520973755a37c410 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 14:26:52 -0500 Subject: [PATCH 0176/1208] DefaultScriptService: remove unneeded imports --- src/main/java/org/scijava/script/DefaultScriptService.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index db11308bd..cdb25e50c 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -45,8 +45,6 @@ import java.util.Map; import java.util.concurrent.Future; -import javax.script.ScriptEngineFactory; -import javax.script.ScriptEngineManager; import javax.script.ScriptException; import org.scijava.Context; From 36f32e63b341f93553fb8087cef1242c027719aa Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 14:31:13 -0500 Subject: [PATCH 0177/1208] Always use 'log' for LogService variable name In the vast majority of cases, when referring to a LogService, we name it log rather than logService. This does break the more general rule of referring to most service instances in full lower camel case, but in the case of the LogService, it makes the code more concise yet precise. --- .../java/org/scijava/command/console/RunArgument.java | 6 +++--- src/main/java/org/scijava/console/ConsoleUtils.java | 10 +++++----- .../java/org/scijava/script/ScriptLanguageIndex.java | 6 +++--- .../org/scijava/script/console/RunScriptArgument.java | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/scijava/command/console/RunArgument.java b/src/main/java/org/scijava/command/console/RunArgument.java index aca51500c..cfff0dd47 100644 --- a/src/main/java/org/scijava/command/console/RunArgument.java +++ b/src/main/java/org/scijava/command/console/RunArgument.java @@ -57,7 +57,7 @@ public class RunArgument extends AbstractConsoleArgument { private CommandService commandService; @Parameter - private LogService logService; + private LogService log; // -- Constructor -- @@ -100,12 +100,12 @@ private void run(final String commandToRun, final String optionString) { return; // TODO: parse the optionString a la ImageJ1 - final Map inputMap = ConsoleUtils.parseParameterString(optionString, info, logService); + final Map inputMap = ConsoleUtils.parseParameterString(optionString, info, log); try { commandService.run(info, true, inputMap).get(); } catch (final Exception exc) { - logService.error(exc); + log.error(exc); } } diff --git a/src/main/java/org/scijava/console/ConsoleUtils.java b/src/main/java/org/scijava/console/ConsoleUtils.java index 72ccde7fa..75fd39021 100644 --- a/src/main/java/org/scijava/console/ConsoleUtils.java +++ b/src/main/java/org/scijava/console/ConsoleUtils.java @@ -64,8 +64,8 @@ public static Map parseParameterString(final String parameterStr /** * @see #parseParameterString(String, ModuleInfo, LogService) */ - public static Map parseParameterString(final String parameterString, final LogService logService) { - return parseParameterString(parameterString, null, logService); + public static Map parseParameterString(final String parameterString, final LogService log) { + return parseParameterString(parameterString, null, log); } /** @@ -77,7 +77,7 @@ public static Map parseParameterString(final String parameterStr * * TODO reconcile with attribute parsing of {@link ScriptInfo} */ - public static Map parseParameterString(final String parameterString, final ModuleInfo info, final LogService logService) { + public static Map parseParameterString(final String parameterString, final ModuleInfo info, final LogService log) { final Map inputMap = new HashMap(); if (!parameterString.isEmpty()) { @@ -93,8 +93,8 @@ public static Map parseParameterString(final String parameterStr else if (inputs != null && inputs.hasNext() && split.length == 1) { inputMap.put(inputs.next().getName(), split[0]); } - else if (logService != null) - logService.error("Parameters must be formatted as a comma-separated list of key=value pairs"); + else if (log != null) + log.error("Parameters must be formatted as a comma-separated list of key=value pairs"); } } diff --git a/src/main/java/org/scijava/script/ScriptLanguageIndex.java b/src/main/java/org/scijava/script/ScriptLanguageIndex.java index 4563dbd97..f05329780 100644 --- a/src/main/java/org/scijava/script/ScriptLanguageIndex.java +++ b/src/main/java/org/scijava/script/ScriptLanguageIndex.java @@ -68,10 +68,10 @@ public ScriptLanguageIndex() { /** * Instantiates an index of the available script languages. * - * @param logService the log service for errors and warnings + * @param log the log service for errors and warnings */ - public ScriptLanguageIndex(final LogService logService) { - log = logService; + public ScriptLanguageIndex(final LogService log) { + this.log = log; } public boolean add(final ScriptEngineFactory factory, final boolean gently) { diff --git a/src/main/java/org/scijava/script/console/RunScriptArgument.java b/src/main/java/org/scijava/script/console/RunScriptArgument.java index df8c94204..c4e2f6d89 100644 --- a/src/main/java/org/scijava/script/console/RunScriptArgument.java +++ b/src/main/java/org/scijava/script/console/RunScriptArgument.java @@ -55,7 +55,7 @@ public class RunScriptArgument extends AbstractConsoleArgument { private ScriptService scriptService; @Parameter - private LogService logService; + private LogService log; // -- Constructor -- @@ -100,12 +100,12 @@ private void run(final String scriptToRun, final String paramString) { final ScriptInfo info = scriptService.getScript(script); - final Map inputMap = ConsoleUtils.parseParameterString(paramString, info, logService); + final Map inputMap = ConsoleUtils.parseParameterString(paramString, info, log); try { scriptService.run(info, true, inputMap).get(); } catch (final Exception exc) { - logService.error(exc); + log.error(exc); } } From 0931e1c0bbab737c85f106d11743cacce8d3bd36 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 14:35:03 -0500 Subject: [PATCH 0178/1208] Remove email address from @author tags ImageJ convention is to use only the name, without email address. The email address can be found in the pom.xml file and/or Git history. Philosophically, we really do not want to encourage anyone to email us directly about the code -- public communication channels are better. And pragmatically, putting the email address in source in an invitation for it to get out of sync. --- src/main/java/org/scijava/command/console/RunArgument.java | 2 +- src/main/java/org/scijava/console/ConsoleUtils.java | 2 +- src/main/java/org/scijava/console/HeadlessArgument.java | 2 +- src/main/java/org/scijava/convert/CastingConverter.java | 2 +- src/main/java/org/scijava/script/console/RunScriptArgument.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/command/console/RunArgument.java b/src/main/java/org/scijava/command/console/RunArgument.java index cfff0dd47..305bcd494 100644 --- a/src/main/java/org/scijava/command/console/RunArgument.java +++ b/src/main/java/org/scijava/command/console/RunArgument.java @@ -48,7 +48,7 @@ * * @author Curtis Rueden * @author Johannes Schindelin - * @author Mark Hiner hinerm at gmail.com + * @author Mark Hiner */ @Plugin(type = ConsoleArgument.class) public class RunArgument extends AbstractConsoleArgument { diff --git a/src/main/java/org/scijava/console/ConsoleUtils.java b/src/main/java/org/scijava/console/ConsoleUtils.java index 75fd39021..577881ae3 100644 --- a/src/main/java/org/scijava/console/ConsoleUtils.java +++ b/src/main/java/org/scijava/console/ConsoleUtils.java @@ -43,7 +43,7 @@ /** * Helper class for {@link ConsoleArgument}s. * - * @author Mark Hiner hinerm at gmail.com + * @author Mark Hiner */ public final class ConsoleUtils { diff --git a/src/main/java/org/scijava/console/HeadlessArgument.java b/src/main/java/org/scijava/console/HeadlessArgument.java index e075c9250..6f67331ce 100644 --- a/src/main/java/org/scijava/console/HeadlessArgument.java +++ b/src/main/java/org/scijava/console/HeadlessArgument.java @@ -42,7 +42,7 @@ * and the enclosing {@link Context} will not be used after the * {@link ConsoleService} argument processing is complete. * - * @author Mark Hiner hinerm at gmail.com + * @author Mark Hiner */ @Plugin(type = ConsoleArgument.class) public class HeadlessArgument extends AbstractConsoleArgument { diff --git a/src/main/java/org/scijava/convert/CastingConverter.java b/src/main/java/org/scijava/convert/CastingConverter.java index 395a06435..da6fe9d90 100644 --- a/src/main/java/org/scijava/convert/CastingConverter.java +++ b/src/main/java/org/scijava/convert/CastingConverter.java @@ -39,7 +39,7 @@ /** * Minimal {@link Converter} implementation to do direct casting. * - * @author Mark Hiner hinerm at gmail.com + * @author Mark Hiner */ @Plugin(type = Converter.class, priority = Priority.FIRST_PRIORITY) public class CastingConverter extends AbstractConverter { diff --git a/src/main/java/org/scijava/script/console/RunScriptArgument.java b/src/main/java/org/scijava/script/console/RunScriptArgument.java index c4e2f6d89..9627693d7 100644 --- a/src/main/java/org/scijava/script/console/RunScriptArgument.java +++ b/src/main/java/org/scijava/script/console/RunScriptArgument.java @@ -46,7 +46,7 @@ /** * {@link ConsoleArgument} for executing scripts directly. * - * @author Mark Hiner hinerm at gmail.com + * @author Mark Hiner */ @Plugin(type = ConsoleArgument.class) public class RunScriptArgument extends AbstractConsoleArgument { From 5bd5a4382ad63aeefafd1885fa909bd67adf986f Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 15:21:30 -0500 Subject: [PATCH 0179/1208] CommandRunner: do not add new command to the index I may regret this later. But it is much simpler and easier to understand if we just run the command class directly, rather than wrapping it in a new CommandInfo and then adding it to the PluginIndex. If we later decide to restore the PluginIndex-modifying behavior, let's do it in a nicer way where we have a method in CommandService that does this work, rather than needing to recapitulate its internals here. --- src/main/java/org/scijava/command/run/CommandRunner.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/command/run/CommandRunner.java b/src/main/java/org/scijava/command/run/CommandRunner.java index ec085ef96..d25529628 100644 --- a/src/main/java/org/scijava/command/run/CommandRunner.java +++ b/src/main/java/org/scijava/command/run/CommandRunner.java @@ -32,7 +32,6 @@ package org.scijava.command.run; import org.scijava.command.Command; -import org.scijava.command.CommandInfo; import org.scijava.command.CommandService; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; @@ -60,10 +59,7 @@ public class CommandRunner extends AbstractClassRunner { public void run(final Class c, final Object... args) { @SuppressWarnings("unchecked") final Class commandClass = (Class) c; - final Plugin annotation = c.getAnnotation(Plugin.class); - final CommandInfo info = new CommandInfo(commandClass, annotation); - pluginService.addPlugin(info); - commandService.run(info, true, args); + commandService.run(commandClass, true, args); } // -- Typed methods -- From 10791637a73bc6f16948d9f5f9d02619d476aa51 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 15:19:16 -0500 Subject: [PATCH 0180/1208] Rename ClassRunner to CodeRunner The name CodeRunner is more suitably general. See next commit. --- .../java/org/scijava/command/run/CommandRunner.java | 10 +++++----- src/main/java/org/scijava/main/run/MainRunner.java | 10 +++++----- ...bstractClassRunner.java => AbstractCodeRunner.java} | 6 +++--- .../scijava/run/{ClassRunner.java => CodeRunner.java} | 8 ++++---- src/main/java/org/scijava/run/DefaultRunService.java | 10 +++++----- src/main/java/org/scijava/run/RunService.java | 4 ++-- 6 files changed, 24 insertions(+), 24 deletions(-) rename src/main/java/org/scijava/run/{AbstractClassRunner.java => AbstractCodeRunner.java} (91%) rename src/main/java/org/scijava/run/{ClassRunner.java => CodeRunner.java} (89%) diff --git a/src/main/java/org/scijava/command/run/CommandRunner.java b/src/main/java/org/scijava/command/run/CommandRunner.java index d25529628..fcd081ca4 100644 --- a/src/main/java/org/scijava/command/run/CommandRunner.java +++ b/src/main/java/org/scijava/command/run/CommandRunner.java @@ -36,16 +36,16 @@ import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; import org.scijava.plugin.PluginService; -import org.scijava.run.AbstractClassRunner; -import org.scijava.run.ClassRunner; +import org.scijava.run.AbstractCodeRunner; +import org.scijava.run.CodeRunner; /** * Runs the given {@link Command} class. * * @author Curtis Rueden */ -@Plugin(type = ClassRunner.class) -public class CommandRunner extends AbstractClassRunner { +@Plugin(type = CodeRunner.class) +public class CommandRunner extends AbstractCodeRunner { @Parameter private PluginService pluginService; @@ -53,7 +53,7 @@ public class CommandRunner extends AbstractClassRunner { @Parameter private CommandService commandService; - // -- ClassRunner methods -- + // -- CodeRunner methods -- @Override public void run(final Class c, final Object... args) { diff --git a/src/main/java/org/scijava/main/run/MainRunner.java b/src/main/java/org/scijava/main/run/MainRunner.java index 36d2a6474..1c7296e2f 100644 --- a/src/main/java/org/scijava/main/run/MainRunner.java +++ b/src/main/java/org/scijava/main/run/MainRunner.java @@ -38,21 +38,21 @@ import org.scijava.log.LogService; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; -import org.scijava.run.AbstractClassRunner; -import org.scijava.run.ClassRunner; +import org.scijava.run.AbstractCodeRunner; +import org.scijava.run.CodeRunner; /** * Executes the given class's {@code main} method. * * @author Curtis Rueden */ -@Plugin(type = ClassRunner.class, priority = Priority.LOW_PRIORITY) -public class MainRunner extends AbstractClassRunner { +@Plugin(type = CodeRunner.class, priority = Priority.LOW_PRIORITY) +public class MainRunner extends AbstractCodeRunner { @Parameter(required = false) private LogService log; - // -- ClassRunner methods -- + // -- CodeRunner methods -- @Override public void run(final Class c, final Object... args) diff --git a/src/main/java/org/scijava/run/AbstractClassRunner.java b/src/main/java/org/scijava/run/AbstractCodeRunner.java similarity index 91% rename from src/main/java/org/scijava/run/AbstractClassRunner.java rename to src/main/java/org/scijava/run/AbstractCodeRunner.java index 1acd7d45d..116c7f187 100644 --- a/src/main/java/org/scijava/run/AbstractClassRunner.java +++ b/src/main/java/org/scijava/run/AbstractCodeRunner.java @@ -34,12 +34,12 @@ import org.scijava.plugin.AbstractHandlerPlugin; /** - * Abstract superclass of {@link ClassRunner} implementations. + * Abstract superclass of {@link CodeRunner} implementations. * * @author Curtis Rueden */ -public abstract class AbstractClassRunner extends - AbstractHandlerPlugin> implements ClassRunner +public abstract class AbstractCodeRunner extends + AbstractHandlerPlugin> implements CodeRunner { // -- Typed methods -- diff --git a/src/main/java/org/scijava/run/ClassRunner.java b/src/main/java/org/scijava/run/CodeRunner.java similarity index 89% rename from src/main/java/org/scijava/run/ClassRunner.java rename to src/main/java/org/scijava/run/CodeRunner.java index 79e279a1a..77888ec86 100644 --- a/src/main/java/org/scijava/run/ClassRunner.java +++ b/src/main/java/org/scijava/run/CodeRunner.java @@ -38,19 +38,19 @@ /** * A plugin which extends the {@link RunService}'s execution handling. A - * {@link ClassRunner} knows how to execute certain classes, beyond just Java's + * {@link CodeRunner} knows how to execute certain classes, beyond just Java's * usual {@code main} method. *

    * Class runner plugins discoverable at runtime must implement this interface * and be annotated with @{@link Plugin} with attribute {@link Plugin#type()} = - * {@link ClassRunner}.class. While it possible to create a class runner plugin + * {@link CodeRunner}.class. While it possible to create a class runner plugin * merely by implementing this interface, it is encouraged to instead extend - * {@link AbstractClassRunner}, for convenience. + * {@link AbstractCodeRunner}, for convenience. *

    * * @author Curtis Rueden */ -public interface ClassRunner extends HandlerPlugin> { +public interface CodeRunner extends HandlerPlugin> { /** Executes the given class, with the specified arguments. */ void run(Class c, Object... args) throws InvocationTargetException; diff --git a/src/main/java/org/scijava/run/DefaultRunService.java b/src/main/java/org/scijava/run/DefaultRunService.java index 06d76556f..7385b8684 100644 --- a/src/main/java/org/scijava/run/DefaultRunService.java +++ b/src/main/java/org/scijava/run/DefaultRunService.java @@ -40,13 +40,13 @@ import org.scijava.service.Service; /** - * Default service for managing available {@link ClassRunner} plugins. + * Default service for managing available {@link CodeRunner} plugins. * * @author Curtis Rueden */ @Plugin(type = Service.class) public class DefaultRunService extends - AbstractHandlerService, ClassRunner> implements RunService + AbstractHandlerService, CodeRunner> implements RunService { @Parameter @@ -58,7 +58,7 @@ public class DefaultRunService extends public void run(final Class c, final Object... args) throws InvocationTargetException { - for (final ClassRunner runner : getInstances()) { + for (final CodeRunner runner : getInstances()) { if (runner.supports(c)) { runner.run(c); return; @@ -70,8 +70,8 @@ public void run(final Class c, final Object... args) // -- PTService methods -- @Override - public Class getPluginType() { - return ClassRunner.class; + public Class getPluginType() { + return CodeRunner.class; } // -- Typed methods -- diff --git a/src/main/java/org/scijava/run/RunService.java b/src/main/java/org/scijava/run/RunService.java index 2dec65342..667f88e0b 100644 --- a/src/main/java/org/scijava/run/RunService.java +++ b/src/main/java/org/scijava/run/RunService.java @@ -37,12 +37,12 @@ import org.scijava.service.SciJavaService; /** - * Interface for service that manages available {@link ClassRunner} plugins. + * Interface for service that manages available {@link CodeRunner} plugins. * * @author Curtis Rueden */ public interface RunService extends - HandlerService, ClassRunner>, SciJavaService + HandlerService, CodeRunner>, SciJavaService { /** From 6328ca8851ad1b917b2b4ba71917a7496330860c Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 16:08:18 -0500 Subject: [PATCH 0181/1208] Rename MainRunner to MainCodeRunner This is for clarity and consistency. --- .../scijava/main/run/{MainRunner.java => MainCodeRunner.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/org/scijava/main/run/{MainRunner.java => MainCodeRunner.java} (98%) diff --git a/src/main/java/org/scijava/main/run/MainRunner.java b/src/main/java/org/scijava/main/run/MainCodeRunner.java similarity index 98% rename from src/main/java/org/scijava/main/run/MainRunner.java rename to src/main/java/org/scijava/main/run/MainCodeRunner.java index 1c7296e2f..611717431 100644 --- a/src/main/java/org/scijava/main/run/MainRunner.java +++ b/src/main/java/org/scijava/main/run/MainCodeRunner.java @@ -47,7 +47,7 @@ * @author Curtis Rueden */ @Plugin(type = CodeRunner.class, priority = Priority.LOW_PRIORITY) -public class MainRunner extends AbstractCodeRunner { +public class MainCodeRunner extends AbstractCodeRunner { @Parameter(required = false) private LogService log; From dd3271cd0c45d695a6396767104d8c79d12fce58 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 16:08:37 -0500 Subject: [PATCH 0182/1208] Rename CommandRunner to CommandCodeRunner This is for clarity and consistency. --- .../command/run/{CommandRunner.java => CommandCodeRunner.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/org/scijava/command/run/{CommandRunner.java => CommandCodeRunner.java} (97%) diff --git a/src/main/java/org/scijava/command/run/CommandRunner.java b/src/main/java/org/scijava/command/run/CommandCodeRunner.java similarity index 97% rename from src/main/java/org/scijava/command/run/CommandRunner.java rename to src/main/java/org/scijava/command/run/CommandCodeRunner.java index fcd081ca4..cb952787e 100644 --- a/src/main/java/org/scijava/command/run/CommandRunner.java +++ b/src/main/java/org/scijava/command/run/CommandCodeRunner.java @@ -45,7 +45,7 @@ * @author Curtis Rueden */ @Plugin(type = CodeRunner.class) -public class CommandRunner extends AbstractCodeRunner { +public class CommandCodeRunner extends AbstractCodeRunner { @Parameter private PluginService pluginService; From 4c46eddc448ea5501c033c5216f0aba0da5cb791 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 15:30:44 -0500 Subject: [PATCH 0183/1208] Generalize CodeRunner from Class to Object Sometimes we want to run Class objects. Sometimes String identifiers. Sometimes maybe other things. Rather than overtype things with a new interface, let's just use good ol' Object here, for flexibility. --- .../command/run/CommandCodeRunner.java | 21 ++++++++++---- .../org/scijava/main/run/MainCodeRunner.java | 19 ++++++++---- .../org/scijava/run/AbstractCodeRunner.java | 7 ++--- src/main/java/org/scijava/run/CodeRunner.java | 17 +++++++---- .../org/scijava/run/DefaultRunService.java | 29 ++++++++++++++----- src/main/java/org/scijava/run/RunService.java | 16 +++++++--- 6 files changed, 76 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/scijava/command/run/CommandCodeRunner.java b/src/main/java/org/scijava/command/run/CommandCodeRunner.java index cb952787e..f2a510802 100644 --- a/src/main/java/org/scijava/command/run/CommandCodeRunner.java +++ b/src/main/java/org/scijava/command/run/CommandCodeRunner.java @@ -56,17 +56,26 @@ public class CommandCodeRunner extends AbstractCodeRunner { // -- CodeRunner methods -- @Override - public void run(final Class c, final Object... args) { - @SuppressWarnings("unchecked") - final Class commandClass = (Class) c; - commandService.run(commandClass, true, args); + public void run(final Object code, final Object... args) { + commandService.run(getCommandClass(code), true, args); } // -- Typed methods -- @Override - public boolean supports(final Class c) { - return Command.class.isAssignableFrom(c); + public boolean supports(final Object code) { + return getCommandClass(code) != null; + } + + // -- Helper methods -- + + private Class getCommandClass(final Object code) { + if (!(code instanceof Class)) return null; + final Class c = (Class) code; + if (!Command.class.isAssignableFrom(c)) return null; + @SuppressWarnings("unchecked") + final Class commandClass = (Class) c; + return commandClass; } } diff --git a/src/main/java/org/scijava/main/run/MainCodeRunner.java b/src/main/java/org/scijava/main/run/MainCodeRunner.java index 611717431..80c24a052 100644 --- a/src/main/java/org/scijava/main/run/MainCodeRunner.java +++ b/src/main/java/org/scijava/main/run/MainCodeRunner.java @@ -40,6 +40,7 @@ import org.scijava.plugin.Plugin; import org.scijava.run.AbstractCodeRunner; import org.scijava.run.CodeRunner; +import org.scijava.util.ClassUtils; /** * Executes the given class's {@code main} method. @@ -55,12 +56,12 @@ public class MainCodeRunner extends AbstractCodeRunner { // -- CodeRunner methods -- @Override - public void run(final Class c, final Object... args) + public void run(final Object code, final Object... args) throws InvocationTargetException { final Object[] sArgs = stringify(args); try { - getMain(c).invoke(null, new Object[] { sArgs }); + getMain(code).invoke(null, new Object[] { sArgs }); } catch (final IllegalArgumentException exc) { throw new InvocationTargetException(exc); @@ -73,13 +74,15 @@ public void run(final Class c, final Object... args) // -- Typed methods -- @Override - public boolean supports(final Class c) { - return getMain(c) != null; + public boolean supports(final Object code) { + return getMain(code) != null; } // -- Helper methods -- - private Method getMain(final Class c) { + private Method getMain(final Object code) { + final Class c = getClass(code); + if (c == null) return null; try { return c.getMethod("main", String[].class); } @@ -93,6 +96,12 @@ private Method getMain(final Class c) { } } + private Class getClass(final Object code) { + if (code instanceof Class) return (Class) code; + if (code instanceof String) return ClassUtils.loadClass((String) code); + return null; + } + /** Ensures each element is a {@link String}. */ private String[] stringify(final Object... o) { final String[] s; diff --git a/src/main/java/org/scijava/run/AbstractCodeRunner.java b/src/main/java/org/scijava/run/AbstractCodeRunner.java index 116c7f187..fa1ce41d7 100644 --- a/src/main/java/org/scijava/run/AbstractCodeRunner.java +++ b/src/main/java/org/scijava/run/AbstractCodeRunner.java @@ -39,15 +39,14 @@ * @author Curtis Rueden */ public abstract class AbstractCodeRunner extends - AbstractHandlerPlugin> implements CodeRunner + AbstractHandlerPlugin implements CodeRunner { // -- Typed methods -- @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) - public Class> getType() { - return (Class) Class.class; + public Class getType() { + return Object.class; } } diff --git a/src/main/java/org/scijava/run/CodeRunner.java b/src/main/java/org/scijava/run/CodeRunner.java index 77888ec86..c5dab3c96 100644 --- a/src/main/java/org/scijava/run/CodeRunner.java +++ b/src/main/java/org/scijava/run/CodeRunner.java @@ -33,15 +33,17 @@ import java.lang.reflect.InvocationTargetException; +import org.scijava.Identifiable; import org.scijava.plugin.HandlerPlugin; import org.scijava.plugin.Plugin; /** * A plugin which extends the {@link RunService}'s execution handling. A - * {@link CodeRunner} knows how to execute certain classes, beyond just Java's - * usual {@code main} method. + * {@link CodeRunner} knows how to execute code of a certain form, such as the + * {@code main} method of a Java {@link Class}, or an {@link Identifiable} + * SciJava module. *

    - * Class runner plugins discoverable at runtime must implement this interface + * Code runner plugins discoverable at runtime must implement this interface * and be annotated with @{@link Plugin} with attribute {@link Plugin#type()} = * {@link CodeRunner}.class. While it possible to create a class runner plugin * merely by implementing this interface, it is encouraged to instead extend @@ -50,9 +52,12 @@ * * @author Curtis Rueden */ -public interface CodeRunner extends HandlerPlugin> { +public interface CodeRunner extends HandlerPlugin { - /** Executes the given class, with the specified arguments. */ - void run(Class c, Object... args) throws InvocationTargetException; + /** + * Executes the code identified by the given object, passing the + * specified arguments as inputs. + */ + void run(Object code, Object... args) throws InvocationTargetException; } diff --git a/src/main/java/org/scijava/run/DefaultRunService.java b/src/main/java/org/scijava/run/DefaultRunService.java index 7385b8684..cf6828f9a 100644 --- a/src/main/java/org/scijava/run/DefaultRunService.java +++ b/src/main/java/org/scijava/run/DefaultRunService.java @@ -32,6 +32,7 @@ package org.scijava.run; import java.lang.reflect.InvocationTargetException; +import java.util.Map; import org.scijava.log.LogService; import org.scijava.plugin.AbstractHandlerService; @@ -46,7 +47,7 @@ */ @Plugin(type = Service.class) public class DefaultRunService extends - AbstractHandlerService, CodeRunner> implements RunService + AbstractHandlerService implements RunService { @Parameter @@ -55,16 +56,29 @@ public class DefaultRunService extends // -- RunService methods -- @Override - public void run(final Class c, final Object... args) + public void run(final Object code, final Object... args) throws InvocationTargetException { for (final CodeRunner runner : getInstances()) { - if (runner.supports(c)) { - runner.run(c); + if (runner.supports(code)) { + runner.run(code, args); return; } } - throw new IllegalArgumentException("Unknown class type: " + c.getName()); + throw new IllegalArgumentException("Unknown code type: " + code); + } + + @Override + public void run(final Object code, final Map inputMap) + throws InvocationTargetException + { + for (final CodeRunner runner : getInstances()) { + if (runner.supports(code)) { + runner.run(code, inputMap); + return; + } + } + throw new IllegalArgumentException("Unknown code type: " + code); } // -- PTService methods -- @@ -77,9 +91,8 @@ public Class getPluginType() { // -- Typed methods -- @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) - public Class> getType() { - return (Class) Class.class; + public Class getType() { + return Object.class; } } diff --git a/src/main/java/org/scijava/run/RunService.java b/src/main/java/org/scijava/run/RunService.java index 667f88e0b..2a9b4db85 100644 --- a/src/main/java/org/scijava/run/RunService.java +++ b/src/main/java/org/scijava/run/RunService.java @@ -32,6 +32,7 @@ package org.scijava.run; import java.lang.reflect.InvocationTargetException; +import java.util.Map; import org.scijava.plugin.HandlerService; import org.scijava.service.SciJavaService; @@ -42,13 +43,20 @@ * @author Curtis Rueden */ public interface RunService extends - HandlerService, CodeRunner>, SciJavaService + HandlerService, SciJavaService { /** - * Executes the given class using the most appropriate handler, passing the - * given arguments to the execution. + * Executes the given code using the most appropriate handler, passing the + * specified arguments as inputs. */ - void run(Class c, Object... args) throws InvocationTargetException; + void run(Object code, Object... args) throws InvocationTargetException; + + /** + * Executes the given code using the most appropriate handler, passing the + * arguments in the specified map as inputs. + */ + void run(Object code, Map inputMap) + throws InvocationTargetException; } From 571c053902b4af1d4ef3996b48c7d61b883f2233 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 15:31:35 -0500 Subject: [PATCH 0184/1208] RunScriptArgument: throw exception for bogus input If a non-script is given, the supports method will return false. It is a precondition of run that supports return true; if not, we are justified in throwing an exception. --- .../org/scijava/script/console/RunScriptArgument.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/script/console/RunScriptArgument.java b/src/main/java/org/scijava/script/console/RunScriptArgument.java index 9627693d7..eab90b8c6 100644 --- a/src/main/java/org/scijava/script/console/RunScriptArgument.java +++ b/src/main/java/org/scijava/script/console/RunScriptArgument.java @@ -94,9 +94,11 @@ public boolean supports(final LinkedList args) { private void run(final String scriptToRun, final String paramString) { final File script = getScript(scriptToRun); - // couldn't find anything to run - if (script == null) - return; + if (script == null) { + // couldn't find anything to run + throw new UnsupportedOperationException(// + "Not a script: '" + scriptToRun + "'"); + } final ScriptInfo info = scriptService.getScript(script); From 5f51acf3c6ec9fe17f8c09084cd0e8b5aafafbf8 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 15:39:17 -0500 Subject: [PATCH 0185/1208] CodeRunner: add API for running with an input map --- .../org/scijava/command/run/CommandCodeRunner.java | 10 ++++++++++ src/main/java/org/scijava/main/run/MainCodeRunner.java | 9 +++++++++ src/main/java/org/scijava/run/CodeRunner.java | 8 ++++++++ 3 files changed, 27 insertions(+) diff --git a/src/main/java/org/scijava/command/run/CommandCodeRunner.java b/src/main/java/org/scijava/command/run/CommandCodeRunner.java index f2a510802..440cf8b68 100644 --- a/src/main/java/org/scijava/command/run/CommandCodeRunner.java +++ b/src/main/java/org/scijava/command/run/CommandCodeRunner.java @@ -31,6 +31,9 @@ package org.scijava.command.run; +import java.lang.reflect.InvocationTargetException; +import java.util.Map; + import org.scijava.command.Command; import org.scijava.command.CommandService; import org.scijava.plugin.Parameter; @@ -60,6 +63,13 @@ public void run(final Object code, final Object... args) { commandService.run(getCommandClass(code), true, args); } + @Override + public void run(final Object code, final Map inputMap) + throws InvocationTargetException + { + commandService.run(getCommandClass(code), true, inputMap); + } + // -- Typed methods -- @Override diff --git a/src/main/java/org/scijava/main/run/MainCodeRunner.java b/src/main/java/org/scijava/main/run/MainCodeRunner.java index 80c24a052..a34ad8861 100644 --- a/src/main/java/org/scijava/main/run/MainCodeRunner.java +++ b/src/main/java/org/scijava/main/run/MainCodeRunner.java @@ -33,6 +33,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.Map; import org.scijava.Priority; import org.scijava.log.LogService; @@ -71,6 +72,14 @@ public void run(final Object code, final Object... args) } } + @Override + public void run(final Object code, final Map inputMap) + throws InvocationTargetException + { + throw new UnsupportedOperationException( + "Cannot execute main method with a map of inputs"); + } + // -- Typed methods -- @Override diff --git a/src/main/java/org/scijava/run/CodeRunner.java b/src/main/java/org/scijava/run/CodeRunner.java index c5dab3c96..98129b975 100644 --- a/src/main/java/org/scijava/run/CodeRunner.java +++ b/src/main/java/org/scijava/run/CodeRunner.java @@ -32,6 +32,7 @@ package org.scijava.run; import java.lang.reflect.InvocationTargetException; +import java.util.Map; import org.scijava.Identifiable; import org.scijava.plugin.HandlerPlugin; @@ -60,4 +61,11 @@ public interface CodeRunner extends HandlerPlugin { */ void run(Object code, Object... args) throws InvocationTargetException; + /** + * Executes the code identified by the given object, passing the arguments in + * the specified map as inputs. + */ + void run(Object code, Map inputMap) + throws InvocationTargetException; + } From 5d2ed7cd773ec9ce82ca26ae17a8055541ef6332 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 15:55:27 -0500 Subject: [PATCH 0186/1208] Add a ConsoleArgument which uses the RunService Now that we have the RunService, all supported flavors of --run can (hopefully!) go through it, via additional CodeRunner plugins. --- .../org/scijava/run/console/RunArgument.java | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 src/main/java/org/scijava/run/console/RunArgument.java diff --git a/src/main/java/org/scijava/run/console/RunArgument.java b/src/main/java/org/scijava/run/console/RunArgument.java new file mode 100644 index 000000000..4ed621aaa --- /dev/null +++ b/src/main/java/org/scijava/run/console/RunArgument.java @@ -0,0 +1,104 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.run.console; + +import java.lang.reflect.InvocationTargetException; +import java.util.LinkedList; + +import org.scijava.console.AbstractConsoleArgument; +import org.scijava.console.ConsoleArgument; +import org.scijava.console.ConsoleUtils; +import org.scijava.log.LogService; +import org.scijava.parse.Items; +import org.scijava.parse.ParseService; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; +import org.scijava.run.RunService; + +/** + * Handles the {@code --run} command line argument. + * + * @author Curtis Rueden + */ +@Plugin(type = ConsoleArgument.class) +public class RunArgument extends AbstractConsoleArgument { + + @Parameter + private RunService runService; + + @Parameter + private ParseService parser; + + @Parameter + private LogService log; + + // -- Constructor -- + + public RunArgument() { + super(2, "--run"); + } + + // -- ConsoleArgument methods -- + + @Override + public void handle(final LinkedList args) { + if (!supports(args)) return; + + args.removeFirst(); // --run + final String code = args.removeFirst(); + final String arg = ConsoleUtils.hasParam(args) ? args.removeFirst() : null; + + final Items items = parser.parse(arg); + try { + if (arg == null) runService.run(code); + else if (items.isMap()) runService.run(code, items.asMap()); + else if (items.isList()) runService.run(code, items.toArray()); + else { + throw new IllegalArgumentException("Arguments are inconsistent. " + + "Please pass either a list of key/value pairs, " + + "or a list of values."); + } + } + catch (final InvocationTargetException exc) { + throw new RuntimeException(exc); + } + } + + // -- Typed methods -- + + @Override + public boolean supports(final LinkedList args) { + if (!super.supports(args)) return false; + return runService.supports(args.get(1)); + } + +} From 03e550418ba36ff795eeed204dd4369bcd273ac4 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 15:59:44 -0500 Subject: [PATCH 0187/1208] CommandRunner: remove unused service parameter --- src/main/java/org/scijava/command/run/CommandCodeRunner.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/org/scijava/command/run/CommandCodeRunner.java b/src/main/java/org/scijava/command/run/CommandCodeRunner.java index 440cf8b68..e96f46267 100644 --- a/src/main/java/org/scijava/command/run/CommandCodeRunner.java +++ b/src/main/java/org/scijava/command/run/CommandCodeRunner.java @@ -38,7 +38,6 @@ import org.scijava.command.CommandService; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; -import org.scijava.plugin.PluginService; import org.scijava.run.AbstractCodeRunner; import org.scijava.run.CodeRunner; @@ -50,9 +49,6 @@ @Plugin(type = CodeRunner.class) public class CommandCodeRunner extends AbstractCodeRunner { - @Parameter - private PluginService pluginService; - @Parameter private CommandService commandService; From 6453d2fe1c5813a5472bf322ca60751bfd3d0574 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 16:06:47 -0500 Subject: [PATCH 0188/1208] Add a CodeRunner for Identifiable SciJava modules --- .../scijava/module/run/ModuleCodeRunner.java | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/main/java/org/scijava/module/run/ModuleCodeRunner.java diff --git a/src/main/java/org/scijava/module/run/ModuleCodeRunner.java b/src/main/java/org/scijava/module/run/ModuleCodeRunner.java new file mode 100644 index 000000000..3b6cbac4d --- /dev/null +++ b/src/main/java/org/scijava/module/run/ModuleCodeRunner.java @@ -0,0 +1,86 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.module.run; + +import java.lang.reflect.InvocationTargetException; +import java.util.Map; + +import org.scijava.Identifiable; +import org.scijava.module.ModuleInfo; +import org.scijava.module.ModuleService; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; +import org.scijava.run.AbstractCodeRunner; +import org.scijava.run.CodeRunner; + +/** + * Runs the given {@link Identifiable} SciJava module. + * + * @author Curtis Rueden + * @see ModuleInfo + */ +@Plugin(type = CodeRunner.class) +public class ModuleCodeRunner extends AbstractCodeRunner { + + @Parameter + private ModuleService moduleService; + + // -- CodeRunner methods -- + + @Override + public void run(final Object code, final Object... args) { + moduleService.run(getModuleInfo(code), true, args); + } + + @Override + public void run(final Object code, final Map inputMap) + throws InvocationTargetException + { + moduleService.run(getModuleInfo(code), true, inputMap); + } + + // -- Typed methods -- + + @Override + public boolean supports(final Object code) { + return getModuleInfo(code) != null; + } + + // -- Helper methods -- + + private ModuleInfo getModuleInfo(final Object code) { + if (!(code instanceof String)) return null; + final String id = (String) code; + return moduleService.getModuleById(id); + } + +} From d5234858669a6963ed9ae9f7efa008c30550fcea Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 18:46:00 -0500 Subject: [PATCH 0189/1208] Wait for command or module execution to complete CodeRunner plugins should fully execute their associated code, blocking until execution is complete. --- .../command/run/CommandCodeRunner.java | 8 +++++--- .../scijava/module/run/ModuleCodeRunner.java | 8 +++++--- .../org/scijava/run/AbstractCodeRunner.java | 20 +++++++++++++++++++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/scijava/command/run/CommandCodeRunner.java b/src/main/java/org/scijava/command/run/CommandCodeRunner.java index e96f46267..dc1a12e2d 100644 --- a/src/main/java/org/scijava/command/run/CommandCodeRunner.java +++ b/src/main/java/org/scijava/command/run/CommandCodeRunner.java @@ -55,15 +55,17 @@ public class CommandCodeRunner extends AbstractCodeRunner { // -- CodeRunner methods -- @Override - public void run(final Object code, final Object... args) { - commandService.run(getCommandClass(code), true, args); + public void run(final Object code, final Object... args) + throws InvocationTargetException + { + waitFor(commandService.run(getCommandClass(code), true, args)); } @Override public void run(final Object code, final Map inputMap) throws InvocationTargetException { - commandService.run(getCommandClass(code), true, inputMap); + waitFor(commandService.run(getCommandClass(code), true, inputMap)); } // -- Typed methods -- diff --git a/src/main/java/org/scijava/module/run/ModuleCodeRunner.java b/src/main/java/org/scijava/module/run/ModuleCodeRunner.java index 3b6cbac4d..03f1a9f3c 100644 --- a/src/main/java/org/scijava/module/run/ModuleCodeRunner.java +++ b/src/main/java/org/scijava/module/run/ModuleCodeRunner.java @@ -57,15 +57,17 @@ public class ModuleCodeRunner extends AbstractCodeRunner { // -- CodeRunner methods -- @Override - public void run(final Object code, final Object... args) { - moduleService.run(getModuleInfo(code), true, args); + public void run(final Object code, final Object... args) + throws InvocationTargetException + { + waitFor(moduleService.run(getModuleInfo(code), true, args)); } @Override public void run(final Object code, final Map inputMap) throws InvocationTargetException { - moduleService.run(getModuleInfo(code), true, inputMap); + waitFor(moduleService.run(getModuleInfo(code), true, inputMap)); } // -- Typed methods -- diff --git a/src/main/java/org/scijava/run/AbstractCodeRunner.java b/src/main/java/org/scijava/run/AbstractCodeRunner.java index fa1ce41d7..ce118eab4 100644 --- a/src/main/java/org/scijava/run/AbstractCodeRunner.java +++ b/src/main/java/org/scijava/run/AbstractCodeRunner.java @@ -31,6 +31,10 @@ package org.scijava.run; +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + import org.scijava.plugin.AbstractHandlerPlugin; /** @@ -49,4 +53,20 @@ public Class getType() { return Object.class; } + // -- Internal methods -- + + protected T waitFor(final Future future) + throws InvocationTargetException + { + try { + return future.get(); + } + catch (final InterruptedException exc) { + throw new InvocationTargetException(exc); + } + catch (final ExecutionException exc) { + throw new InvocationTargetException(exc); + } + } + } From fdbfce3117b61cb9c41a72d12d7cb376e755c092 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 18:47:50 -0500 Subject: [PATCH 0190/1208] Add a CodeRunner plugin that executes scripts --- .../scijava/script/run/ScriptCodeRunner.java | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 src/main/java/org/scijava/script/run/ScriptCodeRunner.java diff --git a/src/main/java/org/scijava/script/run/ScriptCodeRunner.java b/src/main/java/org/scijava/script/run/ScriptCodeRunner.java new file mode 100644 index 000000000..da6f4cd07 --- /dev/null +++ b/src/main/java/org/scijava/script/run/ScriptCodeRunner.java @@ -0,0 +1,112 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.script.run; + +import java.io.File; +import java.io.FileNotFoundException; +import java.lang.reflect.InvocationTargetException; +import java.util.Map; + +import javax.script.ScriptException; + +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; +import org.scijava.run.AbstractCodeRunner; +import org.scijava.run.CodeRunner; +import org.scijava.script.ScriptService; + +/** + * Runs the given script. + * + * @author Curtis Rueden + * @author Mark Hiner + */ +@Plugin(type = CodeRunner.class) +public class ScriptCodeRunner extends AbstractCodeRunner { + + @Parameter + private ScriptService scriptService; + + // -- CodeRunner methods -- + + @Override + public void run(final Object code, final Object... args) + throws InvocationTargetException + { + try { + waitFor(scriptService.run(getScript(code), true, args)); + } + catch (final FileNotFoundException exc) { + throw new InvocationTargetException(exc); + } + catch (final ScriptException exc) { + throw new InvocationTargetException(exc); + } + } + + @Override + public void run(final Object code, final Map inputMap) + throws InvocationTargetException + { + try { + waitFor(scriptService.run(getScript(code), true, inputMap)); + } + catch (final FileNotFoundException exc) { + throw new InvocationTargetException(exc); + } + catch (final ScriptException exc) { + throw new InvocationTargetException(exc); + } + } + + // -- Typed methods -- + + @Override + public boolean supports(final Object code) { + return getScript(code) != null; + } + + // -- Helper methods -- + + private File getScript(final Object code) { + final File scriptFile; + if (code instanceof File) scriptFile = (File) code; + else if (code instanceof String) scriptFile = new File((String) code); + else return null; + + if (!scriptFile.exists()) return null; + if (!scriptService.canHandleFile(scriptFile)) return null; + + return scriptFile; + } + +} From b02aee7ea5a9adbb0b8fcba9a89183276475326a Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 19:01:01 -0500 Subject: [PATCH 0191/1208] CommandCodeRunner: allow running commands by title The soon-to-be-deprecated org.scijava.command.console.RunArgument supports that, so we need to keep supporting it here, too. --- .../command/run/CommandCodeRunner.java | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/command/run/CommandCodeRunner.java b/src/main/java/org/scijava/command/run/CommandCodeRunner.java index dc1a12e2d..40b34de68 100644 --- a/src/main/java/org/scijava/command/run/CommandCodeRunner.java +++ b/src/main/java/org/scijava/command/run/CommandCodeRunner.java @@ -35,6 +35,7 @@ import java.util.Map; import org.scijava.command.Command; +import org.scijava.command.CommandInfo; import org.scijava.command.CommandService; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; @@ -58,21 +59,29 @@ public class CommandCodeRunner extends AbstractCodeRunner { public void run(final Object code, final Object... args) throws InvocationTargetException { - waitFor(commandService.run(getCommandClass(code), true, args)); + final Class c = getCommandClass(code); + if (c != null) waitFor(commandService.run(c, true, args)); + + final CommandInfo info = getCommandInfo(code); + if (info != null) waitFor(commandService.run(info, true, args)); } @Override public void run(final Object code, final Map inputMap) throws InvocationTargetException { - waitFor(commandService.run(getCommandClass(code), true, inputMap)); + final Class c = getCommandClass(code); + if (c != null) waitFor(commandService.run(c, true, inputMap)); + + final CommandInfo info = getCommandInfo(code); + if (info != null) waitFor(commandService.run(info, true, inputMap)); } // -- Typed methods -- @Override public boolean supports(final Object code) { - return getCommandClass(code) != null; + return getCommandClass(code) != null || getCommandInfo(code) != null; } // -- Helper methods -- @@ -86,4 +95,19 @@ private Class getCommandClass(final Object code) { return commandClass; } + private CommandInfo getCommandInfo(final Object code) { + if (!(code instanceof String)) return null; + final String command = (String) code; + + final CommandInfo info = commandService.getCommand(command); + if (info != null) return info; + + // command was not a class name; search for command by title instead + for (final CommandInfo ci : commandService.getCommands()) { + if (command.equals(ci.getTitle())) return ci; + } + + return null; + } + } From ea4748f148837821a31dcb3846ed2188806a0163 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 17:03:50 -0500 Subject: [PATCH 0192/1208] Deprecate the "--class" CLI flag The "--run" support has been generalized now, such that continuing to support this specialization is more trouble than it is worth. --- .../org/scijava/command/console/RunArgument.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/scijava/command/console/RunArgument.java b/src/main/java/org/scijava/command/console/RunArgument.java index 305bcd494..26924fa0d 100644 --- a/src/main/java/org/scijava/command/console/RunArgument.java +++ b/src/main/java/org/scijava/command/console/RunArgument.java @@ -44,12 +44,9 @@ import org.scijava.plugin.Plugin; /** - * Handles the {@code --run} command line argument. - * - * @author Curtis Rueden - * @author Johannes Schindelin - * @author Mark Hiner + * @deprecated Use {@link org.scijava.run.console.RunArgument} instead. */ +@Deprecated @Plugin(type = ConsoleArgument.class) public class RunArgument extends AbstractConsoleArgument { @@ -62,7 +59,7 @@ public class RunArgument extends AbstractConsoleArgument { // -- Constructor -- public RunArgument() { - super(2, "--run", "--class"); + super(2, "--class"); } // -- ConsoleArgument methods -- @@ -72,7 +69,10 @@ public void handle(final LinkedList args) { if (!supports(args)) return; - args.removeFirst(); // --run + log.warn("The --class flag is deprecated, and will\n" + + "be removed in a future release. Use --run instead."); + + args.removeFirst(); // --class final String commandToRun = args.removeFirst(); final String paramString = ConsoleUtils.hasParam(args) ? args.removeFirst() : ""; From 3d02bc86e3b6f886651f2e3b3c4d82ee1c3c84fb Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 19:53:59 -0500 Subject: [PATCH 0193/1208] Deprecate the "--script" CLI flag The "--run" support has been generalized now, such that continuing to support this specialization is more trouble than it is worth. --- .../scijava/script/console/RunScriptArgument.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/script/console/RunScriptArgument.java b/src/main/java/org/scijava/script/console/RunScriptArgument.java index eab90b8c6..0bc8347c1 100644 --- a/src/main/java/org/scijava/script/console/RunScriptArgument.java +++ b/src/main/java/org/scijava/script/console/RunScriptArgument.java @@ -44,10 +44,9 @@ import org.scijava.script.ScriptService; /** - * {@link ConsoleArgument} for executing scripts directly. - * - * @author Mark Hiner + * @deprecated Use {@link org.scijava.run.console.RunArgument} instead. */ +@Deprecated @Plugin(type = ConsoleArgument.class) public class RunScriptArgument extends AbstractConsoleArgument { @@ -60,7 +59,7 @@ public class RunScriptArgument extends AbstractConsoleArgument { // -- Constructor -- public RunScriptArgument() { - super(2, "--run", "--script"); + super(2, "--script"); } // -- ConsoleArgument methods -- @@ -70,7 +69,10 @@ public void handle(final LinkedList args) { if (!supports(args)) return; - args.removeFirst(); // --run + log.warn("The --script flag is deprecated, and will\n" + + "be removed in a future release. Use --run instead."); + + args.removeFirst(); // --script final String scriptToRun = args.removeFirst(); final String paramString = ConsoleUtils.hasParam(args) ? args.removeFirst() : ""; From aec9f92d3da02ea4136573f68d360fdc833415ad Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 20:29:50 -0500 Subject: [PATCH 0194/1208] Add unit tests for RunService --- .../java/org/scijava/run/RunServiceTest.java | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 src/test/java/org/scijava/run/RunServiceTest.java diff --git a/src/test/java/org/scijava/run/RunServiceTest.java b/src/test/java/org/scijava/run/RunServiceTest.java new file mode 100644 index 000000000..228eacb37 --- /dev/null +++ b/src/test/java/org/scijava/run/RunServiceTest.java @@ -0,0 +1,127 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.run; + +import static org.junit.Assert.assertEquals; + +import java.lang.reflect.InvocationTargetException; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.scijava.Context; +import org.scijava.plugin.Plugin; + +/** + * Tests {@link RunService}. + * + * @author Curtis Rueden + */ +public class RunServiceTest { + + private RunService runService; + + @Before + public void setUp() { + runService = new Context().service(RunService.class); + } + + @After + public void tearDown() { + runService.context().dispose(); + } + + /** Tests {@link RunService#run(Object, Object...)}. */ + @Test + public void testRunList() throws InvocationTargetException { + final StringBuilder sb = new StringBuilder(); + runService.run(sb, "foo", "bar", "fu bar"); + assertEquals("|foo|bar|fu bar|", sb.toString()); + } + + /** Tests {@link RunService#run(Object, Object...)}. */ + @Test + public void testRunMap() throws InvocationTargetException { + final StringBuilder sb = new StringBuilder(); + final Map inputMap = new LinkedHashMap(); + inputMap.put("foo", "bar"); + inputMap.put("animal", "quick brown fox"); + inputMap.put("number", 33); + runService.run(sb, inputMap); + assertEquals("|foo=bar|animal=quick brown fox|number=33|", sb.toString()); + } + + // -- Helper classes -- + + /** A {@link CodeRunner} that stringifies its arguments. */ + @Plugin(type = CodeRunner.class) + public static class StringRunner extends AbstractCodeRunner { + + @Override + public void run(final Object code, final Object... args) + throws InvocationTargetException + { + final StringBuilder sb = getStringBuilder(code); + sb.append("|"); + for (final Object arg : args) { + sb.append(arg); + sb.append("|"); + } + } + + @Override + public void run(final Object code, final Map inputMap) + throws InvocationTargetException + { + final StringBuilder sb = getStringBuilder(code); + sb.append("|"); + for (final String key : inputMap.keySet()) { + sb.append(key); + sb.append("="); + sb.append(inputMap.get(key)); + sb.append("|"); + } + } + + @Override + public boolean supports(final Object code) { + return getStringBuilder(code) != null; + } + + private StringBuilder getStringBuilder(final Object code) { + return code instanceof StringBuilder ? (StringBuilder) code : null; + } + } + +} From bfc0a60a97a804cce713bb8855f799493059a405 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 4 Apr 2016 20:50:47 -0500 Subject: [PATCH 0195/1208] Add unit tests for CodeRunner plugins (Well, not the ScriptCodeRunner. Testing that one is too annoying, at least for the moment.) --- .../command/run/CommandCodeRunnerTest.java | 136 +++++++++++++++++ .../scijava/main/run/MainCodeRunnerTest.java | 95 ++++++++++++ .../module/run/ModuleCodeRunnerTest.java | 137 ++++++++++++++++++ 3 files changed, 368 insertions(+) create mode 100644 src/test/java/org/scijava/command/run/CommandCodeRunnerTest.java create mode 100644 src/test/java/org/scijava/main/run/MainCodeRunnerTest.java create mode 100644 src/test/java/org/scijava/module/run/ModuleCodeRunnerTest.java diff --git a/src/test/java/org/scijava/command/run/CommandCodeRunnerTest.java b/src/test/java/org/scijava/command/run/CommandCodeRunnerTest.java new file mode 100644 index 000000000..8a1ed203b --- /dev/null +++ b/src/test/java/org/scijava/command/run/CommandCodeRunnerTest.java @@ -0,0 +1,136 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.command.run; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.scijava.Context; +import org.scijava.ItemIO; +import org.scijava.command.Command; +import org.scijava.command.CommandService; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; + +/** + * Tests {@link CommandCodeRunner}. + * + * @author Curtis Rueden + */ +public class CommandCodeRunnerTest { + + private Context context; + private CommandCodeRunner runner; + + @Before + public void setUp() { + context = new Context(CommandService.class); + runner = new CommandCodeRunner(); + context.inject(runner); + } + + @After + public void tearDown() { + context.dispose(); + } + + @Test + public void testRunList() throws InvocationTargetException { + final StringBuilder buffer = new StringBuilder(); + + runner.run(OpenSesame.class, "buffer", buffer); + assertEquals("Alakazam", buffer.toString()); + + runner.run(OpenSesame.class, "buffer", buffer, "magicWord", "Shazam"); + assertEquals("AlakazamShazam", buffer.toString()); + + runner.run("Open Sesame", "buffer", buffer, "magicWord", "Marzipan"); + assertEquals("AlakazamShazamMarzipan", buffer.toString()); + } + + @Test + public void testRunMap() throws InvocationTargetException { + final StringBuilder buffer = new StringBuilder(); + + final Map inputMap = new HashMap(); + inputMap.put("buffer", buffer); + + runner.run(OpenSesame.class, inputMap); + assertEquals("Alakazam", buffer.toString()); + + inputMap.put("magicWord", "Shazam"); + runner.run(OpenSesame.class, inputMap); + assertEquals("AlakazamShazam", buffer.toString()); + + inputMap.put("magicWord", "Marzipan"); + runner.run("Open Sesame", inputMap); + assertEquals("AlakazamShazamMarzipan", buffer.toString()); + } + + @Test + public void testSupports() { + assertTrue(runner.supports(OpenSesame.class)); + assertTrue(runner.supports(OpenSesame.class.getName())); + assertTrue(runner.supports("Open Sesame")); + + assertFalse(runner.supports(CommandCodeRunnerTest.class)); + assertFalse(runner.supports("Not an actual command")); + assertFalse(runner.supports(0)); + } + + // -- Helper methods -- + + @Plugin(type = Command.class, label = "Open Sesame") + public static class OpenSesame implements Command { + + @Parameter(type = ItemIO.BOTH) + private StringBuilder buffer; + + @Parameter(required = false, persist = false) + private String magicWord; + + @Override + public void run() { + buffer.append(magicWord == null ? "Alakazam" : magicWord); + } + + } + +} diff --git a/src/test/java/org/scijava/main/run/MainCodeRunnerTest.java b/src/test/java/org/scijava/main/run/MainCodeRunnerTest.java new file mode 100644 index 000000000..9814b758b --- /dev/null +++ b/src/test/java/org/scijava/main/run/MainCodeRunnerTest.java @@ -0,0 +1,95 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.main.run; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; + +import org.junit.Before; +import org.junit.Test; + +/** + * Tests {@link MainCodeRunner}. + * + * @author Curtis Rueden + */ +public class MainCodeRunnerTest { + + private MainCodeRunner runner; + + @Before + public void setUp() { + runner = new MainCodeRunner(); + } + + @Test + public void testRunList() throws InvocationTargetException { + runner.run(Counter.class); + assertEquals(Counter.counter, 0); + runner.run(Counter.class, "a"); + assertEquals(Counter.counter, 1); + runner.run(Counter.class, "b", "c"); + assertEquals(Counter.counter, 3); + runner.run(Counter.class, "d", "e", "f"); + assertEquals(Counter.counter, 6); + } + + @Test(expected = UnsupportedOperationException.class) + public void testRunMap() throws InvocationTargetException { + runner.run(Counter.class, new HashMap()); + } + + @Test + public void testSupports() { + assertTrue(runner.supports(Counter.class)); + assertTrue(runner.supports(Counter.class.getName())); + + assertFalse(runner.supports(getClass())); + assertFalse(runner.supports("Not an actual class")); + assertFalse(runner.supports(0)); + } + + // -- Helper classes -- + + public static class Counter { + + public static int counter; + + public static void main(final String[] args) { + counter += args.length; + } + } +} diff --git a/src/test/java/org/scijava/module/run/ModuleCodeRunnerTest.java b/src/test/java/org/scijava/module/run/ModuleCodeRunnerTest.java new file mode 100644 index 000000000..99dec327f --- /dev/null +++ b/src/test/java/org/scijava/module/run/ModuleCodeRunnerTest.java @@ -0,0 +1,137 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.module.run; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.scijava.Context; +import org.scijava.ItemIO; +import org.scijava.module.DefaultMutableModule; +import org.scijava.module.DefaultMutableModuleInfo; +import org.scijava.module.DefaultMutableModuleItem; +import org.scijava.module.ModuleService; + +/** + * Tests {@link ModuleCodeRunner}. + * + * @author Curtis Rueden + */ +public class ModuleCodeRunnerTest { + + private Context context; + private ModuleCodeRunner runner; + + @Before + public void setUp() { + context = new Context(ModuleService.class); + context.service(ModuleService.class).addModule(new AlphabetModuleInfo()); + runner = new ModuleCodeRunner(); + context.inject(runner); + } + + @After + public void tearDown() { + context.dispose(); + } + + @Test + public void testRunList() throws InvocationTargetException { + final StringBuilder sb = new StringBuilder(); + runner.run("module:" + AlphabetModule.class.getName(), // + "buffer", sb, "length", 3); + assertEquals("ABC", sb.toString()); + } + + @Test + public void testRunMap() throws InvocationTargetException { + final StringBuilder sb = new StringBuilder(); + final Map inputMap = new HashMap(); + inputMap.put("buffer", sb); + inputMap.put("length", 4); + runner.run("module:" + AlphabetModule.class.getName(), inputMap); + assertEquals("ABCD", sb.toString()); + } + + @Test + public void testSupports() { + assertTrue(runner.supports("module:" + AlphabetModule.class.getName())); + + assertFalse(runner.supports("module:" + getClass().getName())); + } + + // -- Helper classes -- + + /** A module that writes the alphabet into a buffer. */ + public static class AlphabetModule extends DefaultMutableModule { + + @Override + public AlphabetModuleInfo getInfo() { return new AlphabetModuleInfo(); } + + @Override + public void run() { + final StringBuilder sb = (StringBuilder) getInput("buffer"); + final int length = (Integer) getInput("length"); + sb.setLength(0); + for (int i = 0; i < length; i++) { + final char letter = (char) ('A' + i); + sb.append(letter); + } + } + } + + /** Module metadata for {@link AlphabetModule}. */ + public static class AlphabetModuleInfo extends DefaultMutableModuleInfo { + + public AlphabetModuleInfo() { + // So much fun to construct modules by hand! Who needs commands? + setModuleClass(AlphabetModule.class); + final DefaultMutableModuleItem bufferItem = + new DefaultMutableModuleItem(this, "buffer", + StringBuilder.class); + bufferItem.setIOType(ItemIO.BOTH); + addInput(bufferItem); + addInput(new DefaultMutableModuleItem(this, "length", + int.class)); + } + + } + +} From 001b3dd8a77ba865bd17e175215822ece2325458 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 5 Apr 2016 17:15:17 -0500 Subject: [PATCH 0196/1208] Move parameter logic to AbstractConsoleArgument The AbstractConsoleArgument already had a protected isFlag method; for consistently, let's just put single parameter extraction there too. --- .../scijava/console/AbstractConsoleArgument.java | 13 +++++++++++++ .../java/org/scijava/run/console/RunArgument.java | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/console/AbstractConsoleArgument.java b/src/main/java/org/scijava/console/AbstractConsoleArgument.java index 118a9dbe1..8c48af157 100644 --- a/src/main/java/org/scijava/console/AbstractConsoleArgument.java +++ b/src/main/java/org/scijava/console/AbstractConsoleArgument.java @@ -86,4 +86,17 @@ public Class> getType() { protected boolean isFlag(final LinkedList args) { return flags.isEmpty() || flags.contains(args.getFirst()); } + + /** + * If the next argument is an appropriate parameter to a + * {@link ConsoleArgument}, retrieves it; otherwise, returns null. + * + * @return The first argument of the given list, if it does not + * start with a {@code '-'} character; or null otherwise. + */ + protected String getParam(final LinkedList args) { + if (args.isEmpty()) return null; + final String arg = args.getFirst(); + return arg.startsWith("-") ? null : arg; + } } diff --git a/src/main/java/org/scijava/run/console/RunArgument.java b/src/main/java/org/scijava/run/console/RunArgument.java index 4ed621aaa..8897bf519 100644 --- a/src/main/java/org/scijava/run/console/RunArgument.java +++ b/src/main/java/org/scijava/run/console/RunArgument.java @@ -75,7 +75,7 @@ public void handle(final LinkedList args) { args.removeFirst(); // --run final String code = args.removeFirst(); - final String arg = ConsoleUtils.hasParam(args) ? args.removeFirst() : null; + final String arg = getParam(args); final Items items = parser.parse(arg); try { From b254d8e26647404394d3347d2e4c7ca352a2a69e Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 5 Apr 2016 17:16:15 -0500 Subject: [PATCH 0197/1208] Deprecate the ConsoleUtils utility class All of its needed functionality moved elsewhere. --- .../org/scijava/console/ConsoleUtils.java | 42 +++++++------------ 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/scijava/console/ConsoleUtils.java b/src/main/java/org/scijava/console/ConsoleUtils.java index 577881ae3..8c078fde4 100644 --- a/src/main/java/org/scijava/console/ConsoleUtils.java +++ b/src/main/java/org/scijava/console/ConsoleUtils.java @@ -39,44 +39,32 @@ import org.scijava.log.LogService; import org.scijava.module.ModuleInfo; import org.scijava.module.ModuleItem; +import org.scijava.parse.ParseService; -/** - * Helper class for {@link ConsoleArgument}s. - * - * @author Mark Hiner - */ +/** @deprecated Use alternatives instead (see individual method docs). */ +@Deprecated public final class ConsoleUtils { - /** - * @see #parseParameterString(String, ModuleInfo, LogService) - */ + /** @deprecated Use {@link ParseService} instead. */ + @Deprecated public static Map parseParameterString(final String parameterString) { return parseParameterString(parameterString, (CommandInfo)null); } - /** - * @see #parseParameterString(String, ModuleInfo, LogService) - */ + /** @deprecated Use {@link ParseService} instead. */ + @Deprecated public static Map parseParameterString(final String parameterString, final ModuleInfo info) { return parseParameterString(parameterString, info, null); } - /** - * @see #parseParameterString(String, ModuleInfo, LogService) - */ + /** @deprecated Use {@link ParseService} instead. */ + @Deprecated public static Map parseParameterString(final String parameterString, final LogService log) { return parseParameterString(parameterString, null, log); } - /** - * Helper method for turning a parameter string into a {@code Map} of - * key:value pairs. If a {@link ModuleInfo} is provided, the parameter - * string is assumed to be a comma-separated list of values, ordered - * according to the {@code ModuleInfo's} inputs. Otherwise, the parameter - * string is assumed to be a comma-separated list of "key=value" pairs. - * - * TODO reconcile with attribute parsing of {@link ScriptInfo} - */ + /** @deprecated Use {@link ParseService} instead. */ + @Deprecated public static Map parseParameterString(final String parameterString, final ModuleInfo info, final LogService log) { final Map inputMap = new HashMap(); @@ -104,12 +92,10 @@ else if (log != null) } /** - * Test if the next argument is an appropriate parameter to a - * {@link ConsoleArgument}. - * - * @return {@code true} if the first argument of the given list does not - * start with a {@code '-'} character. + * @deprecated Use {@link AbstractConsoleArgument#getParam(LinkedList)} + * instead. */ + @Deprecated public static boolean hasParam(final LinkedList args) { return !(args.isEmpty() || args.getFirst().startsWith("-")); } From 7b39b2e10a0132bef40c570ec2f769fda1827bfc Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 6 Apr 2016 09:15:57 -0500 Subject: [PATCH 0198/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 86a4aaaaa..7e7669c37 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.54.0-SNAPSHOT + 2.54.1-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From b917ce373841ad3e676594dbb315933bc0b21128 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 6 Apr 2016 10:30:11 -0500 Subject: [PATCH 0199/1208] Make pre- and post-processor plugins singletons They are now each managed by a SingletonService. And the ModuleService uses those services to obtain the instances. Closes #232. --- .../scijava/module/DefaultModuleService.java | 12 +++-- .../process/DefaultPostprocessorService.java | 54 +++++++++++++++++++ .../process/DefaultPreprocessorService.java | 54 +++++++++++++++++++ .../module/process/PostprocessorPlugin.java | 4 +- .../module/process/PostprocessorService.java | 45 ++++++++++++++++ .../module/process/PreprocessorPlugin.java | 4 +- .../module/process/PreprocessorService.java | 45 ++++++++++++++++ .../java/org/scijava/ContextCreationTest.java | 2 + 8 files changed, 212 insertions(+), 8 deletions(-) create mode 100644 src/main/java/org/scijava/module/process/DefaultPostprocessorService.java create mode 100644 src/main/java/org/scijava/module/process/DefaultPreprocessorService.java create mode 100644 src/main/java/org/scijava/module/process/PostprocessorService.java create mode 100644 src/main/java/org/scijava/module/process/PreprocessorService.java diff --git a/src/main/java/org/scijava/module/DefaultModuleService.java b/src/main/java/org/scijava/module/DefaultModuleService.java index 67b1a1907..f04fd5977 100644 --- a/src/main/java/org/scijava/module/DefaultModuleService.java +++ b/src/main/java/org/scijava/module/DefaultModuleService.java @@ -53,11 +53,12 @@ import org.scijava.module.process.ModulePostprocessor; import org.scijava.module.process.ModulePreprocessor; import org.scijava.module.process.PostprocessorPlugin; +import org.scijava.module.process.PostprocessorService; import org.scijava.module.process.PreprocessorPlugin; +import org.scijava.module.process.PreprocessorService; import org.scijava.object.ObjectService; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; -import org.scijava.plugin.PluginService; import org.scijava.prefs.PrefService; import org.scijava.service.AbstractService; import org.scijava.service.Service; @@ -84,7 +85,10 @@ public class DefaultModuleService extends AbstractService implements private EventService eventService; @Parameter - private PluginService pluginService; + private PreprocessorService preprocessorService; + + @Parameter + private PostprocessorService postprocessorService; @Parameter private ObjectService objectService; @@ -364,13 +368,13 @@ public void initialize() { /** Creates the preprocessor chain. */ private List pre(final boolean process) { if (!process) return null; - return pluginService.createInstancesOfType(PreprocessorPlugin.class); + return preprocessorService.getInstances(); } /** Creates the postprocessor chain. */ private List post(final boolean process) { if (!process) return null; - return pluginService.createInstancesOfType(PostprocessorPlugin.class); + return postprocessorService.getInstances(); } /** diff --git a/src/main/java/org/scijava/module/process/DefaultPostprocessorService.java b/src/main/java/org/scijava/module/process/DefaultPostprocessorService.java new file mode 100644 index 000000000..581c300da --- /dev/null +++ b/src/main/java/org/scijava/module/process/DefaultPostprocessorService.java @@ -0,0 +1,54 @@ +/* + * #%L + * SCIFIO library for reading and converting scientific file formats. + * %% + * Copyright (C) 2011 - 2015 Board of Regents of the University of + * Wisconsin-Madison + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.module.process; + +import org.scijava.plugin.AbstractSingletonService; +import org.scijava.plugin.Plugin; +import org.scijava.service.Service; + +/** + * Default service for managing available {@link PostprocessorPlugin}s. + * + * @author Curtis Rueden + */ +@Plugin(type = Service.class) +public class DefaultPostprocessorService extends + AbstractSingletonService implements PostprocessorService +{ + + // -- PTService methods -- + + @Override + public Class getPluginType() { + return PostprocessorPlugin.class; + } + +} diff --git a/src/main/java/org/scijava/module/process/DefaultPreprocessorService.java b/src/main/java/org/scijava/module/process/DefaultPreprocessorService.java new file mode 100644 index 000000000..05ff59eda --- /dev/null +++ b/src/main/java/org/scijava/module/process/DefaultPreprocessorService.java @@ -0,0 +1,54 @@ +/* + * #%L + * SCIFIO library for reading and converting scientific file formats. + * %% + * Copyright (C) 2011 - 2015 Board of Regents of the University of + * Wisconsin-Madison + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.module.process; + +import org.scijava.plugin.AbstractSingletonService; +import org.scijava.plugin.Plugin; +import org.scijava.service.Service; + +/** + * Default service for managing available {@link PreprocessorPlugin}s. + * + * @author Curtis Rueden + */ +@Plugin(type = Service.class) +public class DefaultPreprocessorService extends + AbstractSingletonService implements PreprocessorService +{ + + // -- PTService methods -- + + @Override + public Class getPluginType() { + return PreprocessorPlugin.class; + } + +} diff --git a/src/main/java/org/scijava/module/process/PostprocessorPlugin.java b/src/main/java/org/scijava/module/process/PostprocessorPlugin.java index 37bfbcd34..ef21ba10b 100644 --- a/src/main/java/org/scijava/module/process/PostprocessorPlugin.java +++ b/src/main/java/org/scijava/module/process/PostprocessorPlugin.java @@ -33,7 +33,7 @@ import org.scijava.Contextual; import org.scijava.plugin.Plugin; -import org.scijava.plugin.SciJavaPlugin; +import org.scijava.plugin.SingletonPlugin; /** * A postprocessor plugin defines a step that occurs immediately following the @@ -51,7 +51,7 @@ * @author Curtis Rueden * @see ModulePostprocessor */ -public interface PostprocessorPlugin extends SciJavaPlugin, Contextual, +public interface PostprocessorPlugin extends SingletonPlugin, Contextual, ModulePostprocessor { // PostprocessorPlugin is a module postprocessor, diff --git a/src/main/java/org/scijava/module/process/PostprocessorService.java b/src/main/java/org/scijava/module/process/PostprocessorService.java new file mode 100644 index 000000000..cf8552c5d --- /dev/null +++ b/src/main/java/org/scijava/module/process/PostprocessorService.java @@ -0,0 +1,45 @@ +/* + * #%L + * SCIFIO library for reading and converting scientific file formats. + * %% + * Copyright (C) 2011 - 2015 Board of Regents of the University of + * Wisconsin-Madison + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.module.process; + +import org.scijava.plugin.SingletonService; +import org.scijava.service.SciJavaService; + +/** + * Interface for service which manages available {@link PostprocessorPlugin}s. + * + * @author Curtis Rueden + */ +public interface PostprocessorService extends + SingletonService, SciJavaService +{ + // NB: No implementation needed. +} diff --git a/src/main/java/org/scijava/module/process/PreprocessorPlugin.java b/src/main/java/org/scijava/module/process/PreprocessorPlugin.java index 1fa632790..cb53fa9ae 100644 --- a/src/main/java/org/scijava/module/process/PreprocessorPlugin.java +++ b/src/main/java/org/scijava/module/process/PreprocessorPlugin.java @@ -33,7 +33,7 @@ import org.scijava.Contextual; import org.scijava.plugin.Plugin; -import org.scijava.plugin.SciJavaPlugin; +import org.scijava.plugin.SingletonPlugin; /** * A preprocessor plugin defines a step that occurs just prior to the actual @@ -51,7 +51,7 @@ * @author Curtis Rueden * @see ModulePreprocessor */ -public interface PreprocessorPlugin extends SciJavaPlugin, Contextual, +public interface PreprocessorPlugin extends SingletonPlugin, Contextual, ModulePreprocessor { // PreprocessorPlugin is a module preprocessor, diff --git a/src/main/java/org/scijava/module/process/PreprocessorService.java b/src/main/java/org/scijava/module/process/PreprocessorService.java new file mode 100644 index 000000000..b0792ddae --- /dev/null +++ b/src/main/java/org/scijava/module/process/PreprocessorService.java @@ -0,0 +1,45 @@ +/* + * #%L + * SCIFIO library for reading and converting scientific file formats. + * %% + * Copyright (C) 2011 - 2015 Board of Regents of the University of + * Wisconsin-Madison + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.module.process; + +import org.scijava.plugin.SingletonService; +import org.scijava.service.SciJavaService; + +/** + * Interface for service which manages available {@link PreprocessorPlugin}s. + * + * @author Curtis Rueden + */ +public interface PreprocessorService extends + SingletonService, SciJavaService +{ + // NB: No implementation needed. +} diff --git a/src/test/java/org/scijava/ContextCreationTest.java b/src/test/java/org/scijava/ContextCreationTest.java index abbab3c9b..da59f1d23 100644 --- a/src/test/java/org/scijava/ContextCreationTest.java +++ b/src/test/java/org/scijava/ContextCreationTest.java @@ -100,6 +100,8 @@ public void testFull() { org.scijava.main.DefaultMainService.class, org.scijava.menu.DefaultMenuService.class, org.scijava.module.DefaultModuleService.class, + org.scijava.module.process.DefaultPostprocessorService.class, + org.scijava.module.process.DefaultPreprocessorService.class, org.scijava.object.DefaultObjectService.class, org.scijava.options.DefaultOptionsService.class, org.scijava.parse.DefaultParseService.class, From 31df424de4f6c30cd49f8d2272ebb0c530bd877f Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 6 Apr 2016 15:38:53 -0500 Subject: [PATCH 0200/1208] Happy New Year 2016 --- LICENSE.txt | 2 +- .../java/org/scijava/convert/NumberConverters.java | 6 +++--- .../scijava/convert/NumberToBigDecimalConverter.java | 4 ++-- .../scijava/convert/NumberToBigIntegerConverter.java | 6 +++--- .../org/scijava/convert/NumberToDoubleConverter.java | 2 +- .../org/scijava/convert/NumberToFloatConverter.java | 4 ++-- .../org/scijava/convert/NumberToIntegerConverter.java | 4 ++-- .../org/scijava/convert/NumberToLongConverter.java | 4 ++-- .../org/scijava/convert/NumberToNumberConverter.java | 6 +++--- .../org/scijava/convert/NumberToShortConverter.java | 2 +- .../module/process/DefaultPostprocessorService.java | 11 ++++++----- .../module/process/DefaultPreprocessorService.java | 11 ++++++----- .../scijava/module/process/PostprocessorService.java | 11 ++++++----- .../scijava/module/process/PreprocessorService.java | 11 ++++++----- src/main/java/org/scijava/parse/ParseService.java | 4 ++-- src/main/java/org/scijava/script/ScriptREPL.java | 2 +- .../scijava/convert/AbstractNumberConverterTests.java | 6 +++--- .../convert/BigIntegerToBigDecimalConverterTest.java | 6 +++--- .../convert/ByteToBigDecimalConverterTest.java | 6 +++--- .../convert/ByteToBigIntegerConverterTest.java | 6 +++--- .../scijava/convert/ByteToDoubleConverterTest.java | 6 +++--- .../org/scijava/convert/ByteToFloatConverterTest.java | 6 +++--- .../scijava/convert/ByteToIntegerConverterTest.java | 6 +++--- .../org/scijava/convert/ByteToLongConverterTest.java | 6 +++--- .../org/scijava/convert/ByteToShortConverterTest.java | 6 +++--- .../convert/DoubleToBigDecimalConverterTest.java | 6 +++--- .../convert/FloatToBigDecimalConverterTest.java | 6 +++--- .../scijava/convert/FloatToDoubleConverterTest.java | 6 +++--- .../convert/IntegerToBigDecimalConverterTest.java | 6 +++--- .../convert/IntegerToBigIntegerConverterTest.java | 6 +++--- .../scijava/convert/IntegerToDoubleConverterTest.java | 6 +++--- .../scijava/convert/IntegerToLongConverterTest.java | 6 +++--- .../convert/LongToBigDecimalConverterTest.java | 6 +++--- .../convert/LongToBigIntegerConverterTest.java | 6 +++--- .../convert/ShortToBigDecimalConverterTest.java | 6 +++--- .../convert/ShortToBigIntegerConverterTest.java | 6 +++--- .../scijava/convert/ShortToDoubleConverterTest.java | 6 +++--- .../scijava/convert/ShortToFloatConverterTest.java | 6 +++--- .../scijava/convert/ShortToIntegerConverterTest.java | 6 +++--- .../org/scijava/convert/ShortToLongConverterTest.java | 6 +++--- src/test/java/org/scijava/parse/ParseServiceTest.java | 4 ++-- 41 files changed, 121 insertions(+), 117 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 242746407..4513c78b9 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2009 - 2015, Board of Regents of the University of +Copyright (c) 2009 - 2016, Board of Regents of the University of Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck Institute of Molecular Cell Biology and Genetics. All rights reserved. diff --git a/src/main/java/org/scijava/convert/NumberConverters.java b/src/main/java/org/scijava/convert/NumberConverters.java index c8dc7412c..678addc1c 100644 --- a/src/main/java/org/scijava/convert/NumberConverters.java +++ b/src/main/java/org/scijava/convert/NumberConverters.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/scijava/convert/NumberToBigDecimalConverter.java b/src/main/java/org/scijava/convert/NumberToBigDecimalConverter.java index b18178b1b..fb24c86f5 100644 --- a/src/main/java/org/scijava/convert/NumberToBigDecimalConverter.java +++ b/src/main/java/org/scijava/convert/NumberToBigDecimalConverter.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% @@ -52,4 +52,4 @@ public Class getOutputType() { return BigDecimal.class; } -} \ No newline at end of file +} diff --git a/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java b/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java index b8d0449e2..30825bebf 100644 --- a/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java +++ b/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/scijava/convert/NumberToDoubleConverter.java b/src/main/java/org/scijava/convert/NumberToDoubleConverter.java index 05fd1ce74..911959663 100644 --- a/src/main/java/org/scijava/convert/NumberToDoubleConverter.java +++ b/src/main/java/org/scijava/convert/NumberToDoubleConverter.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/convert/NumberToFloatConverter.java b/src/main/java/org/scijava/convert/NumberToFloatConverter.java index 368ab0bd9..ee3c9f46c 100644 --- a/src/main/java/org/scijava/convert/NumberToFloatConverter.java +++ b/src/main/java/org/scijava/convert/NumberToFloatConverter.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% @@ -48,4 +48,4 @@ public Class getOutputType() { return Float.class; } -} \ No newline at end of file +} diff --git a/src/main/java/org/scijava/convert/NumberToIntegerConverter.java b/src/main/java/org/scijava/convert/NumberToIntegerConverter.java index f16a48208..aef88f2ed 100644 --- a/src/main/java/org/scijava/convert/NumberToIntegerConverter.java +++ b/src/main/java/org/scijava/convert/NumberToIntegerConverter.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% @@ -48,4 +48,4 @@ public Class getOutputType() { return Integer.class; } -} \ No newline at end of file +} diff --git a/src/main/java/org/scijava/convert/NumberToLongConverter.java b/src/main/java/org/scijava/convert/NumberToLongConverter.java index 314db3b9e..d60844eaf 100644 --- a/src/main/java/org/scijava/convert/NumberToLongConverter.java +++ b/src/main/java/org/scijava/convert/NumberToLongConverter.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% @@ -48,4 +48,4 @@ public Class getOutputType() { return Long.class; } -} \ No newline at end of file +} diff --git a/src/main/java/org/scijava/convert/NumberToNumberConverter.java b/src/main/java/org/scijava/convert/NumberToNumberConverter.java index 8a41b1b3b..1f0436fef 100644 --- a/src/main/java/org/scijava/convert/NumberToNumberConverter.java +++ b/src/main/java/org/scijava/convert/NumberToNumberConverter.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/scijava/convert/NumberToShortConverter.java b/src/main/java/org/scijava/convert/NumberToShortConverter.java index 133b3cc80..b6fa2bcfd 100644 --- a/src/main/java/org/scijava/convert/NumberToShortConverter.java +++ b/src/main/java/org/scijava/convert/NumberToShortConverter.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/main/java/org/scijava/module/process/DefaultPostprocessorService.java b/src/main/java/org/scijava/module/process/DefaultPostprocessorService.java index 581c300da..beab91032 100644 --- a/src/main/java/org/scijava/module/process/DefaultPostprocessorService.java +++ b/src/main/java/org/scijava/module/process/DefaultPostprocessorService.java @@ -1,19 +1,20 @@ /* * #%L - * SCIFIO library for reading and converting scientific file formats. + * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2011 - 2015 Board of Regents of the University of - * Wisconsin-Madison + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/scijava/module/process/DefaultPreprocessorService.java b/src/main/java/org/scijava/module/process/DefaultPreprocessorService.java index 05ff59eda..39b95f79f 100644 --- a/src/main/java/org/scijava/module/process/DefaultPreprocessorService.java +++ b/src/main/java/org/scijava/module/process/DefaultPreprocessorService.java @@ -1,19 +1,20 @@ /* * #%L - * SCIFIO library for reading and converting scientific file formats. + * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2011 - 2015 Board of Regents of the University of - * Wisconsin-Madison + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/scijava/module/process/PostprocessorService.java b/src/main/java/org/scijava/module/process/PostprocessorService.java index cf8552c5d..26d7afb07 100644 --- a/src/main/java/org/scijava/module/process/PostprocessorService.java +++ b/src/main/java/org/scijava/module/process/PostprocessorService.java @@ -1,19 +1,20 @@ /* * #%L - * SCIFIO library for reading and converting scientific file formats. + * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2011 - 2015 Board of Regents of the University of - * Wisconsin-Madison + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/scijava/module/process/PreprocessorService.java b/src/main/java/org/scijava/module/process/PreprocessorService.java index b0792ddae..84580c7b0 100644 --- a/src/main/java/org/scijava/module/process/PreprocessorService.java +++ b/src/main/java/org/scijava/module/process/PreprocessorService.java @@ -1,19 +1,20 @@ /* * #%L - * SCIFIO library for reading and converting scientific file formats. + * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2011 - 2015 Board of Regents of the University of - * Wisconsin-Madison + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/scijava/parse/ParseService.java b/src/main/java/org/scijava/parse/ParseService.java index 1b64b7d8a..31e63d5c6 100644 --- a/src/main/java/org/scijava/parse/ParseService.java +++ b/src/main/java/org/scijava/parse/ParseService.java @@ -8,13 +8,13 @@ * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/scijava/script/ScriptREPL.java b/src/main/java/org/scijava/script/ScriptREPL.java index e3536bd97..c3ce836ac 100644 --- a/src/main/java/org/scijava/script/ScriptREPL.java +++ b/src/main/java/org/scijava/script/ScriptREPL.java @@ -2,7 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% diff --git a/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java b/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java index 854c99974..32618f0d9 100644 --- a/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java +++ b/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java index 8775bcf74..502104206 100644 --- a/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java index 137857f2b..4741a8c5d 100644 --- a/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java index b36aa1dd7..7cf5030e3 100644 --- a/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java b/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java index c8ce44631..0c398fac6 100644 --- a/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/ByteToFloatConverterTest.java b/src/test/java/org/scijava/convert/ByteToFloatConverterTest.java index be49e244b..846d4df75 100644 --- a/src/test/java/org/scijava/convert/ByteToFloatConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToFloatConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java b/src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java index 82e8bd95b..f3a3ad127 100644 --- a/src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/ByteToLongConverterTest.java b/src/test/java/org/scijava/convert/ByteToLongConverterTest.java index 6c14de3ef..5ab8a85c9 100644 --- a/src/test/java/org/scijava/convert/ByteToLongConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToLongConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/ByteToShortConverterTest.java b/src/test/java/org/scijava/convert/ByteToShortConverterTest.java index 4407bb916..8045395cb 100644 --- a/src/test/java/org/scijava/convert/ByteToShortConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToShortConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java index 4172e42a8..a8faeac1d 100644 --- a/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java index 8db1d49a4..ea2ce8f74 100644 --- a/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java b/src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java index 00bf08c86..f8632d524 100644 --- a/src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java +++ b/src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java index 6fd1f64ff..e56bec712 100644 --- a/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java index 21276deac..a5df04620 100644 --- a/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java b/src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java index 23f8db5ef..114246f17 100644 --- a/src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java +++ b/src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/IntegerToLongConverterTest.java b/src/test/java/org/scijava/convert/IntegerToLongConverterTest.java index eb6b7604e..489f3eeb1 100644 --- a/src/test/java/org/scijava/convert/IntegerToLongConverterTest.java +++ b/src/test/java/org/scijava/convert/IntegerToLongConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java index e28ea2cb1..2a874eb5c 100644 --- a/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java index 632f5deaa..98d432a10 100644 --- a/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java index 4d1c6caa2..12c1f0596 100644 --- a/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java index c920e5d51..ad166093f 100644 --- a/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java b/src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java index 0fdf6c6c3..585fa52a1 100644 --- a/src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/ShortToFloatConverterTest.java b/src/test/java/org/scijava/convert/ShortToFloatConverterTest.java index e9db0a38b..7c64a1b26 100644 --- a/src/test/java/org/scijava/convert/ShortToFloatConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToFloatConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java b/src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java index 24033528d..4d0b3d557 100644 --- a/src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/convert/ShortToLongConverterTest.java b/src/test/java/org/scijava/convert/ShortToLongConverterTest.java index c1586a412..a3162331c 100644 --- a/src/test/java/org/scijava/convert/ShortToLongConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToLongConverterTest.java @@ -2,19 +2,19 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of + * Copyright (C) 2009 - 2016 Board of Regents of the University of * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck * Institute of Molecular Cell Biology and Genetics. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/scijava/parse/ParseServiceTest.java b/src/test/java/org/scijava/parse/ParseServiceTest.java index 80894ef47..a125dfff8 100644 --- a/src/test/java/org/scijava/parse/ParseServiceTest.java +++ b/src/test/java/org/scijava/parse/ParseServiceTest.java @@ -8,13 +8,13 @@ * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE From d056704b15cd4e8c7139a6a3e87d634432f26ff0 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 6 Apr 2016 15:39:10 -0500 Subject: [PATCH 0201/1208] Add a ScriptEngine adapter This is similar to the AdaptedScriptLanguage, but for ScriptEngine. It will be used shortly by the scijava/scripting-scala project. --- pom.xml | 2 +- .../scijava/script/AdaptedScriptEngine.java | 140 ++++++++++++++++++ 2 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/scijava/script/AdaptedScriptEngine.java diff --git a/pom.xml b/pom.xml index 7e7669c37..f64763fa5 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.54.1-SNAPSHOT + 2.55.0-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. diff --git a/src/main/java/org/scijava/script/AdaptedScriptEngine.java b/src/main/java/org/scijava/script/AdaptedScriptEngine.java new file mode 100644 index 000000000..381b99017 --- /dev/null +++ b/src/main/java/org/scijava/script/AdaptedScriptEngine.java @@ -0,0 +1,140 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.script; + +import java.io.Reader; + +import javax.script.Bindings; +import javax.script.ScriptContext; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineFactory; +import javax.script.ScriptException; + +/** + * Abstract superclass for {@link ScriptEngine} implementations which adapt an + * existing {@link ScriptEngine}. + *

    + * This is useful for situations where a JSR-223-compliant script engine has + * been provided, but whose behavior we need to extend or tweak. + *

    + * + * @author Curtis Rueden + */ +public class AdaptedScriptEngine implements ScriptEngine { + + private final ScriptEngine engine; + + public AdaptedScriptEngine(final ScriptEngine engine) { + this.engine = engine; + } + + // -- ScriptEngine methods -- + + @Override + public Object eval(final String script, final ScriptContext context) + throws ScriptException + { + return engine.eval(script, context); + } + + @Override + public Object eval(final Reader reader, final ScriptContext context) + throws ScriptException + { + return engine.eval(reader, context); + } + + @Override + public Object eval(final String script) throws ScriptException { + return engine.eval(script); + } + + @Override + public Object eval(final Reader reader) throws ScriptException { + return engine.eval(reader); + } + + @Override + public Object eval(final String script, final Bindings n) + throws ScriptException + { + return engine.eval(script, n); + } + + @Override + public Object eval(final Reader reader, final Bindings n) + throws ScriptException + { + return engine.eval(reader, n); + } + + @Override + public void put(final String key, final Object value) { + engine.put(key, value); + } + + @Override + public Object get(final String key) { + return engine.get(key); + } + + @Override + public Bindings getBindings(final int scope) { + return engine.getBindings(scope); + } + + @Override + public void setBindings(final Bindings bindings, final int scope) { + engine.setBindings(bindings, scope); + } + + @Override + public Bindings createBindings() { + return engine.createBindings(); + } + + @Override + public ScriptContext getContext() { + return engine.getContext(); + } + + @Override + public void setContext(final ScriptContext context) { + engine.setContext(context); + } + + @Override + public ScriptEngineFactory getFactory() { + return engine.getFactory(); + } + +} From e3619bf8962798a4b2fc8ddcc844bd3d4961990c Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 6 Apr 2016 16:06:14 -0500 Subject: [PATCH 0202/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f64763fa5..6387ed173 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.55.0-SNAPSHOT + 2.55.1-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From e292f0099ca8a9ff67d51658171a425eb814f239 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 8 Apr 2016 08:16:01 -0500 Subject: [PATCH 0203/1208] PluginIndexTest: clean up the test contexts --- src/test/java/org/scijava/plugin/PluginIndexTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/java/org/scijava/plugin/PluginIndexTest.java b/src/test/java/org/scijava/plugin/PluginIndexTest.java index 04ffbd149..a29df6309 100644 --- a/src/test/java/org/scijava/plugin/PluginIndexTest.java +++ b/src/test/java/org/scijava/plugin/PluginIndexTest.java @@ -73,6 +73,8 @@ public void testGetPluginsOfClass() { final PluginInfo plugin = pluginService.getPlugin(FooBar.class); assertSame(testPlugin, plugin); + + context.dispose(); } /** @@ -102,6 +104,8 @@ public void testGetPluginsOfClassString() { final PluginInfo plugin = pluginService.getPlugin(fakeClass); assertSame(testPlugin, plugin); + + context.dispose(); } /** A dummy plugin for testing the plugin service. */ From 47607a690feab664fc58ef8110af117ab54bd0a9 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 8 Apr 2016 07:34:02 -0500 Subject: [PATCH 0204/1208] Add a feature to blacklist certain plugins Right now, it must be done using the scijava.plugin.blacklist system property, a colon-separated list of regexes defining plugins to ignore. If this idea works out well, we can expose the API such that the blacklist can be specified per context instead of globally. --- .../scijava/plugin/DefaultPluginFinder.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/main/java/org/scijava/plugin/DefaultPluginFinder.java b/src/main/java/org/scijava/plugin/DefaultPluginFinder.java index 5c5796e75..9f2c22424 100644 --- a/src/main/java/org/scijava/plugin/DefaultPluginFinder.java +++ b/src/main/java/org/scijava/plugin/DefaultPluginFinder.java @@ -31,8 +31,11 @@ package org.scijava.plugin; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.regex.Pattern; +import java.util.regex.PatternSyntaxException; import org.scijava.annotations.Index; import org.scijava.annotations.IndexItem; @@ -51,6 +54,8 @@ public class DefaultPluginFinder implements PluginFinder { /** Class loader to use when querying the annotation indexes. */ private final ClassLoader customClassLoader; + private final PluginBlacklist blacklist; + // -- Constructors -- public DefaultPluginFinder() { @@ -59,6 +64,7 @@ public DefaultPluginFinder() { public DefaultPluginFinder(final ClassLoader classLoader) { customClassLoader = classLoader; + blacklist = new SysPropBlacklist(); } // -- PluginFinder methods -- @@ -77,6 +83,7 @@ public HashMap findPlugins( // create a PluginInfo object for each item in the index for (final IndexItem item : annotationIndex) { + if (blacklist.contains(item.className())) continue; try { final PluginInfo info = createInfo(item, classLoader); plugins.add(info); @@ -109,4 +116,47 @@ private ClassLoader getClassLoader() { return Thread.currentThread().getContextClassLoader(); } + // -- Helper classes -- + + private interface PluginBlacklist { + boolean contains(String className); + } + + /** + * A blacklist defined by the {@code scijava.plugin.blacklist} system + * property, formatted as a colon-separated list of regexes. + *

    + * If a plugin class matches any of the regexes, it is excluded from the + * plugin index. + *

    + */ + private class SysPropBlacklist implements PluginBlacklist { + private final List patterns; + + public SysPropBlacklist() { + final String sysProp = System.getProperty("scijava.plugin.blacklist"); + final String[] regexes = // + sysProp == null ? new String[0] : sysProp.split(":"); + patterns = new ArrayList(regexes.length); + for (final String regex : regexes) { + try { + patterns.add(Pattern.compile(regex)); + } + catch (final PatternSyntaxException exc) { + // NB: Ignore this malformed pattern. + } + } + } + + // -- PluginBlacklist methods -- + + @Override + public boolean contains(final String className) { + for (final Pattern pattern : patterns) { + if (pattern.matcher(className).matches()) return true; + } + return false; + } + } + } From e7becba239a28c8d9aee392285214a870dc217ee Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 8 Apr 2016 08:16:24 -0500 Subject: [PATCH 0205/1208] Add tests for the plugin blacklisting feature --- .../org/scijava/plugin/PluginFinderTest.java | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/test/java/org/scijava/plugin/PluginFinderTest.java diff --git a/src/test/java/org/scijava/plugin/PluginFinderTest.java b/src/test/java/org/scijava/plugin/PluginFinderTest.java new file mode 100644 index 000000000..1c8df132f --- /dev/null +++ b/src/test/java/org/scijava/plugin/PluginFinderTest.java @@ -0,0 +1,78 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.plugin; + +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; + +import org.junit.Test; +import org.scijava.Context; + +/** + * Tests {@link PluginFinder}. + * + * @author Curtis Rueden + */ +public class PluginFinderTest { + + /** + * Tests that the {@code scijava.plugin.blacklist} system property works to + * exclude plugins from the index, even when they are on the classpath. + */ + @Test + public void testPluginBlacklistSystemProperty() { + // check that the plugin is there, normally + Context context = new Context(PluginService.class); + PluginService pluginService = context.service(PluginService.class); + PluginInfo plugin = // + pluginService.getPlugin(BlacklistedPlugin.class); + assertSame(BlacklistedPlugin.class.getName(), plugin.getClassName()); + context.dispose(); + + // blacklist the plugin, then check that it is absent + System.setProperty("scijava.plugin.blacklist", ".*BlacklistedPlugin"); + context = new Context(PluginService.class); + pluginService = context.service(PluginService.class); + plugin = pluginService.getPlugin(BlacklistedPlugin.class); + assertNull(plugin); + context.dispose(); + + // reset the system + System.getProperties().remove("scijava.plugin.blacklist"); + } + + @Plugin(type = SciJavaPlugin.class) + public static class BlacklistedPlugin implements SciJavaPlugin { + // NB: No implementation needed. + } + +} From 85cc2b5755ae064081ac5fe5d317873c65ee5323 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 8 Apr 2016 11:01:15 -0500 Subject: [PATCH 0206/1208] ScriptREPL: make evaluation errors less verbose When something goes wrong interpreting a line of code, let's just display the error message, not the whole stack trace, unless we are in debug mode. --- src/main/java/org/scijava/script/ScriptREPL.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/org/scijava/script/ScriptREPL.java b/src/main/java/org/scijava/script/ScriptREPL.java index c3ce836ac..4d0564a89 100644 --- a/src/main/java/org/scijava/script/ScriptREPL.java +++ b/src/main/java/org/scijava/script/ScriptREPL.java @@ -42,6 +42,7 @@ import java.util.List; import javax.script.Bindings; +import javax.script.ScriptException; import org.scijava.Context; import org.scijava.Gateway; @@ -154,7 +155,17 @@ public boolean evaluate(final String line) { out.println(s(result)); } } + catch (final ScriptException exc) { + // NB: Something went wrong interpreting the line of code. + // Let's just display the error message, unless we are in debug mode. + if (log.isDebug()) exc.printStackTrace(out); + else { + final String msg = exc.getMessage(); + out.println(msg == null ? exc.getClass().getName() : msg); + } + } catch (final Throwable exc) { + // NB: Something unusual went wrong. Dump the whole exception always. exc.printStackTrace(out); } } From 4b87b622b0089bdbaad98a39b9a6c61d70195c9e Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 8 Apr 2016 11:20:38 -0500 Subject: [PATCH 0207/1208] ScriptService: fix out-of-date javadoc As of f29650e3d52e06518809068de8786896e2a422b4, we no longer auto-wrap vanilla JSR-223 ScriptEngineFactory implementations available on the classpath. So let's not claim that we do in the javadoc. --- src/main/java/org/scijava/script/ScriptService.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptService.java b/src/main/java/org/scijava/script/ScriptService.java index a9f1f470e..3f016abd9 100644 --- a/src/main/java/org/scijava/script/ScriptService.java +++ b/src/main/java/org/scijava/script/ScriptService.java @@ -74,13 +74,9 @@ public interface ScriptService extends SingletonService, ScriptLanguageIndex getIndex(); /** - * Gets the available scripting languages, including wrapped - * {@link ScriptEngineFactory} instances available from the Java scripting - * framework itself. + * Gets the available scripting languages. *

    - * This method is similar to {@link #getInstances()}, except that - * {@link #getInstances()} only returns {@link ScriptLanguage} subclasses - * annotated with @{@link Plugin}. + * This method does the same thing as {@link #getInstances()}. *

    */ List getLanguages(); From a57b47816a34703c6a1f07ee70ee6ee8d517b78c Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 8 Apr 2016 13:17:37 -0500 Subject: [PATCH 0208/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6387ed173..00b62eb19 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.55.1-SNAPSHOT + 2.55.2-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From 2b6eb9b740c789adfae68f3d58a7d2ab4f3558d6 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 11 Apr 2016 09:40:57 -0500 Subject: [PATCH 0209/1208] POM: add ImageJ wiki URL for Kevin Mader --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 00b62eb19..2ad80e64b 100644 --- a/pom.xml +++ b/pom.xml @@ -91,6 +91,7 @@ Kevin Mader + http://imagej.net/User:Ksmader kmader From d03cc39ba2738d398e47d80d11003d191350d3b6 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 11 Apr 2016 16:25:29 -0500 Subject: [PATCH 0210/1208] Ensure all core services implement SciJavaService This commit also adds a test to prevent this issue in the future. --- src/main/java/org/scijava/app/AppService.java | 3 ++- src/main/java/org/scijava/convert/ConvertService.java | 4 +++- src/test/java/org/scijava/service/ServiceIndexTest.java | 9 +++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/app/AppService.java b/src/main/java/org/scijava/app/AppService.java index 8853b0d56..f7d00844a 100644 --- a/src/main/java/org/scijava/app/AppService.java +++ b/src/main/java/org/scijava/app/AppService.java @@ -34,13 +34,14 @@ import java.util.Map; import org.scijava.plugin.SingletonService; +import org.scijava.service.SciJavaService; /** * Interface for application-level functionality. * * @author Curtis Rueden */ -public interface AppService extends SingletonService { +public interface AppService extends SingletonService, SciJavaService { /** Gets the foremost application (the one with the highest priority). */ App getApp(); diff --git a/src/main/java/org/scijava/convert/ConvertService.java b/src/main/java/org/scijava/convert/ConvertService.java index adb219061..caf9d1d68 100644 --- a/src/main/java/org/scijava/convert/ConvertService.java +++ b/src/main/java/org/scijava/convert/ConvertService.java @@ -35,6 +35,7 @@ import java.util.Collection; import org.scijava.plugin.HandlerService; +import org.scijava.service.SciJavaService; /** * Service for converting between types using an extensible plugin: @@ -46,8 +47,9 @@ * @author Mark Hiner */ public interface ConvertService extends - HandlerService> + HandlerService>, SciJavaService { + /** * @see Converter#convert(Object, Type) */ diff --git a/src/test/java/org/scijava/service/ServiceIndexTest.java b/src/test/java/org/scijava/service/ServiceIndexTest.java index 7629ddcd3..0bae8801b 100644 --- a/src/test/java/org/scijava/service/ServiceIndexTest.java +++ b/src/test/java/org/scijava/service/ServiceIndexTest.java @@ -34,6 +34,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; import java.util.List; @@ -66,6 +67,14 @@ public void testGetAll() { assertSame(StderrLogService.class, all.get(3).getClass()); } + @Test + public void testMarkerInterfaces() { + final Context context = new Context(); + for (Service s : context.getServiceIndex().getAll()) { + assertTrue(s.getClass().getName(), s instanceof SciJavaService); + } + } + /** * Test the {@link ServiceIndex#getPrevService(Class, Class)} operation. */ From afab5fd2de2a499c9f4fde79c3410f59cd19ec92 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 13 Apr 2016 16:00:58 -0500 Subject: [PATCH 0211/1208] AbstractBasicDetails: add missing final keywords --- src/main/java/org/scijava/AbstractBasicDetails.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/AbstractBasicDetails.java b/src/main/java/org/scijava/AbstractBasicDetails.java index cfeae9f66..507665b1c 100644 --- a/src/main/java/org/scijava/AbstractBasicDetails.java +++ b/src/main/java/org/scijava/AbstractBasicDetails.java @@ -53,7 +53,7 @@ public abstract class AbstractBasicDetails implements BasicDetails { private String description; /** Table of extra key/value pairs. */ - private Map values = new HashMap(); + private final Map values = new HashMap(); // -- Object methods -- @@ -102,7 +102,7 @@ public void setDescription(final String description) { } @Override - public void set(String key, String value) { + public void set(final String key, final String value) { values.put(key, value); } From be41b8e2913fb5fc1f6059cbcc1dca1065a98f90 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 13 Apr 2016 16:02:02 -0500 Subject: [PATCH 0212/1208] ScriptInfo: support all attrs When an arbitrary key/value pair is given, we should set it as an attribute rather than throwing an exception. In Java, the way these are specified is rather verbose: @Parameter(attrs = { @Attr(name="foo", value="bar") }) private int value; But for scripts, it is now not only possible, but much more succinct: // @int value(foo="bar") Noticed by Gabriel Einsdorf. --- src/main/java/org/scijava/script/ScriptInfo.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index 67c028b0a..d23134478 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -399,7 +399,7 @@ private void addReturnValue() throws ScriptException { } private void addItem(final String name, final Class type, - final Map attrs) throws ScriptException + final Map attrs) { final DefaultMutableModuleItem item = new DefaultMutableModuleItem(this, name, type); @@ -412,7 +412,7 @@ private void addItem(final String name, final Class type, } private void assignAttribute(final DefaultMutableModuleItem item, - final String k, final Object v) throws ScriptException + final String k, final Object v) { // CTR: There must be an easier way to do this. // Just compile the thing using javac? Or parse via javascript, maybe? @@ -435,7 +435,7 @@ private void assignAttribute(final DefaultMutableModuleItem item, else if (is(k, "style")) item.setWidgetStyle(as(v, String.class)); else if (is(k, "visibility")) item.setVisibility(as(v, ItemVisibility.class)); else if (is(k, "value")) item.setDefaultValue(as(v, item.getType())); - else throw new ScriptException("Invalid attribute name: " + k); + else item.set(k, v.toString()); } /** Super terse comparison helper method. */ From 004bf6c24deb784b13b67c292225169de9b89d2d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 14 Apr 2016 08:59:58 -0500 Subject: [PATCH 0213/1208] ScriptInfoTest: test custom attribute population --- src/test/java/org/scijava/script/ScriptInfoTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/scijava/script/ScriptInfoTest.java b/src/test/java/org/scijava/script/ScriptInfoTest.java index 887b8d52b..664ea358c 100644 --- a/src/test/java/org/scijava/script/ScriptInfoTest.java +++ b/src/test/java/org/scijava/script/ScriptInfoTest.java @@ -142,7 +142,7 @@ public void testParameters() { "% @LogService(required = false) log\n" + // "% @int(label=\"Slider Value\", softMin=5, softMax=15, " + // "stepSize=3, value=11, style=\"slider\") sliderValue\n" + // - "% @String(persist = false, " + // + "% @String(persist = false, family='Carnivora', " + // "choices={'quick brown fox', 'lazy dog'}) animal\n" + // "% @BOTH java.lang.StringBuilder buffer"; @@ -164,6 +164,7 @@ public void testParameters() { Arrays.asList("quick brown fox", "lazy dog"); assertItem("animal", String.class, null, ItemIO.INPUT, true, false, null, null, null, null, null, null, null, null, animalChoices, animal); + assertEquals(animal.get("family"), "Carnivora"); // test custom attribute final ModuleItem buffer = info.getOutput("buffer"); assertItem("buffer", StringBuilder.class, null, ItemIO.BOTH, true, true, From 5b24cd50f960ee589cf9d97d826dadd187938a94 Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 20 Apr 2016 10:18:43 -0500 Subject: [PATCH 0214/1208] Revert "Make pre- and post-processor plugins singletons" This reverts commit b917ce373841ad3e676594dbb315933bc0b21128. These plugin instances are stateful as they are Cancelable, thus they should not be singletons. --- pom.xml | 2 +- .../scijava/module/DefaultModuleService.java | 12 ++-- .../process/DefaultPostprocessorService.java | 55 ------------------- .../process/DefaultPreprocessorService.java | 55 ------------------- .../module/process/PostprocessorPlugin.java | 4 +- .../module/process/PostprocessorService.java | 46 ---------------- .../module/process/PreprocessorPlugin.java | 4 +- .../module/process/PreprocessorService.java | 46 ---------------- .../java/org/scijava/ContextCreationTest.java | 2 - 9 files changed, 9 insertions(+), 217 deletions(-) delete mode 100644 src/main/java/org/scijava/module/process/DefaultPostprocessorService.java delete mode 100644 src/main/java/org/scijava/module/process/DefaultPreprocessorService.java delete mode 100644 src/main/java/org/scijava/module/process/PostprocessorService.java delete mode 100644 src/main/java/org/scijava/module/process/PreprocessorService.java diff --git a/pom.xml b/pom.xml index 2ad80e64b..efae373bf 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.55.2-SNAPSHOT + 2.56.0-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. diff --git a/src/main/java/org/scijava/module/DefaultModuleService.java b/src/main/java/org/scijava/module/DefaultModuleService.java index f04fd5977..67b1a1907 100644 --- a/src/main/java/org/scijava/module/DefaultModuleService.java +++ b/src/main/java/org/scijava/module/DefaultModuleService.java @@ -53,12 +53,11 @@ import org.scijava.module.process.ModulePostprocessor; import org.scijava.module.process.ModulePreprocessor; import org.scijava.module.process.PostprocessorPlugin; -import org.scijava.module.process.PostprocessorService; import org.scijava.module.process.PreprocessorPlugin; -import org.scijava.module.process.PreprocessorService; import org.scijava.object.ObjectService; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; +import org.scijava.plugin.PluginService; import org.scijava.prefs.PrefService; import org.scijava.service.AbstractService; import org.scijava.service.Service; @@ -85,10 +84,7 @@ public class DefaultModuleService extends AbstractService implements private EventService eventService; @Parameter - private PreprocessorService preprocessorService; - - @Parameter - private PostprocessorService postprocessorService; + private PluginService pluginService; @Parameter private ObjectService objectService; @@ -368,13 +364,13 @@ public void initialize() { /** Creates the preprocessor chain. */ private List pre(final boolean process) { if (!process) return null; - return preprocessorService.getInstances(); + return pluginService.createInstancesOfType(PreprocessorPlugin.class); } /** Creates the postprocessor chain. */ private List post(final boolean process) { if (!process) return null; - return postprocessorService.getInstances(); + return pluginService.createInstancesOfType(PostprocessorPlugin.class); } /** diff --git a/src/main/java/org/scijava/module/process/DefaultPostprocessorService.java b/src/main/java/org/scijava/module/process/DefaultPostprocessorService.java deleted file mode 100644 index beab91032..000000000 --- a/src/main/java/org/scijava/module/process/DefaultPostprocessorService.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * #%L - * SciJava Common shared library for SciJava software. - * %% - * Copyright (C) 2009 - 2016 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package org.scijava.module.process; - -import org.scijava.plugin.AbstractSingletonService; -import org.scijava.plugin.Plugin; -import org.scijava.service.Service; - -/** - * Default service for managing available {@link PostprocessorPlugin}s. - * - * @author Curtis Rueden - */ -@Plugin(type = Service.class) -public class DefaultPostprocessorService extends - AbstractSingletonService implements PostprocessorService -{ - - // -- PTService methods -- - - @Override - public Class getPluginType() { - return PostprocessorPlugin.class; - } - -} diff --git a/src/main/java/org/scijava/module/process/DefaultPreprocessorService.java b/src/main/java/org/scijava/module/process/DefaultPreprocessorService.java deleted file mode 100644 index 39b95f79f..000000000 --- a/src/main/java/org/scijava/module/process/DefaultPreprocessorService.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * #%L - * SciJava Common shared library for SciJava software. - * %% - * Copyright (C) 2009 - 2016 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package org.scijava.module.process; - -import org.scijava.plugin.AbstractSingletonService; -import org.scijava.plugin.Plugin; -import org.scijava.service.Service; - -/** - * Default service for managing available {@link PreprocessorPlugin}s. - * - * @author Curtis Rueden - */ -@Plugin(type = Service.class) -public class DefaultPreprocessorService extends - AbstractSingletonService implements PreprocessorService -{ - - // -- PTService methods -- - - @Override - public Class getPluginType() { - return PreprocessorPlugin.class; - } - -} diff --git a/src/main/java/org/scijava/module/process/PostprocessorPlugin.java b/src/main/java/org/scijava/module/process/PostprocessorPlugin.java index ef21ba10b..37bfbcd34 100644 --- a/src/main/java/org/scijava/module/process/PostprocessorPlugin.java +++ b/src/main/java/org/scijava/module/process/PostprocessorPlugin.java @@ -33,7 +33,7 @@ import org.scijava.Contextual; import org.scijava.plugin.Plugin; -import org.scijava.plugin.SingletonPlugin; +import org.scijava.plugin.SciJavaPlugin; /** * A postprocessor plugin defines a step that occurs immediately following the @@ -51,7 +51,7 @@ * @author Curtis Rueden * @see ModulePostprocessor */ -public interface PostprocessorPlugin extends SingletonPlugin, Contextual, +public interface PostprocessorPlugin extends SciJavaPlugin, Contextual, ModulePostprocessor { // PostprocessorPlugin is a module postprocessor, diff --git a/src/main/java/org/scijava/module/process/PostprocessorService.java b/src/main/java/org/scijava/module/process/PostprocessorService.java deleted file mode 100644 index 26d7afb07..000000000 --- a/src/main/java/org/scijava/module/process/PostprocessorService.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * #%L - * SciJava Common shared library for SciJava software. - * %% - * Copyright (C) 2009 - 2016 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package org.scijava.module.process; - -import org.scijava.plugin.SingletonService; -import org.scijava.service.SciJavaService; - -/** - * Interface for service which manages available {@link PostprocessorPlugin}s. - * - * @author Curtis Rueden - */ -public interface PostprocessorService extends - SingletonService, SciJavaService -{ - // NB: No implementation needed. -} diff --git a/src/main/java/org/scijava/module/process/PreprocessorPlugin.java b/src/main/java/org/scijava/module/process/PreprocessorPlugin.java index cb53fa9ae..1fa632790 100644 --- a/src/main/java/org/scijava/module/process/PreprocessorPlugin.java +++ b/src/main/java/org/scijava/module/process/PreprocessorPlugin.java @@ -33,7 +33,7 @@ import org.scijava.Contextual; import org.scijava.plugin.Plugin; -import org.scijava.plugin.SingletonPlugin; +import org.scijava.plugin.SciJavaPlugin; /** * A preprocessor plugin defines a step that occurs just prior to the actual @@ -51,7 +51,7 @@ * @author Curtis Rueden * @see ModulePreprocessor */ -public interface PreprocessorPlugin extends SingletonPlugin, Contextual, +public interface PreprocessorPlugin extends SciJavaPlugin, Contextual, ModulePreprocessor { // PreprocessorPlugin is a module preprocessor, diff --git a/src/main/java/org/scijava/module/process/PreprocessorService.java b/src/main/java/org/scijava/module/process/PreprocessorService.java deleted file mode 100644 index 84580c7b0..000000000 --- a/src/main/java/org/scijava/module/process/PreprocessorService.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * #%L - * SciJava Common shared library for SciJava software. - * %% - * Copyright (C) 2009 - 2016 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package org.scijava.module.process; - -import org.scijava.plugin.SingletonService; -import org.scijava.service.SciJavaService; - -/** - * Interface for service which manages available {@link PreprocessorPlugin}s. - * - * @author Curtis Rueden - */ -public interface PreprocessorService extends - SingletonService, SciJavaService -{ - // NB: No implementation needed. -} diff --git a/src/test/java/org/scijava/ContextCreationTest.java b/src/test/java/org/scijava/ContextCreationTest.java index da59f1d23..abbab3c9b 100644 --- a/src/test/java/org/scijava/ContextCreationTest.java +++ b/src/test/java/org/scijava/ContextCreationTest.java @@ -100,8 +100,6 @@ public void testFull() { org.scijava.main.DefaultMainService.class, org.scijava.menu.DefaultMenuService.class, org.scijava.module.DefaultModuleService.class, - org.scijava.module.process.DefaultPostprocessorService.class, - org.scijava.module.process.DefaultPreprocessorService.class, org.scijava.object.DefaultObjectService.class, org.scijava.options.DefaultOptionsService.class, org.scijava.parse.DefaultParseService.class, From 27abde60ccfeafc7c71461e27b2251d23a2779ac Mon Sep 17 00:00:00 2001 From: Mark Hiner Date: Wed, 20 Apr 2016 09:52:03 -0500 Subject: [PATCH 0215/1208] Add regression test for aggressive cancelation Ensure commands run after a command is canceled are not themselves canceled. --- .../org/scijava/command/CommandModuleTest.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/scijava/command/CommandModuleTest.java b/src/test/java/org/scijava/command/CommandModuleTest.java index 49d40bafc..d19a9d86f 100644 --- a/src/test/java/org/scijava/command/CommandModuleTest.java +++ b/src/test/java/org/scijava/command/CommandModuleTest.java @@ -58,8 +58,12 @@ public void testCancelable() throws InterruptedException, ExecutionException { assertTrue(c.isCanceled()); assertEquals("Stop! Collaborate and listen!", ice.getCancelReason()); assertEquals("Stop! Collaborate and listen!", c.getCancelReason()); + + final CommandModule crow = commandService.run(CrowCommand.class, true).get(); + assertFalse(crow.isCanceled()); } - + + @Test public void testNotCancelable() throws InterruptedException, ExecutionException @@ -98,6 +102,16 @@ public void run() { } } + /** A {@link Cancelable} command which is not auto-canceled. */ + @Plugin(type = Command.class) + public static class CrowCommand extends ContextCommand { + + @Override + public void run() { + // everything's good + } + } + @Plugin(type = PreprocessorPlugin.class) public static class CommandCanceler extends AbstractPreprocessorPlugin { From 54a6b54bbcf5f6e6b6c0fe2dfc8666859a199c92 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 20 Apr 2016 20:19:52 -0500 Subject: [PATCH 0216/1208] Use imagej.net URL for all developers And remove the superfluous (and prone to obsolescence) other info. --- pom.xml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index efae373bf..8f64f6671 100644 --- a/pom.xml +++ b/pom.xml @@ -27,10 +27,7 @@ ctrueden Curtis Rueden - ctrueden@wisc.edu - http://loci.wisc.edu/people/curtis-rueden - UW-Madison LOCI - http://loci.wisc.edu/ + http://imagej.net/User:Rueden founder lead @@ -40,15 +37,11 @@ support maintainer - -6 hinerm Mark Hiner - hiner@wisc.edu - http://loci.wisc.edu/people/mark-hiner - UW-Madison LOCI - http://loci.wisc.edu/ + http://imagej.net/User:Hinerm lead developer @@ -57,7 +50,6 @@ support maintainer - -6 From fb31fe64926e5b90d0b3ef6be4803b693f690193 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 20 Apr 2016 20:22:11 -0500 Subject: [PATCH 0217/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8f64f6671..67530d876 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.56.0-SNAPSHOT + 2.56.1-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From b43000861a1ff388be6978d63a8e0000ba5e8515 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 22 Apr 2016 15:56:07 -0500 Subject: [PATCH 0218/1208] ScriptREPL: fail nicely if there are no languages --- .../java/org/scijava/script/ScriptREPL.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptREPL.java b/src/main/java/org/scijava/script/ScriptREPL.java index 4d0564a89..6096c4116 100644 --- a/src/main/java/org/scijava/script/ScriptREPL.java +++ b/src/main/java/org/scijava/script/ScriptREPL.java @@ -122,15 +122,24 @@ public void initialize() { out.println("Welcome to the SciJava REPL!"); out.println(); help(); + final List langs = scriptService.getLanguages(); + if (langs.isEmpty()) { + out.println("--------------------------------------------------------------"); + out.println("Uh oh! There are no SciJava script languages available!"); + out.println("Are any on your classpath? E.g.: org.scijava:scripting-groovy?"); + out.println("--------------------------------------------------------------"); + out.println(); + return; + } out.println("Have fun!"); out.println(); - lang(scriptService.getLanguages().get(0).getLanguageName()); + lang(langs.get(0).getLanguageName()); populateBindings(interpreter.getBindings()); } /** Outputs the prompt. */ public void prompt() { - out.print(interpreter.isReady() ? "> " : "\\ "); + out.print(interpreter == null || interpreter.isReady() ? "> " : "\\ "); } /** @@ -148,6 +157,9 @@ public boolean evaluate(final String line) { else if (tLine.startsWith(":lang ")) lang(line.substring(6).trim()); else if (line.trim().equals(":quit")) return false; else { + // ensure that a script language is active + if (interpreter == null) return true; + // pass the input to the current interpreter for evaluation try { final Object result = interpreter.interpret(line); @@ -190,6 +202,8 @@ public void help() { /** Lists variables in the script context. */ public void vars() { + if (interpreter == null) return; // no active script language + final List keys = new ArrayList(); final List types = new ArrayList(); final Bindings bindings = interpreter.getBindings(); @@ -213,7 +227,8 @@ public void lang(final String langName) { // create the new interpreter final ScriptLanguage language = scriptService.getLanguageByName(langName); if (language == null) { - throw new IllegalArgumentException("No such language: " + langName); + out.println("No such language: " + langName); + return; } final ScriptInterpreter newInterpreter = new DefaultScriptInterpreter(language); From 254dd05f9026f1d02fec4818a65e1f9206ce542d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 22 Apr 2016 20:20:05 -0500 Subject: [PATCH 0219/1208] ServiceIndexTest: dispose contexts in unit tests --- .../org/scijava/service/ServiceIndexTest.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/scijava/service/ServiceIndexTest.java b/src/test/java/org/scijava/service/ServiceIndexTest.java index 0bae8801b..b8c7f8f6c 100644 --- a/src/test/java/org/scijava/service/ServiceIndexTest.java +++ b/src/test/java/org/scijava/service/ServiceIndexTest.java @@ -65,6 +65,7 @@ public void testGetAll() { assertSame(DefaultPluginService.class, all.get(1).getClass()); assertSame(DefaultThreadService.class, all.get(2).getClass()); assertSame(StderrLogService.class, all.get(3).getClass()); + context.dispose(); } @Test @@ -73,6 +74,7 @@ public void testMarkerInterfaces() { for (Service s : context.getServiceIndex().getAll()) { assertTrue(s.getClass().getName(), s instanceof SciJavaService); } + context.dispose(); } /** @@ -80,9 +82,11 @@ public void testMarkerInterfaces() { */ @Test public void testGetPrevService() { + final Context context = new Context(SciJavaService.class); + // Create a service index where the OptionsService hierarchy should be: // HigherOptionsService > DefaultOptionsService > LowerOptionsService - final ServiceIndex serviceIndex = setUpPrivateServices(); + final ServiceIndex serviceIndex = setUpPrivateServices(context); // DefaultOptionsService should be the previous service to LowerOptionsService assertEquals(DefaultOptionsService.class, serviceIndex.getPrevService( @@ -96,6 +100,8 @@ public void testGetPrevService() { // There should not be a previous service before HigherOptionsService assertNull(serviceIndex.getPrevService(OptionsService.class, HigherOptionsService.class)); + + context.dispose(); } /** @@ -103,9 +109,11 @@ public void testGetPrevService() { */ @Test public void testGetNextService() { + final Context context = new Context(SciJavaService.class); + // Create a service index where the OptionsService hierarchy should be: // HigherOptionService > DefaultOptionService > LowerOptionService - final ServiceIndex serviceIndex = setUpPrivateServices(); + final ServiceIndex serviceIndex = setUpPrivateServices(context); // DefaultOptionsService should be the next service to HigherOptionsService assertEquals(DefaultOptionsService.class, serviceIndex.getNextService( @@ -119,6 +127,8 @@ public void testGetNextService() { // There should not be a next service after LowerOptionsService assertNull(serviceIndex.getNextService(OptionsService.class, LowerOptionsService.class)); + + context.dispose(); } // -- Helper methods -- @@ -126,8 +136,7 @@ public void testGetNextService() { /** * @return A {@link ServiceIndex} with all private services manually added. */ - private ServiceIndex setUpPrivateServices() { - final Context context = new Context(SciJavaService.class); + private ServiceIndex setUpPrivateServices(final Context context) { final ServiceIndex serviceIndex = context.getServiceIndex(); serviceIndex.add(new HigherOptionsService()); serviceIndex.add(new LowerOptionsService()); From 1f213f22147465f6b3d9dce2558baaf8e3ef84c7 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 22 Apr 2016 20:20:16 -0500 Subject: [PATCH 0220/1208] ServiceIndexTest: add missing final keyword --- src/test/java/org/scijava/service/ServiceIndexTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/scijava/service/ServiceIndexTest.java b/src/test/java/org/scijava/service/ServiceIndexTest.java index b8c7f8f6c..200db1a85 100644 --- a/src/test/java/org/scijava/service/ServiceIndexTest.java +++ b/src/test/java/org/scijava/service/ServiceIndexTest.java @@ -71,7 +71,7 @@ public void testGetAll() { @Test public void testMarkerInterfaces() { final Context context = new Context(); - for (Service s : context.getServiceIndex().getAll()) { + for (final Service s : context.getServiceIndex().getAll()) { assertTrue(s.getClass().getName(), s instanceof SciJavaService); } context.dispose(); From b42fe551abfe93ebc337dac62e9e8aa32eb13a26 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 25 Apr 2016 12:54:34 -0500 Subject: [PATCH 0221/1208] ScriptREPL: do not needlessly trim again --- src/main/java/org/scijava/script/ScriptREPL.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/script/ScriptREPL.java b/src/main/java/org/scijava/script/ScriptREPL.java index 6096c4116..8e85ad77f 100644 --- a/src/main/java/org/scijava/script/ScriptREPL.java +++ b/src/main/java/org/scijava/script/ScriptREPL.java @@ -155,7 +155,7 @@ public boolean evaluate(final String line) { else if (tLine.equals(":vars")) vars(); else if (tLine.equals(":langs")) langs(); else if (tLine.startsWith(":lang ")) lang(line.substring(6).trim()); - else if (line.trim().equals(":quit")) return false; + else if (tLine.equals(":quit")) return false; else { // ensure that a script language is active if (interpreter == null) return true; From bbac0d9945b0b0008e541535b2811dee5c732435 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 25 Apr 2016 12:55:14 -0500 Subject: [PATCH 0222/1208] DefaultScriptInterpreter: fix newline accumulation From @skalarproduktraum: "Before when walking the history, a trailing \n got appended to the submitted command. Unfortunately, these accumulated over time." Fixes scijava/scijava-ui-swing#21. --- .../org/scijava/script/DefaultScriptInterpreter.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptInterpreter.java b/src/main/java/org/scijava/script/DefaultScriptInterpreter.java index f6c630348..649787886 100644 --- a/src/main/java/org/scijava/script/DefaultScriptInterpreter.java +++ b/src/main/java/org/scijava/script/DefaultScriptInterpreter.java @@ -186,22 +186,23 @@ public Object interpret(final String line) throws ScriptException { if (!shouldEvaluatePendingInput(true)) return MORE_INPUT_PENDING; } + if (pendingLineCount > 0) buffer.append("\n"); pendingLineCount++; buffer.append(line); - buffer.append("\n"); + final String command = buffer.toString(); if (!(engine instanceof Compilable)) { // Not a compilable language. // Evaluate directly, with no multi-line statements possible. try { - return eval(buffer.toString()); + return eval(command); } finally { reset(); } } - final CompiledScript cs = tryCompiling(buffer.toString(), + final CompiledScript cs = tryCompiling(command, // getPendingLineCount(), line.length()); if (cs == null) { @@ -215,7 +216,7 @@ public Object interpret(final String line) throws ScriptException { } // Command is complete; evaluate the compiled script. try { - addToHistory(buffer.toString()); + addToHistory(command); return cs.eval(); } finally { From 0ce6c58c9632034b6b82c329b37db92bc3f633d7 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 4 May 2016 13:45:20 -0500 Subject: [PATCH 0223/1208] POM: add URL for Gabriel Einsdorf --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 67530d876..c47ff87ba 100644 --- a/pom.xml +++ b/pom.xml @@ -75,6 +75,7 @@ Gabriel Einsdorf + http://imagej.net/User:Gab1one gab1one From 235051db24f6691f1547fba3a825a823ce392f4b Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 22 Jun 2016 11:01:19 -0400 Subject: [PATCH 0224/1208] DefaultScriptService: support arrays of aliases When typing a script parameter on e.g. "String[][]", where "String" is aliases to "java.lang.String", we want this to work as expected for all array dimensionalities, rather than needing to explicitly alias all the array types too. --- .../scijava/script/DefaultScriptService.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index cdb25e50c..35b145dbc 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -254,8 +254,12 @@ public void addAlias(final String alias, final Class type) { public synchronized Class lookupClass(final String alias) throws ScriptException { - final Class type = aliasMap().get(alias); - if (type != null) return type; + final String componentAlias = stripArrayNotation(alias); + final Class type = aliasMap().get(componentAlias); + if (type != null) { + final int arrayDim = (alias.length() - componentAlias.length()) / 2; + return makeArrayType(type, arrayDim); + } try { final Class c = ClassUtils.loadClass(alias, false); @@ -473,4 +477,16 @@ private Future cast(final Future future) { return (Future) future; } + // -- Helper methods - aliases -- + + private String stripArrayNotation(final String alias) { + if (!alias.endsWith("[]")) return alias; + return stripArrayNotation(alias.substring(0, alias.length() - 2)); + } + + private Class makeArrayType(final Class type, final int arrayDim) { + if (arrayDim <= 0) return type; + return makeArrayType(ClassUtils.getArrayClass(type), arrayDim - 1); + } + } From 0372d6af751dc46e074f41187e363dd51b9c092a Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 22 Jun 2016 11:02:22 -0400 Subject: [PATCH 0225/1208] ScriptServiceTest: test arrays of aliases --- .../org/scijava/script/ScriptServiceTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/test/java/org/scijava/script/ScriptServiceTest.java b/src/test/java/org/scijava/script/ScriptServiceTest.java index 60a249232..a7c5a075a 100644 --- a/src/test/java/org/scijava/script/ScriptServiceTest.java +++ b/src/test/java/org/scijava/script/ScriptServiceTest.java @@ -32,10 +32,13 @@ package org.scijava.script; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; import java.io.File; import java.util.List; +import javax.script.ScriptException; + import org.junit.Test; import org.scijava.Context; import org.scijava.util.AppUtils; @@ -72,4 +75,33 @@ public void testSystemProperty() { assertEquals(dir2, scriptDirs.get(2).getAbsolutePath()); } + @Test + public void testArrayAliases() throws ScriptException { + final Context ctx = new Context(ScriptService.class); + final ScriptService ss = ctx.service(ScriptService.class); + + final Class pInt2D = ss.lookupClass("int[][]"); + assertSame(int[][].class, pInt2D); + final Class pInt1D = ss.lookupClass("int[]"); + assertSame(int[].class, pInt1D); + final Class pInt = ss.lookupClass("int"); + assertSame(int.class, pInt); + + final Class oInt2D = ss.lookupClass("Integer[][]"); + assertSame(Integer[][].class, oInt2D); + final Class oInt1D = ss.lookupClass("Integer[]"); + assertSame(Integer[].class, oInt1D); + final Class oInt = ss.lookupClass("Integer"); + assertSame(Integer.class, oInt); + + final Class str2D = ss.lookupClass("String[][]"); + assertSame(String[][].class, str2D); + final Class str1D = ss.lookupClass("String[]"); + assertSame(String[].class, str1D); + final Class str = ss.lookupClass("String"); + assertSame(String.class, str); + + ctx.dispose(); + } + } From be376ed976e1a89d4f567f66941f194f6eb8e1b0 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 22 Jun 2016 16:13:16 -0400 Subject: [PATCH 0226/1208] Remove unused imports --- src/main/java/org/scijava/run/console/RunArgument.java | 1 - src/main/java/org/scijava/script/ScriptService.java | 2 -- src/test/java/org/scijava/command/CommandServiceTest.java | 2 -- src/test/java/org/scijava/display/DisplayTest.java | 3 --- src/test/java/org/scijava/main/MainServiceTest.java | 1 - src/test/java/org/scijava/menu/ShadowMenuTest.java | 2 -- src/test/java/org/scijava/options/OptionsTest.java | 2 -- src/test/java/org/scijava/prefs/PrefServiceTest.java | 1 - src/test/java/org/scijava/test/TestUtilsTest.java | 1 - src/test/java/org/scijava/util/ColorRGBTest.java | 2 -- 10 files changed, 17 deletions(-) diff --git a/src/main/java/org/scijava/run/console/RunArgument.java b/src/main/java/org/scijava/run/console/RunArgument.java index 8897bf519..729e5e385 100644 --- a/src/main/java/org/scijava/run/console/RunArgument.java +++ b/src/main/java/org/scijava/run/console/RunArgument.java @@ -36,7 +36,6 @@ import org.scijava.console.AbstractConsoleArgument; import org.scijava.console.ConsoleArgument; -import org.scijava.console.ConsoleUtils; import org.scijava.log.LogService; import org.scijava.parse.Items; import org.scijava.parse.ParseService; diff --git a/src/main/java/org/scijava/script/ScriptService.java b/src/main/java/org/scijava/script/ScriptService.java index 3f016abd9..dfdb08115 100644 --- a/src/main/java/org/scijava/script/ScriptService.java +++ b/src/main/java/org/scijava/script/ScriptService.java @@ -40,13 +40,11 @@ import java.util.Map; import java.util.concurrent.Future; -import javax.script.ScriptEngineFactory; import javax.script.ScriptException; import org.scijava.MenuPath; import org.scijava.module.process.PostprocessorPlugin; import org.scijava.module.process.PreprocessorPlugin; -import org.scijava.plugin.Plugin; import org.scijava.plugin.SingletonService; import org.scijava.service.SciJavaService; diff --git a/src/test/java/org/scijava/command/CommandServiceTest.java b/src/test/java/org/scijava/command/CommandServiceTest.java index df8f1f565..2921d7979 100644 --- a/src/test/java/org/scijava/command/CommandServiceTest.java +++ b/src/test/java/org/scijava/command/CommandServiceTest.java @@ -35,8 +35,6 @@ import org.junit.Test; import org.scijava.Context; -import org.scijava.command.Command; -import org.scijava.command.CommandService; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; diff --git a/src/test/java/org/scijava/display/DisplayTest.java b/src/test/java/org/scijava/display/DisplayTest.java index ed6ad0d81..b99635b17 100644 --- a/src/test/java/org/scijava/display/DisplayTest.java +++ b/src/test/java/org/scijava/display/DisplayTest.java @@ -38,9 +38,6 @@ import org.junit.Test; import org.scijava.Context; -import org.scijava.display.Display; -import org.scijava.display.DisplayService; -import org.scijava.display.TextDisplay; /** * Unit tests for core {@link Display} classes. diff --git a/src/test/java/org/scijava/main/MainServiceTest.java b/src/test/java/org/scijava/main/MainServiceTest.java index fd1382213..d3ec4aca5 100644 --- a/src/test/java/org/scijava/main/MainServiceTest.java +++ b/src/test/java/org/scijava/main/MainServiceTest.java @@ -39,7 +39,6 @@ import org.junit.Test; import org.scijava.Context; import org.scijava.console.ConsoleService; -import org.scijava.main.console.MainArgument; /** * Tests {@link MainService}. diff --git a/src/test/java/org/scijava/menu/ShadowMenuTest.java b/src/test/java/org/scijava/menu/ShadowMenuTest.java index 0e8bf5a58..458d41387 100644 --- a/src/test/java/org/scijava/menu/ShadowMenuTest.java +++ b/src/test/java/org/scijava/menu/ShadowMenuTest.java @@ -43,8 +43,6 @@ import org.junit.Test; import org.scijava.Context; import org.scijava.MenuPath; -import org.scijava.menu.ShadowMenu; -import org.scijava.menu.ShadowMenuIterator; import org.scijava.module.DefaultMutableModuleInfo; import org.scijava.module.ModuleInfo; diff --git a/src/test/java/org/scijava/options/OptionsTest.java b/src/test/java/org/scijava/options/OptionsTest.java index 9e59fc7e8..04c01667c 100644 --- a/src/test/java/org/scijava/options/OptionsTest.java +++ b/src/test/java/org/scijava/options/OptionsTest.java @@ -39,8 +39,6 @@ import org.junit.Test; import org.scijava.Context; -import org.scijava.options.OptionsPlugin; -import org.scijava.options.OptionsService; import org.scijava.plugin.Parameter; import org.scijava.plugin.PluginInfo; import org.scijava.plugin.PluginService; diff --git a/src/test/java/org/scijava/prefs/PrefServiceTest.java b/src/test/java/org/scijava/prefs/PrefServiceTest.java index c217544d8..660acbcfe 100644 --- a/src/test/java/org/scijava/prefs/PrefServiceTest.java +++ b/src/test/java/org/scijava/prefs/PrefServiceTest.java @@ -45,7 +45,6 @@ import org.junit.Before; import org.junit.Test; import org.scijava.Context; -import org.scijava.prefs.PrefService; /** * Tests {@link PrefService}. diff --git a/src/test/java/org/scijava/test/TestUtilsTest.java b/src/test/java/org/scijava/test/TestUtilsTest.java index 1fe7f508d..7e6c6278f 100644 --- a/src/test/java/org/scijava/test/TestUtilsTest.java +++ b/src/test/java/org/scijava/test/TestUtilsTest.java @@ -40,7 +40,6 @@ import java.util.Arrays; import org.junit.Test; -import org.scijava.test.TestUtils; /** * Tests the {@link TestUtils}. diff --git a/src/test/java/org/scijava/util/ColorRGBTest.java b/src/test/java/org/scijava/util/ColorRGBTest.java index 89d73f52a..25f3d8c69 100644 --- a/src/test/java/org/scijava/util/ColorRGBTest.java +++ b/src/test/java/org/scijava/util/ColorRGBTest.java @@ -37,8 +37,6 @@ import static org.junit.Assert.assertSame; import org.junit.Test; -import org.scijava.util.ColorRGB; -import org.scijava.util.Colors; /** * Tests {@link ColorRGB}. From da2e6466bfd6d1bf36bd0e840a10227e9b3027e7 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 22 Jun 2016 16:13:24 -0400 Subject: [PATCH 0227/1208] POM: bump pom-scijava parent to 10.5.0 And bump the minimum Java version to Java 8. --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index c47ff87ba..9414cc57e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.scijava pom-scijava - 9.6.0 + 10.5.0 scijava-common - 2.56.1-SNAPSHOT + 2.57.0-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. @@ -109,7 +109,7 @@ - 1.8 + 1.8 3.0.0 From 09feb4d38b7579fcf2572dad0b45bc876c8eb33b Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 22 Jun 2016 16:19:56 -0400 Subject: [PATCH 0228/1208] Use diamond syntax Thank you Java 7! --- .../org/scijava/AbstractBasicDetails.java | 2 +- .../annotations/AbstractIndexWriter.java | 12 ++-- .../annotations/AnnotationCombiner.java | 2 +- .../annotations/AnnotationProcessor.java | 12 ++-- .../scijava/annotations/ByteCodeAnalyzer.java | 8 +-- .../scijava/annotations/EclipseHelper.java | 2 +- .../java/org/scijava/annotations/Index.java | 8 +-- .../org/scijava/annotations/IndexReader.java | 4 +- .../annotations/legacy/LegacyReader.java | 10 ++-- .../org/scijava/app/DefaultAppService.java | 2 +- .../scijava/cache/DefaultCacheService.java | 2 +- .../java/org/scijava/command/CommandInfo.java | 14 ++--- .../scijava/command/CommandModuleItem.java | 2 +- .../command/DefaultCommandService.java | 8 +-- .../scijava/command/DynamicCommandInfo.java | 2 +- .../console/AbstractConsoleArgument.java | 2 +- .../org/scijava/console/ConsoleUtils.java | 2 +- .../console/DefaultConsoleService.java | 4 +- .../scijava/console/MultiOutputStream.java | 2 +- .../convert/AbstractConvertService.java | 6 +- .../org/scijava/convert/DefaultConverter.java | 4 +- .../org/scijava/display/AbstractDisplay.java | 2 +- .../display/DefaultDisplayService.java | 4 +- .../scijava/display/DisplayPostprocessor.java | 2 +- .../scijava/event/DefaultEventHistory.java | 4 +- .../scijava/event/DefaultEventService.java | 12 ++-- .../scijava/input/DefaultInputService.java | 4 +- src/main/java/org/scijava/input/KeyCode.java | 4 +- .../org/scijava/io/AbstractDataHandle.java | 2 +- .../scijava/io/DefaultRecentFileService.java | 4 +- src/main/java/org/scijava/io/URILocation.java | 2 +- .../org/scijava/log/AbstractLogService.java | 2 +- .../org/scijava/main/DefaultMainService.java | 2 +- .../scijava/main/console/MainArgument.java | 2 +- .../org/scijava/menu/DefaultMenuService.java | 6 +- .../java/org/scijava/menu/ShadowMenu.java | 12 ++-- .../org/scijava/menu/ShadowMenuIterator.java | 2 +- .../org/scijava/module/AbstractModule.java | 8 +-- .../scijava/module/AbstractModuleInfo.java | 8 +-- .../scijava/module/DefaultModuleService.java | 4 +- .../scijava/module/DefaultMutableModule.java | 4 +- .../module/DefaultMutableModuleItem.java | 2 +- .../java/org/scijava/module/MethodRef.java | 2 +- .../scijava/object/DefaultObjectService.java | 2 +- .../java/org/scijava/object/ObjectIndex.java | 18 +++--- .../org/scijava/object/SortedObjectIndex.java | 6 +- .../org/scijava/object/event/ListEvent.java | 2 +- .../scijava/parse/DefaultParseService.java | 2 +- .../plugin/AbstractSingletonService.java | 4 +- .../scijava/plugin/DefaultPluginFinder.java | 6 +- .../scijava/plugin/DefaultPluginService.java | 6 +- .../java/org/scijava/plugin/PluginIndex.java | 2 +- .../org/scijava/prefs/DefaultPrefService.java | 4 +- .../scijava/script/DefaultScriptService.java | 12 ++-- src/main/java/org/scijava/script/History.java | 2 +- .../org/scijava/script/InvocationObject.java | 2 +- .../java/org/scijava/script/ScriptFinder.java | 2 +- .../java/org/scijava/script/ScriptInfo.java | 6 +- .../scijava/script/ScriptLanguageIndex.java | 4 +- .../java/org/scijava/script/ScriptREPL.java | 12 ++-- .../org/scijava/service/ServiceHelper.java | 6 +- src/main/java/org/scijava/test/TestUtils.java | 2 +- .../scijava/thread/DefaultThreadService.java | 2 +- .../org/scijava/tool/DefaultToolService.java | 8 +-- .../java/org/scijava/ui/DefaultUIService.java | 10 ++-- .../java/org/scijava/ui/dnd/MIMEType.java | 4 +- .../java/org/scijava/util/ArrayUtils.java | 4 +- .../java/org/scijava/util/ClassUtils.java | 12 ++-- src/main/java/org/scijava/util/Colors.java | 2 +- .../java/org/scijava/util/DebugUtils.java | 2 +- src/main/java/org/scijava/util/FileUtils.java | 2 +- .../java/org/scijava/util/IteratorPlus.java | 2 +- .../org/scijava/util/LastRecentlyUsed.java | 4 +- .../java/org/scijava/util/MirrorWebsite.java | 12 ++-- src/main/java/org/scijava/util/POM.java | 4 +- .../org/scijava/util/ReflectedUniverse.java | 2 +- .../org/scijava/util/ServiceCombiner.java | 2 +- src/main/java/org/scijava/util/Timing.java | 2 +- src/main/java/org/scijava/util/XML.java | 2 +- .../widget/AbstractInputHarvester.java | 2 +- .../scijava/widget/AbstractInputPanel.java | 2 +- .../scijava/widget/DefaultWidgetModel.java | 2 +- .../java/org/scijava/ContextCreationTest.java | 4 +- .../annotations/DirectoryIndexerTest.java | 6 +- .../org/scijava/app/StatusServiceTest.java | 2 +- .../command/run/CommandCodeRunnerTest.java | 2 +- .../scijava/console/ConsoleServiceTest.java | 6 +- .../console/SystemPropertyArgumentTest.java | 2 +- .../scijava/convert/ConvertServiceTest.java | 12 ++-- .../org/scijava/event/EventServiceTest.java | 2 +- .../java/org/scijava/menu/ShadowMenuTest.java | 2 +- .../module/run/ModuleCodeRunnerTest.java | 6 +- .../org/scijava/object/ObjectIndexTest.java | 30 +++++----- .../scijava/object/SortedObjectIndexTest.java | 4 +- .../java/org/scijava/options/OptionsTest.java | 2 +- .../org/scijava/plugin/PluginIndexTest.java | 4 +- .../org/scijava/prefs/PrefServiceTest.java | 4 +- .../java/org/scijava/run/RunServiceTest.java | 2 +- .../org/scijava/script/ScriptFinderTest.java | 2 +- .../java/org/scijava/util/BoolArrayTest.java | 2 +- .../java/org/scijava/util/ByteArrayTest.java | 2 +- .../java/org/scijava/util/CharArrayTest.java | 2 +- .../org/scijava/util/ConversionUtilsTest.java | 6 +- .../org/scijava/util/DoubleArrayTest.java | 2 +- .../java/org/scijava/util/FloatArrayTest.java | 2 +- .../java/org/scijava/util/IntArrayTest.java | 2 +- .../scijava/util/LastRecentlyUsedTest.java | 4 +- .../java/org/scijava/util/LongArrayTest.java | 2 +- .../org/scijava/util/ObjectArrayTest.java | 60 +++++++++---------- .../java/org/scijava/util/ShortArrayTest.java | 2 +- 110 files changed, 282 insertions(+), 282 deletions(-) diff --git a/src/main/java/org/scijava/AbstractBasicDetails.java b/src/main/java/org/scijava/AbstractBasicDetails.java index 507665b1c..513cf0258 100644 --- a/src/main/java/org/scijava/AbstractBasicDetails.java +++ b/src/main/java/org/scijava/AbstractBasicDetails.java @@ -53,7 +53,7 @@ public abstract class AbstractBasicDetails implements BasicDetails { private String description; /** Table of extra key/value pairs. */ - private final Map values = new HashMap(); + private final Map values = new HashMap<>(); // -- Object methods -- diff --git a/src/main/java/org/scijava/annotations/AbstractIndexWriter.java b/src/main/java/org/scijava/annotations/AbstractIndexWriter.java index fe58d191f..f8238b0fa 100644 --- a/src/main/java/org/scijava/annotations/AbstractIndexWriter.java +++ b/src/main/java/org/scijava/annotations/AbstractIndexWriter.java @@ -61,7 +61,7 @@ public abstract class AbstractIndexWriter { private final Map> map = - new ConcurrentSkipListMap>(); + new ConcurrentSkipListMap<>(); protected synchronized boolean foundAnnotations() { return !map.isEmpty(); @@ -72,10 +72,10 @@ protected synchronized void add(final Map annotationValues, { Map list = map.get(annotationName); if (list == null) { - list = new LinkedHashMap(); + list = new LinkedHashMap<>(); map.put(annotationName, list); } - final Map o = new TreeMap(); + final Map o = new TreeMap<>(); o.put("class", className); o.put("values", annotationValues); list.put(className, o); @@ -128,7 +128,7 @@ protected synchronized void merge(final String annotationName, } Map m = map.get(annotationName); if (m == null) { - m = new LinkedHashMap(); + m = new LinkedHashMap<>(); map.put(annotationName, m); } /* @@ -184,7 +184,7 @@ else if (o instanceof Enum) { } protected Map adapt(A annotation) { - Map result = new TreeMap(); + Map result = new TreeMap<>(); for (Method method : annotation.annotationType().getMethods()) try { if (method.getDeclaringClass() == annotation.annotationType()) { @@ -204,7 +204,7 @@ protected Map adapt(A annotation) { } private static Map adapt(Enum e) { - Map result = new TreeMap(); + Map result = new TreeMap<>(); result.put("enum", e.getClass().getName()); result.put("value", e.name()); return result; diff --git a/src/main/java/org/scijava/annotations/AnnotationCombiner.java b/src/main/java/org/scijava/annotations/AnnotationCombiner.java index 5a5b7c127..cde5a05fe 100644 --- a/src/main/java/org/scijava/annotations/AnnotationCombiner.java +++ b/src/main/java/org/scijava/annotations/AnnotationCombiner.java @@ -87,7 +87,7 @@ public void combine(File outputDirectory) throws Exception { /** Scans for annotations files in every resource on the classpath. */ public Set getAnnotationFiles() throws IOException { - final HashSet files = new HashSet(); + final HashSet files = new HashSet<>(); for (final String prefix : new String[] { PREFIX, LEGACY_PREFIX }) { final Enumeration directories = diff --git a/src/main/java/org/scijava/annotations/AnnotationProcessor.java b/src/main/java/org/scijava/annotations/AnnotationProcessor.java index 70a54e3e1..3940bc3f7 100644 --- a/src/main/java/org/scijava/annotations/AnnotationProcessor.java +++ b/src/main/java/org/scijava/annotations/AnnotationProcessor.java @@ -111,7 +111,7 @@ public boolean process(final Set elements, private class Writer extends AbstractIndexWriter implements StreamFactory { private final Map> originatingElements = - new HashMap>(); + new HashMap<>(); private final Filer filer = processingEnv.getFiler(); private final Elements utils = processingEnv.getElementUtils(); private final Types typeUtils = processingEnv.getTypeUtils(); @@ -124,7 +124,7 @@ public void add(final TypeElement element) { // remember originating elements List originating = originatingElements.get(annotationName); if (originating == null) { - originating = new ArrayList(); + originating = new ArrayList<>(); originatingElements.put(annotationName, originating); } @@ -159,7 +159,7 @@ private Map adapt( final List mirrors, final TypeMirror annotationType) { - final Map result = new TreeMap(); + final Map result = new TreeMap<>(); for (final AnnotationMirror mirror : mirrors) { if (typeUtils.isSameType(mirror.getAnnotationType(), annotationType)) { return (Map) adapt(mirror); @@ -172,7 +172,7 @@ private Map adapt( protected Object adapt(final Object o) { if (o instanceof AnnotationMirror) { final AnnotationMirror mirror = (AnnotationMirror) o; - final Map result = new TreeMap(); + final Map result = new TreeMap<>(); for (final Entry entry : mirror .getElementValues().entrySet()) { @@ -184,7 +184,7 @@ protected Object adapt(final Object o) { } else if (o instanceof List) { final List list = (List) o; - final List result = new ArrayList(list.size()); + final List result = new ArrayList<>(list.size()); for (final Object item : list) { result.add(adapt(item)); } @@ -197,7 +197,7 @@ else if (o instanceof TypeMirror) { } else if (o instanceof VariableElement) { final VariableElement element = (VariableElement) o; - final Map result = new TreeMap(); + final Map result = new TreeMap<>(); final String enumName = utils.getBinaryName((TypeElement) element.getEnclosingElement()) .toString(); diff --git a/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java b/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java index 4f752d324..c7b5b13bf 100644 --- a/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java +++ b/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java @@ -204,7 +204,7 @@ private String getName() { private Map> getAnnotations() { final Map> annotations = - new TreeMap>(); + new TreeMap<>(); for (final Attribute attr : attributes) { if ("RuntimeVisibleAnnotations".equals(attr.getName())) { final byte[] buf = attr.attribute; @@ -215,7 +215,7 @@ private Map> getAnnotations() { raw2className(getStringConstant(getU2(buf, offset))); offset += 2; final Map values = - new TreeMap(); + new TreeMap<>(); annotations.put(className, values); offset = parseAnnotationValues(buf, offset, values); } @@ -297,7 +297,7 @@ private int parseAnnotationValue(byte[] buf, int offset, } case 'e': { final Map enumValue = - new TreeMap(); + new TreeMap<>(); enumValue.put("enum", raw2className(getStringConstant(getU2(buf, offset)))); offset += 2; @@ -309,7 +309,7 @@ private int parseAnnotationValue(byte[] buf, int offset, case '@': { // skipping annotation type offset += 2; - final Map values = new TreeMap(); + final Map values = new TreeMap<>(); offset = parseAnnotationValues(buf, offset, values); value = values; break; diff --git a/src/main/java/org/scijava/annotations/EclipseHelper.java b/src/main/java/org/scijava/annotations/EclipseHelper.java index b2f78d7e3..d9a8dbb91 100644 --- a/src/main/java/org/scijava/annotations/EclipseHelper.java +++ b/src/main/java/org/scijava/annotations/EclipseHelper.java @@ -98,7 +98,7 @@ public class EclipseHelper extends DirectoryIndexer { private static final String FORCE_ANNOTATION_INDEX_PROPERTY = "force.annotation.index"; - static Set indexed = new HashSet(); + static Set indexed = new HashSet<>(); private boolean bannerShown; private static boolean debug = diff --git a/src/main/java/org/scijava/annotations/Index.java b/src/main/java/org/scijava/annotations/Index.java index a6231532f..e30dc7cf7 100644 --- a/src/main/java/org/scijava/annotations/Index.java +++ b/src/main/java/org/scijava/annotations/Index.java @@ -86,7 +86,7 @@ public static Index load(final Class annotation, final ClassLoader loader) { EclipseHelper.updateAnnotationIndex(loader); - return new Index(annotation, loader); + return new Index<>(annotation, loader); } static final String INDEX_PREFIX = "META-INF/json/"; @@ -110,9 +110,9 @@ private class IndexItemIterator implements Iterator> { private Map legacyURLs; public IndexItemIterator(final Class annotation) { - seen = new HashSet(); + seen = new HashSet<>(); try { - legacyURLs = new LinkedHashMap(); + legacyURLs = new LinkedHashMap<>(); final Enumeration legacy = loader.getResources(LEGACY_INDEX_PREFIX + annotation.getName()); final int legacySuffixLength = @@ -160,7 +160,7 @@ private void readNext() throws IOException { @SuppressWarnings("unchecked") final Map values = (Map) map.get("values"); - next = new IndexItem(annotation, loader, className, values); + next = new IndexItem<>(annotation, loader, className, values); return; } indexReader.close(); diff --git a/src/main/java/org/scijava/annotations/IndexReader.java b/src/main/java/org/scijava/annotations/IndexReader.java index 5c613748e..aa3069feb 100644 --- a/src/main/java/org/scijava/annotations/IndexReader.java +++ b/src/main/java/org/scijava/annotations/IndexReader.java @@ -84,7 +84,7 @@ public Object next() throws IOException { return null; } if (c == '{') { - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); for (;;) { if (expect('"', '}') == 1) { return map; @@ -99,7 +99,7 @@ public Object next() throws IOException { } } if (c == '[') { - List list = new ArrayList(); + List list = new ArrayList<>(); c = in.read(); if (c == ']') { return list; diff --git a/src/main/java/org/scijava/annotations/legacy/LegacyReader.java b/src/main/java/org/scijava/annotations/legacy/LegacyReader.java index 5bf17928d..8deee7f31 100644 --- a/src/main/java/org/scijava/annotations/legacy/LegacyReader.java +++ b/src/main/java/org/scijava/annotations/legacy/LegacyReader.java @@ -83,7 +83,7 @@ public LegacyReader(final InputStream in) throws IOException { if (version != STREAM_VERSION) { throw new IOException("Unsupported version: " + version); } - references = new ArrayList(); + references = new ArrayList<>(); } public void close() throws IOException { @@ -260,7 +260,7 @@ protected NonPrimitiveClassDesc(final String className, if ((fields.length % 2) != 0) { throw new RuntimeException("That's odd: " + fields.length); } - this.fields = new LinkedHashMap(); + this.fields = new LinkedHashMap<>(); for (int i = 0; i < fields.length; i += 2) { String name = (String) fields[i]; ClassDesc classDesc; @@ -300,7 +300,7 @@ else if (c != TC_OBJECT) { @Override protected final Object readWithoutClassDesc() throws IOException { - final Map map = new LinkedHashMap(); + final Map map = new LinkedHashMap<>(); int index = references.size(); references.add(map); for (final String fieldName : order) { @@ -357,7 +357,7 @@ public static String toSimpleName(Class clazz) { } private final Map classDescs = - new HashMap(); + new HashMap<>(); { new ClassDesc("B") { @@ -477,7 +477,7 @@ public Object readExtra(final Map map) throws IOException expectToken(TC_BLOCKDATA); expectToken(4); int capacity = read32(); - final List list = new ArrayList(capacity); + final List list = new ArrayList<>(capacity); for (int i = 0; i < size; i++) { list.add(readObject()); } diff --git a/src/main/java/org/scijava/app/DefaultAppService.java b/src/main/java/org/scijava/app/DefaultAppService.java index 903e9d283..9a1ae4125 100644 --- a/src/main/java/org/scijava/app/DefaultAppService.java +++ b/src/main/java/org/scijava/app/DefaultAppService.java @@ -121,7 +121,7 @@ private Map apps() { /** Initializes {@link #apps}. */ private synchronized void initApps() { if (apps != null) return; // already initialized - final HashMap map = new HashMap(); + final HashMap map = new HashMap<>(); for (final App app : getInstances()) { final String name = app.getInfo().getName(); diff --git a/src/main/java/org/scijava/cache/DefaultCacheService.java b/src/main/java/org/scijava/cache/DefaultCacheService.java index b1b305273..f78f93686 100644 --- a/src/main/java/org/scijava/cache/DefaultCacheService.java +++ b/src/main/java/org/scijava/cache/DefaultCacheService.java @@ -73,6 +73,6 @@ public V get(final Object key, final Callable valueLoader) @Override public void initialize() { - map = new WeakHashMap(); + map = new WeakHashMap<>(); } } diff --git a/src/main/java/org/scijava/command/CommandInfo.java b/src/main/java/org/scijava/command/CommandInfo.java index 49bfdb488..8947db7a6 100644 --- a/src/main/java/org/scijava/command/CommandInfo.java +++ b/src/main/java/org/scijava/command/CommandInfo.java @@ -94,21 +94,21 @@ public class CommandInfo extends PluginInfo implements ModuleInfo { /** List of problems detected when parsing command parameters. */ private final List problems = - new ArrayList(); + new ArrayList<>(); /** Table of inputs, keyed on name. */ private final Map> inputMap = - new HashMap>(); + new HashMap<>(); /** Table of outputs, keyed on name. */ private final Map> outputMap = - new HashMap>(); + new HashMap<>(); /** Ordered list of input items. */ - private final List> inputList = new ArrayList>(); + private final List> inputList = new ArrayList<>(); /** Ordered list of output items. */ - private final List> outputList = new ArrayList>(); + private final List> outputList = new ArrayList<>(); // -- Constructors -- @@ -179,7 +179,7 @@ protected CommandInfo(final PluginInfo info, final String className, /** Sets the table of items with fixed, preset values. */ public void setPresets(final Map presets) { if (presets == null) { - this.presets = new HashMap(); + this.presets = new HashMap<>(); } else { this.presets = presets; @@ -495,7 +495,7 @@ private void checkFields(final Class type) { // add item to the relevant list (inputs or outputs) final CommandModuleItem item = - new CommandModuleItem(this, f); + new CommandModuleItem<>(this, f); if (item.isInput()) { inputMap.put(name, item); if (!isPreset) inputList.add(item); diff --git a/src/main/java/org/scijava/command/CommandModuleItem.java b/src/main/java/org/scijava/command/CommandModuleItem.java index 4844db92d..aff1ecda3 100644 --- a/src/main/java/org/scijava/command/CommandModuleItem.java +++ b/src/main/java/org/scijava/command/CommandModuleItem.java @@ -166,7 +166,7 @@ public List getChoices() { final String[] choices = getParameter().choices(); if (choices.length == 0) return super.getChoices(); - final ArrayList choiceList = new ArrayList(); + final ArrayList choiceList = new ArrayList<>(); for (final String choice : choices) { choiceList.add(tValue(choice)); } diff --git a/src/main/java/org/scijava/command/DefaultCommandService.java b/src/main/java/org/scijava/command/DefaultCommandService.java index 71a4054fd..d33cbaf97 100644 --- a/src/main/java/org/scijava/command/DefaultCommandService.java +++ b/src/main/java/org/scijava/command/DefaultCommandService.java @@ -208,7 +208,7 @@ public Class getPluginType() { @Override public void initialize() { - commandMap = new HashMap, CommandInfo>(); + commandMap = new HashMap<>(); // inform the module service of available commands final List> plugins = @@ -226,7 +226,7 @@ protected void onEvent(final PluginsRemovedEvent event) { @EventHandler protected void onEvent(final PluginsAddedEvent event) { final ArrayList> commands = - new ArrayList>(); + new ArrayList<>(); findCommandPlugins(event.getItems(), commands); addCommands(commands); } @@ -258,7 +258,7 @@ private CommandInfo getOrCreate( /** Adds new commands to the module service. */ private void addCommands(final List> plugins) { // extract commands from the list of plugins - final List commands = new ArrayList(); + final List commands = new ArrayList<>(); for (final PluginInfo info : plugins) { final CommandInfo commandInfo = wrapAsCommand(info); commands.add(commandInfo); @@ -291,7 +291,7 @@ private void removeCommands(final List> plugins) { private List getCommandsUnknown( final List> plugins) { - final List commands = new ArrayList(); + final List commands = new ArrayList<>(); for (final PluginInfo info : plugins) { final CommandInfo commandInfo = commandMap.get(info); if (commandInfo == null) continue; diff --git a/src/main/java/org/scijava/command/DynamicCommandInfo.java b/src/main/java/org/scijava/command/DynamicCommandInfo.java index a6b9cc507..d3c1552fd 100644 --- a/src/main/java/org/scijava/command/DynamicCommandInfo.java +++ b/src/main/java/org/scijava/command/DynamicCommandInfo.java @@ -310,7 +310,7 @@ private void populateItems() { /** Creates a mutable copy of the given module item. */ private DefaultMutableModuleItem copy(final ModuleItem item) { - return new DefaultMutableModuleItem(this, item); + return new DefaultMutableModuleItem<>(this, item); } } diff --git a/src/main/java/org/scijava/console/AbstractConsoleArgument.java b/src/main/java/org/scijava/console/AbstractConsoleArgument.java index 8c48af157..ffab5502d 100644 --- a/src/main/java/org/scijava/console/AbstractConsoleArgument.java +++ b/src/main/java/org/scijava/console/AbstractConsoleArgument.java @@ -58,7 +58,7 @@ public AbstractConsoleArgument(final String... flags) { public AbstractConsoleArgument(final int requiredArgs, final String... flags) { numArgs = requiredArgs; - this.flags = new HashSet(); + this.flags = new HashSet<>(); for (final String s : flags) this.flags.add(s); } diff --git a/src/main/java/org/scijava/console/ConsoleUtils.java b/src/main/java/org/scijava/console/ConsoleUtils.java index 8c078fde4..b3ac60dbc 100644 --- a/src/main/java/org/scijava/console/ConsoleUtils.java +++ b/src/main/java/org/scijava/console/ConsoleUtils.java @@ -66,7 +66,7 @@ public static Map parseParameterString(final String parameterStr /** @deprecated Use {@link ParseService} instead. */ @Deprecated public static Map parseParameterString(final String parameterString, final ModuleInfo info, final LogService log) { - final Map inputMap = new HashMap(); + final Map inputMap = new HashMap<>(); if (!parameterString.isEmpty()) { Iterator> inputs = null; diff --git a/src/main/java/org/scijava/console/DefaultConsoleService.java b/src/main/java/org/scijava/console/DefaultConsoleService.java index 22483a459..6d53557b1 100644 --- a/src/main/java/org/scijava/console/DefaultConsoleService.java +++ b/src/main/java/org/scijava/console/DefaultConsoleService.java @@ -76,7 +76,7 @@ public class DefaultConsoleService extends @Override public void processArgs(final String... args) { log.debug("Received command line arguments:"); - final LinkedList argList = new LinkedList(); + final LinkedList argList = new LinkedList<>(); for (final String arg : args) { log.debug("\t" + arg); argList.add(arg); @@ -159,7 +159,7 @@ private synchronized void initListeners() { err = new OutputStreamReporter(Source.STDERR); syserr.getParent().addOutputStream(err); - listeners = new ArrayList(); + listeners = new ArrayList<>(); cachedListeners = listeners.toArray(new OutputListener[0]); } diff --git a/src/main/java/org/scijava/console/MultiOutputStream.java b/src/main/java/org/scijava/console/MultiOutputStream.java index 0b596af93..0f1cda471 100644 --- a/src/main/java/org/scijava/console/MultiOutputStream.java +++ b/src/main/java/org/scijava/console/MultiOutputStream.java @@ -58,7 +58,7 @@ public class MultiOutputStream extends OutputStream { * @param os Output streams which will receive this stream's output. */ public MultiOutputStream(final OutputStream... os) { - streams = new ArrayList(os.length); + streams = new ArrayList<>(os.length); for (int i = 0; i < os.length; i++) { streams.add(os[i]); } diff --git a/src/main/java/org/scijava/convert/AbstractConvertService.java b/src/main/java/org/scijava/convert/AbstractConvertService.java index a0b46cd94..5faf2f9ab 100644 --- a/src/main/java/org/scijava/convert/AbstractConvertService.java +++ b/src/main/java/org/scijava/convert/AbstractConvertService.java @@ -103,7 +103,7 @@ public boolean supports(final Class src, final Type dest) { @Override public Collection getCompatibleInputs(final Class dest) { - final Set objects = new LinkedHashSet(); + final Set objects = new LinkedHashSet<>(); for (final Converter c : getInstances()) { if (dest.isAssignableFrom(c.getOutputType())) { @@ -135,7 +135,7 @@ public Object convert(final ConversionRequest request) { @Override public Collection> getCompatibleInputClasses(final Class dest) { - final Set> compatibleClasses = new HashSet>(); + final Set> compatibleClasses = new HashSet<>(); for (final Converter converter : getInstances()) { addIfMatches(dest, converter.getOutputType(), converter.getInputType(), compatibleClasses); @@ -146,7 +146,7 @@ public Collection> getCompatibleInputClasses(final Class dest) { @Override public Collection> getCompatibleOutputClasses(final Class source) { - final Set> compatibleClasses = new HashSet>(); + final Set> compatibleClasses = new HashSet<>(); for (final Converter converter : getInstances()) { addIfMatches(source, converter.getInputType(), converter.getOutputType(), compatibleClasses); diff --git a/src/main/java/org/scijava/convert/DefaultConverter.java b/src/main/java/org/scijava/convert/DefaultConverter.java index 803483dc3..262a55249 100644 --- a/src/main/java/org/scijava/convert/DefaultConverter.java +++ b/src/main/java/org/scijava/convert/DefaultConverter.java @@ -259,8 +259,8 @@ private Collection createCollection(final Class type) { if (type.isInterface() || Modifier.isAbstract(type.getModifiers())) { // We don't have a concrete class. If it's a set or a list, we use // the typical default implementation. Otherwise we won't convert. - if (ConversionUtils.canCast(type, List.class)) return new ArrayList(); - if (ConversionUtils.canCast(type, Set.class)) return new HashSet(); + if (ConversionUtils.canCast(type, List.class)) return new ArrayList<>(); + if (ConversionUtils.canCast(type, Set.class)) return new HashSet<>(); return null; } diff --git a/src/main/java/org/scijava/display/AbstractDisplay.java b/src/main/java/org/scijava/display/AbstractDisplay.java index 1b84f07b9..534c5d31e 100644 --- a/src/main/java/org/scijava/display/AbstractDisplay.java +++ b/src/main/java/org/scijava/display/AbstractDisplay.java @@ -75,7 +75,7 @@ public abstract class AbstractDisplay extends AbstractRichPlugin implements public AbstractDisplay(final Class type) { this.type = type; - objects = new ArrayList(); + objects = new ArrayList<>(); } // -- AbstractDisplay methods -- diff --git a/src/main/java/org/scijava/display/DefaultDisplayService.java b/src/main/java/org/scijava/display/DefaultDisplayService.java index 40f94b786..ac441a0f3 100644 --- a/src/main/java/org/scijava/display/DefaultDisplayService.java +++ b/src/main/java/org/scijava/display/DefaultDisplayService.java @@ -80,7 +80,7 @@ public final class DefaultDisplayService extends AbstractService implements // -- instance variables -- private final LinkedList> displayList = - new LinkedList>(); + new LinkedList<>(); // -- DisplayService methods -- @@ -183,7 +183,7 @@ public Display getDisplay(final String name) { @Override public List> getDisplays(final Object o) { - final ArrayList> displays = new ArrayList>(); + final ArrayList> displays = new ArrayList<>(); for (final Display display : getDisplays()) { if (display.isDisplaying(o)) displays.add(display); } diff --git a/src/main/java/org/scijava/display/DisplayPostprocessor.java b/src/main/java/org/scijava/display/DisplayPostprocessor.java index 4d43d0aa5..d14f0777e 100644 --- a/src/main/java/org/scijava/display/DisplayPostprocessor.java +++ b/src/main/java/org/scijava/display/DisplayPostprocessor.java @@ -96,7 +96,7 @@ private void handleOutput(final String defaultName, final Object output) { } final boolean addToExisting = addToExisting(output); - final ArrayList> displays = new ArrayList>(); + final ArrayList> displays = new ArrayList<>(); // get list of existing displays currently visualizing this output final List> existingDisplays = diff --git a/src/main/java/org/scijava/event/DefaultEventHistory.java b/src/main/java/org/scijava/event/DefaultEventHistory.java index 541528fcd..9cc78716d 100644 --- a/src/main/java/org/scijava/event/DefaultEventHistory.java +++ b/src/main/java/org/scijava/event/DefaultEventHistory.java @@ -53,10 +53,10 @@ public class DefaultEventHistory extends AbstractService implements private EventService eventService; /** Event details that have been recorded. */ - private ArrayList history = new ArrayList(); + private ArrayList history = new ArrayList<>(); private ArrayList listeners = - new ArrayList(); + new ArrayList<>(); private boolean active; diff --git a/src/main/java/org/scijava/event/DefaultEventService.java b/src/main/java/org/scijava/event/DefaultEventService.java index 3e41c1023..8a26e0c23 100644 --- a/src/main/java/org/scijava/event/DefaultEventService.java +++ b/src/main/java/org/scijava/event/DefaultEventService.java @@ -87,13 +87,13 @@ public class DefaultEventService extends AbstractService implements * A cache for mapping {@link Method}s to the {@link SciJavaEvent} class taken * as parameters. Only methods with event parameters will cached here. */ - private final Map> eventClasses = new HashMap>(); + private final Map> eventClasses = new HashMap<>(); /** * Set of claimed {@link EventHandler#key()}s. Additional event handlers * specifying the same key will be ignored rather than subscribed. */ - private final HashSet keys = new HashSet(); + private final HashSet keys = new HashSet<>(); // -- EventService methods -- @@ -118,7 +118,7 @@ public List> subscribe(final Object o) { ClassUtils.getAnnotatedMethods(o.getClass(), EventHandler.class); if (!eventHandlers.isEmpty()) { - subscribers = new ArrayList>(); + subscribers = new ArrayList<>(); for (final Method m : eventHandlers) { // verify that the event handler method is valid final Class eventClass = getEventClass(m); @@ -203,7 +203,7 @@ private void unsubscribe(final Class c, private EventSubscriber subscribe( final Class c, final Object o, final Method m) { - final ProxySubscriber subscriber = new ProxySubscriber(c, o, m); + final ProxySubscriber subscriber = new ProxySubscriber<>(c, o, m); subscribe(c, subscriber); return subscriber; } @@ -233,7 +233,7 @@ private Class getEventClass(final Method m) { // -- Event handlers garbage collection preventer -- private WeakHashMap>> keepEm = - new WeakHashMap>>(); + new WeakHashMap<>(); /** * Prevents {@link ProxySubscriber} instances from being garbage collected @@ -255,7 +255,7 @@ private Class getEventClass(final Method m) { private synchronized void keepIt(final Object o, final ProxySubscriber subscriber) { List> list = keepEm.get(o); if (list == null) { - list = new ArrayList>(); + list = new ArrayList<>(); keepEm.put(o, list); } list.add(subscriber); diff --git a/src/main/java/org/scijava/input/DefaultInputService.java b/src/main/java/org/scijava/input/DefaultInputService.java index d806b9042..ebb23aec3 100644 --- a/src/main/java/org/scijava/input/DefaultInputService.java +++ b/src/main/java/org/scijava/input/DefaultInputService.java @@ -69,9 +69,9 @@ public class DefaultInputService extends AbstractService implements private boolean metaDown = false; private boolean shiftDown = false; - private HashSet pressedKeys = new HashSet(); + private HashSet pressedKeys = new HashSet<>(); - private HashSet buttonsDown = new HashSet(); + private HashSet buttonsDown = new HashSet<>(); private Display display; private int lastX = -1, lastY = -1; diff --git a/src/main/java/org/scijava/input/KeyCode.java b/src/main/java/org/scijava/input/KeyCode.java index a01ff8663..613b87fb8 100644 --- a/src/main/java/org/scijava/input/KeyCode.java +++ b/src/main/java/org/scijava/input/KeyCode.java @@ -601,10 +601,10 @@ public enum KeyCode { UNDEFINED(0x0); private static final Map CODES = - new HashMap(); + new HashMap<>(); private static final Map NAMES = - new HashMap(); + new HashMap<>(); static { for (final KeyCode keyCode : values()) { diff --git a/src/main/java/org/scijava/io/AbstractDataHandle.java b/src/main/java/org/scijava/io/AbstractDataHandle.java index 64ac47c77..ec1977163 100644 --- a/src/main/java/org/scijava/io/AbstractDataHandle.java +++ b/src/main/java/org/scijava/io/AbstractDataHandle.java @@ -200,7 +200,7 @@ public String findString(final boolean saveString, final int blockSize, @SuppressWarnings("resource") final InputStreamReader in = - new InputStreamReader(new DataHandleInputStream(this), getEncoding()); + new InputStreamReader(new DataHandleInputStream<>(this), getEncoding()); final char[] buf = new char[blockSize]; long loc = 0; while (loc < maxLen && offset() < length() - 1) { diff --git a/src/main/java/org/scijava/io/DefaultRecentFileService.java b/src/main/java/org/scijava/io/DefaultRecentFileService.java index 90a5b0198..1f7cd3c03 100644 --- a/src/main/java/org/scijava/io/DefaultRecentFileService.java +++ b/src/main/java/org/scijava/io/DefaultRecentFileService.java @@ -165,7 +165,7 @@ public List getRecentFiles() { @Override public void initialize() { loadList(); - recentModules = new HashMap(); + recentModules = new HashMap<>(); for (final String path : recentFiles) { recentModules.put(path, createInfo(path)); } @@ -201,7 +201,7 @@ private ModuleInfo createInfo(final String path) { final CommandInfo info = new CommandInfo(commandClassName); // hard code path to open as a preset - final HashMap presets = new HashMap(); + final HashMap presets = new HashMap<>(); presets.put("inputFile", path); info.setPresets(presets); diff --git a/src/main/java/org/scijava/io/URILocation.java b/src/main/java/org/scijava/io/URILocation.java index cb2d2022c..fb22b0e68 100644 --- a/src/main/java/org/scijava/io/URILocation.java +++ b/src/main/java/org/scijava/io/URILocation.java @@ -92,7 +92,7 @@ public URI getURI() { * @return A map of the decoded key/value pairs. */ private Map decodeQuery(final String query) { - final Map map = new LinkedHashMap(); + final Map map = new LinkedHashMap<>(); if (query == null) return map; for (final String param : query.split("&")) { final int equals = param.indexOf("="); diff --git a/src/main/java/org/scijava/log/AbstractLogService.java b/src/main/java/org/scijava/log/AbstractLogService.java index 135c90dd3..f183c77da 100644 --- a/src/main/java/org/scijava/log/AbstractLogService.java +++ b/src/main/java/org/scijava/log/AbstractLogService.java @@ -47,7 +47,7 @@ public abstract class AbstractLogService extends AbstractService implements LogS private int currentLevel = System.getenv("DEBUG") == null ? INFO : DEBUG; private Map classAndPackageLevels = - new HashMap(); + new HashMap<>(); // -- abstract methods -- diff --git a/src/main/java/org/scijava/main/DefaultMainService.java b/src/main/java/org/scijava/main/DefaultMainService.java index 725eaaa09..7511ea501 100644 --- a/src/main/java/org/scijava/main/DefaultMainService.java +++ b/src/main/java/org/scijava/main/DefaultMainService.java @@ -54,7 +54,7 @@ public class DefaultMainService extends AbstractService implements MainService { @Parameter(required = false) private LogService log; - private final List
    mains = new ArrayList
    (); + private final List
    mains = new ArrayList<>(); @Override public int execMains() { diff --git a/src/main/java/org/scijava/main/console/MainArgument.java b/src/main/java/org/scijava/main/console/MainArgument.java index 1311008a7..c7608b37b 100644 --- a/src/main/java/org/scijava/main/console/MainArgument.java +++ b/src/main/java/org/scijava/main/console/MainArgument.java @@ -72,7 +72,7 @@ public void handle(final LinkedList args) { args.removeFirst(); // --main / --main-class final String className = args.removeFirst(); - final List argList = new ArrayList(); + final List argList = new ArrayList<>(); while (!args.isEmpty() && !isFlag(args) && !isSeparator(args)) { argList.add(args.removeFirst()); } diff --git a/src/main/java/org/scijava/menu/DefaultMenuService.java b/src/main/java/org/scijava/menu/DefaultMenuService.java index d128cca83..39dc744d4 100644 --- a/src/main/java/org/scijava/menu/DefaultMenuService.java +++ b/src/main/java/org/scijava/menu/DefaultMenuService.java @@ -145,12 +145,12 @@ private synchronized void addModules(final Collection items, { // categorize modules by menu root final HashMap> modulesByMenuRoot = - new HashMap>(); + new HashMap<>(); for (final ModuleInfo info : items) { final String menuRoot = info.getMenuRoot(); ArrayList modules = modulesByMenuRoot.get(menuRoot); if (modules == null) { - modules = new ArrayList(); + modules = new ArrayList<>(); modulesByMenuRoot.put(menuRoot, modules); } modules.add(info); @@ -192,7 +192,7 @@ private HashMap rootMenus() { /** Initializes {@link #rootMenus}. */ private synchronized void initRootMenus() { if (rootMenus != null) return; - final HashMap map = new HashMap(); + final HashMap map = new HashMap<>(); final List allModules = moduleService.getModules(); addModules(allModules, map); diff --git a/src/main/java/org/scijava/menu/ShadowMenu.java b/src/main/java/org/scijava/menu/ShadowMenu.java index ec9b90b28..13745d286 100644 --- a/src/main/java/org/scijava/menu/ShadowMenu.java +++ b/src/main/java/org/scijava/menu/ShadowMenu.java @@ -135,7 +135,7 @@ private ShadowMenu(final Context context, final ModuleInfo moduleInfo, } this.menuDepth = menuDepth; this.parent = parent; - children = new HashMap(); + children = new HashMap<>(); } // -- ShadowMenu methods -- @@ -187,7 +187,7 @@ public ShadowMenu getParent() { public List getChildren() { // copy the children table into an ordered list final List childList = - new ArrayList(children.values()); + new ArrayList<>(children.values()); // sort the list by weight then alphabetically Collections.sort(childList); return childList; @@ -270,7 +270,7 @@ public boolean update(final ModuleInfo module) { * @return true if at least one module was successfully updated */ public boolean updateAll(final Collection c) { - final HashSet nodes = new HashSet(); + final HashSet nodes = new HashSet<>(); for (final ModuleInfo info : c) { final ShadowMenu removed = removeInternal(info); if (removed == null) continue; // was not in menu structure @@ -361,7 +361,7 @@ public boolean add(final ModuleInfo o) { */ @Override public boolean addAll(final Collection c) { - final HashSet nodes = new HashSet(); + final HashSet nodes = new HashSet<>(); for (final ModuleInfo info : c) { if (!info.isVisible()) continue; final ShadowMenu node = addInternal(info); @@ -416,7 +416,7 @@ public boolean remove(final Object o) { @Override public boolean removeAll(final Collection c) { - final HashSet nodes = new HashSet(); + final HashSet nodes = new HashSet<>(); for (final Object o : c) { if (!(o instanceof ModuleInfo)) continue; final ModuleInfo info = (ModuleInfo) o; @@ -430,7 +430,7 @@ public boolean removeAll(final Collection c) { @Override public boolean retainAll(final Collection c) { - final ArrayList toRemove = new ArrayList(); + final ArrayList toRemove = new ArrayList<>(); for (final ModuleInfo info : this) { if (!c.contains(info)) toRemove.add(info); } diff --git a/src/main/java/org/scijava/menu/ShadowMenuIterator.java b/src/main/java/org/scijava/menu/ShadowMenuIterator.java index 884cd5ab5..7b13e3f23 100644 --- a/src/main/java/org/scijava/menu/ShadowMenuIterator.java +++ b/src/main/java/org/scijava/menu/ShadowMenuIterator.java @@ -52,7 +52,7 @@ public class ShadowMenuIterator implements Iterator { public ShadowMenuIterator(final ShadowMenu node) { this.node = node; final List children = node.getChildren(); - childIterators = new ArrayList(); + childIterators = new ArrayList<>(); for (final ShadowMenu child : children) { childIterators.add(new ShadowMenuIterator(child)); } diff --git a/src/main/java/org/scijava/module/AbstractModule.java b/src/main/java/org/scijava/module/AbstractModule.java index 0406bdb71..d8c0433e2 100644 --- a/src/main/java/org/scijava/module/AbstractModule.java +++ b/src/main/java/org/scijava/module/AbstractModule.java @@ -54,9 +54,9 @@ public abstract class AbstractModule implements Module { private MethodRef initializerRef; public AbstractModule() { - inputs = new HashMap(); - outputs = new HashMap(); - resolvedInputs = new HashSet(); + inputs = new HashMap<>(); + outputs = new HashMap<>(); + resolvedInputs = new HashSet<>(); } // -- Module methods -- @@ -152,7 +152,7 @@ public void setResolved(final String name, final boolean resolved) { private Map createMap(final Iterable> items, final boolean outputMap) { - final Map map = new HashMap(); + final Map map = new HashMap<>(); for (final ModuleItem item : items) { final String name = item.getName(); final Object value = outputMap ? getOutput(name) : getInput(name); diff --git a/src/main/java/org/scijava/module/AbstractModuleInfo.java b/src/main/java/org/scijava/module/AbstractModuleInfo.java index 1b6461b6b..581eb4ec5 100644 --- a/src/main/java/org/scijava/module/AbstractModuleInfo.java +++ b/src/main/java/org/scijava/module/AbstractModuleInfo.java @@ -287,10 +287,10 @@ private ModuleItem castItem(final ModuleItem item, private synchronized void initParameters() { if (initialized) return; // already initialized - inputMap = new HashMap>(); - outputMap = new HashMap>(); - inputList = new ArrayList>(); - outputList = new ArrayList>(); + inputMap = new HashMap<>(); + outputMap = new HashMap<>(); + inputList = new ArrayList<>(); + outputList = new ArrayList<>(); parseParameters(); diff --git a/src/main/java/org/scijava/module/DefaultModuleService.java b/src/main/java/org/scijava/module/DefaultModuleService.java index 67b1a1907..0d1e26106 100644 --- a/src/main/java/org/scijava/module/DefaultModuleService.java +++ b/src/main/java/org/scijava/module/DefaultModuleService.java @@ -410,7 +410,7 @@ private Module getRegisteredModuleInstance(final ModuleInfo info) { private Map createMap(final Object[] values) { if (values == null || values.length == 0) return null; - final HashMap inputMap = new HashMap(); + final HashMap inputMap = new HashMap<>(); if (values.length % 2 != 0) { log.error("Ignoring extraneous argument: " + values[values.length - 1]); @@ -466,7 +466,7 @@ private void assignInputs(final Module module, private ModuleItem getTypedSingleItem(final Module module, final Class type, final Iterable> items) { - Set> types = new HashSet>(); + Set> types = new HashSet<>(); types.add(type); @SuppressWarnings("unchecked") ModuleItem result = (ModuleItem) getSingleItem(module, types, items); diff --git a/src/main/java/org/scijava/module/DefaultMutableModule.java b/src/main/java/org/scijava/module/DefaultMutableModule.java index e40f54498..d2fe1b1c1 100644 --- a/src/main/java/org/scijava/module/DefaultMutableModule.java +++ b/src/main/java/org/scijava/module/DefaultMutableModule.java @@ -59,7 +59,7 @@ public MutableModuleItem addInput(final String name, final Class type) { final DefaultMutableModuleItem item = - new DefaultMutableModuleItem(this, name, type); + new DefaultMutableModuleItem<>(this, name, type); addInput(item); return item; } @@ -74,7 +74,7 @@ public MutableModuleItem addOutput(final String name, final Class type) { final DefaultMutableModuleItem item = - new DefaultMutableModuleItem(this, name, type); + new DefaultMutableModuleItem<>(this, name, type); addOutput(item); return item; } diff --git a/src/main/java/org/scijava/module/DefaultMutableModuleItem.java b/src/main/java/org/scijava/module/DefaultMutableModuleItem.java index b833cb34f..4d95ed91e 100644 --- a/src/main/java/org/scijava/module/DefaultMutableModuleItem.java +++ b/src/main/java/org/scijava/module/DefaultMutableModuleItem.java @@ -66,7 +66,7 @@ public class DefaultMutableModuleItem extends AbstractModuleItem private T softMaximum; private Number stepSize; private int columnCount; - private final List choices = new ArrayList(); + private final List choices = new ArrayList<>(); private String name; private String label; private String description; diff --git a/src/main/java/org/scijava/module/MethodRef.java b/src/main/java/org/scijava/module/MethodRef.java index aaca5bbd2..45706d786 100644 --- a/src/main/java/org/scijava/module/MethodRef.java +++ b/src/main/java/org/scijava/module/MethodRef.java @@ -51,7 +51,7 @@ public class MethodRef implements Validated { /** List of problems when initializing the method reference. */ private final List problems = - new ArrayList(); + new ArrayList<>(); public MethodRef(final Class clazz, final String methodName, final Class... params) diff --git a/src/main/java/org/scijava/object/DefaultObjectService.java b/src/main/java/org/scijava/object/DefaultObjectService.java index a9d560980..3c0f98780 100644 --- a/src/main/java/org/scijava/object/DefaultObjectService.java +++ b/src/main/java/org/scijava/object/DefaultObjectService.java @@ -105,7 +105,7 @@ public void removeObject(final Object obj) { @Override public void initialize() { - objectIndex = new ObjectIndex(Object.class); + objectIndex = new ObjectIndex<>(Object.class); } // -- Event handlers -- diff --git a/src/main/java/org/scijava/object/ObjectIndex.java b/src/main/java/org/scijava/object/ObjectIndex.java index a953dbe22..7dafa1831 100644 --- a/src/main/java/org/scijava/object/ObjectIndex.java +++ b/src/main/java/org/scijava/object/ObjectIndex.java @@ -80,13 +80,13 @@ public class ObjectIndex implements Collection { * —Russell Hoban, Riddley Walker */ protected final Map, List> hoard = - new ConcurrentHashMap, List>(); + new ConcurrentHashMap<>(); private final Class baseClass; /** List of objects to add later as needed (i.e., lazily). */ private final List> pending = - new LinkedList>(); + new LinkedList<>(); public ObjectIndex(final Class baseClass) { this.baseClass = baseClass; @@ -133,7 +133,7 @@ public List get(final Class type) { List list = retrieveList(type); // NB: Return a copy of the data, to facilitate thread safety. - list = new ArrayList(list); + list = new ArrayList<>(list); return list; } @@ -237,7 +237,7 @@ public void clear() { @Override public String toString() { - final List> classes = new ArrayList>(hoard.keySet()); + final List> classes = new ArrayList<>(hoard.keySet()); Collections.sort(classes, new Comparator>() { @Override @@ -285,13 +285,13 @@ protected boolean remove(final Object o, final boolean batch) { } private Map, List[]> type2Lists = - new HashMap, List[]>(); + new HashMap<>(); protected synchronized List[] retrieveListsForType(final Class type) { final List[] lists = type2Lists.get(type); if (lists != null) return lists; - final ArrayList> listOfLists = new ArrayList>(); + final ArrayList> listOfLists = new ArrayList<>(); for (final Class c : getTypes(type)) { listOfLists.add(retrieveList(c)); } @@ -342,13 +342,13 @@ protected boolean removeFromList(final Object obj, final List list, // -- Helper methods -- private static Map, Class[]> typeMap = - new HashMap, Class[]>(); + new HashMap<>(); /** Gets a new set containing the type and all its supertypes. */ protected static synchronized Class[] getTypes(final Class type) { Class[] types = typeMap.get(type); if (types != null) return types; - final Set>set = new LinkedHashSet>(); + final Set>set = new LinkedHashSet<>(); set.add(All.class); // NB: Always include the "All" class. getTypes(type, set); types = set.toArray(new Class[set.size()]); @@ -374,7 +374,7 @@ private static synchronized void getTypes(final Class type, protected List retrieveList(final Class type) { List list = hoard.get(type); if (list == null) { - list = new ArrayList(); + list = new ArrayList<>(); hoard.put(type, list); } return list; diff --git a/src/main/java/org/scijava/object/SortedObjectIndex.java b/src/main/java/org/scijava/object/SortedObjectIndex.java index 2a1bd99db..c5270529d 100644 --- a/src/main/java/org/scijava/object/SortedObjectIndex.java +++ b/src/main/java/org/scijava/object/SortedObjectIndex.java @@ -93,15 +93,15 @@ public boolean addAll(final Collection c) { } private void mergeAfterSorting(final Collection c) { - final List listToMerge = new ArrayList(c); + final List listToMerge = new ArrayList<>(c); Collections.sort(listToMerge); - final Map, List> map = new HashMap, List>(); + final Map, List> map = new HashMap<>(); for (final E e : listToMerge) { for (final Class clazz : getTypes(getType(e))) { final List list = retrieveList(clazz); List list2 = map.get(clazz); if (list2 == null) { - list2 = list.size() == 0 ? (List)list : new ArrayList(); + list2 = list.size() == 0 ? (List)list : new ArrayList<>(); map.put(clazz, list2); } list2.add(e); diff --git a/src/main/java/org/scijava/object/event/ListEvent.java b/src/main/java/org/scijava/object/event/ListEvent.java index 753a9a5fa..037941db7 100644 --- a/src/main/java/org/scijava/object/event/ListEvent.java +++ b/src/main/java/org/scijava/object/event/ListEvent.java @@ -45,7 +45,7 @@ */ public abstract class ListEvent extends SciJavaEvent { - private final List items = new ArrayList(); + private final List items = new ArrayList<>(); public ListEvent(final T o) { items.add(o); diff --git a/src/main/java/org/scijava/parse/DefaultParseService.java b/src/main/java/org/scijava/parse/DefaultParseService.java index 4ea6fbaf2..8142ae59c 100644 --- a/src/main/java/org/scijava/parse/DefaultParseService.java +++ b/src/main/java/org/scijava/parse/DefaultParseService.java @@ -75,7 +75,7 @@ public ItemsList(final String arg) { @Override public Map asMap() { final LinkedHashMap map = - new LinkedHashMap(); + new LinkedHashMap<>(); for (final Item item : this) { map.put(item.name(), item.value()); } diff --git a/src/main/java/org/scijava/plugin/AbstractSingletonService.java b/src/main/java/org/scijava/plugin/AbstractSingletonService.java index f60c76c77..16183e03e 100644 --- a/src/main/java/org/scijava/plugin/AbstractSingletonService.java +++ b/src/main/java/org/scijava/plugin/AbstractSingletonService.java @@ -98,7 +98,7 @@ public void initialize() { @Override public ArrayList get() { - return new ArrayList(getInstances()); + return new ArrayList<>(getInstances()); } }); } @@ -125,7 +125,7 @@ private synchronized void initInstances() { .createInstancesOfType(getPluginType()))); final HashMap, PT> map = - new HashMap, PT>(); + new HashMap<>(); for (final PT plugin : list) { @SuppressWarnings("unchecked") diff --git a/src/main/java/org/scijava/plugin/DefaultPluginFinder.java b/src/main/java/org/scijava/plugin/DefaultPluginFinder.java index 9f2c22424..10b646715 100644 --- a/src/main/java/org/scijava/plugin/DefaultPluginFinder.java +++ b/src/main/java/org/scijava/plugin/DefaultPluginFinder.java @@ -74,7 +74,7 @@ public HashMap findPlugins( final List> plugins) { final HashMap exceptions = - new HashMap(); + new HashMap<>(); // load the annotation indexes final ClassLoader classLoader = getClassLoader(); @@ -108,7 +108,7 @@ private PluginInfo createInfo( final Class pluginType = (Class) plugin.type(); - return new PluginInfo(className, pluginType, plugin, classLoader); + return new PluginInfo<>(className, pluginType, plugin, classLoader); } private ClassLoader getClassLoader() { @@ -137,7 +137,7 @@ public SysPropBlacklist() { final String sysProp = System.getProperty("scijava.plugin.blacklist"); final String[] regexes = // sysProp == null ? new String[0] : sysProp.split(":"); - patterns = new ArrayList(regexes.length); + patterns = new ArrayList<>(regexes.length); for (final String regex : regexes) { try { patterns.add(Pattern.compile(regex)); diff --git a/src/main/java/org/scijava/plugin/DefaultPluginService.java b/src/main/java/org/scijava/plugin/DefaultPluginService.java index 796870681..923d644da 100644 --- a/src/main/java/org/scijava/plugin/DefaultPluginService.java +++ b/src/main/java/org/scijava/plugin/DefaultPluginService.java @@ -183,7 +183,7 @@ public List> getPluginsOfType( public List> getPluginsOfClass(final Class

    pluginClass, final Class type) { - final ArrayList> result = new ArrayList>(); + final ArrayList> result = new ArrayList<>(); findPluginsOfClass(pluginClass, getPluginsOfType(type), result); filterNonmatchingClasses(pluginClass, result); return result; @@ -203,7 +203,7 @@ public List> getPluginsOfClass( getPluginsOfClass(final String className, final Class type) { final ArrayList> result = - new ArrayList>(); + new ArrayList<>(); findPluginsOfClass(className, getPluginsOfType(type), result); return result; } @@ -220,7 +220,7 @@ public List createInstancesOfType( public List createInstances( final List> infos) { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); for (final PluginInfo info : infos) { final PT p = createInstance(info); if (p != null) list.add(p); diff --git a/src/main/java/org/scijava/plugin/PluginIndex.java b/src/main/java/org/scijava/plugin/PluginIndex.java index 629aa52b5..38ffa36e6 100644 --- a/src/main/java/org/scijava/plugin/PluginIndex.java +++ b/src/main/java/org/scijava/plugin/PluginIndex.java @@ -103,7 +103,7 @@ public PluginIndex(final PluginFinder pluginFinder) { */ public void discover() { if (pluginFinder == null) return; - final ArrayList> plugins = new ArrayList>(); + final ArrayList> plugins = new ArrayList<>(); exceptions = pluginFinder.findPlugins(plugins); addAll(plugins); } diff --git a/src/main/java/org/scijava/prefs/DefaultPrefService.java b/src/main/java/org/scijava/prefs/DefaultPrefService.java index 327706198..681fa3e50 100644 --- a/src/main/java/org/scijava/prefs/DefaultPrefService.java +++ b/src/main/java/org/scijava/prefs/DefaultPrefService.java @@ -431,7 +431,7 @@ public void putMap(final Map map) { } public Map getMap() { - final Map map = new HashMap(); + final Map map = new HashMap<>(); final String[] keys = keys(); for (int index = 0; index < keys.length; index++) { map.put(keys[index], get(keys[index])); @@ -447,7 +447,7 @@ public void putList(final List list) { } public List getList() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (int index = 0; index < 1000; index++) { final String value = get("" + index); if (value == null) { diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index 35b145dbc..fcc9ed717 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -121,7 +121,7 @@ public ScriptLanguageIndex getIndex() { @Override public List getLanguages() { - return new ArrayList(getIndex()); + return new ArrayList<>(getIndex()); } @Override @@ -359,7 +359,7 @@ private synchronized void initScriptLanguageIndex() { private synchronized void initScriptDirs() { if (scriptDirs != null) return; - final ArrayList dirs = new ArrayList(); + final ArrayList dirs = new ArrayList<>(); // append default script directories final File baseDir = AppUtils.getBaseDirectory(getClass()); //FIXME @@ -379,16 +379,16 @@ private synchronized void initScriptDirs() { /** Initializes {@link #menuPrefixes}. */ private synchronized void initMenuPrefixes() { if (menuPrefixes != null) return; - menuPrefixes = new HashMap(); + menuPrefixes = new HashMap<>(); } /** Initializes {@link #scripts}. */ private synchronized void initScripts() { if (scripts != null) return; // already initialized - final HashMap map = new HashMap(); + final HashMap map = new HashMap<>(); - final ArrayList scriptList = new ArrayList(); + final ArrayList scriptList = new ArrayList<>(); new ScriptFinder(this).findScripts(scriptList); for (final ScriptInfo info : scriptList) { @@ -402,7 +402,7 @@ private synchronized void initScripts() { private synchronized void initAliasMap() { if (aliasMap != null) return; // already initialized - final HashMap> map = new HashMap>(); + final HashMap> map = new HashMap<>(); // primitives addAliases(map, boolean.class, byte.class, char.class, double.class, diff --git a/src/main/java/org/scijava/script/History.java b/src/main/java/org/scijava/script/History.java index c2fe584bb..22208d189 100644 --- a/src/main/java/org/scijava/script/History.java +++ b/src/main/java/org/scijava/script/History.java @@ -48,7 +48,7 @@ class History { private final PrefService prefs; private final String name; - private final LastRecentlyUsed entries = new LastRecentlyUsed(MAX_ENTRIES); + private final LastRecentlyUsed entries = new LastRecentlyUsed<>(MAX_ENTRIES); private String currentCommand = ""; private int position = -1; diff --git a/src/main/java/org/scijava/script/InvocationObject.java b/src/main/java/org/scijava/script/InvocationObject.java index 44591f9ec..5d5b96b59 100644 --- a/src/main/java/org/scijava/script/InvocationObject.java +++ b/src/main/java/org/scijava/script/InvocationObject.java @@ -43,7 +43,7 @@ public class InvocationObject { public String moduleCalled; public ArrayList parameterObjects = - new ArrayList(); + new ArrayList<>(); public InvocationObject(final String moduleCalled) { this.moduleCalled = moduleCalled; diff --git a/src/main/java/org/scijava/script/ScriptFinder.java b/src/main/java/org/scijava/script/ScriptFinder.java index f0deabdd9..8e75e2ed1 100644 --- a/src/main/java/org/scijava/script/ScriptFinder.java +++ b/src/main/java/org/scijava/script/ScriptFinder.java @@ -81,7 +81,7 @@ public void findScripts(final List scripts) { int scriptCount = 0; - final HashSet scriptFiles = new HashSet(); + final HashSet scriptFiles = new HashSet<>(); for (final File directory : directories) { if (!directory.exists()) { log.debug("Ignoring non-existent scripts directory: " + diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index d23134478..7f68d3aa2 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -393,7 +393,7 @@ private void checkValid(final boolean valid, final String param) /** Adds an output for the value returned by the script itself. */ private void addReturnValue() throws ScriptException { - final HashMap attrs = new HashMap(); + final HashMap attrs = new HashMap<>(); attrs.put("type", "OUTPUT"); addItem(ScriptModule.RETURN_VALUE, Object.class, attrs); } @@ -402,7 +402,7 @@ private void addItem(final String name, final Class type, final Map attrs) { final DefaultMutableModuleItem item = - new DefaultMutableModuleItem(this, name, type); + new DefaultMutableModuleItem<>(this, name, type); for (final String key : attrs.keySet()) { final Object value = attrs.get(key); assignAttribute(item, key, value); @@ -449,7 +449,7 @@ private T as(final Object v, final Class type) { } private List asList(final Object v, final Class type) { - final ArrayList result = new ArrayList(); + final ArrayList result = new ArrayList<>(); final List list = as(v, List.class); for (final Object item : list) { result.add(as(item, type)); diff --git a/src/main/java/org/scijava/script/ScriptLanguageIndex.java b/src/main/java/org/scijava/script/ScriptLanguageIndex.java index f05329780..229bd55d9 100644 --- a/src/main/java/org/scijava/script/ScriptLanguageIndex.java +++ b/src/main/java/org/scijava/script/ScriptLanguageIndex.java @@ -53,10 +53,10 @@ public class ScriptLanguageIndex extends ArrayList { private static final long serialVersionUID = 1L; private final Map byExtension = - new HashMap(); + new HashMap<>(); private final Map byName = - new HashMap(); + new HashMap<>(); private final LogService log; diff --git a/src/main/java/org/scijava/script/ScriptREPL.java b/src/main/java/org/scijava/script/ScriptREPL.java index 8e85ad77f..639b11a92 100644 --- a/src/main/java/org/scijava/script/ScriptREPL.java +++ b/src/main/java/org/scijava/script/ScriptREPL.java @@ -204,8 +204,8 @@ public void help() { public void vars() { if (interpreter == null) return; // no active script language - final List keys = new ArrayList(); - final List types = new ArrayList(); + final List keys = new ArrayList<>(); + final List types = new ArrayList<>(); final Bindings bindings = interpreter.getBindings(); for (final String key : bindings.keySet()) { final Object value = bindings.get(key); @@ -241,9 +241,9 @@ public void lang(final String langName) { } public void langs() { - final List names = new ArrayList(); - final List versions = new ArrayList(); - final List aliases = new ArrayList(); + final List names = new ArrayList<>(); + final List versions = new ArrayList<>(); + final List aliases = new ArrayList<>(); for (final ScriptLanguage lang : scriptService.getLanguages()) { names.add(lang.getLanguageName()); versions.add(lang.getLanguageVersion()); @@ -297,7 +297,7 @@ private void copyBindings(final ScriptInterpreter src, } private List gateways() { - final ArrayList gateways = new ArrayList(); + final ArrayList gateways = new ArrayList<>(); if (pluginService == null) return gateways; // HACK: Instantiating a Gateway with the noargs constructor spins // up a second Context, which is not what we want. Perhaps SJC should diff --git a/src/main/java/org/scijava/service/ServiceHelper.java b/src/main/java/org/scijava/service/ServiceHelper.java index f239f811b..52c6583fb 100644 --- a/src/main/java/org/scijava/service/ServiceHelper.java +++ b/src/main/java/org/scijava/service/ServiceHelper.java @@ -115,13 +115,13 @@ public ServiceHelper(final Context context, setContext(context); log = context.getService(LogService.class); if (log == null) log = new StderrLogService(); - classPoolMap = new HashMap, Double>(); - classPoolList = new ArrayList>(); + classPoolMap = new HashMap<>(); + classPoolList = new ArrayList<>(); findServiceClasses(classPoolMap, classPoolList); if (classPoolList.isEmpty()) { log.warn("Class pool is empty: forgot to call Thread#setClassLoader?"); } - this.serviceClasses = new ArrayList>(); + this.serviceClasses = new ArrayList<>(); if (serviceClasses == null) { // load all discovered services this.serviceClasses.addAll(classPoolList); diff --git a/src/main/java/org/scijava/test/TestUtils.java b/src/main/java/org/scijava/test/TestUtils.java index 36b29c72d..ec3667ba4 100644 --- a/src/main/java/org/scijava/test/TestUtils.java +++ b/src/main/java/org/scijava/test/TestUtils.java @@ -215,7 +215,7 @@ public static Map.Entry, String> getCallingCodeLocation(final Class loader + ")!"); } final String suffix = element.getMethodName() + "-L" + element.getLineNumber(); - return new AbstractMap.SimpleEntry, String>(clazz, suffix); + return new AbstractMap.SimpleEntry<>(clazz, suffix); } throw new UnsupportedOperationException("No calling class outside " + thisClassName + " found!"); } diff --git a/src/main/java/org/scijava/thread/DefaultThreadService.java b/src/main/java/org/scijava/thread/DefaultThreadService.java index ae136e921..c63016cc7 100644 --- a/src/main/java/org/scijava/thread/DefaultThreadService.java +++ b/src/main/java/org/scijava/thread/DefaultThreadService.java @@ -58,7 +58,7 @@ public final class DefaultThreadService extends AbstractService implements private static final String SCIJAVA_THREAD_PREFIX = "SciJava-"; private static WeakHashMap parents = - new WeakHashMap(); + new WeakHashMap<>(); @Parameter private LogService log; diff --git a/src/main/java/org/scijava/tool/DefaultToolService.java b/src/main/java/org/scijava/tool/DefaultToolService.java index 15cc3fdee..76061a22f 100644 --- a/src/main/java/org/scijava/tool/DefaultToolService.java +++ b/src/main/java/org/scijava/tool/DefaultToolService.java @@ -344,7 +344,7 @@ private Tool activeTool() { private synchronized void initAlwaysActiveTools() { if (alwaysActiveTools != null) return; // already initialized - final HashMap map = new HashMap(); + final HashMap map = new HashMap<>(); for (final Tool tool : alwaysActiveToolList()) { map.put(tool.getInfo().getName(), tool); } @@ -356,7 +356,7 @@ private synchronized void initAlwaysActiveTools() { private synchronized void initAlwaysActiveToolList() { if (alwaysActiveToolList != null) return; // already initialized - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); for (final Tool tool : getInstances()) { if (!tool.isAlwaysActive()) continue; list.add(tool); @@ -369,7 +369,7 @@ private synchronized void initAlwaysActiveToolList() { private synchronized void initTools() { if (tools != null) return; // already initialized - final HashMap map = new HashMap(); + final HashMap map = new HashMap<>(); for (final Tool tool : toolList()) { map.put(tool.getInfo().getName(), tool); } @@ -381,7 +381,7 @@ private synchronized void initTools() { private synchronized void initToolList() { if (toolList != null) return; // already initialized - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); for (final Tool tool : getInstances()) { if (tool.isAlwaysActive()) continue; list.add(tool); diff --git a/src/main/java/org/scijava/ui/DefaultUIService.java b/src/main/java/org/scijava/ui/DefaultUIService.java index 7f8907dbb..8a38fb33b 100644 --- a/src/main/java/org/scijava/ui/DefaultUIService.java +++ b/src/main/java/org/scijava/ui/DefaultUIService.java @@ -240,7 +240,7 @@ public List getAvailableUIs() { @Override public List getVisibleUIs() { - final ArrayList uis = new ArrayList(); + final ArrayList uis = new ArrayList<>(); for (final UserInterface ui : uiList()) { if (ui.isVisible()) uis.add(ui); } @@ -366,7 +366,7 @@ public String getStatusMessage(final StatusEvent statusEvent) { public synchronized void dispose() { // dispose active display viewers // NB - copy list to avoid ConcurrentModificationExceptions - final List> viewers = new ArrayList>(); + final List> viewers = new ArrayList<>(); viewers.addAll(displayViewers()); for (final DisplayViewer viewer : viewers) { viewer.dispose(); @@ -505,9 +505,9 @@ private Map uiMap() { private synchronized void discoverUIs() { if (initialized) return; - displayViewers = new ArrayList>(); - uiList = new ArrayList(); - uiMap = new HashMap(); + displayViewers = new ArrayList<>(); + uiList = new ArrayList<>(); + uiMap = new HashMap<>(); final List> infos = pluginService.getPluginsOfType(UserInterface.class); diff --git a/src/main/java/org/scijava/ui/dnd/MIMEType.java b/src/main/java/org/scijava/ui/dnd/MIMEType.java index 7cef9096f..71618b2b4 100644 --- a/src/main/java/org/scijava/ui/dnd/MIMEType.java +++ b/src/main/java/org/scijava/ui/dnd/MIMEType.java @@ -90,8 +90,8 @@ public MIMEType(final String mimeType, final Class javaType) { base = st.nextToken().trim(); // parse parameters - final ArrayList names = new ArrayList(); - final HashMap map = new HashMap(); + final ArrayList names = new ArrayList<>(); + final HashMap map = new HashMap<>(); while (st.hasMoreTokens()) { final String param = st.nextToken(); final int equals = param.indexOf("="); diff --git a/src/main/java/org/scijava/util/ArrayUtils.java b/src/main/java/org/scijava/util/ArrayUtils.java index 5e415caae..34e6169bf 100644 --- a/src/main/java/org/scijava/util/ArrayUtils.java +++ b/src/main/java/org/scijava/util/ArrayUtils.java @@ -114,11 +114,11 @@ public static Collection toCollection(final Object value) { return new DoubleArray((double[]) value); } if (value instanceof Object[]) { - return new ObjectArray((Object[]) value); + return new ObjectArray<>((Object[]) value); } // This object is neither an array nor a collection. // So we wrap it in a list and return. - final List list = new ObjectArray(Object.class); + final List list = new ObjectArray<>(Object.class); list.add(value); return list; } diff --git a/src/main/java/org/scijava/util/ClassUtils.java b/src/main/java/org/scijava/util/ClassUtils.java index 2ef416612..70631e038 100644 --- a/src/main/java/org/scijava/util/ClassUtils.java +++ b/src/main/java/org/scijava/util/ClassUtils.java @@ -372,7 +372,7 @@ public static List getAnnotatedMethods( List methods = methodCache.getList(c, annotationClass); if (methods == null) { - methods = new ArrayList(); + methods = new ArrayList<>(); getAnnotatedMethods(c, annotationClass, methods); } @@ -425,7 +425,7 @@ public static List getAnnotatedFields( List fields = fieldCache.getList(c, annotationClass); if (fields == null) { - fields = new ArrayList(); + fields = new ArrayList<>(); getAnnotatedFields(c, annotationClass, fields); } @@ -506,7 +506,7 @@ public static void cacheAnnotatedObjects(final Class scannedClass, // Initialize step - determine which queries are solved final Set> keysToDrop = - new HashSet>(); + new HashSet<>(); for (final Class annotationClass : query.keySet()) { // Fields if (fieldCache.getList(scannedClass, annotationClass) != null) { @@ -525,7 +525,7 @@ else if (methodCache.getList(scannedClass, annotationClass) != null) { // Stop now if we know all requested information is cached if (query.isEmpty()) return; - final List> inherited = new ArrayList>(); + final List> inherited = new ArrayList<>(); // cache all parents recursively final Class superClass = scannedClass.getSuperclass(); @@ -882,7 +882,7 @@ public void putList(final Class c, { Map, List> map = get(c); if (map == null) { - map = new HashMap, List>(); + map = new HashMap<>(); put(c, map); } @@ -904,7 +904,7 @@ public List makeList(final Class c, { List elements = getList(c, annotationClass); if (elements == null) { - elements = new ArrayList(); + elements = new ArrayList<>(); putList(c, annotationClass, elements); } return elements; diff --git a/src/main/java/org/scijava/util/Colors.java b/src/main/java/org/scijava/util/Colors.java index 64eafd8e3..409ad5975 100644 --- a/src/main/java/org/scijava/util/Colors.java +++ b/src/main/java/org/scijava/util/Colors.java @@ -197,7 +197,7 @@ public final class Colors { public static final ColorRGB YELLOWGREEN = new ColorRGB(154, 205, 50); private static final Map COLORS = - new HashMap(); + new HashMap<>(); static { for (final Field f : Colors.class.getDeclaredFields()) { diff --git a/src/main/java/org/scijava/util/DebugUtils.java b/src/main/java/org/scijava/util/DebugUtils.java index 869dd34a8..8f199a165 100644 --- a/src/main/java/org/scijava/util/DebugUtils.java +++ b/src/main/java/org/scijava/util/DebugUtils.java @@ -80,7 +80,7 @@ public static String getStackDump() { // sort list of threads by name final ArrayList threads = - new ArrayList(stackTraces.keySet()); + new ArrayList<>(stackTraces.keySet()); Collections.sort(threads, new Comparator() { @Override diff --git a/src/main/java/org/scijava/util/FileUtils.java b/src/main/java/org/scijava/util/FileUtils.java index 06bf48e56..bd2d16910 100644 --- a/src/main/java/org/scijava/util/FileUtils.java +++ b/src/main/java/org/scijava/util/FileUtils.java @@ -574,7 +574,7 @@ else if (protocol.equals("jar")) { final JarURLConnection connection = (JarURLConnection) new URL(baseURL).openConnection(); final JarFile jar = connection.getJarFile(); - for (final JarEntry entry : new IteratorPlus(jar.entries())) { + for (final JarEntry entry : new IteratorPlus<>(jar.entries())) { final String urlEncoded = new URI(null, null, entry.getName(), null).toString(); if (urlEncoded.length() > prefix.length() && // omit directory itself diff --git a/src/main/java/org/scijava/util/IteratorPlus.java b/src/main/java/org/scijava/util/IteratorPlus.java index dc587ecd9..cb706c90a 100644 --- a/src/main/java/org/scijava/util/IteratorPlus.java +++ b/src/main/java/org/scijava/util/IteratorPlus.java @@ -73,7 +73,7 @@ public IteratorPlus(final Iterable iterable) { } public IteratorPlus(final Enumeration enumeration) { - this(new EnumerationIterator(enumeration)); + this(new EnumerationIterator<>(enumeration)); } public IteratorPlus(final Iterator iterator) { diff --git a/src/main/java/org/scijava/util/LastRecentlyUsed.java b/src/main/java/org/scijava/util/LastRecentlyUsed.java index 88057c527..684bc4701 100644 --- a/src/main/java/org/scijava/util/LastRecentlyUsed.java +++ b/src/main/java/org/scijava/util/LastRecentlyUsed.java @@ -70,7 +70,7 @@ public LastRecentlyUsed(int size) { entries = new Object[2 * size]; next = new int[2 * size]; previous = new int[2 * size]; - map = new HashMap(); + map = new HashMap<>(); } /** @@ -364,7 +364,7 @@ protected void assertConsistency() { return; } assert(bottom != 0); - final Set indices = new HashSet(map.values()); + final Set indices = new HashSet<>(map.values()); assert(indices.size() == map.size()); for (int i = 0; i < entries.length; i++) { if (indices.contains(i)) { diff --git a/src/main/java/org/scijava/util/MirrorWebsite.java b/src/main/java/org/scijava/util/MirrorWebsite.java index 1c1138a4f..47a31b43f 100644 --- a/src/main/java/org/scijava/util/MirrorWebsite.java +++ b/src/main/java/org/scijava/util/MirrorWebsite.java @@ -71,8 +71,8 @@ public class MirrorWebsite { private String baseURL; private String basePath; // the local directory for file:// baseURL, otherwise null private File localDirectory; - private Map linkMap = new HashMap(); - private Set missingLinks = new LinkedHashSet(); + private Map linkMap = new HashMap<>(); + private Set missingLinks = new LinkedHashSet<>(); private ExecutorService executorService; private Map jobs; private Set done; @@ -94,8 +94,8 @@ public void run() throws InterruptedException { throw new RuntimeException("Mirroring already in progress!"); executorService = Executors.newFixedThreadPool(threadCount); - done = new TreeSet(); - jobs = new LinkedHashMap(); + done = new TreeSet<>(); + jobs = new LinkedHashMap<>(); mirror("index.html"); } @@ -182,7 +182,7 @@ else if ((" " + previous + " ").indexOf(" " + sourceURL + " ") < 0) } private List getLinks(String relativePath, String path, String html) { - List result = new ArrayList(); + List result = new ArrayList<>(); int offset = -1; for (;;) { @@ -262,7 +262,7 @@ private List ensureUptodate(String path) throws IOException { final String directory = path.substring(0, path.length() - 10); final File[] list = new File(basePath + directory).listFiles(); if (list == null) return Collections.emptyList(); - final List result = new ArrayList(); + final List result = new ArrayList<>(); for (final File item : list) { if (item.isDirectory()) result.add(directory + item.getName() + "/index.html"); else result.add(directory + item.getName()); diff --git a/src/main/java/org/scijava/util/POM.java b/src/main/java/org/scijava/util/POM.java index 7dc50d507..99a57c6da 100644 --- a/src/main/java/org/scijava/util/POM.java +++ b/src/main/java/org/scijava/util/POM.java @@ -268,10 +268,10 @@ public static List getAllPOMs() { return null; } - final ArrayList poms = new ArrayList(); + final ArrayList poms = new ArrayList<>(); // recursively list contents of META-INF/maven/ directories - for (final URL resource : new IteratorPlus(resources)) { + for (final URL resource : new IteratorPlus<>(resources)) { for (final URL url : FileUtils.listContents(resource)) { // look for pom.xml files amongst the contents if (url.getPath().endsWith("/pom.xml")) { diff --git a/src/main/java/org/scijava/util/ReflectedUniverse.java b/src/main/java/org/scijava/util/ReflectedUniverse.java index 968212bfd..a0027b628 100644 --- a/src/main/java/org/scijava/util/ReflectedUniverse.java +++ b/src/main/java/org/scijava/util/ReflectedUniverse.java @@ -86,7 +86,7 @@ public ReflectedUniverse(final URL[] urls) { /** Constructs a new reflected universe that uses the given class loader. */ public ReflectedUniverse(final ClassLoader loader) { - variables = new HashMap(); + variables = new HashMap<>(); this.loader = loader == null ? getClass().getClassLoader() : loader; } diff --git a/src/main/java/org/scijava/util/ServiceCombiner.java b/src/main/java/org/scijava/util/ServiceCombiner.java index f91e182d9..2c6f63d33 100644 --- a/src/main/java/org/scijava/util/ServiceCombiner.java +++ b/src/main/java/org/scijava/util/ServiceCombiner.java @@ -58,7 +58,7 @@ public class ServiceCombiner implements Combiner { public void combine(final File outputDirectory) throws IOException { final Map files = - new HashMap(); + new HashMap<>(); final Enumeration directories = Thread.currentThread().getContextClassLoader().getResources( SERVICES_PREFIX); diff --git a/src/main/java/org/scijava/util/Timing.java b/src/main/java/org/scijava/util/Timing.java index 98f350688..52e54d352 100644 --- a/src/main/java/org/scijava/util/Timing.java +++ b/src/main/java/org/scijava/util/Timing.java @@ -69,7 +69,7 @@ */ public class Timing { private long total = 0, start = System.nanoTime(), tick = start; - private List> list = new ArrayList>(); + private List> list = new ArrayList<>(); public void reset() { tick = System.nanoTime(); diff --git a/src/main/java/org/scijava/util/XML.java b/src/main/java/org/scijava/util/XML.java index 79f0cd741..c195967e9 100644 --- a/src/main/java/org/scijava/util/XML.java +++ b/src/main/java/org/scijava/util/XML.java @@ -242,7 +242,7 @@ public static String cdata(final Element el, final String child) { /** Gets the element nodes from the given node list. */ public static ArrayList elements(final NodeList nodes) { - final ArrayList elements = new ArrayList(); + final ArrayList elements = new ArrayList<>(); if (nodes != null) { for (int i=0; i> inputs = module.getInfo().inputs(); - final ArrayList models = new ArrayList(); + final ArrayList models = new ArrayList<>(); for (final ModuleItem item : inputs) { final WidgetModel model = addInput(inputPanel, module, item); diff --git a/src/main/java/org/scijava/widget/AbstractInputPanel.java b/src/main/java/org/scijava/widget/AbstractInputPanel.java index e9155aa85..37513ce9e 100644 --- a/src/main/java/org/scijava/widget/AbstractInputPanel.java +++ b/src/main/java/org/scijava/widget/AbstractInputPanel.java @@ -45,7 +45,7 @@ public abstract class AbstractInputPanel implements InputPanel { /** Table of widgets. */ protected Map> widgets = - new HashMap>(); + new HashMap<>(); // -- InputPanel methods -- diff --git a/src/main/java/org/scijava/widget/DefaultWidgetModel.java b/src/main/java/org/scijava/widget/DefaultWidgetModel.java index 4f5052fb1..14db291d5 100644 --- a/src/main/java/org/scijava/widget/DefaultWidgetModel.java +++ b/src/main/java/org/scijava/widget/DefaultWidgetModel.java @@ -87,7 +87,7 @@ public DefaultWidgetModel(final Context context, final InputPanel inputPan this.module = module; this.item = item; this.objectPool = objectPool; - convertedObjects = new WeakHashMap(); + convertedObjects = new WeakHashMap<>(); if (item.getValue(module) == null) { // assign the item's default value as the current value diff --git a/src/test/java/org/scijava/ContextCreationTest.java b/src/test/java/org/scijava/ContextCreationTest.java index abbab3c9b..5b6ca51a0 100644 --- a/src/test/java/org/scijava/ContextCreationTest.java +++ b/src/test/java/org/scijava/ContextCreationTest.java @@ -343,7 +343,7 @@ public void testNoServicesCtor() { // create a 2-service context final PluginIndex index = pluginIndex(BaseImpl.class, ExtensionImpl.class); // Add another service, that is not indexed under Service.class - index.add(new PluginInfo(ThreadService.class.getName(), + index.add(new PluginInfo<>(ThreadService.class.getName(), SciJavaPlugin.class)); final Context c = new Context(pluginIndex(BaseImpl.class, ExtensionImpl.class)); @@ -440,7 +440,7 @@ private Class[] services( private PluginIndex pluginIndex(final Class... plugins) { final PluginIndex index = new PluginIndex(null); for (final Class c : plugins) { - index.add(new PluginInfo(c.getName(), Service.class)); + index.add(new PluginInfo<>(c.getName(), Service.class)); } return index; } diff --git a/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java b/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java index 848eec71a..35c1bc7ed 100644 --- a/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java +++ b/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java @@ -115,7 +115,7 @@ public void testRepeatedClassPathElements() throws Exception { final ClassLoader loader = new URLClassLoader(new URL[] { classPathURL, classPathURL }); - final Set seen = new HashSet(); + final Set seen = new HashSet<>(); for (final IndexItem item : Index.load(Simple.class, loader)) { final String name = item.className(); @@ -172,7 +172,7 @@ public static Map> readIndex( public final Enumeration getResources(final String path) throws IOException { - final List urls = new ArrayList(); + final List urls = new ArrayList<>(); for (final URL directory : directories) { final URL url = new URL(directory, path); final URLConnection connection = url.openConnection(); @@ -190,7 +190,7 @@ public static Map> readIndex( final Class annotationClass, final ClassLoader loader) { // read the index - final Map> map = new TreeMap>(); + final Map> map = new TreeMap<>(); for (final IndexItem item : Index.load(annotationClass, loader)) { map.put(item.className(), item); } diff --git a/src/test/java/org/scijava/app/StatusServiceTest.java b/src/test/java/org/scijava/app/StatusServiceTest.java index 58a049138..7c4320864 100644 --- a/src/test/java/org/scijava/app/StatusServiceTest.java +++ b/src/test/java/org/scijava/app/StatusServiceTest.java @@ -81,7 +81,7 @@ private void eventHandler(final StatusEvent e) { @Before public void setUp() throws Exception { context = new Context(); - queue = new ArrayBlockingQueue(10); + queue = new ArrayBlockingQueue<>(10); statusListener = new StatusListener(); statusListener.setContext(context); ss = statusListener.statusService; diff --git a/src/test/java/org/scijava/command/run/CommandCodeRunnerTest.java b/src/test/java/org/scijava/command/run/CommandCodeRunnerTest.java index 8a1ed203b..43277d036 100644 --- a/src/test/java/org/scijava/command/run/CommandCodeRunnerTest.java +++ b/src/test/java/org/scijava/command/run/CommandCodeRunnerTest.java @@ -89,7 +89,7 @@ public void testRunList() throws InvocationTargetException { public void testRunMap() throws InvocationTargetException { final StringBuilder buffer = new StringBuilder(); - final Map inputMap = new HashMap(); + final Map inputMap = new HashMap<>(); inputMap.put("buffer", buffer); runner.run(OpenSesame.class, inputMap); diff --git a/src/test/java/org/scijava/console/ConsoleServiceTest.java b/src/test/java/org/scijava/console/ConsoleServiceTest.java index 992723f8d..d67f20ebf 100644 --- a/src/test/java/org/scijava/console/ConsoleServiceTest.java +++ b/src/test/java/org/scijava/console/ConsoleServiceTest.java @@ -100,7 +100,7 @@ public void testOutputListeners() throws InterruptedException, final String stdoutAfter = "ave"; final String stderrAfter = "rs-"; - final ArrayList events = new ArrayList(); + final ArrayList events = new ArrayList<>(); final OutputListener outputListener = new OutputTracker(events); final Runnable r = new Printer(stdoutLocal, stderrLocal); @@ -145,9 +145,9 @@ public void testMultipleContextOutput() throws InterruptedException, final ThreadService ts1 = c1.service(ThreadService.class); final ThreadService ts2 = c2.service(ThreadService.class); - final ArrayList events1 = new ArrayList(); + final ArrayList events1 = new ArrayList<>(); cs1.addOutputListener(new OutputTracker(events1)); - final ArrayList events2 = new ArrayList(); + final ArrayList events2 = new ArrayList<>(); cs2.addOutputListener(new OutputTracker(events2)); final String globalOut = "and"; diff --git a/src/test/java/org/scijava/console/SystemPropertyArgumentTest.java b/src/test/java/org/scijava/console/SystemPropertyArgumentTest.java index 03e05e503..f0042394b 100644 --- a/src/test/java/org/scijava/console/SystemPropertyArgumentTest.java +++ b/src/test/java/org/scijava/console/SystemPropertyArgumentTest.java @@ -60,7 +60,7 @@ public void testSystemProperties() { private void assertPropertySet(final String key, final String value) { final SystemPropertyArgument spa = new SystemPropertyArgument(); - final LinkedList args = new LinkedList(); + final LinkedList args = new LinkedList<>(); args.add(value == null ? "-D" + key : "-D" + key + "=" + value); assertTrue(spa.supports(args)); assertNull(System.getProperty(key)); diff --git a/src/test/java/org/scijava/convert/ConvertServiceTest.java b/src/test/java/org/scijava/convert/ConvertServiceTest.java index b2d5fd7fd..8f106da8a 100644 --- a/src/test/java/org/scijava/convert/ConvertServiceTest.java +++ b/src/test/java/org/scijava/convert/ConvertServiceTest.java @@ -148,7 +148,7 @@ public void testArrays() { assertFalse(convertService.supports(int[].class, LongArray.class)); // Test that lists can be converted to any primitive [] - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (int i=0; i<100; i++) list.add((int) (10000 * Math.random())); assertTrue(convertService.supports(list, int[].class)); @@ -222,7 +222,7 @@ public void testConvert() { assertSame(string, stringToObject); // check "conversion" (i.e., casting) to interface - final ArrayList arrayList = new ArrayList(); + final ArrayList arrayList = new ArrayList<>(); final Collection arrayListToCollection = convertService.convert(arrayList, Collection.class); assertSame(arrayList, arrayListToCollection); @@ -266,7 +266,7 @@ public void testConvert() { assertEquals(8.7, stringToDouble, 0.0); // check conversion via constructor: HashSet to ArrayList - final HashSet set = new HashSet(); + final HashSet set = new HashSet<>(); set.add("Foo"); set.add("Bar"); @SuppressWarnings("unchecked") @@ -406,7 +406,7 @@ class Struct { final Struct struct = new Struct(); // Verify behavior setting a nesting of multi-elements (Set of Array) - final Set nestedSetValues = new HashSet(); + final Set nestedSetValues = new HashSet<>(); final char[] chars = { 'a', 'b', 'c' }; nestedSetValues.add(chars); @@ -539,7 +539,7 @@ class Struct { @Test public void testGetCompatibleInputs() { final List compatibleInputs = - new ArrayList(convertService.getCompatibleInputs(HisList.class)); + new ArrayList<>(convertService.getCompatibleInputs(HisList.class)); assertEquals(4, compatibleInputs.size()); assertEquals(StringHisListConverter.S1, compatibleInputs.get(0)); @@ -564,7 +564,7 @@ private void setFieldValue(final Object o, final String fieldName, * Convenience method to convert an array of values to a collection. */ private List getValueList(final T... values) { - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (final T value : values) list.add(value); return list; diff --git a/src/test/java/org/scijava/event/EventServiceTest.java b/src/test/java/org/scijava/event/EventServiceTest.java index ceff9f097..a76dced38 100644 --- a/src/test/java/org/scijava/event/EventServiceTest.java +++ b/src/test/java/org/scijava/event/EventServiceTest.java @@ -53,7 +53,7 @@ public class EventServiceTest { public void testWeakEventHandlers() { // verify that the garbage collector collects weak references final WeakReference reference = - new WeakReference(new MyEventHandler()); + new WeakReference<>(new MyEventHandler()); gc(); assertNull(reference.get()); diff --git a/src/test/java/org/scijava/menu/ShadowMenuTest.java b/src/test/java/org/scijava/menu/ShadowMenuTest.java index 458d41387..479531083 100644 --- a/src/test/java/org/scijava/menu/ShadowMenuTest.java +++ b/src/test/java/org/scijava/menu/ShadowMenuTest.java @@ -136,7 +136,7 @@ public void testGetMenu() { private ShadowMenu createShadowMenu() { final Context context = new Context(true); - final ArrayList modules = new ArrayList(); + final ArrayList modules = new ArrayList<>(); modules.add(createModuleInfo("Edit>Copy")); modules.add(createModuleInfo("Edit>Cut")); modules.add(createModuleInfo("Edit>Paste")); diff --git a/src/test/java/org/scijava/module/run/ModuleCodeRunnerTest.java b/src/test/java/org/scijava/module/run/ModuleCodeRunnerTest.java index 99dec327f..05bcd6957 100644 --- a/src/test/java/org/scijava/module/run/ModuleCodeRunnerTest.java +++ b/src/test/java/org/scijava/module/run/ModuleCodeRunnerTest.java @@ -83,7 +83,7 @@ public void testRunList() throws InvocationTargetException { @Test public void testRunMap() throws InvocationTargetException { final StringBuilder sb = new StringBuilder(); - final Map inputMap = new HashMap(); + final Map inputMap = new HashMap<>(); inputMap.put("buffer", sb); inputMap.put("length", 4); runner.run("module:" + AlphabetModule.class.getName(), inputMap); @@ -124,11 +124,11 @@ public AlphabetModuleInfo() { // So much fun to construct modules by hand! Who needs commands? setModuleClass(AlphabetModule.class); final DefaultMutableModuleItem bufferItem = - new DefaultMutableModuleItem(this, "buffer", + new DefaultMutableModuleItem<>(this, "buffer", StringBuilder.class); bufferItem.setIOType(ItemIO.BOTH); addInput(bufferItem); - addInput(new DefaultMutableModuleItem(this, "length", + addInput(new DefaultMutableModuleItem<>(this, "length", int.class)); } diff --git a/src/test/java/org/scijava/object/ObjectIndexTest.java b/src/test/java/org/scijava/object/ObjectIndexTest.java index 6d6d33b62..659db41ae 100644 --- a/src/test/java/org/scijava/object/ObjectIndexTest.java +++ b/src/test/java/org/scijava/object/ObjectIndexTest.java @@ -53,7 +53,7 @@ public class ObjectIndexTest { @Test public void testGetAll() { final ObjectIndex objectIndex = - new ObjectIndex(Object.class); + new ObjectIndex<>(Object.class); final Object o1 = new Integer(5); final Object o2 = new Float(2.5f); final Object o3 = new Integer(3); @@ -70,7 +70,7 @@ public void testGetAll() { @Test public void testGet() { final ObjectIndex objectIndex = - new ObjectIndex(Object.class); + new ObjectIndex<>(Object.class); final Object o1 = new Integer(5); final Object o2 = new Float(2.5f); final Object o3 = new Integer(3); @@ -91,7 +91,7 @@ public void testGet() { @Test public void testIsEmpty() { final ObjectIndex objectIndex = - new ObjectIndex(Object.class); + new ObjectIndex<>(Object.class); assertTrue(objectIndex.isEmpty()); final Object o1 = new Integer(5); objectIndex.add(o1); @@ -103,7 +103,7 @@ public void testIsEmpty() { @Test public void testContains() { final ObjectIndex objectIndex = - new ObjectIndex(Object.class); + new ObjectIndex<>(Object.class); final Object o1 = new Integer(5); assertFalse(objectIndex.contains(o1)); objectIndex.add(o1); @@ -115,7 +115,7 @@ public void testContains() { @Test public void testIterator() { final ObjectIndex objectIndex = - new ObjectIndex(Object.class); + new ObjectIndex<>(Object.class); final Object[] objects = { new Integer(5), new Float(2.5f), new Integer(3) }; for (final Object o : objects) @@ -132,7 +132,7 @@ public void testIterator() { @Test public void testToArray() { final ObjectIndex objectIndex = - new ObjectIndex(Object.class); + new ObjectIndex<>(Object.class); final Object[] objects = { new Integer(5), new Float(2.5f), new Integer(3) }; for (final Object o : objects) @@ -144,12 +144,12 @@ public void testToArray() { @Test public void testContainsAll() { final ObjectIndex objectIndex = - new ObjectIndex(Object.class); - assertTrue(objectIndex.containsAll(new ArrayList())); + new ObjectIndex<>(Object.class); + assertTrue(objectIndex.containsAll(new ArrayList<>())); final Object o1 = new Integer(5); final Object o2 = new Float(2.5f); final Object o3 = new Integer(3); - final ArrayList objects = new ArrayList(); + final ArrayList objects = new ArrayList<>(); objects.add(o1); objects.add(o2); objects.add(o3); @@ -163,8 +163,8 @@ public void testContainsAll() { @Test public void testAddAll() { final ObjectIndex objectIndex = - new ObjectIndex(Object.class); - final ArrayList objects = new ArrayList(); + new ObjectIndex<>(Object.class); + final ArrayList objects = new ArrayList<>(); objects.add(new Integer(5)); objects.add(new Float(2.5f)); objects.add(new Integer(3)); @@ -176,11 +176,11 @@ public void testAddAll() { @Test public void testRemoveAll() { final ObjectIndex objectIndex = - new ObjectIndex(Object.class); + new ObjectIndex<>(Object.class); final Object o1 = new Integer(5); final Object o2 = new Float(2.5f); final Object o3 = new Integer(3); - final ArrayList objects = new ArrayList(); + final ArrayList objects = new ArrayList<>(); objects.add(o1); objects.add(o2); objects.add(o3); @@ -195,7 +195,7 @@ public void testRemoveAll() { @Test public void testClear() { final ObjectIndex objectIndex = - new ObjectIndex(Object.class); + new ObjectIndex<>(Object.class); objectIndex.clear(); assertTrue(objectIndex.isEmpty()); objectIndex.add(new Integer(5)); @@ -207,7 +207,7 @@ public void testClear() { @Test public void testToString() { final ObjectIndex objectIndex = - new ObjectIndex(Object.class); + new ObjectIndex<>(Object.class); objectIndex.add(new Integer(5)); objectIndex.add(new Float(2.5f)); objectIndex.add(new Integer(3)); diff --git a/src/test/java/org/scijava/object/SortedObjectIndexTest.java b/src/test/java/org/scijava/object/SortedObjectIndexTest.java index 906915352..2606115e8 100644 --- a/src/test/java/org/scijava/object/SortedObjectIndexTest.java +++ b/src/test/java/org/scijava/object/SortedObjectIndexTest.java @@ -48,7 +48,7 @@ public class SortedObjectIndexTest { @Test public void testGetAllSorted() { final SortedObjectIndex objectIndex = - new SortedObjectIndex(String.class); + new SortedObjectIndex<>(String.class); final String o1 = "quick"; final String o2 = "brown"; final String o3 = "fox"; @@ -65,7 +65,7 @@ public void testGetAllSorted() { @Test public void testDuplicates() { final SortedObjectIndex objectIndex = - new SortedObjectIndex(String.class); + new SortedObjectIndex<>(String.class); final String o1 = "quick"; final String o2 = "brown"; final String o3 = "fox"; diff --git a/src/test/java/org/scijava/options/OptionsTest.java b/src/test/java/org/scijava/options/OptionsTest.java index 04c01667c..8433da024 100644 --- a/src/test/java/org/scijava/options/OptionsTest.java +++ b/src/test/java/org/scijava/options/OptionsTest.java @@ -57,7 +57,7 @@ private OptionsService createOptionsService() { // add FooOptions to the list of available plugins final PluginService pluginService = context.getService(PluginService.class); final PluginInfo info = - new PluginInfo(FooOptions.class, OptionsPlugin.class); + new PluginInfo<>(FooOptions.class, OptionsPlugin.class); pluginService.addPlugin(info); return context.getService(OptionsService.class); diff --git a/src/test/java/org/scijava/plugin/PluginIndexTest.java b/src/test/java/org/scijava/plugin/PluginIndexTest.java index a29df6309..6508facfa 100644 --- a/src/test/java/org/scijava/plugin/PluginIndexTest.java +++ b/src/test/java/org/scijava/plugin/PluginIndexTest.java @@ -59,7 +59,7 @@ public void testGetPluginsOfClass() { // add a plugin to the index final PluginInfo testPlugin = - new PluginInfo(FooBar.class.getName(), SciJavaPlugin.class); + new PluginInfo<>(FooBar.class.getName(), SciJavaPlugin.class); pluginIndex.add(testPlugin); // retrieve the plugin from the index, by class @@ -91,7 +91,7 @@ public void testGetPluginsOfClassString() { // add a fake plugin to the index final String fakeClass = "foo.bar.FooBar"; final PluginInfo testPlugin = - new PluginInfo(fakeClass, SciJavaPlugin.class); + new PluginInfo<>(fakeClass, SciJavaPlugin.class); pluginIndex.add(testPlugin); // retrieve the fake plugin from the index, by class name diff --git a/src/test/java/org/scijava/prefs/PrefServiceTest.java b/src/test/java/org/scijava/prefs/PrefServiceTest.java index 660acbcfe..a4e1f22ed 100644 --- a/src/test/java/org/scijava/prefs/PrefServiceTest.java +++ b/src/test/java/org/scijava/prefs/PrefServiceTest.java @@ -146,7 +146,7 @@ public void testLong() { */ @Test public void testMap() { - final Map map = new HashMap(); + final Map map = new HashMap<>(); map.put("0", "A"); map.put("1", "B"); map.put("2", "C"); @@ -165,7 +165,7 @@ public void testMap() { @Test public void testList() { final String recentFilesKey = "RecentFiles"; - final List recentFiles = new ArrayList(); + final List recentFiles = new ArrayList<>(); recentFiles.add("some/path1"); recentFiles.add("some/path2"); recentFiles.add("some/path3"); diff --git a/src/test/java/org/scijava/run/RunServiceTest.java b/src/test/java/org/scijava/run/RunServiceTest.java index 228eacb37..80c6ca809 100644 --- a/src/test/java/org/scijava/run/RunServiceTest.java +++ b/src/test/java/org/scijava/run/RunServiceTest.java @@ -74,7 +74,7 @@ public void testRunList() throws InvocationTargetException { @Test public void testRunMap() throws InvocationTargetException { final StringBuilder sb = new StringBuilder(); - final Map inputMap = new LinkedHashMap(); + final Map inputMap = new LinkedHashMap<>(); inputMap.put("foo", "bar"); inputMap.put("animal", "quick brown fox"); inputMap.put("number", 33); diff --git a/src/test/java/org/scijava/script/ScriptFinderTest.java b/src/test/java/org/scijava/script/ScriptFinderTest.java index 122da260f..bc8c6f62a 100644 --- a/src/test/java/org/scijava/script/ScriptFinderTest.java +++ b/src/test/java/org/scijava/script/ScriptFinderTest.java @@ -193,7 +193,7 @@ private ScriptService createScriptService() { private ArrayList findScripts(final ScriptService scriptService) { final ScriptFinder scriptFinder = new ScriptFinder(scriptService); - final ArrayList scripts = new ArrayList(); + final ArrayList scripts = new ArrayList<>(); scriptFinder.findScripts(scripts); Collections.sort(scripts); return scripts; diff --git a/src/test/java/org/scijava/util/BoolArrayTest.java b/src/test/java/org/scijava/util/BoolArrayTest.java index 713fe4f42..8468c911f 100644 --- a/src/test/java/org/scijava/util/BoolArrayTest.java +++ b/src/test/java/org/scijava/util/BoolArrayTest.java @@ -326,7 +326,7 @@ public void testContainsAll() { final boolean[] raw = { true, true }; final BoolArray array = new BoolArray(raw.clone()); - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); assertTrue(array.containsAll(list)); list.add(true); assertTrue(array.containsAll(list)); diff --git a/src/test/java/org/scijava/util/ByteArrayTest.java b/src/test/java/org/scijava/util/ByteArrayTest.java index 2540fe5dd..70d3cbcd7 100644 --- a/src/test/java/org/scijava/util/ByteArrayTest.java +++ b/src/test/java/org/scijava/util/ByteArrayTest.java @@ -358,7 +358,7 @@ public void testContainsAll() { final byte[] raw = { 3, 5, 8, 13, 21 }; final ByteArray array = new ByteArray(raw.clone()); - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); assertTrue(array.containsAll(list)); list.add((byte) 13); assertTrue(array.containsAll(list)); diff --git a/src/test/java/org/scijava/util/CharArrayTest.java b/src/test/java/org/scijava/util/CharArrayTest.java index f8ba039ea..0947b9ce0 100644 --- a/src/test/java/org/scijava/util/CharArrayTest.java +++ b/src/test/java/org/scijava/util/CharArrayTest.java @@ -354,7 +354,7 @@ public void testContainsAll() { final char[] raw = { 3, 5, 8, 13, 21 }; final CharArray array = new CharArray(raw.clone()); - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); assertTrue(array.containsAll(list)); list.add((char) 13); assertTrue(array.containsAll(list)); diff --git a/src/test/java/org/scijava/util/ConversionUtilsTest.java b/src/test/java/org/scijava/util/ConversionUtilsTest.java index 68d7ced59..6a1bed171 100644 --- a/src/test/java/org/scijava/util/ConversionUtilsTest.java +++ b/src/test/java/org/scijava/util/ConversionUtilsTest.java @@ -101,7 +101,7 @@ public void testCast() { assertSame(string, stringToObject); // check casting to interface - final ArrayList arrayList = new ArrayList(); + final ArrayList arrayList = new ArrayList<>(); final Collection arrayListToCollection = ConversionUtils.cast(arrayList, Collection.class); assertSame(arrayList, arrayListToCollection); @@ -395,7 +395,7 @@ class Struct { final Struct struct = new Struct(); // Verify behavior setting a nesting of multi-elements (Set of Array) - final Set nestedSetValues = new HashSet(); + final Set nestedSetValues = new HashSet<>(); final char[] chars = { 'a', 'b', 'c' }; nestedSetValues.add(chars); @@ -535,7 +535,7 @@ private void setFieldValue(final Object o, final String fieldName, * Convenience method to convert an array of values to a collection. */ private List getValueList(final T... values) { - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (final T value : values) list.add(value); return list; diff --git a/src/test/java/org/scijava/util/DoubleArrayTest.java b/src/test/java/org/scijava/util/DoubleArrayTest.java index 717f997a1..1430a530a 100644 --- a/src/test/java/org/scijava/util/DoubleArrayTest.java +++ b/src/test/java/org/scijava/util/DoubleArrayTest.java @@ -364,7 +364,7 @@ public void testContainsAll() { final double[] raw = { 3, 5, 8, 13, 21 }; final DoubleArray array = new DoubleArray(raw.clone()); - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); assertTrue(array.containsAll(list)); list.add(13d); assertTrue(array.containsAll(list)); diff --git a/src/test/java/org/scijava/util/FloatArrayTest.java b/src/test/java/org/scijava/util/FloatArrayTest.java index b5d62c5ce..0b7947657 100644 --- a/src/test/java/org/scijava/util/FloatArrayTest.java +++ b/src/test/java/org/scijava/util/FloatArrayTest.java @@ -364,7 +364,7 @@ public void testContainsAll() { final float[] raw = { 3, 5, 8, 13, 21 }; final FloatArray array = new FloatArray(raw.clone()); - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); assertTrue(array.containsAll(list)); list.add(13f); assertTrue(array.containsAll(list)); diff --git a/src/test/java/org/scijava/util/IntArrayTest.java b/src/test/java/org/scijava/util/IntArrayTest.java index badb7112e..30f97a709 100644 --- a/src/test/java/org/scijava/util/IntArrayTest.java +++ b/src/test/java/org/scijava/util/IntArrayTest.java @@ -358,7 +358,7 @@ public void testContainsAll() { final int[] raw = { 3, 5, 8, 13, 21 }; final IntArray array = new IntArray(raw.clone()); - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); assertTrue(array.containsAll(list)); list.add(13); assertTrue(array.containsAll(list)); diff --git a/src/test/java/org/scijava/util/LastRecentlyUsedTest.java b/src/test/java/org/scijava/util/LastRecentlyUsedTest.java index c93cd1875..553be9b92 100644 --- a/src/test/java/org/scijava/util/LastRecentlyUsedTest.java +++ b/src/test/java/org/scijava/util/LastRecentlyUsedTest.java @@ -48,7 +48,7 @@ public class LastRecentlyUsedTest { @Test public void test() { int count = 3; - final LastRecentlyUsed lru = new LastRecentlyUsed(count); + final LastRecentlyUsed lru = new LastRecentlyUsed<>(count); for (int i = 1; i <= count; i++) { lru.add("" + i); @@ -72,7 +72,7 @@ public void test() { @Test public void testRemove() { - final LastRecentlyUsed lru = new LastRecentlyUsed(3); + final LastRecentlyUsed lru = new LastRecentlyUsed<>(3); lru.add("a"); lru.add("b"); lru.add("c"); diff --git a/src/test/java/org/scijava/util/LongArrayTest.java b/src/test/java/org/scijava/util/LongArrayTest.java index c6f6e9237..17b5294cc 100644 --- a/src/test/java/org/scijava/util/LongArrayTest.java +++ b/src/test/java/org/scijava/util/LongArrayTest.java @@ -358,7 +358,7 @@ public void testContainsAll() { final long[] raw = { 3, 5, 8, 13, 21 }; final LongArray array = new LongArray(raw.clone()); - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); assertTrue(array.containsAll(list)); list.add(13L); assertTrue(array.containsAll(list)); diff --git a/src/test/java/org/scijava/util/ObjectArrayTest.java b/src/test/java/org/scijava/util/ObjectArrayTest.java index b7d651dc6..d3ef289f1 100644 --- a/src/test/java/org/scijava/util/ObjectArrayTest.java +++ b/src/test/java/org/scijava/util/ObjectArrayTest.java @@ -53,7 +53,7 @@ public class ObjectArrayTest extends PrimitiveArrayTest { /** Tests {@link ObjectArray#ObjectArray(Class)}. */ @Test public void testConstructorNoArgs() { - final ObjectArray array = new ObjectArray(Integer.class); + final ObjectArray array = new ObjectArray<>(Integer.class); assertEquals(0, array.size()); assertEquals(0, array.copyArray().length); } @@ -63,7 +63,7 @@ public void testConstructorNoArgs() { public void testConstructorSize() { final int size = 24; final ObjectArray array = - new ObjectArray(Integer.class, size); + new ObjectArray<>(Integer.class, size); assertEquals(size, array.size()); assertEquals(size, array.copyArray().length); } @@ -72,7 +72,7 @@ public void testConstructorSize() { @Test public void testConstructorArray() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw); + final ObjectArray array = new ObjectArray<>(raw); assertSame(raw, array.getArray()); assertEquals(raw.length, array.size()); for (int i = 0; i < raw.length; i++) { @@ -85,7 +85,7 @@ public void testConstructorArray() { @Test public void testAddValue() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); final Integer e6 = 1, e7 = 2; array.addValue(e6); array.addValue(e7); @@ -100,7 +100,7 @@ public void testAddValue() { /** Tests {@link ObjectArray#removeValue(Object)}. */ public void testRemoveValue() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); assertEquals(raw.length, array.size()); array.removeValue(raw[0]); assertEquals(raw.length - 1, array.size()); @@ -115,7 +115,7 @@ public void testRemoveValue() { /** Tests {@link ObjectArray#getValue(int)}. */ public void testGetValue() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); for (int i = 0; i < raw.length; i++) { assertEquals("@" + i, raw[i], array.getValue(i)); } @@ -125,7 +125,7 @@ public void testGetValue() { @Test public void testSetValue() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); final Integer e0 = 7, e2 = 1, e4 = 2; array.setValue(0, e0); array.setValue(2, e2); @@ -142,7 +142,7 @@ public void testSetValue() { @Test public void testAddValueIndex() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); final Integer e0 = 7, e4 = 1, e7 = 2; array.addValue(0, e0); array.addValue(4, e4); @@ -161,7 +161,7 @@ public void testAddValueIndex() { /** Tests {@link ObjectArray#remove(int)}. */ public void testRemoveIndex() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); assertEquals(raw.length, array.size()); array.remove(0); assertEquals(raw.length - 1, array.size()); @@ -177,7 +177,7 @@ public void testRemoveIndex() { @Test public void testIndexOf() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); for (int i = 0; i < raw.length; i++) { assertEquals("@" + i, i, array.indexOf(raw[i])); } @@ -192,7 +192,7 @@ public void testIndexOf() { @Test public void testLastIndexOf() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); for (int i = 0; i < raw.length; i++) { assertEquals("@" + i, i, array.lastIndexOf(raw[i])); } @@ -207,7 +207,7 @@ public void testLastIndexOf() { @Test public void testContains() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); for (int i = 0; i < raw.length; i++) { assertTrue("@" + i, array.contains(raw[i])); } @@ -224,7 +224,7 @@ public void testContains() { */ @Test public void testSetArray() { - final ObjectArray array = new ObjectArray(Integer.class); + final ObjectArray array = new ObjectArray<>(Integer.class); final Integer[] raw = { 1, 2, 3, 5, 8, 13, 21 }; array.setArray(raw); assertSame(raw, array.getArray()); @@ -234,21 +234,21 @@ public void testSetArray() { @Test public void testInsert() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - testInsert(new ObjectArray(raw)); + testInsert(new ObjectArray<>(raw)); } /** Tests {@link ObjectArray#delete(int, int)}. */ @Test public void testDelete() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - testDelete(new ObjectArray(raw)); + testDelete(new ObjectArray<>(raw)); } /** Tests {@link ObjectArray#get(int)}. */ @Test public void testGet() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); for (int i = 0; i < raw.length; i++) { assertEquals("@" + i, raw[i].intValue(), array.get(i).intValue()); } @@ -258,7 +258,7 @@ public void testGet() { @Test public void testSet() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); final Integer e0 = 7, e2 = 1, e4 = 2; array.set(0, e0); array.set(2, e2); @@ -275,7 +275,7 @@ public void testSet() { @Test public void testAdd() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); final Integer e6 = 1, e7 = 2; array.add(e6); array.add(e7); @@ -291,7 +291,7 @@ public void testAdd() { @Test public void testIndexOfBoxed() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); for (int i = 0; i < raw.length; i++) { assertEquals("@" + i, i, array.indexOf(new Integer(raw[i]))); } @@ -308,7 +308,7 @@ public void testIndexOfBoxed() { @Test public void testLastIndexOfBoxed() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); for (int i = 0; i < raw.length; i++) { assertEquals("@" + i, i, array.lastIndexOf(new Integer(raw[i]))); } @@ -325,7 +325,7 @@ public void testLastIndexOfBoxed() { @Test public void testContainsBoxed() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); for (int i = 0; i < raw.length; i++) { assertTrue("@" + i, array.contains(new Integer(raw[i]))); } @@ -342,7 +342,7 @@ public void testContainsBoxed() { @Test public void testRemove() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); assertEquals(raw.length, array.size()); array.remove(new Integer(raw[0])); assertEquals(raw.length - 1, array.size()); @@ -358,9 +358,9 @@ public void testRemove() { @Test public void testContainsAll() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); assertTrue(array.containsAll(list)); list.add(13); assertTrue(array.containsAll(list)); @@ -368,11 +368,11 @@ public void testContainsAll() { assertFalse(array.containsAll(list)); final ObjectArray yes = - new ObjectArray(new Integer[] { 3, 8, 21 }); + new ObjectArray<>(new Integer[] { 3, 8, 21 }); assertTrue(array.containsAll(yes)); final ObjectArray no = - new ObjectArray(new Integer[] { 5, 13, 1 }); + new ObjectArray<>(new Integer[] { 5, 13, 1 }); assertFalse(array.containsAll(no)); } @@ -380,9 +380,9 @@ public void testContainsAll() { @Test public void testAddAll() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); final Integer[] add = { 1, 7 }; - final ObjectArray toAdd = new ObjectArray(add.clone()); + final ObjectArray toAdd = new ObjectArray<>(add.clone()); final int index = 3; array.addAll(index, toAdd); for (int i = 0; i < index; i++) { @@ -400,9 +400,9 @@ public void testAddAll() { @Test public void testRemoveAll() { final Integer[] raw = { 3, 5, 8, 13, 21 }; - final ObjectArray array = new ObjectArray(raw.clone()); + final ObjectArray array = new ObjectArray<>(raw.clone()); final ObjectArray toRemove = - new ObjectArray(new Integer[] { 3, 8, 21 }); + new ObjectArray<>(new Integer[] { 3, 8, 21 }); assertEquals(raw.length, array.size()); array.removeAll(toRemove); assertEquals(raw.length - 3, array.size()); diff --git a/src/test/java/org/scijava/util/ShortArrayTest.java b/src/test/java/org/scijava/util/ShortArrayTest.java index a24e9e90b..26ed7c378 100644 --- a/src/test/java/org/scijava/util/ShortArrayTest.java +++ b/src/test/java/org/scijava/util/ShortArrayTest.java @@ -358,7 +358,7 @@ public void testContainsAll() { final short[] raw = { 3, 5, 8, 13, 21 }; final ShortArray array = new ShortArray(raw.clone()); - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); assertTrue(array.containsAll(list)); list.add((short) 13); assertTrue(array.containsAll(list)); From 250cb8ff0f441923b4e0a21ac2b23a01ecbce072 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 22 Jun 2016 16:21:44 -0400 Subject: [PATCH 0229/1208] AbstractDataHandle: use accessor instead of field --- src/main/java/org/scijava/io/AbstractDataHandle.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/io/AbstractDataHandle.java b/src/main/java/org/scijava/io/AbstractDataHandle.java index ec1977163..1c12135a2 100644 --- a/src/main/java/org/scijava/io/AbstractDataHandle.java +++ b/src/main/java/org/scijava/io/AbstractDataHandle.java @@ -148,7 +148,7 @@ public String readString(int n) throws IOException { if (n > avail) n = (int) avail; final byte[] b = new byte[n]; readFully(b); - return new String(b, encoding); + return new String(b, getEncoding()); } @Override From cb147308801b1f253d9436c530865bc452b1a8f5 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 22 Jun 2016 16:29:39 -0400 Subject: [PATCH 0230/1208] DataHandle: move default methods into interface --- .../org/scijava/io/AbstractDataHandle.java | 201 ------------------ src/main/java/org/scijava/io/DataHandle.java | 181 ++++++++++++++-- 2 files changed, 164 insertions(+), 218 deletions(-) diff --git a/src/main/java/org/scijava/io/AbstractDataHandle.java b/src/main/java/org/scijava/io/AbstractDataHandle.java index 1c12135a2..f6d02f82a 100644 --- a/src/main/java/org/scijava/io/AbstractDataHandle.java +++ b/src/main/java/org/scijava/io/AbstractDataHandle.java @@ -31,9 +31,6 @@ package org.scijava.io; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.ByteBuffer; import java.nio.ByteOrder; import org.scijava.plugin.AbstractWrapperPlugin; @@ -47,14 +44,6 @@ public abstract class AbstractDataHandle extends AbstractWrapperPlugin implements DataHandle { - // -- Constants -- - - /** Block size to use when searching through the stream. */ - private static final int DEFAULT_BLOCK_SIZE = 256 * 1024; // 256 KB - - /** Maximum number of bytes to search when searching through the stream. */ - private static final int MAX_SEARCH_SIZE = 512 * 1024 * 1024; // 512 MB - // -- Fields -- private ByteOrder order = ByteOrder.BIG_ENDIAN; @@ -67,21 +56,11 @@ public ByteOrder getOrder() { return order; } - @Override - public boolean isLittleEndian() { - return getOrder() == ByteOrder.LITTLE_ENDIAN; - } - @Override public void setOrder(final ByteOrder order) { this.order = order; } - @Override - public void setOrder(final boolean little) { - setOrder(little ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); - } - @Override public String getEncoding() { return encoding; @@ -92,184 +71,4 @@ public void setEncoding(final String encoding) { this.encoding = encoding; } - @Override - public int read(final ByteBuffer buf) throws IOException { - return read(buf, buf.remaining()); - } - - @Override - public int read(final ByteBuffer buf, final int len) - throws IOException - { - final int n; - if (buf.hasArray()) { - // read directly into the array - n = read(buf.array(), buf.arrayOffset(), len); - } - else { - // read into a temporary array, then copy - final byte[] b = new byte[len]; - n = read(b); - buf.put(b, 0, n); - } - return n; - } - - @Override - public void write(final ByteBuffer buf) throws IOException { - write(buf, buf.remaining()); - } - - @Override - public void write(final ByteBuffer buf, final int len) - throws IOException - { - if (buf.hasArray()) { - // write directly from the buffer's array - write(buf.array(), buf.arrayOffset(), len); - } - else { - // copy into a temporary array, then write - final byte[] b = new byte[len]; - buf.get(b); - write(b); - } - } - - @Override - public String readCString() throws IOException { - final String line = findString("\0"); - return line.length() == 0 ? null : line; - } - - @Override - public String readString(int n) throws IOException { - final long avail = length() - offset(); - if (n > avail) n = (int) avail; - final byte[] b = new byte[n]; - readFully(b); - return new String(b, getEncoding()); - } - - @Override - public String readString(final String lastChars) throws IOException { - if (lastChars.length() == 1) return findString(lastChars); - final String[] terminators = new String[lastChars.length()]; - for (int i = 0; i < terminators.length; i++) { - terminators[i] = lastChars.substring(i, i + 1); - } - return findString(terminators); - } - - @Override - public String findString(final String... terminators) throws IOException { - return findString(true, DEFAULT_BLOCK_SIZE, terminators); - } - - @Override - public String findString(final boolean saveString, - final String... terminators) throws IOException - { - return findString(saveString, DEFAULT_BLOCK_SIZE, terminators); - } - - @Override - public String findString(final int blockSize, final String... terminators) - throws IOException - { - return findString(true, blockSize, terminators); - } - - @Override - public String findString(final boolean saveString, final int blockSize, - final String... terminators) throws IOException - { - final StringBuilder out = new StringBuilder(); - final long startPos = offset(); - long bytesDropped = 0; - final long inputLen = length(); - long maxLen = inputLen - startPos; - final boolean tooLong = saveString && maxLen > MAX_SEARCH_SIZE; - if (tooLong) maxLen = MAX_SEARCH_SIZE; - boolean match = false; - int maxTermLen = 0; - for (final String term : terminators) { - final int len = term.length(); - if (len > maxTermLen) maxTermLen = len; - } - - @SuppressWarnings("resource") - final InputStreamReader in = - new InputStreamReader(new DataHandleInputStream<>(this), getEncoding()); - final char[] buf = new char[blockSize]; - long loc = 0; - while (loc < maxLen && offset() < length() - 1) { - // if we're not saving the string, drop any old, unnecessary output - if (!saveString) { - final int outLen = out.length(); - if (outLen >= maxTermLen) { - final int dropIndex = outLen - maxTermLen + 1; - final String last = out.substring(dropIndex, outLen); - out.setLength(0); - out.append(last); - bytesDropped += dropIndex; - } - } - - // read block from stream - final int r = in.read(buf, 0, blockSize); - if (r <= 0) throw new IOException("Cannot read from stream: " + r); - - // append block to output - out.append(buf, 0, r); - - // check output, returning smallest possible string - int min = Integer.MAX_VALUE, tagLen = 0; - for (final String t : terminators) { - final int len = t.length(); - final int start = (int) (loc - bytesDropped - len); - final int value = out.indexOf(t, start < 0 ? 0 : start); - if (value >= 0 && value < min) { - match = true; - min = value; - tagLen = len; - } - } - - if (match) { - // reset stream to proper location - seek(startPos + bytesDropped + min + tagLen); - - // trim output string - if (saveString) { - out.setLength(min + tagLen); - return out.toString(); - } - return null; - } - - loc += r; - } - - // no match - if (tooLong) throw new IOException("Maximum search length reached."); - return saveString ? out.toString() : null; - } - - // -- InputStream look-alikes -- - - @Override - public int read(byte[] b) throws IOException { - return read(b, 0, b.length); - } - - @Override - public long skip(final long n) throws IOException { - if (n < 0) return 0; - final long remain = length() - offset(); - final long num = n < remain ? n : remain; - seek(offset() + num); - return num; - } - } diff --git a/src/main/java/org/scijava/io/DataHandle.java b/src/main/java/org/scijava/io/DataHandle.java index d70be75dd..ea6417fa1 100644 --- a/src/main/java/org/scijava/io/DataHandle.java +++ b/src/main/java/org/scijava/io/DataHandle.java @@ -35,6 +35,7 @@ import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; +import java.io.InputStreamReader; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -52,6 +53,12 @@ public interface DataHandle extends WrapperPlugin, DataInput, DataOutput, Closeable { + /** Default block size to use when searching through the stream. */ + int DEFAULT_BLOCK_SIZE = 256 * 1024; // 256 KB + + /** Default bound on bytes to search when searching through the stream. */ + int MAX_SEARCH_SIZE = 512 * 1024 * 1024; // 512 MB + /** Returns the current offset in the stream. */ long offset() throws IOException; @@ -66,7 +73,9 @@ public interface DataHandle extends WrapperPlugin, ByteOrder getOrder(); /** Gets the endianness of the stream. */ - boolean isLittleEndian(); + default boolean isLittleEndian() { + return getOrder() == ByteOrder.LITTLE_ENDIAN; + } /** * Sets the byte order of the stream. @@ -76,7 +85,9 @@ public interface DataHandle extends WrapperPlugin, void setOrder(ByteOrder order); /** Sets the endianness of the stream. */ - void setOrder(final boolean little); + default void setOrder(final boolean little) { + setOrder(little ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); + } /** Gets the native encoding of the stream. */ String getEncoding(); @@ -88,7 +99,9 @@ public interface DataHandle extends WrapperPlugin, * Reads up to {@code buf.remaining()} bytes of data from the stream into a * {@link ByteBuffer}. */ - int read(ByteBuffer buf) throws IOException; + default int read(final ByteBuffer buf) throws IOException { + return read(buf, buf.remaining()); + } /** * Reads up to {@code len} bytes of data from the stream into a @@ -96,7 +109,20 @@ public interface DataHandle extends WrapperPlugin, * * @return the total number of bytes read into the buffer. */ - int read(ByteBuffer buf, int len) throws IOException; + default int read(final ByteBuffer buf, final int len) throws IOException { + final int n; + if (buf.hasArray()) { + // read directly into the array + n = read(buf.array(), buf.arrayOffset(), len); + } + else { + // read into a temporary array, then copy + final byte[] b = new byte[len]; + n = read(b); + buf.put(b, 0, n); + } + return n; + } /** * Sets the stream pointer offset, measured from the beginning of the stream, @@ -108,25 +134,57 @@ public interface DataHandle extends WrapperPlugin, * Writes up to {@code buf.remaining()} bytes of data from the given * {@link ByteBuffer} to the stream. */ - void write(ByteBuffer buf) throws IOException; + default void write(final ByteBuffer buf) throws IOException { + write(buf, buf.remaining()); + } /** * Writes up to len bytes of data from the given ByteBuffer to the stream. */ - void write(ByteBuffer buf, int len) throws IOException; + default void write(final ByteBuffer buf, final int len) + throws IOException + { + if (buf.hasArray()) { + // write directly from the buffer's array + write(buf.array(), buf.arrayOffset(), len); + } + else { + // copy into a temporary array, then write + final byte[] b = new byte[len]; + buf.get(b); + write(b); + } + } + /** Reads a string of arbitrary length, terminated by a null char. */ - String readCString() throws IOException; + default String readCString() throws IOException { + final String line = findString("\0"); + return line.length() == 0 ? null : line; + } /** Reads a string of up to length n. */ - String readString(int n) throws IOException; + default String readString(int n) throws IOException { + final long avail = length() - offset(); + if (n > avail) n = (int) avail; + final byte[] b = new byte[n]; + readFully(b); + return new String(b, getEncoding()); + } /** * Reads a string ending with one of the characters in the given string. * * @see #findString(String...) */ - String readString(String lastChars) throws IOException; + default String readString(final String lastChars) throws IOException { + if (lastChars.length() == 1) return findString(lastChars); + final String[] terminators = new String[lastChars.length()]; + for (int i = 0; i < terminators.length; i++) { + terminators[i] = lastChars.substring(i, i + 1); + } + return findString(terminators); + } /** * Reads a string ending with one of the given terminating substrings. @@ -136,7 +194,9 @@ public interface DataHandle extends WrapperPlugin, * terminating sequence, or through the end of the stream if no * terminating sequence is found. */ - String findString(String... terminators) throws IOException; + default String findString(final String... terminators) throws IOException { + return findString(true, DEFAULT_BLOCK_SIZE, terminators); + } /** * Reads or skips a string ending with one of the given terminating @@ -152,8 +212,11 @@ public interface DataHandle extends WrapperPlugin, * terminating sequence, or through the end of the stream if no * terminating sequence is found, or null if saveString flag is unset. */ - String findString(boolean saveString, String... terminators) - throws IOException; + default String findString(final boolean saveString, + final String... terminators) throws IOException + { + return findString(saveString, DEFAULT_BLOCK_SIZE, terminators); + } /** * Reads a string ending with one of the given terminating substrings, using @@ -165,7 +228,11 @@ String findString(boolean saveString, String... terminators) * terminating sequence, or through the end of the stream if no * terminating sequence is found. */ - String findString(int blockSize, String... terminators) throws IOException; + default String findString(final int blockSize, final String... terminators) + throws IOException + { + return findString(true, blockSize, terminators); + } /** * Reads or skips a string ending with one of the given terminating @@ -182,8 +249,80 @@ String findString(boolean saveString, String... terminators) * terminating sequence, or through the end of the stream if no * terminating sequence is found, or null if saveString flag is unset. */ - String findString(boolean saveString, int blockSize, String... terminators) - throws IOException; + default String findString(final boolean saveString, final int blockSize, + final String... terminators) throws IOException + { + final StringBuilder out = new StringBuilder(); + final long startPos = offset(); + long bytesDropped = 0; + final long inputLen = length(); + long maxLen = inputLen - startPos; + final boolean tooLong = saveString && maxLen > MAX_SEARCH_SIZE; + if (tooLong) maxLen = MAX_SEARCH_SIZE; + boolean match = false; + int maxTermLen = 0; + for (final String term : terminators) { + final int len = term.length(); + if (len > maxTermLen) maxTermLen = len; + } + + @SuppressWarnings("resource") + final InputStreamReader in = + new InputStreamReader(new DataHandleInputStream<>(this), getEncoding()); + final char[] buf = new char[blockSize]; + long loc = 0; + while (loc < maxLen && offset() < length() - 1) { + // if we're not saving the string, drop any old, unnecessary output + if (!saveString) { + final int outLen = out.length(); + if (outLen >= maxTermLen) { + final int dropIndex = outLen - maxTermLen + 1; + final String last = out.substring(dropIndex, outLen); + out.setLength(0); + out.append(last); + bytesDropped += dropIndex; + } + } + + // read block from stream + final int r = in.read(buf, 0, blockSize); + if (r <= 0) throw new IOException("Cannot read from stream: " + r); + + // append block to output + out.append(buf, 0, r); + + // check output, returning smallest possible string + int min = Integer.MAX_VALUE, tagLen = 0; + for (final String t : terminators) { + final int len = t.length(); + final int start = (int) (loc - bytesDropped - len); + final int value = out.indexOf(t, start < 0 ? 0 : start); + if (value >= 0 && value < min) { + match = true; + min = value; + tagLen = len; + } + } + + if (match) { + // reset stream to proper location + seek(startPos + bytesDropped + min + tagLen); + + // trim output string + if (saveString) { + out.setLength(min + tagLen); + return out.toString(); + } + return null; + } + + loc += r; + } + + // no match + if (tooLong) throw new IOException("Maximum search length reached."); + return saveString ? out.toString() : null; + } // -- InputStream look-alikes -- @@ -200,7 +339,9 @@ String findString(boolean saveString, int blockSize, String... terminators) * * @return the total number of bytes read into the buffer. */ - int read(byte[] b) throws IOException; + default int read(byte[] b) throws IOException { + return read(b, 0, b.length); + } /** * Reads up to len bytes of data from the stream into an array of bytes. @@ -221,6 +362,12 @@ String findString(boolean saveString, int blockSize, String... terminators) * @return the actual number of bytes skipped. * @throws IOException - if an I/O error occurs. */ - long skip(long n) throws IOException; + default long skip(final long n) throws IOException { + if (n < 0) return 0; + final long remain = length() - offset(); + final long num = n < remain ? n : remain; + seek(offset() + num); + return num; + } } From b52332e0c5f1103567f98fbd161ef0e5ec744042 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 22 Jun 2016 16:30:39 -0400 Subject: [PATCH 0231/1208] Location: move default methods into interface --- src/main/java/org/scijava/io/AbstractLocation.java | 11 +---------- src/main/java/org/scijava/io/Location.java | 4 +++- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/scijava/io/AbstractLocation.java b/src/main/java/org/scijava/io/AbstractLocation.java index fe40a36d8..046b3c569 100644 --- a/src/main/java/org/scijava/io/AbstractLocation.java +++ b/src/main/java/org/scijava/io/AbstractLocation.java @@ -31,20 +31,11 @@ package org.scijava.io; -import java.net.URI; - /** * Abstract base class for {@link Location} implementations. * * @author Curtis Rueden */ public abstract class AbstractLocation implements Location { - - // -- Location methods -- - - @Override - public URI getURI() { - return null; - } - + // NB: No implementation needed. } diff --git a/src/main/java/org/scijava/io/Location.java b/src/main/java/org/scijava/io/Location.java index a02abbf25..a2e509fcc 100644 --- a/src/main/java/org/scijava/io/Location.java +++ b/src/main/java/org/scijava/io/Location.java @@ -53,6 +53,8 @@ public interface Location { * Gets the location expressed as a {@link URI}, or null if the location * cannot be expressed as such. */ - URI getURI(); + default URI getURI() { + return null; + } } From eaa0eb4d96ce33fb15ddc63a217f3a47cfd1bdc4 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 22 Jun 2016 16:34:27 -0400 Subject: [PATCH 0232/1208] DataHandleTest: use try-with-resources --- src/test/java/org/scijava/io/DataHandleTest.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/scijava/io/DataHandleTest.java b/src/test/java/org/scijava/io/DataHandleTest.java index a9d0db06b..d496a665b 100644 --- a/src/test/java/org/scijava/io/DataHandleTest.java +++ b/src/test/java/org/scijava/io/DataHandleTest.java @@ -64,12 +64,14 @@ public void testDataHandle() throws IOException { context.service(DataHandleService.class); final Location loc = createLocation(); - final DataHandle handle = dataHandleService.create(loc); - assertEquals(getExpectedHandleType(), handle.getClass()); + try (final DataHandle handle = // + dataHandleService.create(loc)) + { + assertEquals(getExpectedHandleType(), handle.getClass()); - checkReads(handle); - checkWrites(handle); - handle.close(); + checkReads(handle); + checkWrites(handle); + } } // -- DataHandleTest methods -- From a7f49c6793b3e345873d61c05d6ca411c9b6d70e Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 29 Jun 2016 15:59:44 -0500 Subject: [PATCH 0233/1208] ScriptInfo: do not mix datestamp into the version At the time I wrote that code, I was mainly concerned with ensuring that generated version strings do not clash. However, there are compelling reasons to avoid "false negatives" as well (two scripts which are actually the same, but end up with differing version strings). When mixing in the datestamp with the hash, a false negative will happen if the script's last modified date is not preserved when copied between systems. This makes data provenance more difficult, because two systems may have identical installations content-wise, but different version strings due to timestamp skew. So, let's keep it simpler: use the content hash if available (i.e.: if the script contents can be read), and the datestamp only if not. --- src/main/java/org/scijava/script/ScriptInfo.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index 7f68d3aa2..6d4657be6 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -322,16 +322,15 @@ public String getLocation() { public String getVersion() { final File file = new File(path); if (!file.exists()) return null; // no version for non-existent script - final Date lastModified = FileUtils.getModifiedTime(file); - final String datestamp = - new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss").format(lastModified); try { - final String hash = DigestUtils.bestHex(FileUtils.readFile(file)); - return datestamp + "-" + hash; + return DigestUtils.bestHex(FileUtils.readFile(file)); } catch (final IOException exc) { log.error(exc); } + final Date lastModified = FileUtils.getModifiedTime(file); + final String datestamp = + new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss").format(lastModified); return datestamp; } From 43407c19200dcce584adcd7c73a878d168370c3d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 29 Jun 2016 16:11:04 -0500 Subject: [PATCH 0234/1208] Manifest: implement the Versioned interface This migrates the version determination logic from VersionUtils into the org.scijava.util.Manifest class directly. And updates VersionUtils to lean on it. --- src/main/java/org/scijava/util/Manifest.java | 24 ++++++++++++++++++- .../java/org/scijava/util/VersionUtils.java | 21 ++-------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/scijava/util/Manifest.java b/src/main/java/org/scijava/util/Manifest.java index 3fffeb861..8d40cc80c 100644 --- a/src/main/java/org/scijava/util/Manifest.java +++ b/src/main/java/org/scijava/util/Manifest.java @@ -40,12 +40,14 @@ import java.util.Map; import java.util.jar.Attributes; +import org.scijava.Versioned; + /** * Helper class for working with JAR manifests. * * @author Curtis Rueden */ -public class Manifest { +public class Manifest implements Versioned { /** The JAR manifest backing this object. */ private final java.util.jar.Manifest manifest; @@ -165,4 +167,24 @@ private static Manifest getManifest(final URL jarURL) throws IOException { return new Manifest(conn.getManifest()); } + // -- Versioned methods -- + + @Override + public String getVersion() { + final String v = getBaseVersion(); + if (v == null || !v.endsWith("-SNAPSHOT")) return v; + + // append commit hash to differentiate between development versions + final String buildNumber = getImplementationBuild(); + return buildNumber == null ? v : v + "-" + buildNumber; + } + + // -- Helper methods -- + + private String getBaseVersion() { + final String manifestVersion = getImplementationVersion(); + if (manifestVersion != null) return manifestVersion; + return getSpecificationVersion(); + } + } diff --git a/src/main/java/org/scijava/util/VersionUtils.java b/src/main/java/org/scijava/util/VersionUtils.java index b78201336..4e1fe115f 100644 --- a/src/main/java/org/scijava/util/VersionUtils.java +++ b/src/main/java/org/scijava/util/VersionUtils.java @@ -80,13 +80,7 @@ public static String getVersion(final Class c, final String groupId, */ public static String getVersionFromManifest(final Class c) { final Manifest m = Manifest.getManifest(c); - if (m == null) return null; - final String version = getVersionFromManifest(m); - if (version == null || !version.endsWith("-SNAPSHOT")) return version; - - // append commit hash to differentiate between development versions - final String buildNumber = getBuildNumber(m); - return buildNumber == null ? version : version + "-" + buildNumber; + return m == null ? null : m.getVersion(); } /** @@ -115,18 +109,7 @@ public static String getVersionFromPOM(final Class c, * @return Build number of specified {@link Class} or null if not found. */ public static String getBuildNumber(final Class c) { - return getBuildNumber(Manifest.getManifest(c)); - } - - // -- Helper methods -- - - private static String getVersionFromManifest(final Manifest m) { - final String manifestVersion = m.getImplementationVersion(); - if (manifestVersion != null) return manifestVersion; - return m.getSpecificationVersion(); - } - - private static String getBuildNumber(final Manifest m) { + final Manifest m = Manifest.getManifest(c); return m == null ? null : m.getImplementationBuild(); } From f60925d7e0cb1cc2823faa640f2f3357cd5287c0 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 29 Jun 2016 16:33:21 -0500 Subject: [PATCH 0235/1208] AbstractApp: improve version detection Let's use the manifest if available, since it might have the build number. This also adds an explanation for why we don't use VersionUtils.getVersion here. --- .../java/org/scijava/app/AbstractApp.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/app/AbstractApp.java b/src/main/java/org/scijava/app/AbstractApp.java index ff26c35dc..4e40d3604 100644 --- a/src/main/java/org/scijava/app/AbstractApp.java +++ b/src/main/java/org/scijava/app/AbstractApp.java @@ -63,7 +63,24 @@ public String getTitle() { @Override public String getVersion() { - return getPOM() == null ? "Unknown" : getPOM().getVersion(); + // NB: We do not use VersionUtils.getVersion(c, groupId, artifactId) + // because that method does not cache the parsed Manifest and/or POM. + // We might have them already parsed here, and if not, we want to + // parse then cache locally, rather than discarding them afterwards. + + // try the manifest first, since it might know its build number + final Manifest m = getManifest(); + if (m != null) { + final String v = m.getVersion(); + if (v != null) return v; + } + // try the POM + final POM p = getPOM(); + if (p != null) { + final String v = p.getVersion(); + if (v != null) return v; + } + return "Unknown"; } @Override From ba4a4f782e35098058ebef11503379a9c724b1c0 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 9 Jun 2016 16:56:48 -0500 Subject: [PATCH 0236/1208] POM: goodbye Mark! --- pom.xml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 9414cc57e..5830f4e85 100644 --- a/pom.xml +++ b/pom.xml @@ -38,21 +38,14 @@ maintainer - - hinerm - Mark Hiner - http://imagej.net/User:Hinerm - - lead - developer - debugger - reviewer - support - maintainer - - + + Mark Hiner + http://imagej.net/User:Hinerm + founder + hinerm + Johannes Schindelin http://imagej.net/User:Schindelin From d2791e03b618982c10e21cbc0bf7b46be2438206 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 29 Jun 2016 22:27:23 -0500 Subject: [PATCH 0237/1208] POMTest: the bus factor is now 1 :'-( --- src/test/java/org/scijava/util/POMTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/org/scijava/util/POMTest.java b/src/test/java/org/scijava/util/POMTest.java index e8ad4071c..9964478e4 100644 --- a/src/test/java/org/scijava/util/POMTest.java +++ b/src/test/java/org/scijava/util/POMTest.java @@ -137,9 +137,8 @@ public void testElements() throws ParserConfigurationException, final POM pom = new POM(new File("pom.xml")); final ArrayList developers = pom.elements("//project/developers/developer"); - assertEquals(2, developers.size()); + assertEquals(1, developers.size()); assertEquals("ctrueden", XML.cdata(developers.get(0), "id")); - assertEquals("hinerm", XML.cdata(developers.get(1), "id")); } } From 16b68aff659fccb176485497d6180b5078606994 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 29 Jun 2016 22:28:39 -0500 Subject: [PATCH 0238/1208] ScriptInfoTest: adjust for new version strings The behavior changed with a7f49c6793b3e345873d61c05d6ca411c9b6d70e. We no longer prepend the datestamp. This changes the test accordingly. --- src/test/java/org/scijava/script/ScriptInfoTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/org/scijava/script/ScriptInfoTest.java b/src/test/java/org/scijava/script/ScriptInfoTest.java index 664ea358c..53f9ed659 100644 --- a/src/test/java/org/scijava/script/ScriptInfoTest.java +++ b/src/test/java/org/scijava/script/ScriptInfoTest.java @@ -122,9 +122,8 @@ public void testVersion() throws IOException { // verify that the version is correct final ScriptInfo info = new ScriptInfo(context, scriptFile); final String version = info.getVersion(); - final String timestampPattern = "\\d{4}-\\d{2}-\\d{2}-\\d{2}:\\d{2}:\\d{2}"; final String sha1 = "28f4a2880d604774ac5d604d35f431047a087c9e"; - assertTrue(version.matches("^" + timestampPattern + "-" + sha1 + "$")); + assertTrue(version.matches("^" + sha1 + "$")); // clean up the temporary directory FileUtils.deleteRecursively(tmpDir); From d389ff0a40f487822ebe0ac5a2d448bc6a719921 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 10 May 2016 05:59:15 -0500 Subject: [PATCH 0239/1208] ScriptService: generalize the javadoc The service is for working with scripts in general, not only the ScriptLanguage plugins. --- src/main/java/org/scijava/script/DefaultScriptService.java | 2 +- src/main/java/org/scijava/script/ScriptService.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index fcc9ed717..a21759de4 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -72,7 +72,7 @@ import org.scijava.util.ColorRGBA; /** - * Default service for working with scripting languages. + * Default service for working with scripts. * * @author Johannes Schindelin * @author Curtis Rueden diff --git a/src/main/java/org/scijava/script/ScriptService.java b/src/main/java/org/scijava/script/ScriptService.java index dfdb08115..d90945551 100644 --- a/src/main/java/org/scijava/script/ScriptService.java +++ b/src/main/java/org/scijava/script/ScriptService.java @@ -49,9 +49,8 @@ import org.scijava.service.SciJavaService; /** - * Interface for service that works with scripting languages. This service - * discovers available scripting languages, and provides convenience methods to - * interact with them. + * Interface for service that works with scripts. This service discovers + * available scripts, and provides convenience methods to interact with them. * * @author Johannes Schindelin */ From 179de87ec761c127e0797dfbb60b74efafb63353 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 10 May 2016 07:40:13 -0500 Subject: [PATCH 0240/1208] FileUtils: add findResources methods They will be useful for finding scripts inside JARs on the classpath. These methods were migrated from imagej-ui-swing; see: https://github.com/imagej/imagej-ui-swing/blob/imagej-ui-swing-0.18.0/src/main/java/net/imagej/ui/swing/script/FileFunctions.java --- src/main/java/org/scijava/util/FileUtils.java | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/src/main/java/org/scijava/util/FileUtils.java b/src/main/java/org/scijava/util/FileUtils.java index bd2d16910..16b6a0916 100644 --- a/src/main/java/org/scijava/util/FileUtils.java +++ b/src/main/java/org/scijava/util/FileUtils.java @@ -48,7 +48,10 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; +import java.util.Collections; import java.util.Date; +import java.util.HashMap; +import java.util.Map; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.regex.Matcher; @@ -607,6 +610,82 @@ else if (protocol.equals("jar")) { return result; } + /** + * Finds {@link URL}s of available resources. Both JAR files and files on disk + * are searched, according to the following mechanism: + *
      + *
    1. Resources at the given {@code pathPrefix} are discovered using + * {@link ClassLoader#getResources(String)} with the current thread's context + * class loader. In particular, this invocation discovers resources in JAR + * files beneath the given {@code pathPrefix}.
    2. + *
    3. The directory named {@code pathPrefix} beneath the given + * {@code baseDirectory} is scanned last, so that users can more easily + * override resources provided inside JAR files by placing a resource of the + * same name within that directory.
    4. + *
    + *

    + * In both cases, resources are then recursively scanned using + * {@link #listContents(URL)}, and anything matching the given {@code regex} + * pattern is added to the output map. + *

    + * + * @param regex The regex to use when matching resources, or null to match + * everything. + * @param pathPrefix The path to search for resources. + * @param baseDirectory The {@code baseDirectory/pathPrefix} directory to scan + * after the URL resources. + * @return A map of URLs referencing the matched resources. + * @see AppUtils#getBaseDirectory + */ + public static Map findResources(final String regex, + final String pathPrefix, final File baseDirectory) + { + // scan URL resource paths first + final ClassLoader loader = Thread.currentThread().getContextClassLoader(); + final ArrayList urls = new ArrayList<>(); + try { + urls.addAll(Collections.list(loader.getResources(pathPrefix + "/"))); + } + catch (final IOException exc) { + // error loading resources; proceed with an empty list + } + + // scan directory second; user can thus override resources from JARs + if (baseDirectory != null) { + try { + urls.add(new File(baseDirectory, pathPrefix).toURI().toURL()); + } + catch (final MalformedURLException exc) { + // error adding directory; proceed without it + } + } + + return findResources(regex, urls); + } + + /** + * Finds {@link URL}s of resources known to ImageJ. + *

    + * Each of the given {@link URL}s is recursively scanned using + * {@link #listContents(URL)}, and anything matching the given {@code regex} + * pattern is added to the output map. + * + * @param regex The regex to use when matching resources, or null to match + * everything. + * @param urls Paths to search for resources. + * @return A map of URLs referencing the matched resources. + */ + public static Map findResources(final String regex, + final Iterable urls) + { + final HashMap result = new HashMap<>(); + final Pattern pattern = regex == null ? null : Pattern.compile(regex); + for (final URL url : urls) { + getResources(pattern, result, url); + } + return result; + } + // -- Helper methods -- /** Builds the {@link #VERSION_PATTERN} constant. */ @@ -639,6 +718,45 @@ private static String classifiers() { return sb.toString(); } + /** Helper method of {@link #findResources(String, Iterable)}. */ + private static void getResources(final Pattern pattern, + final Map result, final URL base) + { + final String prefix = urlPath(base); + if (prefix == null) return; // unsupported base URL + + for (final URL url : FileUtils.listContents(base)) { + final String s = urlPath(url); + if (s == null || !s.startsWith(prefix)) continue; + + if (pattern == null || pattern.matcher(s).matches()) { + // this resource matches the pattern + final String key = urlPath(s.substring(prefix.length())); + if (key != null) result.put(key, url); + } + } + } + + /** Helper method of {@link #getResources(Pattern, Map, URL)}. */ + private static String urlPath(final URL url) { + try { + return url.toURI().toString(); + } + catch (final URISyntaxException exc) { + return null; + } + } + + /** Helper method of {@link #getResources(Pattern, Map, URL)}. */ + private static String urlPath(final String path) { + try { + return new URI(path).getPath(); + } + catch (final URISyntaxException exc) { + return null; + } + } + // -- Deprecated methods -- /** From 7540fa6af7555cb540fb34ba68c8737223c8ec14 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 10 May 2016 09:39:03 -0500 Subject: [PATCH 0241/1208] ScriptService: index scripts by path, not file If two scripts exist at the same menu path, but exist as separate files on disk (due to being at two different script directory prefixes), then one script should override the other. Furthermore, we will soon be discovering URL-based scripts from classpath resources, which do not fit the files-on-disk assumption. --- .../scijava/script/DefaultScriptService.java | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index a21759de4..ecb168123 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -32,7 +32,6 @@ package org.scijava.script; import java.io.File; -import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.math.BigDecimal; @@ -106,8 +105,8 @@ public class DefaultScriptService extends /** Menu prefix to use for each script directory, if any. */ private HashMap menuPrefixes; - /** Index of available scripts, by script file. */ - private HashMap scripts; + /** Index of available scripts, by script path. */ + private HashMap scripts; /** Table of short type names to associated {@link Class}. */ private HashMap> aliasMap; @@ -330,7 +329,7 @@ private HashMap menuPrefixes() { } /** Gets {@link #scripts}, initializing if needed. */ - private HashMap scripts() { + private HashMap scripts() { if (scripts == null) initScripts(); return scripts; } @@ -386,13 +385,13 @@ private synchronized void initMenuPrefixes() { private synchronized void initScripts() { if (scripts != null) return; // already initialized - final HashMap map = new HashMap<>(); + final HashMap map = new HashMap<>(); final ArrayList scriptList = new ArrayList<>(); new ScriptFinder(this).findScripts(scriptList); for (final ScriptInfo info : scriptList) { - map.put(asFile(info.getPath()), info); + map.put(info.getPath(), info); } scripts = map; @@ -461,17 +460,6 @@ private ScriptInfo getOrCreate(final File file) { return new ScriptInfo(getContext(), file); } - private File asFile(final String path) { - final File file = new File(path); - try { - return file.getCanonicalFile(); - } - catch (final IOException exc) { - log.warn(exc); - return file.getAbsoluteFile(); - } - } - @SuppressWarnings({ "rawtypes", "unchecked" }) private Future cast(final Future future) { return (Future) future; From c7412b8f65b06727b69d5145842453af792583b8 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 10 May 2016 09:43:38 -0500 Subject: [PATCH 0242/1208] ScriptService: fix the base directory FIXME We should ask the AppService's primary app for its base directory, rather than calling a static method. --- src/main/java/org/scijava/script/DefaultScriptService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index ecb168123..d0adb48ba 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -51,6 +51,7 @@ import org.scijava.InstantiableException; import org.scijava.MenuPath; import org.scijava.Priority; +import org.scijava.app.AppService; import org.scijava.command.CommandService; import org.scijava.event.EventHandler; import org.scijava.log.LogService; @@ -65,7 +66,6 @@ import org.scijava.plugin.PluginService; import org.scijava.service.Service; import org.scijava.service.event.ServicesLoadedEvent; -import org.scijava.util.AppUtils; import org.scijava.util.ClassUtils; import org.scijava.util.ColorRGB; import org.scijava.util.ColorRGBA; @@ -90,6 +90,9 @@ public class DefaultScriptService extends @Parameter private CommandService commandService; + @Parameter + private AppService appService; + @Parameter private ParseService parser; @@ -361,7 +364,7 @@ private synchronized void initScriptDirs() { final ArrayList dirs = new ArrayList<>(); // append default script directories - final File baseDir = AppUtils.getBaseDirectory(getClass()); //FIXME + final File baseDir = appService.getApp().getBaseDirectory(); dirs.add(new File(baseDir, "scripts")); // append additional script directories from system property From 846937a7dcbfa35c4ba83ce3399a08544aef29a1 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 10 May 2016 11:04:48 -0400 Subject: [PATCH 0243/1208] ScriptService: declare "scripts" as a constant --- src/main/java/org/scijava/script/DefaultScriptService.java | 2 +- src/main/java/org/scijava/script/ScriptService.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index d0adb48ba..0a4147187 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -365,7 +365,7 @@ private synchronized void initScriptDirs() { // append default script directories final File baseDir = appService.getApp().getBaseDirectory(); - dirs.add(new File(baseDir, "scripts")); + dirs.add(new File(baseDir, SCRIPTS_RESOURCE_DIR)); // append additional script directories from system property final String scriptsPath = System.getProperty(SCRIPTS_PATH_PROPERTY); diff --git a/src/main/java/org/scijava/script/ScriptService.java b/src/main/java/org/scijava/script/ScriptService.java index d90945551..4e3e9be30 100644 --- a/src/main/java/org/scijava/script/ScriptService.java +++ b/src/main/java/org/scijava/script/ScriptService.java @@ -53,6 +53,7 @@ * available scripts, and provides convenience methods to interact with them. * * @author Johannes Schindelin + * @author Curtis Rueden */ public interface ScriptService extends SingletonService, SciJavaService @@ -65,6 +66,12 @@ public interface ScriptService extends SingletonService, */ String SCRIPTS_PATH_PROPERTY = "scijava.scripts.path"; + /** + * Base directory for discovering scripts, including within classpath + * resources as well as beneath the application base directory. + */ + String SCRIPTS_RESOURCE_DIR = "scripts"; + // -- Scripting languages -- /** Gets the index of available scripting languages. */ From 9b7c6bbb0d63e5cc29483727eb88effe76846022 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 16 May 2016 10:03:09 -0500 Subject: [PATCH 0244/1208] MenuPath: handle null collection more nicely --- src/main/java/org/scijava/MenuPath.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/MenuPath.java b/src/main/java/org/scijava/MenuPath.java index 09b1677c7..8b22c74e7 100644 --- a/src/main/java/org/scijava/MenuPath.java +++ b/src/main/java/org/scijava/MenuPath.java @@ -56,7 +56,7 @@ public MenuPath() { * the argument will make a copy. */ public MenuPath(final Collection menuEntries) { - addAll(menuEntries); + if (menuEntries != null) addAll(menuEntries); } /** From f544fc19b0b2edb6a67afbab747e7c21acff94f3 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 16 May 2016 10:03:25 -0500 Subject: [PATCH 0245/1208] MenuPath: support alternative path separators --- src/main/java/org/scijava/MenuPath.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/MenuPath.java b/src/main/java/org/scijava/MenuPath.java index 8b22c74e7..ebd245ff6 100644 --- a/src/main/java/org/scijava/MenuPath.java +++ b/src/main/java/org/scijava/MenuPath.java @@ -66,8 +66,16 @@ public MenuPath(final Collection menuEntries) { * @see #PATH_SEPARATOR */ public MenuPath(final String path) { + this(path, PATH_SEPARATOR); + } + + /** + * Creates a menu path with entries parsed from the given string, splitting on + * the specified separator. + */ + public MenuPath(final String path, final String separator) { if (path != null && !path.isEmpty()) { - final String[] tokens = path.split(PATH_SEPARATOR); + final String[] tokens = path.split(separator); for (final String token : tokens) { add(new MenuEntry(token.trim())); } From f94e26d39b46ef1b26e963a2f9feae20a1114fd2 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 13 May 2016 13:03:33 -0500 Subject: [PATCH 0246/1208] ScriptFinder: let the ctor take a Context instead This is more flexible: if we need to require additional services later, we will not have to modify the constructor signature again. --- .../scijava/script/DefaultScriptService.java | 2 +- .../java/org/scijava/script/ScriptFinder.java | 17 +++++++++++++---- .../org/scijava/script/ScriptFinderTest.java | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index 0a4147187..be695cb89 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -391,7 +391,7 @@ private synchronized void initScripts() { final HashMap map = new HashMap<>(); final ArrayList scriptList = new ArrayList<>(); - new ScriptFinder(this).findScripts(scriptList); + new ScriptFinder(context()).findScripts(scriptList); for (final ScriptInfo info : scriptList) { map.put(info.getPath(), info); diff --git a/src/main/java/org/scijava/script/ScriptFinder.java b/src/main/java/org/scijava/script/ScriptFinder.java index 8e75e2ed1..33d7cf7f8 100644 --- a/src/main/java/org/scijava/script/ScriptFinder.java +++ b/src/main/java/org/scijava/script/ScriptFinder.java @@ -38,6 +38,7 @@ import java.util.Set; import org.scijava.AbstractContextual; +import org.scijava.Context; import org.scijava.MenuEntry; import org.scijava.MenuPath; import org.scijava.log.LogService; @@ -59,14 +60,14 @@ public class ScriptFinder extends AbstractContextual { private static final String SCRIPT_ICON = "/icons/script_code.png"; - private final ScriptService scriptService; + @Parameter + private ScriptService scriptService; @Parameter private LogService log; - public ScriptFinder(final ScriptService scriptService) { - this.scriptService = scriptService; - setContext(scriptService.getContext()); + public ScriptFinder(final Context context) { + setContext(context); } // -- ScriptFinder methods -- @@ -161,4 +162,12 @@ else if (scriptService.canHandleFile(file)) { return info; } + // -- Deprecated methods -- + + /** @deprecated Use {@link #ScriptFinder(Context)} instead. */ + @Deprecated + public ScriptFinder(final ScriptService scriptService) { + this(scriptService.context()); + } + } diff --git a/src/test/java/org/scijava/script/ScriptFinderTest.java b/src/test/java/org/scijava/script/ScriptFinderTest.java index bc8c6f62a..0f52f5a9e 100644 --- a/src/test/java/org/scijava/script/ScriptFinderTest.java +++ b/src/test/java/org/scijava/script/ScriptFinderTest.java @@ -192,7 +192,7 @@ private ScriptService createScriptService() { } private ArrayList findScripts(final ScriptService scriptService) { - final ScriptFinder scriptFinder = new ScriptFinder(scriptService); + final ScriptFinder scriptFinder = new ScriptFinder(scriptService.context()); final ArrayList scripts = new ArrayList<>(); scriptFinder.findScripts(scripts); Collections.sort(scripts); From affde428099e773e98098acd751436a805b0539d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 29 Jun 2016 20:47:44 -0500 Subject: [PATCH 0247/1208] FileUtils: remove ImageJ-ism in javadoc --- src/main/java/org/scijava/util/FileUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/util/FileUtils.java b/src/main/java/org/scijava/util/FileUtils.java index 16b6a0916..c41a4e101 100644 --- a/src/main/java/org/scijava/util/FileUtils.java +++ b/src/main/java/org/scijava/util/FileUtils.java @@ -664,7 +664,7 @@ public static Map findResources(final String regex, } /** - * Finds {@link URL}s of resources known to ImageJ. + * Finds {@link URL}s of resources known to the system. *

    * Each of the given {@link URL}s is recursively scanned using * {@link #listContents(URL)}, and anything matching the given {@code regex} From d691f00b9eeb231e54c02d4b127fc61763311aa7 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 29 Jun 2016 21:37:20 -0500 Subject: [PATCH 0248/1208] ScriptFinder: add javadoc to the constructor --- src/main/java/org/scijava/script/ScriptFinder.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/scijava/script/ScriptFinder.java b/src/main/java/org/scijava/script/ScriptFinder.java index 33d7cf7f8..7c5a6a90d 100644 --- a/src/main/java/org/scijava/script/ScriptFinder.java +++ b/src/main/java/org/scijava/script/ScriptFinder.java @@ -66,6 +66,11 @@ public class ScriptFinder extends AbstractContextual { @Parameter private LogService log; + /** + * Creates a new script finder. + * + * @param context The SciJava application context housing needed services. + */ public ScriptFinder(final Context context) { setContext(context); } From ff73f88a96f5d06a8565adfb633c3fe1ce8ef218 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 29 Jun 2016 22:13:30 -0500 Subject: [PATCH 0249/1208] ScriptFinder: add support for scripts inside JARs This is a near-total rewrite of the script detection logic to use FileUtils.findResources instead of recursive directory listings. This change offers (at least) two major advantages: 1. Support for non-file resources, particularly scripts within JARs. 2. Built-in recursive resource scanning, instead of doing it ourselves. The new logic splits the script detection into two steps: 1) scan classpath resources beneath a given path prefix (default "scripts"); and 2) scan directories given by ScriptService#getScriptDirectories(). --- .../java/org/scijava/script/ScriptFinder.java | 166 +++++++++++------- 1 file changed, 104 insertions(+), 62 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptFinder.java b/src/main/java/org/scijava/script/ScriptFinder.java index 7c5a6a90d..48d66e6aa 100644 --- a/src/main/java/org/scijava/script/ScriptFinder.java +++ b/src/main/java/org/scijava/script/ScriptFinder.java @@ -32,17 +32,22 @@ package org.scijava.script; import java.io.File; -import java.util.Arrays; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import org.scijava.AbstractContextual; import org.scijava.Context; -import org.scijava.MenuEntry; import org.scijava.MenuPath; import org.scijava.log.LogService; import org.scijava.plugin.Parameter; +import org.scijava.util.FileUtils; /** * Discovers scripts. @@ -66,13 +71,27 @@ public class ScriptFinder extends AbstractContextual { @Parameter private LogService log; + private final String pathPrefix; + /** * Creates a new script finder. * * @param context The SciJava application context housing needed services. */ public ScriptFinder(final Context context) { + this(context, ScriptService.SCRIPTS_RESOURCE_DIR); + } + + /** + * Creates a new script finder. + * + * @param context The SciJava application context housing needed services. + * @param pathPrefix the path prefix beneath which to scan classpath + * resources, or null to skip classpath scanning. + */ + public ScriptFinder(final Context context, final String pathPrefix) { setContext(context); + this.pathPrefix = pathPrefix; } // -- ScriptFinder methods -- @@ -85,19 +104,16 @@ public ScriptFinder(final Context context) { public void findScripts(final List scripts) { final List directories = scriptService.getScriptDirectories(); + final Set urls = new HashSet<>(); int scriptCount = 0; - final HashSet scriptFiles = new HashSet<>(); - for (final File directory : directories) { - if (!directory.exists()) { - log.debug("Ignoring non-existent scripts directory: " + - directory.getAbsolutePath()); - continue; - } - final MenuPath prefix = scriptService.getMenuPrefix(directory); - final MenuPath menuPath = prefix == null ? new MenuPath() : prefix; - scriptCount += - discoverScripts(scripts, scriptFiles, directory, menuPath); + scriptCount += scanResources(scripts, urls); + + // NB: We use a separate call to findResources for each directory so that + // we can distinguish which URLs came from each directory, because each + // directory may have a different menu prefix. + for (final File dir : directories) { + scriptCount += scanDirectory(scripts, urls, dir); } log.debug("Found " + scriptCount + " scripts"); @@ -105,66 +121,92 @@ public void findScripts(final List scripts) { // -- Helper methods -- - /** - * Looks through a directory, discovering and adding scripts. - * - * @param scripts The collection to which the discovered scripts are added. - * @param directory The directory in which to look for scripts recursively. - * @param menuPath The menu path, which must not be {@code null}. - */ - private int discoverScripts(final List scripts, - final Set scriptFiles, final File directory, final MenuPath menuPath) - { - final File[] fileList = directory.listFiles(); - if (fileList == null) return 0; // directory does not exist - Arrays.sort(fileList); + /** Scans classpath resources for scripts (e.g., inside JAR files). */ + private int scanResources(final List scripts, final Set urls) { + if (pathPrefix == null) return 0; - int scriptCount = 0; - final boolean isTopLevel = menuPath.size() == 0; + // NB: We leave the baseDirectory argument null, because scripts on disk + // will be picked up in the subsequent logic, which handles multiple + // script directories rather than being limited to a single one. + final Map scriptMap = // + FileUtils.findResources(null, pathPrefix, null); - for (final File file : fileList) { - if (scriptFiles.contains(file)) continue; // script already added + return createInfos(scripts, urls, scriptMap, null); + } - final String name = file.getName().replace('_', ' '); - if (file.isDirectory()) { - // recurse into subdirectory - discoverScripts(scripts, scriptFiles, file, subMenuPath(menuPath, name)); - } - else if (isTopLevel) { - // ignore scripts in toplevel script directories - continue; - } - else if (scriptService.canHandleFile(file)) { - // found a script! - final int dot = name.lastIndexOf('.'); - final String noExt = dot <= 0 ? name : name.substring(0, dot); - scripts.add(createEntry(file, subMenuPath(menuPath, noExt))); - scriptFiles.add(file); - scriptCount++; - } + /** Scans a directory for scripts. */ + private int scanDirectory(final List scripts, final Set urls, + final File dir) + { + if (!dir.exists()) { + final String path = dir.getAbsolutePath(); + log.debug("Ignoring non-existent scripts directory: " + path); + return 0; } + final MenuPath menuPrefix = scriptService.getMenuPrefix(dir); - return scriptCount; - } + try { + final Set dirURL = Collections.singleton(dir.toURI().toURL()); + final Map scriptMap = // + FileUtils.findResources(null, dirURL); - private MenuPath - subMenuPath(final MenuPath menuPath, final String subMenuName) - { - final MenuPath result = new MenuPath(menuPath); - result.add(new MenuEntry(subMenuName)); - return result; + return createInfos(scripts, urls, scriptMap, menuPrefix); + } + catch (final MalformedURLException exc) { + log.error("Invalid script directory: " + dir, exc); + return 0; + } } - private ScriptInfo - createEntry(final File scriptFile, final MenuPath menuPath) + private int createInfos(final List scripts, final Set urls, + final Map scriptMap, final MenuPath menuPrefix) { - final ScriptInfo info = new ScriptInfo(getContext(), scriptFile); - info.setMenuPath(menuPath); + int scriptCount = 0; + for (final String path : scriptMap.keySet()) { + if (!scriptService.canHandleFile(path)) { + log.warn("Ignoring unsupported script: " + path); + continue; + } + + final int dot = path.lastIndexOf('.'); + final String basePath = dot <= 0 ? path : path.substring(0, dot); + final String friendlyPath = basePath.replace('_', ' '); + + final MenuPath menuPath = new MenuPath(menuPrefix); + menuPath.addAll(new MenuPath(friendlyPath, "/")); - // flag script with special icon - menuPath.getLeaf().setIconPath(SCRIPT_ICON); + // E.g.: + // path = "File/Import/Movie_File....groovy" + // basePath = "File/Import/Movie_File..." + // friendlyPath = "File/Import/Movie File..." + // menuPath = File > Import > Movie File... - return info; + // NB: Ignore base-level scripts (not nested in any menu). + if (menuPath.size() == 1) continue; + + final URL url = scriptMap.get(path); + + // NB: Skip scripts whose URLs have already been added. + if (urls.contains(url)) continue; + urls.add(url); + + try { + final ScriptInfo info = new ScriptInfo(getContext(), // + path, new InputStreamReader(url.openStream())); + + info.setMenuPath(menuPath); + + // flag script with special icon + menuPath.getLeaf().setIconPath(SCRIPT_ICON); + + scripts.add(info); + scriptCount++; + } + catch (final IOException exc) { + log.error("Invalid script URL: " + url, exc); + } + } + return scriptCount; } // -- Deprecated methods -- From 225b419a900034e9e0bae493470aa177ebffd11a Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 29 Jun 2016 22:22:53 -0500 Subject: [PATCH 0250/1208] ScriptFinderTest: verify scripts on the classpath This tests that scripts present on the classpath, but not any of the directories explicitly given by ScriptService#getScriptDirectories(), are still found. --- .../org/scijava/script/ScriptFinderTest.java | 3 +++ src/test/resources/scripts/Math/pow.foo | Bin 0 -> 2059 bytes 2 files changed, 3 insertions(+) create mode 100644 src/test/resources/scripts/Math/pow.foo diff --git a/src/test/java/org/scijava/script/ScriptFinderTest.java b/src/test/java/org/scijava/script/ScriptFinderTest.java index 0f52f5a9e..a860dde8c 100644 --- a/src/test/java/org/scijava/script/ScriptFinderTest.java +++ b/src/test/java/org/scijava/script/ScriptFinderTest.java @@ -107,6 +107,7 @@ public void testFindScripts() { "Math > divide", // "Scripts > fox", // "Math > multiply", // + "Math > pow", // "Scripts > quick", // "Math > Trig > sin", // "Math > subtract", // @@ -140,6 +141,7 @@ public void testMenuPrefixes() { "Foo > Bar > Scripts > fox", // "Foo > Bar > ignored", // "Foo > Bar > Math > multiply", // + "Math > pow", // "Foo > Bar > Scripts > quick", // "Foo > Bar > Math > Trig > sin", // "Foo > Bar > Math > subtract", // @@ -172,6 +174,7 @@ public void testOverlappingDirectories() { "Math > divide", // "Plugins > fox", // "Math > multiply", // + "Math > pow", // "Plugins > quick", // "Math > Trig > sin", // "Math > subtract", // diff --git a/src/test/resources/scripts/Math/pow.foo b/src/test/resources/scripts/Math/pow.foo new file mode 100644 index 0000000000000000000000000000000000000000..dc5577bfcfbc134e74b5ada3ea738e815452cf26 GIT binary patch literal 2059 zcmb_d&1(};5PwawwI5Qo1rK6Mt5x)1YN4o55t_8smNbYd2tD;Bc}=$6yj|bEwA&n{ z1<^wfdeDPVLBwNk{sUGJ5%r)@#ClLv1i@A>exQdq^YR@@3&zdmWp;iuzxmC~+vRnl z*@7J6O!}ti4E5P8ZJBAGp0o^Kn2CPQO-Ut-4H_)TxFp%9&P6=qq(QewnM|0mAZd&m z)V4!3$s}nFVx(?^@_2Vx3Z2LMf}|Vl+xh8ihmOVXD0Pf6YA9utg> zQmfCgh$Q<=5%<|qT@j;MCc4ROUx8J?0`j}mdxZOP@a-$#PaQch_0f%anxbaXqJm0O zNV2;mSD;{rbk?i~N^6lsqe9R*2-{W++mEK8ZcAt3h4DLD2 z9M9*pKvgX=CmBLois}7eS_(~E+Bo}dFZlcO{@9Q9FMx?As6b41eiY>Zm}pco(Ytv1 z)%2c&4gdprpp|)vD1)Zcfac82A``t|{uh^>x{ADJgQ-h8sd;FFVu+_tK^I(xsegr&@EE z^QJIjcz@(p7io6kME Date: Sun, 19 Jun 2016 16:01:48 -0400 Subject: [PATCH 0251/1208] ScriptInfo: remove unthrown exception clause --- src/main/java/org/scijava/script/ScriptInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index 6d4657be6..73356e07e 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -391,7 +391,7 @@ private void checkValid(final boolean valid, final String param) } /** Adds an output for the value returned by the script itself. */ - private void addReturnValue() throws ScriptException { + private void addReturnValue() { final HashMap attrs = new HashMap<>(); attrs.put("type", "OUTPUT"); addItem(ScriptModule.RETURN_VALUE, Object.class, attrs); From 77e09424607aa2d3ed902ad13e389ea1326772d9 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Sun, 19 Jun 2016 16:11:38 -0400 Subject: [PATCH 0252/1208] Invert + generalize script return value logic There may be other reasons affecting the decision to append the script's return value as an extra output. Let's be flexible. --- .../java/org/scijava/script/ScriptInfo.java | 29 ++++++++++++++----- .../java/org/scijava/script/ScriptModule.java | 2 +- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index 73356e07e..c0c8a65d2 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -94,8 +94,8 @@ public class ScriptInfo extends AbstractModuleInfo implements Contextual { @Parameter private ConvertService convertService; - /** True iff the return value is explicitly declared as an output. */ - private boolean returnValueDeclared; + /** True iff the return value should be appended as an output. */ + private boolean appendReturnValue; /** * Creates a script metadata object which describes the given script file. @@ -229,7 +229,7 @@ public BufferedReader getReader() { @Override public void parseParameters() { clearParameters(); - returnValueDeclared = false; + appendReturnValue = true; try { final BufferedReader in; @@ -254,7 +254,7 @@ public void parseParameters() { } in.close(); - if (!returnValueDeclared) addReturnValue(); + if (appendReturnValue) addReturnValue(); } catch (final IOException exc) { log.error("Error reading script: " + path, exc); @@ -264,9 +264,9 @@ public void parseParameters() { } } - /** Gets whether the return value is explicitly declared as an output. */ - public boolean isReturnValueDeclared() { - return returnValueDeclared; + /** Gets whether the return value is appended as an additional output. */ + public boolean isReturnValueAppended() { + return appendReturnValue; } // -- ModuleInfo methods -- @@ -372,7 +372,12 @@ private void parseParam(final String param, } final Class type = scriptService.lookupClass(typeName); addItem(varName, type, attrs); - if (ScriptModule.RETURN_VALUE.equals(varName)) returnValueDeclared = true; + + if (ScriptModule.RETURN_VALUE.equals(varName)) { + // NB: The return value variable is declared as an explicit OUTPUT. + // So we should not append the return value as an extra output. + appendReturnValue = false; + } } /** Parses a comma-delimited list of {@code key=value} pairs into a map. */ @@ -479,4 +484,12 @@ private static String getReaderContentsAsString(final Reader reader) return builder.toString(); } + // -- Deprecated methods -- + + /** @deprecated Use {@link #isReturnValueAppended()} instead. */ + @Deprecated + public boolean isReturnValueDeclared() { + return !isReturnValueAppended(); + } + } diff --git a/src/main/java/org/scijava/script/ScriptModule.java b/src/main/java/org/scijava/script/ScriptModule.java index 602545ebe..ae06eb9d7 100644 --- a/src/main/java/org/scijava/script/ScriptModule.java +++ b/src/main/java/org/scijava/script/ScriptModule.java @@ -190,7 +190,7 @@ public void run() { final String name = item.getName(); if (isResolved(name)) continue; final Object value; - if (RETURN_VALUE.equals(name) && !getInfo().isReturnValueDeclared()) { + if (RETURN_VALUE.equals(name) && getInfo().isReturnValueAppended()) { // NB: This is the special implicit return value output! value = returnValue; } From 230c267177babaa35e82794e787a8916bac565fc Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Sun, 19 Jun 2016 16:18:50 -0400 Subject: [PATCH 0253/1208] ScriptModule: track return value explicitly Rather than relying on the return value being stored as an extra output, let's save the return value as its own reference. That way, in cases where the return value does _not_ get appended as an extra output, we still have a handle on it. --- src/main/java/org/scijava/script/ScriptModule.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptModule.java b/src/main/java/org/scijava/script/ScriptModule.java index ae06eb9d7..45d2028db 100644 --- a/src/main/java/org/scijava/script/ScriptModule.java +++ b/src/main/java/org/scijava/script/ScriptModule.java @@ -88,6 +88,8 @@ public class ScriptModule extends AbstractModule implements Contextual { /** Destination for standard error during script execution. */ private Writer error; + private Object returnValue; + public ScriptModule(final ScriptInfo info) { this.info = info; } @@ -130,7 +132,7 @@ public ScriptEngine getEngine() { /** Gets the return value of the script. */ public Object getReturnValue() { - return getOutput(RETURN_VALUE); + return returnValue; } // -- Module methods -- @@ -167,7 +169,7 @@ public void run() { } // execute script! - Object returnValue = null; + returnValue = null; try { final Reader reader = getInfo().getReader(); if (reader == null) returnValue = engine.eval(new FileReader(path)); From 2eb86fb5688b32a35dc1bc8483dc1393c1d493d7 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Sun, 19 Jun 2016 16:21:52 -0400 Subject: [PATCH 0254/1208] ScriptInfo: append return value if no outputs We want the return value to be an easy way to return a single, untyped (Object) output. This is quite useful for the "lazy" (I mean "elegant") script writer. But for those consuming scripts, it is annoying to always have to deal with this extra "result" output. As a compromise, let's only append the "result" output if: A) no other outputs were declared; and B) "result" was not declared as an input either. --- src/main/java/org/scijava/script/ScriptInfo.java | 7 ++++++- src/test/java/org/scijava/script/ScriptInfoTest.java | 8 ++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index c0c8a65d2..efb1b26cf 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -412,7 +412,12 @@ private void addItem(final String name, final Class type, assignAttribute(item, key, value); } if (item.isInput()) registerInput(item); - if (item.isOutput()) registerOutput(item); + if (item.isOutput()) { + registerOutput(item); + // NB: Only append the return value as an extra + // output when no explicit outputs are declared. + appendReturnValue = false; + } } private void assignAttribute(final DefaultMutableModuleItem item, diff --git a/src/test/java/org/scijava/script/ScriptInfoTest.java b/src/test/java/org/scijava/script/ScriptInfoTest.java index 53f9ed659..6073a8d1a 100644 --- a/src/test/java/org/scijava/script/ScriptInfoTest.java +++ b/src/test/java/org/scijava/script/ScriptInfoTest.java @@ -97,7 +97,7 @@ public void testNoisyParameters() throws Exception { final ScriptModule scriptModule = scriptService.run("hello.bsizes", script, true).get(); - final Object output = scriptModule.getOutput("result"); + final Object output = scriptModule.getReturnValue(); if (output == null) fail("null result"); else if (!(output instanceof Integer)) { @@ -169,10 +169,6 @@ public void testParameters() { assertItem("buffer", StringBuilder.class, null, ItemIO.BOTH, true, true, null, null, null, null, null, null, null, null, noChoices, buffer); - final ModuleItem result = info.getOutput("result"); - assertItem("result", Object.class, null, ItemIO.OUTPUT, true, true, null, - null, null, null, null, null, null, null, noChoices, result); - int inputCount = 0; final ModuleItem[] inputs = { log, sliderValue, animal, buffer }; for (final ModuleItem inItem : info.inputs()) { @@ -180,7 +176,7 @@ public void testParameters() { } int outputCount = 0; - final ModuleItem[] outputs = { buffer, result }; + final ModuleItem[] outputs = { buffer }; for (final ModuleItem outItem : info.outputs()) { assertSame(outputs[outputCount++], outItem); } From 1e1020437a9d9a014de23d906f7ed9bbcaf2bb18 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Sun, 19 Jun 2016 16:30:15 -0400 Subject: [PATCH 0255/1208] Test the improved script return value behavior When _no_ explicit @OUTPUT is given, the return value _is_ appended. When an explicit @OUTPUT _is_ given, the return value is _not_ appended. --- .../org/scijava/script/ScriptInfoTest.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/test/java/org/scijava/script/ScriptInfoTest.java b/src/test/java/org/scijava/script/ScriptInfoTest.java index 6073a8d1a..37b85214c 100644 --- a/src/test/java/org/scijava/script/ScriptInfoTest.java +++ b/src/test/java/org/scijava/script/ScriptInfoTest.java @@ -32,6 +32,7 @@ package org.scijava.script; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -45,6 +46,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.script.Bindings; import javax.script.ScriptContext; @@ -84,6 +86,42 @@ public static void tearDown() { // -- Tests -- + /** + * Tests that the return value is appended as an extra output when no + * explicit outputs were declared. + */ + @Test + public void testReturnValueAppended() throws Exception { + final String script = "" + // + "% @LogService log\n" + // + "% @int value\n"; + final ScriptModule scriptModule = + scriptService.run("include-return-value.bsizes", script, true).get(); + + final Map outputs = scriptModule.getOutputs(); + assertEquals(1, outputs.size()); + assertTrue(outputs.containsKey(ScriptModule.RETURN_VALUE)); + } + + /** + * Tests that the return value is not appended as an extra output + * when explicit outputs were declared. + */ + @Test + public void testReturnValueExcluded() throws Exception { + final String script = "" + // + "% @LogService log\n" + // + "% @OUTPUT int value\n"; + final ScriptModule scriptModule = + scriptService.run("exclude-return-value.bsizes", script, true).get(); + + final Map outputs = scriptModule.getOutputs(); + assertEquals(1, outputs.size()); + assertTrue(outputs.containsKey("value")); + assertFalse(outputs.containsKey(ScriptModule.RETURN_VALUE)); + } + + /** * Ensures parameters are parsed correctly from scripts, even in the presence * of noise like e-mail addresses. From b9ad5941f3f0b464da5f6b45de789854b89cefbe Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 7 Jul 2016 12:34:07 +0200 Subject: [PATCH 0256/1208] ScriptREPL: add javadoc --- src/main/java/org/scijava/script/ScriptREPL.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/scijava/script/ScriptREPL.java b/src/main/java/org/scijava/script/ScriptREPL.java index 639b11a92..f62a7618e 100644 --- a/src/main/java/org/scijava/script/ScriptREPL.java +++ b/src/main/java/org/scijava/script/ScriptREPL.java @@ -75,6 +75,7 @@ public class ScriptREPL { private final PrintStream out; + /** The currently active interpreter. */ private ScriptInterpreter interpreter; public ScriptREPL(final Context context) { From f4c47e073ba42ce17d3c11b5dc57f3773129d39c Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 7 Jul 2016 12:34:24 +0200 Subject: [PATCH 0257/1208] ScriptREPL: only include the interpreted languages Compiled languages (e.g., the JavaScriptLanguage) will not work as desired within the intepreter. --- .../java/org/scijava/script/ScriptREPL.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptREPL.java b/src/main/java/org/scijava/script/ScriptREPL.java index f62a7618e..931f8fb8d 100644 --- a/src/main/java/org/scijava/script/ScriptREPL.java +++ b/src/main/java/org/scijava/script/ScriptREPL.java @@ -75,6 +75,9 @@ public class ScriptREPL { private final PrintStream out; + /** List of interpreter-friendly script languages. */ + private List languages; + /** The currently active interpreter. */ private ScriptInterpreter interpreter; @@ -88,6 +91,19 @@ public ScriptREPL(final Context context, final OutputStream out) { (PrintStream) out : new PrintStream(out); } + /** + * Gets the list of languages compatible with the REPL. + *

    + * This list will match those given by {@link ScriptService#getLanguages()}, + * but filtered to exclude any who report {@code true} for + * {@link ScriptLanguage#isCompiledLanguage()}. + *

    + */ + public List getInterpretedLanguages() { + if (languages == null) initLanguages(); + return languages; + } + /** Gets the script interpreter for the currently active language. */ public ScriptInterpreter getInterpreter() { return interpreter; @@ -123,7 +139,7 @@ public void initialize() { out.println("Welcome to the SciJava REPL!"); out.println(); help(); - final List langs = scriptService.getLanguages(); + final List langs = getInterpretedLanguages(); if (langs.isEmpty()) { out.println("--------------------------------------------------------------"); out.println("Uh oh! There are no SciJava script languages available!"); @@ -245,7 +261,7 @@ public void langs() { final List names = new ArrayList<>(); final List versions = new ArrayList<>(); final List aliases = new ArrayList<>(); - for (final ScriptLanguage lang : scriptService.getLanguages()) { + for (final ScriptLanguage lang : getInterpretedLanguages()) { names.add(lang.getLanguageName()); versions.add(lang.getLanguageVersion()); aliases.add(lang.getNames()); @@ -272,6 +288,16 @@ public static void main(final String... args) throws Exception { // -- Helper methods -- + /** Initializes {@link #languages}. */ + private synchronized void initLanguages() { + if (languages != null) return; + final List langs = new ArrayList<>(); + for (final ScriptLanguage lang : scriptService.getLanguages()) { + if (!lang.isCompiledLanguage()) langs.add(lang); + } + languages = langs; + } + /** Populates the bindings with the context + services + gateways. */ private void populateBindings(final Bindings bindings) { bindings.put("ctx", context); From 74cdce192c2568cbed099fb65f404cccb72db87d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 8 Jul 2016 10:19:59 +0200 Subject: [PATCH 0258/1208] Add a base class for SciJava-based unit tests This eases creation + disposal of a unique Context for each test method. --- .../org/scijava/test/AbstractSciJavaTest.java | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/test/java/org/scijava/test/AbstractSciJavaTest.java diff --git a/src/test/java/org/scijava/test/AbstractSciJavaTest.java b/src/test/java/org/scijava/test/AbstractSciJavaTest.java new file mode 100644 index 000000000..c6cc2167a --- /dev/null +++ b/src/test/java/org/scijava/test/AbstractSciJavaTest.java @@ -0,0 +1,87 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.test; + +import java.awt.Cursor; +import java.util.Random; + +import org.junit.After; +import org.junit.Before; +import org.scijava.Context; +import org.scijava.plugin.Parameter; +import org.scijava.service.Service; +import org.scijava.util.ByteArray; +import org.scijava.util.FloatArray; + +/** + * Base class for unit testing of SciJava components. + *

    + * Many SciJava-based unit tests need to have a {@link Context} with relevant + * services. Following the + * DRY + * principle, we should implement it only once. Here. + *

    + * + * @author Johannes Schindelin + * @author Curtis Rueden + */ +public abstract class AbstractSciJavaTest { + + @Parameter + protected Context context; + + /** Subclasses can override to create a differently configured context. */ + protected Context createContext() { + return new Context(serviceClasses()); + } + + /** Subclasses must override to define the services the context will have. */ + protected abstract Class[] serviceClasses(); + + /** Sets up a SciJava context and injects needed services. */ + @Before + public void setUp() { + createContext().inject(this); + } + + /** + * Disposes of the {@link Context} that was initialized in {@link #setUp()}. + */ + @After + public synchronized void cleanUp() { + if (context != null) { + context.dispose(); + context = null; + } + } + +} From 2a2d8e2d505ef0dcd15d73472be3cece96373c1e Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 8 Jul 2016 18:46:34 +0200 Subject: [PATCH 0259/1208] CommandModuleItem: implement getDefaultValue() The fact that commands could not report their default parameter values was an oversight. Unfortunately, to actually do it, we must instantiate a dummy instance of the Command class. But for the vast majority of cases, this approach will work just fine. --- .../scijava/command/CommandModuleItem.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/main/java/org/scijava/command/CommandModuleItem.java b/src/main/java/org/scijava/command/CommandModuleItem.java index aff1ecda3..9752fad33 100644 --- a/src/main/java/org/scijava/command/CommandModuleItem.java +++ b/src/main/java/org/scijava/command/CommandModuleItem.java @@ -143,6 +143,38 @@ public T getMaximumValue() { return tValue(getParameter().max()); } + @Override + public T getDefaultValue() { + // NB: The default value for a command is the initial field value. + // E.g.: + // + // @Parameter + // private int weekdays = 5; + // + // To obtain this information, we need to instantiate the module, then + // extract the value of the associated field. + // + // Of course, the command might do evil things like: + // + // @Parameter + // private long time = System.currentTimeMillis(); + // + // In which case the default value will vary by instance. But there is + // nothing we can really do about that. This is only a best effort. + + try { + final Object dummy = getInfo().loadDelegateClass().newInstance(); + @SuppressWarnings("unchecked") + final T value = (T) getField().get(dummy); + return value; + } + catch (final InstantiationException | IllegalAccessException + | ClassNotFoundException exc) + { + throw new IllegalStateException(exc); + } + } + @Override public Number getStepSize() { // FIXME: stepSize should be typed on T, not Number! From cde0f427e0201ced9469f84bb600b4b537c2f41f Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 8 Jul 2016 18:48:21 +0200 Subject: [PATCH 0260/1208] CommandModuleTest: test getDefaultValue() --- .../scijava/command/CommandModuleTest.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/test/java/org/scijava/command/CommandModuleTest.java b/src/test/java/org/scijava/command/CommandModuleTest.java index d19a9d86f..931c17c13 100644 --- a/src/test/java/org/scijava/command/CommandModuleTest.java +++ b/src/test/java/org/scijava/command/CommandModuleTest.java @@ -43,6 +43,7 @@ import org.scijava.module.Module; import org.scijava.module.process.AbstractPreprocessorPlugin; import org.scijava.module.process.PreprocessorPlugin; +import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; /** Regression tests for {@link CommandModule}. */ @@ -76,6 +77,25 @@ public void testNotCancelable() throws InterruptedException, assertEquals("NO SINGING!", fire.getCancelReason()); } + @Test + public void testDefaultValues() { + final Context context = new Context(CommandService.class); + final CommandService commandService = context.service(CommandService.class); + final CommandInfo info = // + commandService.getCommand(CommandWithDefaultValues.class); + + assertEquals(5, info.getInput("weekdays").getDefaultValue()); + + final long defaultTime = (Long) info.getInput("time").getDefaultValue(); + final long timeDiff = System.currentTimeMillis() - defaultTime; + assertTrue(timeDiff >= 0 && timeDiff < 50); // 50 ms should be enough ;-) + + final String defaultName = (String) info.getInput("name").getDefaultValue(); + assertEquals("John Jacob Jingleheimer Schmidt", defaultName); + + assertEquals(null, info.getInput("thing").getDefaultValue()); + } + // -- Helper classes -- /** A command which implements {@link Cancelable}. */ @@ -125,4 +145,27 @@ public void process(final Module module) { } } } + + /** A command which assigns default values to its parameters. */ + @Plugin(type = Command.class) + public static class CommandWithDefaultValues extends ContextCommand { + + @Parameter + private int weekdays = 5; + + @Parameter + private long time = System.currentTimeMillis(); + + @Parameter + private String name = "John Jacob Jingleheimer Schmidt"; + + @Parameter + private Object thing; + + @Override + public void run() { + weekdays = 0; + time = 0; + } + } } From 72aa4839111920ee606f92b1f71f30dfe2e5cc39 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 16 Mar 2015 14:02:09 -0500 Subject: [PATCH 0261/1208] AbstractLogService: tweak javadoc --- src/main/java/org/scijava/log/AbstractLogService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/log/AbstractLogService.java b/src/main/java/org/scijava/log/AbstractLogService.java index f183c77da..9b7d5b0c7 100644 --- a/src/main/java/org/scijava/log/AbstractLogService.java +++ b/src/main/java/org/scijava/log/AbstractLogService.java @@ -38,7 +38,7 @@ import org.scijava.service.AbstractService; /** - * Base implementation of an abstract {@link LogService}. + * Base class for {@link LogService} implementations. * * @author Johannes Schindelin */ From 75d7b6a9d27345c482c1f05eb9a6c7ced4c7d1ee Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 16 Mar 2015 14:03:11 -0500 Subject: [PATCH 0262/1208] AbstractLogService: format code style --- .../org/scijava/log/AbstractLogService.java | 81 ++++++++++--------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/src/main/java/org/scijava/log/AbstractLogService.java b/src/main/java/org/scijava/log/AbstractLogService.java index 9b7d5b0c7..fdc3aed1d 100644 --- a/src/main/java/org/scijava/log/AbstractLogService.java +++ b/src/main/java/org/scijava/log/AbstractLogService.java @@ -8,13 +8,13 @@ * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -38,29 +38,31 @@ import org.scijava.service.AbstractService; /** - * Base class for {@link LogService} implementations. - * + * Base class for {@link LogService} implementationst. + * * @author Johannes Schindelin */ -public abstract class AbstractLogService extends AbstractService implements LogService { +public abstract class AbstractLogService extends AbstractService implements + LogService +{ private int currentLevel = System.getenv("DEBUG") == null ? INFO : DEBUG; - private Map classAndPackageLevels = + private final Map classAndPackageLevels = new HashMap<>(); // -- abstract methods -- /** * Displays a message. - * + * * @param msg the message to display. */ protected abstract void log(final String msg); /** * Displays an exception. - * + * * @param t the exception to display. */ protected abstract void log(final Throwable t); @@ -87,7 +89,8 @@ public AbstractLogService() { if (!(propKey instanceof String)) continue; final String propName = (String) propKey; if (!propName.startsWith(logLevelPrefix)) continue; - final String classOrPackageName = propName.substring(logLevelPrefix.length()); + final String classOrPackageName = + propName.substring(logLevelPrefix.length()); setLevel(classOrPackageName, level(props.getProperty(propName))); } @@ -109,97 +112,97 @@ protected void log(final int level, final Object msg) { log((prefix == null ? "" : prefix + " ") + msg); } - protected String getPrefix(int level) { + protected String getPrefix(final int level) { switch (level) { - case ERROR: - return "[ERROR]"; - case WARN: - return "[WARNING]"; - case INFO: - return "[INFO]"; - case DEBUG: - return "[DEBUG]"; - case TRACE: - return "[TRACE]"; - default: - return null; + case ERROR: + return "[ERROR]"; + case WARN: + return "[WARNING]"; + case INFO: + return "[INFO]"; + case DEBUG: + return "[DEBUG]"; + case TRACE: + return "[TRACE]"; + default: + return null; } } // -- LogService methods -- @Override - public void debug(Object msg) { + public void debug(final Object msg) { log(DEBUG, msg, null); } @Override - public void debug(Throwable t) { + public void debug(final Throwable t) { log(DEBUG, null, t); } @Override - public void debug(Object msg, Throwable t) { + public void debug(final Object msg, final Throwable t) { log(DEBUG, msg, t); } @Override - public void error(Object msg) { + public void error(final Object msg) { log(ERROR, msg, null); } @Override - public void error(Throwable t) { + public void error(final Throwable t) { log(ERROR, null, t); } @Override - public void error(Object msg, Throwable t) { + public void error(final Object msg, final Throwable t) { log(ERROR, msg, t); } @Override - public void info(Object msg) { + public void info(final Object msg) { log(INFO, msg, null); } @Override - public void info(Throwable t) { + public void info(final Throwable t) { log(INFO, null, t); } @Override - public void info(Object msg, Throwable t) { + public void info(final Object msg, final Throwable t) { log(INFO, msg, t); } @Override - public void trace(Object msg) { + public void trace(final Object msg) { log(TRACE, msg, null); } @Override - public void trace(Throwable t) { + public void trace(final Throwable t) { log(TRACE, null, t); } @Override - public void trace(Object msg, Throwable t) { + public void trace(final Object msg, final Throwable t) { log(TRACE, msg, t); } @Override - public void warn(Object msg) { + public void warn(final Object msg) { log(WARN, msg, null); } @Override - public void warn(Throwable t) { + public void warn(final Throwable t) { log(WARN, null, t); } @Override - public void warn(Object msg, Throwable t) { + public void warn(final Object msg, final Throwable t) { log(WARN, msg, t); } @@ -248,7 +251,7 @@ public void setLevel(final int level) { currentLevel = level; } - //@Override +// @Override public void setLevel(final String classOrPackageName, final int level) { classAndPackageLevels.put(classOrPackageName, level); } @@ -289,7 +292,7 @@ private String callingClass() { } private String parentPackage(final String classOrPackageName) { - int dot = classOrPackageName.lastIndexOf("."); + final int dot = classOrPackageName.lastIndexOf("."); if (dot < 0) return null; return classOrPackageName.substring(0, dot); } From 460a601160339493ea76aef2bed06028b3c37102 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 16 Mar 2015 14:03:42 -0500 Subject: [PATCH 0263/1208] LogService: add setLevel method to public API Specifically, the setLevel(String classOrPackageName, int level) method was public in AbstractLogService, but not part of the LogService API. --- src/main/java/org/scijava/log/AbstractLogService.java | 2 +- src/main/java/org/scijava/log/LogService.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/log/AbstractLogService.java b/src/main/java/org/scijava/log/AbstractLogService.java index fdc3aed1d..f84aad31d 100644 --- a/src/main/java/org/scijava/log/AbstractLogService.java +++ b/src/main/java/org/scijava/log/AbstractLogService.java @@ -251,7 +251,7 @@ public void setLevel(final int level) { currentLevel = level; } -// @Override + @Override public void setLevel(final String classOrPackageName, final int level) { classAndPackageLevels.put(classOrPackageName, level); } diff --git a/src/main/java/org/scijava/log/LogService.java b/src/main/java/org/scijava/log/LogService.java index e1fae2013..35cb1720a 100644 --- a/src/main/java/org/scijava/log/LogService.java +++ b/src/main/java/org/scijava/log/LogService.java @@ -100,4 +100,6 @@ public interface LogService extends SciJavaService { void setLevel(int level); + void setLevel(String classOrPackageName, int level); + } From a2310cca7a65f570bc0bb967e0f9849c42896330 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 11 Jul 2016 12:53:24 +0200 Subject: [PATCH 0264/1208] MiscUtils: deprecate equal(Object, Object) method The standard library has this built-in now. --- src/main/java/org/scijava/util/MiscUtils.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/scijava/util/MiscUtils.java b/src/main/java/org/scijava/util/MiscUtils.java index 47f3e2794..15ed2b596 100644 --- a/src/main/java/org/scijava/util/MiscUtils.java +++ b/src/main/java/org/scijava/util/MiscUtils.java @@ -31,6 +31,8 @@ package org.scijava.util; +import java.util.Objects; + /** * Miscellaneous utility methods. Every project needs a class like this, right? * @@ -83,13 +85,9 @@ public static > int compare(final T o1, } /** - * Compares two objects for equality, even if one or both of them are null. - * - * @param o1 The first object to compare. - * @param o2 The second object to compare. - * @return True if the two objects are both null, or both are non-null and - * {@code o1.equals(o2)} holds. + * @deprecated Use {@link Objects#equals(Object, Object)} instead. */ + @Deprecated public static boolean equal(final Object o1, final Object o2) { return o1 == null ? o2 == null : o1.equals(o2); } From ff3caa8594784075912f81154142b6a765204041 Mon Sep 17 00:00:00 2001 From: dietzc Date: Tue, 12 Jul 2016 17:30:22 +0200 Subject: [PATCH 0265/1208] Add method to get InputWidget from InputPanel --- src/main/java/org/scijava/widget/AbstractInputPanel.java | 5 +++++ src/main/java/org/scijava/widget/InputPanel.java | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/org/scijava/widget/AbstractInputPanel.java b/src/main/java/org/scijava/widget/AbstractInputPanel.java index 37513ce9e..a4d1cbf6a 100644 --- a/src/main/java/org/scijava/widget/AbstractInputPanel.java +++ b/src/main/java/org/scijava/widget/AbstractInputPanel.java @@ -61,6 +61,11 @@ public boolean supports(final InputWidget widget) { public void addWidget(final InputWidget widget) { widgets.put(widget.get().getItem().getName(), widget); } + + @Override + public InputWidget getWidget(final String name) { + return widgets.get(name); + } @Override public Object getValue(final String name) { diff --git a/src/main/java/org/scijava/widget/InputPanel.java b/src/main/java/org/scijava/widget/InputPanel.java index 2ce25cfa9..4a6e17dda 100644 --- a/src/main/java/org/scijava/widget/InputPanel.java +++ b/src/main/java/org/scijava/widget/InputPanel.java @@ -70,5 +70,8 @@ public interface InputPanel extends UIComponent

    { /** Gets the type of the UI component housing the panel's widgets. */ Class getWidgetComponentType(); + + /** Gets the widget with the provided name. */ + InputWidget getWidget(String name); } From ee718f3d568815f357d5fda9e799b0e92a72695e Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 18 Jul 2016 14:48:07 -0500 Subject: [PATCH 0266/1208] AbstractConverter: do not require an ObjectService We can fail gracefully if the ObjectService is not present. --- src/main/java/org/scijava/convert/AbstractConverter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/convert/AbstractConverter.java b/src/main/java/org/scijava/convert/AbstractConverter.java index 00a827aa1..10478e841 100644 --- a/src/main/java/org/scijava/convert/AbstractConverter.java +++ b/src/main/java/org/scijava/convert/AbstractConverter.java @@ -72,7 +72,7 @@ public abstract class AbstractConverter extends // -- Parameters -- - @Parameter + @Parameter(required = false) private ObjectService objectService; // -- ConversionHandler methods -- @@ -131,6 +131,7 @@ public Object convert(final ConversionRequest request) { @Override public void populateInputCandidates(final Collection objects) { + if (objectService == null) return; for (final Object candidate : objectService.getObjects(getInputType())) { if (canConvert(candidate, getOutputType())) objects.add(candidate); } From 0daddfb318275aa66ddba8d7ea37cdbc720840c5 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 18 Jul 2016 14:48:38 -0500 Subject: [PATCH 0267/1208] DefaultEventService: reduce indentation nesting --- .../scijava/event/DefaultEventService.java | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/scijava/event/DefaultEventService.java b/src/main/java/org/scijava/event/DefaultEventService.java index 8a26e0c23..f297a6bc3 100644 --- a/src/main/java/org/scijava/event/DefaultEventService.java +++ b/src/main/java/org/scijava/event/DefaultEventService.java @@ -113,32 +113,30 @@ public void publishLater(final E e) { @Override public List> subscribe(final Object o) { - List> subscribers = Collections.emptyList(); final List eventHandlers = ClassUtils.getAnnotatedMethods(o.getClass(), EventHandler.class); + if (eventHandlers.isEmpty()) return Collections.emptyList(); + + final ArrayList> subscribers = new ArrayList<>(); + for (final Method m : eventHandlers) { + // verify that the event handler method is valid + final Class eventClass = getEventClass(m); + if (eventClass == null) { + log.warn("Invalid EventHandler method: " + m); + continue; + } - if (!eventHandlers.isEmpty()) { - subscribers = new ArrayList<>(); - for (final Method m : eventHandlers) { - // verify that the event handler method is valid - final Class eventClass = getEventClass(m); - if (eventClass == null) { - log.warn("Invalid EventHandler method: " + m); - continue; - } - - // verify that the event handler key isn't already claimed - final String key = m.getAnnotation(EventHandler.class).key(); - if (!key.isEmpty()) { - synchronized (keys) { - if (keys.contains(key)) continue; - keys.add(key); - } + // verify that the event handler key isn't already claimed + final String key = m.getAnnotation(EventHandler.class).key(); + if (!key.isEmpty()) { + synchronized (keys) { + if (keys.contains(key)) continue; + keys.add(key); } - - // subscribe the event handler - subscribers.add(subscribe(eventClass, o, m)); } + + // subscribe the event handler + subscribers.add(subscribe(eventClass, o, m)); } return subscribers; } From 906e6442b8cec6798813783a02c5fbc7e008a3a5 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 1 Aug 2014 10:49:50 -0500 Subject: [PATCH 0268/1208] Clean up method ordering and section headers See: http://imagej.net/Coding_style#Ordering_of_code_blocks --- .../java/org/scijava/AbstractGateway.java | 10 ++-- .../java/org/scijava/app/AbstractApp.java | 48 ++++++++++--------- .../java/org/scijava/script/ScriptInfo.java | 2 + 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/scijava/AbstractGateway.java b/src/main/java/org/scijava/AbstractGateway.java index 202cab0f1..9db79f09e 100644 --- a/src/main/java/org/scijava/AbstractGateway.java +++ b/src/main/java/org/scijava/AbstractGateway.java @@ -274,13 +274,15 @@ public String getTitle() { } @Override - public String getVersion() { - return getApp().getVersion(); + public String getInfo(final boolean mem) { + return getApp().getInfo(mem); } + // -- Versioned methods -- + @Override - public String getInfo(final boolean mem) { - return getApp().getInfo(mem); + public String getVersion() { + return getApp().getVersion(); } } diff --git a/src/main/java/org/scijava/app/AbstractApp.java b/src/main/java/org/scijava/app/AbstractApp.java index 4e40d3604..66e86db9d 100644 --- a/src/main/java/org/scijava/app/AbstractApp.java +++ b/src/main/java/org/scijava/app/AbstractApp.java @@ -56,33 +56,13 @@ public abstract class AbstractApp extends AbstractRichPlugin implements App { /** JAR manifest with metadata about the application. */ private Manifest manifest; + // -- App methods -- + @Override public String getTitle() { return getInfo().getName(); } - @Override - public String getVersion() { - // NB: We do not use VersionUtils.getVersion(c, groupId, artifactId) - // because that method does not cache the parsed Manifest and/or POM. - // We might have them already parsed here, and if not, we want to - // parse then cache locally, rather than discarding them afterwards. - - // try the manifest first, since it might know its build number - final Manifest m = getManifest(); - if (m != null) { - final String v = m.getVersion(); - if (v != null) return v; - } - // try the POM - final POM p = getPOM(); - if (p != null) { - final String v = p.getVersion(); - if (v != null) return v; - } - return "Unknown"; - } - @Override public POM getPOM() { if (pom == null) { @@ -145,4 +125,28 @@ public void quit() { getContext().dispose(); } + // -- Versioned methods -- + + @Override + public String getVersion() { + // NB: We do not use VersionUtils.getVersion(c, groupId, artifactId) + // because that method does not cache the parsed Manifest and/or POM. + // We might have them already parsed here, and if not, we want to + // parse then cache locally, rather than discarding them afterwards. + + // try the manifest first, since it might know its build number + final Manifest m = getManifest(); + if (m != null) { + final String v = m.getVersion(); + if (v != null) return v; + } + // try the POM + final POM p = getPOM(); + if (p != null) { + final String v = p.getVersion(); + if (v != null) return v; + } + return "Unknown"; + } + } diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index 6d4657be6..bd17bfc34 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -318,6 +318,8 @@ public String getLocation() { return new File(path).toURI().normalize().toString(); } + // -- Versioned methods -- + @Override public String getVersion() { final File file = new File(path); From 5a3f01141f6cf8e67daa185351daf27a8ddeee15 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 27 Jul 2016 14:10:28 -0500 Subject: [PATCH 0269/1208] Locatable: add default behavior for getLocation --- src/main/java/org/scijava/Locatable.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/Locatable.java b/src/main/java/org/scijava/Locatable.java index 3073a9266..9d4d73bf5 100644 --- a/src/main/java/org/scijava/Locatable.java +++ b/src/main/java/org/scijava/Locatable.java @@ -31,6 +31,10 @@ package org.scijava; +import java.net.URL; + +import org.scijava.util.ClassUtils; + /** * An object whose location is defined by a URL string. * @@ -39,6 +43,9 @@ public interface Locatable { /** Gets the URL string defining the object's location. */ - String getLocation(); + default String getLocation() { + final URL location = ClassUtils.getLocation(getClass()); + return location == null ? null : location.toExternalForm(); + } } From bc0b7c6c5d7c5807b6ca89b52b0dbb2c215c1aab Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 27 Jul 2016 14:10:52 -0500 Subject: [PATCH 0270/1208] Versioned: add default behavior for getVersion --- src/main/java/org/scijava/Versioned.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/Versioned.java b/src/main/java/org/scijava/Versioned.java index 793c0fc9d..03379bead 100644 --- a/src/main/java/org/scijava/Versioned.java +++ b/src/main/java/org/scijava/Versioned.java @@ -31,6 +31,8 @@ package org.scijava; +import org.scijava.util.VersionUtils; + /** * An object that knows its version. * @@ -39,6 +41,9 @@ public interface Versioned { /** Gets the version of the object. */ - String getVersion(); + default String getVersion() { + return VersionUtils.getVersion(getClass()); + } + } From 0d1f357932b9a6049831143a09aacebc888dd8be Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 27 Jul 2016 14:12:07 -0500 Subject: [PATCH 0271/1208] Prioritized: add default behavior for compareTo --- src/main/java/org/scijava/Prioritized.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/org/scijava/Prioritized.java b/src/main/java/org/scijava/Prioritized.java index 4aafbeb13..de544e2bf 100644 --- a/src/main/java/org/scijava/Prioritized.java +++ b/src/main/java/org/scijava/Prioritized.java @@ -31,6 +31,8 @@ package org.scijava; +import org.scijava.util.ClassUtils; + /** * An object that can be sorted according to priority. * @@ -52,4 +54,18 @@ public interface Prioritized extends Comparable { */ void setPriority(double priority); + // -- Comparable methods -- + + @Override + default int compareTo(final Prioritized that) { + if (that == null) return 1; + + // compare priorities + final int priorityCompare = Priority.compare(this, that); + if (priorityCompare != 0) return priorityCompare; + + // compare classes + return ClassUtils.compare(getClass(), that.getClass()); + } + } From 3ff7c91d23015001edaaf5edc8be4d21825f6a6c Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 27 Jul 2016 14:15:52 -0500 Subject: [PATCH 0272/1208] AbstractRichPlugin: remove compareTo behavior It is now inherited from the Prioritized interface. --- .../org/scijava/plugin/AbstractRichPlugin.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/main/java/org/scijava/plugin/AbstractRichPlugin.java b/src/main/java/org/scijava/plugin/AbstractRichPlugin.java index 11f88620b..3ef02bcff 100644 --- a/src/main/java/org/scijava/plugin/AbstractRichPlugin.java +++ b/src/main/java/org/scijava/plugin/AbstractRichPlugin.java @@ -32,9 +32,7 @@ package org.scijava.plugin; import org.scijava.AbstractContextual; -import org.scijava.Prioritized; import org.scijava.Priority; -import org.scijava.util.ClassUtils; /** * Abstract base class for {@link RichPlugin} implementations. @@ -83,18 +81,4 @@ public void setInfo(final PluginInfo info) { this.info = info; } - // -- Comparable methods -- - - @Override - public int compareTo(final Prioritized that) { - if (that == null) return 1; - - // compare priorities - final int priorityCompare = Priority.compare(this, that); - if (priorityCompare != 0) return priorityCompare; - - // compare classes - return ClassUtils.compare(getClass(), that.getClass()); - } - } From c3d560a3e009b098c16ad56453acb83bc0fe6e00 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 1 Aug 2014 10:17:54 -0500 Subject: [PATCH 0273/1208] Make RichPlugin implement more useful interfaces Now, all rich plugins are Identifiable, Locatable and Versioned. --- src/main/java/org/scijava/plugin/RichPlugin.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/plugin/RichPlugin.java b/src/main/java/org/scijava/plugin/RichPlugin.java index bbe7a304f..faec2240c 100644 --- a/src/main/java/org/scijava/plugin/RichPlugin.java +++ b/src/main/java/org/scijava/plugin/RichPlugin.java @@ -32,7 +32,10 @@ package org.scijava.plugin; import org.scijava.Contextual; +import org.scijava.Identifiable; +import org.scijava.Locatable; import org.scijava.Prioritized; +import org.scijava.Versioned; /** * Base interface for {@link Contextual}, {@link Prioritized} plugins that @@ -42,8 +45,15 @@ * * @author Curtis Rueden */ -public interface RichPlugin extends Contextual, Prioritized, HasPluginInfo, - SciJavaPlugin +public interface RichPlugin extends SciJavaPlugin, Contextual, Prioritized, + HasPluginInfo, Identifiable, Locatable, Versioned { - // NB: Marker interface. + + // -- Identifiable methods -- + + @Override + default String getIdentifier() { + return "plugin:" + getClass().getName(); + } + } From e485a090764759244392167c48dea90bc56d5600 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 1 Aug 2014 10:48:57 -0500 Subject: [PATCH 0274/1208] Gateway: remove superfluous Versioned inheritance All RichPlugins are now versioned. --- src/main/java/org/scijava/Gateway.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/org/scijava/Gateway.java b/src/main/java/org/scijava/Gateway.java index 6ef437ea5..50eaaf9be 100644 --- a/src/main/java/org/scijava/Gateway.java +++ b/src/main/java/org/scijava/Gateway.java @@ -118,7 +118,7 @@ * @author Mark Hiner * @author Curtis Rueden */ -public interface Gateway extends RichPlugin, Versioned { +public interface Gateway extends RichPlugin { /** * Perform launch operations associated with this gateway. @@ -362,10 +362,4 @@ public interface Gateway extends RichPlugin, Versioned { /** @see org.scijava.app.App#getInfo(boolean) */ String getInfo(boolean mem); - // -- Versioned methods -- - - /** @see org.scijava.app.App#getVersion() */ - @Override - String getVersion(); - } From 4b37eedd36d057f92e480f243d62152d9930aa0b Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 1 Aug 2016 12:41:53 -0500 Subject: [PATCH 0275/1208] SortedObjectIndex: fix order of method blocks See: http://imagej.net/Coding_style#Ordering_of_code_blocks --- .../org/scijava/object/SortedObjectIndex.java | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/main/java/org/scijava/object/SortedObjectIndex.java b/src/main/java/org/scijava/object/SortedObjectIndex.java index c5270529d..1cd3120d6 100644 --- a/src/main/java/org/scijava/object/SortedObjectIndex.java +++ b/src/main/java/org/scijava/object/SortedObjectIndex.java @@ -92,6 +92,49 @@ public boolean addAll(final Collection c) { return changed; } + // -- Internal methods -- + + @Override + protected boolean addToList(final E obj, final List list, + final boolean batch) + { + if (batch) { + // adding multiple values; append to end of list, and sort afterward + return super.addToList(obj, list, batch); + } + + // search for the correct location to insert the object + final int result = Collections.binarySearch(list, obj); + // NB: The objects' natural ordering may not be consistent with equals. + // Hence, the index reported may indicate a match with an unequal object + // (i.e., obj.compareTo(match) == 0 but !obj.equals(match)). + // But since we allow duplicate items in the index, this situation is fine; + // either way, we want to insert the object at the given point. + final int index = result < 0 ? -result - 1 : result; + + // insert object at the appropriate location + list.add(index, obj); + return true; + } + + // -- Helper methods -- + + private void sort() { + for (final List list : hoard.values()) { + Collections.sort(list); + } + } + + private int findInList(final Object o, final List list) { + if (!getBaseClass().isAssignableFrom(o.getClass())) { + // wrong type + return list.size(); + } + @SuppressWarnings("unchecked") + final E typedObj = (E) o; + return Collections.binarySearch(list, typedObj); + } + private void mergeAfterSorting(final Collection c) { final List listToMerge = new ArrayList<>(c); Collections.sort(listToMerge); @@ -145,47 +188,4 @@ private void mergeInto(final List sorted, final List into) { } } - // -- Internal methods -- - - @Override - protected boolean addToList(final E obj, final List list, - final boolean batch) - { - if (batch) { - // adding multiple values; append to end of list, and sort afterward - return super.addToList(obj, list, batch); - } - - // search for the correct location to insert the object - final int result = Collections.binarySearch(list, obj); - // NB: The objects' natural ordering may not be consistent with equals. - // Hence, the index reported may indicate a match with an unequal object - // (i.e., obj.compareTo(match) == 0 but !obj.equals(match)). - // But since we allow duplicate items in the index, this situation is fine; - // either way, we want to insert the object at the given point. - final int index = result < 0 ? -result - 1 : result; - - // insert object at the appropriate location - list.add(index, obj); - return true; - } - - // -- Helper methods -- - - private void sort() { - for (final List list : hoard.values()) { - Collections.sort(list); - } - } - - private int findInList(final Object o, final List list) { - if (!getBaseClass().isAssignableFrom(o.getClass())) { - // wrong type - return list.size(); - } - @SuppressWarnings("unchecked") - final E typedObj = (E) o; - return Collections.binarySearch(list, typedObj); - } - } From 212d8277cef1c5cb02eb778d0988371a9370981a Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 1 Aug 2016 12:52:51 -0500 Subject: [PATCH 0276/1208] RecentFileService: index recent files properly When invoking the PrefService, we should give a class, not leave it undefined. Otherwise, the recent files list gets stored under the global preferences node, rather than the RecentFileService. --- src/main/java/org/scijava/io/DefaultRecentFileService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/io/DefaultRecentFileService.java b/src/main/java/org/scijava/io/DefaultRecentFileService.java index 1f7cd3c03..7c699f846 100644 --- a/src/main/java/org/scijava/io/DefaultRecentFileService.java +++ b/src/main/java/org/scijava/io/DefaultRecentFileService.java @@ -147,7 +147,7 @@ public boolean remove(final String path) { @Override public void clear() { recentFiles.clear(); - prefService.clear(RECENT_FILES_KEY); + prefService.clear(RecentFileService.class, RECENT_FILES_KEY); // unregister the modules with the module service moduleService.removeModules(recentModules.values()); @@ -185,12 +185,13 @@ protected void onEvent(final IOEvent event) { /** Loads the list of recent files from persistent storage. */ private void loadList() { - recentFiles = prefService.getList(RECENT_FILES_KEY); + recentFiles = prefService.getList(RecentFileService.class, + RECENT_FILES_KEY); } /** Saves the list of recent files to persistent storage. */ private void saveList() { - prefService.putList(recentFiles, RECENT_FILES_KEY); + prefService.putList(RecentFileService.class, recentFiles, RECENT_FILES_KEY); } /** Creates a {@link ModuleInfo} to reopen data at the given path. */ From 6dcda87b813149355940fa10258c842f11a44214 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 5 Aug 2016 14:42:19 -0500 Subject: [PATCH 0277/1208] POM: bump parent to pom-scijava 11.0.0 --- pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5830f4e85..8462de89a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.scijava pom-scijava - 10.5.0 + 11.0.0 @@ -102,7 +102,6 @@ - 1.8 3.0.0 From a2dc49649dad601cc86f56958041da3903200d37 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 5 Aug 2016 14:42:59 -0500 Subject: [PATCH 0278/1208] POM: stop pinning scijava-expression-parser It was now outdated. --- pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pom.xml b/pom.xml index 8462de89a..315ebc6b0 100644 --- a/pom.xml +++ b/pom.xml @@ -101,10 +101,6 @@ http://jenkins.imagej.net/job/SciJava-common/ - - 3.0.0 - - From eb2ca6f908422b847a5c0a575f0f4e3e85bd4ef0 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 5 Aug 2016 14:45:43 -0500 Subject: [PATCH 0279/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 315ebc6b0..6abefec34 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.57.0-SNAPSHOT + 2.57.1-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From b32b4af1a844a5ba1d97b7b08e8b697f7d8a0948 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 15 Aug 2016 10:22:40 -0500 Subject: [PATCH 0280/1208] PlatformService: deprecate getAppEventService() This service is long-deprecated in favor of the AppService. --- src/main/java/org/scijava/platform/PlatformService.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/platform/PlatformService.java b/src/main/java/org/scijava/platform/PlatformService.java index 3cb305b25..4154cae30 100644 --- a/src/main/java/org/scijava/platform/PlatformService.java +++ b/src/main/java/org/scijava/platform/PlatformService.java @@ -35,6 +35,8 @@ import java.net.URL; import java.util.List; +import org.scijava.app.App; +import org.scijava.app.AppService; import org.scijava.command.CommandService; import org.scijava.event.EventService; import org.scijava.plugin.SingletonService; @@ -54,8 +56,6 @@ public interface PlatformService extends SingletonService, CommandService getCommandService(); - AppEventService getAppEventService(); - /** Gets the platform handlers applicable to this platform. */ List getTargetPlatforms(); @@ -85,4 +85,9 @@ public interface PlatformService extends SingletonService, */ boolean registerAppMenus(Object menus); + // -- Deprecated methods -- + + /** @deprecated Use {@link AppService} and {@link App} instead. */ + @Deprecated + AppEventService getAppEventService(); } From 075f96dc2902e6e926bd7a30d43c367ca866c3b1 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 15 Aug 2016 08:47:37 -0500 Subject: [PATCH 0281/1208] Rename get*Service() methods of services As we move toward SJC3, I decided to drop the "get" prefix from service dependency accessors. This is arguably inconsistent with the rest of SJC, and certainly it is inconsistent with the Java standard library. However, it has some nice consequences: * When browsing available service functionality via autocomplete, service accessors do not clutter the accessors method list. * It makes chaining service accessors more streamlined and readable. I debated dropping the "Service" suffix too, in the same manner as the Gateways do, but decided that would be confusing at the lower level of the API where services reside: services have other API mixed in, so a method called e.g. object() might be confused for something which returns relevant objects, rather than an ObjectService instance. The Gateways do not have this issue because their primary accessors are in fact all services, so the naming is less confusing there. --- .../org/scijava/command/CommandService.java | 17 +++++++++++-- .../command/DefaultCommandService.java | 6 ++--- .../display/DefaultDisplayService.java | 6 ++--- .../org/scijava/display/DisplayService.java | 25 ++++++++++++++++--- .../scijava/input/DefaultInputService.java | 2 +- .../java/org/scijava/input/InputService.java | 9 ++++++- .../scijava/object/DefaultObjectService.java | 2 +- .../org/scijava/object/ObjectService.java | 9 ++++++- .../platform/DefaultPlatformService.java | 4 +-- .../org/scijava/platform/PlatformService.java | 16 ++++++++++-- .../org/scijava/plugin/AbstractPTService.java | 2 +- .../plugin/AbstractSingletonService.java | 5 ++-- .../plugin/AbstractWrapperService.java | 2 +- .../java/org/scijava/plugin/PTService.java | 9 ++++++- 14 files changed, 89 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/scijava/command/CommandService.java b/src/main/java/org/scijava/command/CommandService.java index 1659b088e..3f0e0da8e 100644 --- a/src/main/java/org/scijava/command/CommandService.java +++ b/src/main/java/org/scijava/command/CommandService.java @@ -64,9 +64,9 @@ */ public interface CommandService extends PTService, SciJavaService { - EventService getEventService(); + EventService eventService(); - ModuleService getModuleService(); + ModuleService moduleService(); /** Gets the list of all available {@link Command}s). */ List getCommands(); @@ -257,4 +257,17 @@ Future run(Class commandClass, Future run(CommandInfo info, boolean process, Map inputMap); + // -- Deprecated methods -- + + /** @deprecated Use {@link #eventService()} instead. */ + @Deprecated + default EventService getEventService() { + return eventService(); + } + + /** @deprecated Use {@link #moduleService()} instead. */ + @Deprecated + default ModuleService getModuleService() { + return moduleService(); + } } diff --git a/src/main/java/org/scijava/command/DefaultCommandService.java b/src/main/java/org/scijava/command/DefaultCommandService.java index d33cbaf97..b4f74e32e 100644 --- a/src/main/java/org/scijava/command/DefaultCommandService.java +++ b/src/main/java/org/scijava/command/DefaultCommandService.java @@ -83,17 +83,17 @@ public class DefaultCommandService extends AbstractPTService implements // -- CommandService methods -- @Override - public EventService getEventService() { + public EventService eventService() { return eventService; } @Override - public PluginService getPluginService() { + public PluginService pluginService() { return pluginService; } @Override - public ModuleService getModuleService() { + public ModuleService moduleService() { return moduleService; } diff --git a/src/main/java/org/scijava/display/DefaultDisplayService.java b/src/main/java/org/scijava/display/DefaultDisplayService.java index ac441a0f3..018b73c69 100644 --- a/src/main/java/org/scijava/display/DefaultDisplayService.java +++ b/src/main/java/org/scijava/display/DefaultDisplayService.java @@ -85,17 +85,17 @@ public final class DefaultDisplayService extends AbstractService implements // -- DisplayService methods -- @Override - public EventService getEventService() { + public EventService eventService() { return eventService; } @Override - public ObjectService getObjectService() { + public ObjectService objectService() { return objectService; } @Override - public PluginService getPluginService() { + public PluginService pluginService() { return pluginService; } diff --git a/src/main/java/org/scijava/display/DisplayService.java b/src/main/java/org/scijava/display/DisplayService.java index 20f0d33e6..204de8f74 100644 --- a/src/main/java/org/scijava/display/DisplayService.java +++ b/src/main/java/org/scijava/display/DisplayService.java @@ -50,11 +50,11 @@ */ public interface DisplayService extends SciJavaService { - EventService getEventService(); + EventService eventService(); - ObjectService getObjectService(); + ObjectService objectService(); - PluginService getPluginService(); + PluginService pluginService(); /** Gets the currently active display (of any Display type). */ Display getActiveDisplay(); @@ -183,4 +183,23 @@
    > List> getDisplayPluginsOfType( */ Display createDisplayQuietly(Object o); + // -- Deprecated methods -- + + /** @deprecated Use {@link #eventService()} instead. */ + @Deprecated + default EventService getEventService() { + return eventService(); + } + + /** @deprecated Use {@link #objectService()} instead. */ + @Deprecated + default ObjectService getObjectService() { + return objectService(); + } + + /** @deprecated Use {@link #pluginService()} instead. */ + @Deprecated + default PluginService getPluginService() { + return pluginService(); + } } diff --git a/src/main/java/org/scijava/input/DefaultInputService.java b/src/main/java/org/scijava/input/DefaultInputService.java index ebb23aec3..ca0f8ee75 100644 --- a/src/main/java/org/scijava/input/DefaultInputService.java +++ b/src/main/java/org/scijava/input/DefaultInputService.java @@ -79,7 +79,7 @@ public class DefaultInputService extends AbstractService implements // -- InputService methods -- @Override - public EventService getEventService() { + public EventService eventService() { return eventService; } diff --git a/src/main/java/org/scijava/input/InputService.java b/src/main/java/org/scijava/input/InputService.java index 467788e0e..b4ecdd249 100644 --- a/src/main/java/org/scijava/input/InputService.java +++ b/src/main/java/org/scijava/input/InputService.java @@ -45,7 +45,7 @@ */ public interface InputService extends SciJavaService { - EventService getEventService(); + EventService eventService(); InputModifiers getModifiers(); @@ -98,4 +98,11 @@ public interface InputService extends SciJavaService { */ boolean isButtonDown(int button); + // -- Deprecated methods -- + + /** @deprecated Use {@link #eventService()} instead. */ + @Deprecated + default EventService getEventService() { + return eventService(); + } } diff --git a/src/main/java/org/scijava/object/DefaultObjectService.java b/src/main/java/org/scijava/object/DefaultObjectService.java index 3c0f98780..1b25c787d 100644 --- a/src/main/java/org/scijava/object/DefaultObjectService.java +++ b/src/main/java/org/scijava/object/DefaultObjectService.java @@ -72,7 +72,7 @@ public final class DefaultObjectService extends AbstractService implements // -- ObjectService methods -- @Override - public EventService getEventService() { + public EventService eventService() { return eventService; } diff --git a/src/main/java/org/scijava/object/ObjectService.java b/src/main/java/org/scijava/object/ObjectService.java index fd4bf23f5..a3b880997 100644 --- a/src/main/java/org/scijava/object/ObjectService.java +++ b/src/main/java/org/scijava/object/ObjectService.java @@ -43,7 +43,7 @@ */ public interface ObjectService extends SciJavaService { - EventService getEventService(); + EventService eventService(); /** Gets the index of available objects. */ ObjectIndex getIndex(); @@ -57,4 +57,11 @@ public interface ObjectService extends SciJavaService { /** Deregisters an object with the object service. */ void removeObject(Object obj); + // -- Deprecated methods -- + + /** @deprecated Use {@link #eventService()} instead. */ + @Deprecated + default EventService getEventService() { + return eventService(); + } } diff --git a/src/main/java/org/scijava/platform/DefaultPlatformService.java b/src/main/java/org/scijava/platform/DefaultPlatformService.java index aabd65a1c..5b64ed8c4 100644 --- a/src/main/java/org/scijava/platform/DefaultPlatformService.java +++ b/src/main/java/org/scijava/platform/DefaultPlatformService.java @@ -75,12 +75,12 @@ public final class DefaultPlatformService extends // -- PlatformService methods -- @Override - public EventService getEventService() { + public EventService eventService() { return eventService; } @Override - public CommandService getCommandService() { + public CommandService commandService() { return commandService; } diff --git a/src/main/java/org/scijava/platform/PlatformService.java b/src/main/java/org/scijava/platform/PlatformService.java index 4154cae30..1e1f0b783 100644 --- a/src/main/java/org/scijava/platform/PlatformService.java +++ b/src/main/java/org/scijava/platform/PlatformService.java @@ -52,9 +52,9 @@ public interface PlatformService extends SingletonService, SciJavaService { - EventService getEventService(); + EventService eventService(); - CommandService getCommandService(); + CommandService commandService(); /** Gets the platform handlers applicable to this platform. */ List getTargetPlatforms(); @@ -90,4 +90,16 @@ public interface PlatformService extends SingletonService, /** @deprecated Use {@link AppService} and {@link App} instead. */ @Deprecated AppEventService getAppEventService(); + + /** @deprecated Use {@link #eventService()} instead. */ + @Deprecated + default EventService getEventService() { + return eventService(); + } + + /** @deprecated Use {@link #commandService()} instead. */ + @Deprecated + default CommandService getCommandService() { + return commandService(); + } } diff --git a/src/main/java/org/scijava/plugin/AbstractPTService.java b/src/main/java/org/scijava/plugin/AbstractPTService.java index 4c77c451e..35cb019ca 100644 --- a/src/main/java/org/scijava/plugin/AbstractPTService.java +++ b/src/main/java/org/scijava/plugin/AbstractPTService.java @@ -51,7 +51,7 @@ public abstract class AbstractPTService extends // -- PTService methods -- @Override - public PluginService getPluginService() { + public PluginService pluginService() { return pluginService; } diff --git a/src/main/java/org/scijava/plugin/AbstractSingletonService.java b/src/main/java/org/scijava/plugin/AbstractSingletonService.java index 16183e03e..eb18761c2 100644 --- a/src/main/java/org/scijava/plugin/AbstractSingletonService.java +++ b/src/main/java/org/scijava/plugin/AbstractSingletonService.java @@ -120,9 +120,8 @@ protected List filterInstances(final List list) { private synchronized void initInstances() { if (instances != null) return; - final List list = - Collections.unmodifiableList(filterInstances(getPluginService() - .createInstancesOfType(getPluginType()))); + final List list = Collections.unmodifiableList(filterInstances( + pluginService().createInstancesOfType(getPluginType()))); final HashMap, PT> map = new HashMap<>(); diff --git a/src/main/java/org/scijava/plugin/AbstractWrapperService.java b/src/main/java/org/scijava/plugin/AbstractWrapperService.java index 5254a5a12..a4f2e5959 100644 --- a/src/main/java/org/scijava/plugin/AbstractWrapperService.java +++ b/src/main/java/org/scijava/plugin/AbstractWrapperService.java @@ -77,7 +77,7 @@ public boolean supports(final DT data) { private PT findWrapper(final D data) { for (final PluginInfo plugin : getPlugins()) { - final PT instance = getPluginService().createInstance(plugin); + final PT instance = pluginService().createInstance(plugin); if (instance != null && instance.supports(data)) return instance; } return null; diff --git a/src/main/java/org/scijava/plugin/PTService.java b/src/main/java/org/scijava/plugin/PTService.java index 1f3caf9df..ed7249c3d 100644 --- a/src/main/java/org/scijava/plugin/PTService.java +++ b/src/main/java/org/scijava/plugin/PTService.java @@ -87,7 +87,7 @@ public interface PTService extends Service { * Gets the service responsible for discovering and managing this service's * plugins. */ - PluginService getPluginService(); + PluginService pluginService(); /** Gets the plugins managed by this service. */ List> getPlugins(); @@ -98,4 +98,11 @@ public interface PTService extends Service { /** Creates an instance of the given plugin class. */

    P create(final Class

    pluginClass); + // -- Deprecated methods -- + + /** @deprecated Use {@link #pluginService()} instead. */ + @Deprecated + default PluginService getPluginService() { + return pluginService(); + } } From c2d607a1e499ef89d34b266b4326d92c9d1cfca2 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 15 Aug 2016 08:36:15 -0500 Subject: [PATCH 0282/1208] Push default Service method behavior to interface Thanks, Java 8. --- .../org/scijava/service/AbstractService.java | 17 ----------------- src/main/java/org/scijava/service/Service.java | 13 +++++++++++-- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/scijava/service/AbstractService.java b/src/main/java/org/scijava/service/AbstractService.java index 88f036f21..bc95cdf4a 100644 --- a/src/main/java/org/scijava/service/AbstractService.java +++ b/src/main/java/org/scijava/service/AbstractService.java @@ -32,7 +32,6 @@ package org.scijava.service; import org.scijava.Context; -import org.scijava.event.EventService; import org.scijava.plugin.AbstractRichPlugin; /** @@ -59,22 +58,6 @@ public abstract class AbstractService extends AbstractRichPlugin implements */ private Context context; - // -- Service methods -- - - @Override - public void initialize() { - // NB: Do nothing by default. - } - - @Override - public void registerEventHandlers() { - // TODO: Consider removing this method in scijava-common 3.0.0. - // Instead, the ServiceHelper could just invoke the lines below directly, - // and there would be one less boilerplate Service method to implement. - final EventService eventService = context().getService(EventService.class); - if (eventService != null) eventService.subscribe(this); - } - // -- Contextual methods -- @Override diff --git a/src/main/java/org/scijava/service/Service.java b/src/main/java/org/scijava/service/Service.java index 140d1377f..0118f93f1 100644 --- a/src/main/java/org/scijava/service/Service.java +++ b/src/main/java/org/scijava/service/Service.java @@ -32,6 +32,7 @@ package org.scijava.service; import org.scijava.Disposable; +import org.scijava.event.EventService; import org.scijava.plugin.Plugin; import org.scijava.plugin.RichPlugin; @@ -58,7 +59,9 @@ public interface Service extends RichPlugin, Disposable { * when initializing the service. It should not be called a second time. *

    */ - void initialize(); + default void initialize() { + // NB: Do nothing by default. + } /** * Registers the service's event handler methods. @@ -68,6 +71,12 @@ public interface Service extends RichPlugin, Disposable { * when initializing the service. It should not be called a second time. *

    */ - void registerEventHandlers(); + default void registerEventHandlers() { + // TODO: Consider removing this method in scijava-common 3.0.0. + // Instead, the ServiceHelper could just invoke the lines below directly, + // and there would be one less boilerplate Service method to implement. + final EventService eventService = context().getService(EventService.class); + if (eventService != null) eventService.subscribe(this); + } } From bbb2a5a8fdf40c7103dcae7e6d076f612044b82b Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 15 Aug 2016 08:37:28 -0500 Subject: [PATCH 0283/1208] SingletonService: add ObjectService accessor This will be handy to add default method behavior to the interface. --- .../java/org/scijava/plugin/AbstractSingletonService.java | 5 +++++ src/main/java/org/scijava/plugin/SingletonService.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/org/scijava/plugin/AbstractSingletonService.java b/src/main/java/org/scijava/plugin/AbstractSingletonService.java index eb18761c2..d7d793a8f 100644 --- a/src/main/java/org/scijava/plugin/AbstractSingletonService.java +++ b/src/main/java/org/scijava/plugin/AbstractSingletonService.java @@ -67,6 +67,11 @@ public abstract class AbstractSingletonService // -- SingletonService methods -- + @Override + public ObjectService objectService() { + return objectService; + } + @Override public List getInstances() { if (instances == null) initInstances(); diff --git a/src/main/java/org/scijava/plugin/SingletonService.java b/src/main/java/org/scijava/plugin/SingletonService.java index 5f22897a2..0efbae764 100644 --- a/src/main/java/org/scijava/plugin/SingletonService.java +++ b/src/main/java/org/scijava/plugin/SingletonService.java @@ -33,6 +33,8 @@ import java.util.List; +import org.scijava.object.ObjectService; + /** * A service for managing {@link SingletonPlugin}s of a particular type. The * {@code SingletonService} creates and maintain a list of singleton instances. @@ -52,6 +54,9 @@ public interface SingletonService extends PTService { + /** Gets the {@link ObjectService} upon which this service depends. */ + ObjectService objectService(); + /** * Gets the list of plugin instances. There will be one singleton instance for * each available plugin. From 78f12f37507e26297432cd82f5111cf254068679 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 15 Aug 2016 08:38:04 -0500 Subject: [PATCH 0284/1208] Push default SingletonService behavior to iface Thanks, Java 8. --- .../plugin/AbstractSingletonService.java | 37 ------------------- .../org/scijava/plugin/SingletonService.java | 35 ++++++++++++++++++ 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/main/java/org/scijava/plugin/AbstractSingletonService.java b/src/main/java/org/scijava/plugin/AbstractSingletonService.java index d7d793a8f..14b2eeab4 100644 --- a/src/main/java/org/scijava/plugin/AbstractSingletonService.java +++ b/src/main/java/org/scijava/plugin/AbstractSingletonService.java @@ -31,14 +31,12 @@ package org.scijava.plugin; -import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.scijava.log.LogService; -import org.scijava.object.LazyObjects; import org.scijava.object.ObjectService; /** @@ -85,41 +83,6 @@ public

    P getInstance(final Class

    pluginClass) { return (P) instanceMap.get(pluginClass); } - // -- PTService methods -- - - @Override - public

    P create(final Class

    pluginClass) { - throw new UnsupportedOperationException( - "Cannot create singleton plugin instance. " - + "Use getInstance(Class) instead."); - } - - // -- Service methods -- - - @Override - public void initialize() { - // add singleton instances to the object index... IN THE FUTURE! - objectService.getIndex().addLater(new LazyObjects() { - - @Override - public ArrayList get() { - return new ArrayList<>(getInstances()); - } - }); - } - - // -- Internal methods -- - - /** - * Allows subclasses to exclude instances. - * - * @param list the initial list of instances - * @return the filtered list of instances - */ - protected List filterInstances(final List list) { - return list; - } - // -- Helper methods -- private synchronized void initInstances() { diff --git a/src/main/java/org/scijava/plugin/SingletonService.java b/src/main/java/org/scijava/plugin/SingletonService.java index 0efbae764..e2f0d06d2 100644 --- a/src/main/java/org/scijava/plugin/SingletonService.java +++ b/src/main/java/org/scijava/plugin/SingletonService.java @@ -31,8 +31,10 @@ package org.scijava.plugin; +import java.util.ArrayList; import java.util.List; +import org.scijava.object.LazyObjects; import org.scijava.object.ObjectService; /** @@ -66,4 +68,37 @@ public interface SingletonService extends /** Gets the singleton plugin instance of the given class. */

    P getInstance(Class

    pluginClass); + /** + * Filters the given list of instances by this service's inclusion criteria. + * + * @param list the initial list of instances + * @return the filtered list of instances + */ + default List filterInstances(final List list) { + return list; + } + + // -- PTService methods -- + + @Override + default

    P create(final Class

    pluginClass) { + throw new UnsupportedOperationException( + "Cannot create singleton plugin instance. " + + "Use getInstance(Class) instead."); + } + + // -- Service methods -- + + @Override + default void initialize() { + // add singleton instances to the object index... IN THE FUTURE! + objectService().getIndex().addLater(new LazyObjects() { + + @Override + public ArrayList get() { + return new ArrayList<>(getInstances()); + } + }); + } + } From ab3f350597c87ba9b9024058fafbf9263044d2e2 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 15 Aug 2016 08:42:10 -0500 Subject: [PATCH 0285/1208] AbstractPTService: use accessor method, not field This will allow us to push the behavior into the interface momentarily. --- src/main/java/org/scijava/plugin/AbstractPTService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/plugin/AbstractPTService.java b/src/main/java/org/scijava/plugin/AbstractPTService.java index 35cb019ca..9e00e481f 100644 --- a/src/main/java/org/scijava/plugin/AbstractPTService.java +++ b/src/main/java/org/scijava/plugin/AbstractPTService.java @@ -57,15 +57,15 @@ public PluginService pluginService() { @Override public List> getPlugins() { - return pluginService.getPluginsOfType(getPluginType()); + return pluginService().getPluginsOfType(getPluginType()); } @Override public

    P create(final Class

    pluginClass) { final PluginInfo info = - pluginService.getPlugin(pluginClass, getPluginType()); + pluginService().getPlugin(pluginClass, getPluginType()); @SuppressWarnings("unchecked") - final P plugin = (P) pluginService.createInstance(info); + final P plugin = (P) pluginService().createInstance(info); return plugin; } From c7e578e89b453f5a232b5092ec104a43dfd926e9 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 15 Aug 2016 08:55:07 -0500 Subject: [PATCH 0286/1208] Push default PTService behavior to iface Thanks, Java 8. --- .../org/scijava/plugin/AbstractPTService.java | 17 ----------------- src/main/java/org/scijava/plugin/PTService.java | 12 ++++++++++-- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/scijava/plugin/AbstractPTService.java b/src/main/java/org/scijava/plugin/AbstractPTService.java index 9e00e481f..201f06738 100644 --- a/src/main/java/org/scijava/plugin/AbstractPTService.java +++ b/src/main/java/org/scijava/plugin/AbstractPTService.java @@ -31,8 +31,6 @@ package org.scijava.plugin; -import java.util.List; - import org.scijava.service.AbstractService; /** @@ -54,19 +52,4 @@ public abstract class AbstractPTService extends public PluginService pluginService() { return pluginService; } - - @Override - public List> getPlugins() { - return pluginService().getPluginsOfType(getPluginType()); - } - - @Override - public

    P create(final Class

    pluginClass) { - final PluginInfo info = - pluginService().getPlugin(pluginClass, getPluginType()); - @SuppressWarnings("unchecked") - final P plugin = (P) pluginService().createInstance(info); - return plugin; - } - } diff --git a/src/main/java/org/scijava/plugin/PTService.java b/src/main/java/org/scijava/plugin/PTService.java index ed7249c3d..7239493de 100644 --- a/src/main/java/org/scijava/plugin/PTService.java +++ b/src/main/java/org/scijava/plugin/PTService.java @@ -90,13 +90,21 @@ public interface PTService extends Service { PluginService pluginService(); /** Gets the plugins managed by this service. */ - List> getPlugins(); + default List> getPlugins() { + return pluginService().getPluginsOfType(getPluginType()); + } /** Gets the type of plugins managed by this service. */ Class getPluginType(); /** Creates an instance of the given plugin class. */ -

    P create(final Class

    pluginClass); + default

    P create(final Class

    pluginClass) { + final PluginInfo info = + pluginService().getPlugin(pluginClass, getPluginType()); + @SuppressWarnings("unchecked") + final P plugin = (P) pluginService().createInstance(info); + return plugin; + } // -- Deprecated methods -- From b11491de4117e7f7ceeccc190283ed1b6ab5cd39 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 15 Aug 2016 08:55:26 -0500 Subject: [PATCH 0287/1208] PTService: put unimplemented methods first --- src/main/java/org/scijava/plugin/PTService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/plugin/PTService.java b/src/main/java/org/scijava/plugin/PTService.java index 7239493de..3b2e3435c 100644 --- a/src/main/java/org/scijava/plugin/PTService.java +++ b/src/main/java/org/scijava/plugin/PTService.java @@ -89,14 +89,14 @@ public interface PTService extends Service { */ PluginService pluginService(); + /** Gets the type of plugins managed by this service. */ + Class getPluginType(); + /** Gets the plugins managed by this service. */ default List> getPlugins() { return pluginService().getPluginsOfType(getPluginType()); } - /** Gets the type of plugins managed by this service. */ - Class getPluginType(); - /** Creates an instance of the given plugin class. */ default

    P create(final Class

    pluginClass) { final PluginInfo info = From f208fed6d1d58d4f8de76009b098f17c982f97b0 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 15 Aug 2016 10:46:23 -0500 Subject: [PATCH 0288/1208] Add a common interface for objects that do logging --- src/main/java/org/scijava/log/Logged.java | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/java/org/scijava/log/Logged.java diff --git a/src/main/java/org/scijava/log/Logged.java b/src/main/java/org/scijava/log/Logged.java new file mode 100644 index 000000000..54707a4e3 --- /dev/null +++ b/src/main/java/org/scijava/log/Logged.java @@ -0,0 +1,43 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.log; + +/** + * Interface for the objects which want to log their activities. + * + * @author Curtis Rueden + */ +public interface Logged { + + /** Gets the {@link LogService} to use when logging activities. */ + LogService log(); +} From 23aada3eec762cb72eb40365c54b2377e4086b59 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 15 Aug 2016 10:54:32 -0500 Subject: [PATCH 0289/1208] Implement the Logged interface as appropriate --- src/main/java/org/scijava/Gateway.java | 1 + .../org/scijava/command/InteractiveCommand.java | 14 +++++++++----- src/main/java/org/scijava/plugin/RichPlugin.java | 10 +++++++++- .../org/scijava/script/AbstractScriptEngine.java | 4 +++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/scijava/Gateway.java b/src/main/java/org/scijava/Gateway.java index 50eaaf9be..052f9d54e 100644 --- a/src/main/java/org/scijava/Gateway.java +++ b/src/main/java/org/scijava/Gateway.java @@ -244,6 +244,7 @@ public interface Gateway extends RichPlugin { * * @return The {@link LogService} of this application context. */ + @Override LogService log(); /** diff --git a/src/main/java/org/scijava/command/InteractiveCommand.java b/src/main/java/org/scijava/command/InteractiveCommand.java index a1b465ab7..c080ce0fa 100644 --- a/src/main/java/org/scijava/command/InteractiveCommand.java +++ b/src/main/java/org/scijava/command/InteractiveCommand.java @@ -37,6 +37,7 @@ import org.scijava.event.EventHandler; import org.scijava.event.EventService; import org.scijava.log.LogService; +import org.scijava.log.Logged; import org.scijava.module.MethodCallException; import org.scijava.module.ModuleItem; import org.scijava.plugin.Parameter; @@ -60,7 +61,7 @@ * @author Curtis Rueden */ public abstract class InteractiveCommand extends DynamicCommand implements - Interactive, Previewable + Interactive, Previewable, Logged { @Parameter @@ -102,6 +103,13 @@ public void cancel() { // That is, closing the non-modal dialog does nothing. } + // -- Logged methods -- + + @Override + public LogService log() { + return log; + } + // -- Internal methods -- protected void updateInput(final ModuleItem item) { @@ -137,10 +145,6 @@ protected void update(final ModuleItem item, final T newValue) { } } - protected LogService log() { - return log; - } - // -- Event handlers -- @EventHandler diff --git a/src/main/java/org/scijava/plugin/RichPlugin.java b/src/main/java/org/scijava/plugin/RichPlugin.java index faec2240c..a1a37dd42 100644 --- a/src/main/java/org/scijava/plugin/RichPlugin.java +++ b/src/main/java/org/scijava/plugin/RichPlugin.java @@ -36,6 +36,8 @@ import org.scijava.Locatable; import org.scijava.Prioritized; import org.scijava.Versioned; +import org.scijava.log.LogService; +import org.scijava.log.Logged; /** * Base interface for {@link Contextual}, {@link Prioritized} plugins that @@ -46,7 +48,7 @@ * @author Curtis Rueden */ public interface RichPlugin extends SciJavaPlugin, Contextual, Prioritized, - HasPluginInfo, Identifiable, Locatable, Versioned + HasPluginInfo, Logged, Identifiable, Locatable, Versioned { // -- Identifiable methods -- @@ -56,4 +58,10 @@ default String getIdentifier() { return "plugin:" + getClass().getName(); } + // -- Logged methods -- + + @Override + default LogService log() { + return context().getService(LogService.class); + } } diff --git a/src/main/java/org/scijava/script/AbstractScriptEngine.java b/src/main/java/org/scijava/script/AbstractScriptEngine.java index 46382835d..61ff5a4d8 100644 --- a/src/main/java/org/scijava/script/AbstractScriptEngine.java +++ b/src/main/java/org/scijava/script/AbstractScriptEngine.java @@ -40,6 +40,7 @@ import javax.script.ScriptException; import org.scijava.log.LogService; +import org.scijava.log.Logged; import org.scijava.log.StderrLogService; /** @@ -48,7 +49,7 @@ * * @author Johannes Schindelin */ -public abstract class AbstractScriptEngine implements ScriptEngine { +public abstract class AbstractScriptEngine implements ScriptEngine, Logged { // Abstract methods @@ -68,6 +69,7 @@ public abstract class AbstractScriptEngine implements ScriptEngine { // log service + @Override public synchronized LogService log() { if (log == null) { log = new StderrLogService(); From 2c50d024bba04818fe3bec973cae687f4011ec0f Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 17 Aug 2016 13:55:42 -0500 Subject: [PATCH 0290/1208] TypedService: add a way to find the best plugin --- .../java/org/scijava/plugin/TypedService.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/plugin/TypedService.java b/src/main/java/org/scijava/plugin/TypedService.java index 86983ddbf..ff118ea0c 100644 --- a/src/main/java/org/scijava/plugin/TypedService.java +++ b/src/main/java/org/scijava/plugin/TypedService.java @@ -52,5 +52,24 @@ public interface TypedService> extends PTService, Typed

    { - // NB: Marker interface. + + /** + * Gets a new instance of the highest priority plugin managed by this service + * which supports the given data object according to the {@link Typed} + * interface. + *

    + * Note that this newly created plugin instance will not actually be + * injected with the given data object! + *

    + * + * @see HandlerService#getHandler(Object) + * @see WrapperService#create(Object) + */ + default PT find(final DT data) { + for (final PluginInfo plugin : getPlugins()) { + final PT instance = pluginService().createInstance(plugin); + if (instance != null && instance.supports(data)) return instance; + } + return null; + } } From 54e4fb39df8a3754fd3cec436a831967abf760ca Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 17 Aug 2016 15:21:38 -0500 Subject: [PATCH 0291/1208] Push default WrapperService behavior to iface Thanks, Java 8. --- .../plugin/AbstractWrapperService.java | 43 +------------------ .../org/scijava/plugin/WrapperService.java | 22 +++++++++- 2 files changed, 22 insertions(+), 43 deletions(-) diff --git a/src/main/java/org/scijava/plugin/AbstractWrapperService.java b/src/main/java/org/scijava/plugin/AbstractWrapperService.java index a4f2e5959..ab5cf266a 100644 --- a/src/main/java/org/scijava/plugin/AbstractWrapperService.java +++ b/src/main/java/org/scijava/plugin/AbstractWrapperService.java @@ -31,8 +31,6 @@ package org.scijava.plugin; -import org.scijava.log.LogService; - /** * Abstract base class for {@link WrapperService}s. * @@ -43,44 +41,5 @@ public abstract class AbstractWrapperService> extends AbstractTypedService implements WrapperService { - - @Parameter(required = false) - private LogService log; - - // -- WrapperService methods -- - - @Override - public PT create(final D data) { - final PT instance = findWrapper(data); - if (instance != null) instance.set(data); - return instance; - } - - // -- Service methods -- - - @Override - public void initialize() { - if (log != null) { - log.debug("Found " + getPlugins().size() + " " + - getPluginType().getSimpleName() + " plugins."); - } - } - - // -- Typed methods -- - - @Override - public boolean supports(final DT data) { - return findWrapper(data) != null; - } - - // -- Helper methods -- - - private PT findWrapper(final D data) { - for (final PluginInfo plugin : getPlugins()) { - final PT instance = pluginService().createInstance(plugin); - if (instance != null && instance.supports(data)) return instance; - } - return null; - } - + // NB: No implementation needed. } diff --git a/src/main/java/org/scijava/plugin/WrapperService.java b/src/main/java/org/scijava/plugin/WrapperService.java index 0664c95a8..d174ca149 100644 --- a/src/main/java/org/scijava/plugin/WrapperService.java +++ b/src/main/java/org/scijava/plugin/WrapperService.java @@ -62,6 +62,26 @@ public interface WrapperService> extends * @return An appropriate plugin instance, or null if the data is not * compatible with any available plugin. */ - PT create(D data); + default PT create(final D data) { + final PT instance = find(data); + if (instance != null) instance.set(data); + return instance; + } + // -- Service methods -- + + @Override + default void initialize() { + if (log() != null) { + log().debug("Found " + getPlugins().size() + " " + + getPluginType().getSimpleName() + " plugins."); + } + } + + // -- Typed methods -- + + @Override + default boolean supports(final DT data) { + return find(data) != null; + } } From 132157b36b58f173c6daa6dde0c95510b4345f13 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 17 Aug 2016 15:22:44 -0500 Subject: [PATCH 0292/1208] Push default TypedPlugin behavior to iface Thanks, Java 8. --- src/main/java/org/scijava/Typed.java | 4 +++- .../java/org/scijava/plugin/AbstractTypedPlugin.java | 9 +-------- src/main/java/org/scijava/ui/dnd/DragAndDropHandler.java | 4 +++- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/scijava/Typed.java b/src/main/java/org/scijava/Typed.java index be50d652d..20d877557 100644 --- a/src/main/java/org/scijava/Typed.java +++ b/src/main/java/org/scijava/Typed.java @@ -47,7 +47,9 @@ public interface Typed { * requirements beyond class assignability. *

    */ - boolean supports(T data); + default boolean supports(@SuppressWarnings("unused") T data) { + return true; + } /** Gets the type associated with the object. */ Class getType(); diff --git a/src/main/java/org/scijava/plugin/AbstractTypedPlugin.java b/src/main/java/org/scijava/plugin/AbstractTypedPlugin.java index cda3c8e3b..9493deced 100644 --- a/src/main/java/org/scijava/plugin/AbstractTypedPlugin.java +++ b/src/main/java/org/scijava/plugin/AbstractTypedPlugin.java @@ -43,12 +43,5 @@ public abstract class AbstractTypedPlugin extends AbstractRichPlugin implements TypedPlugin { - - // -- Typed methods -- - - @Override - public boolean supports(final D data) { - return true; - } - + // NB: No implementation needed. } diff --git a/src/main/java/org/scijava/ui/dnd/DragAndDropHandler.java b/src/main/java/org/scijava/ui/dnd/DragAndDropHandler.java index 3fbf71803..d02c25e44 100644 --- a/src/main/java/org/scijava/ui/dnd/DragAndDropHandler.java +++ b/src/main/java/org/scijava/ui/dnd/DragAndDropHandler.java @@ -143,6 +143,8 @@ public interface DragAndDropHandler extends HandlerPlugin { * compatible display. */ @Override - boolean supports(final D dataObject); + default boolean supports(final D dataObject) { + return true; + } } From 3b6e3a0d84c87464c9a429aa949aaa25ab49b761 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 22 Aug 2016 14:31:00 -0500 Subject: [PATCH 0293/1208] ScriptInfo: use try-with-resources block --- src/main/java/org/scijava/script/ScriptInfo.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index e7e74c2ec..3b82405c1 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -231,14 +231,9 @@ public void parseParameters() { clearParameters(); appendReturnValue = true; - try { - final BufferedReader in; - if (script == null) { - in = new BufferedReader(new FileReader(getPath())); - } - else { - in = getReader(); - } + try (final BufferedReader in = script == null ? // + new BufferedReader(new FileReader(getPath())) : getReader()) // + { while (true) { final String line = in.readLine(); if (line == null) break; @@ -252,7 +247,6 @@ public void parseParameters() { } else if (line.matches(".*\\w.*")) break; } - in.close(); if (appendReturnValue) addReturnValue(); } From 2757138268d44b43bf7dc10cae669b4ee234dacd Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 22 Aug 2016 14:46:24 -0500 Subject: [PATCH 0294/1208] ScriptInfo: fix warning about field shadowing --- src/main/java/org/scijava/script/ScriptInfo.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index 3b82405c1..d89917930 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -136,16 +136,16 @@ public ScriptInfo(final Context context, final String path, setContext(context); this.path = path; - String script = null; + String contents = null; if (reader != null) { try { - script = getReaderContentsAsString(reader); + contents = getReaderContentsAsString(reader); } catch (final IOException exc) { log.error("Error reading script: " + path, exc); } } - this.script = script; + script = contents; } // -- ScriptInfo methods -- From 01fc1ffd213f55949f3a3e29783e4956ad3f7d4a Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 22 Aug 2016 14:58:44 -0500 Subject: [PATCH 0295/1208] ParseService: add a non-strict parsing mode This is based off of the new non-strict evaluation mode of SJEP. But the API does not explicitly guarantee exactly what "non-strict" means at this layer. We just want to make a best effort. --- pom.xml | 1 + .../org/scijava/parse/DefaultParseService.java | 14 ++++++++++---- src/main/java/org/scijava/parse/ParseService.java | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 6abefec34..f6c8e7a27 100644 --- a/pom.xml +++ b/pom.xml @@ -106,6 +106,7 @@ org.scijava scijava-expression-parser + 3.1.0 diff --git a/src/main/java/org/scijava/parse/DefaultParseService.java b/src/main/java/org/scijava/parse/DefaultParseService.java index 8142ae59c..84db28d9b 100644 --- a/src/main/java/org/scijava/parse/DefaultParseService.java +++ b/src/main/java/org/scijava/parse/DefaultParseService.java @@ -55,7 +55,12 @@ public class DefaultParseService extends AbstractService implements @Override public Items parse(final String arg) { - return new ItemsList(arg); + return parse(arg, true); + } + + @Override + public Items parse(final String arg, final boolean strict) { + return new ItemsList(arg, strict); } // -- Helper classes -- @@ -67,9 +72,9 @@ public Items parse(final String arg) { */ private static class ItemsList extends ObjectArray implements Items { - public ItemsList(final String arg) { + public ItemsList(final String arg, final boolean strict) { super(Item.class); - parseItems(arg); + parseItems(arg, strict); } @Override @@ -98,8 +103,9 @@ public boolean isList() { return true; } - private void parseItems(final String arg) { + private void parseItems(final String arg, final boolean strict) { final DefaultEvaluator e = new DefaultEvaluator(); + e.setStrict(strict); final Object result = e.evaluate("(" + arg + ")"); if (result == null) { throw new IllegalStateException("Error parsing string: '" + arg + "'"); diff --git a/src/main/java/org/scijava/parse/ParseService.java b/src/main/java/org/scijava/parse/ParseService.java index 31e63d5c6..102719442 100644 --- a/src/main/java/org/scijava/parse/ParseService.java +++ b/src/main/java/org/scijava/parse/ParseService.java @@ -54,4 +54,19 @@ public interface ParseService extends SciJavaService { */ Items parse(String arg); + /** + * Parses a comma-delimited list of data elements. + *

    + * Some data elements might be {@code key=value} pairs, while others might be + * raw values (i.e., no equals sign). + *

    + * + * @param arg The string to parse. + * @param strict Whether to fail fast when encountering an unassigned variable + * token. + * @return A parsed list of {@link Item}s. + * @throws IllegalArgumentException If the string does not conform to expected + * syntax. + */ + Items parse(String arg, boolean strict); } From b700de66e226af61ef8f9c2ce7214dfd32d831ab Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 22 Aug 2016 15:00:26 -0500 Subject: [PATCH 0296/1208] ScriptInfo: parse attributes in non-strict mode This gets us one step closer to supporting things like: // @String(visibility=MESSAGE) text --- src/main/java/org/scijava/script/ScriptInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index d89917930..08bec72dc 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -378,7 +378,7 @@ private void parseParam(final String param, /** Parses a comma-delimited list of {@code key=value} pairs into a map. */ private Map parseAttrs(final String attrs) { - return parser.parse(attrs).asMap(); + return parser.parse(attrs, false).asMap(); } private boolean isIOType(final String token) { From c677ea109cf81cc653de7c12c788474a282b1c1e Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 22 Aug 2016 15:01:15 -0500 Subject: [PATCH 0297/1208] ScriptInfo: try harder when converting types If we cannot convert directly from source to target type, try converting through String before giving up. With this change, the following now works as desired: // @String(visibility=MESSAGE) text The reason this change fixes the above is that the expression "visibility=MESSAGE" evaluates to the map: visibility -> new org.scijava.sjep.eval.Unresolved("MESSAGE") That is, the variable "visibility" contains an object of type org.scijava.sjep.eval.Unresolved, with a token value of "MESSAGE". We cannot convert from an org.scijava.sjep.eval.Unresolved to an org.scijava.ItemVisibility, but we _can_ convert from Unresolved to String (the toString() method is called, resulting in "MESSAGE"), followed by String to ItemVisibility (the string value is considered to be naming one of the enumeration's values). This heuristic avoids an explicit assumption in the scripting framework of the ParseService being backed by SJEP (it might not be -- someone might be using their own higher priority ParseService). --- src/main/java/org/scijava/script/ScriptInfo.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index 08bec72dc..10c4dd07d 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -450,7 +450,13 @@ private boolean is(final String key, final String desired) { /** Super terse conversion helper method. */ private T as(final Object v, final Class type) { - return convertService.convert(v, type); + final T converted = convertService.convert(v, type); + if (converted != null) return converted; + // NB: Attempt to convert via string. + // This is useful in cases where a weird type of object came back + // (e.g., org.scijava.sjep.eval.Unresolved), but which happens to have a + // nice string representation which ultimately is expressible as the type. + return convertService.convert(v.toString(), type); } private List asList(final Object v, final Class type) { From 632d975ae50ea897efec3d2b53e21f267a244f26 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 22 Aug 2016 15:06:37 -0500 Subject: [PATCH 0298/1208] ScriptInfoTest: test that enums are now evaluated As discussed in the previous commit, the following now works: // @String(visibility=MESSAGE) text --- src/test/java/org/scijava/script/ScriptInfoTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/scijava/script/ScriptInfoTest.java b/src/test/java/org/scijava/script/ScriptInfoTest.java index 37b85214c..eb384c03a 100644 --- a/src/test/java/org/scijava/script/ScriptInfoTest.java +++ b/src/test/java/org/scijava/script/ScriptInfoTest.java @@ -58,6 +58,7 @@ import org.junit.Test; import org.scijava.Context; import org.scijava.ItemIO; +import org.scijava.ItemVisibility; import org.scijava.log.LogService; import org.scijava.module.ModuleItem; import org.scijava.plugin.Plugin; @@ -181,6 +182,7 @@ public void testParameters() { "stepSize=3, value=11, style=\"slider\") sliderValue\n" + // "% @String(persist = false, family='Carnivora', " + // "choices={'quick brown fox', 'lazy dog'}) animal\n" + // + "% @String(visibility=MESSAGE) msg\n" + // "% @BOTH java.lang.StringBuilder buffer"; final ScriptInfo info = @@ -203,12 +205,15 @@ public void testParameters() { null, null, null, null, null, null, null, null, animalChoices, animal); assertEquals(animal.get("family"), "Carnivora"); // test custom attribute + final ModuleItem msg = info.getInput("msg"); + assertSame(ItemVisibility.MESSAGE, msg.getVisibility()); + final ModuleItem buffer = info.getOutput("buffer"); assertItem("buffer", StringBuilder.class, null, ItemIO.BOTH, true, true, null, null, null, null, null, null, null, null, noChoices, buffer); int inputCount = 0; - final ModuleItem[] inputs = { log, sliderValue, animal, buffer }; + final ModuleItem[] inputs = { log, sliderValue, animal, msg, buffer }; for (final ModuleItem inItem : info.inputs()) { assertSame(inputs[inputCount++], inItem); } From 58f37727d4aed3aa0d74b495c162833be913e07f Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 22 Aug 2016 17:03:23 -0500 Subject: [PATCH 0299/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f6c8e7a27..82a9a3b32 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.57.1-SNAPSHOT + 2.58.1-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From 4aa8556da5071f4ab93fad74586798cc2313292f Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 22 Aug 2016 21:53:37 -0500 Subject: [PATCH 0300/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 82a9a3b32..e4e4b2a7d 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.58.1-SNAPSHOT + 2.58.2-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From ece9a5ceee43ca816550e82d48221587b607fff7 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 25 Aug 2016 12:08:35 -0500 Subject: [PATCH 0301/1208] DefaultScriptService: also alias java.util.Date This was an oversight, since this type is on the same level as java.io.File and org.scijava.util.ColorRGB(A). See: http://forum.imagej.net/t/parameter-date-in-imagej-macro/2577 --- src/main/java/org/scijava/script/DefaultScriptService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index be695cb89..1d228997a 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -39,6 +39,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -416,7 +417,7 @@ private synchronized void initAliasMap() { // built-in types addAliases(map, Context.class, BigDecimal.class, BigInteger.class, - ColorRGB.class, ColorRGBA.class, File.class, String.class); + ColorRGB.class, ColorRGBA.class, Date.class, File.class, String.class); // gateway types final List> gatewayPlugins = From 66f6eee89d458031bfbff1ee579937c76289b340 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 25 Aug 2016 12:13:05 -0500 Subject: [PATCH 0302/1208] ScriptServiceTest: add a test for built-in aliases --- .../org/scijava/script/ScriptServiceTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/test/java/org/scijava/script/ScriptServiceTest.java b/src/test/java/org/scijava/script/ScriptServiceTest.java index a7c5a075a..ec40e4790 100644 --- a/src/test/java/org/scijava/script/ScriptServiceTest.java +++ b/src/test/java/org/scijava/script/ScriptServiceTest.java @@ -35,6 +35,9 @@ import static org.junit.Assert.assertSame; import java.io.File; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Date; import java.util.List; import javax.script.ScriptException; @@ -42,6 +45,8 @@ import org.junit.Test; import org.scijava.Context; import org.scijava.util.AppUtils; +import org.scijava.util.ColorRGB; +import org.scijava.util.ColorRGBA; /** * Tests the {@link DefaultScriptService}. @@ -75,6 +80,26 @@ public void testSystemProperty() { assertEquals(dir2, scriptDirs.get(2).getAbsolutePath()); } + @Test + public void testBuiltInAliases() throws ScriptException { + final Context ctx = new Context(ScriptService.class); + final ScriptService ss = ctx.service(ScriptService.class); + + final Class[] builtIns = { boolean.class, byte.class, char.class, + double.class, float.class, int.class, long.class, short.class, + Boolean.class, Byte.class, Character.class, Double.class, Float.class, + Integer.class, Long.class, Short.class, Context.class, BigDecimal.class, + BigInteger.class, ColorRGB.class, ColorRGBA.class, Date.class, File.class, + String.class }; + + for (final Class builtIn : builtIns) { + final Class c = ss.lookupClass(builtIn.getSimpleName()); + assertSame(builtIn, c); + } + + ctx.dispose(); + } + @Test public void testArrayAliases() throws ScriptException { final Context ctx = new Context(ScriptService.class); From f990ad54597f9895f3443a942c6b685c330e7c46 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 25 Aug 2016 12:53:51 -0500 Subject: [PATCH 0303/1208] Fix race condition in alias initialization The ServicesLoadedEvent fires asynchronously. Hence, it was possible that the service aliases did not get added in time for subsequent alias lookups. This was most likely in the unit tests, where a context is spun up and then immediately queried for aliases, before things had time to settle. Of course, it was totally bogus to initialize the service classes this way. We now employ a better, more consistent solution: rather than querying the ServiceIndex, we ask the PluginIndex for all PluginInfo objects and load their classes. This is fine because we do not need actual Service instances to exist yet -- we only need the Class objects to create the aliases. This fixes a long-standing race condition which caused the SciJava Common Jenkins build to occasionally fail. --- .../scijava/script/DefaultScriptService.java | 76 +++++++++---------- 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index 1d228997a..9f3410734 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -54,7 +54,6 @@ import org.scijava.Priority; import org.scijava.app.AppService; import org.scijava.command.CommandService; -import org.scijava.event.EventHandler; import org.scijava.log.LogService; import org.scijava.module.Module; import org.scijava.module.ModuleService; @@ -63,10 +62,9 @@ import org.scijava.plugin.AbstractSingletonService; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; -import org.scijava.plugin.PluginInfo; import org.scijava.plugin.PluginService; +import org.scijava.plugin.SciJavaPlugin; import org.scijava.service.Service; -import org.scijava.service.event.ServicesLoadedEvent; import org.scijava.util.ClassUtils; import org.scijava.util.ColorRGB; import org.scijava.util.ColorRGBA; @@ -300,18 +298,6 @@ public Collection get() { }); } - // -- Event handlers -- - - @EventHandler - private void - onEvent(@SuppressWarnings("unused") final ServicesLoadedEvent evt) - { - // NB: Add service type aliases after all services have joined the context. - for (final Service service : getContext().getServiceIndex()) { - addAliases(aliasMap(), service.getClass()); - } - } - // -- Helper methods - lazy initialization -- /** Gets {@link #scriptLanguageIndex}, initializing if needed. */ @@ -419,21 +405,34 @@ private synchronized void initAliasMap() { addAliases(map, Context.class, BigDecimal.class, BigInteger.class, ColorRGB.class, ColorRGBA.class, Date.class, File.class, String.class); + // service types + addAliases(map, pluginClasses(Service.class)); + // gateway types - final List> gatewayPlugins = - pluginService.getPluginsOfType(Gateway.class); - for (final PluginInfo info : gatewayPlugins) { - try { - addAliases(map, info.loadClass()); - } - catch (final InstantiableException exc) { - log.warn("Ignoring invalid gateway: " + info.getClassName(), exc); - } - } + addAliases(map, pluginClasses(Gateway.class)); aliasMap = map; } + // -- Helper methods - run -- + + /** + * Gets a {@link ScriptInfo} for the given file, creating a new one if none + * are registered with the service. + */ + private ScriptInfo getOrCreate(final File file) { + final ScriptInfo info = scripts().get(file); + if (info != null) return info; + return new ScriptInfo(getContext(), file); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private Future cast(final Future future) { + return (Future) future; + } + + // -- Helper methods - aliases -- + private void addAliases(final HashMap> map, final Class... types) { @@ -452,25 +451,18 @@ private void addAliases(final HashMap> map, addAliases(map, type.getInterfaces()); } - // -- Helper methods - run -- - - /** - * Gets a {@link ScriptInfo} for the given file, creating a new one if none - * are registered with the service. - */ - private ScriptInfo getOrCreate(final File file) { - final ScriptInfo info = scripts().get(file); - if (info != null) return info; - return new ScriptInfo(getContext(), file); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - private Future cast(final Future future) { - return (Future) future; + private Class[] pluginClasses(final Class type) { + return pluginService.getPluginsOfType(type).stream().map(info -> { + try { + return info.loadClass(); + } + catch (final InstantiableException exc) { + log.warn("Invalid class: " + info.getClassName(), exc); + return null; + } + }).toArray(Class[]::new); } - // -- Helper methods - aliases -- - private String stripArrayNotation(final String alias) { if (!alias.endsWith("[]")) return alias; return stripArrayNotation(alias.substring(0, alias.length() - 2)); From fd0a289d21a913c4fc941cbd4c151f4aa34deccf Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 25 Aug 2016 16:11:04 -0500 Subject: [PATCH 0304/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e4e4b2a7d..b72d8a983 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.58.2-SNAPSHOT + 2.58.3-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From 2cb16a62fbdda8941c13b32958115192396c521a Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 26 Aug 2016 03:09:49 -0500 Subject: [PATCH 0305/1208] Add default behavior for service accessors It is easy and reasonable to fall back to asking the context directly for the service. However, there is a downside: services which do not override these methods to return their injected field values may have subtle bugs relating to service dependencies and initialization order. For example, InputService has a method EventService, which is intended to never return null. In other words: it is intended that InputService implementations (at least by default) _depend_ on the EventService. If you write: Context ctx = new Context(InputService.class); When DefaultInputService is on the classpath, it will be instantiated, its @Parameter EventService field will be noted, and the highest-priority concrete EventService implementation (i.e., DefaultEventService) will then be recursively instantiated and initialized, and so forth. So you will end up with a Context containing a DefaultInputService _and_ all of its service dependencies. But if DefaultInputService neglects to declare an @Parameter EventService, the way the service loader is coded right now, the EventService dependency will not be noticed, and the Context will contain only a DefaultInputService, whose eventService() method will return null, resulting in NPE when calling other methods which use it. There is one vital reason to define these default method behaviors anyway, though: to avoid breaking SPI compatibility with downstream components. For example, the net.imagej:imagej-legacy component implements a LegacyConsoleService (ConsoleService is a SingletonService), which was forced to implement the new objectService() method when upgrading its version of scijava-common. Unfortunately, the ImageJ Updater (net.imagej:imagej-updater) has a serious design flaw whereby it updates itself and its dependencies (including scijava-common) first, without updating any downstream libraries (e.g., imagej-legacy). So we end up with a situation where scijava-common is at 2.58.2, after the addition of the newly required objectService() method, while imagej-legacy remains at its old version which does not implement that method. And the Context fails to spin up. Adding these default method behaviors is a simple way around the issue. We should consider whether to remove these default implementations in SJC3. And we should definitely consider how best to fix SciJava Common so that downstream JAR skew cannot taint the Context startup so easily. But for now, it is safest to provide these methods, in case of JAR skew. --- .../java/org/scijava/command/CommandService.java | 8 ++++++-- .../java/org/scijava/display/DisplayService.java | 12 +++++++++--- src/main/java/org/scijava/input/InputService.java | 4 +++- src/main/java/org/scijava/object/ObjectService.java | 4 +++- .../java/org/scijava/platform/PlatformService.java | 8 ++++++-- src/main/java/org/scijava/plugin/PTService.java | 4 +++- .../java/org/scijava/plugin/SingletonService.java | 4 +++- 7 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/scijava/command/CommandService.java b/src/main/java/org/scijava/command/CommandService.java index 3f0e0da8e..3d0a4f80a 100644 --- a/src/main/java/org/scijava/command/CommandService.java +++ b/src/main/java/org/scijava/command/CommandService.java @@ -64,9 +64,13 @@ */ public interface CommandService extends PTService, SciJavaService { - EventService eventService(); + default EventService eventService() { + return context().getService(EventService.class); + } - ModuleService moduleService(); + default ModuleService moduleService() { + return context().getService(ModuleService.class); + } /** Gets the list of all available {@link Command}s). */ List getCommands(); diff --git a/src/main/java/org/scijava/display/DisplayService.java b/src/main/java/org/scijava/display/DisplayService.java index 204de8f74..92bb6e725 100644 --- a/src/main/java/org/scijava/display/DisplayService.java +++ b/src/main/java/org/scijava/display/DisplayService.java @@ -50,11 +50,17 @@ */ public interface DisplayService extends SciJavaService { - EventService eventService(); + default EventService eventService() { + return context().getService(EventService.class); + } - ObjectService objectService(); + default ObjectService objectService() { + return context().getService(ObjectService.class); + } - PluginService pluginService(); + default PluginService pluginService() { + return context().getService(PluginService.class); + } /** Gets the currently active display (of any Display type). */ Display getActiveDisplay(); diff --git a/src/main/java/org/scijava/input/InputService.java b/src/main/java/org/scijava/input/InputService.java index b4ecdd249..261aab401 100644 --- a/src/main/java/org/scijava/input/InputService.java +++ b/src/main/java/org/scijava/input/InputService.java @@ -45,7 +45,9 @@ */ public interface InputService extends SciJavaService { - EventService eventService(); + default EventService eventService() { + return context().getService(EventService.class); + } InputModifiers getModifiers(); diff --git a/src/main/java/org/scijava/object/ObjectService.java b/src/main/java/org/scijava/object/ObjectService.java index a3b880997..ef5ce9692 100644 --- a/src/main/java/org/scijava/object/ObjectService.java +++ b/src/main/java/org/scijava/object/ObjectService.java @@ -43,7 +43,9 @@ */ public interface ObjectService extends SciJavaService { - EventService eventService(); + default EventService eventService() { + return context().getService(EventService.class); + } /** Gets the index of available objects. */ ObjectIndex getIndex(); diff --git a/src/main/java/org/scijava/platform/PlatformService.java b/src/main/java/org/scijava/platform/PlatformService.java index 1e1f0b783..267881bc8 100644 --- a/src/main/java/org/scijava/platform/PlatformService.java +++ b/src/main/java/org/scijava/platform/PlatformService.java @@ -52,9 +52,13 @@ public interface PlatformService extends SingletonService, SciJavaService { - EventService eventService(); + default EventService eventService() { + return context().getService(EventService.class); + } - CommandService commandService(); + default CommandService commandService() { + return context().getService(CommandService.class); + } /** Gets the platform handlers applicable to this platform. */ List getTargetPlatforms(); diff --git a/src/main/java/org/scijava/plugin/PTService.java b/src/main/java/org/scijava/plugin/PTService.java index 3b2e3435c..9951e8478 100644 --- a/src/main/java/org/scijava/plugin/PTService.java +++ b/src/main/java/org/scijava/plugin/PTService.java @@ -87,7 +87,9 @@ public interface PTService extends Service { * Gets the service responsible for discovering and managing this service's * plugins. */ - PluginService pluginService(); + default PluginService pluginService() { + return context().getService(PluginService.class); + } /** Gets the type of plugins managed by this service. */ Class getPluginType(); diff --git a/src/main/java/org/scijava/plugin/SingletonService.java b/src/main/java/org/scijava/plugin/SingletonService.java index e2f0d06d2..343033112 100644 --- a/src/main/java/org/scijava/plugin/SingletonService.java +++ b/src/main/java/org/scijava/plugin/SingletonService.java @@ -57,7 +57,9 @@ public interface SingletonService extends { /** Gets the {@link ObjectService} upon which this service depends. */ - ObjectService objectService(); + default ObjectService objectService() { + return context().getService(ObjectService.class); + } /** * Gets the list of plugin instances. There will be one singleton instance for From c29a6c9bce83a8480e72e2202c5f158031224df9 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 26 Aug 2016 03:32:06 -0500 Subject: [PATCH 0306/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b72d8a983..87d4aaa18 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.58.3-SNAPSHOT + 2.58.4-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. From 331e5843514ad70f052f3a849b428c3c8687ef29 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 31 Aug 2016 19:51:57 -0500 Subject: [PATCH 0307/1208] AbstractGateway: fix bug in getShortName behavior The default short name should be the class's _simple_ name (sans package) in lower case... not the fully qualified name in lower case. --- src/main/java/org/scijava/AbstractGateway.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/AbstractGateway.java b/src/main/java/org/scijava/AbstractGateway.java index 9db79f09e..0b55b646d 100644 --- a/src/main/java/org/scijava/AbstractGateway.java +++ b/src/main/java/org/scijava/AbstractGateway.java @@ -108,7 +108,7 @@ public void launch(final String... args) { @Override public String getShortName() { - return getClass().getName().toLowerCase(); + return getClass().getSimpleName().toLowerCase(); } @Override From 34e2800ee0fec9eb9e57f4c787f2249fbaf7be5d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 1 Sep 2016 13:37:52 -0500 Subject: [PATCH 0308/1208] ScriptFinder: quelch unsupported script message If you have a script directory prefix with a mixture of scripts and non-scripts such as JAR files (which is what Fiji has, for example), the ScriptFinder was issuing a warning message for each and every JAR file. This is normal and expected, so let's not warn about it, but rather mention it only when debug logging is enabled. --- src/main/java/org/scijava/script/ScriptFinder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/script/ScriptFinder.java b/src/main/java/org/scijava/script/ScriptFinder.java index 48d66e6aa..5766b2086 100644 --- a/src/main/java/org/scijava/script/ScriptFinder.java +++ b/src/main/java/org/scijava/script/ScriptFinder.java @@ -164,7 +164,7 @@ private int createInfos(final List scripts, final Set urls, int scriptCount = 0; for (final String path : scriptMap.keySet()) { if (!scriptService.canHandleFile(path)) { - log.warn("Ignoring unsupported script: " + path); + log.debug("Ignoring unsupported script: " + path); continue; } From 37dbcadfacdfc3496f62063ab54986846e202db3 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 08:23:42 -0500 Subject: [PATCH 0309/1208] Tweak description text --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 87d4aaa18..a6b72b5aa 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ 2.58.4-SNAPSHOT SciJava Common - SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO. + SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by downstream projects in the SciJava ecosystem, such as ImageJ and SCIFIO. http://scijava.org/ 2009 From 8a3ec325bc9f591a583ee1e26c8d030e3236aeb0 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 31 Aug 2016 20:08:15 -0500 Subject: [PATCH 0310/1208] POM: bump pom-scijava parent to 11.2.1 Aside from the usual managed component version updates, this reduces boilerplate for the maven-jar-plugin and license-maven-plugin, and avoids an annoying Eclipse warning. --- pom.xml | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/pom.xml b/pom.xml index a6b72b5aa..5414f69ec 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.scijava pom-scijava - 11.0.0 + 11.2.1 @@ -101,12 +101,21 @@ http://jenkins.imagej.net/job/SciJava-common/ + + org.scijava + + bsd_2 + SciJava Common shared library for SciJava software. + Board of Regents of the University of +Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck +Institute of Molecular Cell Biology and Genetics. + + org.scijava scijava-expression-parser - 3.1.0 @@ -131,27 +140,6 @@ - - maven-jar-plugin - - - - org.scijava - - - - - - org.codehaus.mojo - license-maven-plugin - - bsd_2 - Board of Regents of the University of -Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck -Institute of Molecular Cell Biology and Genetics. - SciJava Common shared library for SciJava software. - - org.apache.maven.plugins maven-compiler-plugin From ae5f1cf705cfb24084fe28a16f80f1525d172a42 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 10:34:43 -0500 Subject: [PATCH 0311/1208] DisplayPostprocessor: flag when output is handled In some cases, the handleOutput method handles an output; in others, it skips the output for various reasons. This commit changes the method to return a boolean flag indicating which scenario took place. --- .../scijava/display/DisplayPostprocessor.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/scijava/display/DisplayPostprocessor.java b/src/main/java/org/scijava/display/DisplayPostprocessor.java index d14f0777e..659f63533 100644 --- a/src/main/java/org/scijava/display/DisplayPostprocessor.java +++ b/src/main/java/org/scijava/display/DisplayPostprocessor.java @@ -82,17 +82,14 @@ public void process(final Module module) { * @param defaultName The default name for the display, if not already set. * @param output The object to display. */ - private void handleOutput(final String defaultName, final Object output) { - if (output == null) { - // ignore null outputs - return; - } + private boolean handleOutput(final String defaultName, final Object output) { + if (output == null) return false; // ignore null outputs if (output instanceof Display) { // output is itself a display; just update it final Display display = (Display) output; display.update(); - return; + return true; } final boolean addToExisting = addToExisting(output); @@ -133,7 +130,7 @@ private void handleOutput(final String defaultName, final Object output) { for (final Display display : displays) { display.update(); } - return; + return true; } if (output instanceof Map) { @@ -144,7 +141,7 @@ private void handleOutput(final String defaultName, final Object output) { final Object itemValue = map.get(key); handleOutput(itemName, itemValue); } - return; + return true; } if (output instanceof Collection) { @@ -153,7 +150,7 @@ private void handleOutput(final String defaultName, final Object output) { for (final Object item : collection) { handleOutput(defaultName, item); } - return; + return true; } // no available displays for this type of output @@ -162,6 +159,7 @@ private void handleOutput(final String defaultName, final Object output) { log.warn("Ignoring unsupported output: " + defaultName + " [" + valueClass + "]"); } + return false; } private boolean addToExisting(final Object output) { From cf8aaee565128aae5cbe9d4d36f7bbf6ace1cd0b Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 10:36:49 -0500 Subject: [PATCH 0312/1208] ScriptModule: do not resolve outputs The module item resolution API is for inputs only. It makes no sense to resolve the outputs here. (Actually, we are about to change that API to allow resolution of outputs as well... but it will still not make sense to do so here in the ScriptModule.) --- src/main/java/org/scijava/script/ScriptModule.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptModule.java b/src/main/java/org/scijava/script/ScriptModule.java index 45d2028db..558eec7b6 100644 --- a/src/main/java/org/scijava/script/ScriptModule.java +++ b/src/main/java/org/scijava/script/ScriptModule.java @@ -190,7 +190,6 @@ public void run() { final ScriptLanguage language = getLanguage(); for (final ModuleItem item : getInfo().outputs()) { final String name = item.getName(); - if (isResolved(name)) continue; final Object value; if (RETURN_VALUE.equals(name) && getInfo().isReturnValueAppended()) { // NB: This is the special implicit return value output! @@ -200,7 +199,6 @@ public void run() { final Object decoded = language.decode(value); final Object typed = conversionService.convert(decoded, item.getType()); setOutput(name, typed); - setResolved(name, true); } // flush output and error streams From 071dc89c84d882ca88ac3dab8f813d03b46f8286 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 10:33:14 -0500 Subject: [PATCH 0313/1208] Module: revamp item resolution Previously, only inputs could be marked resolved or not. But it is useful also to be able to resolve outputs, so that the postprocessing chain can be more intelligent about its actions. So now the API allows resolution of both inputs and outputs. --- pom.xml | 2 +- .../org/scijava/module/AbstractModule.java | 30 ++++++-- src/main/java/org/scijava/module/Module.java | 73 +++++++++++++++++-- 3 files changed, 93 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 91a54bfbb..cfaf505af 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.58.4-SNAPSHOT + 2.59.0-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by downstream projects in the SciJava ecosystem, such as ImageJ and SCIFIO. diff --git a/src/main/java/org/scijava/module/AbstractModule.java b/src/main/java/org/scijava/module/AbstractModule.java index d8c0433e2..77948a285 100644 --- a/src/main/java/org/scijava/module/AbstractModule.java +++ b/src/main/java/org/scijava/module/AbstractModule.java @@ -48,8 +48,8 @@ public abstract class AbstractModule implements Module { private final HashMap inputs; private final HashMap outputs; - /** Table indicating resolved inputs. */ private final HashSet resolvedInputs; + private final HashSet resolvedOutputs; private MethodRef initializerRef; @@ -57,6 +57,7 @@ public AbstractModule() { inputs = new HashMap<>(); outputs = new HashMap<>(); resolvedInputs = new HashSet<>(); + resolvedOutputs = new HashSet<>(); } // -- Module methods -- @@ -137,14 +138,33 @@ public void setOutputs(final Map outputs) { } @Override - public boolean isResolved(final String name) { + public boolean isInputResolved(final String name) { return resolvedInputs.contains(name); } @Override - public void setResolved(final String name, final boolean resolved) { - if (resolved) resolvedInputs.add(name); - else resolvedInputs.remove(name); + public boolean isOutputResolved(final String name) { + return resolvedOutputs.contains(name); + } + + @Override + public void resolveInput(final String name) { + resolvedInputs.add(name); + } + + @Override + public void resolveOutput(final String name) { + resolvedOutputs.add(name); + } + + @Override + public void unresolveInput(final String name) { + resolvedInputs.remove(name); + } + + @Override + public void unresolveOutput(final String name) { + resolvedOutputs.remove(name); } // -- Helper methods -- diff --git a/src/main/java/org/scijava/module/Module.java b/src/main/java/org/scijava/module/Module.java index 275f0d904..068b91e2c 100644 --- a/src/main/java/org/scijava/module/Module.java +++ b/src/main/java/org/scijava/module/Module.java @@ -33,6 +33,11 @@ import java.util.Map; +import org.scijava.display.DisplayPostprocessor; +import org.scijava.module.process.ModulePostprocessor; +import org.scijava.module.process.ModulePreprocessor; +import org.scijava.widget.InputHarvester; + /** * A module is an encapsulated piece of functionality with inputs and outputs. *

    @@ -126,15 +131,71 @@ public interface Module extends Runnable { void setOutputs(Map outputs); /** - * Gets the resolution status of the input with the given name. A "resolved" - * input is known to have a final, valid value for use with the module. + * Gets the resolution status of the input with the given name. + * + * @see #resolveInput(String) + */ + boolean isInputResolved(String name); + + /** + * Gets the resolution status of the output with the given name. + * + * @see #resolveOutput(String) + */ + boolean isOutputResolved(String name); + + /** + * Marks the input with the given name as resolved. A "resolved" input is + * known to have a final, valid value for use with the module. + *

    + * {@link ModulePreprocessor}s in the module execution chain that populate + * input values (e.g. {@link InputHarvester} plugins) will typically skip over + * inputs which have already been resolved. + *

    + */ + void resolveInput(String name); + + /** + * Marks the output with the given name as resolved. A "resolved" output has + * been handled by the framework somehow, typically displayed to the user. + *

    + * {@link ModulePostprocessor}s in the module execution chain that handle + * output values (e.g. the {@link DisplayPostprocessor}) will typically skip + * over outputs which have already been resolved. + *

    + */ + void resolveOutput(String name); + + /** + * Marks the input with the given name as unresolved. + * + * @see #resolveInput(String) */ - boolean isResolved(String name); + void unresolveInput(String name); + + /** + * Marks the output with the given name as unresolved. + * + * @see #resolveOutput(String) + */ + void unresolveOutput(String name); + + // -- Deprecated -- + + /** @deprecated Use {@link #isInputResolved(String)} instead. */ + @Deprecated + default boolean isResolved(final String name) { + return isInputResolved(name); + } /** - * Sets the resolution status of the input with the given name. A "resolved" - * input is known to have a final, valid value for use with the module. + * @deprecated Use {@link #resolveInput(String)} and + * {@link #unresolveInput(String)} instead. */ - void setResolved(String name, boolean resolved); + @Deprecated + default void setResolved(final String name, final boolean resolved) { + if (resolved) resolveInput(name); + else unresolveInput(name); + } } From cfb0659e3136d5bbb9be7cd6806fe622a0c6909e Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 10:44:55 -0500 Subject: [PATCH 0314/1208] Stop using old module input resolution methods --- src/main/java/org/scijava/command/CommandModule.java | 2 +- .../java/org/scijava/display/ActiveDisplayPreprocessor.java | 2 +- src/main/java/org/scijava/module/DefaultModuleService.java | 4 ++-- .../org/scijava/module/process/DefaultValuePreprocessor.java | 2 +- .../java/org/scijava/module/process/GatewayPreprocessor.java | 2 +- .../org/scijava/module/process/LoadInputsPreprocessor.java | 2 +- .../java/org/scijava/module/process/ServicePreprocessor.java | 4 ++-- src/main/java/org/scijava/options/OptionsPlugin.java | 2 +- src/main/java/org/scijava/ui/FilePreprocessor.java | 4 ++-- src/main/java/org/scijava/ui/UIPreprocessor.java | 2 +- src/main/java/org/scijava/widget/AbstractInputHarvester.java | 4 ++-- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/scijava/command/CommandModule.java b/src/main/java/org/scijava/command/CommandModule.java index 793fde188..01afe55ef 100644 --- a/src/main/java/org/scijava/command/CommandModule.java +++ b/src/main/java/org/scijava/command/CommandModule.java @@ -266,7 +266,7 @@ private void assignPresets() { for (final String name : presets.keySet()) { final Object value = presets.get(name); setInput(name, value); - setResolved(name, true); + resolveInput(name); } } diff --git a/src/main/java/org/scijava/display/ActiveDisplayPreprocessor.java b/src/main/java/org/scijava/display/ActiveDisplayPreprocessor.java index 916bc2d0a..b49596826 100644 --- a/src/main/java/org/scijava/display/ActiveDisplayPreprocessor.java +++ b/src/main/java/org/scijava/display/ActiveDisplayPreprocessor.java @@ -82,7 +82,7 @@ public void process(final Module module) { final String name = displayInput.getName(); module.setInput(name, activeDisplay); - module.setResolved(name, true); + module.resolveInput(name); } } diff --git a/src/main/java/org/scijava/module/DefaultModuleService.java b/src/main/java/org/scijava/module/DefaultModuleService.java index ad1eea492..1d96526c5 100644 --- a/src/main/java/org/scijava/module/DefaultModuleService.java +++ b/src/main/java/org/scijava/module/DefaultModuleService.java @@ -459,7 +459,7 @@ private void assignInputs(final Module module, } } module.setInput(name, converted); - module.setResolved(name, true); + module.resolveInput(name); } } @@ -480,7 +480,7 @@ private ModuleItem getSingleItem(final Module module, for (final ModuleItem item : items) { final String name = item.getName(); - final boolean resolved = module.isResolved(name); + final boolean resolved = module.isInputResolved(name); if (resolved) continue; // skip resolved inputs if (!item.isAutoFill()) continue; // skip unfillable inputs final Class itemType = item.getType(); diff --git a/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java b/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java index 3ea3863f6..2bf08354e 100644 --- a/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java +++ b/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java @@ -72,7 +72,7 @@ public void process(final Module module) { private void assignDefaultValue(final Module module, final ModuleItem item) { - if (module.isResolved(item.getName())) return; + if (module.isInputResolved(item.getName())) return; final T nullValue = ConversionUtils.getNullValue(item.getType()); if (Objects.equals(item.getValue(module), nullValue)) return; final T defaultValue = moduleService.getDefaultValue(item); diff --git a/src/main/java/org/scijava/module/process/GatewayPreprocessor.java b/src/main/java/org/scijava/module/process/GatewayPreprocessor.java index 6f0ed52c8..745c0464a 100644 --- a/src/main/java/org/scijava/module/process/GatewayPreprocessor.java +++ b/src/main/java/org/scijava/module/process/GatewayPreprocessor.java @@ -110,7 +110,7 @@ private void setGatewayValue(final Context context, return; } input.setValue(module, gateway); - module.setResolved(input.getName(), true); + module.resolveInput(input.getName()); } } diff --git a/src/main/java/org/scijava/module/process/LoadInputsPreprocessor.java b/src/main/java/org/scijava/module/process/LoadInputsPreprocessor.java index 17d1b736f..4c158d688 100644 --- a/src/main/java/org/scijava/module/process/LoadInputsPreprocessor.java +++ b/src/main/java/org/scijava/module/process/LoadInputsPreprocessor.java @@ -76,7 +76,7 @@ public void process(final Module module) { /** Loads the value of the given module item from persistent storage. */ private void loadValue(final Module module, final ModuleItem item) { // skip input that has already been resolved - if (module.isResolved(item.getName())) return; + if (module.isInputResolved(item.getName())) return; final T prefValue = moduleService.load(item); final Class type = item.getType(); diff --git a/src/main/java/org/scijava/module/process/ServicePreprocessor.java b/src/main/java/org/scijava/module/process/ServicePreprocessor.java index 69e8f4500..f1d111d4f 100644 --- a/src/main/java/org/scijava/module/process/ServicePreprocessor.java +++ b/src/main/java/org/scijava/module/process/ServicePreprocessor.java @@ -83,7 +83,7 @@ public void process(final Module module) { // input is a compatible context final String name = input.getName(); module.setInput(name, getContext()); - module.setResolved(name, true); + module.resolveInput(name); } } } @@ -95,7 +95,7 @@ private void setServiceValue(final Context context, { final S service = context.getService(input.getType()); input.setValue(module, service); - module.setResolved(input.getName(), true); + module.resolveInput(input.getName()); } } diff --git a/src/main/java/org/scijava/options/OptionsPlugin.java b/src/main/java/org/scijava/options/OptionsPlugin.java index 783cf3161..47420f0b0 100644 --- a/src/main/java/org/scijava/options/OptionsPlugin.java +++ b/src/main/java/org/scijava/options/OptionsPlugin.java @@ -116,7 +116,7 @@ public void run() { // NB: Clear "resolved" status of all inputs. // Otherwise, no inputs are harvested on next run. for (final ModuleItem input : getInfo().inputs()) { - setResolved(input.getName(), false); + unresolveInput(input.getName()); } eventService.publish(new OptionsEvent(this)); diff --git a/src/main/java/org/scijava/ui/FilePreprocessor.java b/src/main/java/org/scijava/ui/FilePreprocessor.java index 68ce98c6c..f82d624ee 100644 --- a/src/main/java/org/scijava/ui/FilePreprocessor.java +++ b/src/main/java/org/scijava/ui/FilePreprocessor.java @@ -74,7 +74,7 @@ public void process(final Module module) { } fileInput.setValue(module, result); - module.setResolved(fileInput.getName(), true); + module.resolveInput(fileInput.getName()); } // -- Helper methods -- @@ -87,7 +87,7 @@ public void process(final Module module) { private ModuleItem getFileInput(final Module module) { ModuleItem result = null; for (final ModuleItem input : module.getInfo().inputs()) { - if (module.isResolved(input.getName())) continue; + if (module.isInputResolved(input.getName())) continue; final Class type = input.getType(); if (!File.class.isAssignableFrom(type)) { // not a File parameter; abort diff --git a/src/main/java/org/scijava/ui/UIPreprocessor.java b/src/main/java/org/scijava/ui/UIPreprocessor.java index 44da9289c..bfd11993e 100644 --- a/src/main/java/org/scijava/ui/UIPreprocessor.java +++ b/src/main/java/org/scijava/ui/UIPreprocessor.java @@ -67,7 +67,7 @@ public void process(final Module module) { // input is a compatible UI final String name = input.getName(); module.setInput(name, ui); - module.setResolved(name, true); + module.resolveInput(name); } } } diff --git a/src/main/java/org/scijava/widget/AbstractInputHarvester.java b/src/main/java/org/scijava/widget/AbstractInputHarvester.java index 2003ec523..a437389c3 100644 --- a/src/main/java/org/scijava/widget/AbstractInputHarvester.java +++ b/src/main/java/org/scijava/widget/AbstractInputHarvester.java @@ -115,7 +115,7 @@ public void processResults(final InputPanel inputPanel, for (final ModuleItem item : inputs) { final String name = item.getName(); - module.setResolved(name, true); + module.resolveInput(name); } } @@ -125,7 +125,7 @@ private WidgetModel addInput(final InputPanel inputPanel, final Module module, final ModuleItem item) throws ModuleException { final String name = item.getName(); - final boolean resolved = module.isResolved(name); + final boolean resolved = module.isInputResolved(name); if (resolved) return null; // skip resolved inputs final Class type = item.getType(); From a55f1b048f34af79877920449b7e1c4b69bfb3cd Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 08:31:33 -0500 Subject: [PATCH 0315/1208] POM: add an explanation for the section --- pom.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pom.xml b/pom.xml index 5414f69ec..91a54bfbb 100644 --- a/pom.xml +++ b/pom.xml @@ -139,6 +139,17 @@ Institute of Molecular Cell Biology and Genetics.
    + org.apache.maven.plugins From a6bf3cfacb89caa9f497f90fbdb737d86cbc9e1f Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 10:38:30 -0500 Subject: [PATCH 0316/1208] DisplayPostprocessor: resolve displayed outputs When a module output is successfully displayed, we mark it resolved, so that any downstream postprocessors know the output was handled. --- src/main/java/org/scijava/display/DisplayPostprocessor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/display/DisplayPostprocessor.java b/src/main/java/org/scijava/display/DisplayPostprocessor.java index 659f63533..48987e637 100644 --- a/src/main/java/org/scijava/display/DisplayPostprocessor.java +++ b/src/main/java/org/scijava/display/DisplayPostprocessor.java @@ -68,9 +68,11 @@ public void process(final Module module) { if (displayService == null) return; for (final ModuleItem outputItem : module.getInfo().outputs()) { + if (module.isOutputResolved(outputItem.getName())) continue; final Object value = outputItem.getValue(module); final String name = defaultName(outputItem); - handleOutput(name, value); + final boolean resolved = handleOutput(name, value); + if (resolved) module.resolveOutput(name); } } From bd51228082f4e1f49d5ebae0fc1e2261a73e3620 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 10:44:29 -0500 Subject: [PATCH 0317/1208] Stop using deprecated MiscUtils.equal method --- src/main/java/org/scijava/module/DefaultModuleService.java | 4 ++-- .../scijava/module/process/DefaultValuePreprocessor.java | 5 +++-- src/main/java/org/scijava/widget/DefaultWidgetModel.java | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/scijava/module/DefaultModuleService.java b/src/main/java/org/scijava/module/DefaultModuleService.java index 0d1e26106..ad1eea492 100644 --- a/src/main/java/org/scijava/module/DefaultModuleService.java +++ b/src/main/java/org/scijava/module/DefaultModuleService.java @@ -36,6 +36,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; @@ -63,7 +64,6 @@ import org.scijava.service.Service; import org.scijava.thread.ThreadService; import org.scijava.util.ClassUtils; -import org.scijava.util.MiscUtils; /** * Default service for keeping track of and executing available modules. @@ -291,7 +291,7 @@ public ModuleItem getSingleOutput(Module module, Collection> types) public void save(final ModuleItem item, final T value) { if (!item.isPersisted()) return; - if (MiscUtils.equal(item.getDefaultValue(), value)) { + if (Objects.equals(item.getDefaultValue(), value)) { // NB: Do not persist the value if it is the default. // This is nice if the default value might change later, // such as when iteratively developing a script. diff --git a/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java b/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java index 1422b9422..3ea3863f6 100644 --- a/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java +++ b/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java @@ -31,6 +31,8 @@ package org.scijava.module.process; +import java.util.Objects; + import org.scijava.Priority; import org.scijava.module.Module; import org.scijava.module.ModuleItem; @@ -38,7 +40,6 @@ import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; import org.scijava.util.ConversionUtils; -import org.scijava.util.MiscUtils; /** * A preprocessor plugin that populates default parameter values. @@ -73,7 +74,7 @@ private void assignDefaultValue(final Module module, { if (module.isResolved(item.getName())) return; final T nullValue = ConversionUtils.getNullValue(item.getType()); - if (MiscUtils.equal(item.getValue(module), nullValue)) return; + if (Objects.equals(item.getValue(module), nullValue)) return; final T defaultValue = moduleService.getDefaultValue(item); if (defaultValue == null) return; item.setValue(module, defaultValue); diff --git a/src/main/java/org/scijava/widget/DefaultWidgetModel.java b/src/main/java/org/scijava/widget/DefaultWidgetModel.java index 14db291d5..26305ee9d 100644 --- a/src/main/java/org/scijava/widget/DefaultWidgetModel.java +++ b/src/main/java/org/scijava/widget/DefaultWidgetModel.java @@ -34,6 +34,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.WeakHashMap; import org.scijava.AbstractContextual; @@ -49,7 +50,6 @@ import org.scijava.thread.ThreadService; import org.scijava.util.ClassUtils; import org.scijava.util.ConversionUtils; -import org.scijava.util.MiscUtils; import org.scijava.util.NumberUtils; /** @@ -148,12 +148,12 @@ public Object getValue() { @Override public void setValue(final Object value) { final String name = item.getName(); - if (MiscUtils.equal(item.getValue(module), value)) return; // no change + if (Objects.equals(item.getValue(module), value)) return; // no change // Check if a converted value is present Object convertedInput = convertedObjects.get(value); if (convertedInput != null && - MiscUtils.equal(item.getValue(module), convertedInput)) + Objects.equals(item.getValue(module), convertedInput)) { return; // no change } From 2bd51a34a1d3f3d9ebff529a75c4dd03fad874b4 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 11:04:00 -0500 Subject: [PATCH 0318/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cfaf505af..7dd28a3b2 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.59.0-SNAPSHOT + 2.59.1-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by downstream projects in the SciJava ecosystem, such as ImageJ and SCIFIO. From 8e2d1304f371414e2f4d8a97f6c6a5b64092e665 Mon Sep 17 00:00:00 2001 From: rimadoma Date: Mon, 15 Aug 2016 18:24:36 +0100 Subject: [PATCH 0319/1208] gitignore: add rules for IntelliJ Signed-off-by: Curtis Rueden --- .gitignore | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 54e060e75..436cdc7f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,13 @@ *.swp + +# Maven # +/target/ + +# Eclipse # /.classpath /.project /.settings/ -/target/ + +# IntelliJ # +/*.iml +/.idea/ From 89412f87f585588ad0a315942a11f5ce71232375 Mon Sep 17 00:00:00 2001 From: rimadoma Date: Mon, 15 Aug 2016 19:00:11 +0100 Subject: [PATCH 0320/1208] Remove redundant if --- src/main/java/org/scijava/ui/DefaultUIService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/scijava/ui/DefaultUIService.java b/src/main/java/org/scijava/ui/DefaultUIService.java index 8a38fb33b..3ff967c75 100644 --- a/src/main/java/org/scijava/ui/DefaultUIService.java +++ b/src/main/java/org/scijava/ui/DefaultUIService.java @@ -214,7 +214,6 @@ public boolean isHeadless() { public UserInterface getDefaultUI() { if (defaultUI != null) return defaultUI; if (uiList().isEmpty()) return null; - if (defaultUI != null) return defaultUI; return uiList().get(0); } From 7021a0ad7375abf2a422dfd94a19fb8ac4e2620a Mon Sep 17 00:00:00 2001 From: Richard Domander Date: Tue, 30 Aug 2016 18:03:55 +0100 Subject: [PATCH 0321/1208] Add a HeadlessUI Add a null object pattern style is used, for when UIService is running headless. This avoid NullPointerException and similar issues. Signed-off-by: Curtis Rueden --- .../java/org/scijava/ui/DefaultUIService.java | 2 + .../org/scijava/ui/headlessUI/HeadlessUI.java | 192 ++++++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 src/main/java/org/scijava/ui/headlessUI/HeadlessUI.java diff --git a/src/main/java/org/scijava/ui/DefaultUIService.java b/src/main/java/org/scijava/ui/DefaultUIService.java index 3ff967c75..7de130b60 100644 --- a/src/main/java/org/scijava/ui/DefaultUIService.java +++ b/src/main/java/org/scijava/ui/DefaultUIService.java @@ -68,6 +68,7 @@ import org.scijava.ui.DialogPrompt.OptionType; import org.scijava.ui.DialogPrompt.Result; import org.scijava.ui.event.UIShownEvent; +import org.scijava.ui.headlessUI.HeadlessUI; import org.scijava.ui.viewer.DisplayViewer; /** @@ -212,6 +213,7 @@ public boolean isHeadless() { @Override public UserInterface getDefaultUI() { + if (isHeadless()) return HeadlessUI.getInstance(); if (defaultUI != null) return defaultUI; if (uiList().isEmpty()) return null; return uiList().get(0); diff --git a/src/main/java/org/scijava/ui/headlessUI/HeadlessUI.java b/src/main/java/org/scijava/ui/headlessUI/HeadlessUI.java new file mode 100644 index 000000000..844d4b77b --- /dev/null +++ b/src/main/java/org/scijava/ui/headlessUI/HeadlessUI.java @@ -0,0 +1,192 @@ +/*- + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.ui.headlessUI; + +import static org.scijava.Priority.LAST_PRIORITY; + +import java.io.File; + +import org.scijava.Context; +import org.scijava.display.Display; +import org.scijava.plugin.PluginInfo; +import org.scijava.ui.ApplicationFrame; +import org.scijava.ui.Desktop; +import org.scijava.ui.DialogPrompt; +import org.scijava.ui.StatusBar; +import org.scijava.ui.SystemClipboard; +import org.scijava.ui.ToolBar; +import org.scijava.ui.UserInterface; +import org.scijava.ui.console.ConsolePane; +import org.scijava.ui.viewer.DisplayWindow; + +/** + * A "null object" UI implementation that can be returned when a UIService is + * running headless + * + * @author Richard Domander (Royal Veterinary College, London) + */ +public class HeadlessUI implements UserInterface { + + private static HeadlessUI instance; + + private HeadlessUI() {} + + public static HeadlessUI getInstance() { + if (instance == null) { + instance = new HeadlessUI(); + } + + return instance; + } + + @Override + public void show() {} + + @Override + public boolean isVisible() { + return false; + } + + @Override + public void show(final Object o) {} + + @Override + public void show(final String name, final Object o) {} + + @Override + public void show(final Display display) {} + + @Override + public Desktop getDesktop() { + return null; + } + + @Override + public ApplicationFrame getApplicationFrame() { + return null; + } + + @Override + public ToolBar getToolBar() { + return null; + } + + @Override + public StatusBar getStatusBar() { + return null; + } + + @Override + public ConsolePane getConsolePane() { + return null; + } + + @Override + public SystemClipboard getSystemClipboard() { + return null; + } + + @Override + public DisplayWindow createDisplayWindow(final Display display) { + return null; + } + + @Override + public DialogPrompt dialogPrompt(final String message, final String title, + final DialogPrompt.MessageType messageType, + final DialogPrompt.OptionType optionType) + { + return null; + } + + @Override + public File chooseFile(final File file, final String style) { + return null; + } + + @Override + public File chooseFile(final String title, final File file, + final String style) + { + return null; + } + + @Override + public void showContextMenu(final String menuRoot, final Display display, + final int x, final int y) + {} + + @Override + public void saveLocation() {} + + @Override + public void restoreLocation() {} + + @Override + public boolean requiresEDT() { + return false; + } + + /** Returns null since this is a contextless null object */ + @Override + public Context context() { + return null; + } + + /** Returns null since this is a contextless null object */ + @Override + public Context getContext() { + return null; + } + + @Override + public void setContext(final Context context) {} + + @Override + public PluginInfo getInfo() { + return null; + } + + @Override + public void setInfo(final PluginInfo info) {} + + @Override + public void dispose() {} + + @Override + public double getPriority() { + return LAST_PRIORITY; + } + + @Override + public void setPriority(final double priority) {} +} From e20e90fed30ad73c5623b1363c999be6bda8679a Mon Sep 17 00:00:00 2001 From: Richard Domander Date: Tue, 30 Aug 2016 18:03:55 +0100 Subject: [PATCH 0322/1208] Test that HeadlessUI is the default while headless Signed-off-by: Curtis Rueden --- .../java/org/scijava/ui/UIServiceTest.java | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/test/java/org/scijava/ui/UIServiceTest.java diff --git a/src/test/java/org/scijava/ui/UIServiceTest.java b/src/test/java/org/scijava/ui/UIServiceTest.java new file mode 100644 index 000000000..bcd515739 --- /dev/null +++ b/src/test/java/org/scijava/ui/UIServiceTest.java @@ -0,0 +1,105 @@ +/*- + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava.ui; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.scijava.Context; +import org.scijava.display.Display; +import org.scijava.ui.headlessUI.HeadlessUI; +import org.scijava.ui.viewer.DisplayWindow; + +/** + * Tests for {@link DefaultUIService}. + * + * @author Richard Domander (Royal Veterinary College, London) + */ +public class UIServiceTest { + + @Test + public void testHeadlessUI() { + final Context context = new Context(UIService.class); + final UIService uiService = context.service(UIService.class); + + final MockUserInterface mockUI = new MockUserInterface(); + uiService.setDefaultUI(mockUI); + + // test non-headless behavior + uiService.setHeadless(false); + assertFalse(uiService.isHeadless()); + assertTrue(uiService.getDefaultUI() instanceof MockUserInterface); + + // test headless behavior + uiService.setHeadless(true); + assertTrue(uiService.isHeadless()); + assertTrue("UIService should return HeadlessUI when running \"headless\"", + uiService.getDefaultUI() instanceof HeadlessUI); + + context.dispose(); + } + + private static final class MockUserInterface extends AbstractUserInterface { + + @Override + public SystemClipboard getSystemClipboard() { + return null; + } + + @Override + public DisplayWindow createDisplayWindow(final Display display) { + return null; + } + + @Override + public DialogPrompt dialogPrompt(final String message, final String title, + final DialogPrompt.MessageType messageType, + final DialogPrompt.OptionType optionType) + { + return null; + } + + @Override + public void showContextMenu(final String menuRoot, final Display display, + final int x, final int y) + {} + + @Override + public boolean requiresEDT() { + return false; + } + + @Override + public void dispose() {} + } +} From 96655703a58c0e04720f616e548b72095b65356d Mon Sep 17 00:00:00 2001 From: Richard Domander Date: Wed, 31 Aug 2016 13:45:45 +0100 Subject: [PATCH 0323/1208] UserInterface: improve javadoc Signed-off-by: Curtis Rueden --- .../java/org/scijava/ui/UserInterface.java | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/scijava/ui/UserInterface.java b/src/main/java/org/scijava/ui/UserInterface.java index 7eadc1cb2..cfa80b1b7 100644 --- a/src/main/java/org/scijava/ui/UserInterface.java +++ b/src/main/java/org/scijava/ui/UserInterface.java @@ -50,7 +50,7 @@ * implementing this interface, it is encouraged to instead extend * {@link AbstractUserInterface}, for convenience. *

    - * + * * @author Curtis Rueden * @see Plugin * @see UIService @@ -74,7 +74,7 @@ public interface UserInterface extends RichPlugin, Disposable { /** * Shows the object onscreen using an appropriate UI widget. - * + * * @param name The name to use when displaying the object. * @param o The object to be displayed. */ @@ -83,7 +83,10 @@ public interface UserInterface extends RichPlugin, Disposable { /** Shows the display onscreen using an appropriate UI widget. */ void show(Display display); - /** Gets the desktop, for use with multi-document interfaces (MDI). */ + /** + * Gets the desktop, for use with multi-document interfaces (MDI), or null if + * not applicable. + */ Desktop getDesktop(); /** Gets the main SciJava application frame, or null if not applicable. */ @@ -98,15 +101,21 @@ public interface UserInterface extends RichPlugin, Disposable { /** Gets the main SciJava console pane, or null if not applicable. */ ConsolePane getConsolePane(); - /** Gets the system clipboard associated with this UI. */ + /** + * Gets the system clipboard associated with this UI, or null if not + * applicable. + */ SystemClipboard getSystemClipboard(); - /** Creates a new display window housing the given display. */ + /** + * Creates a new display window housing the given display, or null if not + * applicable. + */ DisplayWindow createDisplayWindow(Display display); /** * Creates a dialog prompter. - * + * * @param message The message in the dialog itself. * @param title The title of the dialog. * @param messageType The type of message. This typically is rendered as an @@ -115,14 +124,14 @@ public interface UserInterface extends RichPlugin, Disposable { * as an exclamation point. * @param optionType The choices available when dismissing the dialog. These * choices are typically rendered as buttons for the user to click. - * @return The newly created DialogPrompt object. + * @return The newly created DialogPrompt object, or null if not applicable. */ DialogPrompt dialogPrompt(String message, String title, DialogPrompt.MessageType messageType, DialogPrompt.OptionType optionType); /** * Prompts the user to choose a file. - * + * * @param file The initial value displayed in the file chooser prompt. * @param style The style of chooser to use: *
      @@ -130,12 +139,14 @@ DialogPrompt dialogPrompt(String message, String title, *
    • {@link FileWidget#SAVE_STYLE}
    • *
    • {@link FileWidget#DIRECTORY_STYLE}
    • *
    + * @return The {@link File} chosen by the user, or null if prompt is not + * available */ File chooseFile(File file, String style); /** * Prompts the user to choose a file. - * + * * @param title Title to use in the file chooser dialog. * @param file The initial value displayed in the file chooser prompt. * @param style The style of chooser to use: @@ -144,6 +155,8 @@ DialogPrompt dialogPrompt(String message, String title, *
  • {@link FileWidget#SAVE_STYLE}
  • *
  • {@link FileWidget#DIRECTORY_STYLE}
  • * + * @return The {@link File} chosen by the user, or null if prompt is not + * available */ File chooseFile(String title, File file, String style); From 6464d96eb5014354dcb905631ddbb8fe0c9d97b9 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 12:21:45 -0500 Subject: [PATCH 0324/1208] Add Richard Domander as a contributor --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 7dd28a3b2..42082ee9a 100644 --- a/pom.xml +++ b/pom.xml @@ -66,6 +66,11 @@ http://imagej.net/User:Dietzc dietzc + + Richard Domander + http://imagej.net/User:Rdom + rimadoma + Gabriel Einsdorf http://imagej.net/User:Gab1one From 838af0af21e5332f10c17375eed3ba56f423c0c9 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 12:31:25 -0500 Subject: [PATCH 0325/1208] UserInterface: push default behavior to interface There is quite a bit of reasonable default behavior which can now, thanks to Java 8, be expressed in default interface methods. --- .../org/scijava/ui/AbstractUserInterface.java | 55 ------------------- .../java/org/scijava/ui/UserInterface.java | 42 +++++++++++--- 2 files changed, 33 insertions(+), 64 deletions(-) diff --git a/src/main/java/org/scijava/ui/AbstractUserInterface.java b/src/main/java/org/scijava/ui/AbstractUserInterface.java index 22a318808..f2b0ce3cf 100644 --- a/src/main/java/org/scijava/ui/AbstractUserInterface.java +++ b/src/main/java/org/scijava/ui/AbstractUserInterface.java @@ -31,7 +31,6 @@ package org.scijava.ui; -import java.io.File; import java.util.List; import org.scijava.app.StatusService; @@ -45,10 +44,8 @@ import org.scijava.plugin.PluginService; import org.scijava.prefs.PrefService; import org.scijava.thread.ThreadService; -import org.scijava.ui.console.ConsolePane; import org.scijava.ui.viewer.DisplayViewer; import org.scijava.ui.viewer.DisplayWindow; -import org.scijava.widget.FileWidget; /** * Abstract superclass for {@link UserInterface} implementations. @@ -102,11 +99,6 @@ public boolean isVisible() { return visible; } - @Override - public void show(final Object o) { - show(null, o); - } - @Override public void show(final String name, final Object o) { final Display display; @@ -163,44 +155,6 @@ public void run() { }); } - @Override - public Desktop getDesktop() { - return null; - } - - @Override - public ApplicationFrame getApplicationFrame() { - return null; - } - - @Override - public ToolBar getToolBar() { - return null; - } - - @Override - public StatusBar getStatusBar() { - return null; - } - - @Override - public ConsolePane getConsolePane() { - return null; - } - - @Override - public File chooseFile(final File file, final String style) { - return chooseFile(fileChooserTitle(style), file, style); - } - - @Deprecated - @Override - public File chooseFile(final String title, final File file, - final String style) - { - throw new UnsupportedOperationException("No default implementation."); - } - @Override public void saveLocation() { final ApplicationFrame appFrame = getApplicationFrame(); @@ -230,13 +184,4 @@ public void restoreLocation() { protected void createUI() { restoreLocation(); } - - /** Gets a default file chooser title to use when none is given. */ - protected String fileChooserTitle(final String style) { - if (style.equals(FileWidget.DIRECTORY_STYLE)) return "Choose a directory"; - if (style.equals(FileWidget.OPEN_STYLE)) return "Open"; - if (style.equals(FileWidget.SAVE_STYLE)) return "Save"; - return "Choose a file"; - } - } diff --git a/src/main/java/org/scijava/ui/UserInterface.java b/src/main/java/org/scijava/ui/UserInterface.java index cfa80b1b7..f5cf978d0 100644 --- a/src/main/java/org/scijava/ui/UserInterface.java +++ b/src/main/java/org/scijava/ui/UserInterface.java @@ -70,7 +70,9 @@ public interface UserInterface extends RichPlugin, Disposable { boolean isVisible(); /** Shows the object onscreen using an appropriate UI widget. */ - void show(Object o); + default void show(final Object o) { + show(null, o); + } /** * Shows the object onscreen using an appropriate UI widget. @@ -87,25 +89,37 @@ public interface UserInterface extends RichPlugin, Disposable { * Gets the desktop, for use with multi-document interfaces (MDI), or null if * not applicable. */ - Desktop getDesktop(); + default Desktop getDesktop() { + return null; + } /** Gets the main SciJava application frame, or null if not applicable. */ - ApplicationFrame getApplicationFrame(); + default ApplicationFrame getApplicationFrame() { + return null; + } /** Gets the main SciJava toolbar, or null if not applicable. */ - ToolBar getToolBar(); + default ToolBar getToolBar() { + return null; + } /** Gets the main SciJava status bar, or null if not applicable. */ - StatusBar getStatusBar(); + default StatusBar getStatusBar() { + return null; + } /** Gets the main SciJava console pane, or null if not applicable. */ - ConsolePane getConsolePane(); + default ConsolePane getConsolePane() { + return null; + } /** * Gets the system clipboard associated with this UI, or null if not * applicable. */ - SystemClipboard getSystemClipboard(); + default SystemClipboard getSystemClipboard() { + return null; + } /** * Creates a new display window housing the given display, or null if not @@ -142,7 +156,15 @@ DialogPrompt dialogPrompt(String message, String title, * @return The {@link File} chosen by the user, or null if prompt is not * available */ - File chooseFile(File file, String style); + default File chooseFile(final File file, final String style) { + final String title; + if (style.equals(FileWidget.DIRECTORY_STYLE)) title = "Choose a directory"; + else if (style.equals(FileWidget.OPEN_STYLE)) title = "Open"; + else if (style.equals(FileWidget.SAVE_STYLE)) title = "Save"; + else title = "Choose a file"; + + return chooseFile(title, file, style); + } /** * Prompts the user to choose a file. @@ -158,7 +180,9 @@ DialogPrompt dialogPrompt(String message, String title, * @return The {@link File} chosen by the user, or null if prompt is not * available */ - File chooseFile(String title, File file, String style); + default File chooseFile(String title, File file, String style) { + throw new UnsupportedOperationException(); + } /** * Displays a popup context menu for the given display at the specified From e17c5fe5877c2cc71c625efbbcd4255ff66864af Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 12:45:42 -0500 Subject: [PATCH 0326/1208] AbstractUserInterface: remove unnecessary services --- src/main/java/org/scijava/ui/AbstractUserInterface.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/org/scijava/ui/AbstractUserInterface.java b/src/main/java/org/scijava/ui/AbstractUserInterface.java index f2b0ce3cf..7210682f0 100644 --- a/src/main/java/org/scijava/ui/AbstractUserInterface.java +++ b/src/main/java/org/scijava/ui/AbstractUserInterface.java @@ -59,9 +59,6 @@ public abstract class AbstractUserInterface extends AbstractRichPlugin private static final String LAST_X = "lastXLocation"; private static final String LAST_Y = "lastYLocation"; - @Parameter - private CommandService commandService; - @Parameter private DisplayService displayService; @@ -71,9 +68,6 @@ public abstract class AbstractUserInterface extends AbstractRichPlugin @Parameter private PluginService pluginService; - @Parameter - private StatusService statusService; - @Parameter private ThreadService threadService; From 922e72d018cf84a6591ce3be5a1b3fe2ea7701b0 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 12:46:24 -0500 Subject: [PATCH 0327/1208] DefaultUIService: remove unnecessary services I vaguely recall that some of these services were added as hacks to ensure that service initialization happened in a certain order. But if so, I didn't flag those particular services with all-important HACK and/or NB comments. So away they go (for now). --- .../java/org/scijava/ui/DefaultUIService.java | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/src/main/java/org/scijava/ui/DefaultUIService.java b/src/main/java/org/scijava/ui/DefaultUIService.java index 7de130b60..2c0d51390 100644 --- a/src/main/java/org/scijava/ui/DefaultUIService.java +++ b/src/main/java/org/scijava/ui/DefaultUIService.java @@ -41,7 +41,6 @@ import org.scijava.app.AppService; import org.scijava.app.StatusService; import org.scijava.app.event.StatusEvent; -import org.scijava.command.CommandService; import org.scijava.display.Display; import org.scijava.display.DisplayService; import org.scijava.display.event.DisplayActivatedEvent; @@ -51,10 +50,6 @@ import org.scijava.event.EventHandler; import org.scijava.event.EventService; import org.scijava.log.LogService; -import org.scijava.menu.MenuService; -import org.scijava.options.OptionsService; -import org.scijava.platform.AppEventService; -import org.scijava.platform.PlatformService; import org.scijava.platform.event.AppQuitEvent; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; @@ -63,7 +58,6 @@ import org.scijava.service.AbstractService; import org.scijava.service.Service; import org.scijava.thread.ThreadService; -import org.scijava.tool.ToolService; import org.scijava.ui.DialogPrompt.MessageType; import org.scijava.ui.DialogPrompt.OptionType; import org.scijava.ui.DialogPrompt.Result; @@ -96,30 +90,12 @@ public final class DefaultUIService extends AbstractService implements @Parameter private AppService appService; - @Parameter - private PlatformService platformService; - @Parameter private PluginService pluginService; - @Parameter - private CommandService commandService; - @Parameter private DisplayService displayService; - @Parameter - private MenuService menuService; - - @Parameter - private ToolService toolService; - - @Parameter - private OptionsService optionsService; - - @Parameter - private AppEventService appEventService; - /** * A list of extant display viewers. It's needed in order to find the viewer * associated with a display. From 9f0b8703c23f0d0f7128f04fe89652578cc56237 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 12:50:54 -0500 Subject: [PATCH 0328/1208] DefaultUIService: tweak syntax for conciseness --- src/main/java/org/scijava/ui/DefaultUIService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/ui/DefaultUIService.java b/src/main/java/org/scijava/ui/DefaultUIService.java index 2c0d51390..aa56bac0f 100644 --- a/src/main/java/org/scijava/ui/DefaultUIService.java +++ b/src/main/java/org/scijava/ui/DefaultUIService.java @@ -191,8 +191,7 @@ public boolean isHeadless() { public UserInterface getDefaultUI() { if (isHeadless()) return HeadlessUI.getInstance(); if (defaultUI != null) return defaultUI; - if (uiList().isEmpty()) return null; - return uiList().get(0); + return uiList().isEmpty() ? null : uiList().get(0); } @Override From 2f20aa30d2da43c09465cf90002491f0423cd563 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 13:06:05 -0500 Subject: [PATCH 0329/1208] UIServiceTest: remove no-longer-needed override --- src/test/java/org/scijava/ui/UIServiceTest.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/test/java/org/scijava/ui/UIServiceTest.java b/src/test/java/org/scijava/ui/UIServiceTest.java index bcd515739..f81442f36 100644 --- a/src/test/java/org/scijava/ui/UIServiceTest.java +++ b/src/test/java/org/scijava/ui/UIServiceTest.java @@ -71,11 +71,6 @@ public void testHeadlessUI() { private static final class MockUserInterface extends AbstractUserInterface { - @Override - public SystemClipboard getSystemClipboard() { - return null; - } - @Override public DisplayWindow createDisplayWindow(final Display display) { return null; From 9dc359a5316d73e20400cb04e6ca32ae4ef21cc1 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 13:40:42 -0500 Subject: [PATCH 0330/1208] StatusServiceTest: simplify exception handling No need to try/catch and fail... just throw it. --- .../org/scijava/app/StatusServiceTest.java | 94 ++++++------------- 1 file changed, 29 insertions(+), 65 deletions(-) diff --git a/src/test/java/org/scijava/app/StatusServiceTest.java b/src/test/java/org/scijava/app/StatusServiceTest.java index 7c4320864..66ec12c79 100644 --- a/src/test/java/org/scijava/app/StatusServiceTest.java +++ b/src/test/java/org/scijava/app/StatusServiceTest.java @@ -88,96 +88,60 @@ public void setUp() throws Exception { } @Test - public void testShowProgress() { + public void testShowProgress() throws InterruptedException { ss.showProgress(15, 45); - try { - final StatusEvent event = queue.poll(10, TimeUnit.SECONDS); - assertEquals(event.getProgressValue(), 15); - assertEquals(event.getProgressMaximum(), 45); - assertFalse(event.isWarning()); - } - catch (final InterruptedException e) { - e.printStackTrace(); - fail(); - } + final StatusEvent event = queue.poll(10, TimeUnit.SECONDS); + assertEquals(event.getProgressValue(), 15); + assertEquals(event.getProgressMaximum(), 45); + assertFalse(event.isWarning()); } @Test - public void testShowStatusString() { + public void testShowStatusString() throws InterruptedException { final String text = "Hello, world"; ss.showStatus(text); - try { - final StatusEvent event = queue.poll(10, TimeUnit.SECONDS); - assertEquals(event.getStatusMessage(), text); - assertFalse(event.isWarning()); - } - catch (final InterruptedException e) { - e.printStackTrace(); - fail(); - } + final StatusEvent event = queue.poll(10, TimeUnit.SECONDS); + assertEquals(event.getStatusMessage(), text); + assertFalse(event.isWarning()); } @Test - public void testShowStatusIntIntString() { + public void testShowStatusIntIntString() throws InterruptedException { final String text = "Working..."; ss.showStatus(25, 55, text); - try { - final StatusEvent event = queue.poll(10, TimeUnit.SECONDS); - assertEquals(event.getProgressValue(), 25); - assertEquals(event.getProgressMaximum(), 55); - assertEquals(event.getStatusMessage(), text); - assertFalse(event.isWarning()); - } - catch (final InterruptedException e) { - e.printStackTrace(); - fail(); - } + final StatusEvent event = queue.poll(10, TimeUnit.SECONDS); + assertEquals(event.getProgressValue(), 25); + assertEquals(event.getProgressMaximum(), 55); + assertEquals(event.getStatusMessage(), text); + assertFalse(event.isWarning()); } @Test - public void testWarn() { + public void testWarn() throws InterruptedException { final String text = "Totally hosed"; ss.warn(text); - try { - final StatusEvent event = queue.poll(10, TimeUnit.SECONDS); - assertEquals(event.getStatusMessage(), text); - assertTrue(event.isWarning()); - } - catch (final InterruptedException e) { - e.printStackTrace(); - fail(); - } + final StatusEvent event = queue.poll(10, TimeUnit.SECONDS); + assertEquals(event.getStatusMessage(), text); + assertTrue(event.isWarning()); } @Test - public void testShowStatusIntIntStringBoolean() { + public void testShowStatusIntIntStringBoolean() throws InterruptedException { final String text = "Working and hosed..."; ss.showStatus(33, 44, text, true); - try { - final StatusEvent event = queue.poll(10, TimeUnit.SECONDS); - assertEquals(event.getStatusMessage(), text); - assertEquals(event.getProgressValue(), 33); - assertEquals(event.getProgressMaximum(), 44); - assertTrue(event.isWarning()); - } - catch (final InterruptedException e) { - e.printStackTrace(); - fail(); - } + final StatusEvent event = queue.poll(10, TimeUnit.SECONDS); + assertEquals(event.getStatusMessage(), text); + assertEquals(event.getProgressValue(), 33); + assertEquals(event.getProgressMaximum(), 44); + assertTrue(event.isWarning()); } @Test - public void testClearStatus() { + public void testClearStatus() throws InterruptedException { ss.clearStatus(); - try { - final StatusEvent event = queue.poll(10, TimeUnit.SECONDS); - assertEquals(event.getStatusMessage(), ""); - assertFalse(event.isWarning()); - } - catch (final InterruptedException e) { - e.printStackTrace(); - fail(); - } + final StatusEvent event = queue.poll(10, TimeUnit.SECONDS); + assertEquals(event.getStatusMessage(), ""); + assertFalse(event.isWarning()); } } From 24790f3db7e0e0b086e98634e8280f87c36b44fa Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 13:48:19 -0500 Subject: [PATCH 0331/1208] StatusServiceTest: clean up context setup/teardown --- src/test/java/org/scijava/app/StatusServiceTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/scijava/app/StatusServiceTest.java b/src/test/java/org/scijava/app/StatusServiceTest.java index 66ec12c79..674fc5365 100644 --- a/src/test/java/org/scijava/app/StatusServiceTest.java +++ b/src/test/java/org/scijava/app/StatusServiceTest.java @@ -40,6 +40,7 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.TimeUnit; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.scijava.AbstractContextual; @@ -79,7 +80,7 @@ private void eventHandler(final StatusEvent e) { } @Before - public void setUp() throws Exception { + public void setUp() { context = new Context(); queue = new ArrayBlockingQueue<>(10); statusListener = new StatusListener(); @@ -87,6 +88,11 @@ public void setUp() throws Exception { ss = statusListener.statusService; } + @After + public void tearDown() { + context.dispose(); + } + @Test public void testShowProgress() throws InterruptedException { ss.showProgress(15, 45); From 537fc20e8d83eb73e9a90d52f4703718ff066528 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 30 Aug 2016 10:35:12 -0500 Subject: [PATCH 0332/1208] ArrayUtils: add method for easily creating arrays I don't know if heap pollution is a potential problem here. But the method sure is mighty convenient... so here we go. --- src/main/java/org/scijava/util/ArrayUtils.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/scijava/util/ArrayUtils.java b/src/main/java/org/scijava/util/ArrayUtils.java index 34e6169bf..b53426756 100644 --- a/src/main/java/org/scijava/util/ArrayUtils.java +++ b/src/main/java/org/scijava/util/ArrayUtils.java @@ -79,6 +79,12 @@ private ArrayUtils() { // -- ArrayUtils methods -- + /** Creates an array of the given type, containing the specified values. */ + @SafeVarargs + public static T[] array(final T... values) { + return values; + } + /** * Converts the provided Object to a {@link Collection} implementation. If the * object is an array type, a {@link PrimitiveArray} wrapper will be created. From aa8be0f3588fd7d57a30b7282b6bd8c94ced6438 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 14:00:41 -0500 Subject: [PATCH 0333/1208] ContextCreationTest: remove unneeded method Now that we have the handy ArrayUtils.array method, we can ditch the less general services helper method. --- .../java/org/scijava/ContextCreationTest.java | 49 +++++++------------ 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/src/test/java/org/scijava/ContextCreationTest.java b/src/test/java/org/scijava/ContextCreationTest.java index 5b6ca51a0..97caa7f8c 100644 --- a/src/test/java/org/scijava/ContextCreationTest.java +++ b/src/test/java/org/scijava/ContextCreationTest.java @@ -38,6 +38,7 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.scijava.util.ArrayUtils.array; import java.util.Arrays; import java.util.List; @@ -285,33 +286,32 @@ public void testNonStrictOptionalMissingTransitive() { * Verifies that the order plugins appear in the PluginIndex and Service list * does not affect which services are loaded. */ - @SuppressWarnings("unchecked") @Test public void testClassOrder() { final int expectedSize = 2; // Same order, Base first - Context c = - createContext(pluginIndex(BaseImpl.class, ExtensionImpl.class), services( - BaseService.class, ExtensionService.class)); + Context c = createContext(// + pluginIndex(BaseImpl.class, ExtensionImpl.class), // + array(BaseService.class, ExtensionService.class)); assertEquals(expectedSize, c.getServiceIndex().size()); // Same order, Extension first - c = - createContext(pluginIndex(ExtensionImpl.class, BaseImpl.class), services( - ExtensionService.class, BaseService.class)); + c = createContext(// + pluginIndex(ExtensionImpl.class, BaseImpl.class), // + array(ExtensionService.class, BaseService.class)); assertEquals(expectedSize, c.getServiceIndex().size()); // Different order, Extension first - c = - createContext(pluginIndex(ExtensionImpl.class, BaseImpl.class), services( - BaseService.class, ExtensionService.class)); + c = createContext(// + pluginIndex(ExtensionImpl.class, BaseImpl.class), // + array(BaseService.class, ExtensionService.class)); assertEquals(expectedSize, c.getServiceIndex().size()); // Different order, Base first - c = - createContext(pluginIndex(BaseImpl.class, ExtensionImpl.class), services( - ExtensionService.class, BaseService.class)); + c = createContext(// + pluginIndex(BaseImpl.class, ExtensionImpl.class), // + array(ExtensionService.class, BaseService.class)); assertEquals(expectedSize, c.getServiceIndex().size()); } @@ -319,16 +319,15 @@ public void testClassOrder() { * Verifies that the Service index created when using Abstract classes is the * same as for interfaces. */ - @SuppressWarnings("unchecked") @Test public void testAbstractClasslist() { - final Context cAbstract = - createContext(pluginIndex(BaseImpl.class, ExtensionImpl.class), services( - AbstractBase.class, AbstractExtension.class)); + final Context cAbstract = createContext(// + pluginIndex(BaseImpl.class, ExtensionImpl.class), // + array(AbstractBase.class, AbstractExtension.class)); - final Context cService = - createContext(pluginIndex(BaseImpl.class, ExtensionImpl.class), services( - BaseService.class, ExtensionService.class)); + final Context cService = createContext(// + pluginIndex(BaseImpl.class, ExtensionImpl.class), // + array(BaseService.class, ExtensionService.class)); assertEquals(cService.getServiceIndex().size(), cAbstract.getServiceIndex() .size()); @@ -423,16 +422,6 @@ private Context createContext(final PluginIndex index, index); } - /** - * Convenience method since you can't instantiate a Class - * array. - */ - private Class[] services( - final Class... serviceClasses) - { - return serviceClasses; - } - /** * Creates a PluginIndex and adds all the provided classes as plugins, indexed * under Service.class From 640782f64278cb87fa926b648e9968d19ed2a14e Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 12:35:36 -0500 Subject: [PATCH 0334/1208] Make the HeadlessUI a real boy The HeadlessUI is now a SciJava UserInterface plugin, just like any other user interface. This is useful because while we want it to always be chosen when headless mode is active, it should also be used in non-headless mode when nothing else is available. This will help prevent NPEs etc. in UIService method calls. Consequently, this commit adds some defensive checks to DefaultUIService. These are needed now with the new HeadlessUI, because that UI returns null for methods like dialogPrompt -- something that no other UIs did previously. In other words: we relaxed the postconditions of some UserInterface methods to allow for null returns, and therefore the DefaultUIService needs to behave accordingly, handling those nulls. --- .../java/org/scijava/ui/DefaultUIService.java | 13 +-- .../org/scijava/ui/headlessUI/HeadlessUI.java | 99 ++----------------- 2 files changed, 13 insertions(+), 99 deletions(-) diff --git a/src/main/java/org/scijava/ui/DefaultUIService.java b/src/main/java/org/scijava/ui/DefaultUIService.java index aa56bac0f..66f81401c 100644 --- a/src/main/java/org/scijava/ui/DefaultUIService.java +++ b/src/main/java/org/scijava/ui/DefaultUIService.java @@ -189,7 +189,7 @@ public boolean isHeadless() { @Override public UserInterface getDefaultUI() { - if (isHeadless()) return HeadlessUI.getInstance(); + if (isHeadless()) return uiMap().get(HeadlessUI.NAME); if (defaultUI != null) return defaultUI; return uiList().isEmpty() ? null : uiList().get(0); } @@ -302,14 +302,13 @@ public DialogPrompt.Result showDialog(final String message, if (ui == null) return null; final DialogPrompt dialogPrompt = ui.dialogPrompt(message, title, messageType, optionType); - return dialogPrompt.prompt(); + return dialogPrompt == null ? null : dialogPrompt.prompt(); } @Override public File chooseFile(final File file, final String style) { final UserInterface ui = getDefaultUI(); - if (ui == null) return null; - return ui.chooseFile(file, style); + return ui == null ? null : ui.chooseFile(file, style); } @Override @@ -317,8 +316,7 @@ public File chooseFile(final File file, final String style) { chooseFile(final String title, final File file, final String style) { final UserInterface ui = getDefaultUI(); - if (ui == null) return null; - return ui.chooseFile(title, file, style); + return ui == null ? null : ui.chooseFile(title, file, style); } @Override @@ -326,8 +324,7 @@ public void showContextMenu(final String menuRoot, final Display display, final int x, final int y) { final UserInterface ui = getDefaultUI(); - if (ui == null) return; - ui.showContextMenu(menuRoot, display, x, y); + if (ui != null) ui.showContextMenu(menuRoot, display, x, y); } @Override diff --git a/src/main/java/org/scijava/ui/headlessUI/HeadlessUI.java b/src/main/java/org/scijava/ui/headlessUI/HeadlessUI.java index 844d4b77b..167e4e5ed 100644 --- a/src/main/java/org/scijava/ui/headlessUI/HeadlessUI.java +++ b/src/main/java/org/scijava/ui/headlessUI/HeadlessUI.java @@ -31,21 +31,14 @@ package org.scijava.ui.headlessUI; -import static org.scijava.Priority.LAST_PRIORITY; - import java.io.File; -import org.scijava.Context; +import org.scijava.Priority; import org.scijava.display.Display; -import org.scijava.plugin.PluginInfo; -import org.scijava.ui.ApplicationFrame; -import org.scijava.ui.Desktop; +import org.scijava.plugin.AbstractRichPlugin; +import org.scijava.plugin.Plugin; import org.scijava.ui.DialogPrompt; -import org.scijava.ui.StatusBar; -import org.scijava.ui.SystemClipboard; -import org.scijava.ui.ToolBar; import org.scijava.ui.UserInterface; -import org.scijava.ui.console.ConsolePane; import org.scijava.ui.viewer.DisplayWindow; /** @@ -53,20 +46,13 @@ * running headless * * @author Richard Domander (Royal Veterinary College, London) + * @author Curtis Rueden */ -public class HeadlessUI implements UserInterface { - - private static HeadlessUI instance; +@Plugin(type = UserInterface.class, name = HeadlessUI.NAME, + priority = Priority.VERY_LOW_PRIORITY) +public class HeadlessUI extends AbstractRichPlugin implements UserInterface { - private HeadlessUI() {} - - public static HeadlessUI getInstance() { - if (instance == null) { - instance = new HeadlessUI(); - } - - return instance; - } + public static final String NAME = "headless"; @Override public void show() {} @@ -76,45 +62,12 @@ public boolean isVisible() { return false; } - @Override - public void show(final Object o) {} - @Override public void show(final String name, final Object o) {} @Override public void show(final Display display) {} - @Override - public Desktop getDesktop() { - return null; - } - - @Override - public ApplicationFrame getApplicationFrame() { - return null; - } - - @Override - public ToolBar getToolBar() { - return null; - } - - @Override - public StatusBar getStatusBar() { - return null; - } - - @Override - public ConsolePane getConsolePane() { - return null; - } - - @Override - public SystemClipboard getSystemClipboard() { - return null; - } - @Override public DisplayWindow createDisplayWindow(final Display display) { return null; @@ -128,11 +81,6 @@ public DialogPrompt dialogPrompt(final String message, final String title, return null; } - @Override - public File chooseFile(final File file, final String style) { - return null; - } - @Override public File chooseFile(final String title, final File file, final String style) @@ -156,37 +104,6 @@ public boolean requiresEDT() { return false; } - /** Returns null since this is a contextless null object */ - @Override - public Context context() { - return null; - } - - /** Returns null since this is a contextless null object */ - @Override - public Context getContext() { - return null; - } - - @Override - public void setContext(final Context context) {} - - @Override - public PluginInfo getInfo() { - return null; - } - - @Override - public void setInfo(final PluginInfo info) {} - @Override public void dispose() {} - - @Override - public double getPriority() { - return LAST_PRIORITY; - } - - @Override - public void setPriority(final double priority) {} } From 611eee2494fb93c70ac985a3a1b084cf6158c650 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 13:20:11 -0500 Subject: [PATCH 0335/1208] UIServiceTest: extract context setup/teardown --- .../java/org/scijava/ui/UIServiceTest.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/scijava/ui/UIServiceTest.java b/src/test/java/org/scijava/ui/UIServiceTest.java index f81442f36..204097876 100644 --- a/src/test/java/org/scijava/ui/UIServiceTest.java +++ b/src/test/java/org/scijava/ui/UIServiceTest.java @@ -34,6 +34,8 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.scijava.Context; import org.scijava.display.Display; @@ -44,14 +46,26 @@ * Tests for {@link DefaultUIService}. * * @author Richard Domander (Royal Veterinary College, London) + * @author Curtis Rueden */ public class UIServiceTest { + private Context context; + private UIService uiService; + + @Before + public void setUp() { + context = new Context(UIService.class); + uiService = context.service(UIService.class); + } + + @After + public void tearDown() { + context.dispose(); + } + @Test public void testHeadlessUI() { - final Context context = new Context(UIService.class); - final UIService uiService = context.service(UIService.class); - final MockUserInterface mockUI = new MockUserInterface(); uiService.setDefaultUI(mockUI); @@ -65,8 +79,6 @@ public void testHeadlessUI() { assertTrue(uiService.isHeadless()); assertTrue("UIService should return HeadlessUI when running \"headless\"", uiService.getDefaultUI() instanceof HeadlessUI); - - context.dispose(); } private static final class MockUserInterface extends AbstractUserInterface { From 57f764ddaae8f2eed5a199b8314866efad67e6d7 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 13:23:25 -0500 Subject: [PATCH 0336/1208] UIServiceTest: add a couple more tests --- src/test/java/org/scijava/ui/UIServiceTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/org/scijava/ui/UIServiceTest.java b/src/test/java/org/scijava/ui/UIServiceTest.java index 204097876..aef87bd99 100644 --- a/src/test/java/org/scijava/ui/UIServiceTest.java +++ b/src/test/java/org/scijava/ui/UIServiceTest.java @@ -31,9 +31,12 @@ package org.scijava.ui; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import java.util.List; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -64,6 +67,18 @@ public void tearDown() { context.dispose(); } + @Test + public void testDefaultUI() { + assertTrue(uiService.getDefaultUI() instanceof HeadlessUI); + } + + @Test + public void testAvailableUIs() { + final List uiList = uiService.getAvailableUIs(); + assertEquals(1, uiList.size()); + assertTrue(uiList.get(0) instanceof HeadlessUI); + } + @Test public void testHeadlessUI() { final MockUserInterface mockUI = new MockUserInterface(); From 51bb349c9b909e0e3c9660d358031db99a1127bd Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 14:26:52 -0500 Subject: [PATCH 0337/1208] POM: bump version to 2.60.0-SNAPSHOT The HeadlessUI is new API, so we bump the minor version. There is also a new ArrayUtils method. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 42082ee9a..d0e1b4e28 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.59.1-SNAPSHOT + 2.60.0-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by downstream projects in the SciJava ecosystem, such as ImageJ and SCIFIO. From dabb48aeb6b75937ef0d56ea9dd376ae6af2730f Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 14:45:42 -0500 Subject: [PATCH 0338/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d0e1b4e28..1fffb5592 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.60.0-SNAPSHOT + 2.60.1-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by downstream projects in the SciJava ecosystem, such as ImageJ and SCIFIO. From f485ee35bfd1cf277306e4ebc11e88d1d9996753 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 16:02:34 -0500 Subject: [PATCH 0339/1208] Remove unused imports --- src/main/java/org/scijava/ui/AbstractUserInterface.java | 2 -- src/test/java/org/scijava/test/AbstractSciJavaTest.java | 5 ----- 2 files changed, 7 deletions(-) diff --git a/src/main/java/org/scijava/ui/AbstractUserInterface.java b/src/main/java/org/scijava/ui/AbstractUserInterface.java index 7210682f0..2bae5bea8 100644 --- a/src/main/java/org/scijava/ui/AbstractUserInterface.java +++ b/src/main/java/org/scijava/ui/AbstractUserInterface.java @@ -33,8 +33,6 @@ import java.util.List; -import org.scijava.app.StatusService; -import org.scijava.command.CommandService; import org.scijava.display.Display; import org.scijava.display.DisplayService; import org.scijava.log.LogService; diff --git a/src/test/java/org/scijava/test/AbstractSciJavaTest.java b/src/test/java/org/scijava/test/AbstractSciJavaTest.java index c6cc2167a..1cc567e4c 100644 --- a/src/test/java/org/scijava/test/AbstractSciJavaTest.java +++ b/src/test/java/org/scijava/test/AbstractSciJavaTest.java @@ -31,16 +31,11 @@ package org.scijava.test; -import java.awt.Cursor; -import java.util.Random; - import org.junit.After; import org.junit.Before; import org.scijava.Context; import org.scijava.plugin.Parameter; import org.scijava.service.Service; -import org.scijava.util.ByteArray; -import org.scijava.util.FloatArray; /** * Base class for unit testing of SciJava components. From a94ff04af66474e25c484378814c8351bb9640fa Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 2 Sep 2016 16:03:19 -0500 Subject: [PATCH 0340/1208] App: remove redundant superinterface --- src/main/java/org/scijava/app/App.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/app/App.java b/src/main/java/org/scijava/app/App.java index 2bfee1844..e5aad2949 100644 --- a/src/main/java/org/scijava/app/App.java +++ b/src/main/java/org/scijava/app/App.java @@ -33,7 +33,6 @@ import java.io.File; -import org.scijava.Versioned; import org.scijava.plugin.Plugin; import org.scijava.plugin.RichPlugin; import org.scijava.plugin.SingletonPlugin; @@ -54,7 +53,7 @@ * @see Plugin * @see AppService */ -public interface App extends RichPlugin, SingletonPlugin, Versioned { +public interface App extends RichPlugin, SingletonPlugin { /** Gets the title of the application. */ String getTitle(); From e3453f26f2be119cbf0a48f812913df89f45321f Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Sat, 3 Sep 2016 16:29:17 -0500 Subject: [PATCH 0341/1208] StderrLogService: use stdout non-severe messages The logging page at http://imagej.net/Logging states that severe logging messages (WARN and ERROR levels) are emitted to stderr, while less severe ones (INFO and DEBUG levels) are emitted to stdout. This was not actually true with the default LogService implementation. This commit addresses the situation. Originally, I planned to make this change with SciJava Common 3.0.0, because I thought we would need to break backwards compatibility to achieve it. But actually, the change was easy to make in a smooth manner. SJC3 will see a cleanup of the logging API, but that cleanup is not a prerequisite to fixing the situation with stdout + stderr. Thanks to Florian Jug for spurring this change. --- .../java/org/scijava/log/StderrLogService.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/org/scijava/log/StderrLogService.java b/src/main/java/org/scijava/log/StderrLogService.java index 5d7fc4688..23da68cb6 100644 --- a/src/main/java/org/scijava/log/StderrLogService.java +++ b/src/main/java/org/scijava/log/StderrLogService.java @@ -37,6 +37,11 @@ /** * Implementation of {@link LogService} using the standard error stream. + *

    + * Actually, this service is somewhat misnamed now, since it prints {@code WARN} + * and {@code ERROR} messages to stderr, but messages at lesser severities to + * stdout. + *

    * * @author Johannes Schindelin * @author Curtis Rueden @@ -44,6 +49,15 @@ @Plugin(type = Service.class, priority = Priority.LOW_PRIORITY) public class StderrLogService extends AbstractLogService { + @Override + protected void log(final int level, final Object msg) { + final String prefix = getPrefix(level); + final String message = (prefix == null ? "" : prefix + " ") + msg; + // NB: Emit severe messages to stderr, and less severe ones to stdout. + if (level <= WARN) System.err.println(message); + else System.out.println(message); + } + /** * Prints a message to stderr. * From c75c31fa6d1da59e33e19e46eb0fff298213bebc Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Sun, 4 Sep 2016 09:43:05 -0500 Subject: [PATCH 0342/1208] ScriptModule: tweak style --- src/main/java/org/scijava/script/ScriptModule.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptModule.java b/src/main/java/org/scijava/script/ScriptModule.java index 558eec7b6..458a249e0 100644 --- a/src/main/java/org/scijava/script/ScriptModule.java +++ b/src/main/java/org/scijava/script/ScriptModule.java @@ -158,7 +158,8 @@ public void run() { if (error != null) { scriptContext.setErrorWriter(error); errorPrinter = new PrintWriter(error); - } else { + } + else { errorPrinter = null; } @@ -179,11 +180,8 @@ public void run() { while (e instanceof ScriptException && e.getCause() != null) { e = e.getCause(); } - if (error == null) { - log.error(e); - } else { - e.printStackTrace(errorPrinter); - } + if (error == null) log.error(e); + else e.printStackTrace(errorPrinter); } // populate output values From a95a116978482934619ec6652042e3289b365c2e Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Sun, 4 Sep 2016 09:53:49 -0500 Subject: [PATCH 0343/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1fffb5592..d03ae872d 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.60.1-SNAPSHOT + 2.60.2-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by downstream projects in the SciJava ecosystem, such as ImageJ and SCIFIO. From 6d81fd7c2319d001dba3084579bc45b524ed8850 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 14 Sep 2016 21:59:25 -0700 Subject: [PATCH 0344/1208] Fix population of default values The logic was inverted since 14aa08f3ddcc845ab6ad89ce6f197d5de90fff54. Partially fixes #248. --- .../org/scijava/module/process/DefaultValuePreprocessor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java b/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java index 2bf08354e..07df44016 100644 --- a/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java +++ b/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java @@ -74,7 +74,7 @@ private void assignDefaultValue(final Module module, { if (module.isInputResolved(item.getName())) return; final T nullValue = ConversionUtils.getNullValue(item.getType()); - if (Objects.equals(item.getValue(module), nullValue)) return; + if (!Objects.equals(item.getValue(module), nullValue)) return; final T defaultValue = moduleService.getDefaultValue(item); if (defaultValue == null) return; item.setValue(module, defaultValue); From 103b326e6f3c8c54eecd34c85413a18cbd0a1cbd Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Fri, 16 Sep 2016 13:01:16 -0500 Subject: [PATCH 0345/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d03ae872d..45b9d9c07 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.60.2-SNAPSHOT + 2.60.3-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by downstream projects in the SciJava ecosystem, such as ImageJ and SCIFIO. From 20b4873c0938475b7b36081947b90938e1d533ee Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 21 Sep 2016 13:54:56 -0500 Subject: [PATCH 0346/1208] DefaultParseService: be defensive about null args It is not allowed to attempt to parse a null value. However, previously, the exception would come from deep inside SJEP. Let's fail fast instead. --- src/main/java/org/scijava/parse/DefaultParseService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/scijava/parse/DefaultParseService.java b/src/main/java/org/scijava/parse/DefaultParseService.java index 84db28d9b..bbc92f3f8 100644 --- a/src/main/java/org/scijava/parse/DefaultParseService.java +++ b/src/main/java/org/scijava/parse/DefaultParseService.java @@ -60,6 +60,7 @@ public Items parse(final String arg) { @Override public Items parse(final String arg, final boolean strict) { + if (arg == null) throw new NullPointerException("arg must not be null"); return new ItemsList(arg, strict); } From fe807dea47b09540e515af5669577cbb80244fe1 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 21 Sep 2016 13:53:06 -0500 Subject: [PATCH 0347/1208] RunArgument: fix NPE when no script args are given The intent was that you could write e.g.: myApp --run myScript Instead of requiring that an empty args list be passed like: myApp --run myScript '' But in practice, the former was generating a NullPointerException. --- .../java/org/scijava/run/console/RunArgument.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/scijava/run/console/RunArgument.java b/src/main/java/org/scijava/run/console/RunArgument.java index 729e5e385..ceec173f7 100644 --- a/src/main/java/org/scijava/run/console/RunArgument.java +++ b/src/main/java/org/scijava/run/console/RunArgument.java @@ -76,15 +76,17 @@ public void handle(final LinkedList args) { final String code = args.removeFirst(); final String arg = getParam(args); - final Items items = parser.parse(arg); try { if (arg == null) runService.run(code); - else if (items.isMap()) runService.run(code, items.asMap()); - else if (items.isList()) runService.run(code, items.toArray()); else { - throw new IllegalArgumentException("Arguments are inconsistent. " + - "Please pass either a list of key/value pairs, " + - "or a list of values."); + final Items items = parser.parse(arg); + if (items.isMap()) runService.run(code, items.asMap()); + else if (items.isList()) runService.run(code, items.toArray()); + else { + throw new IllegalArgumentException("Arguments are inconsistent. " + + "Please pass either a list of key/value pairs, " + + "or a list of values."); + } } } catch (final InvocationTargetException exc) { From ae5f92663fa5feda7ef5853521495299c9a24135 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 21 Sep 2016 13:57:21 -0500 Subject: [PATCH 0348/1208] RunArgument: fix bug when argument list is given When an argument list is provided, we need to remove it from the list of pending command line arguments to process. Otherwise, it will get "double" processed, which can result in various weirdness. For instance, in ImageJ2 with the legacy layer active, the class net.imagej.legacy.LegacyCommandline$Filename.handle would try to handle the empty string as a filename and then barf. --- src/main/java/org/scijava/run/console/RunArgument.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/scijava/run/console/RunArgument.java b/src/main/java/org/scijava/run/console/RunArgument.java index ceec173f7..429addb29 100644 --- a/src/main/java/org/scijava/run/console/RunArgument.java +++ b/src/main/java/org/scijava/run/console/RunArgument.java @@ -75,6 +75,7 @@ public void handle(final LinkedList args) { args.removeFirst(); // --run final String code = args.removeFirst(); final String arg = getParam(args); + if (arg != null) args.removeFirst(); // argument list was given try { if (arg == null) runService.run(code); From 0ddf72d30e32ebae45d841029f881a2b3d8839d6 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 29 Sep 2016 14:20:23 -0500 Subject: [PATCH 0349/1208] ScriptInfo: cache URL source, if given & relevant These days, the ScriptFinder discovers all scripts via the classpath as URL resources. Let's remember those in each ScriptInfo object. --- pom.xml | 2 +- .../java/org/scijava/script/ScriptInfo.java | 68 ++++++++++++++++++- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 45b9d9c07..bcc0a33c3 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.60.3-SNAPSHOT + 2.61.0-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by downstream projects in the SciJava ecosystem, such as ImageJ and SCIFIO. diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index 10c4dd07d..155a688bb 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -35,8 +35,11 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; +import java.net.MalformedURLException; +import java.net.URL; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -76,6 +79,7 @@ public class ScriptInfo extends AbstractModuleInfo implements Contextual { private static final int PARAM_CHAR_MAX = 640 * 1024; // should be enough ;-) + private final URL url; private final String path; private final String script; @@ -105,7 +109,7 @@ public class ScriptInfo extends AbstractModuleInfo implements Contextual { * @param file The script file. */ public ScriptInfo(final Context context, final File file) { - this(context, file.getPath()); + this(context, null, file.getPath(), null); } /** @@ -116,7 +120,23 @@ public ScriptInfo(final Context context, final File file) { * @param path Path to the script file. */ public ScriptInfo(final Context context, final String path) { - this(context, path, null); + this(context, null, path, null); + } + + /** + * Creates a script metadata object which describes a script at the given URL. + * + * @param context The SciJava application context to use when populating + * service inputs. + * @param url URL which references the script. + * @param path Pseudo-path to the script file. This file does not actually + * need to exist, but rather provides a name for the script with file + * extension. + */ + public ScriptInfo(final Context context, final URL url, final String path) + throws IOException + { + this(context, url, path, new InputStreamReader(url.openStream())); } /** @@ -132,9 +152,16 @@ public ScriptInfo(final Context context, final String path) { */ public ScriptInfo(final Context context, final String path, final Reader reader) + { + this(context, null, path, reader); + } + + private ScriptInfo(final Context context, final URL url, final String path, + final Reader reader) { setContext(context); - this.path = path; + this.url = url(url, path); + this.path = path(url, path); String contents = null; if (reader != null) { @@ -150,6 +177,26 @@ public ScriptInfo(final Context context, final String path, // -- ScriptInfo methods -- + /** + * Gets the URL of the script. + *

    + * If the actual source of the script is a URL (provided via + * {@link #ScriptInfo(Context, URL, String)}), then this will return it. + *

    + *

    + * Alternately, if the path (from {@link #getPath()}) is a real file on disk + * (provided via {@link #ScriptInfo(Context, File)} or + * {@link #ScriptInfo(Context, String)}), then the URL returned here will be a + * {@code file://} one reference to it. + *

    + *

    + * Otherwise, this method will return null. + *

    + */ + public URL getURL() { + return url; + } + /** * Gets the path to the script on disk. *

    @@ -332,6 +379,21 @@ public String getVersion() { // -- Helper methods -- + private URL url(final URL u, final String p) { + if (u != null) return u; + try { + return new File(p).toURI().toURL(); + } + catch (final MalformedURLException exc) { + log.debug("Cannot glean URL from path: " + p, exc); + return null; + } + } + + private String path(final URL u, final String p) { + return p == null ? u.getPath() : p; + } + private void parseParam(final String param) throws ScriptException { final int lParen = param.indexOf("("); final int rParen = param.lastIndexOf(")"); From 76b015635a50cf99ca29d68cb08bcf091d460d8b Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 29 Sep 2016 14:22:52 -0500 Subject: [PATCH 0350/1208] ScriptFinder: remember the URL for each script Previously, we threw away the URL references. It's nicer to keep them. --- src/main/java/org/scijava/script/ScriptFinder.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptFinder.java b/src/main/java/org/scijava/script/ScriptFinder.java index 5766b2086..6e9484b34 100644 --- a/src/main/java/org/scijava/script/ScriptFinder.java +++ b/src/main/java/org/scijava/script/ScriptFinder.java @@ -33,7 +33,6 @@ import java.io.File; import java.io.IOException; -import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.util.Collections; @@ -191,8 +190,7 @@ private int createInfos(final List scripts, final Set urls, urls.add(url); try { - final ScriptInfo info = new ScriptInfo(getContext(), // - path, new InputStreamReader(url.openStream())); + final ScriptInfo info = new ScriptInfo(getContext(), url, path); info.setMenuPath(menuPath); From 5f7d51840e04d94a1d7b24b5e49d63aeb46ae9c3 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 29 Sep 2016 14:28:11 -0500 Subject: [PATCH 0351/1208] ScriptFinderTest: test that the URLs are retained --- .../java/org/scijava/script/ScriptFinderTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/org/scijava/script/ScriptFinderTest.java b/src/test/java/org/scijava/script/ScriptFinderTest.java index a860dde8c..8f6276f83 100644 --- a/src/test/java/org/scijava/script/ScriptFinderTest.java +++ b/src/test/java/org/scijava/script/ScriptFinderTest.java @@ -32,6 +32,7 @@ package org.scijava.script; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; @@ -114,6 +115,7 @@ public void testFindScripts() { "Math > Trig > tan", // }; assertMenuPaths(expected, scripts); + assertURLsMatch(scripts); } /** @@ -148,6 +150,7 @@ public void testMenuPrefixes() { "Foo > Bar > Math > Trig > tan", // }; assertMenuPaths(expected, scripts); + assertURLsMatch(scripts); } /** @@ -181,6 +184,7 @@ public void testOverlappingDirectories() { "Math > Trig > tan", // }; assertMenuPaths(expected, scripts); + assertURLsMatch(scripts); } // -- Helper methods -- @@ -212,6 +216,14 @@ private void assertMenuPaths(final String[] expected, } } + private void assertURLsMatch(final ArrayList scripts) { + for (final ScriptInfo info : scripts) { + final String urlPath = info.getURL().getPath(); + final String path = info.getPath(); + assertTrue(urlPath + " <> " + path, urlPath.endsWith("/" + path)); + } + } + // -- Helper classes -- /** "Handles" scripts with .foo extension. */ From 1f41932e1bed748cc6ae34f87990535455fe788f Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 24 Oct 2016 13:03:40 -0500 Subject: [PATCH 0352/1208] ScriptREPL: catch exceptions for built-in commands Previously, we only caught exceptions when evaluating lines of script. But the built-ins can go wrong, too; e.g., when asking a script engine to do some operation which it does not support. So let's just always catch all exceptions when talking to the script engines, to make a best effort to recover nicely whenever possible. Note that this patch is mostly indentation changes; use "git diff -b" to see the true scope of the changes more easily. --- .../java/org/scijava/script/ScriptREPL.java | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptREPL.java b/src/main/java/org/scijava/script/ScriptREPL.java index 931f8fb8d..b6ed9eb28 100644 --- a/src/main/java/org/scijava/script/ScriptREPL.java +++ b/src/main/java/org/scijava/script/ScriptREPL.java @@ -167,37 +167,37 @@ public void prompt() { * @return False iff the REPL should exit. */ public boolean evaluate(final String line) { - final String tLine = line.trim(); - if (tLine.equals(":help")) help(); - else if (tLine.equals(":vars")) vars(); - else if (tLine.equals(":langs")) langs(); - else if (tLine.startsWith(":lang ")) lang(line.substring(6).trim()); - else if (tLine.equals(":quit")) return false; - else { - // ensure that a script language is active - if (interpreter == null) return true; - - // pass the input to the current interpreter for evaluation - try { + try { + final String tLine = line.trim(); + if (tLine.equals(":help")) help(); + else if (tLine.equals(":vars")) vars(); + else if (tLine.equals(":langs")) langs(); + else if (tLine.startsWith(":lang ")) lang(line.substring(6).trim()); + else if (tLine.equals(":quit")) return false; + else { + // ensure that a script language is active + if (interpreter == null) return true; + + // pass the input to the current interpreter for evaluation final Object result = interpreter.interpret(line); if (result != ScriptInterpreter.MORE_INPUT_PENDING) { out.println(s(result)); } } - catch (final ScriptException exc) { - // NB: Something went wrong interpreting the line of code. - // Let's just display the error message, unless we are in debug mode. - if (log.isDebug()) exc.printStackTrace(out); - else { - final String msg = exc.getMessage(); - out.println(msg == null ? exc.getClass().getName() : msg); - } - } - catch (final Throwable exc) { - // NB: Something unusual went wrong. Dump the whole exception always. - exc.printStackTrace(out); + } + catch (final ScriptException exc) { + // NB: Something went wrong interpreting the line of code. + // Let's just display the error message, unless we are in debug mode. + if (log.isDebug()) exc.printStackTrace(out); + else { + final String msg = exc.getMessage(); + out.println(msg == null ? exc.getClass().getName() : msg); } } + catch (final Throwable exc) { + // NB: Something unusual went wrong. Dump the whole exception always. + exc.printStackTrace(out); + } return true; } From bee1d56b46d0d84f27d38f5398bc5d7ba6e486ca Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 24 Oct 2016 13:48:01 -0500 Subject: [PATCH 0353/1208] ScriptREPL: dump exceptions to the OutputStream We don't want to use the log, but rather the designated stream. --- src/main/java/org/scijava/script/ScriptREPL.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/script/ScriptREPL.java b/src/main/java/org/scijava/script/ScriptREPL.java index b6ed9eb28..f3e409fea 100644 --- a/src/main/java/org/scijava/script/ScriptREPL.java +++ b/src/main/java/org/scijava/script/ScriptREPL.java @@ -341,7 +341,7 @@ private List gateways() { gateways.add(gateway); } catch (final Throwable t) { - if (log != null) log.error(t); + t.printStackTrace(out); } } return gateways; From 1aea31a94e34aca71ab69955457427afd1d27b29 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 24 Oct 2016 13:47:15 -0500 Subject: [PATCH 0354/1208] ScriptREPL: implement a local debug mode Instead of asking the LogService for whether it is in debug mode, let's just have our own debug flag, which can be toggled via the REPL itself. This is more convenient for the REPL user. --- src/main/java/org/scijava/script/ScriptREPL.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptREPL.java b/src/main/java/org/scijava/script/ScriptREPL.java index f3e409fea..399dcec56 100644 --- a/src/main/java/org/scijava/script/ScriptREPL.java +++ b/src/main/java/org/scijava/script/ScriptREPL.java @@ -46,7 +46,6 @@ import org.scijava.Context; import org.scijava.Gateway; -import org.scijava.log.LogService; import org.scijava.plugin.Parameter; import org.scijava.plugin.PluginInfo; import org.scijava.plugin.PluginService; @@ -70,9 +69,6 @@ public class ScriptREPL { @Parameter(required = false) private PluginService pluginService; - @Parameter(required = false) - private LogService log; - private final PrintStream out; /** List of interpreter-friendly script languages. */ @@ -81,6 +77,9 @@ public class ScriptREPL { /** The currently active interpreter. */ private ScriptInterpreter interpreter; + /** Flag for debug mode. */ + private boolean debug; + public ScriptREPL(final Context context) { this(context, System.out); } @@ -172,6 +171,7 @@ public boolean evaluate(final String line) { if (tLine.equals(":help")) help(); else if (tLine.equals(":vars")) vars(); else if (tLine.equals(":langs")) langs(); + else if (tLine.equals(":debug")) debug(); else if (tLine.startsWith(":lang ")) lang(line.substring(6).trim()); else if (tLine.equals(":quit")) return false; else { @@ -188,7 +188,7 @@ public boolean evaluate(final String line) { catch (final ScriptException exc) { // NB: Something went wrong interpreting the line of code. // Let's just display the error message, unless we are in debug mode. - if (log.isDebug()) exc.printStackTrace(out); + if (debug) exc.printStackTrace(out); else { final String msg = exc.getMessage(); out.println(msg == null ? exc.getClass().getName() : msg); @@ -211,6 +211,7 @@ public void help() { out.println(" :vars | dump a list of variables"); out.println(" :lang | switch the active language"); out.println(" :langs | list available languages"); + out.println(" :debug | toggle full stack traces"); out.println(" :quit | exit the REPL"); out.println(); out.println("Or type a statement to evaluate it with the active language."); @@ -269,6 +270,11 @@ public void langs() { printColumns(names, versions, aliases); } + public void debug() { + debug = !debug; + out.println("debug mode -> " + debug); + } + // -- Main method -- public static void main(final String... args) throws Exception { From 1215dd8b623e5fc778d92c2b2365266617924210 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 24 Oct 2016 13:48:23 -0500 Subject: [PATCH 0355/1208] ScriptREPL: recover gracefully from failed copy When copying variables between languages, if something goes wrong, let's just catch it, dump the error, and try to continue. Otherwise, the language switch operation will completely fail. --- src/main/java/org/scijava/script/ScriptREPL.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/script/ScriptREPL.java b/src/main/java/org/scijava/script/ScriptREPL.java index 399dcec56..95a7a6a0e 100644 --- a/src/main/java/org/scijava/script/ScriptREPL.java +++ b/src/main/java/org/scijava/script/ScriptREPL.java @@ -252,7 +252,12 @@ public void lang(final String langName) { new DefaultScriptInterpreter(language); // preserve state of the previous interpreter - copyBindings(interpreter, newInterpreter); + try { + copyBindings(interpreter, newInterpreter); + } + catch (final Throwable t) { + t.printStackTrace(out); + } out.println("language -> " + newInterpreter.getLanguage().getLanguageName()); interpreter = newInterpreter; From 102329f23f92fd57d1af9e659bb0afd0e1f80d56 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 26 Oct 2016 10:56:20 -0500 Subject: [PATCH 0356/1208] MenuPath: add option to trim, or not, as desired --- src/main/java/org/scijava/MenuPath.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/MenuPath.java b/src/main/java/org/scijava/MenuPath.java index ebd245ff6..f53f5cb1a 100644 --- a/src/main/java/org/scijava/MenuPath.java +++ b/src/main/java/org/scijava/MenuPath.java @@ -74,10 +74,20 @@ public MenuPath(final String path) { * the specified separator. */ public MenuPath(final String path, final String separator) { + this(path, separator, true); + } + + /** + * Creates a menu path with entries parsed from the given string, splitting on + * the specified separator, and trimming whitespace if indicated. + */ + public MenuPath(final String path, final String separator, + final boolean trim) + { if (path != null && !path.isEmpty()) { final String[] tokens = path.split(separator); for (final String token : tokens) { - add(new MenuEntry(token.trim())); + add(new MenuEntry(trim ? token.trim() : token)); } } } From 4202cc9d9e58de2203ea593ebb284cb27a7f4112 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 26 Oct 2016 10:56:48 -0500 Subject: [PATCH 0357/1208] ScriptFinder: do not trim script menu paths Otherwise, e.g., trailing spaces converted from underscores are lost. --- src/main/java/org/scijava/script/ScriptFinder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/script/ScriptFinder.java b/src/main/java/org/scijava/script/ScriptFinder.java index 6e9484b34..951cda817 100644 --- a/src/main/java/org/scijava/script/ScriptFinder.java +++ b/src/main/java/org/scijava/script/ScriptFinder.java @@ -172,7 +172,7 @@ private int createInfos(final List scripts, final Set urls, final String friendlyPath = basePath.replace('_', ' '); final MenuPath menuPath = new MenuPath(menuPrefix); - menuPath.addAll(new MenuPath(friendlyPath, "/")); + menuPath.addAll(new MenuPath(friendlyPath, "/", false)); // E.g.: // path = "File/Import/Movie_File....groovy" From d17d2cad603b24fe2f0e4490c1c0a71c2102ec3c Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 26 Oct 2016 13:54:13 -0500 Subject: [PATCH 0358/1208] Bump to next development cycle Signed-off-by: Jenkins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bcc0a33c3..571f9d3e3 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.61.0-SNAPSHOT + 2.61.1-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by downstream projects in the SciJava ecosystem, such as ImageJ and SCIFIO. From d52961bd49a3a0155cbc706b830becad870a339c Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Sat, 19 Nov 2016 22:51:01 -0600 Subject: [PATCH 0359/1208] Update parent to pom-scijava 12.0.0 This version is a major update to the SciJava Bill of Materials; see: http://forum.imagej.net/t/split-boms-from-parent-configuration/2563 --- pom.xml | 16 +++++++++++++++- src/test/java/org/scijava/util/POMTest.java | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 571f9d3e3..edf8dccd4 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.scijava pom-scijava - 11.2.1 + 12.0.0 @@ -16,6 +16,10 @@ SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by downstream projects in the SciJava ecosystem, such as ImageJ and SCIFIO. http://scijava.org/ 2009 + + SciJava + http://www.scijava.org/ + Simplified BSD License @@ -91,6 +95,16 @@ + + + SciJava + https://groups.google.com/group/scijava + https://groups.google.com/group/scijava + scijava@googlegroups.com + https://groups.google.com/group/scijava + + + scm:git:git://github.com/scijava/scijava-common scm:git:git@github.com:scijava/scijava-common diff --git a/src/test/java/org/scijava/util/POMTest.java b/src/test/java/org/scijava/util/POMTest.java index 9964478e4..f54d3ff7f 100644 --- a/src/test/java/org/scijava/util/POMTest.java +++ b/src/test/java/org/scijava/util/POMTest.java @@ -103,8 +103,8 @@ public void testAccessors() throws ParserConfigurationException, final String issueManagementURL = pom.getIssueManagementURL(); assertEquals("https://github.com/scijava/scijava-common/issues", issueManagementURL); - assertNull(pom.getOrganizationName()); - assertNull(pom.getOrganizationURL()); + assertEquals("SciJava", pom.getOrganizationName()); + assertEquals("http://www.scijava.org/", pom.getOrganizationURL()); assertTrue(pom.getPath().endsWith("pom.xml")); assertTrue(pom.getProjectDescription().startsWith( "SciJava Common is a shared library for SciJava software.")); From 66ed844ee76a264ca83629f0fef50c9b726c8897 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Mon, 12 Dec 2016 15:32:23 +0100 Subject: [PATCH 0360/1208] Add a rudimentary input validation mechanism Now, if you want to validate that the value of an input is acceptable, you can specify a validater method which will be called when that input is marked as resolved. Admittedly, this is a bit late in the module execution process, and dynamic validation would still be nice in the future (e.g., to provide feedback as values are updated in input harvester UIs). But the good thing about this scheme is that regardless of which preprocessor locks in the parameter value, validation will be called immediately afterward, before the next preprocessor runs. Thanks to Richard Domander for the idea and discussion. --- .../org/scijava/command/CommandModuleItem.java | 5 +++++ .../java/org/scijava/module/AbstractModule.java | 16 ++++++++++++++++ .../org/scijava/module/AbstractModuleItem.java | 15 +++++++++++++++ .../scijava/module/DefaultMutableModuleItem.java | 11 +++++++++++ src/main/java/org/scijava/module/ModuleItem.java | 10 ++++++++++ .../org/scijava/module/MutableModuleItem.java | 2 ++ src/main/java/org/scijava/plugin/Parameter.java | 9 +++++++++ src/main/java/org/scijava/script/ScriptInfo.java | 1 + 8 files changed, 69 insertions(+) diff --git a/src/main/java/org/scijava/command/CommandModuleItem.java b/src/main/java/org/scijava/command/CommandModuleItem.java index 9752fad33..79b9424e8 100644 --- a/src/main/java/org/scijava/command/CommandModuleItem.java +++ b/src/main/java/org/scijava/command/CommandModuleItem.java @@ -123,6 +123,11 @@ public String getInitializer() { return getParameter().initializer(); } + @Override + public String getValidater() { + return getParameter().validater(); + } + @Override public String getCallback() { return getParameter().callback(); diff --git a/src/main/java/org/scijava/module/AbstractModule.java b/src/main/java/org/scijava/module/AbstractModule.java index 77948a285..41ecf2eb9 100644 --- a/src/main/java/org/scijava/module/AbstractModule.java +++ b/src/main/java/org/scijava/module/AbstractModule.java @@ -149,6 +149,16 @@ public boolean isOutputResolved(final String name) { @Override public void resolveInput(final String name) { + final ModuleItem item = getInputItem(name); + if (item != null) { + try { + item.validate(this); + } + catch (final MethodCallException exc) { + // NB: Hacky, but avoids changing the API signature. + throw new RuntimeException(exc); + } + } resolvedInputs.add(name); } @@ -181,4 +191,10 @@ private Map createMap(final Iterable> items, return map; } + private ModuleItem getInputItem(final String name) { + for (final ModuleItem item : getInfo().inputs()) { + if (item.getName().equals(name)) return item; + } + return null; + } } diff --git a/src/main/java/org/scijava/module/AbstractModuleItem.java b/src/main/java/org/scijava/module/AbstractModuleItem.java index c6d84537d..f29453329 100644 --- a/src/main/java/org/scijava/module/AbstractModuleItem.java +++ b/src/main/java/org/scijava/module/AbstractModuleItem.java @@ -56,6 +56,7 @@ public abstract class AbstractModuleItem extends AbstractBasicDetails private final ModuleInfo info; private MethodRef initializerRef; + private MethodRef validaterRef; private MethodRef callbackRef; public AbstractModuleItem(final ModuleInfo info) { @@ -200,6 +201,20 @@ public void initialize(final Module module) throws MethodCallException { initializerRef.execute(module.getDelegateObject()); } + @Override + public String getValidater() { + return null; + } + + @Override + public void validate(final Module module) throws MethodCallException { + final Object delegateObject = module.getDelegateObject(); + if (validaterRef == null) { + validaterRef = new MethodRef(delegateObject.getClass(), getValidater()); + } + validaterRef.execute(module.getDelegateObject()); + } + @Override public String getCallback() { return null; diff --git a/src/main/java/org/scijava/module/DefaultMutableModuleItem.java b/src/main/java/org/scijava/module/DefaultMutableModuleItem.java index 4d95ed91e..a627750a2 100644 --- a/src/main/java/org/scijava/module/DefaultMutableModuleItem.java +++ b/src/main/java/org/scijava/module/DefaultMutableModuleItem.java @@ -57,6 +57,7 @@ public class DefaultMutableModuleItem extends AbstractModuleItem private boolean persisted; private String persistKey; private String initializer; + private String validater; private String callback; private String widgetStyle; private T defaultValue; @@ -162,6 +163,11 @@ public void setInitializer(final String initializer) { this.initializer = initializer; } + @Override + public void setValidater(final String validater) { + this.validater = validater; + } + @Override public void setCallback(final String callback) { this.callback = callback; @@ -255,6 +261,11 @@ public String getInitializer() { return initializer; } + @Override + public String getValidater() { + return validater; + } + @Override public String getCallback() { return callback; diff --git a/src/main/java/org/scijava/module/ModuleItem.java b/src/main/java/org/scijava/module/ModuleItem.java index 087a03c8a..cdb439e16 100644 --- a/src/main/java/org/scijava/module/ModuleItem.java +++ b/src/main/java/org/scijava/module/ModuleItem.java @@ -123,6 +123,16 @@ public interface ModuleItem extends BasicDetails { */ void initialize(Module module) throws MethodCallException; + /** Gets the function that is called to validate the item's value. */ + String getValidater(); + + /** + * Invokes this item's validation function, if any, on the given module. + * + * @see #getValidater() + */ + void validate(Module module) throws MethodCallException; + /** * Gets the function that is called whenever this item changes. *

    diff --git a/src/main/java/org/scijava/module/MutableModuleItem.java b/src/main/java/org/scijava/module/MutableModuleItem.java index 3fd6df99d..3fc9e6d32 100644 --- a/src/main/java/org/scijava/module/MutableModuleItem.java +++ b/src/main/java/org/scijava/module/MutableModuleItem.java @@ -56,6 +56,8 @@ public interface MutableModuleItem extends ModuleItem { void setInitializer(String initializer); + void setValidater(String validater); + void setCallback(String callback); void setWidgetStyle(String widgetStyle); diff --git a/src/main/java/org/scijava/plugin/Parameter.java b/src/main/java/org/scijava/plugin/Parameter.java index 84e8eddbf..4fc208a94 100644 --- a/src/main/java/org/scijava/plugin/Parameter.java +++ b/src/main/java/org/scijava/plugin/Parameter.java @@ -38,6 +38,7 @@ import org.scijava.ItemIO; import org.scijava.ItemVisibility; +import org.scijava.module.Module; /** * An annotation for indicating a field is an input or output parameter. This @@ -119,6 +120,14 @@ /** Defines a function that is called to initialize the parameter. */ String initializer() default ""; + /** + * Defines a function that is called to validate the parameter value after it + * is marked as resolved. + * + * @see Module#resolveInput(String) + */ + String validater() default ""; + /** * Defines a function that is called whenever this parameter changes. *

    diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index 155a688bb..46194dcfe 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -488,6 +488,7 @@ private void assignAttribute(final DefaultMutableModuleItem item, else if (is(k, "columns")) item.setColumnCount(as(v, int.class)); else if (is(k, "description")) item.setDescription(as(v, String.class)); else if (is(k, "initializer")) item.setInitializer(as(v, String.class)); + else if (is(k, "validater")) item.setValidater(as(v, String.class)); else if (is(k, "type")) item.setIOType(as(v, ItemIO.class)); else if (is(k, "label")) item.setLabel(as(v, String.class)); else if (is(k, "max")) item.setMaximumValue(as(v, item.getType())); From 75146d3f6a5f9ec1b3ca572019033016536772fe Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 26 Oct 2016 21:21:33 -0500 Subject: [PATCH 0361/1208] ShadowMenu: reformat string concatenation --- src/main/java/org/scijava/menu/ShadowMenu.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/menu/ShadowMenu.java b/src/main/java/org/scijava/menu/ShadowMenu.java index 13745d286..ae2d92e5c 100644 --- a/src/main/java/org/scijava/menu/ShadowMenu.java +++ b/src/main/java/org/scijava/menu/ShadowMenu.java @@ -548,12 +548,14 @@ else if (existingChild != null) { final ModuleInfo childInfo = existingChild.getModuleInfo(); if (childInfo != null && info.getPriority() == childInfo.getPriority()) { - log.warn("ShadowMenu: menu item already exists:\n\texisting: " + - childInfo + "\n\t ignored: " + info); + log.warn("ShadowMenu: menu item already exists:\n" + // + "\texisting: " + childInfo + "\n" + // + "\t ignored: " + info); } else { log.debug("ShadowMenu: higher-priority menu item already exists:\n" + - "\texisting: " + childInfo + "\n\t ignored: " + info); + "\texisting: " + childInfo + "\n" + // + "\t ignored: " + info); } } } From a196883399bab4433466faa47fa26757bc151063 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 26 Oct 2016 21:23:14 -0500 Subject: [PATCH 0362/1208] ShadowMenu: give details on duplicates In particular, it helps to know which JAR file each entry came from. --- .../java/org/scijava/menu/ShadowMenu.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/scijava/menu/ShadowMenu.java b/src/main/java/org/scijava/menu/ShadowMenu.java index ae2d92e5c..cf0307b00 100644 --- a/src/main/java/org/scijava/menu/ShadowMenu.java +++ b/src/main/java/org/scijava/menu/ShadowMenu.java @@ -549,13 +549,13 @@ else if (existingChild != null) { if (childInfo != null && info.getPriority() == childInfo.getPriority()) { log.warn("ShadowMenu: menu item already exists:\n" + // - "\texisting: " + childInfo + "\n" + // - "\t ignored: " + info); + "\texisting: " + details(childInfo) + "\n" + // + "\t ignored: " + details(info)); } else { log.debug("ShadowMenu: higher-priority menu item already exists:\n" + - "\texisting: " + childInfo + "\n" + // - "\t ignored: " + info); + "\texisting: " + details(childInfo) + "\n" + // + "\t ignored: " + details(info)); } } } @@ -566,6 +566,21 @@ private boolean isLeaf(final int depth, final MenuPath path) { return depth == path.size() - 1; } + private String details(final ModuleInfo info) { + if (info == null) return ""; + String className, classLocation; + try { + final Class c = info.loadDelegateClass(); + className = c.getName(); + classLocation = ClassUtils.getLocation(c).toString(); + } + catch (final ClassNotFoundException exc) { + className = info.getDelegateClassName(); + classLocation = ""; + } + return info.getMenuPath() + " : " + className + " [" + classLocation + "]"; + } + private ShadowMenu getMenu(final MenuPath menuPath, final int index) { final MenuEntry entry = menuPath.get(index); From b37942c91f214700e8111fdb305c1ceb77fa37a6 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 26 Oct 2016 21:22:44 -0500 Subject: [PATCH 0363/1208] ScriptLanguageIndex: reformat string concatenation --- src/main/java/org/scijava/script/ScriptLanguageIndex.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptLanguageIndex.java b/src/main/java/org/scijava/script/ScriptLanguageIndex.java index 229bd55d9..33b02bf56 100644 --- a/src/main/java/org/scijava/script/ScriptLanguageIndex.java +++ b/src/main/java/org/scijava/script/ScriptLanguageIndex.java @@ -173,9 +173,10 @@ private String overwriteMessage(final boolean overwrite, final String type, final String key, final ScriptLanguage proposed, final ScriptLanguage existing) { - return (overwrite ? "Overwriting " : "Not overwriting ") + type + // - " '" + key + "':\n\tproposed = " + proposed.getClass().getName() + - "\n\texisting = " + existing.getClass().getName(); + return (overwrite ? "Overwriting " : "Not overwriting ") + // + type + " '" + key + "':\n" + // + "\tproposed = " + proposed.getClass().getName() + "\n" + + "\texisting = " + existing.getClass().getName(); } } From fc37cb2ee31fd7a122940c40c6fdf096312da889 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 26 Oct 2016 21:23:48 -0500 Subject: [PATCH 0364/1208] ScriptLanguageIndex: give details on duplicates In particular, it helps to know which JAR file each language came from. --- .../java/org/scijava/script/ScriptLanguageIndex.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/script/ScriptLanguageIndex.java b/src/main/java/org/scijava/script/ScriptLanguageIndex.java index 33b02bf56..4d7e77126 100644 --- a/src/main/java/org/scijava/script/ScriptLanguageIndex.java +++ b/src/main/java/org/scijava/script/ScriptLanguageIndex.java @@ -40,6 +40,7 @@ import javax.script.ScriptEngineFactory; import org.scijava.log.LogService; +import org.scijava.util.ClassUtils; import org.scijava.util.FileUtils; /** @@ -175,8 +176,13 @@ private String overwriteMessage(final boolean overwrite, final String type, { return (overwrite ? "Overwriting " : "Not overwriting ") + // type + " '" + key + "':\n" + // - "\tproposed = " + proposed.getClass().getName() + "\n" + - "\texisting = " + existing.getClass().getName(); + "\tproposed = " + details(proposed) + "\n" + + "\texisting = " + details(existing); } + /** Helper method of {@link #overwriteMessage}. */ + private String details(final ScriptLanguage language) { + final Class c = language.getClass(); + return c.getName() + " [" + ClassUtils.getLocation(c); + } } From e529070e41661384a314e3f0b9f478946cfcda69 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 13 Dec 2016 20:40:20 +0100 Subject: [PATCH 0365/1208] GatewayPreprocessor: add missing final keywords --- .../scijava/module/process/GatewayPreprocessor.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/scijava/module/process/GatewayPreprocessor.java b/src/main/java/org/scijava/module/process/GatewayPreprocessor.java index 745c0464a..ed71dbdfb 100644 --- a/src/main/java/org/scijava/module/process/GatewayPreprocessor.java +++ b/src/main/java/org/scijava/module/process/GatewayPreprocessor.java @@ -87,22 +87,22 @@ private void setGatewayValue(final Context context, try { gateway = type.getConstructor(Context.class).newInstance(context); } - catch (IllegalArgumentException exc) { + catch (final IllegalArgumentException exc) { exception = exc; } - catch (SecurityException exc) { + catch (final SecurityException exc) { exception = exc; } - catch (InstantiationException exc) { + catch (final InstantiationException exc) { exception = exc; } - catch (IllegalAccessException exc) { + catch (final IllegalAccessException exc) { exception = exc; } - catch (InvocationTargetException exc) { + catch (final InvocationTargetException exc) { exception = exc; } - catch (NoSuchMethodException exc) { + catch (final NoSuchMethodException exc) { exception = exc; } if (exception != null) { From c988ebfc75c502ad5a4243a07bbcab0c8fc01c9c Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 13 Dec 2016 21:06:34 +0100 Subject: [PATCH 0366/1208] SaveInputsPreprocessor: fix line wrapping --- .../org/scijava/module/process/SaveInputsPreprocessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/module/process/SaveInputsPreprocessor.java b/src/main/java/org/scijava/module/process/SaveInputsPreprocessor.java index 6c81a9c4a..3720d839e 100644 --- a/src/main/java/org/scijava/module/process/SaveInputsPreprocessor.java +++ b/src/main/java/org/scijava/module/process/SaveInputsPreprocessor.java @@ -43,8 +43,8 @@ *

    * This preprocessor runs late in the chain, giving other preprocessors every * chance to populate the inputs first. In particular, it executes after the - * {@link org.scijava.widget.InputHarvester} has run, so that user-specified values - * are persisted for next time. + * {@link org.scijava.widget.InputHarvester} has run, so that user-specified + * values are persisted for next time. *

    * * @author Curtis Rueden From 85122f6295aeb3684d78eff2696d7809f3dccd4d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 13 Dec 2016 21:08:56 +0100 Subject: [PATCH 0367/1208] Improve order of preprocessor plugins The validity check should come extremely early. After that, the Gateway and Service population should happen ASAP. Only then should we consider others such as single typed inputs. Without this change, it was possible for parameter validator methods to fire before services were populated. --- .../java/org/scijava/module/process/GatewayPreprocessor.java | 4 ++-- .../java/org/scijava/module/process/ServicePreprocessor.java | 4 ++-- .../java/org/scijava/module/process/ValidityPreprocessor.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/scijava/module/process/GatewayPreprocessor.java b/src/main/java/org/scijava/module/process/GatewayPreprocessor.java index ed71dbdfb..54591d97f 100644 --- a/src/main/java/org/scijava/module/process/GatewayPreprocessor.java +++ b/src/main/java/org/scijava/module/process/GatewayPreprocessor.java @@ -52,8 +52,8 @@ * * @author Curtis Rueden */ -@Plugin(type = PreprocessorPlugin.class, - priority = Priority.VERY_HIGH_PRIORITY) +@Plugin(type = PreprocessorPlugin.class, // + priority = 2 * Priority.VERY_HIGH_PRIORITY) public class GatewayPreprocessor extends AbstractPreprocessorPlugin { @Parameter diff --git a/src/main/java/org/scijava/module/process/ServicePreprocessor.java b/src/main/java/org/scijava/module/process/ServicePreprocessor.java index f1d111d4f..51c70c8ee 100644 --- a/src/main/java/org/scijava/module/process/ServicePreprocessor.java +++ b/src/main/java/org/scijava/module/process/ServicePreprocessor.java @@ -61,8 +61,8 @@ * * @author Curtis Rueden */ -@Plugin(type = PreprocessorPlugin.class, - priority = Priority.VERY_HIGH_PRIORITY) +@Plugin(type = PreprocessorPlugin.class, // + priority = 2 * Priority.VERY_HIGH_PRIORITY) public class ServicePreprocessor extends AbstractPreprocessorPlugin { // -- ModuleProcessor methods -- diff --git a/src/main/java/org/scijava/module/process/ValidityPreprocessor.java b/src/main/java/org/scijava/module/process/ValidityPreprocessor.java index a18ef8a9c..2beeca9be 100644 --- a/src/main/java/org/scijava/module/process/ValidityPreprocessor.java +++ b/src/main/java/org/scijava/module/process/ValidityPreprocessor.java @@ -44,7 +44,7 @@ * @author Curtis Rueden */ @Plugin(type = PreprocessorPlugin.class, - priority = Priority.VERY_HIGH_PRIORITY + 1) + priority = 3 * Priority.VERY_HIGH_PRIORITY) public class ValidityPreprocessor extends AbstractPreprocessorPlugin { // -- ModuleProcessor methods -- From c68bf459a9be52c6c4070e2122a4a1dbf9966466 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 13 Dec 2016 21:10:35 +0100 Subject: [PATCH 0368/1208] Do not inject delegate command classes Instead, let the ServicePreprocessor handle them. It turns out it is very tricky to inject the context into the Command instance at the proper time. The best time would be precisely when the CommandModule instance has its context injected, but unfortunately, there is no hook to trigger behavior in response to context injection. It is not guaranteed that Contextual#setContext(Context) be called. Injecting the context into the Command instance during ContextModule#initialize() appeared to work on the surface, but actually deferred population of Service parameters until the InitPreprocessor was called; such behavior was unintuitive and dare I say bogus. Furthermore, by suppressing Service and Context parameters from the list of Command inputs, we made commands behave differently than scripts: the latter report Service and Context parameters as input parameters, whereas the former did not. With this change, that discrepancy is fixed. --- src/main/java/org/scijava/command/CommandInfo.java | 7 ------- src/main/java/org/scijava/command/CommandModule.java | 8 -------- 2 files changed, 15 deletions(-) diff --git a/src/main/java/org/scijava/command/CommandInfo.java b/src/main/java/org/scijava/command/CommandInfo.java index 8947db7a6..445a53f2c 100644 --- a/src/main/java/org/scijava/command/CommandInfo.java +++ b/src/main/java/org/scijava/command/CommandInfo.java @@ -41,7 +41,6 @@ import java.util.Map; import org.scijava.Cancelable; -import org.scijava.Context; import org.scijava.InstantiableException; import org.scijava.ItemIO; import org.scijava.ItemVisibility; @@ -55,7 +54,6 @@ import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; import org.scijava.plugin.PluginInfo; -import org.scijava.service.Service; import org.scijava.util.ClassUtils; import org.scijava.util.StringMaker; @@ -451,11 +449,6 @@ private void checkFields(final Class type) { for (final Field f : fields) { f.setAccessible(true); // expose private fields - // NB: Skip types handled by the application framework itself. - // I.e., these parameters get injected by Context#inject(Object). - if (Service.class.isAssignableFrom(f.getType())) continue; - if (Context.class.isAssignableFrom(f.getType())) continue; - final Parameter param = f.getAnnotation(Parameter.class); boolean valid = true; diff --git a/src/main/java/org/scijava/command/CommandModule.java b/src/main/java/org/scijava/command/CommandModule.java index 01afe55ef..00740256b 100644 --- a/src/main/java/org/scijava/command/CommandModule.java +++ b/src/main/java/org/scijava/command/CommandModule.java @@ -39,7 +39,6 @@ import org.scijava.InstantiableException; import org.scijava.NullContextException; import org.scijava.module.AbstractModule; -import org.scijava.module.MethodCallException; import org.scijava.module.Module; import org.scijava.module.ModuleException; import org.scijava.module.ModuleInfo; @@ -144,13 +143,6 @@ public void cancel() { previewPlugin.cancel(); } - @Override - public void initialize() throws MethodCallException { - // NB: Inject the context into the command before initializing. - getContext().inject(command); - super.initialize(); - } - @Override public CommandInfo getInfo() { return info; From 1ada80f2a761c4e5a29f816ce3c95b8b0e9c540d Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 13 Dec 2016 21:05:29 +0100 Subject: [PATCH 0369/1208] CommandModuleTest: test validater callbacks This also tests that Service parameters are injected very early in the preprocessing chain, before Priority.VERY_HIGH_PRIORITY. --- .../scijava/command/CommandModuleTest.java | 69 ++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/scijava/command/CommandModuleTest.java b/src/test/java/org/scijava/command/CommandModuleTest.java index 931c17c13..1773c3d60 100644 --- a/src/test/java/org/scijava/command/CommandModuleTest.java +++ b/src/test/java/org/scijava/command/CommandModuleTest.java @@ -33,6 +33,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.concurrent.ExecutionException; @@ -40,11 +41,16 @@ import org.junit.Test; import org.scijava.Cancelable; import org.scijava.Context; +import org.scijava.ItemIO; +import org.scijava.Priority; +import org.scijava.log.LogService; import org.scijava.module.Module; +import org.scijava.module.ModuleItem; import org.scijava.module.process.AbstractPreprocessorPlugin; import org.scijava.module.process.PreprocessorPlugin; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; +import org.scijava.service.Service; /** Regression tests for {@link CommandModule}. */ public class CommandModuleTest { @@ -64,7 +70,6 @@ public void testCancelable() throws InterruptedException, ExecutionException { assertFalse(crow.isCanceled()); } - @Test public void testNotCancelable() throws InterruptedException, ExecutionException @@ -96,6 +101,17 @@ public void testDefaultValues() { assertEquals(null, info.getInput("thing").getDefaultValue()); } + @Test + public void testValidation() throws InterruptedException, ExecutionException { + final Context context = new Context(CommandService.class); + final CommandService commandService = context.service(CommandService.class); + + final CommandModule module = // + commandService.run(CommandWithValidation.class, true).get(); + assertNotNull(module.getInput("stuff")); + assertEquals("success", module.getOutput("result")); + } + // -- Helper classes -- /** A command which implements {@link Cancelable}. */ @@ -168,4 +184,55 @@ public void run() { time = 0; } } + + /** A command which validates an input. */ + @Plugin(type = Command.class) + public static class CommandWithValidation extends ContextCommand { + + @Parameter + private LogService log; + + @Parameter(validater = "validateStuff") + private Stuff stuff; + + @Parameter(type = ItemIO.OUTPUT) + private String result = "default"; + + @SuppressWarnings("unused") + private void validateStuff() { + final StringBuilder sb = new StringBuilder(); + if (log == null) sb.append("[null-log] "); + if (stuff == null) sb.append("[null-stuff] "); + result = sb.length() == 0 ? "success" : sb.toString(); + } + + @Override + public void run() { + if (!result.equals("success")) result += " failure"; + } + } + + /** + * Preprocessor to inject {@link Stuff} instances very early. But (in theory) + * not as early as {@link Service} and {@link Context} parameters get + * populated. + */ + @Plugin(type = PreprocessorPlugin.class, + priority = Priority.VERY_HIGH_PRIORITY) + public static class StuffPreprocessor extends AbstractPreprocessorPlugin { + + @Override + public void process(final Module module) { + for (final ModuleItem input : module.getInfo().inputs()) { + if (Stuff.class.isAssignableFrom(input.getType())) { + module.setInput(input.getName(), new Stuff()); + module.resolveInput(input.getName()); + } + } + } + + } + + /** Placeholder class, for type safety. */ + public static class Stuff {} } From 3c582e3fffcbe32726be960de7b5e96d911a6754 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 20 Dec 2016 13:51:24 -0600 Subject: [PATCH 0370/1208] ClassUtils: fix javadoc for annotated list results What was written in the javadoc used to be true, but for performance reasons, we added a cache for situations where the same request is made multiple times. This commit updates the javadoc to reflect the new reality. Closes #252. --- src/main/java/org/scijava/util/ClassUtils.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/util/ClassUtils.java b/src/main/java/org/scijava/util/ClassUtils.java index 70631e038..816ee9925 100644 --- a/src/main/java/org/scijava/util/ClassUtils.java +++ b/src/main/java/org/scijava/util/ClassUtils.java @@ -364,7 +364,9 @@ public static URL getLocation(final Class c) { * * @param c The class to scan for annotated methods. * @param annotationClass The type of annotation for which to scan. - * @return A new list containing all methods with the requested annotation. + * @return A list containing all methods with the requested annotation. Note + * that for performance reasons, lists may be cached and reused, so it + * is best to make a copy of the result if you need to modify it. */ public static List getAnnotatedMethods( final Class c, final Class annotationClass) @@ -417,7 +419,9 @@ public static List getAnnotatedMethods( * * @param c The class to scan for annotated fields. * @param annotationClass The type of annotation for which to scan. - * @return A new list containing all fields with the requested annotation. + * @return A list containing all fields with the requested annotation. Note + * that for performance reasons, lists may be cached and reused, so it + * is best to make a copy of the result if you need to modify it. */ public static List getAnnotatedFields( final Class c, final Class annotationClass) From 3d158e5e36589e6d944635e6f7f6d05e1ee88128 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 15 Dec 2016 15:12:00 +0100 Subject: [PATCH 0371/1208] Context: remove unnecessary SuppressWarnings --- src/main/java/org/scijava/Context.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/scijava/Context.java b/src/main/java/org/scijava/Context.java index 1ec38127f..a9d2d2a70 100644 --- a/src/main/java/org/scijava/Context.java +++ b/src/main/java/org/scijava/Context.java @@ -533,7 +533,6 @@ private static PluginIndex plugins(final boolean empty) { return empty ? new PluginIndex(null) : null; } - @SuppressWarnings("unchecked") private static List> services(final boolean empty) { if (empty) return Collections.> emptyList(); return Arrays.> asList(Service.class); From c09937e74564a223eea8a2df5a80068c2a0a33b6 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 15 Dec 2016 15:12:12 +0100 Subject: [PATCH 0372/1208] Context: recursively inject the context For each non-Service, non-Context, non-primitive @Parameter, check whether it is already assigned a value, and if so, inject the context into that value. This makes it much easier to compose a class whose member fields also need to know the context at the same time as the containing class. See next commit for an example. --- src/main/java/org/scijava/Context.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/scijava/Context.java b/src/main/java/org/scijava/Context.java index a9d2d2a70..5a1a7678f 100644 --- a/src/main/java/org/scijava/Context.java +++ b/src/main/java/org/scijava/Context.java @@ -471,6 +471,11 @@ else if (Context.class.isAssignableFrom(type) && type.isInstance(this)) { // populate Context parameter ClassUtils.setValue(f, o, this); } + else if (!type.isPrimitive()) { + // the parameter is some other object; if it is non-null, we recurse + final Object value = ClassUtils.getValue(f, o); + if (value != null) inject(value); + } } catch (final Throwable t) { handleSafely(t); From a822f7b23c4009d54bc4a138145202f6f414da2b Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 15 Dec 2016 15:14:09 +0100 Subject: [PATCH 0373/1208] CommandModule: make Command instance as a param Together with the previous commit, this change will make the Command instance receive a Context injection as part of the CommandModule's injection -- something which was previously not possible. --- src/main/java/org/scijava/command/CommandModule.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/scijava/command/CommandModule.java b/src/main/java/org/scijava/command/CommandModule.java index 00740256b..6258260b2 100644 --- a/src/main/java/org/scijava/command/CommandModule.java +++ b/src/main/java/org/scijava/command/CommandModule.java @@ -80,6 +80,7 @@ public class CommandModule extends AbstractModule implements Cancelable, private final CommandInfo info; /** The command instance handled by this module. */ + @Parameter private final Command command; @Parameter From fe04dab85f75e8573ca84c4bf0ae86b3c4bf1af7 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 15 Dec 2016 15:16:29 +0100 Subject: [PATCH 0374/1208] CommandModuleTest: test that Command gets injected When running a Command _without_ preprocessing, the services should nonetheless be populated, due to Context injection. --- .../scijava/command/CommandModuleTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/test/java/org/scijava/command/CommandModuleTest.java b/src/test/java/org/scijava/command/CommandModuleTest.java index 1773c3d60..1951fa42a 100644 --- a/src/test/java/org/scijava/command/CommandModuleTest.java +++ b/src/test/java/org/scijava/command/CommandModuleTest.java @@ -34,6 +34,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import java.util.concurrent.ExecutionException; @@ -112,6 +113,20 @@ public void testValidation() throws InterruptedException, ExecutionException { assertEquals("success", module.getOutput("result")); } + @Test + public void testCommandInjection() throws InterruptedException, + ExecutionException + { + final Context context = new Context(CommandService.class); + final CommandService commandService = context.service(CommandService.class); + final LogService logService = context.service(LogService.class); + + final CommandModule module = // + commandService.run(CommandWithService.class, false).get(); + assertSame(logService, module.getInput("log")); + assertTrue((boolean) module.getOutput("success")); + } + // -- Helper classes -- /** A command which implements {@link Cancelable}. */ @@ -235,4 +250,21 @@ public void process(final Module module) { /** Placeholder class, for type safety. */ public static class Stuff {} + + /** A command which has a {@link Service} parameter. */ + @Plugin(type = Command.class) + public static class CommandWithService implements Command { + + @Parameter + private LogService log; + + @Parameter(type = ItemIO.OUTPUT) + private boolean success; + + @Override + public void run() { + success = log != null; + } + } + } From e5d37f042cc6bc3ae58103a610db2b9aa6abf9b2 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 21 Dec 2016 13:23:26 -0600 Subject: [PATCH 0375/1208] Add the Initializable interface Anything with a 'void initialize()' method should implement it, for improved type safety. --- pom.xml | 2 +- src/main/java/org/scijava/Initializable.java | 45 ++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/scijava/Initializable.java diff --git a/pom.xml b/pom.xml index edf8dccd4..ce204c345 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.61.1-SNAPSHOT + 2.62.0-SNAPSHOT SciJava Common SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by downstream projects in the SciJava ecosystem, such as ImageJ and SCIFIO. diff --git a/src/main/java/org/scijava/Initializable.java b/src/main/java/org/scijava/Initializable.java new file mode 100644 index 000000000..8c6b05fed --- /dev/null +++ b/src/main/java/org/scijava/Initializable.java @@ -0,0 +1,45 @@ +/* + * #%L + * SciJava Common shared library for SciJava software. + * %% + * Copyright (C) 2009 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package org.scijava; + +/** + * Interface for objects which can be initialized. + * + * @author Curtis Rueden + */ +public interface Initializable { + + /** Initializes the object. */ + default void initialize() { + // NB: Do nothing by default. + } +} From cdf8788f9c1646e249eb63c3f9121063893764ef Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 21 Dec 2016 13:27:00 -0600 Subject: [PATCH 0376/1208] Service: switch method declaration order We do this mainly so the next commit is cleaner & easier to understand. --- .../java/org/scijava/service/Service.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/scijava/service/Service.java b/src/main/java/org/scijava/service/Service.java index 0118f93f1..cfab56e1c 100644 --- a/src/main/java/org/scijava/service/Service.java +++ b/src/main/java/org/scijava/service/Service.java @@ -52,31 +52,30 @@ public interface Service extends RichPlugin, Disposable { /** - * Performs any needed initialization when the service is first loaded. + * Registers the service's event handler methods. *

    * NB: This method is not intended to be called directly. It is called by * the service framework itself (specifically by the {@link ServiceHelper}) * when initializing the service. It should not be called a second time. *

    */ - default void initialize() { - // NB: Do nothing by default. + default void registerEventHandlers() { + // TODO: Consider removing this method in scijava-common 3.0.0. + // Instead, the ServiceHelper could just invoke the lines below directly, + // and there would be one less boilerplate Service method to implement. + final EventService eventService = context().getService(EventService.class); + if (eventService != null) eventService.subscribe(this); } /** - * Registers the service's event handler methods. + * Performs any needed initialization when the service is first loaded. *

    * NB: This method is not intended to be called directly. It is called by * the service framework itself (specifically by the {@link ServiceHelper}) * when initializing the service. It should not be called a second time. *

    */ - default void registerEventHandlers() { - // TODO: Consider removing this method in scijava-common 3.0.0. - // Instead, the ServiceHelper could just invoke the lines below directly, - // and there would be one less boilerplate Service method to implement. - final EventService eventService = context().getService(EventService.class); - if (eventService != null) eventService.subscribe(this); + default void initialize() { + // NB: Do nothing by default. } - } From a855314fee40dbaed2b3be97ed9f4eadc635a1b6 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 21 Dec 2016 13:27:39 -0600 Subject: [PATCH 0377/1208] Service: implement the Initializable interface --- src/main/java/org/scijava/service/Service.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/service/Service.java b/src/main/java/org/scijava/service/Service.java index cfab56e1c..e707aee67 100644 --- a/src/main/java/org/scijava/service/Service.java +++ b/src/main/java/org/scijava/service/Service.java @@ -32,6 +32,7 @@ package org.scijava.service; import org.scijava.Disposable; +import org.scijava.Initializable; import org.scijava.event.EventService; import org.scijava.plugin.Plugin; import org.scijava.plugin.RichPlugin; @@ -49,7 +50,7 @@ * @author Curtis Rueden * @see Plugin */ -public interface Service extends RichPlugin, Disposable { +public interface Service extends RichPlugin, Initializable, Disposable { /** * Registers the service's event handler methods. @@ -67,6 +68,8 @@ default void registerEventHandlers() { if (eventService != null) eventService.subscribe(this); } + // -- Initializable methods -- + /** * Performs any needed initialization when the service is first loaded. *

    @@ -75,6 +78,7 @@ default void registerEventHandlers() { * when initializing the service. It should not be called a second time. *

    */ + @Override default void initialize() { // NB: Do nothing by default. } From 0f3227dfd1998312547f2d6cc86b7b2a7fe8fb2b Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 21 Dec 2016 13:34:22 -0600 Subject: [PATCH 0378/1208] Context: clean up style --- src/main/java/org/scijava/Context.java | 97 +++++++++++++------------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/src/main/java/org/scijava/Context.java b/src/main/java/org/scijava/Context.java index 5a1a7678f..507570903 100644 --- a/src/main/java/org/scijava/Context.java +++ b/src/main/java/org/scijava/Context.java @@ -55,7 +55,7 @@ /** * Top-level SciJava application context, which initializes and maintains a list * of services. - * + * * @author Curtis Rueden * @see Service */ @@ -100,7 +100,7 @@ public class Context implements Disposable { /** * Creates a new SciJava application context with all available services. - * + * * @see #Context(Collection, PluginIndex, boolean) */ public Context() { @@ -109,7 +109,7 @@ public Context() { /** * Creates a new SciJava application context. - * + * * @param empty If true, the context will be empty of services; otherwise, it * will be initialized with all available services. * @see #Context(boolean, boolean) @@ -120,7 +120,7 @@ public Context(final boolean empty) { /** * Creates a new SciJava application context. - * + * * @param noServices If true, the context will contain no services; otherwise, * it will be initialized with all available services. * @param noPlugins If true, the context will contain no plugins; otherwise, @@ -147,11 +147,11 @@ public Context(final boolean noServices, final boolean noPlugins) { * To avoid this, we have opted to use raw types and suppress the relevant * warnings here instead. *

    - * + * * @param serviceClasses A list of types that implement the {@link Service} * interface (e.g., {@code DisplayService.class}). Compatible - * services will be loaded in the order given, - * regardless of their relative priorities. + * services will be loaded in the order given, regardless of + * their relative priorities. * @see #Context(Collection, PluginIndex, boolean) * @throws ClassCastException If any of the given arguments do not implement * the {@link Service} interface. @@ -163,7 +163,7 @@ public Context(@SuppressWarnings("rawtypes") final Class... serviceClasses) { /** * Creates a new SciJava application context with the specified services (and * any required service dependencies). - * + * * @param serviceClasses A collection of types that implement the * {@link Service} interface (e.g., {@code DisplayService.class}). * Compatible services will be loaded according to the order of the @@ -177,13 +177,13 @@ public Context(final Collection> serviceClasses) { /** * Creates a new SciJava application context with the specified services (and * any required service dependencies). - * + * * @param serviceClasses A collection of types that implement the * {@link Service} interface (e.g., {@code DisplayService.class}). * Compatible services will be loaded according to the order of the * collection, regardless of their relative priorities. - * @param strict Whether context creation will fail fast when there is - * an error instantiating a required service. + * @param strict Whether context creation will fail fast when there is an + * error instantiating a required service. * @see #Context(Collection, PluginIndex, boolean) */ public Context(final Collection> serviceClasses, @@ -197,7 +197,7 @@ public Context(final Collection> serviceClasses, * the specified PluginIndex. This allows a base set of available plugins to * be defined, and is useful when plugins that would not be returned by the * {@link PluginIndex}'s {@link org.scijava.plugin.PluginFinder} are desired. - * + * * @param pluginIndex The plugin index to use when discovering and indexing * plugins. If you wish to completely control how services are * discovered (i.e., use your own @@ -215,7 +215,7 @@ public Context(final PluginIndex pluginIndex) { * any required service dependencies). Service dependency candidates are * selected from those discovered by the given {@link PluginIndex}'s * associated {@link org.scijava.plugin.PluginFinder}. - * + * * @param serviceClasses A collection of types that implement the * {@link Service} interface (e.g., {@code DisplayService.class}). * Compatible services will be loaded according to the order of the @@ -248,7 +248,7 @@ public Context(final Collection> serviceClasses, * those of lower priority). See {@link ServiceHelper#loadServices()} for more * information. *

    - * + * * @param serviceClasses A collection of types that implement the * {@link Service} interface (e.g., {@code DisplayService.class}). * Compatible services will be loaded according to the order of the @@ -259,8 +259,8 @@ public Context(final Collection> serviceClasses, * {@link org.scijava.plugin.PluginFinder} implementation), then you * can pass a custom {@link PluginIndex} here. Passing null will * result in a default plugin index being constructed and used. - * @param strict Whether context creation will fail fast when there is - * an error instantiating a required service. + * @param strict Whether context creation will fail fast when there is an + * error instantiating a required service. */ public Context(final Collection> serviceClasses, final PluginIndex pluginIndex, final boolean strict) @@ -272,9 +272,9 @@ public Context(final Collection> serviceClasses, setStrict(strict); - if (!serviceClasses.isEmpty()){ - final ServiceHelper serviceHelper = - new ServiceHelper(this, serviceClasses, strict); + if (!serviceClasses.isEmpty()) { + final ServiceHelper serviceHelper = // + new ServiceHelper(this, serviceClasses, strict); serviceHelper.loadServices(); } } @@ -299,21 +299,22 @@ public void setStrict(final boolean strict) { /** * Gets the service of the given class. - * + * * @throws NoSuchServiceException if the context does not have the requested * service. */ public S service(final Class c) { final S service = getService(c); if (service == null) { - throw new NoSuchServiceException("Service " + c.getName() + " not found."); + throw new NoSuchServiceException("Service " + c.getName() + + " not found."); } return service; } /** * Gets the service of the given class name (useful for scripts). - * + * * @throws IllegalArgumentException if the class does not exist, or is not a * service class. * @throws NoSuchServiceException if the context does not have the requested @@ -352,15 +353,16 @@ public Service getService(final String className) { * distinct things: *
      *
    • If the given object has any non-final {@link Context} fields annotated - * with @{@link Parameter}, sets the value of those fields to this context.
    • + * with @{@link Parameter}, sets the value of those fields to this context. + * *
    • If the given object has any non-final {@link Service} fields annotated * with @{@link Parameter}, sets the value of those fields to the * corresponding service available from this context.
    • *
    • Calls {@link EventService#subscribe(Object)} with the object to - * register any @{@link EventHandler} annotated methods as event subscribers.
    • - * . + * register any @{@link EventHandler} annotated methods as event subscribers. + * . *
    - * + * * @param o The object to which the context should be assigned. * @throws IllegalStateException If the object already has a context. * @throws IllegalArgumentException If the object has a required @@ -370,7 +372,7 @@ public Service getService(final String className) { public void inject(final Object o) { // Ensure parameter fields and event handler methods are cached for this // object. - Query query = new Query(); + final Query query = new Query(); query.put(Parameter.class, Field.class); query.put(EventHandler.class, Method.class); ClassUtils.cacheAnnotatedObjects(o.getClass(), query); @@ -412,13 +414,13 @@ public void dispose() { public static List> serviceClassList( final Class... serviceClasses) { - return serviceClasses != null ? (List) Arrays.asList(serviceClasses) - : Arrays.asList(Service.class); + return serviceClasses != null ? // + Arrays.asList(serviceClasses) : Arrays.asList(Service.class); } // -- Helper methods -- - private List getParameterFields(Object o) { + private List getParameterFields(final Object o) { try { return ClassUtils.getAnnotatedFields(o.getClass(), Parameter.class); } @@ -436,36 +438,36 @@ private void inject(final Field f, final Object o) { if (Service.class.isAssignableFrom(type)) { final Service existingService = (Service) ClassUtils.getValue(f, o); if (strict && existingService != null) { - throw new IllegalStateException("Context already injected: " + - f.getDeclaringClass().getName() + "#" + f.getName()); + throw new IllegalStateException("Context already injected: " + // + f.getDeclaringClass().getName() + "#" + f.getName()); } // populate Service parameter @SuppressWarnings("unchecked") final Class serviceType = - (Class) type; + (Class) type; final Service service = getService(serviceType); if (service == null && f.getAnnotation(Parameter.class).required()) { - throw new IllegalArgumentException( + throw new IllegalArgumentException(// createMissingServiceMessage(serviceType)); } if (existingService != null && existingService != service) { // NB: Can only happen in non-strict mode. - throw new IllegalStateException("Mismatched context: " + - f.getDeclaringClass().getName() + "#" + f.getName()); + throw new IllegalStateException("Mismatched context: " + // + f.getDeclaringClass().getName() + "#" + f.getName()); } ClassUtils.setValue(f, o, service); } else if (Context.class.isAssignableFrom(type) && type.isInstance(this)) { final Context existingContext = (Context) ClassUtils.getValue(f, o); if (strict && existingContext != null) { - throw new IllegalStateException("Context already injected: " + - f.getDeclaringClass().getName() + "#" + f.getName()); + throw new IllegalStateException("Context already injected: " + // + f.getDeclaringClass().getName() + "#" + f.getName()); } if (existingContext != null && existingContext != this) { // NB: Can only happen in non-strict mode. - throw new IllegalStateException("Mismatched context: " + - f.getDeclaringClass().getName() + "#" + f.getName()); + throw new IllegalStateException("Mismatched context: " + // + f.getDeclaringClass().getName() + "#" + f.getName()); } // populate Context parameter @@ -506,11 +508,10 @@ private String createMissingServiceMessage( final Class serviceType) { final String nl = System.getProperty("line.separator"); - final ClassLoader classLoader = + final ClassLoader classLoader = // Thread.currentThread().getContextClassLoader(); - final StringBuilder msg = - new StringBuilder("Required service is missing: " + - serviceType.getName() + nl); + final StringBuilder msg = new StringBuilder( + "Required service is missing: " + serviceType.getName() + nl); msg.append("Context: " + this + nl); msg.append("ClassLoader: " + classLoader + nl); @@ -528,8 +529,8 @@ private String createMissingServiceMessage( } } else { - msg - .append("ClassLoader was not a URLClassLoader. Could not print classpath."); + msg.append( + "ClassLoader was not a URLClassLoader. Could not print classpath."); } return msg.toString(); } @@ -539,8 +540,8 @@ private static PluginIndex plugins(final boolean empty) { } private static List> services(final boolean empty) { - if (empty) return Collections.> emptyList(); - return Arrays.> asList(Service.class); + if (empty) return Collections.>emptyList(); + return Arrays.>asList(Service.class); } private static boolean strict() { From 2b458fa1392aa52faa56eb0077891fe621680f2c Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 21 Dec 2016 13:41:57 -0600 Subject: [PATCH 0379/1208] Context: add isInjectable(Class) method Now you can ask the context itself whether a particular field type would have its value assigned by an injection operation, or not. Previously, you simply had to know (assume, really) that Service and Context fields would be injected, and others would not. --- src/main/java/org/scijava/Context.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/org/scijava/Context.java b/src/main/java/org/scijava/Context.java index 507570903..108ac7240 100644 --- a/src/main/java/org/scijava/Context.java +++ b/src/main/java/org/scijava/Context.java @@ -388,6 +388,25 @@ public void inject(final Object o) { subscribeToEvents(o); } + /** + * Reports whether a parameter of the given type would be assigned a value as + * a consequence of calling {@link #inject(Object)}. + *

    + * This method is notably useful for downstream code to discern between + * {@link Parameter} fields whose values would be injected, versus those whose + * values would not, without needing to hardcode type comparison checks + * against the {@link Service} and {@link Context} types. + *

    + * + * @param type The type of the @{@link Parameter}-annotated field. + * @return True iff a member field of the given type would have its value + * assigned. + */ + public boolean isInjectable(final Class type) { + if (Service.class.isAssignableFrom(type)) return true; + return Context.class.isAssignableFrom(type) && type.isInstance(this); + } + // -- Disposable methods -- @Override From 3c7a7deb6c78bdf6a134b5565aac57bd08a8ceef Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 21 Dec 2016 13:45:56 -0600 Subject: [PATCH 0380/1208] ContextInjectionTest: clean up afterwards --- .../org/scijava/ContextInjectionTest.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/test/java/org/scijava/ContextInjectionTest.java b/src/test/java/org/scijava/ContextInjectionTest.java index 0e09c8dc4..861d739e8 100644 --- a/src/test/java/org/scijava/ContextInjectionTest.java +++ b/src/test/java/org/scijava/ContextInjectionTest.java @@ -38,6 +38,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import org.junit.After; import org.junit.Test; import org.scijava.event.EventHandler; import org.scijava.event.EventService; @@ -55,6 +56,13 @@ */ public class ContextInjectionTest { + private Context context; + + @After + public void tearDown() { + context.dispose(); + } + /** * Tests that the {@link Context} and {@link Service} parameters are properly * injected when calling {@link Contextual#setContext} on an @@ -62,7 +70,7 @@ public class ContextInjectionTest { */ @Test public void testAbstractContextualSetContext() { - final Context context = new Context(FooService.class); + context = new Context(FooService.class); final NeedsFooContextual needsFoo = new NeedsFooContextual(); assertNull(needsFoo.fooService); @@ -78,7 +86,7 @@ public void testAbstractContextualSetContext() { */ @Test public void testAbstractContextualContextInject() { - final Context context = new Context(FooService.class); + context = new Context(FooService.class); final NeedsFooContextual needsFoo = new NeedsFooContextual(); assertNull(needsFoo.fooService); @@ -94,7 +102,7 @@ public void testAbstractContextualContextInject() { */ @Test public void testNonContextualServiceParameters() { - final Context context = new Context(FooService.class); + context = new Context(FooService.class); final NeedsFooPlain needsFoo = new NeedsFooPlain(); assertNull(needsFoo.fooService); @@ -113,7 +121,7 @@ public void testNonContextualServiceParameters() { */ @Test public void testNonContextualContextParameters() { - final Context context = new Context(true); + context = new Context(true); final NeedsContext needsContext = new NeedsContext(); assertNull(needsContext.context); @@ -139,13 +147,13 @@ public void testNonContextualContextParameters() { */ @Test public void testContextSubclassInjection() { - final Context c = new Context(true); + context = new Context(true); final FooContext foo = new FooContext(); final BarContext bar = new BarContext(); final ContextSubclassParameters cspPlain = new ContextSubclassParameters(); - c.inject(cspPlain); - assertSame(c, cspPlain.c); + context.inject(cspPlain); + assertSame(context, cspPlain.c); assertNull(cspPlain.foo); assertNull(cspPlain.bar); @@ -170,7 +178,7 @@ public void testContextSubclassInjection() { */ @Test public void testAbstractContextualEventSubscription() { - final Context context = new Context(EventService.class); + context = new Context(EventService.class); final EventService eventService = context.getService(EventService.class); final HasEventsContextual hasEvents = new HasEventsContextual(); @@ -191,7 +199,7 @@ public void testAbstractContextualEventSubscription() { */ @Test public void testNonContextualEventSubscription() { - final Context context = new Context(EventService.class); + context = new Context(EventService.class); final EventService eventService = context.getService(EventService.class); final HasEventsPlain hasEvents = new HasEventsPlain(); From 3e3368531be4099afc3f8d54b0f2be8fdc74a892 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 21 Dec 2016 13:47:31 -0600 Subject: [PATCH 0381/1208] ContextInjectionTest: test Context.isInjectable Pretty braindead, but better safe than sorry, right? --- src/test/java/org/scijava/ContextInjectionTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/java/org/scijava/ContextInjectionTest.java b/src/test/java/org/scijava/ContextInjectionTest.java index 861d739e8..2ddf1ea5a 100644 --- a/src/test/java/org/scijava/ContextInjectionTest.java +++ b/src/test/java/org/scijava/ContextInjectionTest.java @@ -63,6 +63,19 @@ public void tearDown() { context.dispose(); } + /** Tests {@link Context#isInjectable(Class)}. */ + public void testInjectable() { + context = new Context(true); + assertTrue(context.isInjectable(Context.class)); + assertTrue(context.isInjectable(FooContext.class)); + assertTrue(context.isInjectable(Service.class)); + assertTrue(context.isInjectable(FooService.class)); + assertFalse(context.isInjectable(String.class)); + assertFalse(context.isInjectable(Integer.class)); + assertFalse(context.isInjectable(int.class)); + assertFalse(context.isInjectable(void.class)); + } + /** * Tests that the {@link Context} and {@link Service} parameters are properly * injected when calling {@link Contextual#setContext} on an From 98e5943f9fe8337de42b46a1befa9002cabc527a Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Thu, 22 Dec 2016 15:43:09 -0600 Subject: [PATCH 0382/1208] ConsoleService: guard against infinite loops The design of the ConsoleArgument handlers allows each handler to remove one or more arguments from the beginning of the linked argument list, which provides for a nice sequential processing sequence. However, it is very easy to code a ConsoleArgument and then forget to remove any elements from the list. Previously, such a bug would cause the ConsoleService's processArgs method to never return, instead calling the same handler over and over. This change adds a rudimentary safeguard against such an occurrence: if the list of arguments is totally unchanged after a ConsoleArgument plugin has supposedly handled it, then we warn the user about the improper handling, remove the first argument from the list, and proceed. In this way, infinite loops should be a lot less likely; a bogus ConsoleArgument plugin would now need to mutate the list (e.g., add an argument rather than remove one) in order to cause trouble. --- .../console/DefaultConsoleService.java | 35 +++++++++++++++++++ .../scijava/console/ConsoleServiceTest.java | 32 +++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/src/main/java/org/scijava/console/DefaultConsoleService.java b/src/main/java/org/scijava/console/DefaultConsoleService.java index 6d53557b1..7d26d3260 100644 --- a/src/main/java/org/scijava/console/DefaultConsoleService.java +++ b/src/main/java/org/scijava/console/DefaultConsoleService.java @@ -35,6 +35,7 @@ import java.io.PrintStream; import java.util.ArrayList; import java.util.LinkedList; +import java.util.List; import org.scijava.Context; import org.scijava.console.OutputEvent.Source; @@ -82,6 +83,8 @@ public void processArgs(final String... args) { argList.add(arg); } + final List previousArgs = new ArrayList<>(); + while (!argList.isEmpty()) { final ConsoleArgument handler = getHandler(argList); if (handler == null) { @@ -90,7 +93,22 @@ public void processArgs(final String... args) { log.warn("Ignoring invalid argument: " + arg); continue; } + + // keep a copy of the argument list prior to handling + previousArgs.clear(); + previousArgs.addAll(argList); + + // process the argument handler.handle(argList); + + // verify that the handler did something to the list; + // this guards against bugs which would cause infinite loops + if (sameElements(previousArgs, argList)) { + // skip improperly handled argument + final String arg = argList.removeFirst(); + log.warn("Plugin '" + handler.getClass().getName() + + "' failed to handle argument: " + arg); + } } } @@ -174,6 +192,23 @@ private MultiPrintStream multiPrintStream(final PrintStream ps) { return new MultiPrintStream(ps); } + /** + * Gets whether two lists have exactly the same elements in them. + *

    + * We cannot use {@link List#equals(Object)} because want to check for + * identical references, not per-element object equality. + *

    + */ + private boolean sameElements(final List l1, + final List l2) + { + if (l1.size() != l2.size()) return false; + for (int i = 0; i < l1.size(); i++) { + if (l1.get(i) != l2.get(i)) return false; + } + return true; + } + // -- Helper classes -- /** diff --git a/src/test/java/org/scijava/console/ConsoleServiceTest.java b/src/test/java/org/scijava/console/ConsoleServiceTest.java index d67f20ebf..c33074e35 100644 --- a/src/test/java/org/scijava/console/ConsoleServiceTest.java +++ b/src/test/java/org/scijava/console/ConsoleServiceTest.java @@ -32,6 +32,7 @@ package org.scijava.console; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -72,10 +73,23 @@ public void tearDown() { /** Tests {@link ConsoleService#processArgs(String...)}. */ @Test public void testProcessArgs() { + assertFalse(consoleService.getInstance(FooArgument.class).argsHandled); consoleService.processArgs("--foo", "--bar"); assertTrue(consoleService.getInstance(FooArgument.class).argsHandled); } + /** + * Tests that {@link ConsoleService#processArgs(String...)} does not result in + * an infinite loop when a buggy {@link ConsoleArgument} forgets to remove its + * handled argument from the list. + */ + @Test + public void testInfiniteLoopAvoidance() { + assertFalse(consoleService.getInstance(BrokenArgument.class).argsHandled); + consoleService.processArgs("--broken"); + assertTrue(consoleService.getInstance(BrokenArgument.class).argsHandled); + } + /** * Tests the {@link OutputListener}-related API: *