diff --git a/pom.xml b/pom.xml index 7270aa62e..b378d4395 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ scijava-common - 2.99.3-SNAPSHOT + 2.100.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/AbstractBasicDetails.java b/src/main/java/org/scijava/AbstractBasicDetails.java index f05f40249..6ef7e6695 100644 --- a/src/main/java/org/scijava/AbstractBasicDetails.java +++ b/src/main/java/org/scijava/AbstractBasicDetails.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * Abstract superclass of {@link BasicDetails} implementations. - * + * * @author Curtis Rueden */ public abstract class AbstractBasicDetails implements BasicDetails { diff --git a/src/main/java/org/scijava/AbstractContextual.java b/src/main/java/org/scijava/AbstractContextual.java index 0c76ae641..56ab59a1e 100644 --- a/src/main/java/org/scijava/AbstractContextual.java +++ b/src/main/java/org/scijava/AbstractContextual.java @@ -6,13 +6,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 @@ -35,11 +35,11 @@ /** * Abstract base class for {@link Contextual} objects. *

- * Delegates to {@link Context#inject(Object)} to do the actual work of - * setting the context, injecting service parameters, and registering + * Delegates to {@link Context#inject(Object)} to do the actual work of setting + * the context, injecting service parameters, and registering * {@link EventHandler} methods as event subscribers. *

- * + * * @author Curtis Rueden * @see Context#inject(Object) */ diff --git a/src/main/java/org/scijava/AbstractGateway.java b/src/main/java/org/scijava/AbstractGateway.java index 944c2dff0..2e554ec44 100644 --- a/src/main/java/org/scijava/AbstractGateway.java +++ b/src/main/java/org/scijava/AbstractGateway.java @@ -6,13 +6,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 @@ -67,7 +67,7 @@ /** * Abstract superclass for {@link Gateway} implementations. - * + * * @author Mark Hiner * @author Curtis Rueden */ @@ -191,7 +191,7 @@ public InputService input() { public IOService io() { return get(IOService.class); } - + @Override public LocationService location() { return get(LocationService.class); diff --git a/src/main/java/org/scijava/AbstractUIDetails.java b/src/main/java/org/scijava/AbstractUIDetails.java index 3590c19e3..20788352c 100644 --- a/src/main/java/org/scijava/AbstractUIDetails.java +++ b/src/main/java/org/scijava/AbstractUIDetails.java @@ -6,13 +6,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,10 +33,12 @@ /** * Abstract superclass of {@link UIDetails} implementations. - * + * * @author Curtis Rueden */ -public abstract class AbstractUIDetails extends AbstractBasicDetails implements UIDetails { +public abstract class AbstractUIDetails extends AbstractBasicDetails implements + UIDetails +{ /** Path to this object's suggested position in the menu structure. */ private MenuPath menuPath; diff --git a/src/main/java/org/scijava/BasicDetails.java b/src/main/java/org/scijava/BasicDetails.java index d2288061b..04f952fec 100644 --- a/src/main/java/org/scijava/BasicDetails.java +++ b/src/main/java/org/scijava/BasicDetails.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * An interface defining basic characteristics including name, label, * description, and a table of key/value pairs. - * + * * @author Curtis Rueden */ public interface BasicDetails extends Named { diff --git a/src/main/java/org/scijava/Cancelable.java b/src/main/java/org/scijava/Cancelable.java index 0c36b0066..5898af1fc 100644 --- a/src/main/java/org/scijava/Cancelable.java +++ b/src/main/java/org/scijava/Cancelable.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An operation that can be canceled. - * + * * @author Curtis Rueden */ public interface Cancelable { @@ -48,14 +48,14 @@ public interface Cancelable { * during execution, and stop doing whatever it is doing if the flag has been * tripped. *

- * + * * @param reason A message describing why the operation is being canceled. */ void cancel(String reason); /** * Gets a message describing why the operation was canceled. - * + * * @return The reason for cancelation, which may be null if no reason was * given, or if the operation was not in fact canceled. */ diff --git a/src/main/java/org/scijava/Context.java b/src/main/java/org/scijava/Context.java index 50014ad17..6c342fb7f 100644 --- a/src/main/java/org/scijava/Context.java +++ b/src/main/java/org/scijava/Context.java @@ -6,13 +6,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 @@ -110,8 +110,8 @@ public class Context implements Disposable, AutoCloseable { private boolean strict; /** - * False if the context is currently active; true if the context - * has already been disposed, or is in the process of being disposed. + * False if the context is currently active; true if the context has already + * been disposed, or is in the process of being disposed. */ private boolean disposed; @@ -270,8 +270,8 @@ public Context(final Collection> serviceClasses, * NB: Instiantiation of a Context has an implied requirement of a * corresponding call to {@link Context#dispose()} at the end of the SciJava * applicaton's lifecycle. This cleans up any remaining resources and allows - * the JVM to exit gracefully. This is called automatically when constructed as - * an {@link AutoCloseable}. + * the JVM to exit gracefully. This is called automatically when constructed + * as an {@link AutoCloseable}. *

* * @param serviceClasses A collection of types that implement the @@ -442,7 +442,7 @@ public void inject(final Object o) { * 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. @@ -483,7 +483,7 @@ public static List> serviceClassList( /** * Gets the class loader to use. This will be the current thread's context * class loader if non-null; otherwise it will be the system class loader. - * + * * @see Thread#getContextClassLoader() * @see ClassLoader#getSystemClassLoader() */ @@ -615,7 +615,8 @@ private synchronized void doDispose(final boolean announce) { CONTEXTS.remove(this); if (announce) { final EventService eventService = getService(EventService.class); - if (eventService != null) eventService.publish(new ContextDisposingEvent()); + if (eventService != null) eventService.publish( + new ContextDisposingEvent()); } // NB: Dispose services in reverse order. diff --git a/src/main/java/org/scijava/Contextual.java b/src/main/java/org/scijava/Contextual.java index 4d83ca900..5df3859cc 100644 --- a/src/main/java/org/scijava/Contextual.java +++ b/src/main/java/org/scijava/Contextual.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An object that belongs to a SciJava application context. - * + * * @author Lee Kamentsky * @author Curtis Rueden */ @@ -42,7 +42,7 @@ public interface Contextual { /** * Gets the application context to which the object belongs. - * + * * @see #getContext() * @throws NullContextException if the context has not yet been set via * {@link #setContext(Context)}. @@ -52,7 +52,7 @@ public interface Contextual { /** * Gets the application context to which the object belongs, or null if * {@link #setContext(Context)} has not yet been called on this object. - * + * * @see #context() */ Context getContext(); @@ -65,7 +65,7 @@ public interface Contextual { * objects do not support later alteration of the context, and will throw * {@link IllegalStateException} if this method is invoked again. *

- * + * * @see Context#inject(Object) * @throws IllegalStateException If the object already has a context. * @throws IllegalArgumentException If the object has a required @@ -76,5 +76,4 @@ default void setContext(final Context context) { context.inject(this); } - } diff --git a/src/main/java/org/scijava/Disposable.java b/src/main/java/org/scijava/Disposable.java index f3ac3548b..0b8ce0222 100644 --- a/src/main/java/org/scijava/Disposable.java +++ b/src/main/java/org/scijava/Disposable.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An object that knows how to clean up after itself. - * + * * @author Curtis Rueden */ public interface Disposable { diff --git a/src/main/java/org/scijava/Gateway.java b/src/main/java/org/scijava/Gateway.java index 9222f058c..d6b99baff 100644 --- a/src/main/java/org/scijava/Gateway.java +++ b/src/main/java/org/scijava/Gateway.java @@ -6,13 +6,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 @@ -75,10 +75,12 @@ * Let's say we have a {@code Kraken} service and a {@code Cow} service. Using * the {@code Context} directly, the code would look like: *

+ * *
  * Context context = new Context();
  * context.getService(Cow.class).feedToKraken();
- * context.getService(Kraken.class).burp();
+ * context.getService(Kraken.class).burp(); + * *

* To perform these actions, you have to know a priori to ask for a * {@code Cow} and a {@code Kraken}; i.e., your IDE's code completion will not @@ -89,16 +91,26 @@ * But if we create a {@code Gateway} class called {@code Animals} with the * following signatures: *

+ * *
- * public Cow cow() { return get(Cow.class); }
- * public Kraken kraken() { return get(Kraken.class); }
+ * + * public Cow cow() { + * return get(Cow.class); + * } + * + * public Kraken kraken() { + * return get(Kraken.class); + * } + * *

* We can now access our services through the new {@code Animals} gateway: *

+ * *
  * Animals animals = new Animals();
  * animals.cow().feedToKraken();
- * animals.kraken().burp();
+ * animals.kraken().burp(); + * *

* This provides succinct yet explicit access to the {@code Cow} and * {@code Kraken} services; it is a simple two-layer access to functionality, @@ -113,7 +125,7 @@ * implementing this interface, it is encouraged to instead extend * {@link AbstractGateway}, for convenience. *

- * + * * @see Context * @author Mark Hiner * @author Curtis Rueden @@ -133,7 +145,7 @@ public interface Gateway extends RichPlugin, Disposable { *
  • 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); @@ -147,7 +159,7 @@ public interface Gateway extends RichPlugin, Disposable { /** * Returns an implementation of the requested {@link Service}, if it exists in * the underlying {@link Context}. - * + * * @param serviceClass the requested {@link Service} * @return The singleton instance of the given class * @throws NullContextException if the application context is not set. @@ -158,7 +170,7 @@ public interface Gateway extends RichPlugin, Disposable { /** * Returns an implementation of the {@link Service} with the given class name, * if it exists in the underlying {@link Context}. - * + * * @param serviceClassName name of the requested {@link Service} * @return The singleton instance of the requested {@link Service} * @throws NullContextException if the application context is not set. @@ -241,11 +253,11 @@ public interface Gateway extends RichPlugin, Disposable { /** * Gets this application context's {@link LocationService}. - * + * * @return The {@link LocationService} of this application context. */ LocationService location(); - + /** * Gets this application context's {@link LogService}. * diff --git a/src/main/java/org/scijava/Identifiable.java b/src/main/java/org/scijava/Identifiable.java index a1be1c4e7..b5a7f9777 100644 --- a/src/main/java/org/scijava/Identifiable.java +++ b/src/main/java/org/scijava/Identifiable.java @@ -6,13 +6,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 @@ -49,7 +49,7 @@ * do multiple potentially equivalent objects need to be synthesized and then * compared using {@link Object#equals}. *

    - * + * * @author Curtis Rueden */ public interface Identifiable { diff --git a/src/main/java/org/scijava/Initializable.java b/src/main/java/org/scijava/Initializable.java index bd7de998f..1674e68ac 100644 --- a/src/main/java/org/scijava/Initializable.java +++ b/src/main/java/org/scijava/Initializable.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Interface for objects which can be initialized. - * + * * @author Curtis Rueden */ public interface Initializable { diff --git a/src/main/java/org/scijava/Instantiable.java b/src/main/java/org/scijava/Instantiable.java index 7f1d82077..21c6fb121 100644 --- a/src/main/java/org/scijava/Instantiable.java +++ b/src/main/java/org/scijava/Instantiable.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An interface declaring the ability to create objects. - * + * * @param The type of objects that can be created. * @author Curtis Rueden */ @@ -50,7 +50,7 @@ public interface Instantiable { * Note that this class may not be precisely {@code T.class} but instead a * subclass thereof. *

    - * + * * @see org.scijava.plugin.PluginInfo for an example of an * {@code Instantiable} type that typically instantiates objects of a * subtype of {@code T} rather than {@code T} itself. diff --git a/src/main/java/org/scijava/InstantiableException.java b/src/main/java/org/scijava/InstantiableException.java index e2df38650..9dadfb9b7 100644 --- a/src/main/java/org/scijava/InstantiableException.java +++ b/src/main/java/org/scijava/InstantiableException.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An exception thrown when an {@link Instantiable} cannot create an object. - * + * * @author Curtis Rueden */ public class InstantiableException extends Exception { diff --git a/src/main/java/org/scijava/ItemIO.java b/src/main/java/org/scijava/ItemIO.java index c4198b74b..2fe8d4937 100644 --- a/src/main/java/org/scijava/ItemIO.java +++ b/src/main/java/org/scijava/ItemIO.java @@ -6,13 +6,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 @@ -40,9 +40,9 @@ *
  • BOTH: item is both an input and an output for the module. This type is * used to indicate an object that is mutated somehow during execution.
  • * - * + * * @author Curtis Rueden */ public enum ItemIO { - INPUT, OUTPUT, BOTH + INPUT, OUTPUT, BOTH } diff --git a/src/main/java/org/scijava/ItemVisibility.java b/src/main/java/org/scijava/ItemVisibility.java index 47b0e9276..c2b8abd46 100644 --- a/src/main/java/org/scijava/ItemVisibility.java +++ b/src/main/java/org/scijava/ItemVisibility.java @@ -6,13 +6,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 @@ -31,36 +31,36 @@ /** * Defines the "visibility" of a parameter. - * + * * @author Curtis Rueden */ public enum ItemVisibility { - /** - * Item is included in the history for purposes of data provenance, and - * included as a parameter when recording scripts. - */ - NORMAL, + /** + * Item is included in the history for purposes of data provenance, and + * included as a parameter when recording scripts. + */ + NORMAL, - /** - * Item is excluded from the history for the purposes of data provenance, but - * still included as a parameter when recording scripts. - */ - TRANSIENT, + /** + * Item is excluded from the history for the purposes of data provenance, + * but still included as a parameter when recording scripts. + */ + TRANSIENT, - /** - * Item is excluded from the history for the purposes of data provenance, and - * also excluded as a parameter when recording scripts. This option should - * only be used for items with no effect on the final output, such as a - * "verbose" flag. - */ - INVISIBLE, + /** + * Item is excluded from the history for the purposes of data provenance, + * and also excluded as a parameter when recording scripts. This option + * should only be used for items with no effect on the final output, such as + * a "verbose" flag. + */ + INVISIBLE, - /** - * As {@link #INVISIBLE}, and further indicating that the item's value is - * intended as a message to the user (e.g., in the input harvester panel) - * rather than an actual parameter to the module execution. - */ - MESSAGE + /** + * As {@link #INVISIBLE}, and further indicating that the item's value is + * intended as a message to the user (e.g., in the input harvester panel) + * rather than an actual parameter to the module execution. + */ + MESSAGE } diff --git a/src/main/java/org/scijava/Locatable.java b/src/main/java/org/scijava/Locatable.java index 5184b2552..57635a427 100644 --- a/src/main/java/org/scijava/Locatable.java +++ b/src/main/java/org/scijava/Locatable.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * An object whose location is defined by a URL string. - * + * * @author Curtis Rueden */ public interface Locatable { diff --git a/src/main/java/org/scijava/MenuEntry.java b/src/main/java/org/scijava/MenuEntry.java index d436963fc..2f3752847 100644 --- a/src/main/java/org/scijava/MenuEntry.java +++ b/src/main/java/org/scijava/MenuEntry.java @@ -6,13 +6,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,7 +33,7 @@ /** * One component of a menu path, for use with {@link MenuPath}. - * + * * @author Curtis Rueden * @author Johannes Schindelin */ @@ -56,8 +56,8 @@ public MenuEntry(final String name, final double weight) { setWeight(weight); } - public MenuEntry(final String name, final double weight, - final char mnemonic, final Accelerator acc, final String iconPath) + public MenuEntry(final String name, final double weight, final char mnemonic, + final Accelerator acc, final String iconPath) { setName(name); setWeight(weight); diff --git a/src/main/java/org/scijava/MenuPath.java b/src/main/java/org/scijava/MenuPath.java index 941c4a860..794720a44 100644 --- a/src/main/java/org/scijava/MenuPath.java +++ b/src/main/java/org/scijava/MenuPath.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * A path in a hierarchical menu structure, for use with {@link UIDetails}. - * + * * @author Curtis Rueden */ public class MenuPath extends ArrayList { @@ -60,7 +60,7 @@ public MenuPath(final Collection menuEntries) { /** * Creates a menu path with entries parsed from the given string. Assumes * {@code >} as the separator (e.g., {@code File>New>Image}). - * + * * @see #PATH_SEPARATOR */ public MenuPath(final String path) { diff --git a/src/main/java/org/scijava/Named.java b/src/main/java/org/scijava/Named.java index bdb669e16..fc59210e7 100644 --- a/src/main/java/org/scijava/Named.java +++ b/src/main/java/org/scijava/Named.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Interface for things that have names. - * + * * @author Lee Kamentsky */ public interface Named { diff --git a/src/main/java/org/scijava/NoSuchServiceException.java b/src/main/java/org/scijava/NoSuchServiceException.java index 4f25b47d3..9b4922f0a 100644 --- a/src/main/java/org/scijava/NoSuchServiceException.java +++ b/src/main/java/org/scijava/NoSuchServiceException.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * An exception thrown when a {@link Gateway} cannot obtain a * {@link org.scijava.service.Service}. - * + * * @author Mark Hiner * @author Curtis Rueden */ diff --git a/src/main/java/org/scijava/NullContextException.java b/src/main/java/org/scijava/NullContextException.java index 32eca3f18..f6f92aeff 100644 --- a/src/main/java/org/scijava/NullContextException.java +++ b/src/main/java/org/scijava/NullContextException.java @@ -6,13 +6,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 @@ -31,14 +31,14 @@ /** * An exception thrown when a {@link Context} is null, but shouldn't be. - * + * * @author Curtis Rueden */ public class NullContextException extends RuntimeException { private static final String DEFAULT_MESSAGE = - "Before attempting to use this object, " - + "please set its context by calling the setContext(...) method."; + "Before attempting to use this object, " + + "please set its context by calling the setContext(...) method."; public NullContextException() { this(DEFAULT_MESSAGE); diff --git a/src/main/java/org/scijava/Optional.java b/src/main/java/org/scijava/Optional.java index 34b10025a..985db07fd 100644 --- a/src/main/java/org/scijava/Optional.java +++ b/src/main/java/org/scijava/Optional.java @@ -6,13 +6,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 @@ -32,16 +32,15 @@ /** * A marker interface for optional SciJava components. *

    - * Some components might be discoverable, but cannot always be initialized, - * e.g. when relying on proprietary libraries. Such components can be marked - * with this interface to indicate that failure to initialize should not - * necessarily cause the entire application context to collapse, for example. + * Some components might be discoverable, but cannot always be initialized, e.g. + * when relying on proprietary libraries. Such components can be marked with + * this interface to indicate that failure to initialize should not necessarily + * cause the entire application context to collapse, for example. *

    - * + * * @author Johannes Schindelin * @see org.scijava.service.Service */ public interface Optional { // NB: Marker interface. } - diff --git a/src/main/java/org/scijava/Prioritized.java b/src/main/java/org/scijava/Prioritized.java index 8ecc6c528..a0bde7688 100644 --- a/src/main/java/org/scijava/Prioritized.java +++ b/src/main/java/org/scijava/Prioritized.java @@ -6,13 +6,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,21 +33,21 @@ /** * An object that can be sorted according to priority. - * + * * @author Curtis Rueden */ public interface Prioritized extends Comparable { /** * Gets the sort priority of the object. - * + * * @see Priority */ double getPriority(); /** * Sets the sort priority of the object. - * + * * @see Priority */ void setPriority(double priority); diff --git a/src/main/java/org/scijava/Priority.java b/src/main/java/org/scijava/Priority.java index e2fbddfd0..c4746626b 100644 --- a/src/main/java/org/scijava/Priority.java +++ b/src/main/java/org/scijava/Priority.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Constants for specifying an item's priority. - * + * * @author Johannes Schindelin * @author Curtis Rueden * @see org.scijava.Prioritized#getPriority() @@ -74,10 +74,11 @@ private Priority() { /** Priority for items that very strongly prefer to be sorted late. */ public static final double EXTREMELY_LOW = -1000000; - /** Priority for items that must be sorted last. + /** + * Priority for items that must be sorted last. *

    - * Note that it is still possible to prioritize something later - * than this value (e.g., for testing purposes), although doing so strongly + * Note that it is still possible to prioritize something later than + * this value (e.g., for testing purposes), although doing so strongly * discouraged in production. *

    */ @@ -94,17 +95,17 @@ private Priority() { * impose logic beyond that of this method, for breaking ties, if a total * ordering consistent with equals is always required. *

    - * + * * @return -1 if {@code p1}'s priority is higher than {@code p2}'s, 1 if * {@code p2}'s priority is higher than {@code p1}'s, or 0 if they * have the same priority. * @see org.scijava.util.ClassUtils#compare(Class, Class) */ public static int compare(final Prioritized p1, final Prioritized p2) { - final double priority1 = - p1 == null ? Double.NEGATIVE_INFINITY : p1.getPriority(); - final double priority2 = - p2 == null ? Double.NEGATIVE_INFINITY : p2.getPriority(); + final double priority1 = p1 == null ? Double.NEGATIVE_INFINITY : p1 + .getPriority(); + final double priority2 = p2 == null ? Double.NEGATIVE_INFINITY : p2 + .getPriority(); if (priority1 == priority2) return 0; // NB: We invert the ordering here, so that large values come first, // rather than the typical natural ordering of smaller values first. @@ -115,7 +116,7 @@ public static int compare(final Prioritized p1, final Prioritized p2) { * Injects the specified priority into the given object. Note that this is * only possible if the given object implements the {@link Prioritized} * interface. - * + * * @param o The object to which the priority should be assigned. * @return true If the priority was successfully injected. */ diff --git a/src/main/java/org/scijava/SciJava.java b/src/main/java/org/scijava/SciJava.java index 90a3be54c..735d0df07 100644 --- a/src/main/java/org/scijava/SciJava.java +++ b/src/main/java/org/scijava/SciJava.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ * Main entry point into SciJava. This class enables working with SciJava * services in a simple way, while retaining extensibility (i.e., access to * third-party services). - * + * * @author Curtis Rueden */ @Plugin(type = Gateway.class, name = "sj") @@ -54,7 +54,7 @@ public SciJava() { /** * Creates a new Scijava application context. - * + * * @param empty If true, the context will be empty; otherwise, it will be * initialized with all available services. */ @@ -79,7 +79,7 @@ public SciJava(final boolean empty) { * To avoid this, we have opted to use raw types and suppress the relevant * warning here instead. *

    - * + * * @param serviceClasses A list of types that implement the {@link Service} * interface (e.g., {@code LogService.class}). * @throws ClassCastException If any of the given arguments do not implement @@ -93,7 +93,7 @@ public SciJava(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 LogService.class}). */ @@ -104,7 +104,7 @@ public SciJava(final Collection> serviceClasses) { /** * Creates a new SciJava application context which wraps the given existing * SciJava context. - * + * * @see Context */ public SciJava(final Context context) { diff --git a/src/main/java/org/scijava/Typed.java b/src/main/java/org/scijava/Typed.java index 552d1fd00..1b89d966e 100644 --- a/src/main/java/org/scijava/Typed.java +++ b/src/main/java/org/scijava/Typed.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * An object with an associated type (i.e., {@link Class}), which can be queried * at runtime. - * + * * @author Curtis Rueden */ public interface Typed { diff --git a/src/main/java/org/scijava/UIDetails.java b/src/main/java/org/scijava/UIDetails.java index 896c6bb18..98a9182c9 100644 --- a/src/main/java/org/scijava/UIDetails.java +++ b/src/main/java/org/scijava/UIDetails.java @@ -6,13 +6,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 @@ -35,14 +35,14 @@ /** * An interface defining details useful for generating relevant user interface * elements. - * + * * @author Curtis Rueden */ public interface UIDetails extends BasicDetails, Prioritized { /** * The default, application-level menu root. - * + * * @see #getMenuRoot() */ String APPLICATION_MENU_ROOT = "app"; diff --git a/src/main/java/org/scijava/Validated.java b/src/main/java/org/scijava/Validated.java index 4fabe278a..c93dfb444 100644 --- a/src/main/java/org/scijava/Validated.java +++ b/src/main/java/org/scijava/Validated.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An object whose validity can be confirmed after initialization. If the object * is deemed invalid, a list of reasons for invalidity can be requested. - * + * * @author Curtis Rueden */ public interface Validated { @@ -47,7 +47,7 @@ public interface Validated { /** * Gets the list of problems encountered while initializing the object. - * + * * @return The list of problems, or a zero-length list in the case of * {@link #isValid()} returning true. */ diff --git a/src/main/java/org/scijava/ValidityProblem.java b/src/main/java/org/scijava/ValidityProblem.java index b95d1e02b..d6d41c861 100644 --- a/src/main/java/org/scijava/ValidityProblem.java +++ b/src/main/java/org/scijava/ValidityProblem.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ * Unlike most exceptions, {@code ValidityException} is typically not thrown, * but rather only recorded for future reference. *

    - * + * * @author Curtis Rueden */ public class ValidityProblem extends Exception { diff --git a/src/main/java/org/scijava/Versioned.java b/src/main/java/org/scijava/Versioned.java index eb5c0cda5..f4f3bf9ec 100644 --- a/src/main/java/org/scijava/Versioned.java +++ b/src/main/java/org/scijava/Versioned.java @@ -6,13 +6,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,7 +33,7 @@ /** * An object that knows its version. - * + * * @author Curtis Rueden */ public interface Versioned { @@ -43,5 +43,4 @@ default String getVersion() { return VersionUtils.getVersion(getClass()); } - } diff --git a/src/main/java/org/scijava/annotations/AbstractIndexWriter.java b/src/main/java/org/scijava/annotations/AbstractIndexWriter.java index 730739ca6..17ed97d10 100644 --- a/src/main/java/org/scijava/annotations/AbstractIndexWriter.java +++ b/src/main/java/org/scijava/annotations/AbstractIndexWriter.java @@ -6,13 +6,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 @@ -53,7 +53,7 @@ * describe the class which was annotated together with the specific annotation * fields. *

    - * + * * @author Johannes Schindelin */ public abstract class AbstractIndexWriter { @@ -94,8 +94,8 @@ protected synchronized void write(final StreamFactory factory) for (Entry> entry : map.entrySet()) { final String annotationName = entry.getKey(); merge(annotationName, factory); - final PrintStream out = - new PrintStream(factory.openOutput(annotationName)); + final PrintStream out = new PrintStream(factory.openOutput( + annotationName)); for (Object o : entry.getValue().values()) { writeObject(out, adapt(o)); } @@ -110,7 +110,7 @@ protected synchronized void write(final StreamFactory factory) * This method is used to read previously-indexed annotations and reconcile * them with the newly-generated ones just. *

    - * + * * @param annotationName the name of the annotation for which the index * contains the annotated classes * @param factory the factory to generate input and output streams given an @@ -136,8 +136,8 @@ protected synchronized void merge(final String annotationName, int changedCount = m.size(); boolean hasObsoletes = false; - final IndexReader reader = - new IndexReader(in, annotationName + " from " + in); + final IndexReader reader = new IndexReader(in, annotationName + " from " + + in); try { for (;;) { @SuppressWarnings("unchecked") diff --git a/src/main/java/org/scijava/annotations/AnnotationCombiner.java b/src/main/java/org/scijava/annotations/AnnotationCombiner.java index 33338727a..ea6bba710 100644 --- a/src/main/java/org/scijava/annotations/AnnotationCombiner.java +++ b/src/main/java/org/scijava/annotations/AnnotationCombiner.java @@ -6,13 +6,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 @@ -46,10 +46,11 @@ /** * Combines annotation indexes from all JAR files on the classpath. - * + * * @author Curtis Rueden */ -public class AnnotationCombiner extends AbstractIndexWriter implements Combiner +public class AnnotationCombiner extends AbstractIndexWriter implements + Combiner { private static final String PREFIX = "META-INF/json/"; @@ -74,8 +75,8 @@ public void combine(File outputDirectory) throws Exception { @SuppressWarnings("unchecked") final Class annotation = (Class) loader.loadClass(annotationName); - for (IndexItem item : Index - .load(annotation, loader)) + for (IndexItem item : Index.load(annotation, + loader)) { add(adapt(item.annotation()), annotationName, item.className()); } @@ -89,8 +90,8 @@ public Set getAnnotationFiles() throws IOException { final HashSet files = new HashSet<>(); for (final String prefix : new String[] { PREFIX, LEGACY_PREFIX }) { - final Enumeration directories = - Context.getClassLoader().getResources(prefix); + final Enumeration directories = Context.getClassLoader() + .getResources(prefix); while (directories.hasMoreElements()) { final URL url = directories.nextElement(); for (final URL annotationIndexURL : FileUtils.listContents(url)) { @@ -99,8 +100,8 @@ public Set getAnnotationFiles() throws IOException { continue; } final int length = string.length(); - add(files, PREFIX + - string.substring(string.lastIndexOf('/', length - 1) + 1, length)); + add(files, PREFIX + string.substring(string.lastIndexOf('/', length - + 1) + 1, length)); } } } @@ -151,8 +152,9 @@ public boolean isClassObsolete(String className) { } // -- Main method -- - + public static void main(final String[] args) throws Exception { - new AnnotationCombiner().combine(args.length > 0 ? new File(args[0]) : null); + new AnnotationCombiner().combine(args.length > 0 ? new File(args[0]) + : null); } } diff --git a/src/main/java/org/scijava/annotations/AnnotationProcessor.java b/src/main/java/org/scijava/annotations/AnnotationProcessor.java index e9acebd7c..9d5bb04fe 100644 --- a/src/main/java/org/scijava/annotations/AnnotationProcessor.java +++ b/src/main/java/org/scijava/annotations/AnnotationProcessor.java @@ -6,13 +6,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 @@ -70,7 +70,7 @@ /** * The annotation processor for use with Java 8 and earlier. - * + * * @author Johannes Schindelin */ @SupportedSourceVersion(SourceVersion.RELEASE_8) @@ -100,8 +100,8 @@ public boolean process(final Set elements, processingEnv.getMessager().printMessage(Kind.ERROR, out.toString()); } catch (final IOException e2) { - processingEnv.getMessager().printMessage(Kind.ERROR, - e2.getMessage() + " while printing " + e.getMessage()); + processingEnv.getMessager().printMessage(Kind.ERROR, e2.getMessage() + + " while printing " + e.getMessage()); } } return false; @@ -127,26 +127,25 @@ public void add(final TypeElement element) { originatingElements.put(annotationName, originating); } - for (final Element annotated : roundEnv - .getElementsAnnotatedWith(element)) + for (final Element annotated : roundEnv.getElementsAnnotatedWith( + element)) { switch (annotated.getKind()) { case ANNOTATION_TYPE: case CLASS: case ENUM: case INTERFACE: - final String className = - utils.getBinaryName((TypeElement) annotated).toString(); - final Map values = - adapt(annotated.getAnnotationMirrors(), element.asType()); + final String className = utils.getBinaryName( + (TypeElement) annotated).toString(); + final Map values = adapt(annotated + .getAnnotationMirrors(), element.asType()); super.add(values, annotationName, className); originating.add(annotated); break; default: - processingEnv.getMessager().printMessage( - Kind.ERROR, - "Cannot handle annotated element of kind " + - annotated.getKind()); + processingEnv.getMessager().printMessage(Kind.ERROR, + "Cannot handle annotated element of kind " + annotated + .getKind()); } } } @@ -197,9 +196,8 @@ else if (o instanceof TypeMirror) { else if (o instanceof VariableElement) { final VariableElement element = (VariableElement) o; final Map result = new TreeMap<>(); - final String enumName = - utils.getBinaryName((TypeElement) element.getEnclosingElement()) - .toString(); + final String enumName = utils.getBinaryName((TypeElement) element + .getEnclosingElement()).toString(); final String valueName = element.getSimpleName().toString(); result.put("enum", enumName); result.put("value", valueName); @@ -211,12 +209,11 @@ else if (o instanceof VariableElement) { } private AnnotationMirror getMirror(final TypeElement element) { - for (final AnnotationMirror candidate : utils - .getAllAnnotationMirrors(element)) + for (final AnnotationMirror candidate : utils.getAllAnnotationMirrors( + element)) { - final Name binaryName = - utils.getBinaryName((TypeElement) candidate.getAnnotationType() - .asElement()); + final Name binaryName = utils.getBinaryName((TypeElement) candidate + .getAnnotationType().asElement()); if (binaryName.contentEquals(Indexable.class.getName())) { return candidate; } @@ -243,9 +240,9 @@ public OutputStream openOutput(final String annotationName) { final List originating = originatingElements.get(annotationName); final String path = Index.INDEX_PREFIX + annotationName; - final FileObject fileObject = - filer.createResource(StandardLocation.CLASS_OUTPUT, "", path, - originating.toArray(new Element[originating.size()])); + final FileObject fileObject = filer.createResource( + StandardLocation.CLASS_OUTPUT, "", path, originating.toArray( + new Element[originating.size()])); // Verify that the generated file is in the META-INF/json/ subdirectory; // Despite our asking for it explicitly, the DefaultFileManager will @@ -255,9 +252,8 @@ public OutputStream openOutput(final String annotationName) if (uri != null && uri.endsWith("/" + path)) { return fileObject.openOutputStream(); } - final String prefix = - uri == null ? "" : uri.substring(0, uri.length() - - annotationName.length()); + final String prefix = uri == null ? "" : uri.substring(0, uri.length() - + annotationName.length()); final File file = new File(prefix + path); final File parent = file.getParentFile(); if (parent != null && !parent.isDirectory() && !parent.mkdirs()) { diff --git a/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java b/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java index 98ec12da7..a008e42e4 100644 --- a/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java +++ b/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ * An analyzer to parse {@code @Plugin} annotations inside a {@code .class} * file without loading the class. The idea is to inspect the classfile to parse * the annotation attributes. - * + * * @author Johannes Schindelin */ class ByteCodeAnalyzer { @@ -101,12 +101,12 @@ private double getDoubleConstant(final int index) { final int offset = poolOffsets[index - 1]; if (getU1(offset) != 6) throw new RuntimeException("Constant " + index + " does not refer to a double"); - return Double.longBitsToDouble((getU4(offset + 1) << 32) | - getU4(offset + 5)); + return Double.longBitsToDouble((getU4(offset + 1) << 32) | getU4(offset + + 5)); } - // See https://en.wikipedia.org/wiki/Java_class_file#The_constant_pool for the - // meaning of the offsets behind these numbers + // 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]; @@ -116,8 +116,8 @@ private void getConstantPoolOffsets() { final int tag = getU1(offset); 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 || tag == 18) offset += 5; + else if (tag == 3 || tag == 4 || tag == 9 || tag == 10 || tag == 11 || + tag == 12 || tag == 18) offset += 5; else if (tag == 5 || tag == 6) { poolOffsets[++i] = offset; offset += 9; @@ -177,8 +177,8 @@ private void getAllAttributes() { private Attribute[] getAttributes(final int offset) { final Attribute[] result = new Attribute[getU2(offset)]; for (int i = 0; i < result.length; i++) - result[i] = - new Attribute(i == 0 ? offset + 2 : result[i - 1].attributeEndOffset); + result[i] = new Attribute(i == 0 ? offset + 2 : result[i - + 1].attributeEndOffset); return result; } @@ -201,19 +201,17 @@ private String getName() { } private Map> getAnnotations() { - final Map> annotations = - new TreeMap<>(); + final Map> annotations = new TreeMap<>(); for (final Attribute attr : attributes) { if ("RuntimeVisibleAnnotations".equals(attr.getName())) { final byte[] buf = attr.attribute; int count = getU2(buf, 0); int offset = 2; for (int i = 0; i < count; i++) { - final String className = - raw2className(getStringConstant(getU2(buf, offset))); + final String className = raw2className(getStringConstant(getU2(buf, + offset))); offset += 2; - final Map values = - new TreeMap<>(); + final Map values = new TreeMap<>(); annotations.put(className, values); offset = parseAnnotationValues(buf, offset, values); } @@ -249,18 +247,16 @@ private int parseAnnotationValue(byte[] buf, int offset, offset += 2; break; case 'C': - value = - Character.valueOf((char) getIntegerConstant(getU2(buf, offset))); + value = Character.valueOf((char) getIntegerConstant(getU2(buf, + offset))); offset += 2; break; case 'S': - value = - Short.valueOf((short) getIntegerConstant(getU2(buf, offset))); + value = Short.valueOf((short) getIntegerConstant(getU2(buf, offset))); offset += 2; break; case 'I': - value = - Integer.valueOf((int) getIntegerConstant(getU2(buf, offset))); + value = Integer.valueOf((int) getIntegerConstant(getU2(buf, offset))); offset += 2; break; case 'J': @@ -294,8 +290,7 @@ private int parseAnnotationValue(byte[] buf, int offset, break; } case 'e': { - final Map enumValue = - new TreeMap<>(); + final Map enumValue = new TreeMap<>(); enumValue.put("enum", raw2className(getStringConstant(getU2(buf, offset)))); offset += 2; diff --git a/src/main/java/org/scijava/annotations/DirectoryIndexer.java b/src/main/java/org/scijava/annotations/DirectoryIndexer.java index 1f52f9565..dc611e96d 100644 --- a/src/main/java/org/scijava/annotations/DirectoryIndexer.java +++ b/src/main/java/org/scijava/annotations/DirectoryIndexer.java @@ -6,13 +6,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 @@ -48,7 +48,7 @@ * That will be the time when we can index the annotations, even if Eclipse * decided not to run any annotation processor. *

    - * + * * @author Johannes Schindelin */ public class DirectoryIndexer extends AbstractIndexWriter { @@ -56,9 +56,8 @@ public class DirectoryIndexer extends AbstractIndexWriter { public void index(final File directory) throws IOException { try { @SuppressWarnings("deprecation") - final URLClassLoader loader = - new URLClassLoader(new URL[] { directory.toURL() }, Thread - .currentThread().getContextClassLoader()); + final URLClassLoader loader = new URLClassLoader(new URL[] { directory + .toURL() }, Thread.currentThread().getContextClassLoader()); discoverAnnotations(directory, "", loader); } catch (MalformedURLException e) { @@ -84,8 +83,8 @@ else if (file.isFile()) { if (!fileName.endsWith(".class")) { continue; } - final String className = - classNamePrefix + fileName.substring(0, fileName.length() - 6); + final String className = classNamePrefix + fileName.substring(0, + fileName.length() - 6); try { for (final Map.Entry> entry : ByteCodeAnalyzer .getAnnotations(file).entrySet()) @@ -123,7 +122,8 @@ protected synchronized void add(final A annotation, add(adapt(annotation), annotation.annotationType().getName(), className); } - private static boolean isIndexable(final A annotation) + private static boolean isIndexable( + final A annotation) { return isIndexable(annotation.annotationType()); } @@ -137,8 +137,8 @@ protected synchronized void write(final File directory) throws IOException { @Override public InputStream openInput(String annotationName) throws IOException { - final File file = - new File(directory, Index.INDEX_PREFIX + annotationName); + final File file = new File(directory, Index.INDEX_PREFIX + + annotationName); if (file.exists()) { return new FileInputStream(file); } @@ -147,8 +147,8 @@ public InputStream openInput(String annotationName) throws IOException { @Override public OutputStream openOutput(String annotationName) throws IOException { - final File file = - new File(directory, Index.INDEX_PREFIX + annotationName); + final File file = new File(directory, Index.INDEX_PREFIX + + annotationName); final File dir = file.getParentFile(); if (dir != null && !dir.isDirectory() && !dir.mkdirs()) { throw new IOException("Could not make directory " + dir); @@ -172,8 +172,8 @@ public boolean isClassObsolete(String className) { } }; - final File[] possiblyObsoletes = - new File(directory, Index.INDEX_PREFIX).listFiles(); + final File[] possiblyObsoletes = new File(directory, Index.INDEX_PREFIX) + .listFiles(); if (possiblyObsoletes != null) { for (final File candidate : possiblyObsoletes) { if (candidate.isFile()) { diff --git a/src/main/java/org/scijava/annotations/EclipseHelper.java b/src/main/java/org/scijava/annotations/EclipseHelper.java index 07e690a01..4b5b544d6 100644 --- a/src/main/java/org/scijava/annotations/EclipseHelper.java +++ b/src/main/java/org/scijava/annotations/EclipseHelper.java @@ -6,13 +6,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 @@ -91,17 +91,18 @@ * nevertheless, updating the timestamp to reflect that we indexed the * annotations. *

    - * + * * @author Johannes Schindelin */ public class EclipseHelper extends DirectoryIndexer { - private static final String FORCE_ANNOTATION_INDEX_PROPERTY = "force.annotation.index"; + private static final String FORCE_ANNOTATION_INDEX_PROPERTY = + "force.annotation.index"; static Set indexed = new HashSet<>(); private boolean bannerShown; - private static boolean debug = - "debug".equals(System.getProperty("scijava.log.level")); + private static boolean debug = "debug".equals(System.getProperty( + "scijava.log.level")); private boolean autoDetectEclipse = true; private static void debug(final String message) { @@ -120,14 +121,12 @@ private static void debug(final String message) { * first class path element (or for tests, the first two), and only if it is a * local directory. *

    - * + * * @param loader the class loader whose class path to inspect */ public static void updateAnnotationIndex(final ClassLoader loader) { debug("Checking class loader: " + loader); - if (loader == null || - !(loader instanceof URLClassLoader)) - { + if (loader == null || !(loader instanceof URLClassLoader)) { debug("Not an URLClassLoader: " + loader); return; } @@ -139,8 +138,8 @@ public static void updateAnnotationIndex(final ClassLoader loader) { for (final URL url : ((URLClassLoader) loader).getURLs()) { debug("Checking URL: " + url); if (helper.autoDetectEclipse && first) { - if (!"file".equals(url.getProtocol()) || - (!url.getPath().endsWith("/") && !url.getPath().contains("surefire"))) + if (!"file".equals(url.getProtocol()) || (!url.getPath().endsWith( + "/") && !url.getPath().contains("surefire"))) { debug("Not Eclipse because first entry is: " + url); return; @@ -186,12 +185,14 @@ private void maybeIndex(final URL url, final ClassLoader loader) { * but crucially also the target/classes/ and target/test-classes/ * directories which may need to be indexed. */ - if (!autoDetectEclipse || url.toString().matches(".*/target/surefire/surefirebooter[0-9]*\\.jar")) try { + if (!autoDetectEclipse || url.toString().matches( + ".*/target/surefire/surefirebooter[0-9]*\\.jar")) try + { final JarFile jar = new JarFile(file); Manifest manifest = jar.getManifest(); if (manifest != null) { - final String classPath = - manifest.getMainAttributes().getValue(Name.CLASS_PATH); + final String classPath = manifest.getMainAttributes().getValue( + Name.CLASS_PATH); if (classPath != null) { for (final String element : classPath.split(" +")) try { @@ -218,8 +219,8 @@ private void maybeIndex(final URL url, final ClassLoader loader) { private void index(File directory, ClassLoader loader) { debug("Directory: " + directory); if (!directory.canWrite() || upToDate(directory) || isIJ1(directory)) { - debug("can write: " + directory.canWrite() + ", up-to-date: " + - upToDate(directory) + ", : is IJ1: " + isIJ1(directory)); + debug("can write: " + directory.canWrite() + ", up-to-date: " + upToDate( + directory) + ", : is IJ1: " + isIJ1(directory)); return; } final File jsonDirectory = new File(directory, Index.INDEX_PREFIX); diff --git a/src/main/java/org/scijava/annotations/Index.java b/src/main/java/org/scijava/annotations/Index.java index dd56ab83e..3c6ae5d05 100644 --- a/src/main/java/org/scijava/annotations/Index.java +++ b/src/main/java/org/scijava/annotations/Index.java @@ -6,13 +6,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 @@ -45,13 +45,13 @@ *

    * You would call it like this: *

    - * + * *
      * for (IndexItem<MyAnnotation> item : Index.load(MyAnnotation.class)) {
    - *   // do something with item.annotation() and/or item.className()
    + * 	// do something with item.annotation() and/or item.className()
      * }
      * 
    - * + * * @author Johannes Schindelin */ public class Index
    implements Iterable> { @@ -62,18 +62,19 @@ public class Index implements Iterable> { * The specified annotation needs to be annotated with {@link Indexable} for * the annotation indexing to work properly, of course. *

    - * + * * @param annotation the annotation type * @return the index */ - public static
    Index load(final Class annotation) + public static Index load( + final Class annotation) { return load(annotation, Thread.currentThread().getContextClassLoader()); } /** * Loads the index of all classes annotated with the specified annotation. - * + * * @param annotation the annotation type * @param loader the class loader to use when loading {@link Class}-type * annotation fields @@ -110,16 +111,15 @@ public IndexItemIterator(final Class annotation) { seen = new HashSet<>(); try { legacyURLs = new LinkedHashMap<>(); - final Enumeration legacy = - loader.getResources(LEGACY_INDEX_PREFIX + annotation.getName()); - final int legacySuffixLength = - LEGACY_INDEX_PREFIX.length() + annotation.getName().length(); + final Enumeration legacy = loader.getResources( + LEGACY_INDEX_PREFIX + annotation.getName()); + final int legacySuffixLength = LEGACY_INDEX_PREFIX.length() + annotation + .getName().length(); while (legacy.hasMoreElements()) { final URL url = legacy.nextElement(); final String string = url.toString(); - final String key = - string.substring(0, string.length() - legacySuffixLength) + - INDEX_PREFIX + annotation.getName(); + final String key = string.substring(0, string.length() - + legacySuffixLength) + INDEX_PREFIX + annotation.getName(); legacyURLs.put(key, url); } if (legacyURLs.isEmpty()) { @@ -139,7 +139,8 @@ private void readNext() throws IOException { if (indexReader == null) { try { indexReader = getNextReader(); - } catch (IOException e) { + } + catch (IOException e) { e.printStackTrace(); continue; } @@ -150,13 +151,13 @@ private void readNext() throws IOException { } } @SuppressWarnings("unchecked") - final Map map = - (Map) indexReader.next(); + final Map map = (Map) indexReader + .next(); if (map != null) { final String className = (String) map.get("class"); @SuppressWarnings("unchecked") - final Map values = - (Map) map.get("values"); + final Map values = (Map) map.get( + "values"); next = new IndexItem<>(annotation, loader, className, values); return; } @@ -179,8 +180,8 @@ private IndexReader getNextReader() throws IOException { return new IndexReader(url.openStream()); } if (legacyURLs != null && !legacyURLs.isEmpty()) { - final Entry entry = - legacyURLs.entrySet().iterator().next(); + final Entry entry = legacyURLs.entrySet().iterator() + .next(); legacyURLs.remove(entry.getKey()); return IndexReader.getLegacyReader(entry.getValue().openStream()); } diff --git a/src/main/java/org/scijava/annotations/IndexItem.java b/src/main/java/org/scijava/annotations/IndexItem.java index 67aab711f..e201c627b 100644 --- a/src/main/java/org/scijava/annotations/IndexItem.java +++ b/src/main/java/org/scijava/annotations/IndexItem.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * Allows access to individual annotations. - * + * * @author Johannes Schindelin */ public class IndexItem { @@ -60,7 +60,7 @@ public class IndexItem { /** * Obtains the annotation values. - * + * * @return the annotation values */ public A annotation() { @@ -69,7 +69,7 @@ public A annotation() { /** * Returns the name of the annotated class. - * + * * @return the name of the annotated class. */ public String className() { @@ -82,12 +82,13 @@ private static A proxy(final Class annotation, final Map map) { return (A) Proxy.newProxyInstance(loader, new Class[] { annotation }, - new InvocationHandler() { + new InvocationHandler() + { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable - { + { if (map.containsKey(method)) { return map.get(method); } @@ -100,32 +101,32 @@ public Object invoke(Object proxy, Method method, Object[] args) value = adapt(value, loader, expectedType, className); } } - else if (name.equals("toString") && - (args == null || args.length == 0)) - { - value = "@" + annotation.getName() + map; - } - else if (name.equals("annotationType") && - (args == null || args.length == 0)) - { - value = annotation; - } - else if (name.equals("hashCode") && - (args == null || args.length == 0)) - { - return annotation.hashCode() ^ map.hashCode(); - } + else if (name.equals("toString") && (args == null || + args.length == 0)) + { + value = "@" + annotation.getName() + map; + } + else if (name.equals("annotationType") && (args == null || + args.length == 0)) + { + value = annotation; + } + else if (name.equals("hashCode") && (args == null || + args.length == 0)) + { + return annotation.hashCode() ^ map.hashCode(); + } else if (name.equals("equals") && args != null && args.length == 1) { - if (!(args[0] instanceof Annotation) || - ((Annotation) args[0]).annotationType() != annotation) - { + if (!(args[0] instanceof Annotation) || ((Annotation) args[0]) + .annotationType() != annotation) + { return false; } for (Method method2 : annotation.getMethods()) { if (method2.getDeclaringClass() == annotation) { - if (!invoke(proxy, method2, new Object[0]).equals( - method2.invoke(args[0]))) - { + if (!invoke(proxy, method2, new Object[0]).equals(method2 + .invoke(args[0]))) + { return false; } } @@ -230,11 +231,10 @@ private static ClassCastException cce(final Object o, final Class expectedType, final String className, final Throwable cause) { final String oType = o == null ? "" : o.getClass().getName(); - final String eType = - expectedType == null ? "" : expectedType.getName(); - final ClassCastException cce = - new ClassCastException(className + ": cannot cast object of type " + - oType + " to " + eType); + final String eType = expectedType == null ? "" : expectedType + .getName(); + final ClassCastException cce = new ClassCastException(className + + ": cannot cast object of type " + oType + " to " + eType); if (cause != null) cce.initCause(cause); return cce; } diff --git a/src/main/java/org/scijava/annotations/IndexReader.java b/src/main/java/org/scijava/annotations/IndexReader.java index 894874238..e5843238f 100644 --- a/src/main/java/org/scijava/annotations/IndexReader.java +++ b/src/main/java/org/scijava/annotations/IndexReader.java @@ -6,13 +6,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 @@ -45,7 +45,7 @@ *

    * Example: an annotation {@code @Simple(string1 = "World")} to the * {@code Annotated} class would be serialized as - * + * *

      * {
      *     "class":"Annotated",
    @@ -54,9 +54,8 @@
      *     }
      * }
      * 
    - * *

    - * + * * @author Johannes Schindelin */ class IndexReader { @@ -69,15 +68,15 @@ class IndexReader { } IndexReader(final InputStream in, final String isName) { - this.in = - in instanceof PushbackInputStream ? (PushbackInputStream) in - : new PushbackInputStream(new BufferedInputStream(in)); + this.in = in instanceof PushbackInputStream ? (PushbackInputStream) in + : new PushbackInputStream(new BufferedInputStream(in)); this.originalISName = isName; } public Object next() throws IOException { int c = in.read(); - while (Character.isWhitespace(c)) c = in.read(); + while (Character.isWhitespace(c)) + c = in.read(); if (c < 0) { return null; } @@ -159,8 +158,8 @@ else if (c < '0' || c > '9') { if (c == '"') { return readString(); } - throw new IOException("Unexpected char: '" + (char) c + "'"+ - ((originalISName.length()>0) ? " from "+originalISName : "")); + throw new IOException("Unexpected char: '" + (char) c + "'" + + ((originalISName.length() > 0) ? " from " + originalISName : "")); } public void close() throws IOException { @@ -183,9 +182,8 @@ private int readCharacter(int first) throws IOException { if (c == '\\') { c = in.read(); if (c == 'u') { - String hex = - "" + ((char) in.read()) + ((char) in.read()) + ((char) in.read()) + - ((char) in.read()); + String hex = "" + ((char) in.read()) + ((char) in.read()) + ((char) in + .read()) + ((char) in.read()); c = Integer.parseInt(hex, 16); } else if (c != '\\' && c != '"') { @@ -198,7 +196,8 @@ else if (c != '\\' && c != '"') { private void expect(char expect) throws IOException { int c = in.read(); if (c != expect) { - throw new IOException("Expected '" + expect + "', got '" + (char) c + "'"); + throw new IOException("Expected '" + expect + "', got '" + (char) c + + "'"); } } @@ -211,7 +210,8 @@ private int expect(char a, char b) throws IOException { return 1; } throw new IOException("Expected '" + a + "' or '" + b + "', got '" + - (char) c + "'"+((originalISName.length()>0) ? " from "+originalISName : "")); + (char) c + "'" + ((originalISName.length() > 0) ? " from " + + originalISName : "")); } private void expect(String match) throws IOException { @@ -222,7 +222,7 @@ private void expect(String match) throws IOException { private IndexReader() { this.in = null; - this.originalISName=""; + this.originalISName = ""; } static IndexReader getLegacyReader(final InputStream in) throws IOException { diff --git a/src/main/java/org/scijava/annotations/Indexable.java b/src/main/java/org/scijava/annotations/Indexable.java index deb8f7d65..aca9bfed1 100644 --- a/src/main/java/org/scijava/annotations/Indexable.java +++ b/src/main/java/org/scijava/annotations/Indexable.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ * All annotations that want to be indexed need to be annotated with * {@code @Indexable}. *

    - * + * * @author Johannes Schindelin */ @Retention(RetentionPolicy.RUNTIME) diff --git a/src/main/java/org/scijava/annotations/legacy/LegacyReader.java b/src/main/java/org/scijava/annotations/legacy/LegacyReader.java index 5b3d0d129..9b04ba4bc 100644 --- a/src/main/java/org/scijava/annotations/legacy/LegacyReader.java +++ b/src/main/java/org/scijava/annotations/legacy/LegacyReader.java @@ -6,13 +6,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 @@ -49,7 +49,7 @@ * current class path library is incompatible with the one used to serialize the * data. *

    - * + * * @author Johannes Schindelin */ public class LegacyReader { @@ -74,8 +74,8 @@ public LegacyReader(final InputStream in) throws IOException { this.in = new BufferedInputStream(in); short signature = (short) read16(); if (signature != STREAM_MAGIC) { - throw new IOException("Unrecognized signature: 0x" + - Integer.toHexString(signature)); + throw new IOException("Unrecognized signature: 0x" + Integer.toHexString( + signature)); } int version = read16(); if (version != STREAM_VERSION) { @@ -122,16 +122,16 @@ else if (c == TC_CLASSDESC) { return newClassDesc(); } else { - throw new UnsupportedOperationException("Unexpected token: 0x" + - Integer.toHexString(c)); + throw new UnsupportedOperationException("Unexpected token: 0x" + Integer + .toHexString(c)); } } private void expectToken(int token) throws IOException { int c = read8(); if (c != token) { - throw new UnsupportedOperationException("Unexpected token: 0x" + - Integer.toHexString(c)); + throw new UnsupportedOperationException("Unexpected token: 0x" + Integer + .toHexString(c)); } } @@ -224,8 +224,8 @@ else if (c == TC_REFERENCE) { superClassDesc = references.get(handle); } else if (c != TC_NULL) { - throw new UnsupportedOperationException("Unexpected token: 0x" + - Integer.toHexString(c)); + throw new UnsupportedOperationException("Unexpected token: 0x" + Integer + .toHexString(c)); } return result; @@ -324,12 +324,12 @@ private class BoxedPrimitiveClassDesc extends NonPrimitiveClassDesc { private final Class clazz; - public BoxedPrimitiveClassDesc(final Class clazz, final String simpleName) + public BoxedPrimitiveClassDesc(final Class clazz, + final String simpleName) { super(toSimpleName(clazz), "value", simpleName); - this.clazz = - clazz == Double.class || clazz == Float.class ? Double.class - : clazz == Boolean.class ? Boolean.class : Long.class; + this.clazz = clazz == Double.class || clazz == Float.class ? Double.class + : clazz == Boolean.class ? Boolean.class : Long.class; } @Override @@ -354,8 +354,7 @@ public static String toSimpleName(Class clazz) { return "L" + clazz.getName().replace('.', '/') + ";"; } - private final Map classDescs = - new HashMap<>(); + private final Map classDescs = new HashMap<>(); { new ClassDesc("B") { @@ -467,7 +466,8 @@ public Map readExtra(final Map map) // implements serialVersionUID 8683452581122892189L @Override - public Object readExtra(final Map map) throws IOException + public Object readExtra(final Map map) + throws IOException { int size = (int) (long) (Long) map.get("size"); @@ -489,7 +489,8 @@ public Object readExtra(final Map map) throws IOException { @Override - public Object readExtra(final Map map) throws IOException + public Object readExtra(final Map map) + throws IOException { map.put("class", map.get("className")); return map; @@ -500,17 +501,19 @@ public Object readExtra(final Map map) throws IOException { @Override - public Object readExtra(final Map map) throws IOException + public Object readExtra(final Map map) + throws IOException { return map.get("values"); } }; - new NonPrimitiveClassDesc("Lnet/java/sezpoz/impl/SerEnumConst;", - "enumName", "Ljava/lang/String;", "constName", "Ljava/lang/String;") + new NonPrimitiveClassDesc("Lnet/java/sezpoz/impl/SerEnumConst;", "enumName", + "Ljava/lang/String;", "constName", "Ljava/lang/String;") { @Override - public Object readExtra(final Map map) throws IOException + public Object readExtra(final Map map) + throws IOException { map.put("enum", map.get("enumName")); map.put("value", map.get("constName")); @@ -522,7 +525,8 @@ public Object readExtra(final Map map) throws IOException { @Override - public Object readExtra(final Map map) throws IOException + public Object readExtra(final Map map) + throws IOException { return map.get("name"); } diff --git a/src/main/java/org/scijava/app/AbstractApp.java b/src/main/java/org/scijava/app/AbstractApp.java index eaa37331d..19bd60ca2 100644 --- a/src/main/java/org/scijava/app/AbstractApp.java +++ b/src/main/java/org/scijava/app/AbstractApp.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * Abstract superclass of {@link App} implementations. - * + * * @author Curtis Rueden */ public abstract class AbstractApp extends AbstractRichPlugin implements App { diff --git a/src/main/java/org/scijava/app/App.java b/src/main/java/org/scijava/app/App.java index bf4bf0721..16003d2fc 100644 --- a/src/main/java/org/scijava/app/App.java +++ b/src/main/java/org/scijava/app/App.java @@ -6,13 +6,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 @@ -47,7 +47,7 @@ * implementing this interface, it is encouraged to instead extend * {@link AbstractApp}, for convenience. *

    - * + * * @author Curtis Rueden * @see Plugin * @see AppService @@ -59,7 +59,6 @@ default String getTitle() { return getInfo().getName(); } - /** The Maven {@code groupId} of the application. */ String getGroupId(); @@ -79,7 +78,7 @@ default String getTitle() { /** * Gets a string with information about the application. - * + * * @param mem If true, memory usage information is included. */ default String getInfo(final boolean mem) { @@ -118,8 +117,8 @@ default File getBaseDirectory() { } /** - * Displays information about the application. Typically this action - * takes the form as About dialog in the UI, and/or a message on the console. + * Displays information about the application. Typically this action takes the + * form as About dialog in the UI, and/or a message on the console. */ void about(); @@ -147,7 +146,7 @@ default void quit() { * SciJava conforms to the
    Semantic * Versioning specification. *

    - * + * * @return The application version, in {@code major.minor.micro} format. */ @Override diff --git a/src/main/java/org/scijava/app/AppService.java b/src/main/java/org/scijava/app/AppService.java index 582860a36..346e06c53 100644 --- a/src/main/java/org/scijava/app/AppService.java +++ b/src/main/java/org/scijava/app/AppService.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * Interface for application-level functionality. - * + * * @author Curtis Rueden */ public interface AppService extends SingletonService, SciJavaService { @@ -54,7 +54,7 @@ default App getApp() { /** * Gets the table of associated applications, keyed by name. - * + * * @see org.scijava.plugin.Plugin#name() */ Map getApps(); diff --git a/src/main/java/org/scijava/app/DefaultAppService.java b/src/main/java/org/scijava/app/DefaultAppService.java index 8a97162b6..da0eab6d2 100644 --- a/src/main/java/org/scijava/app/DefaultAppService.java +++ b/src/main/java/org/scijava/app/DefaultAppService.java @@ -6,13 +6,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 @@ -46,11 +46,13 @@ /** * Default service for application-level functionality. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) -public class DefaultAppService extends AbstractSingletonService implements AppService { +public class DefaultAppService extends AbstractSingletonService implements + AppService +{ @Parameter private LogService log; @@ -76,7 +78,8 @@ public Map getApps() { // -- Event handlers -- @EventHandler(key = "org.scijava.app.AppService#about") - protected void onEvent(@SuppressWarnings("unused") final AppAboutEvent event) + protected void onEvent( + @SuppressWarnings("unused") final AppAboutEvent event) { getApp().about(); } diff --git a/src/main/java/org/scijava/app/DefaultStatusService.java b/src/main/java/org/scijava/app/DefaultStatusService.java index 38e3e555d..28be70a27 100644 --- a/src/main/java/org/scijava/app/DefaultStatusService.java +++ b/src/main/java/org/scijava/app/DefaultStatusService.java @@ -6,13 +6,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,7 +38,7 @@ /** * Default service for status notifications. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) @@ -96,17 +96,15 @@ public String getStatusMessage(final String appName, if (!"".equals(message)) return message; return appService.getApp(appName).getInfo(false); } - + /** - * Publish the status event to the event service. - * The default behavior is to publish status asynchronously. - * You can change this behavior by overriding this method - * in a derived class. - * + * Publish the status event to the event service. The default behavior is to + * publish status asynchronously. You can change this behavior by overriding + * this method in a derived class. + * * @param statusEvent the event to send to status listeners. */ - protected void publish(final StatusEvent statusEvent) - { + protected void publish(final StatusEvent statusEvent) { eventService.publishLater(statusEvent); } diff --git a/src/main/java/org/scijava/app/SciJavaApp.java b/src/main/java/org/scijava/app/SciJavaApp.java index 067184141..744bbeda5 100644 --- a/src/main/java/org/scijava/app/SciJavaApp.java +++ b/src/main/java/org/scijava/app/SciJavaApp.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Application metadata about SciJava Common. - * + * * @author Curtis Rueden * @see AppService */ diff --git a/src/main/java/org/scijava/app/StatusService.java b/src/main/java/org/scijava/app/StatusService.java index 7896b9b4a..7d6935de6 100644 --- a/src/main/java/org/scijava/app/StatusService.java +++ b/src/main/java/org/scijava/app/StatusService.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Interface for the status notification service. - * + * * @author Curtis Rueden */ public interface StatusService extends SciJavaService { @@ -51,7 +51,7 @@ public interface StatusService extends SciJavaService { /** * Updates the status message and progress bar, optionally flagging the status * notification as a warning. - * + * * @param progress New progress value * @param maximum New progress maximum * @param message New status message @@ -69,7 +69,7 @@ public interface StatusService extends SciJavaService { * Gets the status message of the given event. In the case of the empty string * (""), an alternative default string will be returned instead using the * application version of the given application. - * + * * @see StatusEvent#getStatusMessage() * @see App#getInfo(boolean) */ diff --git a/src/main/java/org/scijava/app/event/StatusEvent.java b/src/main/java/org/scijava/app/event/StatusEvent.java index d1c055557..fac9f0f56 100644 --- a/src/main/java/org/scijava/app/event/StatusEvent.java +++ b/src/main/java/org/scijava/app/event/StatusEvent.java @@ -6,13 +6,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,7 +33,7 @@ /** * An event indicating a status update. - * + * * @author Curtis Rueden */ public class StatusEvent extends SciJavaEvent { diff --git a/src/main/java/org/scijava/cache/CacheService.java b/src/main/java/org/scijava/cache/CacheService.java index aaa51c43d..3d61f14dd 100644 --- a/src/main/java/org/scijava/cache/CacheService.java +++ b/src/main/java/org/scijava/cache/CacheService.java @@ -6,13 +6,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 @@ -65,7 +65,7 @@ public interface CacheService extends SciJavaService { default V get(final Object key, final Callable valueLoader) throws ExecutionException { - return (V)get(key); + return (V) get(key); } } diff --git a/src/main/java/org/scijava/cache/DefaultCacheService.java b/src/main/java/org/scijava/cache/DefaultCacheService.java index ffba4ebb4..83e377a5d 100644 --- a/src/main/java/org/scijava/cache/DefaultCacheService.java +++ b/src/main/java/org/scijava/cache/DefaultCacheService.java @@ -6,13 +6,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/command/Command.java b/src/main/java/org/scijava/command/Command.java index 3e99f2d3f..588651b11 100644 --- a/src/main/java/org/scijava/command/Command.java +++ b/src/main/java/org/scijava/command/Command.java @@ -6,13 +6,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 @@ -46,7 +46,7 @@ * {@link ContextCommand} (or in some cases {@link ModuleCommand}, * {@link DynamicCommand} or {@link InteractiveCommand}) for convenience. *

    - * + * * @author Curtis Rueden * @see Plugin * @see PluginService diff --git a/src/main/java/org/scijava/command/CommandInfo.java b/src/main/java/org/scijava/command/CommandInfo.java index f0b2bd34c..ca72b08a9 100644 --- a/src/main/java/org/scijava/command/CommandInfo.java +++ b/src/main/java/org/scijava/command/CommandInfo.java @@ -6,13 +6,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 @@ -64,7 +64,7 @@ * implements {@link ModuleInfo}, allowing it to describe and instantiate the * command in {@link Module} form. *

    - * + * * @author Curtis Rueden * @author Johannes Schindelin * @author Grant Harris @@ -91,16 +91,13 @@ public class CommandInfo extends PluginInfo implements ModuleInfo { private boolean paramsParsed; /** List of problems detected when parsing command parameters. */ - private final List problems = - new ArrayList<>(); + private final List problems = new ArrayList<>(); /** Table of inputs, keyed on name. */ - private final Map> inputMap = - new HashMap<>(); + private final Map> inputMap = new HashMap<>(); /** Table of outputs, keyed on name. */ - private final Map> outputMap = - new HashMap<>(); + private final Map> outputMap = new HashMap<>(); /** Ordered list of input items. */ private final List> inputList = new ArrayList<>(); @@ -112,7 +109,7 @@ public class CommandInfo extends PluginInfo implements ModuleInfo { /** * Creates a new command metadata object. - * + * * @param className The name of the class, which must implement * {@link Command}. */ @@ -122,7 +119,7 @@ public CommandInfo(final String className) { /** * Creates a new command metadata object. - * + * * @param className The name of the class, which must implement * {@link Command}. * @param annotation The @{@link Plugin} annotation to associate with this @@ -134,7 +131,7 @@ public CommandInfo(final String className, final Plugin annotation) { /** * Creates a new command metadata object. - * + * * @param commandClass The plugin class, which must implement {@link Command}. */ public CommandInfo(final Class commandClass) { @@ -143,7 +140,7 @@ public CommandInfo(final Class commandClass) { /** * Creates a new command metadata object. - * + * * @param commandClass The plugin class, which must implement {@link Command}. * @param annotation The @{@link Plugin} annotation to associate with this * metadata object. @@ -157,7 +154,7 @@ public CommandInfo(final Class commandClass, /** * Creates a new command metadata object describing the same command as the * given {@link PluginInfo}. - * + * * @param info The plugin metadata to wrap. */ public CommandInfo(final PluginInfo info) { @@ -403,8 +400,8 @@ public String getIdentifier() { boolean first = true; for (final String name : pre.keySet()) { final Object value = pre.get(name); - final String sValue = - value == null ? "" : value.toString().replaceAll("[^\\w]", "_"); + final String sValue = value == null ? "" : value.toString().replaceAll( + "[^\\w]", "_"); if (first) { sb.append(", "); first = false; @@ -441,8 +438,8 @@ private void checkFields(final Class type) { problems.add(new ValidityProblem("Delegate class is abstract")); } - final List fields = - ClassUtils.getAnnotatedFields(type, Parameter.class); + final List fields = ClassUtils.getAnnotatedFields(type, + Parameter.class); for (final Field f : fields) { f.setAccessible(true); // expose private fields @@ -461,8 +458,9 @@ private void checkFields(final Class type) { } final String name = f.getName(); - if ((inputMap.containsKey(name) || outputMap.containsKey(name)) - && !Service.class.isAssignableFrom(f.getType())) { + if ((inputMap.containsKey(name) || outputMap.containsKey(name)) && + !Service.class.isAssignableFrom(f.getType())) + { // NB: Shadowed parameters are bad because they are ambiguous. final String error = "Invalid duplicate parameter: " + f; problems.add(new ValidityProblem(error)); @@ -486,8 +484,7 @@ private void checkFields(final Class type) { final boolean isPreset = presets.containsKey(name); // add item to the relevant list (inputs or outputs) - final CommandModuleItem item = - new CommandModuleItem<>(this, f); + final CommandModuleItem item = new CommandModuleItem<>(this, f); if (item.isInput()) { inputMap.put(name, item); if (!isPreset) inputList.add(item); @@ -510,8 +507,8 @@ private Class loadCommandClass() { return loadClass(); } catch (final InstantiableException e) { - final String error = - "Could not initialize command class: " + getClassName(); + final String error = "Could not initialize command class: " + + getClassName(); problems.add(new ValidityProblem(error, e)); } return null; diff --git a/src/main/java/org/scijava/command/CommandModule.java b/src/main/java/org/scijava/command/CommandModule.java index bef02fbd5..73b8d6758 100644 --- a/src/main/java/org/scijava/command/CommandModule.java +++ b/src/main/java/org/scijava/command/CommandModule.java @@ -6,13 +6,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 @@ -61,7 +61,7 @@ * To bridge the gap, this class adapts a {@link Command} instance into an * object that fully implements the {@link Module} interface. *

    - * + * * @author Curtis Rueden * @author Johannes Schindelin * @author Grant Harris diff --git a/src/main/java/org/scijava/command/CommandModuleItem.java b/src/main/java/org/scijava/command/CommandModuleItem.java index b9e602de5..d41983d0d 100644 --- a/src/main/java/org/scijava/command/CommandModuleItem.java +++ b/src/main/java/org/scijava/command/CommandModuleItem.java @@ -6,13 +6,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 @@ -47,7 +47,7 @@ /** * {@link ModuleItem} implementation describing an input or output of a command. - * + * * @author Curtis Rueden */ public class CommandModuleItem extends AbstractModuleItem { @@ -101,8 +101,8 @@ public boolean isAutoFill() { @Override public boolean isRequired() { - return getParameter().required() && - !Optional.class.isAssignableFrom(getType()); + return getParameter().required() && !Optional.class.isAssignableFrom( + getType()); } @Override @@ -150,16 +150,16 @@ public T getDefaultValue() { // NB: The default value for a command is the initial field value. // E.g.: // - // @Parameter - // private int weekdays = 5; + // @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(); + // @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. diff --git a/src/main/java/org/scijava/command/CommandService.java b/src/main/java/org/scijava/command/CommandService.java index 502113a69..5237687ea 100644 --- a/src/main/java/org/scijava/command/CommandService.java +++ b/src/main/java/org/scijava/command/CommandService.java @@ -6,13 +6,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 @@ -54,7 +54,7 @@ * It asks the {@link PluginService} for available commands, then takes care of * registering them with the {@link ModuleService}. *

    - * + * * @author Curtis Rueden * @see SciJavaPlugin * @see ModuleService @@ -124,7 +124,7 @@ List getCommandsOfClass( * then a default one is created and then executed. This default command is * not registered with the service for subsequent usage. *

    - * + * * @param className Class name of the command to execute. * @param process If true, executes the command with pre- and postprocessing * steps from all available {@link PreprocessorPlugin}s and @@ -140,8 +140,8 @@ List getCommandsOfClass( * @return {@link Future} of the module instance being executed. Calling * {@link Future#get()} will block until execution is complete. */ - Future - run(String className, boolean process, Object... inputs); + Future run(String className, boolean process, + Object... inputs); /** * Executes the first command of the given class name. @@ -150,7 +150,7 @@ List getCommandsOfClass( * then a default one is created and then executed. This default command is * not registered with the service for subsequent usage. *

    - * + * * @param className Class name of the command to execute. * @param process If true, executes the command with pre- and postprocessing * steps from all available {@link PreprocessorPlugin}s and @@ -174,7 +174,7 @@ Future run(String className, boolean process, * default one is created and then executed. This default command is * not registered with the service for subsequent usage. *

    - * + * * @param Class of the command to execute. * @param commandClass Class object of the command to execute. * @param process If true, executes the command with pre- and postprocessing @@ -201,7 +201,7 @@ Future run(Class commandClass, * default one is created and then executed. This default command is * not registered with the service for subsequent usage. *

    - * + * * @param Class of the command to execute. * @param commandClass Class object of the command to execute. * @param process If true, executes the command with pre- and postprocessing @@ -221,7 +221,7 @@ Future run(Class commandClass, /** * Executes the given command. - * + * * @param info The command to instantiate and run. * @param process If true, executes the command with pre- and postprocessing * steps from all available {@link PreprocessorPlugin}s and @@ -237,12 +237,12 @@ Future run(Class commandClass, * @return {@link Future} of the module instance being executed. Calling * {@link Future#get()} will block until execution is complete. */ - Future - run(CommandInfo info, boolean process, Object... inputs); + Future run(CommandInfo info, boolean process, + Object... inputs); /** * Executes the given command. - * + * * @param info The command to instantiate and run. * @param process If true, executes the command with pre- and postprocessing * steps from all available {@link PreprocessorPlugin}s and diff --git a/src/main/java/org/scijava/command/ContextCommand.java b/src/main/java/org/scijava/command/ContextCommand.java index ae9e3830e..a99eddafc 100644 --- a/src/main/java/org/scijava/command/ContextCommand.java +++ b/src/main/java/org/scijava/command/ContextCommand.java @@ -6,13 +6,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 @@ -73,7 +73,7 @@ * not be able to use the latter paradigm above to invoke your code in a fully * compile-time-safe way. *

    - * + * * @author Curtis Rueden */ public abstract class ContextCommand extends AbstractContextual implements diff --git a/src/main/java/org/scijava/command/DefaultCommandService.java b/src/main/java/org/scijava/command/DefaultCommandService.java index f1d59a2b0..2900fbc52 100644 --- a/src/main/java/org/scijava/command/DefaultCommandService.java +++ b/src/main/java/org/scijava/command/DefaultCommandService.java @@ -6,13 +6,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 @@ -55,7 +55,7 @@ * Default service for working with {@link Command}s. Available commands are * obtained from the plugin service. Loading of the actual command classes can * be deferred until a particular command's first execution. - * + * * @author Curtis Rueden * @see Command */ @@ -132,17 +132,16 @@ public CommandInfo getCommand(final String className) { public List getCommandsOfClass( final Class commandClass) { - final List> plugins = - pluginService.getPluginsOfClass(commandClass, Command.class); + final List> plugins = pluginService.getPluginsOfClass( + commandClass, Command.class); final List commands = getCommands(plugins); return commands; } @Override - public List getCommandsOfClass(final String className) - { - final List> plugins = - pluginService.getPluginsOfClass(className); + public List getCommandsOfClass(final String className) { + final List> plugins = pluginService + .getPluginsOfClass(className); final List commands = getCommandsUnknown(downcast(plugins)); return commands; } @@ -206,8 +205,8 @@ public void initialize() { commandMap = new HashMap<>(); // inform the module service of available commands - final List> plugins = - pluginService.getPluginsOfType(Command.class); + final List> plugins = pluginService.getPluginsOfType( + Command.class); addCommands(plugins); } @@ -220,8 +219,7 @@ protected void onEvent(final PluginsRemovedEvent event) { @EventHandler protected void onEvent(final PluginsAddedEvent event) { - final ArrayList> commands = - new ArrayList<>(); + final ArrayList> commands = new ArrayList<>(); findCommandPlugins(event.getItems(), commands); addCommands(commands); } @@ -239,8 +237,8 @@ private CommandInfo getOrCreate(final String className) { } /** - * Gets a {@link CommandInfo} for the given class, creating a new one if - * none are registered with the service. + * Gets a {@link CommandInfo} for the given class, creating a new one if none + * are registered with the service. */ private CommandInfo getOrCreate( final Class commandClass) @@ -297,7 +295,7 @@ private List getCommandsUnknown( /** * Transfers command plugins from the source list to the destination list. - * + * * @param srcList The list to scan for matching plugins. * @param destList The list to which matching plugins are added. */ diff --git a/src/main/java/org/scijava/command/DynamicCommand.java b/src/main/java/org/scijava/command/DynamicCommand.java index 5d165192d..9e2ebd9e8 100644 --- a/src/main/java/org/scijava/command/DynamicCommand.java +++ b/src/main/java/org/scijava/command/DynamicCommand.java @@ -6,13 +6,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 @@ -46,7 +46,7 @@ * greater configurability, but also greater complexity, than implementing the * {@link Command} interface and using only @{@link Parameter} annotations on * instance fields. - * + * * @author Curtis Rueden */ public abstract class DynamicCommand extends DefaultMutableModule implements diff --git a/src/main/java/org/scijava/command/DynamicCommandInfo.java b/src/main/java/org/scijava/command/DynamicCommandInfo.java index 738521744..10dadf74e 100644 --- a/src/main/java/org/scijava/command/DynamicCommandInfo.java +++ b/src/main/java/org/scijava/command/DynamicCommandInfo.java @@ -6,13 +6,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 @@ -56,7 +56,7 @@ * well as provide metadata manipulation functionality such as * {@link MutableModuleInfo#addInput(ModuleItem)}. *

    - * + * * @author Curtis Rueden */ public class DynamicCommandInfo extends DefaultMutableModuleInfo { @@ -84,7 +84,7 @@ public DynamicCommandInfo(final CommandInfo info, * {@link ModuleItem} in question was of unknown (i.e., potentially * non-mutable) origin. *

    - * + * * @throws ClassCastException if input is not a {@link MutableModuleItem}. */ public MutableModuleItem getMutableInput(final String name, @@ -104,7 +104,7 @@ public MutableModuleItem getMutableInput(final String name, * {@link ModuleItem} in question was of unknown (i.e., potentially * non-mutable) origin. *

    - * + * * @throws ClassCastException if output is not a {@link MutableModuleItem}. */ public MutableModuleItem getMutableOutput(final String name, diff --git a/src/main/java/org/scijava/command/Inputs.java b/src/main/java/org/scijava/command/Inputs.java index a97d282f2..846cc4313 100644 --- a/src/main/java/org/scijava/command/Inputs.java +++ b/src/main/java/org/scijava/command/Inputs.java @@ -6,13 +6,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 @@ -70,7 +70,8 @@ * wordInput.setLabel("Favorite word"); * wordInput.setChoices(Arrays.asList("quick", "brown", "fox")); * wordInput.setDefaultValue("fox"); - * MutableModuleItem opacityInput = inputs.addInput("opacity", Double.class); + * MutableModuleItem opacityInput = inputs.addInput("opacity", + * Double.class); * opacityInput.setMinimumValue(0.0); * opacityInput.setMaximumValue(1.0); * opacityInput.setDefaultValue(0.5); diff --git a/src/main/java/org/scijava/command/Interactive.java b/src/main/java/org/scijava/command/Interactive.java index 6f4d93375..d93fbed4b 100644 --- a/src/main/java/org/scijava/command/Interactive.java +++ b/src/main/java/org/scijava/command/Interactive.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ *

    * See {@link InteractiveCommand} for the most typical use case. *

    - * + * * @author Curtis Rueden * @see ModuleInfo#isInteractive() */ diff --git a/src/main/java/org/scijava/command/InteractiveCommand.java b/src/main/java/org/scijava/command/InteractiveCommand.java index 1edf9a4b3..9a7ad4217 100644 --- a/src/main/java/org/scijava/command/InteractiveCommand.java +++ b/src/main/java/org/scijava/command/InteractiveCommand.java @@ -6,13 +6,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 @@ -55,7 +55,7 @@ * add callback methods to affected inputs, for reacting to a change in the * active display. *

    - * + * * @author Curtis Rueden */ public abstract class InteractiveCommand extends DynamicCommand implements @@ -74,12 +74,14 @@ public abstract class InteractiveCommand extends DynamicCommand implements @Parameter private LogService log; - /** List of names of inputs to keep in sync when the active display changes. */ + /** + * List of names of inputs to keep in sync when the active display changes. + */ private final String[] listenerNames; /** * Creates a new interactive command. - * + * * @param listenerNames The list of names of inputs to keep in sync when the * active display changes. Each input must be a {@link Display}. */ diff --git a/src/main/java/org/scijava/command/ModuleCommand.java b/src/main/java/org/scijava/command/ModuleCommand.java index 2a2bb9469..9499363bf 100644 --- a/src/main/java/org/scijava/command/ModuleCommand.java +++ b/src/main/java/org/scijava/command/ModuleCommand.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ * A command which implements {@link Module} directly (rather than using the * {@link CommandModule} adapter class). This is useful for commands which want * to inspect and manipulate their own inputs and outputs programmatically. - * + * * @author Curtis Rueden */ public abstract class ModuleCommand extends AbstractModule implements diff --git a/src/main/java/org/scijava/command/Previewable.java b/src/main/java/org/scijava/command/Previewable.java index 330d8472c..ae9bfec25 100644 --- a/src/main/java/org/scijava/command/Previewable.java +++ b/src/main/java/org/scijava/command/Previewable.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An operation (usually a {@link Command}) whose results can be previewed. - * + * * @author Curtis Rueden */ public interface Previewable { diff --git a/src/main/java/org/scijava/command/UnimplementedCommand.java b/src/main/java/org/scijava/command/UnimplementedCommand.java index 763d324cf..31735b5be 100644 --- a/src/main/java/org/scijava/command/UnimplementedCommand.java +++ b/src/main/java/org/scijava/command/UnimplementedCommand.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * A command that is not yet implemented. It exists so that stub commands can * override it trivially, and act as markers of future functionality. - * + * * @author Curtis Rueden */ public abstract class UnimplementedCommand extends ContextCommand { diff --git a/src/main/java/org/scijava/command/console/RunArgument.java b/src/main/java/org/scijava/command/console/RunArgument.java index e5dac33f2..7f0d9a959 100644 --- a/src/main/java/org/scijava/command/console/RunArgument.java +++ b/src/main/java/org/scijava/command/console/RunArgument.java @@ -6,13 +6,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 @@ -64,15 +64,15 @@ public RunArgument() { @Override public void handle(final LinkedList args) { - if (!supports(args)) - return; + if (!supports(args)) return; 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() : ""; + final String paramString = ConsoleUtils.hasParam(args) ? args.removeFirst() + : ""; run(commandToRun, paramString); } @@ -81,8 +81,7 @@ public void handle(final LinkedList args) { @Override public boolean supports(final LinkedList args) { - if (!super.supports(args)) - return false; + if (!super.supports(args)) return false; return getInfo(args.get(1)) != null; } @@ -94,15 +93,16 @@ private void run(final String commandToRun, final String optionString) { final CommandInfo info = getInfo(commandToRun); // couldn't find anything to run - if (info == null) - return; + if (info == null) return; // TODO: parse the optionString a la ImageJ1 - final Map inputMap = ConsoleUtils.parseParameterString(optionString, info, log); + final Map inputMap = ConsoleUtils.parseParameterString( + optionString, info, log); try { commandService.run(info, true, inputMap).get(); - } catch (final Exception exc) { + } + catch (final Exception exc) { log.error(exc); } } diff --git a/src/main/java/org/scijava/command/run/CommandCodeRunner.java b/src/main/java/org/scijava/command/run/CommandCodeRunner.java index d823f05f9..b3fa219ff 100644 --- a/src/main/java/org/scijava/command/run/CommandCodeRunner.java +++ b/src/main/java/org/scijava/command/run/CommandCodeRunner.java @@ -6,13 +6,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 @@ -42,7 +42,7 @@ /** * Runs the given {@link Command} class. - * + * * @author Curtis Rueden */ @Plugin(type = CodeRunner.class) diff --git a/src/main/java/org/scijava/console/AbstractConsoleArgument.java b/src/main/java/org/scijava/console/AbstractConsoleArgument.java index eff1cf185..82e713d16 100644 --- a/src/main/java/org/scijava/console/AbstractConsoleArgument.java +++ b/src/main/java/org/scijava/console/AbstractConsoleArgument.java @@ -6,13 +6,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 @@ -43,6 +43,7 @@ public abstract class AbstractConsoleArgument extends AbstractHandlerPlugin> implements ConsoleArgument { + private int numArgs; private Set flags; @@ -53,11 +54,14 @@ public AbstractConsoleArgument() { public AbstractConsoleArgument(final String... flags) { this(1, flags); } - - public AbstractConsoleArgument(final int requiredArgs, final String... flags) { + + public AbstractConsoleArgument(final int requiredArgs, + final String... flags) + { numArgs = requiredArgs; this.flags = new HashSet<>(); - for (final String s : flags) this.flags.add(s); + for (final String s : flags) + this.flags.add(s); } // -- Typed methods -- @@ -85,8 +89,8 @@ protected boolean isFlag(final LinkedList args) { * 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. + * @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; diff --git a/src/main/java/org/scijava/console/ConsoleArgument.java b/src/main/java/org/scijava/console/ConsoleArgument.java index b51e8a549..b30ed8e75 100644 --- a/src/main/java/org/scijava/console/ConsoleArgument.java +++ b/src/main/java/org/scijava/console/ConsoleArgument.java @@ -6,13 +6,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/console/ConsoleService.java b/src/main/java/org/scijava/console/ConsoleService.java index e869933ed..bf14d6580 100644 --- a/src/main/java/org/scijava/console/ConsoleService.java +++ b/src/main/java/org/scijava/console/ConsoleService.java @@ -6,13 +6,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 @@ -46,7 +46,7 @@ */ public interface ConsoleService extends HandlerService, ConsoleArgument>, SciJavaService - // TODO: SJC3: Extend Listenable +// TODO: SJC3: Extend Listenable { /** Handles arguments from an external source such as the command line. */ diff --git a/src/main/java/org/scijava/console/ConsoleUtils.java b/src/main/java/org/scijava/console/ConsoleUtils.java index 909aa3ea0..15734a03f 100644 --- a/src/main/java/org/scijava/console/ConsoleUtils.java +++ b/src/main/java/org/scijava/console/ConsoleUtils.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.console; import java.util.HashMap; @@ -45,25 +46,33 @@ public final class ConsoleUtils { /** @deprecated Use {@link ParseService} instead. */ @Deprecated - public static Map parseParameterString(final String parameterString) { - return parseParameterString(parameterString, (CommandInfo)null); + public static Map parseParameterString( + final String parameterString) + { + return parseParameterString(parameterString, (CommandInfo) null); } /** @deprecated Use {@link ParseService} instead. */ @Deprecated - public static Map parseParameterString(final String parameterString, final ModuleInfo info) { + public static Map parseParameterString( + final String parameterString, final ModuleInfo info) + { return parseParameterString(parameterString, info, null); } /** @deprecated Use {@link ParseService} instead. */ @Deprecated - public static Map parseParameterString(final String parameterString, final LogService log) { + public static Map parseParameterString( + final String parameterString, final LogService log) + { return parseParameterString(parameterString, null, log); } /** @deprecated Use {@link ParseService} instead. */ @Deprecated - public static Map parseParameterString(final String parameterString, final ModuleInfo info, final LogService log) { + public static Map parseParameterString( + final String parameterString, final ModuleInfo info, final LogService log) + { final Map inputMap = new HashMap<>(); if (!parameterString.isEmpty()) { @@ -74,13 +83,12 @@ public static Map parseParameterString(final String parameterStr 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]); + 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 (log != null) - log.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/console/DefaultConsoleService.java b/src/main/java/org/scijava/console/DefaultConsoleService.java index c129e56d2..fda294cfd 100644 --- a/src/main/java/org/scijava/console/DefaultConsoleService.java +++ b/src/main/java/org/scijava/console/DefaultConsoleService.java @@ -6,13 +6,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 @@ -169,9 +169,7 @@ private MultiPrintStream multiPrintStream(final PrintStream ps) { * identical references, not per-element object equality. *

    */ - private boolean sameElements(final List l1, - final List l2) - { + 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; @@ -219,8 +217,8 @@ private ThreadContext getRelevance() { private void publish(final ThreadContext relevance, final String output) { final Context context = getContext(); final boolean contextual = relevance == ThreadContext.SAME; - final OutputEvent event = - new OutputEvent(context, source, output, contextual); + final OutputEvent event = new OutputEvent(context, source, output, + contextual); notifyListeners(event); } } diff --git a/src/main/java/org/scijava/console/MultiOutputStream.java b/src/main/java/org/scijava/console/MultiOutputStream.java index 1cc9803e9..ce73d8cf1 100644 --- a/src/main/java/org/scijava/console/MultiOutputStream.java +++ b/src/main/java/org/scijava/console/MultiOutputStream.java @@ -6,13 +6,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/console/MultiPrintStream.java b/src/main/java/org/scijava/console/MultiPrintStream.java index a194dc24d..3bca48215 100644 --- a/src/main/java/org/scijava/console/MultiPrintStream.java +++ b/src/main/java/org/scijava/console/MultiPrintStream.java @@ -6,13 +6,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/console/OutputEvent.java b/src/main/java/org/scijava/console/OutputEvent.java index dddd58e36..065c765ec 100644 --- a/src/main/java/org/scijava/console/OutputEvent.java +++ b/src/main/java/org/scijava/console/OutputEvent.java @@ -6,13 +6,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 @@ -50,7 +50,7 @@ public class OutputEvent extends SciJavaEvent { /** Possible output sources. */ public enum Source { - STDOUT, STDERR + STDOUT, STDERR } /** The source of the output. */ diff --git a/src/main/java/org/scijava/console/OutputListener.java b/src/main/java/org/scijava/console/OutputListener.java index c86479e10..9486e2bc0 100644 --- a/src/main/java/org/scijava/console/OutputListener.java +++ b/src/main/java/org/scijava/console/OutputListener.java @@ -6,13 +6,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/console/SystemPropertyArgument.java b/src/main/java/org/scijava/console/SystemPropertyArgument.java index aa2f2ddfd..e8dbb1cce 100644 --- a/src/main/java/org/scijava/console/SystemPropertyArgument.java +++ b/src/main/java/org/scijava/console/SystemPropertyArgument.java @@ -6,13 +6,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,7 +38,7 @@ /** * Handles the {@code -D} command line argument, in an analogous way to tools * such as Java and Maven. - * + * * @author Curtis Rueden */ @Plugin(type = ConsoleArgument.class) @@ -79,5 +79,4 @@ public boolean supports(final LinkedList args) { return SYS_PROP_PAT.matcher(arg).matches(); } - } diff --git a/src/main/java/org/scijava/convert/AbstractConvertService.java b/src/main/java/org/scijava/convert/AbstractConvertService.java index 18d995afd..c97077ad4 100644 --- a/src/main/java/org/scijava/convert/AbstractConvertService.java +++ b/src/main/java/org/scijava/convert/AbstractConvertService.java @@ -6,13 +6,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/AbstractConverter.java b/src/main/java/org/scijava/convert/AbstractConverter.java index a7f252b3c..b81113064 100644 --- a/src/main/java/org/scijava/convert/AbstractConverter.java +++ b/src/main/java/org/scijava/convert/AbstractConverter.java @@ -6,13 +6,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/AbstractDelegateConverter.java b/src/main/java/org/scijava/convert/AbstractDelegateConverter.java index f9b979947..4efb62b3b 100644 --- a/src/main/java/org/scijava/convert/AbstractDelegateConverter.java +++ b/src/main/java/org/scijava/convert/AbstractDelegateConverter.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Abstract superclass for {@link Converter} plugins that delegate to other * converters to chain two conversion steps together. - * + * * @author Jan Eglinger * @param the input type * @param the delegate type diff --git a/src/main/java/org/scijava/convert/ArrayConverters.java b/src/main/java/org/scijava/convert/ArrayConverters.java index 18d5f5916..d1f885d01 100644 --- a/src/main/java/org/scijava/convert/ArrayConverters.java +++ b/src/main/java/org/scijava/convert/ArrayConverters.java @@ -6,13 +6,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/ArrayToStringConverter.java b/src/main/java/org/scijava/convert/ArrayToStringConverter.java index d141d5454..7ddd8b62f 100644 --- a/src/main/java/org/scijava/convert/ArrayToStringConverter.java +++ b/src/main/java/org/scijava/convert/ArrayToStringConverter.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ * {@link String}s. This {@link Converter} can convert any array whose component * types can be converted into {@link String}s. By default, this * {@link Converter} delimits the array elements with commas. - * + * * @author Gabriel Selzer */ @Plugin(type = Converter.class, priority = Priority.VERY_LOW) diff --git a/src/main/java/org/scijava/convert/CastingConverter.java b/src/main/java/org/scijava/convert/CastingConverter.java index 1e4e80ca6..d4e5de2b8 100644 --- a/src/main/java/org/scijava/convert/CastingConverter.java +++ b/src/main/java/org/scijava/convert/CastingConverter.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.convert; import java.lang.reflect.Type; diff --git a/src/main/java/org/scijava/convert/ConversionRequest.java b/src/main/java/org/scijava/convert/ConversionRequest.java index 65ce220ba..8f6a4c960 100644 --- a/src/main/java/org/scijava/convert/ConversionRequest.java +++ b/src/main/java/org/scijava/convert/ConversionRequest.java @@ -6,13 +6,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/ConvertService.java b/src/main/java/org/scijava/convert/ConvertService.java index 84e56de9d..dad4236d8 100644 --- a/src/main/java/org/scijava/convert/ConvertService.java +++ b/src/main/java/org/scijava/convert/ConvertService.java @@ -6,13 +6,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 @@ -133,8 +133,8 @@ default boolean supports(final Class src, final Class dest) { } /** - * @return A collection of instances that could be converted to the - * specified class. + * @return A collection of instances that could be converted to the specified + * class. */ default Collection getCompatibleInputs(final Class dest) { final Set objects = new LinkedHashSet<>(); @@ -167,7 +167,9 @@ default Collection> getCompatibleInputClasses(final Class dest) { * @return A collection of all classes that could potentially be converted * from the specified class. */ - default Collection> getCompatibleOutputClasses(final Class source) { + default Collection> getCompatibleOutputClasses( + final Class source) + { final Set> compatibleClasses = new HashSet<>(); for (final Converter converter : getInstances()) { diff --git a/src/main/java/org/scijava/convert/Converter.java b/src/main/java/org/scijava/convert/Converter.java index 5b0544369..ebcda7312 100644 --- a/src/main/java/org/scijava/convert/Converter.java +++ b/src/main/java/org/scijava/convert/Converter.java @@ -6,13 +6,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 @@ -117,7 +117,7 @@ default boolean canConvert(final Object src, final Class dest) { * {@link NumberFormatException} when the conversion is actually attempted via * the {@link Integer#Integer(String)} constructor. *

    - * + * * @see #convert(Object, Type) */ default boolean canConvert(final Class src, final Type dest) { @@ -138,7 +138,7 @@ default boolean canConvert(final Class src, final Type dest) { * {@link NumberFormatException} when the conversion is actually attempted via * the {@link Integer#Integer(String)} constructor. *

    - * + * * @see #convert(Object, Class) */ default boolean canConvert(final Class src, final Class dest) { @@ -220,7 +220,7 @@ default Object convert(final Object src, final Type dest) { * and return those. But other behaviors are possible, depending on the * converter implementation. *

    - * + * * @param objects an initialized collection into which appropriate objects * will be inserted. */ diff --git a/src/main/java/org/scijava/convert/DefaultConvertService.java b/src/main/java/org/scijava/convert/DefaultConvertService.java index d14e64dce..b679c370e 100644 --- a/src/main/java/org/scijava/convert/DefaultConvertService.java +++ b/src/main/java/org/scijava/convert/DefaultConvertService.java @@ -6,13 +6,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,7 +38,6 @@ * @author Mark Hiner */ @Plugin(type = Service.class) -public class DefaultConvertService extends AbstractConvertService -{ +public class DefaultConvertService extends AbstractConvertService { // NB: No implementation needed. } diff --git a/src/main/java/org/scijava/convert/DefaultConverter.java b/src/main/java/org/scijava/convert/DefaultConverter.java index b9f53256d..4040297be 100644 --- a/src/main/java/org/scijava/convert/DefaultConverter.java +++ b/src/main/java/org/scijava/convert/DefaultConverter.java @@ -6,13 +6,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 @@ -62,8 +62,7 @@ *
  • String to Character
  • *
  • String to Enum
  • *
  • Objects where the destination Class has a constructor which takes that - * Object - *
  • + * Object * * * @author Mark Hiner @@ -209,8 +208,8 @@ private Class collectionClass(final Type type) { .findFirst().orElse(null); } - private Object - convertToArray(final Object value, final Class componentType) + private Object convertToArray(final Object value, + final Class componentType) { // First we make sure the value is a collection. This provides the simplest // interface for iterating over all the elements. We use SciJava's @@ -248,7 +247,8 @@ private Collection createCollection(Class type) { // Support conversion to common collection interface types. if (type == Queue.class || type == Deque.class) type = ArrayDeque.class; else if (type == Set.class) type = LinkedHashSet.class; - else if (type == List.class || type == Collection.class) type = ArrayList.class; + else if (type == List.class || type == Collection.class) type = + ArrayList.class; else if (type.isInterface() || Modifier.isAbstract(type.getModifiers())) { // We were given an interface or abstract class, and not a concrete // class, and we don't know what default implementation to use. diff --git a/src/main/java/org/scijava/convert/FileListConverters.java b/src/main/java/org/scijava/convert/FileListConverters.java index f4e8e86e7..d577c3d5f 100644 --- a/src/main/java/org/scijava/convert/FileListConverters.java +++ b/src/main/java/org/scijava/convert/FileListConverters.java @@ -6,13 +6,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 @@ -82,8 +82,7 @@ public T convert(final Object src, final Class dest) { final String[] tokens = StringUtils.splitUnquoted((String) src, ","); final List fileList = new ArrayList<>(); for (final String filePath : tokens) { - if ( filePath.isEmpty() ) - continue; + if (filePath.isEmpty()) continue; fileList.add(new File(filePath.replaceAll("^\"|\"$", ""))); } return (T) fileList.toArray(new File[fileList.size()]); diff --git a/src/main/java/org/scijava/convert/FileToPathConverter.java b/src/main/java/org/scijava/convert/FileToPathConverter.java index 9a6960566..a9658137d 100644 --- a/src/main/java/org/scijava/convert/FileToPathConverter.java +++ b/src/main/java/org/scijava/convert/FileToPathConverter.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * A {@link Converter} used to convert {@link File}s into {@link Path}s. - * + * * @author Gabriel Selzer */ @Plugin(type = Converter.class) diff --git a/src/main/java/org/scijava/convert/NullConverter.java b/src/main/java/org/scijava/convert/NullConverter.java index b43a5cecf..189fd1418 100644 --- a/src/main/java/org/scijava/convert/NullConverter.java +++ b/src/main/java/org/scijava/convert/NullConverter.java @@ -6,13 +6,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/NumberConverters.java b/src/main/java/org/scijava/convert/NumberConverters.java index 2f52ba40d..a8da35941 100644 --- a/src/main/java/org/scijava/convert/NumberConverters.java +++ b/src/main/java/org/scijava/convert/NumberConverters.java @@ -6,13 +6,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 @@ -44,128 +44,263 @@ public final class NumberConverters { private NumberConverters() { // prevent instantiation of container class } - - //convert to short + + // convert to short @Plugin(type = Converter.class) - public static class ByteToShortConverter extends NumberToShortConverter { - @Override public Class getInputType() { return Byte.class; } + public static class ByteToShortConverter extends + NumberToShortConverter + { + + @Override + public Class getInputType() { + return Byte.class; + } } - - //convert to int + + // convert to int @Plugin(type = Converter.class) - public static class ByteToIntegerConverter extends NumberToIntegerConverter { - @Override public Class getInputType() { return Byte.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; } + public static class ShortToIntegerConverter extends + NumberToIntegerConverter + { + + @Override + public Class getInputType() { + return Short.class; + } } - - //convert to long + + // convert to long @Plugin(type = Converter.class) public static class ByteToLongConverter extends NumberToLongConverter { - @Override public Class getInputType() { return Byte.class; } + + @Override + public Class getInputType() { + return Byte.class; + } } - + @Plugin(type = Converter.class) - public static class ShortToLongConverter extends NumberToLongConverter { - @Override public Class getInputType() { return Short.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; } + public static class IntegerToLongConverter extends + NumberToLongConverter + { + + @Override + public Class getInputType() { + return Integer.class; + } } - - //convert to float + + // convert to float @Plugin(type = Converter.class) - public static class ByteToFloatConverter extends NumberToFloatConverter { - @Override public Class getInputType() { return Byte.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; } + public static class ShortToFloatConverter extends + NumberToFloatConverter + { + + @Override + public Class getInputType() { + return Short.class; + } } - - //convert to double + // convert to double @Plugin(type = Converter.class) - public static class ByteToDoubleConverter extends NumberToDoubleConverter { - @Override public Class getInputType() { return Byte.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; } + 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; } + 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; } + public static class FloatToDoubleConverter extends + NumberToDoubleConverter + { + + @Override + public Class getInputType() { + return Float.class; + } } - - //convert to BigInteger + + // convert to BigInteger @Plugin(type = Converter.class) - public static class ByteToBigIntegerConverter extends NumberToBigIntegerConverter { - @Override public Class getInputType() { return Byte.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; } + 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; } + 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; } + public static class LongToBigIntegerConverter extends + NumberToBigIntegerConverter + { + + @Override + public Class getInputType() { + return Long.class; + } } - - //convert to BigDecimal + + // convert to BigDecimal @Plugin(type = Converter.class) - public static class ByteToBigDecimalConverter extends NumberToBigDecimalConverter { - @Override public Class getInputType() { return Byte.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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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 index 34b5a22a1..8ccbdb9bb 100644 --- a/src/main/java/org/scijava/convert/NumberToBigDecimalConverter.java +++ b/src/main/java/org/scijava/convert/NumberToBigDecimalConverter.java @@ -6,13 +6,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,7 +38,9 @@ * * @author Alison Walter */ -public abstract class NumberToBigDecimalConverter extends NumberToNumberConverter { +public abstract class NumberToBigDecimalConverter extends + NumberToNumberConverter +{ @Override public BigDecimal convert(Number n) { diff --git a/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java b/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java index 6877d4b6b..fdae19dce 100644 --- a/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java +++ b/src/main/java/org/scijava/convert/NumberToBigIntegerConverter.java @@ -6,13 +6,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/NumberToDoubleConverter.java b/src/main/java/org/scijava/convert/NumberToDoubleConverter.java index d32b0a751..6ea2f8d2a 100644 --- a/src/main/java/org/scijava/convert/NumberToDoubleConverter.java +++ b/src/main/java/org/scijava/convert/NumberToDoubleConverter.java @@ -6,13 +6,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 @@ -34,7 +34,9 @@ * * @author Alison Walter */ -public abstract class NumberToDoubleConverter extends NumberToNumberConverter { +public abstract class NumberToDoubleConverter extends + NumberToNumberConverter +{ @Override public Double convert(Number n) { diff --git a/src/main/java/org/scijava/convert/NumberToFloatConverter.java b/src/main/java/org/scijava/convert/NumberToFloatConverter.java index cc9a6b31f..1cd62ec04 100644 --- a/src/main/java/org/scijava/convert/NumberToFloatConverter.java +++ b/src/main/java/org/scijava/convert/NumberToFloatConverter.java @@ -6,13 +6,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 @@ -34,7 +34,9 @@ * * @author Alison Walter */ -public abstract class NumberToFloatConverter extends NumberToNumberConverter { +public abstract class NumberToFloatConverter extends + NumberToNumberConverter +{ @Override public Float convert(Number n) { diff --git a/src/main/java/org/scijava/convert/NumberToIntegerConverter.java b/src/main/java/org/scijava/convert/NumberToIntegerConverter.java index 799ac9ac7..5b14d7a82 100644 --- a/src/main/java/org/scijava/convert/NumberToIntegerConverter.java +++ b/src/main/java/org/scijava/convert/NumberToIntegerConverter.java @@ -6,13 +6,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 @@ -34,7 +34,9 @@ * * @author Alison Walter */ -public abstract class NumberToIntegerConverter extends NumberToNumberConverter { +public abstract class NumberToIntegerConverter extends + NumberToNumberConverter +{ @Override public Integer convert(Number n) { diff --git a/src/main/java/org/scijava/convert/NumberToLongConverter.java b/src/main/java/org/scijava/convert/NumberToLongConverter.java index 34df15429..c6384d731 100644 --- a/src/main/java/org/scijava/convert/NumberToLongConverter.java +++ b/src/main/java/org/scijava/convert/NumberToLongConverter.java @@ -6,13 +6,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 @@ -34,7 +34,9 @@ * * @author Alison Walter */ -public abstract class NumberToLongConverter extends NumberToNumberConverter { +public abstract class NumberToLongConverter extends + NumberToNumberConverter +{ @Override public Long convert(Number n) { diff --git a/src/main/java/org/scijava/convert/NumberToNumberConverter.java b/src/main/java/org/scijava/convert/NumberToNumberConverter.java index 4ad78680d..c072d8733 100644 --- a/src/main/java/org/scijava/convert/NumberToNumberConverter.java +++ b/src/main/java/org/scijava/convert/NumberToNumberConverter.java @@ -6,13 +6,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 @@ -51,9 +51,8 @@ public T convert(final Object src, final Class dest) { src.getClass().getSimpleName()); } if (Types.box(dest) != getOutputType()) { - throw new IllegalArgumentException( - "Expected output class of " + getOutputType().getSimpleName() + - ", but got " + dest.getSimpleName()); + throw new IllegalArgumentException("Expected output class of " + + getOutputType().getSimpleName() + ", but got " + dest.getSimpleName()); } @SuppressWarnings("unchecked") final T result = (T) convert((Number) src); diff --git a/src/main/java/org/scijava/convert/NumberToShortConverter.java b/src/main/java/org/scijava/convert/NumberToShortConverter.java index 858fdd13b..a7b0cfd76 100644 --- a/src/main/java/org/scijava/convert/NumberToShortConverter.java +++ b/src/main/java/org/scijava/convert/NumberToShortConverter.java @@ -6,13 +6,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 @@ -34,7 +34,9 @@ * * @author Alison Walter */ -public abstract class NumberToShortConverter extends NumberToNumberConverter { +public abstract class NumberToShortConverter extends + NumberToNumberConverter +{ @Override public Short convert(Number n) { diff --git a/src/main/java/org/scijava/convert/PathToFileConverter.java b/src/main/java/org/scijava/convert/PathToFileConverter.java index 1a066296e..4518e4fc9 100644 --- a/src/main/java/org/scijava/convert/PathToFileConverter.java +++ b/src/main/java/org/scijava/convert/PathToFileConverter.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * A {@link Converter} used to convert {@link Path}s into {@link File}s. - * + * * @author Gabriel Selzer */ @Plugin(type = Converter.class) diff --git a/src/main/java/org/scijava/convert/PrimitiveArrayUnwrapper.java b/src/main/java/org/scijava/convert/PrimitiveArrayUnwrapper.java index 32b048a30..b6833005d 100644 --- a/src/main/java/org/scijava/convert/PrimitiveArrayUnwrapper.java +++ b/src/main/java/org/scijava/convert/PrimitiveArrayUnwrapper.java @@ -6,13 +6,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/PrimitiveArrayWrapper.java b/src/main/java/org/scijava/convert/PrimitiveArrayWrapper.java index 549527f4e..5a8476011 100644 --- a/src/main/java/org/scijava/convert/PrimitiveArrayWrapper.java +++ b/src/main/java/org/scijava/convert/PrimitiveArrayWrapper.java @@ -6,13 +6,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,8 +33,8 @@ import org.scijava.util.PrimitiveArray; /** - * Abstract {@link Converter} for converting from primitive array classes to - * the SciJava {@link PrimitiveArray} classes. + * Abstract {@link Converter} for converting from primitive array classes to the + * SciJava {@link PrimitiveArray} classes. */ public abstract class PrimitiveArrayWrapper> extends AbstractConverter diff --git a/src/main/java/org/scijava/convert/StringToArrayConverter.java b/src/main/java/org/scijava/convert/StringToArrayConverter.java index 8b0996095..d0d7413ba 100644 --- a/src/main/java/org/scijava/convert/StringToArrayConverter.java +++ b/src/main/java/org/scijava/convert/StringToArrayConverter.java @@ -6,13 +6,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 @@ -49,7 +49,7 @@ * n-dimensional arrays. This {@link Converter} can convert any array whose * component types can be created from a {@link String}. By default, this * {@link Converter} delimits the {@link String} based on commas. - * + * * @author Gabriel Selzer */ @Plugin(type = Converter.class, priority = Priority.VERY_LOW) @@ -122,7 +122,7 @@ public Class getInputType() { /** * Converts {@code src} into an array of component type {@code componentType}. - * + * * @param tree the {@link String} to convert * @param componentType the component type of the output array * @return an array of {@code componentType} whose elements were created from diff --git a/src/main/java/org/scijava/convert/StringToNumberConverter.java b/src/main/java/org/scijava/convert/StringToNumberConverter.java index f8f407a87..94f17cc4f 100644 --- a/src/main/java/org/scijava/convert/StringToNumberConverter.java +++ b/src/main/java/org/scijava/convert/StringToNumberConverter.java @@ -6,13 +6,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/display/AbstractDisplay.java b/src/main/java/org/scijava/display/AbstractDisplay.java index c1fbd2ee0..4dd88fbe5 100644 --- a/src/main/java/org/scijava/display/AbstractDisplay.java +++ b/src/main/java/org/scijava/display/AbstractDisplay.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ /** * Abstract superclass of {@link Display} implementations. - * + * * @author Curtis Rueden */ public abstract class AbstractDisplay extends AbstractRichPlugin implements diff --git a/src/main/java/org/scijava/display/ActiveDisplayPreprocessor.java b/src/main/java/org/scijava/display/ActiveDisplayPreprocessor.java index fd5bc184e..53c56e82f 100644 --- a/src/main/java/org/scijava/display/ActiveDisplayPreprocessor.java +++ b/src/main/java/org/scijava/display/ActiveDisplayPreprocessor.java @@ -6,13 +6,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 @@ -47,7 +47,7 @@ * {@link Display} is not used and instead the user must select. This behavior * is consistent with ImageJ v1.x. *

    - * + * * @author Curtis Rueden */ @Plugin(type = PreprocessorPlugin.class, priority = Priority.VERY_HIGH) @@ -65,16 +65,16 @@ public class ActiveDisplayPreprocessor extends AbstractPreprocessorPlugin { public void process(final Module module) { if (displayService == null || moduleService == null) return; - final ModuleItem displayInput = - moduleService.getSingleInput(module, Display.class); + final ModuleItem displayInput = moduleService.getSingleInput(module, + Display.class); if (displayInput == null || !displayInput.isAutoFill()) return; @SuppressWarnings("unchecked") final Class> displayType = (Class>) displayInput.getType(); - final Display activeDisplay = - displayService.getActiveDisplay(displayType); + final Display activeDisplay = displayService.getActiveDisplay( + displayType); if (activeDisplay == null) return; final String name = displayInput.getName(); diff --git a/src/main/java/org/scijava/display/DefaultDisplay.java b/src/main/java/org/scijava/display/DefaultDisplay.java index e75317060..1ab5cb8ed 100644 --- a/src/main/java/org/scijava/display/DefaultDisplay.java +++ b/src/main/java/org/scijava/display/DefaultDisplay.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ //@Plugin(type = Display.class, priority = Priority.VERY_LOW) /** * Default display for objects, when no other displays are available. - * + * * @author Curtis Rueden */ public class DefaultDisplay extends AbstractDisplay { diff --git a/src/main/java/org/scijava/display/DefaultDisplayService.java b/src/main/java/org/scijava/display/DefaultDisplayService.java index b125937d4..6573fc48d 100644 --- a/src/main/java/org/scijava/display/DefaultDisplayService.java +++ b/src/main/java/org/scijava/display/DefaultDisplayService.java @@ -6,13 +6,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 @@ -51,7 +51,7 @@ /** * Default service for working with {@link Display}s. - * + * * @author Barry DeZonia * @author Curtis Rueden * @author Grant Harris @@ -77,8 +77,7 @@ public final class DefaultDisplayService extends AbstractService implements // -- instance variables -- - private final LinkedList> displayList = - new LinkedList<>(); + private final LinkedList> displayList = new LinkedList<>(); // -- DisplayService methods -- @@ -107,14 +106,15 @@ public Display getActiveDisplay() { @Override @SuppressWarnings("unchecked") - public > D getActiveDisplay(final Class displayClass) + public > D getActiveDisplay( + final Class displayClass) { for (final Display disp : displayList) { if (displayClass.isAssignableFrom(disp.getClass())) return (D) disp; } return null; } - + @Override public void setActiveDisplay(final Display display) { if (display != null) { @@ -137,8 +137,8 @@ public > PluginInfo> getDisplayPlugin( final Class pluginClass) { @SuppressWarnings({ "rawtypes", "unchecked" }) - final PluginInfo> displayPlugin = - (PluginInfo) pluginService.getPlugin(pluginClass, Display.class); + final PluginInfo> displayPlugin = (PluginInfo) pluginService + .getPlugin(pluginClass, Display.class); return displayPlugin; } @@ -164,8 +164,7 @@ public List> getDisplays() { } @Override - public > List getDisplaysOfType(final Class type) - { + public > List getDisplaysOfType(final Class type) { return objectService.getObjects(type); } diff --git a/src/main/java/org/scijava/display/DefaultTextDisplay.java b/src/main/java/org/scijava/display/DefaultTextDisplay.java index ab6044b12..07622af7d 100644 --- a/src/main/java/org/scijava/display/DefaultTextDisplay.java +++ b/src/main/java/org/scijava/display/DefaultTextDisplay.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Default display for text. - * + * * @author Curtis Rueden */ @Plugin(type = Display.class, priority = Priority.LOW) diff --git a/src/main/java/org/scijava/display/Display.java b/src/main/java/org/scijava/display/Display.java index 4886b3a1e..20b60fcfd 100644 --- a/src/main/java/org/scijava/display/Display.java +++ b/src/main/java/org/scijava/display/Display.java @@ -6,13 +6,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 @@ -45,7 +45,7 @@ * implementing this interface, it is encouraged to instead extend * {@link AbstractDisplay}, for convenience. *

    - * + * * @author Curtis Rueden * @author Grant Harris * @see Plugin @@ -56,7 +56,7 @@ public interface Display extends List, RichPlugin, Named { /** * Tests whether the display is capable of visualizing objects of the given * class. - * + * * @param c The class to check for visualization capabilities. * @return True if the display can handle certain objects of the given class; * false if it cannot visualize any objects of that class. @@ -75,7 +75,7 @@ default boolean canDisplay(final Object o) { * This method is essentially the same as {@link #add} except that it accepts * any {@link Object} regardless of type. *

    - * + * * @throws IllegalArgumentException if the object cannot be displayed (i.e., * if {@link #canDisplay(Object)} returns false). */ diff --git a/src/main/java/org/scijava/display/DisplayPostprocessor.java b/src/main/java/org/scijava/display/DisplayPostprocessor.java index a97064ce5..24c4ebd01 100644 --- a/src/main/java/org/scijava/display/DisplayPostprocessor.java +++ b/src/main/java/org/scijava/display/DisplayPostprocessor.java @@ -6,13 +6,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 @@ -46,7 +46,7 @@ /** * Displays outputs upon completion of a module execution. - * + * * @author Curtis Rueden * @author Lee Kamentsky * @author Barry DeZonia @@ -77,7 +77,7 @@ public void process(final Module module) { /** * Displays output objects. - * + * * @param defaultName The default name for the display, if not already set. * @param output The object to display. */ @@ -95,8 +95,8 @@ private boolean handleOutput(final String defaultName, final Object output) { final ArrayList> displays = new ArrayList<>(); // get list of existing displays currently visualizing this output - final List> existingDisplays = - displayService.getDisplays(output); + final List> existingDisplays = displayService.getDisplays( + output); displays.addAll(existingDisplays); if (displays.isEmpty()) { @@ -113,7 +113,7 @@ private boolean handleOutput(final String defaultName, final Object output) { String name = null; // TODO rework how displays are named - if (output instanceof Named) name = ((Named)output).getName(); + if (output instanceof Named) name = ((Named) output).getName(); if (name == null) name = defaultName; diff --git a/src/main/java/org/scijava/display/DisplayService.java b/src/main/java/org/scijava/display/DisplayService.java index dc2654396..b1bccd3b6 100644 --- a/src/main/java/org/scijava/display/DisplayService.java +++ b/src/main/java/org/scijava/display/DisplayService.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ /** * Interface for service that tracks available {@link Display}s. - * + * * @author Barry DeZonia * @author Curtis Rueden * @author Grant Harris @@ -68,7 +68,7 @@ default PluginService pluginService() { /** * Set the active display. - * + * * @param display */ void setActiveDisplay(Display display); @@ -84,7 +84,7 @@ > PluginInfo> getDisplayPlugin( /** * Gets the display plugin of the given class name, or null if none. - * + * * @throws ClassCastException if the plugin found is not a display plugin. */ PluginInfo> getDisplayPlugin(String className); @@ -113,7 +113,7 @@
    > List> getDisplayPluginsOfType( /** * Checks whether the given name is already taken by an existing display. - * + * * @param name The name to check. * @return true if the name is available, false if already taken. */ @@ -131,7 +131,7 @@
    > List> getDisplayPluginsOfType( * 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. * @return Newly created {@code Display} containing the given object. The @@ -156,7 +156,7 @@
    > List> getDisplayPluginsOfType( * 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 * then added to the display. @@ -174,7 +174,7 @@
    > List> getDisplayPluginsOfType( * 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 diff --git a/src/main/java/org/scijava/display/Displayable.java b/src/main/java/org/scijava/display/Displayable.java index 4b38e060e..d4c4b284a 100644 --- a/src/main/java/org/scijava/display/Displayable.java +++ b/src/main/java/org/scijava/display/Displayable.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * An interface used by classes that can draw on demand. Typically used by * things like the Overlay classes. - * + * * @author Barry DeZonia */ public interface Displayable { diff --git a/src/main/java/org/scijava/display/TextDisplay.java b/src/main/java/org/scijava/display/TextDisplay.java index f6eddb44f..18f4f28f3 100644 --- a/src/main/java/org/scijava/display/TextDisplay.java +++ b/src/main/java/org/scijava/display/TextDisplay.java @@ -6,13 +6,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 @@ -31,14 +31,14 @@ /** * Interface for text {@link Display}s. - * + * * @author Curtis Rueden */ public interface TextDisplay extends Display { /** * Add a line to the display. - * + * * @param text */ void append(String text); diff --git a/src/main/java/org/scijava/display/event/DisplayActivatedEvent.java b/src/main/java/org/scijava/display/event/DisplayActivatedEvent.java index 7af76b8b4..a5e6c03f8 100644 --- a/src/main/java/org/scijava/display/event/DisplayActivatedEvent.java +++ b/src/main/java/org/scijava/display/event/DisplayActivatedEvent.java @@ -6,13 +6,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,7 +33,7 @@ /** * An event indicating a display has become the active one. - * + * * @author Grant Harris */ public class DisplayActivatedEvent extends DisplayEvent { diff --git a/src/main/java/org/scijava/display/event/DisplayCreatedEvent.java b/src/main/java/org/scijava/display/event/DisplayCreatedEvent.java index eab8406e7..d5fcfaa5a 100644 --- a/src/main/java/org/scijava/display/event/DisplayCreatedEvent.java +++ b/src/main/java/org/scijava/display/event/DisplayCreatedEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An event indicating a new display has been created. - * + * * @author Curtis Rueden */ public class DisplayCreatedEvent extends ObjectCreatedEvent { diff --git a/src/main/java/org/scijava/display/event/DisplayDeletedEvent.java b/src/main/java/org/scijava/display/event/DisplayDeletedEvent.java index aeda51f31..49e0309b1 100644 --- a/src/main/java/org/scijava/display/event/DisplayDeletedEvent.java +++ b/src/main/java/org/scijava/display/event/DisplayDeletedEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An event indicating a display has been deleted. - * + * * @author Curtis Rueden */ public class DisplayDeletedEvent extends ObjectDeletedEvent { diff --git a/src/main/java/org/scijava/display/event/DisplayEvent.java b/src/main/java/org/scijava/display/event/DisplayEvent.java index 22bd5ffeb..8e905b6bb 100644 --- a/src/main/java/org/scijava/display/event/DisplayEvent.java +++ b/src/main/java/org/scijava/display/event/DisplayEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An event indicating something has happened to a {@link Display}. - * + * * @author Curtis Rueden */ public abstract class DisplayEvent extends SciJavaEvent { diff --git a/src/main/java/org/scijava/display/event/DisplayUpdatedEvent.java b/src/main/java/org/scijava/display/event/DisplayUpdatedEvent.java index d609a2391..964a737c0 100644 --- a/src/main/java/org/scijava/display/event/DisplayUpdatedEvent.java +++ b/src/main/java/org/scijava/display/event/DisplayUpdatedEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An event indicating a display has updated; e.g., an object has been added or * removed. - * + * * @author Grant Harris * @author Lee Kamentsky */ @@ -46,17 +46,17 @@ public class DisplayUpdatedEvent extends DisplayEvent { */ public enum DisplayUpdateLevel { - /** - * The data has changed, but the extents and decorations have not.
    - * An example: changing the intensity of a single pixel. - */ - UPDATE, + /** + * The data has changed, but the extents and decorations have not.
    + * An example: changing the intensity of a single pixel. + */ + UPDATE, - /** - * The extents and decorations have changed.
    - * An example: stretching an image so it's height changes. - */ - REBUILD + /** + * The extents and decorations have changed.
    + * An example: stretching an image so it's height changes. + */ + REBUILD } 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 877529707..9b1b31511 100644 --- a/src/main/java/org/scijava/display/event/input/InputEvent.java +++ b/src/main/java/org/scijava/display/event/input/InputEvent.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * An event indicating input device (e.g., keyboard or mouse) activity in a * display. - * + * * @author Curtis Rueden */ public abstract class InputEvent extends DisplayEvent { 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 3acf2bece..5d2f8228b 100644 --- a/src/main/java/org/scijava/display/event/input/KyEvent.java +++ b/src/main/java/org/scijava/display/event/input/KyEvent.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ * It is named {@code KyEvent} rather than {@code KeyEvent} to avoid name * clashes with the {@link java.awt.event.KeyEvent} hierarchy. *

    - * + * * @author Curtis Rueden */ public abstract class KyEvent extends InputEvent { @@ -66,7 +66,7 @@ public KeyCode getCode() { /** * Converts the key event into a corresponding accelerator. - * + * * @return an accelerator matching the key code and modifiers of the event. */ public Accelerator getAccelerator() { @@ -77,8 +77,8 @@ public Accelerator getAccelerator() { @Override public String toString() { - return super.toString() + "\n\tcharacter = '" + character + - "'\n\tcode = " + code + "\n\taccelerator = " + getAccelerator(); + return super.toString() + "\n\tcharacter = '" + character + "'\n\tcode = " + + code + "\n\taccelerator = " + getAccelerator(); } } 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 2c812389b..1e8141525 100644 --- a/src/main/java/org/scijava/display/event/input/KyPressedEvent.java +++ b/src/main/java/org/scijava/display/event/input/KyPressedEvent.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * An event indicating a keyboard key was pressed in a display. - * + * * @author Curtis Rueden */ public class KyPressedEvent extends KyEvent { 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 2ce597b48..5090425c7 100644 --- a/src/main/java/org/scijava/display/event/input/KyReleasedEvent.java +++ b/src/main/java/org/scijava/display/event/input/KyReleasedEvent.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * An event indicating a keyboard key was released in a display. - * + * * @author Curtis Rueden */ public class KyReleasedEvent extends KyEvent { 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 a345748ab..d0c38ecdc 100644 --- a/src/main/java/org/scijava/display/event/input/KyTypedEvent.java +++ b/src/main/java/org/scijava/display/event/input/KyTypedEvent.java @@ -6,13 +6,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 @@ -36,14 +36,13 @@ /** * An event indicating a keyboard key was typed (i.e., pressed and released) in * a display. - * + * * @author Curtis Rueden */ public class KyTypedEvent extends KyEvent { - public KyTypedEvent(final Display display, - final InputModifiers modifiers, final int x, final int y, - final char character, final KeyCode code) + public KyTypedEvent(final Display display, final InputModifiers modifiers, + final int x, final int y, final char character, final KeyCode code) { super(display, modifiers, x, y, character, code); } 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 2e728f3af..2fc43aaf1 100644 --- a/src/main/java/org/scijava/display/event/input/MsButtonEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsButtonEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An event indicating mouse button activity in a display. - * + * * @author Curtis Rueden * @author Grant Harris */ @@ -52,9 +52,9 @@ public abstract class MsButtonEvent extends MsEvent { private final int numClicks; private final boolean isPopupTrigger; - public MsButtonEvent(final Display display, - final InputModifiers modifiers, final int x, final int y, - final int button, final int numClicks, final boolean isPopupTrigger) + public MsButtonEvent(final Display display, final InputModifiers modifiers, + final int x, final int y, final int button, final int numClicks, + final boolean isPopupTrigger) { super(display, modifiers, x, y); this.button = button; 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 8962c1a80..28bb5174a 100644 --- a/src/main/java/org/scijava/display/event/input/MsClickedEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsClickedEvent.java @@ -6,13 +6,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 @@ -34,14 +34,14 @@ /** * An event indicating a mouse button was clicked in a display. - * + * * @author Curtis Rueden */ public class MsClickedEvent extends MsButtonEvent { public MsClickedEvent(final Display display, - final InputModifiers modifiers, final int x, final int y, - final int button, final int numClicks, final boolean isPopupTrigger) + final InputModifiers modifiers, final int x, final int y, final int button, + final int numClicks, final boolean isPopupTrigger) { super(display, modifiers, x, y, button, numClicks, isPopupTrigger); } 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 226453319..619d2fc08 100644 --- a/src/main/java/org/scijava/display/event/input/MsDraggedEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsDraggedEvent.java @@ -6,13 +6,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 @@ -34,14 +34,14 @@ /** * An event indicating a mouse was dragged in a display. - * + * * @author Curtis Rueden */ public class MsDraggedEvent extends MsButtonEvent { public MsDraggedEvent(final Display display, - final InputModifiers modifiers, final int x, final int y, - final int button, final int numClicks, final boolean isPopupTrigger) + final InputModifiers modifiers, final int x, final int y, final int button, + final int numClicks, final boolean isPopupTrigger) { super(display, modifiers, x, y, button, numClicks, isPopupTrigger); } 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 1ee9e2cf5..62d2b8f1d 100644 --- a/src/main/java/org/scijava/display/event/input/MsEnteredEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsEnteredEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An event indicating a mouse cursor entered a display. - * + * * @author Curtis Rueden */ public class MsEnteredEvent extends MsEvent { 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 5e1d047f0..f22af24bf 100644 --- a/src/main/java/org/scijava/display/event/input/MsEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsEvent.java @@ -6,13 +6,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,7 +38,7 @@ * It is named {@code MsEvent} rather than {@code MouseEvent} to avoid name * clashes with the {@link java.awt.event.MouseEvent} hierarchy. *

    - * + * * @author Curtis Rueden */ public abstract class MsEvent extends InputEvent { 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 f60eb58b2..e0e217e56 100644 --- a/src/main/java/org/scijava/display/event/input/MsExitedEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsExitedEvent.java @@ -6,13 +6,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 @@ -34,13 +34,13 @@ /** * An event indicating a mouse cursor exited a display. - * + * * @author Curtis Rueden */ public class MsExitedEvent extends MsEvent { - public MsExitedEvent(final Display display, - final InputModifiers modifiers, final int x, final int y) + public MsExitedEvent(final Display display, final InputModifiers modifiers, + final int x, final int y) { super(display, modifiers, x, y); } 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 ba737a960..2dabf4957 100644 --- a/src/main/java/org/scijava/display/event/input/MsMovedEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsMovedEvent.java @@ -6,13 +6,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 @@ -34,13 +34,13 @@ /** * An event indicating a mouse was moved in a display. - * + * * @author Curtis Rueden */ public class MsMovedEvent extends MsEvent { - public MsMovedEvent(final Display display, - final InputModifiers modifiers, final int x, final int y) + public MsMovedEvent(final Display display, final InputModifiers modifiers, + final int x, final int y) { super(display, modifiers, x, y); } 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 19ca38bfd..5a6dda378 100644 --- a/src/main/java/org/scijava/display/event/input/MsPressedEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsPressedEvent.java @@ -6,13 +6,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 @@ -34,14 +34,14 @@ /** * An event indicating a mouse button was pressed in a display. - * + * * @author Curtis Rueden */ public class MsPressedEvent extends MsButtonEvent { public MsPressedEvent(final Display display, - final InputModifiers modifiers, final int x, final int y, - final int button, final int numClicks, final boolean isPopupTrigger) + final InputModifiers modifiers, final int x, final int y, final int button, + final int numClicks, final boolean isPopupTrigger) { super(display, modifiers, x, y, button, numClicks, isPopupTrigger); } 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 219e62b73..d86a466a1 100644 --- a/src/main/java/org/scijava/display/event/input/MsReleasedEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsReleasedEvent.java @@ -6,13 +6,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 @@ -34,14 +34,14 @@ /** * An event indicating a mouse button was released in a display. - * + * * @author Curtis Rueden */ public class MsReleasedEvent extends MsButtonEvent { public MsReleasedEvent(final Display display, - final InputModifiers modifiers, final int x, final int y, - final int button, final int numClicks, final boolean isPopupTrigger) + final InputModifiers modifiers, final int x, final int y, final int button, + final int numClicks, final boolean isPopupTrigger) { super(display, modifiers, x, y, button, numClicks, isPopupTrigger); } 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 8f0ec7c6b..2fe92d8b7 100644 --- a/src/main/java/org/scijava/display/event/input/MsWheelEvent.java +++ b/src/main/java/org/scijava/display/event/input/MsWheelEvent.java @@ -6,13 +6,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 @@ -34,16 +34,15 @@ /** * An event indicating a mouse wheel was moved in a display. - * + * * @author Curtis Rueden */ public class MsWheelEvent extends MsEvent { private final int wheelRotation; - public MsWheelEvent(final Display display, - final InputModifiers modifiers, final int x, final int y, - final int wheelRotation) + public MsWheelEvent(final Display display, final InputModifiers modifiers, + final int x, final int y, final int wheelRotation) { super(display, modifiers, x, y); this.wheelRotation = wheelRotation; 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 380cc2185..be9432c4c 100644 --- a/src/main/java/org/scijava/display/event/window/WinActivatedEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinActivatedEvent.java @@ -6,13 +6,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,7 +33,7 @@ /** * An event indicating a display window has been activated. - * + * * @author Curtis Rueden */ public class WinActivatedEvent extends WinEvent { 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 7e11f2581..7106965dd 100644 --- a/src/main/java/org/scijava/display/event/window/WinClosedEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinClosedEvent.java @@ -6,13 +6,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,7 +33,7 @@ /** * An event indicating a display window has been closed. - * + * * @author Curtis Rueden */ public class WinClosedEvent extends WinEvent { 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 f8573f746..bf0eb0cb9 100644 --- a/src/main/java/org/scijava/display/event/window/WinClosingEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinClosingEvent.java @@ -6,13 +6,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,7 +33,7 @@ /** * An event indicating a display window is in the process of closing. - * + * * @author Curtis Rueden */ public class WinClosingEvent extends WinEvent { 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 c1f8f7d03..4fac03549 100644 --- a/src/main/java/org/scijava/display/event/window/WinDeactivatedEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinDeactivatedEvent.java @@ -6,13 +6,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,7 +33,7 @@ /** * An event indicating a display window has been deactivated. - * + * * @author Curtis Rueden */ public class WinDeactivatedEvent extends WinEvent { 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 770c05f30..fd4e47f4a 100644 --- a/src/main/java/org/scijava/display/event/window/WinDeiconifiedEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinDeiconifiedEvent.java @@ -6,13 +6,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,7 +33,7 @@ /** * An event indicating a display window was deiconified. - * + * * @author Curtis Rueden */ public class WinDeiconifiedEvent extends WinEvent { 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 b691b0a71..08d8a7215 100644 --- a/src/main/java/org/scijava/display/event/window/WinEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinEvent.java @@ -6,13 +6,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,7 +38,7 @@ * It is named {@code WinEvent} rather than {@code WindowEvent} to avoid name * clashes with the {@link java.awt.event.WindowEvent} hierarchy. *

    - * + * * @author Curtis Rueden */ public abstract class WinEvent extends DisplayEvent { 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 4486a5630..5695b5f03 100644 --- a/src/main/java/org/scijava/display/event/window/WinIconifiedEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinIconifiedEvent.java @@ -6,13 +6,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,7 +33,7 @@ /** * An event indicating a display window was iconified. - * + * * @author Curtis Rueden */ public class WinIconifiedEvent extends WinEvent { 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 e34298e6c..780d54c72 100644 --- a/src/main/java/org/scijava/display/event/window/WinOpenedEvent.java +++ b/src/main/java/org/scijava/display/event/window/WinOpenedEvent.java @@ -6,13 +6,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,7 +33,7 @@ /** * An event indicating a display window has been opened. - * + * * @author Curtis Rueden */ public class WinOpenedEvent extends WinEvent { diff --git a/src/main/java/org/scijava/download/DefaultDownloadService.java b/src/main/java/org/scijava/download/DefaultDownloadService.java index da91dc3e8..b4e877c4d 100644 --- a/src/main/java/org/scijava/download/DefaultDownloadService.java +++ b/src/main/java/org/scijava/download/DefaultDownloadService.java @@ -6,13 +6,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 @@ -91,11 +91,12 @@ public Download download(final Location source, final Location destination, final Task task = taskService.createTask("Download"); return new DefaultDownload(source, destination, task, () -> { final Location cached = cache.cachedLocation(source); - try ( - final DataHandle sourceHandle = dataHandleService.create(source); - final DataHandle cachedHandle = dataHandleService.create(cached); - final DataHandle destHandle = dataHandleService.create(destination) - ) + try (final DataHandle sourceHandle = dataHandleService.create( + source); + final DataHandle cachedHandle = dataHandleService.create( + cached); + final DataHandle destHandle = dataHandleService.create( + destination)) { if (isCachedHandleValid(source, cache, sourceHandle, cachedHandle)) { // The data is cached; download from the cached source instead. diff --git a/src/main/java/org/scijava/download/DiskLocationCache.java b/src/main/java/org/scijava/download/DiskLocationCache.java index 73471ebed..0f42de331 100644 --- a/src/main/java/org/scijava/download/DiskLocationCache.java +++ b/src/main/java/org/scijava/download/DiskLocationCache.java @@ -6,13 +6,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/download/Download.java b/src/main/java/org/scijava/download/Download.java index 56d00f71f..800ea7a22 100644 --- a/src/main/java/org/scijava/download/Download.java +++ b/src/main/java/org/scijava/download/Download.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.download; import org.scijava.io.location.Location; @@ -40,6 +41,8 @@ public interface Download { Location source(); + Location destination(); + Task task(); } diff --git a/src/main/java/org/scijava/download/DownloadService.java b/src/main/java/org/scijava/download/DownloadService.java index abc4c8294..3545da027 100644 --- a/src/main/java/org/scijava/download/DownloadService.java +++ b/src/main/java/org/scijava/download/DownloadService.java @@ -6,13 +6,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/download/LocationCache.java b/src/main/java/org/scijava/download/LocationCache.java index ee49eed26..d568a76c7 100644 --- a/src/main/java/org/scijava/download/LocationCache.java +++ b/src/main/java/org/scijava/download/LocationCache.java @@ -6,13 +6,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/download/MultiWriteHandle.java b/src/main/java/org/scijava/download/MultiWriteHandle.java index 4c7d5ef3a..9213002a2 100644 --- a/src/main/java/org/scijava/download/MultiWriteHandle.java +++ b/src/main/java/org/scijava/download/MultiWriteHandle.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.download; import java.io.IOException; @@ -40,7 +41,7 @@ /** * {@link DataHandle} plugin for writing to multiple {@link DataHandle}s. - * + * * @author Curtis Rueden */ public class MultiWriteHandle extends AbstractDataHandle { diff --git a/src/main/java/org/scijava/event/ContextCreatedEvent.java b/src/main/java/org/scijava/event/ContextCreatedEvent.java index 2f43d2105..9d984cbcd 100644 --- a/src/main/java/org/scijava/event/ContextCreatedEvent.java +++ b/src/main/java/org/scijava/event/ContextCreatedEvent.java @@ -6,13 +6,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 @@ -30,9 +30,9 @@ package org.scijava.event; /** - * Event to be published immediately after a context has been fully created - * with all services initialized. - * + * Event to be published immediately after a context has been fully created with + * all services initialized. + * * @author Curtis Rueden */ -public class ContextCreatedEvent extends SciJavaEvent { } +public class ContextCreatedEvent extends SciJavaEvent {} diff --git a/src/main/java/org/scijava/event/ContextDisposingEvent.java b/src/main/java/org/scijava/event/ContextDisposingEvent.java index 472c6b03e..7beb5a1f1 100644 --- a/src/main/java/org/scijava/event/ContextDisposingEvent.java +++ b/src/main/java/org/scijava/event/ContextDisposingEvent.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Event to be published just before disposing a context. - * + * * @author Johannes Schindelin */ -public class ContextDisposingEvent extends SciJavaEvent { } +public class ContextDisposingEvent extends SciJavaEvent {} diff --git a/src/main/java/org/scijava/event/DefaultEventBus.java b/src/main/java/org/scijava/event/DefaultEventBus.java index 72e269077..9d51e7761 100644 --- a/src/main/java/org/scijava/event/DefaultEventBus.java +++ b/src/main/java/org/scijava/event/DefaultEventBus.java @@ -6,13 +6,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 @@ -47,7 +47,7 @@ * {@code org.scijava.event.bushe.EventService} but rather a SciJava * {@link Service} implementation. *

    - * + * * @author Curtis Rueden */ public class DefaultEventBus extends ThreadSafeEventService { @@ -132,8 +132,7 @@ public void publish(final String topicName, final Object eventObj) { @Override protected void publish(final Object event, final String topic, - final Object eventObj, - @SuppressWarnings("rawtypes") final List subscribers, + final Object eventObj, @SuppressWarnings("rawtypes") final List subscribers, @SuppressWarnings("rawtypes") final List vetoSubscribers, final StackTraceElement[] callingStack) { @@ -144,8 +143,7 @@ protected void publish(final Object event, final String topic, // -- Helper methods -- private void publishNow(final Object event, final String topic, - final Object eventObj, - @SuppressWarnings("rawtypes") final List subscribers, + final Object eventObj, @SuppressWarnings("rawtypes") final List subscribers, @SuppressWarnings("rawtypes") final List vetoSubscribers, final StackTraceElement[] callingStack) { @@ -171,8 +169,7 @@ public void run() { } private void publishLater(final Object event, final String topic, - final Object eventObj, - @SuppressWarnings("rawtypes") final List subscribers, + final Object eventObj, @SuppressWarnings("rawtypes") final List subscribers, @SuppressWarnings("rawtypes") final List vetoSubscribers, final StackTraceElement[] callingStack) { diff --git a/src/main/java/org/scijava/event/DefaultEventHistory.java b/src/main/java/org/scijava/event/DefaultEventHistory.java index c0d397cb1..7ab22b687 100644 --- a/src/main/java/org/scijava/event/DefaultEventHistory.java +++ b/src/main/java/org/scijava/event/DefaultEventHistory.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * Default service for keeping a history of SciJava events. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) @@ -53,8 +53,7 @@ public class DefaultEventHistory extends AbstractService implements /** Event details that have been recorded. */ private ArrayList history = new ArrayList<>(); - private ArrayList listeners = - new ArrayList<>(); + private ArrayList listeners = new ArrayList<>(); private boolean active; @@ -86,8 +85,8 @@ public String toHTML(final Set> filtered, // skip filtered event type continue; } - final boolean bold = - highlighted != null && highlighted.contains(eventType); + final boolean bold = highlighted != null && highlighted.contains( + eventType); sb.append(details.toHTML(bold)); } return sb.toString(); diff --git a/src/main/java/org/scijava/event/DefaultEventService.java b/src/main/java/org/scijava/event/DefaultEventService.java index d627ce668..f45e279c1 100644 --- a/src/main/java/org/scijava/event/DefaultEventService.java +++ b/src/main/java/org/scijava/event/DefaultEventService.java @@ -6,13 +6,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 @@ -53,7 +53,7 @@ /** * Default service for publishing and subscribing to SciJava events. - * + * * @author Curtis Rueden * @author Grant Harris */ @@ -110,8 +110,8 @@ public void publishLater(final E e) { @Override public List> subscribe(final Object o) { - final List eventHandlers = - ClassUtils.getAnnotatedMethods(o.getClass(), EventHandler.class); + final List eventHandlers = ClassUtils.getAnnotatedMethods(o + .getClass(), EventHandler.class); if (eventHandlers.isEmpty()) return Collections.emptyList(); final ArrayList> subscribers = new ArrayList<>(); @@ -216,7 +216,8 @@ private Class getEventClass(final Method m) { if (eventClass == null) { final Class[] c = m.getParameterTypes(); if (c == null || c.length != 1) return null; // wrong number of args - if (!SciJavaEvent.class.isAssignableFrom(c[0])) return null; // wrong class + if (!SciJavaEvent.class.isAssignableFrom(c[0])) return null; // wrong + // class // Cache the eventClass eventClass = c[0]; @@ -225,7 +226,7 @@ private Class getEventClass(final Method m) { @SuppressWarnings("unchecked") final Class typedClass = - (Class) eventClass; + (Class) eventClass; return typedClass; } @@ -233,7 +234,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 @@ -248,11 +249,14 @@ private Class getEventClass(final Method m) { * that there is a non-GC'able reference to each {@link ProxySubscriber} as * long as there is a reference to the containing event handler object. *

    - * + * * @param o the object containing {@link EventHandler}-annotated methods - * @param subscriber a {@link ProxySubscriber} for a particular {@link EventHandler} + * @param subscriber a {@link ProxySubscriber} for a particular + * {@link EventHandler} */ - private synchronized void keepIt(final Object o, final ProxySubscriber subscriber) { + private synchronized void keepIt(final Object o, + final ProxySubscriber subscriber) + { List> list = keepEm.get(o); if (list == null) { list = new ArrayList<>(); @@ -292,7 +296,7 @@ public ProxySubscriber(final Class c, final Object o, final Method m) { /** * Handles the event publication by pushing it to the real subscriber's * subscription method. - * + * * @param event The event to publish. */ @Override @@ -303,14 +307,14 @@ public void onEvent(final E event) { getSubscriptionMethod().invoke(obj, event); } catch (final IllegalAccessException exc) { - log.error("Exception during event handling:\n\t[Event] " + - event.getClass().getName() + ":" + event + "\n\t[Subscriber] " + + log.error("Exception during event handling:\n\t[Event] " + event + .getClass().getName() + ":" + event + "\n\t[Subscriber] " + getProxiedSubscriber() + "\n\t[Method] " + getSubscriptionMethod(), exc); } catch (final InvocationTargetException exc) { - log.error("Exception during event handling:\n\t[Event] " + - event.getClass().getName() + event + "\n\t[Subscriber] " + + log.error("Exception during event handling:\n\t[Event] " + event + .getClass().getName() + event + "\n\t[Subscriber] " + getProxiedSubscriber() + "\n\t[Method] " + getSubscriptionMethod(), exc.getCause()); } diff --git a/src/main/java/org/scijava/event/EventDetails.java b/src/main/java/org/scijava/event/EventDetails.java index 794e3e3fa..7f449bf43 100644 --- a/src/main/java/org/scijava/event/EventDetails.java +++ b/src/main/java/org/scijava/event/EventDetails.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * Caches details of a particular {@link SciJavaEvent}, without saving the event * itself (since doing so could leave dangling references). - * + * * @author Curtis Rueden */ public class EventDetails { @@ -93,8 +93,8 @@ public String toHTML(final boolean bold) { // -- Helper methods -- private String timestampAsString() { - final SimpleDateFormat formatter = - new SimpleDateFormat("hh:mm:ss.SS", Locale.getDefault()); + final SimpleDateFormat formatter = new SimpleDateFormat("hh:mm:ss.SS", + Locale.getDefault()); final String dateStr = formatter.format(timestamp); return dateStr; } diff --git a/src/main/java/org/scijava/event/EventHandler.java b/src/main/java/org/scijava/event/EventHandler.java index 56283f452..d1f4e6e89 100644 --- a/src/main/java/org/scijava/event/EventHandler.java +++ b/src/main/java/org/scijava/event/EventHandler.java @@ -6,13 +6,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 @@ -50,7 +50,7 @@ * functionality rather than extend it (as we are able to do with * {@link EventSubscriber}). *

    - * + * * @author Curtis Rueden * @see EventService */ diff --git a/src/main/java/org/scijava/event/EventHistory.java b/src/main/java/org/scijava/event/EventHistory.java index e54425120..a31c05562 100644 --- a/src/main/java/org/scijava/event/EventHistory.java +++ b/src/main/java/org/scijava/event/EventHistory.java @@ -6,13 +6,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 @@ -29,14 +29,13 @@ package org.scijava.event; - import java.util.Set; import org.scijava.service.SciJavaService; /** * Interface for service that keeps a history of SciJava events. - * + * * @author Curtis Rueden */ public interface EventHistory extends SciJavaService { @@ -52,7 +51,7 @@ public interface EventHistory extends SciJavaService { /** * Gets the recorded event history as an HTML string. - * + * * @param filtered Set of event types to filter out from the history. * @param highlighted Set of event types to highlight in the history. * @return An HTML string representing the recorded event history. diff --git a/src/main/java/org/scijava/event/EventHistoryListener.java b/src/main/java/org/scijava/event/EventHistoryListener.java index 9beecf79f..0d0d44919 100644 --- a/src/main/java/org/scijava/event/EventHistoryListener.java +++ b/src/main/java/org/scijava/event/EventHistoryListener.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Listener for event history changes. - * + * * @author Curtis Rueden */ public interface EventHistoryListener { diff --git a/src/main/java/org/scijava/event/EventService.java b/src/main/java/org/scijava/event/EventService.java index 00ef9d7f0..fb8c51f41 100644 --- a/src/main/java/org/scijava/event/EventService.java +++ b/src/main/java/org/scijava/event/EventService.java @@ -6,13 +6,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 @@ -29,7 +29,6 @@ package org.scijava.event; - import java.util.Collection; import java.util.List; @@ -37,7 +36,7 @@ /** * Interface for the event handling service. - * + * * @author Curtis Rueden * @author Grant Harris */ @@ -91,7 +90,8 @@ public interface EventService extends SciJavaService { *
  • A third party that subscribes to both * {@link org.scijava.module.event.ModulesUpdatedEvent} and * {@link org.scijava.menu.event.MenusUpdatedEvent} will receive the former - * first, since it was already queued by the time the latter was published.
  • + * first, since it was already queued by the time the latter was + * published. * */ void publishLater(E e); @@ -115,7 +115,7 @@ public interface EventService extends SciJavaService { * call {@link org.scijava.Context#inject(Object)}, instead of subscribing to * the event service explicitly. *

    - * + * * @param o the event handler object containing the {@link EventHandler} * annotated methods * @return The list of newly created {@link EventSubscriber}s, weakly @@ -138,7 +138,7 @@ public interface EventService extends SciJavaService { * SciJava's {@link org.scijava.object.ObjectService} via * {@link org.scijava.object.ObjectService#addObject}. *

    - * + * * @param subscriber the event subscriber to register */ void subscribe(EventSubscriber subscriber); diff --git a/src/main/java/org/scijava/event/EventSubscriber.java b/src/main/java/org/scijava/event/EventSubscriber.java index bb05a8f40..b64c475cc 100644 --- a/src/main/java/org/scijava/event/EventSubscriber.java +++ b/src/main/java/org/scijava/event/EventSubscriber.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ * delivery pattern in question. A better solution is to fire more granular * types of events at multiple stages of the program's workflow. *

    - * + * * @author Curtis Rueden * @param Type of event for which to listen */ diff --git a/src/main/java/org/scijava/event/SciJavaEvent.java b/src/main/java/org/scijava/event/SciJavaEvent.java index 2fcc6876d..ca596d9c3 100644 --- a/src/main/java/org/scijava/event/SciJavaEvent.java +++ b/src/main/java/org/scijava/event/SciJavaEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Base class for all SciJava events. - * + * * @author Curtis Rueden */ public abstract class SciJavaEvent extends AbstractContextual { diff --git a/src/main/java/org/scijava/event/bushe/AbstractProxySubscriber.java b/src/main/java/org/scijava/event/bushe/AbstractProxySubscriber.java index f0db8aac1..d5ed6e764 100644 --- a/src/main/java/org/scijava/event/bushe/AbstractProxySubscriber.java +++ b/src/main/java/org/scijava/event/bushe/AbstractProxySubscriber.java @@ -1,3 +1,4 @@ + package org.scijava.event.bushe; import java.lang.ref.WeakReference; @@ -8,158 +9,177 @@ /** * Common base class for EventService Proxies. *

    - * Implementing Prioritized even when Priority is not used is always OK. The default - * value of 0 retains the FIFO order. + * Implementing Prioritized even when Priority is not used is always OK. The + * default value of 0 retains the FIFO order. */ -public abstract class AbstractProxySubscriber implements ProxySubscriber, Prioritized { - private Object proxiedSubscriber; - private Method subscriptionMethod; - private ReferenceStrength referenceStrength; - private EventService eventService; - private int priority; - protected boolean veto; - - protected AbstractProxySubscriber(Object proxiedSubscriber, Method subscriptionMethod, - ReferenceStrength referenceStrength, EventService es, boolean veto) { - this(proxiedSubscriber, subscriptionMethod, referenceStrength, 0, es, veto); - } - - protected AbstractProxySubscriber(Object proxiedSubscriber, Method subscriptionMethod, - ReferenceStrength referenceStrength, int priority, EventService es, boolean veto) { - this.referenceStrength = referenceStrength; - this.priority = priority; - eventService = es; - this.veto = veto; - if (proxiedSubscriber == null) { - throw new IllegalArgumentException("The realSubscriber cannot be null when constructing a proxy subscriber."); - } - if (subscriptionMethod == null) { - throw new IllegalArgumentException("The subscriptionMethod cannot be null when constructing a proxy subscriber."); - } - Class returnType = subscriptionMethod.getReturnType(); - if (veto && returnType != Boolean.TYPE) { - throw new IllegalArgumentException("The subscriptionMethod must have the two parameters, the first one must be a String and the second a non-primitive (Object or derivative)."); - } - if (ReferenceStrength.WEAK.equals(referenceStrength)) { - this.proxiedSubscriber = new WeakReference(proxiedSubscriber); - } else { - this.proxiedSubscriber = proxiedSubscriber; - } - this.subscriptionMethod = subscriptionMethod; - } - - /** @return the object this proxy is subscribed on behalf of */ - public Object getProxiedSubscriber() { - if (proxiedSubscriber instanceof WeakReference) { - return ((WeakReference)proxiedSubscriber).get(); - } - return proxiedSubscriber; - } - - /** @return the subscriptionMethod passed in the constructor */ - public Method getSubscriptionMethod() { - return subscriptionMethod; - } - - /** @return the EventService passed in the constructor */ - public EventService getEventService() { - return eventService; - } - - /** @return the ReferenceStrength passed in the constructor */ - public ReferenceStrength getReferenceStrength() { - return referenceStrength; - } - - /** - * @return the priority, no effect if priority is 0 (the default value) - */ - public int getPriority() { - return priority; - } - - /** - * Called by EventServices to inform the proxy that it is unsubscribed. - * The ProxySubscriber should perform any necessary cleanup. - *

    - * Overriding classes must call super.proxyUnsubscribed() or risk - * things not being cleanup up properly. - */ - public void proxyUnsubscribed() { - proxiedSubscriber = null; - } - - @Override - public final int hashCode() { - throw new RuntimeException("Proxy subscribers are not allowed in Hash " + - "Maps, since the underlying values use Weak References that" + - "may disappear, the calculations may not be the same in" + - "successive calls as required by hashCode."); - } - - protected boolean retryReflectiveCallUsingAccessibleObject(Object[] args, Method subscriptionMethod, Object obj, - IllegalAccessException e, String message) { - boolean accessibleTriedAndFailed = false; - if (subscriptionMethod != null) { - AccessibleObject[] accessibleMethod = {subscriptionMethod}; - try { - AccessibleObject.setAccessible(accessibleMethod, true); - Object returnValue = subscriptionMethod.invoke(obj, args); - return Boolean.valueOf(returnValue+""); - } catch (SecurityException ex) { - accessibleTriedAndFailed = true; - } catch (InvocationTargetException e1) { - throw new RuntimeException(message, e); - } catch (IllegalAccessException e1) { - throw new RuntimeException(message, e); - } - } - if (accessibleTriedAndFailed) { - message = message + ". An attempt was made to make the method accessible, but the SecurityManager denied the attempt."; - } - throw new RuntimeException(message, e); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof AbstractProxySubscriber) { - AbstractProxySubscriber bps = (AbstractProxySubscriber) obj; - if (referenceStrength != bps.referenceStrength) { - return false; - } - if (subscriptionMethod != bps.subscriptionMethod) { - return false; - } - if (ReferenceStrength.WEAK == referenceStrength) { - if (((WeakReference)proxiedSubscriber).get() != ((WeakReference)bps.proxiedSubscriber).get()) { - return false; - } - } else { - if (proxiedSubscriber != bps.proxiedSubscriber) { - return false; - } - } - if (veto != bps.veto) { - return false; - } - if (eventService != bps.eventService) { - return false; - } - return true; - } else { - return false; - } - } - - @Override - public String toString() { - return "AbstractProxySubscriber{" + - "realSubscriber=" + (proxiedSubscriber instanceof WeakReference? - ((WeakReference)proxiedSubscriber).get():proxiedSubscriber) + - ", subscriptionMethod=" + subscriptionMethod + - ", veto=" + veto + - ", referenceStrength=" + referenceStrength + - ", eventService=" + eventService + - '}'; - } +public abstract class AbstractProxySubscriber implements ProxySubscriber, + Prioritized +{ + + private Object proxiedSubscriber; + private Method subscriptionMethod; + private ReferenceStrength referenceStrength; + private EventService eventService; + private int priority; + protected boolean veto; + + protected AbstractProxySubscriber(Object proxiedSubscriber, + Method subscriptionMethod, ReferenceStrength referenceStrength, + EventService es, boolean veto) + { + this(proxiedSubscriber, subscriptionMethod, referenceStrength, 0, es, veto); + } + + protected AbstractProxySubscriber(Object proxiedSubscriber, + Method subscriptionMethod, ReferenceStrength referenceStrength, + int priority, EventService es, boolean veto) + { + this.referenceStrength = referenceStrength; + this.priority = priority; + eventService = es; + this.veto = veto; + if (proxiedSubscriber == null) { + throw new IllegalArgumentException( + "The realSubscriber cannot be null when constructing a proxy subscriber."); + } + if (subscriptionMethod == null) { + throw new IllegalArgumentException( + "The subscriptionMethod cannot be null when constructing a proxy subscriber."); + } + Class returnType = subscriptionMethod.getReturnType(); + if (veto && returnType != Boolean.TYPE) { + throw new IllegalArgumentException( + "The subscriptionMethod must have the two parameters, the first one must be a String and the second a non-primitive (Object or derivative)."); + } + if (ReferenceStrength.WEAK.equals(referenceStrength)) { + this.proxiedSubscriber = new WeakReference(proxiedSubscriber); + } + else { + this.proxiedSubscriber = proxiedSubscriber; + } + this.subscriptionMethod = subscriptionMethod; + } + + /** @return the object this proxy is subscribed on behalf of */ + public Object getProxiedSubscriber() { + if (proxiedSubscriber instanceof WeakReference) { + return ((WeakReference) proxiedSubscriber).get(); + } + return proxiedSubscriber; + } + + /** @return the subscriptionMethod passed in the constructor */ + public Method getSubscriptionMethod() { + return subscriptionMethod; + } + + /** @return the EventService passed in the constructor */ + public EventService getEventService() { + return eventService; + } + + /** @return the ReferenceStrength passed in the constructor */ + public ReferenceStrength getReferenceStrength() { + return referenceStrength; + } + + /** + * @return the priority, no effect if priority is 0 (the default value) + */ + public int getPriority() { + return priority; + } + + /** + * Called by EventServices to inform the proxy that it is unsubscribed. The + * ProxySubscriber should perform any necessary cleanup. + *

    + * Overriding classes must call super.proxyUnsubscribed() or risk things + * not being cleanup up properly. + */ + public void proxyUnsubscribed() { + proxiedSubscriber = null; + } + + @Override + public final int hashCode() { + throw new RuntimeException("Proxy subscribers are not allowed in Hash " + + "Maps, since the underlying values use Weak References that" + + "may disappear, the calculations may not be the same in" + + "successive calls as required by hashCode."); + } + + protected boolean retryReflectiveCallUsingAccessibleObject(Object[] args, + Method subscriptionMethod, Object obj, IllegalAccessException e, + String message) + { + boolean accessibleTriedAndFailed = false; + if (subscriptionMethod != null) { + AccessibleObject[] accessibleMethod = { subscriptionMethod }; + try { + AccessibleObject.setAccessible(accessibleMethod, true); + Object returnValue = subscriptionMethod.invoke(obj, args); + return Boolean.valueOf(returnValue + ""); + } + catch (SecurityException ex) { + accessibleTriedAndFailed = true; + } + catch (InvocationTargetException e1) { + throw new RuntimeException(message, e); + } + catch (IllegalAccessException e1) { + throw new RuntimeException(message, e); + } + } + if (accessibleTriedAndFailed) { + message = message + + ". An attempt was made to make the method accessible, but the SecurityManager denied the attempt."; + } + throw new RuntimeException(message, e); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof AbstractProxySubscriber) { + AbstractProxySubscriber bps = (AbstractProxySubscriber) obj; + if (referenceStrength != bps.referenceStrength) { + return false; + } + if (subscriptionMethod != bps.subscriptionMethod) { + return false; + } + if (ReferenceStrength.WEAK == referenceStrength) { + if (((WeakReference) proxiedSubscriber) + .get() != ((WeakReference) bps.proxiedSubscriber).get()) + { + return false; + } + } + else { + if (proxiedSubscriber != bps.proxiedSubscriber) { + return false; + } + } + if (veto != bps.veto) { + return false; + } + if (eventService != bps.eventService) { + return false; + } + return true; + } + else { + return false; + } + } + + @Override + public String toString() { + return "AbstractProxySubscriber{" + "realSubscriber=" + + (proxiedSubscriber instanceof WeakReference + ? ((WeakReference) proxiedSubscriber).get() : proxiedSubscriber) + + ", subscriptionMethod=" + subscriptionMethod + ", veto=" + veto + + ", referenceStrength=" + referenceStrength + ", eventService=" + + eventService + '}'; + } } diff --git a/src/main/java/org/scijava/event/bushe/EventService.java b/src/main/java/org/scijava/event/bushe/EventService.java index c2d41e9bb..899959489 100644 --- a/src/main/java/org/scijava/event/bushe/EventService.java +++ b/src/main/java/org/scijava/event/bushe/EventService.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.scijava.event.bushe; import java.util.List; @@ -20,77 +21,105 @@ import java.lang.reflect.Type; /** - * The core interface. An EventService provides publish/subscribe services to a single JVM using Class-based and - * String-based (i.e. "topic") publications and subscriptions. + * The core interface. An EventService provides publish/subscribe services to a + * single JVM using Class-based and String-based (i.e. "topic") publications and + * subscriptions. *

    - * In class-based pub/sub, {@link EventSubscriber}s subscribe to a type on an {@link EventService}, such - * as the {@link org.scijava.event.bushe.EventBus}, by providing a class, interface or generic type. The EventService - * notifies subscribers when objects are published on the EventService with a matching type. Full class semantics are - * respected. That is, if a subscriber subscribes to a class, the subscriber is notified if an object of - * that class is publish or if an object of a subclass of that class is published. Likewise if a subscriber subscribes - * to an interface, it will be notified if any object that implements that interface is published. Subscribers can - * subscribe "exactly" using {@link #subscribeExactly(Class, EventSubscriber)} so that they are notified only if an - * object of the exact class is published (and will not be notified if subclasses are published, since this would not - * be "exact") + * In class-based pub/sub, {@link EventSubscriber}s subscribe to a type on an + * {@link EventService}, such as the {@link org.scijava.event.bushe.EventBus}, + * by providing a class, interface or generic type. The EventService notifies + * subscribers when objects are published on the EventService with a matching + * type. Full class semantics are respected. That is, if a subscriber subscribes + * to a class, the subscriber is notified if an object of that class is publish + * or if an object of a subclass of that class is published. Likewise if a + * subscriber subscribes to an interface, it will be notified if any object that + * implements that interface is published. Subscribers can subscribe "exactly" + * using {@link #subscribeExactly(Class, EventSubscriber)} so that they are + * notified only if an object of the exact class is published (and will not be + * notified if subclasses are published, since this would not be "exact") *

    *

    - * In topic-based pub/sub, an object "payload" is published on a topic name (String). {@link EventTopicSubscriber}s subscribe - * to either the exact name of the topic or they may subscribe using a Regular Expression that is used to match topic - * names. + * In topic-based pub/sub, an object "payload" is published on a topic name + * (String). {@link EventTopicSubscriber}s subscribe to either the exact name of + * the topic or they may subscribe using a Regular Expression that is used to + * match topic names. *

    *

    - * See the overview for an general introduction - * and package documentation for usage details and examples. + * See the + * overview + * for an general introduction and package + * documentation for usage details and examples. *

    *

    - * A single subscriber cannot subscribe more than once to an event or topic name. EventService implementations should - * handle double-subscription requests by returning false on subscribe(). A single EventSubscriber can subscribe to more - * than one event class, and a single EventTopicSubscriber can subscribe to more than one topic name or pattern. A - * single object may implement both EventSubscriber and EventTopicSubscriber interfaces. Subscribers are guaranteed to - * only be called for the classes and/or topic names they subscribe to. If a subscriber subscribes to a topic and to a - * regular expression that matches the topic name, this is considered two different subscriptions and the subscriber - * will be called twice for the publication on the topic. Similarly, if a subscriber subscribes to a class and its - * subclasses using subscribe() and again to a class of the same type using subscribeExactly(), this is considered two - * different subscriptions and the subscriber will be called twice for the publication for a single event of the exact - * type. + * A single subscriber cannot subscribe more than once to an event or topic + * name. EventService implementations should handle double-subscription requests + * by returning false on subscribe(). A single EventSubscriber can subscribe to + * more than one event class, and a single EventTopicSubscriber can subscribe to + * more than one topic name or pattern. A single object may implement both + * EventSubscriber and EventTopicSubscriber interfaces. Subscribers are + * guaranteed to only be called for the classes and/or topic names they + * subscribe to. If a subscriber subscribes to a topic and to a regular + * expression that matches the topic name, this is considered two different + * subscriptions and the subscriber will be called twice for the publication on + * the topic. Similarly, if a subscriber subscribes to a class and its + * subclasses using subscribe() and again to a class of the same type using + * subscribeExactly(), this is considered two different subscriptions and the + * subscriber will be called twice for the publication for a single event of the + * exact type. *

    *

    - * By default the EventService only holds WeakReferences to subscribers. If a subscriber has no references to it, then - * it can be garbage collected. This avoids memory leaks in exchange for the risk of accidentally adding a listener and - * have it disappear unexpectedly. If you want to subscribe a subscriber that will have no other reference to it, then - * use one of the subscribeStrongly() methods, which will prevent garbage collection. + * By default the EventService only holds WeakReferences to subscribers. If a + * subscriber has no references to it, then it can be garbage collected. This + * avoids memory leaks in exchange for the risk of accidentally adding a + * listener and have it disappear unexpectedly. If you want to subscribe a + * subscriber that will have no other reference to it, then use one of the + * subscribeStrongly() methods, which will prevent garbage collection. *

    *

    - * Unless garbage collected, EventSubscribers will remain subscribed until they are passed to one of the unsubscribe() - * methods with the event class or topic name to which there are subscribed. + * Unless garbage collected, EventSubscribers will remain subscribed until they + * are passed to one of the unsubscribe() methods with the event class or topic + * name to which there are subscribed. *

    *

    - * Subscribers are called in the order in which they are subscribed by default (FIFO), unless subscribers implement - * {@link Prioritized}. Those subscribers that implement Prioritized and return a negative priority are moved to the - * front of the list (the more negative, the more to the front). Those subscribers that implement Prioritized and return - * a positive priority are moved to the end of the list (the more positive, the more to the back). The FIFO guarantee - * is only valid for the same subscribe() call. That is, the order of two subscribers, one to List.class and the other - * to ArrayList.class is not guaranteed to be in the order of subscription when an ArrayList is published. The same is - * true for topic subscribers when using RegEx expressions - when "Foo" is published, the order of subscribers that are - * subscribed to "Foo", "Fo*" and "F*" are not guaranteed, though the second "Fo*" subscriber will never be called - * before the first "Fo*" subscriber (ditto List and ArrayList). Prioritized subscribers are always guaranteed to be in - * the order of priority, no matter the call or the resulting mix of subscribers. All ordering rules apply to all - * types subscribers: class, topic, pattern, veto, etc. For Swing users, note that FIFO is - * the opposite of Swing, where event listeners are called in the reverse order of when they were subscribed (FILO). + * Subscribers are called in the order in which they are subscribed by default + * (FIFO), unless subscribers implement {@link Prioritized}. Those subscribers + * that implement Prioritized and return a negative priority are moved to the + * front of the list (the more negative, the more to the front). Those + * subscribers that implement Prioritized and return a positive priority are + * moved to the end of the list (the more positive, the more to the back). The + * FIFO guarantee is only valid for the same subscribe() call. That is, the + * order of two subscribers, one to List.class and the other to ArrayList.class + * is not guaranteed to be in the order of subscription when an ArrayList is + * published. The same is true for topic subscribers when using RegEx + * expressions - when "Foo" is published, the order of subscribers that are + * subscribed to "Foo", "Fo*" and "F*" are not guaranteed, though the second + * "Fo*" subscriber will never be called before the first "Fo*" subscriber + * (ditto List and ArrayList). Prioritized subscribers are always guaranteed to + * be in the order of priority, no matter the call or the resulting mix of + * subscribers. All ordering rules apply to all types subscribers: class, topic, + * pattern, veto, etc. For Swing users, note that FIFO is the opposite of Swing, + * where event listeners are called in the reverse order of when they were + * subscribed (FILO). *

    *

    - * Publication on a class or topic name can be vetoed by a {@link VetoEventListener}. All VetoEventListeners are checked - * before any EventSubscribers or EventTopicSubscribers are called. This is unlike the JavaBean's - * VetoPropertyEventListener which can leave side effects and half-propogated events. VetoEventListeners are subscribed - * in the same manner as EventSubscribers and EventTopicSubscribers. + * Publication on a class or topic name can be vetoed by a + * {@link VetoEventListener}. All VetoEventListeners are checked before any + * EventSubscribers or EventTopicSubscribers are called. This is unlike the + * JavaBean's VetoPropertyEventListener which can leave side effects and + * half-propogated events. VetoEventListeners are subscribed in the same manner + * as EventSubscribers and EventTopicSubscribers. *

    *

    - * The state of a published event can be tracked if an event or a topic's payload object implements the - * {@link org.scijava.event.bushe.PublicationStatus} interface. EventServices are required to set such objects' - * {@link org.scijava.event.bushe.PublicationStatus} at the appropriate times during publication. + * The state of a published event can be tracked if an event or a topic's + * payload object implements the + * {@link org.scijava.event.bushe.PublicationStatus} interface. EventServices + * are required to set such objects' + * {@link org.scijava.event.bushe.PublicationStatus} at the appropriate times + * during publication. *

    -*

    + *

    * This simple example prints "Hello World" + * *

      * EventService eventService = new ThreadSafeEventService();
      * //Create a subscriber
    @@ -105,19 +134,25 @@
      * 
    *

    *

    - * Events and/or topic data can be cached, but are not by default. To cache events or topic data, call - * {@link #setDefaultCacheSizePerClassOrTopic(int)}, {@link #setCacheSizeForEventClass(Class, int)}, or - * {@link #setCacheSizeForTopic(String, int)}, {@link #setCacheSizeForTopic(Pattern, int)}. Retrieve cached values - * with {@link #getLastEvent(Class)}, {@link #getLastTopicData(String)}, {@link #getCachedEvents(Class)}, or - * {@link #getCachedTopicData(String)}. Using caching while subscribing is most likely to make sense only if you - * subscribe and publish on the same thread (so caching is very useful for Swing applications since both happen on - * the EDT in a single-threaded manner). In multithreaded applications, you never know if your subscriber has handled - * an event while it was being subscribed (before the subscribe() method returned) that is newer or older than the - * retrieved cached value (taken before or after subscribe() respectively). + * Events and/or topic data can be cached, but are not by default. To cache + * events or topic data, call {@link #setDefaultCacheSizePerClassOrTopic(int)}, + * {@link #setCacheSizeForEventClass(Class, int)}, or + * {@link #setCacheSizeForTopic(String, int)}, + * {@link #setCacheSizeForTopic(Pattern, int)}. Retrieve cached values with + * {@link #getLastEvent(Class)}, {@link #getLastTopicData(String)}, + * {@link #getCachedEvents(Class)}, or {@link #getCachedTopicData(String)}. + * Using caching while subscribing is most likely to make sense only if you + * subscribe and publish on the same thread (so caching is very useful for Swing + * applications since both happen on the EDT in a single-threaded manner). In + * multithreaded applications, you never know if your subscriber has handled an + * event while it was being subscribed (before the subscribe() method returned) + * that is newer or older than the retrieved cached value (taken before or after + * subscribe() respectively). *

    *

    - * There is nothing special about the term "Event," this could just as easily be called a "Message" Service, this term - * is already taken by the JMS, which is similar, but is used across processes and networks. + * There is nothing special about the term "Event," this could just as easily be + * called a "Message" Service, this term is already taken by the JMS, which is + * similar, but is used across processes and networks. *

    * * @author Michael Bushe michael@bushe.com @@ -125,864 +160,984 @@ */ interface EventService { - /** - * Publishes an object so that subscribers will be notified if they subscribed to the object's class, one of its - * subclasses, or to one of the interfaces it implements. - * - * @param event the object to publish - */ - public void publish(Object event); - - /** - * Use this method to publish generified objects to subscribers of Types, i.e. subscribers that use - * {@link #subscribe(Type, EventSubscriber)}, and to publish to subscribers of the non-generic type. - *

    - * Due to generic type erasure, the type must be supplied by the caller. You can get a declared object's - * type by using the {@link org.scijava.event.bushe.TypeReference} class. For Example: - *

    - *
    -    * TypeReference<List<Trade>> subscribingTypeReference = new TypeReference<List<Trade>>(){};
    -    * EventBus.subscribe(subscribingTypeReference.getType(), mySubscriber);
    -    * EventBus.subscribe(List.class, thisSubscriberWillGetCalledToo);
    -    * ...
    -    * //Likely in some other class
    -    * TypeReference<List<Trade>> publishingTypeReference = new TypeReference<List<Trade>>(){};
    -    * List<Trade> trades = new ArrayList<Trade>();
    -    * EventBus.publish(publishingTypeReference.getType(), trades);
    -    * trades.add(trade);
    -    * EventBus.publish(publishingTypeReference.getType(), trades);
    -    * 
    - * @param genericType the generified type of the published object. - * @param event The event that occurred - */ - public void publish(Type genericType, Object event); - - /** - * Publishes an object on a topic name so that all subscribers to that name or a Regular Expression that matches - * the topic name will be notified. - * - * @param topic The name of the topic subscribed to - * @param o the object to publish - */ - public void publish(String topic, Object o); - - /** - * Subscribes an EventSubscriber to the publication of objects matching a type. Only a WeakReference to - * the subscriber is held by the EventService. - *

    - * Subscribing to a class means the subscriber will be called when objects of that class are published, when - * objects of subclasses of the class are published, when objects implementing any of the interfaces of the - * class are published, or when generic types are published with the class' raw type. - *

    - *

    - * Subscription is weak by default to avoid having to call unsubscribe(), and to avoid the memory leaks that would - * occur if unsubscribe was not called. The service will respect the WeakReference semantics. In other words, if - * the subscriber has not been garbage collected, then onEvent(Object) will be called normally. If the hard - * reference has been garbage collected, the service will unsubscribe it's WeakReference. - *

    - *

    - * It's allowable to call unsubscribe() with the same EventSubscriber hard reference to stop a subscription - * immediately. - *

    - *

    - * The service will create the WeakReference on behalf of the caller. - *

    - * - * @param eventClass the class of published objects to subscriber listen to - * @param subscriber The subscriber that will accept the events of the event class when published. - * - * @return true if the subscriber was subscribed successfully, false otherwise - */ - public boolean subscribe(Class eventClass, EventSubscriber subscriber); - - /** - * Subscribe an EventSubscriber to publication of generic Types. - * Subscribers will only be notified for publications using {@link #publish(java.lang.reflect.Type, Object)}. - *

    - * Due to generic type erasure, the type must be supplied by the publisher. You can get a declared object's - * type by using the {@link org.scijava.event.bushe.TypeReference} class. For Example: - *

    - *
    -   * TypeReference<List<Trade>> subscribingTypeReference = new TypeReference<List<Trade>>(){};
    -   * EventBus.subscribe(subscribingTypeReference.getType(), mySubscriber);
    -   * EventBus.subscribe(List.class, thisSubscriberWillGetCalledToo);
    -   * ...
    -   * //Likely in some other class
    -   * TypeReference<List<Trade>> publishingTypeReference = new TypeReference<List<Trade>>(){};
    -   * List<Trade> trades = new ArrayList<Trade>();
    -   * EventBus.publish(publishingTypeReference.getType(), trades);
    -   * trades.add(trade);
    -   * EventBus.publish(publishingTypeReference.getType(), trades);
    -   * 
    - * @param type the generic type to subscribe to - * @param subscriber the subscriber to the type - * @return true if a new subscription is made, false if it already existed - */ - public boolean subscribe(Type type, EventSubscriber subscriber); - - /** - * Subscribes an EventSubscriber to the publication of objects exactly matching a type. Only a WeakReference - * to the subscriber is held by the EventService. - *

    - * Subscription is weak by default to avoid having to call unsubscribe(), and to avoid the memory leaks that would - * occur if unsubscribe was not called. The service will respect the WeakReference semantics. In other words, if - * the subscriber has not been garbage collected, then the onEvent will be called normally. If the hard reference - * has been garbage collected, the service will unsubscribe it's WeakReference. - *

    - *

    - * It's allowable to call unsubscribe() with the same EventSubscriber hard reference to stop a subscription - * immediately. - *

    - *

    - * The service will create the WeakReference on behalf of the caller. - *

    - * - * @param eventClass the class of published objects to listen to - * @param subscriber The subscriber that will accept the events when published. - * - * @return true if the subscriber was subscribed successfully, false otherwise - */ - public boolean subscribeExactly(Class eventClass, EventSubscriber subscriber); - - /** - * Subscribes an EventTopicSubscriber to the publication of a topic name. Only a WeakReference - * to the subscriber is held by the EventService. - *

    - * Subscription is weak by default to avoid having to call unsubscribe(), and to avoid the memory leaks that would - * occur if unsubscribe was not called. The service will respect the WeakReference semantics. In other words, if - * the subscriber has not been garbage collected, then the onEvent will be called normally. If the hard reference - * has been garbage collected, the service will unsubscribe it's WeakReference. - *

    - *

    - * It's allowable to call unsubscribe() with the same EventSubscriber hard reference to stop a subscription - * immediately. - *

    - * - * @param topic the name of the topic listened to - * @param subscriber The topic subscriber that will accept the events when published. - * - * @return true if the subscriber was subscribed successfully, false otherwise - */ - public boolean subscribe(String topic, EventTopicSubscriber subscriber); - - /** - * Subscribes an EventSubscriber to the publication of all the topic names that match a RegEx Pattern. Only a - * WeakReference to the subscriber is held by the EventService. - *

    - * Subscription is weak by default to avoid having to call unsubscribe(), and to avoid the memory leaks that would - * occur if unsubscribe was not called. The service will respect the WeakReference semantics. In other words, if - * the subscriber has not been garbage collected, then the onEvent will be called normally. If the hard reference - * has been garbage collected, the service will unsubscribe it's WeakReference. - *

    - *

    - * It's allowable to call unsubscribe() with the same EventSubscriber hard reference to stop a subscription - * immediately. - *

    - * - * @param topicPattern pattern that matches to the name of the topic published to - * @param subscriber The topic subscriber that will accept the events when published. - * - * @return true if the subscriber was subscribed successfully, false otherwise - */ - public boolean subscribe(Pattern topicPattern, EventTopicSubscriber subscriber); - - /** - * Subscribes an EventSubscriber to the publication of objects matching a type. - *

    - * The semantics are the same as {@link #subscribe(Class, EventSubscriber)}, except that the EventService holds - * a regularly reference, not a WeakReference. - *

    - *

    - * The subscriber will remain subscribed until {@link #unsubscribe(Class,EventSubscriber)} is called. - *

    - * - * @param eventClass the class of published objects to listen to - * @param subscriber The subscriber that will accept the events when published. - * - * @return true if the subscriber was subscribed successfully, false otherwise - */ - public boolean subscribeStrongly(Class eventClass, EventSubscriber subscriber); - - /** - * Subscribes an EventSubscriber to the publication of objects matching a type exactly. - *

    - * The semantics are the same as {@link #subscribeExactly(Class, EventSubscriber)}, except that the EventService - * holds a regularly reference, not a WeakReference. - *

    - *

    - * The subscriber will remain subscribed until {@link #unsubscribe(Class,EventSubscriber)} is called. - *

    - * - * @param eventClass the class of published objects to listen to - * @param subscriber The subscriber that will accept the events when published. - * - * @return true if the subscriber was subscribed successfully, false otherwise - */ - public boolean subscribeExactlyStrongly(Class eventClass, EventSubscriber subscriber); - - /** - * Subscribes a subscriber to an event topic name. - *

    - * The semantics are the same as {@link #subscribe(String, EventTopicSubscriber)}, except that the EventService - * holds a regularly reference, not a WeakReference. - *

    - *

    - * The subscriber will remain subscribed until {@link #unsubscribe(String,EventTopicSubscriber)} is called. - *

    - * - * @param topic the name of the topic listened to - * @param subscriber The topic subscriber that will accept the events when published. - * - * @return true if the subscriber was subscribed successfully, false otherwise - */ - public boolean subscribeStrongly(String topic, EventTopicSubscriber subscriber); - - /** - * Subscribes a subscriber to all the event topic names that match a RegEx expression. - *

    - * The semantics are the same as {@link #subscribe(java.util.regex.Pattern, EventTopicSubscriber)}, except that the - * EventService holds a regularly reference, not a WeakReference. - *

    - *

    - * The subscriber will remain subscribed until {@link #unsubscribe(String,EventTopicSubscriber)} is called. - *

    - * - * @param topicPattern the name of the topic listened to - * @param subscriber The topic subscriber that will accept the events when published. - * - * @return true if the subscriber was subscribed successfully, false otherwise - */ - public boolean subscribeStrongly(Pattern topicPattern, EventTopicSubscriber subscriber); - - /** - * Stop the subscription for a subscriber that is subscribed to a class. - * - * @param eventClass the class of published objects to listen to - * @param subscriber The subscriber that is subscribed to the event. The same reference as the one subscribed. - * - * @return true if the subscriber was subscribed to the event, false if it wasn't - */ - public boolean unsubscribe(Class eventClass, EventSubscriber subscriber); - - /** - * Stop the subscription for a subscriber that is subscribed to an exact class. - * - * @param eventClass the class of published objects to listen to - * @param subscriber The subscriber that is subscribed to the event. The same reference as the one subscribed. - * - * @return true if the subscriber was subscribed to the event, false if it wasn't - */ - public boolean unsubscribeExactly(Class eventClass, EventSubscriber subscriber); - - /** - * Stop the subscription for a subscriber that is subscribed to an event topic. - * - * @param topic the topic listened to - * @param subscriber The subscriber that is subscribed to the topic. The same reference as the one subscribed. - * - * @return true if the subscriber was subscribed to the event, false if it wasn't - */ - public boolean unsubscribe(String topic, EventTopicSubscriber subscriber); - - /** - * Stop the subscription for a subscriber that is subscribed to event topics via a Pattern. - * - * @param topicPattern the regex expression matching topics listened to - * @param subscriber The subscriber that is subscribed to the topic. The same reference as the one subscribed. - * - * @return true if the subscriber was subscribed to the event, false if it wasn't - */ - public boolean unsubscribe(Pattern topicPattern, EventTopicSubscriber subscriber); - - /** - * Subscribes a VetoEventListener to publication of event matching a class. Only a WeakReference to the - * VetoEventListener is held by the EventService. - *

    - * Use this method to avoid having to call unsubscribe(), though with care since garbage collection semantics is - * indeterminate. The service will respect the WeakReference semantics. In other words, if the vetoListener has not - * been garbage collected, then the onEvent will be called normally. If the hard reference has been garbage - * collected, the service will unsubscribe it's WeakReference. - *

    - *

    - * It's allowable to call unsubscribe() with the same VetoEventListener hard reference to stop a subscription - * immediately. - *

    - *

    - * The service will create the WeakReference on behalf of the caller. - *

    - * - * @param eventClass the class of published objects that can be vetoed - * @param vetoListener The VetoEventListener that can determine whether an event is published. - * - * @return true if the VetoEventListener was subscribed successfully, false otherwise - */ - public boolean subscribeVetoListener(Class eventClass, VetoEventListener vetoListener); - - /** - * Subscribes a VetoEventListener to publication of an exact event class. Only a WeakReference to the - * VetoEventListener is held by the EventService. - *

    - * Use this method to avoid having to call unsubscribe(), though with care since garbage collection semantics is - * indeterminate. The service will respect the WeakReference semantics. In other words, if the vetoListener has not - * been garbage collected, then the onEvent will be called normally. If the hard reference has been garbage - * collected, the service will unsubscribe it's WeakReference. - *

    - *

    - * It's allowable to call unsubscribe() with the same VetoEventListener hard reference to stop a subscription - * immediately. - *

    - *

    - * The service will create the WeakReference on behalf of the caller. - *

    - * - * @param eventClass the class of published objects that can be vetoed - * @param vetoListener The vetoListener that can determine whether an event is published. - * - * @return true if the vetoListener was subscribed successfully, false otherwise - */ - public boolean subscribeVetoListenerExactly(Class eventClass, VetoEventListener vetoListener); - - /** - * Subscribes a VetoTopicEventListener to a topic name. Only a WeakReference to the - * VetoEventListener is held by the EventService. - * - * @param topic the name of the topic listened to - * @param vetoListener The vetoListener that can determine whether an event is published. - * - * @return true if the vetoListener was subscribed successfully, false otherwise - */ - public boolean subscribeVetoListener(String topic, VetoTopicEventListener vetoListener); - - /** - * Subscribes an VetoTopicEventListener to all the topic names that match the RegEx Pattern. Only a - * WeakReference to the VetoEventListener is held by the EventService. - * - * @param topicPattern the RegEx pattern to match topics with - * @param vetoListener The vetoListener that can determine whether an event is published. - * - * @return true if the vetoListener was subscribed successfully, false otherwise - */ - public boolean subscribeVetoListener(Pattern topicPattern, VetoTopicEventListener vetoListener); - - /** - * Subscribes a VetoEventListener for an event class and its subclasses. Only a WeakReference to the - * VetoEventListener is held by the EventService. - *

    - * The VetoEventListener will remain subscribed until {@link #unsubscribeVetoListener(Class,VetoEventListener)} is - * called. - *

    - * - * @param eventClass the class of published objects to listen to - * @param vetoListener The vetoListener that will accept the events when published. - * - * @return true if the vetoListener was subscribed successfully, false otherwise - */ - public boolean subscribeVetoListenerStrongly(Class eventClass, VetoEventListener vetoListener); - - /** - * Subscribes a VetoEventListener for an event class (but not its subclasses). - *

    - * The VetoEventListener will remain subscribed until {@link #unsubscribeVetoListener(Class,VetoEventListener)} is - * called. - *

    - * - * @param eventClass the class of published objects to listen to - * @param vetoListener The vetoListener that will accept the events when published. - * - * @return true if the vetoListener was subscribed successfully, false otherwise - */ - public boolean subscribeVetoListenerExactlyStrongly(Class eventClass, VetoEventListener vetoListener); - - /** - * Subscribes a VetoEventListener to a topic name. - *

    - * The VetoEventListener will remain subscribed until {@link #unsubscribeVetoListener(String,VetoTopicEventListener)} is - * called. - *

    - * - * @param topic the name of the topic listened to - * @param vetoListener The topic vetoListener that will accept or reject publication. - * - * @return true if the vetoListener was subscribed successfully, false otherwise - * - * @see #subscribeVetoListenerStrongly(Class,VetoEventListener) - */ - public boolean subscribeVetoListenerStrongly(String topic, VetoTopicEventListener vetoListener); - - /** - * Subscribes a VetoTopicEventListener to a set of topics that match a RegEx expression. - *

    - * The VetoEventListener will remain subscribed until {@link #unsubscribeVetoListener(Pattern,VetoTopicEventListener)} is - * called. - *

    - * - * @param topicPattern the RegEx pattern that matches the name of the topics listened to - * @param vetoListener The topic vetoListener that will accept or reject publication. - * - * @return true if the vetoListener was subscribed successfully, false otherwise - * - * @see #subscribeVetoListenerStrongly(Pattern,VetoTopicEventListener) - */ - public boolean subscribeVetoListenerStrongly(Pattern topicPattern, VetoTopicEventListener vetoListener); - - /** - * Stop the subscription for a vetoListener that is subscribed to an event class and its subclasses. - * - * @param eventClass the class of published objects that can be vetoed - * @param vetoListener The vetoListener that will accept or reject publication of an event. - * - * @return true if the vetoListener was subscribed to the event, false if it wasn't - */ - public boolean unsubscribeVetoListener(Class eventClass, VetoEventListener vetoListener); - - /** - * Stop the subscription for a vetoListener that is subscribed to an event class (but not its subclasses). - * - * @param eventClass the class of published objects that can be vetoed - * @param vetoListener The vetoListener that will accept or reject publication of an event. - * - * @return true if the vetoListener was subscribed to the event, false if it wasn't - */ - public boolean unsubscribeVetoListenerExactly(Class eventClass, VetoEventListener vetoListener); - - /** - * Stop the subscription for a VetoTopicEventListener that is subscribed to an event topic name. - * - * @param topic the name of the topic that is listened to - * @param vetoListener The vetoListener that can determine whether an event is published on that topic - * - * @return true if the vetoListener was subscribed to the topic, false if it wasn't - */ - public boolean unsubscribeVetoListener(String topic, VetoTopicEventListener vetoListener); - - /** - * Stop the subscription for a VetoTopicEventListener that is subscribed to an event topic RegEx pattern. - * - * @param topicPattern the RegEx pattern matching the name of the topics listened to - * @param vetoListener The vetoListener that can determine whether an event is published on that topic - * - * @return true if the vetoListener was subscribed to the topicPattern, false if it wasn't - */ - public boolean unsubscribeVetoListener(Pattern topicPattern, VetoTopicEventListener vetoListener); - - /** - * Union of getSubscribersToClass(Class) and getSubscribersToExactClass(Class) - * - * @param eventClass the eventClass of interest - * - * @return the subscribers that will be called when an event of eventClass is published, this includes those - * subscribed that match by exact class and those that match to a class and its supertypes - */ - public List getSubscribers(Class eventClass); - - /** - * Gets subscribers that subscribed with the given a class, but not those subscribed exactly to the class. - * @param eventClass the eventClass of interest - * - * @return the subscribers that are subscribed to match to a class and its supertypes, but not those subscribed by - * exact class - */ - public List getSubscribersToClass(Class eventClass); - - /** - * Gets subscribers that are subscribed exactly to a class, but not those subscribed non-exactly to a class. - * @param eventClass the eventClass of interest - * - * @return the subscribers that are subscribed by exact class but not those subscribed to match to a class and its - * supertypes - */ - public List getSubscribersToExactClass(Class eventClass); - - /** - * Gets the subscribers that subscribed to a generic type. - * - * @param type the type of interest - * - * @return the subscribers that will be called when an event of eventClass is published, this includes those - * subscribed that match by exact class and those that match to a class and its supertypes - */ - public List getSubscribers(Type type); - - /** - * Union of getSubscribersByPattern(String) and geSubscribersToTopic(String) - * - * @param topic the topic of interest - * - * @return the subscribers that will be called when an event is published on the topic. This includes subscribers - * subscribed to match the exact topic name and those subscribed by a RegEx Pattern that matches the topic - * name. - */ - public List getSubscribers(String topic); - - /** - * Get the subscribers that subscribed to a topic. - * @param topic the topic of interest - * - * @return the subscribers that subscribed to the exact topic name. - */ - public List getSubscribersToTopic(String topic); - - /** - * Gets the subscribers that subscribed to a regular expression. - * @param pattern the RegEx pattern that was subscribed to - * - * @return the subscribers that were subscribed to this pattern. - */ - public List getSubscribers(Pattern pattern); - - /** - * Gets the subscribers that subscribed with a Pattern that matches the given topic. - * @param topic a topic to match Patterns against - * - * @return the subscribers that subscribed by a RegEx Pattern that matches the topic name. - */ - public List getSubscribersByPattern(String topic); - - /** - * Gets veto subscribers that subscribed to a given class. - * @param eventClass the eventClass of interest - * - * @return the veto subscribers that will be called when an event of eventClass or its subclasses is published. - */ - public List getVetoSubscribers(Class eventClass); - - /** - * Get veto subscribers that subscribed to a given class exactly. - * @param eventClass the eventClass of interest - * - * @return the veto subscribers that will be called when an event of eventClass (but not its subclasses) is - * published. - */ - public List getVetoSubscribersToExactClass(Class eventClass); - - /** - * Gets the veto subscribers that subscribed to a class. - * @param eventClass the eventClass of interest - * - * @return the veto subscribers that are subscribed to the eventClass and its subclasses - */ - public List getVetoSubscribersToClass(Class eventClass); - - /** - * Union of {@link #getVetoSubscribersToTopic(String)} and {@link #getVetoSubscribersByPattern(String)} - * Misnamed method, should be called {@link #getVetoSubscribers(String)}. Will be deprecated in 1.5. - * - * @param topicOrPattern the topic or pattern of interest - * - * @return the veto subscribers that will be called when an event is published on the topic. - */ - public List getVetoEventListeners(String topicOrPattern); - - /** - * Gets the veto subscribers that subscribed to a topic. - * @param topic the topic of interest - * - * @return the veto subscribers that will be called when an event is published on the topic. - */ - public List getVetoSubscribersToTopic(String topic); - - /** - * Gets the veto subscribers that subscribed to a regular expression. - * @param pattern the RegEx pattern for the topic of interest - * - * @return the veto subscribers that were subscribed to this pattern. - */ - public List getVetoSubscribers(Pattern pattern); - - /** - * Gets the veto subscribers that are subscribed by pattern that match the topic. - * @param topic the topic to match the pattern string subscribed to - * - * @return the veto subscribers that subscribed by pattern that will be called when an event is published on the topic. - */ - public List getVetoSubscribersByPattern(String topic); - - /** - * Misnamed method for backwards compatibility. - * Duplicate of {@link #getVetoSubscribersToTopic(String)}. - * Out of sync with {@link #getSubscribers(String)}. - * @param topic the topic exactly subscribed to - * - * @return the veto subscribers that are subscribed to the topic. - * @deprecated use getVetoSubscribersToTopic instead for direct replacement, - * or use getVetoEventListeners to get topic and pattern matchers. - * In EventBus 2.0 this name will replace getVetoEventListeners() - * and have it's union functionality - */ - public List getVetoSubscribers(String topic); - - /** Clears all current subscribers and veto subscribers */ - public void clearAllSubscribers(); - - /** - * Sets the default cache size for each kind of event, default is 0 (no caching). - *

    - * If this value is set to a positive number, then when an event is published, the EventService caches the event or - * topic payload data for later retrieval. This allows subscribers to find out what has most recently happened - * before they subscribed. The cached event(s) are returned from #getLastEvent(Class), #getLastTopicData(String), - * #getCachedEvents(Class), or #getCachedTopicData(String) - *

    - *

    - * The default can be overridden on a by-event-class or by-topic basis. - *

    - * - * @param defaultCacheSizePerClassOrTopic the cache size per event - */ - public void setDefaultCacheSizePerClassOrTopic(int defaultCacheSizePerClassOrTopic); - - /** - * The default number of events or payloads kept per event class or topic - * @return the default number of event payloads kept per event class or topic - */ - public int getDefaultCacheSizePerClassOrTopic(); - - /** - * Set the number of events cached for a particular class of event. By default, no events are cached. - *

    - * This overrides any setting for the DefaultCacheSizePerClassOrTopic. - *

    - *

    - * Class hierarchy semantics are respected. That is, if there are three events, A, X and Y, and X and Y are both - * derived from A, then setting the cache size for A applies the cache size for all three. Setting the cache size - * for X applies to X and leaves the settings for A and Y in tact. Interfaces can be passed to this method, but they - * only take effect if the cache size of a class or it's superclasses has been set. Just like Class.getInterfaces(), - * if multiple cache sizes are set, the interface names declared earliest in the implements clause of the eventClass - * takes effect. - *

    - *

    - * The cache for an event is not adjusted until the next event of that class is published. - *

    - * - * @param eventClass the class of event - * @param cacheSize the number of published events to cache for this event - */ - public void setCacheSizeForEventClass(Class eventClass, int cacheSize); - - /** - * Returns the number of events cached for a particular class of event. By default, no events are cached. - *

    - * This result is computed for a particular class from the values passed to #setCacheSizeForEventClass(Class, int), - * and respects the class hierarchy. - *

    - * - * @param eventClass the class of event - * - * @return the maximum size of the event cache for the given event class - * - * @see #setCacheSizeForEventClass(Class,int) - */ - public int getCacheSizeForEventClass(Class eventClass); - - /** - * Set the number of published data objects cached for a particular event topic. By default, no data are cached. - *

    - * This overrides any setting for the DefaultCacheSizePerClassOrTopic. - *

    - *

    - * Exact topic names take precedence over pattern matching. - *

    - *

    - * The cache for a topic is not adjusted until the next publication on that topic. - *

    - * - * @param topicName the topic name - * @param cacheSize the number of published data Objects to cache for this topic - */ - public void setCacheSizeForTopic(String topicName, int cacheSize); - - /** - * Set the number of published data objects cached for a topics matching a pattern. By default, no data are cached. - *

    - * This overrides any setting for the DefaultCacheSizePerClassOrTopic. - *

    - *

    - * Exact topic names take precedence over pattern matching. - *

    - *

    - * The cache for a topic is not adjusted until the next publication on that topic. - *

    - * - * @param pattern the pattern matching topic names - * @param cacheSize the number of data Objects to cache for this topic - */ - public void setCacheSizeForTopic(Pattern pattern, int cacheSize); - - /** - * Returns the number of cached data objects published on a particular topic. - *

    - * This result is computed for a particular class from the values passed to #setCacheSizeForEventClass(Class, int), - * and respects the class hierarchy. - *

    - * - * @param topic the topic name - * - * @return the maximum size of the data Object cache for the given topic - * - * @see #setCacheSizeForTopic(String,int) - * @see #setCacheSizeForTopic(java.util.regex.Pattern,int) - */ - public int getCacheSizeForTopic(String topic); - - /** - * When caching, returns the last event publish for the type supplied. - * @param eventClass an index into the cache - * - * @return the last event published for this event class, or null if caching is turned off (the default) - */ - public T getLastEvent(Class eventClass); - - /** - * When caching, returns the last set of event published for the type supplied. - * @param eventClass an index into the cache - * - * @return the last events published for this event class, or null if caching is turned off (the default) - */ - public List getCachedEvents(Class eventClass); - - /** - * When caching, returns the last payload published on the topic name supplied. - * @param topic an index into the cache - * - * @return the last data Object published on this topic, or null if caching is turned off (the default) - */ - public Object getLastTopicData(String topic); - - /** - * When caching, returns the last set of payload objects published on the topic name supplied. - * @param topic an index into the cache - * - * @return the last data Objects published on this topic, or null if caching is turned off (the default) - */ - public List getCachedTopicData(String topic); - - /** - * Clears the event cache for a specific event class or interface and it's any of it's subclasses or implementing - * classes. - * - * @param eventClass the event class to clear the cache for - */ - public void clearCache(Class eventClass); - - /** - * Clears the topic data cache for a specific topic name. - * - * @param topic the topic name to clear the cache for - */ - public void clearCache(String topic); - - /** - * Clears the topic data cache for all topics that match a particular pattern. - * - * @param pattern the pattern to match topic caches to - */ - public void clearCache(Pattern pattern); - - /** Clear all event caches for all topics and event. */ - public void clearCache(); - - /** - * Stop a subscription for an object that is subscribed with a ProxySubscriber. - *

    - * If an object is subscribed by proxy and it implements EventSubscriber, then the normal unsubscribe methods will - * still unsubscribe the object. - *

    - * - * @param eventClass class this object is subscribed to by proxy - * @param subscribedByProxy object subscribed by proxy - * @return true if the subscription was cancelled, false if it never existed - */ - boolean unsubscribe(Class eventClass, Object subscribedByProxy); - - /** - * Stop a subscription for an object that is subscribed exactly with a ProxySubscriber. - *

    - * If an object is subscribed by proxy and it implements EventSubscriber, then the normal unsubscribe methods will - * still unsubscribe the object. - *

    - * - * @param eventClass class this object is subscribed to by proxy - * @param subscribedByProxy object subscribed by proxy - * @return true if the subscription was cancelled, false if it never existed - */ - boolean unsubscribeExactly(Class eventClass, Object subscribedByProxy); - - /** - * Stop a subscription for an object that is subscribed to a topic with a ProxySubscriber. - *

    - * If an object is subscribed by proxy and it implements EventSubscriber, then the normal unsubscribe methods will - * still unsubscribe the object. - *

    - * - * @param topic the topic this object is subscribed to by proxy - * @param subscribedByProxy object subscribed by proxy - * @return true if the subscription was cancelled, false if it never existed - */ - boolean unsubscribe(String topic, Object subscribedByProxy); - - /** - * When using annotations, an object may be subscribed by proxy. This unsubscribe method will unsubscribe an object - * that is subscribed with a ProxySubscriber. - *

    - * If an object is subscribed by proxy and it implements EventSubscriber, then the normal unsubscribe methods will - * still unsubscribe the object. - *

    - * - * @param pattern the RegEx expression this object is subscribed to by proxy - * @param subscribedByProxy object subscribed by proxy - * @return true if the subscription was cancelled, false if it never existed - */ - boolean unsubscribe(Pattern pattern, Object subscribedByProxy); - - /** - * Stop a veto subscription for an object that is subscribed with a ProxySubscriber. - *

    - * If an object is subscribed by proxy and it implements VetoSubscriber, then the normal unsubscribe methods will - * still unsubscribe the object. - *

    - * - * @param eventClass class this object is subscribed to by proxy - * @param subscribedByProxy object subscribed by proxy - * @return true if the subscription was cancelled, false if it never existed - */ - boolean unsubscribeVeto(Class eventClass, Object subscribedByProxy); - - /** - * Stop a veto subscription for an object that is subscribed exactly with a ProxySubscriber. - *

    - * If an object is subscribed by proxy and it implements VetoSubscriber, then the normal unsubscribe methods will - * still unsubscribe the object. - *

    - * - * @param eventClass class this object is subscribed to by proxy - * @param subscribedByProxy object subscribed by proxy - * @return true if the subscription was cancelled, false if it never existed - */ - boolean unsubscribeVetoExactly(Class eventClass, Object subscribedByProxy); - - /** - * Stop a veto subscription for an object that is subscribed to a topic with a ProxySubscriber. - *

    - * If an object is subscribed by proxy and it implements EventSubscriber, then the normal unsubscribe methods will - * still unsubscribe the object. - *

    - * - * @param topic the topic this object is subscribed to by proxy - * @param subscribedByProxy object subscribed by proxy - * @return true if the subscription was cancelled, false if it never existed - */ - boolean unsubscribeVeto(String topic, Object subscribedByProxy); - - /** - * When using annotations, an object may be subscribed by proxy. This unsubscribe method will unsubscribe an object - * that is subscribed with a ProxySubscriber. - *

    - * If an object is subscribed by proxy and it implements EventSubscriber, then the normal unsubscribe methods will - * still unsubscribe the object. - *

    - * - * @param pattern the RegEx expression this object is subscribed to by proxy - * @param subscribedByProxy object subscribed by proxy - * @return true if the subscription was cancelled, false if it never existed - */ - boolean unsubscribeVeto(Pattern pattern, Object subscribedByProxy); + /** + * Publishes an object so that subscribers will be notified if they subscribed + * to the object's class, one of its subclasses, or to one of the interfaces + * it implements. + * + * @param event the object to publish + */ + public void publish(Object event); + + /** + * Use this method to publish generified objects to subscribers of Types, i.e. + * subscribers that use {@link #subscribe(Type, EventSubscriber)}, and to + * publish to subscribers of the non-generic type. + *

    + * Due to generic type erasure, the type must be supplied by the caller. You + * can get a declared object's type by using the + * {@link org.scijava.event.bushe.TypeReference} class. For Example: + *

    + * + *
    +	 * TypeReference<List<Trade>> subscribingTypeReference = new TypeReference<List<Trade>>(){};
    +	 * EventBus.subscribe(subscribingTypeReference.getType(), mySubscriber);
    +	 * EventBus.subscribe(List.class, thisSubscriberWillGetCalledToo);
    +	 * ...
    +	 * //Likely in some other class
    +	 * TypeReference<List<Trade>> publishingTypeReference = new TypeReference<List<Trade>>(){};
    +	 * List<Trade> trades = new ArrayList<Trade>();
    +	 * EventBus.publish(publishingTypeReference.getType(), trades);
    +	 * trades.add(trade);
    +	 * EventBus.publish(publishingTypeReference.getType(), trades);
    +	 * 
    + * + * @param genericType the generified type of the published object. + * @param event The event that occurred + */ + public void publish(Type genericType, Object event); + + /** + * Publishes an object on a topic name so that all subscribers to that name or + * a Regular Expression that matches the topic name will be notified. + * + * @param topic The name of the topic subscribed to + * @param o the object to publish + */ + public void publish(String topic, Object o); + + /** + * Subscribes an EventSubscriber to the publication of objects matching a + * type. Only a WeakReference to the subscriber is held by the + * EventService. + *

    + * Subscribing to a class means the subscriber will be called when objects of + * that class are published, when objects of subclasses of the class are + * published, when objects implementing any of the interfaces of the class are + * published, or when generic types are published with the class' raw type. + *

    + *

    + * Subscription is weak by default to avoid having to call unsubscribe(), and + * to avoid the memory leaks that would occur if unsubscribe was not called. + * The service will respect the WeakReference semantics. In other words, if + * the subscriber has not been garbage collected, then onEvent(Object) will be + * called normally. If the hard reference has been garbage collected, the + * service will unsubscribe it's WeakReference. + *

    + *

    + * It's allowable to call unsubscribe() with the same EventSubscriber hard + * reference to stop a subscription immediately. + *

    + *

    + * The service will create the WeakReference on behalf of the caller. + *

    + * + * @param eventClass the class of published objects to subscriber listen to + * @param subscriber The subscriber that will accept the events of the event + * class when published. + * @return true if the subscriber was subscribed successfully, false otherwise + */ + public boolean subscribe(Class eventClass, EventSubscriber subscriber); + + /** + * Subscribe an EventSubscriber to publication of generic Types. Subscribers + * will only be notified for publications using + * {@link #publish(java.lang.reflect.Type, Object)}. + *

    + * Due to generic type erasure, the type must be supplied by the publisher. + * You can get a declared object's type by using the + * {@link org.scijava.event.bushe.TypeReference} class. For Example: + *

    + * + *
    +	 * TypeReference<List<Trade>> subscribingTypeReference = new TypeReference<List<Trade>>(){};
    +	 * EventBus.subscribe(subscribingTypeReference.getType(), mySubscriber);
    +	 * EventBus.subscribe(List.class, thisSubscriberWillGetCalledToo);
    +	 * ...
    +	 * //Likely in some other class
    +	 * TypeReference<List<Trade>> publishingTypeReference = new TypeReference<List<Trade>>(){};
    +	 * List<Trade> trades = new ArrayList<Trade>();
    +	 * EventBus.publish(publishingTypeReference.getType(), trades);
    +	 * trades.add(trade);
    +	 * EventBus.publish(publishingTypeReference.getType(), trades);
    +	 * 
    + * + * @param type the generic type to subscribe to + * @param subscriber the subscriber to the type + * @return true if a new subscription is made, false if it already existed + */ + public boolean subscribe(Type type, EventSubscriber subscriber); + + /** + * Subscribes an EventSubscriber to the publication of objects exactly + * matching a type. Only a WeakReference to the subscriber is held by + * the EventService. + *

    + * Subscription is weak by default to avoid having to call unsubscribe(), and + * to avoid the memory leaks that would occur if unsubscribe was not called. + * The service will respect the WeakReference semantics. In other words, if + * the subscriber has not been garbage collected, then the onEvent will be + * called normally. If the hard reference has been garbage collected, the + * service will unsubscribe it's WeakReference. + *

    + *

    + * It's allowable to call unsubscribe() with the same EventSubscriber hard + * reference to stop a subscription immediately. + *

    + *

    + * The service will create the WeakReference on behalf of the caller. + *

    + * + * @param eventClass the class of published objects to listen to + * @param subscriber The subscriber that will accept the events when + * published. + * @return true if the subscriber was subscribed successfully, false otherwise + */ + public boolean subscribeExactly(Class eventClass, EventSubscriber subscriber); + + /** + * Subscribes an EventTopicSubscriber to the publication of a topic name. Only + * a WeakReference to the subscriber is held by the EventService. + *

    + * Subscription is weak by default to avoid having to call unsubscribe(), and + * to avoid the memory leaks that would occur if unsubscribe was not called. + * The service will respect the WeakReference semantics. In other words, if + * the subscriber has not been garbage collected, then the onEvent will be + * called normally. If the hard reference has been garbage collected, the + * service will unsubscribe it's WeakReference. + *

    + *

    + * It's allowable to call unsubscribe() with the same EventSubscriber hard + * reference to stop a subscription immediately. + *

    + * + * @param topic the name of the topic listened to + * @param subscriber The topic subscriber that will accept the events when + * published. + * @return true if the subscriber was subscribed successfully, false otherwise + */ + public boolean subscribe(String topic, EventTopicSubscriber subscriber); + + /** + * Subscribes an EventSubscriber to the publication of all the topic names + * that match a RegEx Pattern. Only a WeakReference to the subscriber + * is held by the EventService. + *

    + * Subscription is weak by default to avoid having to call unsubscribe(), and + * to avoid the memory leaks that would occur if unsubscribe was not called. + * The service will respect the WeakReference semantics. In other words, if + * the subscriber has not been garbage collected, then the onEvent will be + * called normally. If the hard reference has been garbage collected, the + * service will unsubscribe it's WeakReference. + *

    + *

    + * It's allowable to call unsubscribe() with the same EventSubscriber hard + * reference to stop a subscription immediately. + *

    + * + * @param topicPattern pattern that matches to the name of the topic published + * to + * @param subscriber The topic subscriber that will accept the events when + * published. + * @return true if the subscriber was subscribed successfully, false otherwise + */ + public boolean subscribe(Pattern topicPattern, + EventTopicSubscriber subscriber); + + /** + * Subscribes an EventSubscriber to the publication of objects matching a + * type. + *

    + * The semantics are the same as {@link #subscribe(Class, EventSubscriber)}, + * except that the EventService holds a regularly reference, not a + * WeakReference. + *

    + *

    + * The subscriber will remain subscribed until + * {@link #unsubscribe(Class,EventSubscriber)} is called. + *

    + * + * @param eventClass the class of published objects to listen to + * @param subscriber The subscriber that will accept the events when + * published. + * @return true if the subscriber was subscribed successfully, false otherwise + */ + public boolean subscribeStrongly(Class eventClass, + EventSubscriber subscriber); + + /** + * Subscribes an EventSubscriber to the publication of objects matching a type + * exactly. + *

    + * The semantics are the same as + * {@link #subscribeExactly(Class, EventSubscriber)}, except that the + * EventService holds a regularly reference, not a WeakReference. + *

    + *

    + * The subscriber will remain subscribed until + * {@link #unsubscribe(Class,EventSubscriber)} is called. + *

    + * + * @param eventClass the class of published objects to listen to + * @param subscriber The subscriber that will accept the events when + * published. + * @return true if the subscriber was subscribed successfully, false otherwise + */ + public boolean subscribeExactlyStrongly(Class eventClass, + EventSubscriber subscriber); + + /** + * Subscribes a subscriber to an event topic name. + *

    + * The semantics are the same as + * {@link #subscribe(String, EventTopicSubscriber)}, except that the + * EventService holds a regularly reference, not a WeakReference. + *

    + *

    + * The subscriber will remain subscribed until + * {@link #unsubscribe(String,EventTopicSubscriber)} is called. + *

    + * + * @param topic the name of the topic listened to + * @param subscriber The topic subscriber that will accept the events when + * published. + * @return true if the subscriber was subscribed successfully, false otherwise + */ + public boolean subscribeStrongly(String topic, + EventTopicSubscriber subscriber); + + /** + * Subscribes a subscriber to all the event topic names that match a RegEx + * expression. + *

    + * The semantics are the same as + * {@link #subscribe(java.util.regex.Pattern, EventTopicSubscriber)}, except + * that the EventService holds a regularly reference, not a WeakReference. + *

    + *

    + * The subscriber will remain subscribed until + * {@link #unsubscribe(String,EventTopicSubscriber)} is called. + *

    + * + * @param topicPattern the name of the topic listened to + * @param subscriber The topic subscriber that will accept the events when + * published. + * @return true if the subscriber was subscribed successfully, false otherwise + */ + public boolean subscribeStrongly(Pattern topicPattern, + EventTopicSubscriber subscriber); + + /** + * Stop the subscription for a subscriber that is subscribed to a class. + * + * @param eventClass the class of published objects to listen to + * @param subscriber The subscriber that is subscribed to the event. The same + * reference as the one subscribed. + * @return true if the subscriber was subscribed to the event, false if it + * wasn't + */ + public boolean unsubscribe(Class eventClass, EventSubscriber subscriber); + + /** + * Stop the subscription for a subscriber that is subscribed to an exact + * class. + * + * @param eventClass the class of published objects to listen to + * @param subscriber The subscriber that is subscribed to the event. The same + * reference as the one subscribed. + * @return true if the subscriber was subscribed to the event, false if it + * wasn't + */ + public boolean unsubscribeExactly(Class eventClass, + EventSubscriber subscriber); + + /** + * Stop the subscription for a subscriber that is subscribed to an event + * topic. + * + * @param topic the topic listened to + * @param subscriber The subscriber that is subscribed to the topic. The same + * reference as the one subscribed. + * @return true if the subscriber was subscribed to the event, false if it + * wasn't + */ + public boolean unsubscribe(String topic, EventTopicSubscriber subscriber); + + /** + * Stop the subscription for a subscriber that is subscribed to event topics + * via a Pattern. + * + * @param topicPattern the regex expression matching topics listened to + * @param subscriber The subscriber that is subscribed to the topic. The same + * reference as the one subscribed. + * @return true if the subscriber was subscribed to the event, false if it + * wasn't + */ + public boolean unsubscribe(Pattern topicPattern, + EventTopicSubscriber subscriber); + + /** + * Subscribes a VetoEventListener to publication of event matching a class. + * Only a WeakReference to the VetoEventListener is held by the + * EventService. + *

    + * Use this method to avoid having to call unsubscribe(), though with care + * since garbage collection semantics is indeterminate. The service will + * respect the WeakReference semantics. In other words, if the vetoListener + * has not been garbage collected, then the onEvent will be called normally. + * If the hard reference has been garbage collected, the service will + * unsubscribe it's WeakReference. + *

    + *

    + * It's allowable to call unsubscribe() with the same VetoEventListener hard + * reference to stop a subscription immediately. + *

    + *

    + * The service will create the WeakReference on behalf of the caller. + *

    + * + * @param eventClass the class of published objects that can be vetoed + * @param vetoListener The VetoEventListener that can determine whether an + * event is published. + * @return true if the VetoEventListener was subscribed successfully, false + * otherwise + */ + public boolean subscribeVetoListener(Class eventClass, + VetoEventListener vetoListener); + + /** + * Subscribes a VetoEventListener to publication of an exact event class. Only + * a WeakReference to the VetoEventListener is held by the + * EventService. + *

    + * Use this method to avoid having to call unsubscribe(), though with care + * since garbage collection semantics is indeterminate. The service will + * respect the WeakReference semantics. In other words, if the vetoListener + * has not been garbage collected, then the onEvent will be called normally. + * If the hard reference has been garbage collected, the service will + * unsubscribe it's WeakReference. + *

    + *

    + * It's allowable to call unsubscribe() with the same VetoEventListener hard + * reference to stop a subscription immediately. + *

    + *

    + * The service will create the WeakReference on behalf of the caller. + *

    + * + * @param eventClass the class of published objects that can be vetoed + * @param vetoListener The vetoListener that can determine whether an event is + * published. + * @return true if the vetoListener was subscribed successfully, false + * otherwise + */ + public boolean subscribeVetoListenerExactly(Class eventClass, + VetoEventListener vetoListener); + + /** + * Subscribes a VetoTopicEventListener to a topic name. Only a + * WeakReference to the VetoEventListener is held by the EventService. + * + * @param topic the name of the topic listened to + * @param vetoListener The vetoListener that can determine whether an event is + * published. + * @return true if the vetoListener was subscribed successfully, false + * otherwise + */ + public boolean subscribeVetoListener(String topic, + VetoTopicEventListener vetoListener); + + /** + * Subscribes an VetoTopicEventListener to all the topic names that match the + * RegEx Pattern. Only a WeakReference to the VetoEventListener is held + * by the EventService. + * + * @param topicPattern the RegEx pattern to match topics with + * @param vetoListener The vetoListener that can determine whether an event is + * published. + * @return true if the vetoListener was subscribed successfully, false + * otherwise + */ + public boolean subscribeVetoListener(Pattern topicPattern, + VetoTopicEventListener vetoListener); + + /** + * Subscribes a VetoEventListener for an event class and its subclasses. Only + * a WeakReference to the VetoEventListener is held by the + * EventService. + *

    + * The VetoEventListener will remain subscribed until + * {@link #unsubscribeVetoListener(Class,VetoEventListener)} is called. + *

    + * + * @param eventClass the class of published objects to listen to + * @param vetoListener The vetoListener that will accept the events when + * published. + * @return true if the vetoListener was subscribed successfully, false + * otherwise + */ + public boolean subscribeVetoListenerStrongly(Class eventClass, + VetoEventListener vetoListener); + + /** + * Subscribes a VetoEventListener for an event class (but not its subclasses). + *

    + * The VetoEventListener will remain subscribed until + * {@link #unsubscribeVetoListener(Class,VetoEventListener)} is called. + *

    + * + * @param eventClass the class of published objects to listen to + * @param vetoListener The vetoListener that will accept the events when + * published. + * @return true if the vetoListener was subscribed successfully, false + * otherwise + */ + public boolean subscribeVetoListenerExactlyStrongly(Class eventClass, + VetoEventListener vetoListener); + + /** + * Subscribes a VetoEventListener to a topic name. + *

    + * The VetoEventListener will remain subscribed until + * {@link #unsubscribeVetoListener(String,VetoTopicEventListener)} is called. + *

    + * + * @param topic the name of the topic listened to + * @param vetoListener The topic vetoListener that will accept or reject + * publication. + * @return true if the vetoListener was subscribed successfully, false + * otherwise + * @see #subscribeVetoListenerStrongly(Class,VetoEventListener) + */ + public boolean subscribeVetoListenerStrongly(String topic, + VetoTopicEventListener vetoListener); + + /** + * Subscribes a VetoTopicEventListener to a set of topics that match a RegEx + * expression. + *

    + * The VetoEventListener will remain subscribed until + * {@link #unsubscribeVetoListener(Pattern,VetoTopicEventListener)} is called. + *

    + * + * @param topicPattern the RegEx pattern that matches the name of the topics + * listened to + * @param vetoListener The topic vetoListener that will accept or reject + * publication. + * @return true if the vetoListener was subscribed successfully, false + * otherwise + * @see #subscribeVetoListenerStrongly(Pattern,VetoTopicEventListener) + */ + public boolean subscribeVetoListenerStrongly(Pattern topicPattern, + VetoTopicEventListener vetoListener); + + /** + * Stop the subscription for a vetoListener that is subscribed to an event + * class and its subclasses. + * + * @param eventClass the class of published objects that can be vetoed + * @param vetoListener The vetoListener that will accept or reject publication + * of an event. + * @return true if the vetoListener was subscribed to the event, false if it + * wasn't + */ + public boolean unsubscribeVetoListener(Class eventClass, + VetoEventListener vetoListener); + + /** + * Stop the subscription for a vetoListener that is subscribed to an event + * class (but not its subclasses). + * + * @param eventClass the class of published objects that can be vetoed + * @param vetoListener The vetoListener that will accept or reject publication + * of an event. + * @return true if the vetoListener was subscribed to the event, false if it + * wasn't + */ + public boolean unsubscribeVetoListenerExactly(Class eventClass, + VetoEventListener vetoListener); + + /** + * Stop the subscription for a VetoTopicEventListener that is subscribed to an + * event topic name. + * + * @param topic the name of the topic that is listened to + * @param vetoListener The vetoListener that can determine whether an event is + * published on that topic + * @return true if the vetoListener was subscribed to the topic, false if it + * wasn't + */ + public boolean unsubscribeVetoListener(String topic, + VetoTopicEventListener vetoListener); + + /** + * Stop the subscription for a VetoTopicEventListener that is subscribed to an + * event topic RegEx pattern. + * + * @param topicPattern the RegEx pattern matching the name of the topics + * listened to + * @param vetoListener The vetoListener that can determine whether an event is + * published on that topic + * @return true if the vetoListener was subscribed to the topicPattern, false + * if it wasn't + */ + public boolean unsubscribeVetoListener(Pattern topicPattern, + VetoTopicEventListener vetoListener); + + /** + * Union of getSubscribersToClass(Class) and getSubscribersToExactClass(Class) + * + * @param eventClass the eventClass of interest + * @return the subscribers that will be called when an event of eventClass is + * published, this includes those subscribed that match by exact class + * and those that match to a class and its supertypes + */ + public List getSubscribers(Class eventClass); + + /** + * Gets subscribers that subscribed with the given a class, but not those + * subscribed exactly to the class. + * + * @param eventClass the eventClass of interest + * @return the subscribers that are subscribed to match to a class and its + * supertypes, but not those subscribed by exact class + */ + public List getSubscribersToClass(Class eventClass); + + /** + * Gets subscribers that are subscribed exactly to a class, but not those + * subscribed non-exactly to a class. + * + * @param eventClass the eventClass of interest + * @return the subscribers that are subscribed by exact class but not those + * subscribed to match to a class and its supertypes + */ + public List getSubscribersToExactClass(Class eventClass); + + /** + * Gets the subscribers that subscribed to a generic type. + * + * @param type the type of interest + * @return the subscribers that will be called when an event of eventClass is + * published, this includes those subscribed that match by exact class + * and those that match to a class and its supertypes + */ + public List getSubscribers(Type type); + + /** + * Union of getSubscribersByPattern(String) and geSubscribersToTopic(String) + * + * @param topic the topic of interest + * @return the subscribers that will be called when an event is published on + * the topic. This includes subscribers subscribed to match the exact + * topic name and those subscribed by a RegEx Pattern that matches the + * topic name. + */ + public List getSubscribers(String topic); + + /** + * Get the subscribers that subscribed to a topic. + * + * @param topic the topic of interest + * @return the subscribers that subscribed to the exact topic name. + */ + public List getSubscribersToTopic(String topic); + + /** + * Gets the subscribers that subscribed to a regular expression. + * + * @param pattern the RegEx pattern that was subscribed to + * @return the subscribers that were subscribed to this pattern. + */ + public List getSubscribers(Pattern pattern); + + /** + * Gets the subscribers that subscribed with a Pattern that matches the given + * topic. + * + * @param topic a topic to match Patterns against + * @return the subscribers that subscribed by a RegEx Pattern that matches the + * topic name. + */ + public List getSubscribersByPattern(String topic); + + /** + * Gets veto subscribers that subscribed to a given class. + * + * @param eventClass the eventClass of interest + * @return the veto subscribers that will be called when an event of + * eventClass or its subclasses is published. + */ + public List getVetoSubscribers(Class eventClass); + + /** + * Get veto subscribers that subscribed to a given class exactly. + * + * @param eventClass the eventClass of interest + * @return the veto subscribers that will be called when an event of + * eventClass (but not its subclasses) is published. + */ + public List getVetoSubscribersToExactClass(Class eventClass); + + /** + * Gets the veto subscribers that subscribed to a class. + * + * @param eventClass the eventClass of interest + * @return the veto subscribers that are subscribed to the eventClass and its + * subclasses + */ + public List getVetoSubscribersToClass(Class eventClass); + + /** + * Union of {@link #getVetoSubscribersToTopic(String)} and + * {@link #getVetoSubscribersByPattern(String)} Misnamed method, should be + * called {@link #getVetoSubscribers(String)}. Will be deprecated in 1.5. + * + * @param topicOrPattern the topic or pattern of interest + * @return the veto subscribers that will be called when an event is published + * on the topic. + */ + public List getVetoEventListeners(String topicOrPattern); + + /** + * Gets the veto subscribers that subscribed to a topic. + * + * @param topic the topic of interest + * @return the veto subscribers that will be called when an event is published + * on the topic. + */ + public List getVetoSubscribersToTopic(String topic); + + /** + * Gets the veto subscribers that subscribed to a regular expression. + * + * @param pattern the RegEx pattern for the topic of interest + * @return the veto subscribers that were subscribed to this pattern. + */ + public List getVetoSubscribers(Pattern pattern); + + /** + * Gets the veto subscribers that are subscribed by pattern that match the + * topic. + * + * @param topic the topic to match the pattern string subscribed to + * @return the veto subscribers that subscribed by pattern that will be called + * when an event is published on the topic. + */ + public List getVetoSubscribersByPattern(String topic); + + /** + * Misnamed method for backwards compatibility. Duplicate of + * {@link #getVetoSubscribersToTopic(String)}. Out of sync with + * {@link #getSubscribers(String)}. + * + * @param topic the topic exactly subscribed to + * @return the veto subscribers that are subscribed to the topic. + * @deprecated use getVetoSubscribersToTopic instead for direct replacement, + * or use getVetoEventListeners to get topic and pattern matchers. + * In EventBus 2.0 this name will replace getVetoEventListeners() + * and have it's union functionality + */ + public List getVetoSubscribers(String topic); + + /** Clears all current subscribers and veto subscribers */ + public void clearAllSubscribers(); + + /** + * Sets the default cache size for each kind of event, default is 0 (no + * caching). + *

    + * If this value is set to a positive number, then when an event is published, + * the EventService caches the event or topic payload data for later + * retrieval. This allows subscribers to find out what has most recently + * happened before they subscribed. The cached event(s) are returned from + * #getLastEvent(Class), #getLastTopicData(String), #getCachedEvents(Class), + * or #getCachedTopicData(String) + *

    + *

    + * The default can be overridden on a by-event-class or by-topic basis. + *

    + * + * @param defaultCacheSizePerClassOrTopic the cache size per event + */ + public void setDefaultCacheSizePerClassOrTopic( + int defaultCacheSizePerClassOrTopic); + + /** + * The default number of events or payloads kept per event class or topic + * + * @return the default number of event payloads kept per event class or topic + */ + public int getDefaultCacheSizePerClassOrTopic(); + + /** + * Set the number of events cached for a particular class of event. By + * default, no events are cached. + *

    + * This overrides any setting for the DefaultCacheSizePerClassOrTopic. + *

    + *

    + * Class hierarchy semantics are respected. That is, if there are three + * events, A, X and Y, and X and Y are both derived from A, then setting the + * cache size for A applies the cache size for all three. Setting the cache + * size for X applies to X and leaves the settings for A and Y in tact. + * Interfaces can be passed to this method, but they only take effect if the + * cache size of a class or it's superclasses has been set. Just like + * Class.getInterfaces(), if multiple cache sizes are set, the interface names + * declared earliest in the implements clause of the eventClass takes effect. + *

    + *

    + * The cache for an event is not adjusted until the next event of that class + * is published. + *

    + * + * @param eventClass the class of event + * @param cacheSize the number of published events to cache for this event + */ + public void setCacheSizeForEventClass(Class eventClass, int cacheSize); + + /** + * Returns the number of events cached for a particular class of event. By + * default, no events are cached. + *

    + * This result is computed for a particular class from the values passed to + * #setCacheSizeForEventClass(Class, int), and respects the class hierarchy. + *

    + * + * @param eventClass the class of event + * @return the maximum size of the event cache for the given event class + * @see #setCacheSizeForEventClass(Class,int) + */ + public int getCacheSizeForEventClass(Class eventClass); + + /** + * Set the number of published data objects cached for a particular event + * topic. By default, no data are cached. + *

    + * This overrides any setting for the DefaultCacheSizePerClassOrTopic. + *

    + *

    + * Exact topic names take precedence over pattern matching. + *

    + *

    + * The cache for a topic is not adjusted until the next publication on that + * topic. + *

    + * + * @param topicName the topic name + * @param cacheSize the number of published data Objects to cache for this + * topic + */ + public void setCacheSizeForTopic(String topicName, int cacheSize); + + /** + * Set the number of published data objects cached for a topics matching a + * pattern. By default, no data are cached. + *

    + * This overrides any setting for the DefaultCacheSizePerClassOrTopic. + *

    + *

    + * Exact topic names take precedence over pattern matching. + *

    + *

    + * The cache for a topic is not adjusted until the next publication on that + * topic. + *

    + * + * @param pattern the pattern matching topic names + * @param cacheSize the number of data Objects to cache for this topic + */ + public void setCacheSizeForTopic(Pattern pattern, int cacheSize); + + /** + * Returns the number of cached data objects published on a particular topic. + *

    + * This result is computed for a particular class from the values passed to + * #setCacheSizeForEventClass(Class, int), and respects the class hierarchy. + *

    + * + * @param topic the topic name + * @return the maximum size of the data Object cache for the given topic + * @see #setCacheSizeForTopic(String,int) + * @see #setCacheSizeForTopic(java.util.regex.Pattern,int) + */ + public int getCacheSizeForTopic(String topic); + + /** + * When caching, returns the last event publish for the type supplied. + * + * @param eventClass an index into the cache + * @return the last event published for this event class, or null if caching + * is turned off (the default) + */ + public T getLastEvent(Class eventClass); + + /** + * When caching, returns the last set of event published for the type + * supplied. + * + * @param eventClass an index into the cache + * @return the last events published for this event class, or null if caching + * is turned off (the default) + */ + public List getCachedEvents(Class eventClass); + + /** + * When caching, returns the last payload published on the topic name + * supplied. + * + * @param topic an index into the cache + * @return the last data Object published on this topic, or null if caching is + * turned off (the default) + */ + public Object getLastTopicData(String topic); + + /** + * When caching, returns the last set of payload objects published on the + * topic name supplied. + * + * @param topic an index into the cache + * @return the last data Objects published on this topic, or null if caching + * is turned off (the default) + */ + public List getCachedTopicData(String topic); + + /** + * Clears the event cache for a specific event class or interface and it's any + * of it's subclasses or implementing classes. + * + * @param eventClass the event class to clear the cache for + */ + public void clearCache(Class eventClass); + + /** + * Clears the topic data cache for a specific topic name. + * + * @param topic the topic name to clear the cache for + */ + public void clearCache(String topic); + + /** + * Clears the topic data cache for all topics that match a particular pattern. + * + * @param pattern the pattern to match topic caches to + */ + public void clearCache(Pattern pattern); + + /** Clear all event caches for all topics and event. */ + public void clearCache(); + + /** + * Stop a subscription for an object that is subscribed with a + * ProxySubscriber. + *

    + * If an object is subscribed by proxy and it implements EventSubscriber, then + * the normal unsubscribe methods will still unsubscribe the object. + *

    + * + * @param eventClass class this object is subscribed to by proxy + * @param subscribedByProxy object subscribed by proxy + * @return true if the subscription was cancelled, false if it never existed + */ + boolean unsubscribe(Class eventClass, Object subscribedByProxy); + + /** + * Stop a subscription for an object that is subscribed exactly with a + * ProxySubscriber. + *

    + * If an object is subscribed by proxy and it implements EventSubscriber, then + * the normal unsubscribe methods will still unsubscribe the object. + *

    + * + * @param eventClass class this object is subscribed to by proxy + * @param subscribedByProxy object subscribed by proxy + * @return true if the subscription was cancelled, false if it never existed + */ + boolean unsubscribeExactly(Class eventClass, Object subscribedByProxy); + + /** + * Stop a subscription for an object that is subscribed to a topic with a + * ProxySubscriber. + *

    + * If an object is subscribed by proxy and it implements EventSubscriber, then + * the normal unsubscribe methods will still unsubscribe the object. + *

    + * + * @param topic the topic this object is subscribed to by proxy + * @param subscribedByProxy object subscribed by proxy + * @return true if the subscription was cancelled, false if it never existed + */ + boolean unsubscribe(String topic, Object subscribedByProxy); + + /** + * When using annotations, an object may be subscribed by proxy. This + * unsubscribe method will unsubscribe an object that is subscribed with a + * ProxySubscriber. + *

    + * If an object is subscribed by proxy and it implements EventSubscriber, then + * the normal unsubscribe methods will still unsubscribe the object. + *

    + * + * @param pattern the RegEx expression this object is subscribed to by proxy + * @param subscribedByProxy object subscribed by proxy + * @return true if the subscription was cancelled, false if it never existed + */ + boolean unsubscribe(Pattern pattern, Object subscribedByProxy); + + /** + * Stop a veto subscription for an object that is subscribed with a + * ProxySubscriber. + *

    + * If an object is subscribed by proxy and it implements VetoSubscriber, then + * the normal unsubscribe methods will still unsubscribe the object. + *

    + * + * @param eventClass class this object is subscribed to by proxy + * @param subscribedByProxy object subscribed by proxy + * @return true if the subscription was cancelled, false if it never existed + */ + boolean unsubscribeVeto(Class eventClass, Object subscribedByProxy); + + /** + * Stop a veto subscription for an object that is subscribed exactly with a + * ProxySubscriber. + *

    + * If an object is subscribed by proxy and it implements VetoSubscriber, then + * the normal unsubscribe methods will still unsubscribe the object. + *

    + * + * @param eventClass class this object is subscribed to by proxy + * @param subscribedByProxy object subscribed by proxy + * @return true if the subscription was cancelled, false if it never existed + */ + boolean unsubscribeVetoExactly(Class eventClass, Object subscribedByProxy); + + /** + * Stop a veto subscription for an object that is subscribed to a topic with a + * ProxySubscriber. + *

    + * If an object is subscribed by proxy and it implements EventSubscriber, then + * the normal unsubscribe methods will still unsubscribe the object. + *

    + * + * @param topic the topic this object is subscribed to by proxy + * @param subscribedByProxy object subscribed by proxy + * @return true if the subscription was cancelled, false if it never existed + */ + boolean unsubscribeVeto(String topic, Object subscribedByProxy); + + /** + * When using annotations, an object may be subscribed by proxy. This + * unsubscribe method will unsubscribe an object that is subscribed with a + * ProxySubscriber. + *

    + * If an object is subscribed by proxy and it implements EventSubscriber, then + * the normal unsubscribe methods will still unsubscribe the object. + *

    + * + * @param pattern the RegEx expression this object is subscribed to by proxy + * @param subscribedByProxy object subscribed by proxy + * @return true if the subscription was cancelled, false if it never existed + */ + boolean unsubscribeVeto(Pattern pattern, Object subscribedByProxy); } diff --git a/src/main/java/org/scijava/event/bushe/EventSubscriber.java b/src/main/java/org/scijava/event/bushe/EventSubscriber.java index 03e8f9227..af17db6f5 100644 --- a/src/main/java/org/scijava/event/bushe/EventSubscriber.java +++ b/src/main/java/org/scijava/event/bushe/EventSubscriber.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.scijava.event.bushe; /** @@ -22,14 +23,18 @@ */ public interface EventSubscriber { - /** - * Handle a published event.

    The EventService calls this method on each publication of an object that matches the - * class or interface passed to one of the EventService's class-based subscribe methods, specifically, {@link - * EventService#subscribe(Class,EventSubscriber)} {@link EventService#subscribeExactly(Class,EventSubscriber)} - * {@link EventService#subscribeStrongly(Class,EventSubscriber)} and {@link EventService#subscribeExactlyStrongly(Class, - *EventSubscriber)}. - * - * @param event The Object that is being published. - */ - public void onEvent(T event); + /** + * Handle a published event. + *

    + * The EventService calls this method on each publication of an object that + * matches the class or interface passed to one of the EventService's + * class-based subscribe methods, specifically, + * {@link EventService#subscribe(Class,EventSubscriber)} + * {@link EventService#subscribeExactly(Class,EventSubscriber)} + * {@link EventService#subscribeStrongly(Class,EventSubscriber)} and + * {@link EventService#subscribeExactlyStrongly(Class, EventSubscriber)}. + * + * @param event The Object that is being published. + */ + public void onEvent(T event); } diff --git a/src/main/java/org/scijava/event/bushe/EventTopicSubscriber.java b/src/main/java/org/scijava/event/bushe/EventTopicSubscriber.java index 37bf575e4..a5a58aa20 100644 --- a/src/main/java/org/scijava/event/bushe/EventTopicSubscriber.java +++ b/src/main/java/org/scijava/event/bushe/EventTopicSubscriber.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.scijava.event.bushe; /** @@ -22,18 +23,19 @@ */ interface EventTopicSubscriber { - /** - * Handle an event published on a topic. - *

    - * The EventService calls this method on each publication on a matching topic name passed to one of the - * EventService's topic-based subscribe methods, specifically, {@link EventService#subscribe(String, - *EventTopicSubscriber)} {@link EventService#subscribe(java.util.regex.Pattern,EventTopicSubscriber)} {@link - * EventService#subscribeStrongly(String,EventTopicSubscriber)} and {@link EventService#subscribeStrongly(java.util.regex.Pattern, - *EventTopicSubscriber)}. - *

    - * - * @param topic the name of the topic published on - * @param data the data object published on the topic - */ - public void onEvent(String topic, T data); + /** + * Handle an event published on a topic. + *

    + * The EventService calls this method on each publication on a matching topic + * name passed to one of the EventService's topic-based subscribe methods, + * specifically, {@link EventService#subscribe(String, EventTopicSubscriber)} + * {@link EventService#subscribe(java.util.regex.Pattern,EventTopicSubscriber)} + * {@link EventService#subscribeStrongly(String,EventTopicSubscriber)} and + * {@link EventService#subscribeStrongly(java.util.regex.Pattern, EventTopicSubscriber)}. + *

    + * + * @param topic the name of the topic published on + * @param data the data object published on the topic + */ + public void onEvent(String topic, T data); } diff --git a/src/main/java/org/scijava/event/bushe/Logger.java b/src/main/java/org/scijava/event/bushe/Logger.java index f2de3981b..f3cb188e5 100644 --- a/src/main/java/org/scijava/event/bushe/Logger.java +++ b/src/main/java/org/scijava/event/bushe/Logger.java @@ -1,3 +1,4 @@ + package org.scijava.event.bushe; import java.lang.reflect.InvocationTargetException; @@ -6,216 +7,270 @@ import java.util.HashMap; /** - * Central Logging class. Shields code from Logging implementation. + * Central Logging class. Shields code from Logging implementation. *

    * The EventBus allows operation in two modes - using java.util.logging so that - * the EventBus can be deployed in its own jar or using any logging system supported - * by apache commons logging, which of course requires other jars. + * the EventBus can be deployed in its own jar or using any logging system + * supported by apache commons logging, which of course requires other jars. *

    *

    * The EventBus logging uses the names of its classes as the log, primarily - * "org.scijava.event.bushe.EventService". This aids in debugging which subscription and publication issues. + * "org.scijava.event.bushe.EventService". This aids in debugging which + * subscription and publication issues. *

    *

    * Implementation note: There are no imports in this class to make things - * explicit. There is also no explicit use of classes outside java.util, - * anything else is used by reflection to avoid NoClassDefFound errors on class load. + * explicit. There is also no explicit use of classes outside java.util, + * anything else is used by reflection to avoid NoClassDefFound errors on class + * load. *

    */ class Logger { - private java.util.logging.Logger utilLogger; - private /*Untyped to avoid java.lang.NoClassDefFoundError - org.apache.commons.logging.Log*/ Object commonsLogger; - private Map METHOD_CACHE_NO_PARAMS; - private Map METHOD_CACHE_ONE_PARAM; - private Map METHOD_CACHE_TWO_PARAMS; - private static Class logFactoryClass; - private static Class logClass; - private static Method getLogMethod; - private static final Object[] EMPTY_ARGS = new Object[0]; - private static final Class[] CLASS_ARGS_EMPTY = new Class[0]; - private static final Class[] CLASS_ARGS_ONE = new Class[]{Object.class}; - private static final Class[] CLASS_ARGS_TWO = new Class[]{Object.class, Throwable.class}; - - /** Allows switching between Java and Commons logging.*/ - public static enum LoggerType { - /*java.util.logging*/ - JAVA, - /*org.apache.commons.logging*/ - COMMONS - } - - /** Standardized logging levels. */ - public static enum Level { - FATAL, - ERROR, - WARN, - INFO, - DEBUG, - TRACE - } - - public static LoggerType LOGGER_TYPE= null; - - public static Logger getLogger(String name) { - if (LOGGER_TYPE == null) { - LOGGER_TYPE = getLoggerType(); - } - if (LOGGER_TYPE == LoggerType.COMMONS) { - try { - Object logger = getLogMethod.invoke(null, name); - return new Logger(logger); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - return new Logger(java.util.logging.Logger.getLogger(name)); - } - - /** - * This method should only be called once in a JVM run. - * @return - */ - private static LoggerType getLoggerType() { - LoggerType result = null; - //See if apache commons is available - try { - logFactoryClass = Class.forName("org.apache.commons.logging.LogFactory"); - getLogMethod = logFactoryClass.getMethod("getLog", new Class[]{String.class}); - logClass = Class.forName("org.apache.commons.logging.Log"); - return LoggerType.COMMONS; - } catch (Throwable e) { - } - return LoggerType.JAVA; - } - - public Logger(java.util.logging.Logger utilLogger) { - this.utilLogger = utilLogger; - } - - public Logger(Object commonsLogger) { - this.commonsLogger = commonsLogger; - } - - /** - * Returns whether this level is loggable. If there is - * a misconfiguration, this will always return false. - * @param level the EventBus Logger level - * @return whether this level is loggable. - */ - public boolean isLoggable(Level level) { - if (utilLogger != null) { - java.util.logging.Level javaLevel = getJavaLevelFor(level); - return javaLevel != null && utilLogger.isLoggable(javaLevel); - } else if (commonsLogger != null) { - switch (level) { - case ERROR: return (Boolean)callCommonsLogger("isErrorEnabled"); - case FATAL: return (Boolean)callCommonsLogger("isFatalEnabled"); - case WARN: return (Boolean)callCommonsLogger("isWarnEnabled"); - case INFO: return (Boolean)callCommonsLogger("isInfoEnabled"); - case DEBUG: return (Boolean)callCommonsLogger("isDebugEnabled"); - case TRACE: return (Boolean)callCommonsLogger("isTraceEnabled"); - } - } - return false; - } - - private java.util.logging.Level getJavaLevelFor(Level level) { - switch (level) { - case FATAL: return java.util.logging.Level.SEVERE; - case ERROR: return java.util.logging.Level.SEVERE; - case WARN: return java.util.logging.Level.WARNING; - case INFO: return java.util.logging.Level.INFO; - case DEBUG: return java.util.logging.Level.FINE; - case TRACE: return java.util.logging.Level.FINEST; - } - return null; - } - - public void debug(String message) { - log(Level.DEBUG, message); - } - - public void log(Level level, String message) { - log(level, message, null); - } - - public void log(Level level, String message, Throwable throwable) { - if (!isLoggable(level)) { - return; - } - if (utilLogger != null) { - java.util.logging.Level javaLevel = getJavaLevelFor(level); - if (throwable == null) { - utilLogger.log(javaLevel, message); - } else { - utilLogger.log(javaLevel, message, throwable); - } - } else if (commonsLogger != null) { - if (throwable == null) { - switch (level) { - case ERROR: callCommonsLogger("error", message); break; - case FATAL: callCommonsLogger("fatal", message); break; - case WARN: callCommonsLogger("warn", message); break; - case INFO: callCommonsLogger("info", message); break; - case DEBUG: callCommonsLogger("debug", message); break; - case TRACE: callCommonsLogger("trace", message); break; - } - } else { - switch (level) { - case ERROR: callCommonsLogger("error", message, throwable); break; - case FATAL: callCommonsLogger("fatal", message, throwable); break; - case WARN: callCommonsLogger("warn", message, throwable); break; - case INFO: callCommonsLogger("info", message, throwable); break; - case DEBUG: callCommonsLogger("debug", message, throwable); break; - case TRACE: callCommonsLogger("trace", message, throwable); break; - } - } - } - } - - private Object callCommonsLogger(String methodName) { - if (METHOD_CACHE_NO_PARAMS == null) { - METHOD_CACHE_NO_PARAMS = new HashMap(); - } - return callCommonsLogger(METHOD_CACHE_NO_PARAMS, methodName, CLASS_ARGS_EMPTY, EMPTY_ARGS); - } - - private Object callCommonsLogger(String methodName, String message) { - if (METHOD_CACHE_ONE_PARAM == null) { - METHOD_CACHE_ONE_PARAM = new HashMap(); - } - return callCommonsLogger(METHOD_CACHE_ONE_PARAM, methodName, CLASS_ARGS_ONE, new Object[]{message}); - } - - private Object callCommonsLogger(String methodName, String message, Throwable throwable) { - if (METHOD_CACHE_TWO_PARAMS == null) { - METHOD_CACHE_TWO_PARAMS = new HashMap(); - } - return callCommonsLogger(METHOD_CACHE_TWO_PARAMS, methodName, CLASS_ARGS_TWO, new Object[]{message, throwable}); - } - - private Object callCommonsLogger(Map cache, String methodName, Class[] classOfArgs, Object[] args) { - Method method = cache.get(methodName); - if (method == null) { - try { - method = logClass.getMethod(methodName, classOfArgs); - cache.put(methodName, method); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } - } - if (method == null) { - return null; - } - try { - return method.invoke(commonsLogger, args); - } catch (IllegalAccessException e) { - return null; - } catch (InvocationTargetException e) { - return null; - } - } + + private java.util.logging.Logger utilLogger; + private /*Untyped to avoid java.lang.NoClassDefFoundError + org.apache.commons.logging.Log*/ Object commonsLogger; + private Map METHOD_CACHE_NO_PARAMS; + private Map METHOD_CACHE_ONE_PARAM; + private Map METHOD_CACHE_TWO_PARAMS; + private static Class logFactoryClass; + private static Class logClass; + private static Method getLogMethod; + private static final Object[] EMPTY_ARGS = new Object[0]; + private static final Class[] CLASS_ARGS_EMPTY = new Class[0]; + private static final Class[] CLASS_ARGS_ONE = new Class[] { Object.class }; + private static final Class[] CLASS_ARGS_TWO = new Class[] { Object.class, + Throwable.class }; + + /** Allows switching between Java and Commons logging. */ + public static enum LoggerType { + /*java.util.logging*/ + JAVA, + /*org.apache.commons.logging*/ + COMMONS + } + + /** Standardized logging levels. */ + public static enum Level { + FATAL, ERROR, WARN, INFO, DEBUG, TRACE + } + + public static LoggerType LOGGER_TYPE = null; + + public static Logger getLogger(String name) { + if (LOGGER_TYPE == null) { + LOGGER_TYPE = getLoggerType(); + } + if (LOGGER_TYPE == LoggerType.COMMONS) { + try { + Object logger = getLogMethod.invoke(null, name); + return new Logger(logger); + } + catch (IllegalAccessException e) { + e.printStackTrace(); + } + catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + return new Logger(java.util.logging.Logger.getLogger(name)); + } + + /** + * This method should only be called once in a JVM run. + * + * @return + */ + private static LoggerType getLoggerType() { + LoggerType result = null; + // See if apache commons is available + try { + logFactoryClass = Class.forName("org.apache.commons.logging.LogFactory"); + getLogMethod = logFactoryClass.getMethod("getLog", new Class[] { + String.class }); + logClass = Class.forName("org.apache.commons.logging.Log"); + return LoggerType.COMMONS; + } + catch (Throwable e) {} + return LoggerType.JAVA; + } + + public Logger(java.util.logging.Logger utilLogger) { + this.utilLogger = utilLogger; + } + + public Logger(Object commonsLogger) { + this.commonsLogger = commonsLogger; + } + + /** + * Returns whether this level is loggable. If there is a misconfiguration, + * this will always return false. + * + * @param level the EventBus Logger level + * @return whether this level is loggable. + */ + public boolean isLoggable(Level level) { + if (utilLogger != null) { + java.util.logging.Level javaLevel = getJavaLevelFor(level); + return javaLevel != null && utilLogger.isLoggable(javaLevel); + } + else if (commonsLogger != null) { + switch (level) { + case ERROR: + return (Boolean) callCommonsLogger("isErrorEnabled"); + case FATAL: + return (Boolean) callCommonsLogger("isFatalEnabled"); + case WARN: + return (Boolean) callCommonsLogger("isWarnEnabled"); + case INFO: + return (Boolean) callCommonsLogger("isInfoEnabled"); + case DEBUG: + return (Boolean) callCommonsLogger("isDebugEnabled"); + case TRACE: + return (Boolean) callCommonsLogger("isTraceEnabled"); + } + } + return false; + } + + private java.util.logging.Level getJavaLevelFor(Level level) { + switch (level) { + case FATAL: + return java.util.logging.Level.SEVERE; + case ERROR: + return java.util.logging.Level.SEVERE; + case WARN: + return java.util.logging.Level.WARNING; + case INFO: + return java.util.logging.Level.INFO; + case DEBUG: + return java.util.logging.Level.FINE; + case TRACE: + return java.util.logging.Level.FINEST; + } + return null; + } + + public void debug(String message) { + log(Level.DEBUG, message); + } + + public void log(Level level, String message) { + log(level, message, null); + } + + public void log(Level level, String message, Throwable throwable) { + if (!isLoggable(level)) { + return; + } + if (utilLogger != null) { + java.util.logging.Level javaLevel = getJavaLevelFor(level); + if (throwable == null) { + utilLogger.log(javaLevel, message); + } + else { + utilLogger.log(javaLevel, message, throwable); + } + } + else if (commonsLogger != null) { + if (throwable == null) { + switch (level) { + case ERROR: + callCommonsLogger("error", message); + break; + case FATAL: + callCommonsLogger("fatal", message); + break; + case WARN: + callCommonsLogger("warn", message); + break; + case INFO: + callCommonsLogger("info", message); + break; + case DEBUG: + callCommonsLogger("debug", message); + break; + case TRACE: + callCommonsLogger("trace", message); + break; + } + } + else { + switch (level) { + case ERROR: + callCommonsLogger("error", message, throwable); + break; + case FATAL: + callCommonsLogger("fatal", message, throwable); + break; + case WARN: + callCommonsLogger("warn", message, throwable); + break; + case INFO: + callCommonsLogger("info", message, throwable); + break; + case DEBUG: + callCommonsLogger("debug", message, throwable); + break; + case TRACE: + callCommonsLogger("trace", message, throwable); + break; + } + } + } + } + + private Object callCommonsLogger(String methodName) { + if (METHOD_CACHE_NO_PARAMS == null) { + METHOD_CACHE_NO_PARAMS = new HashMap(); + } + return callCommonsLogger(METHOD_CACHE_NO_PARAMS, methodName, + CLASS_ARGS_EMPTY, EMPTY_ARGS); + } + + private Object callCommonsLogger(String methodName, String message) { + if (METHOD_CACHE_ONE_PARAM == null) { + METHOD_CACHE_ONE_PARAM = new HashMap(); + } + return callCommonsLogger(METHOD_CACHE_ONE_PARAM, methodName, CLASS_ARGS_ONE, + new Object[] { message }); + } + + private Object callCommonsLogger(String methodName, String message, + Throwable throwable) + { + if (METHOD_CACHE_TWO_PARAMS == null) { + METHOD_CACHE_TWO_PARAMS = new HashMap(); + } + return callCommonsLogger(METHOD_CACHE_TWO_PARAMS, methodName, + CLASS_ARGS_TWO, new Object[] { message, throwable }); + } + + private Object callCommonsLogger(Map cache, String methodName, + Class[] classOfArgs, Object[] args) + { + Method method = cache.get(methodName); + if (method == null) { + try { + method = logClass.getMethod(methodName, classOfArgs); + cache.put(methodName, method); + } + catch (NoSuchMethodException e) { + e.printStackTrace(); + } + } + if (method == null) { + return null; + } + try { + return method.invoke(commonsLogger, args); + } + catch (IllegalAccessException e) { + return null; + } + catch (InvocationTargetException e) { + return null; + } + } } diff --git a/src/main/java/org/scijava/event/bushe/Prioritized.java b/src/main/java/org/scijava/event/bushe/Prioritized.java index 7a3187055..cf3663b7d 100644 --- a/src/main/java/org/scijava/event/bushe/Prioritized.java +++ b/src/main/java/org/scijava/event/bushe/Prioritized.java @@ -1,14 +1,19 @@ + package org.scijava.event.bushe; /** - * Subscribers can implement this interface in order to affect the order in which they are called. + * Subscribers can implement this interface in order to affect the order in + * which they are called. *

    - * Subscribers that do not implement this interface are called on a FIFO basis, as are subscribers that implement this - * interface and return 0. If the priority returned from this interface is negative, then this subscriber will be - * called before non-Prioritized subscribers, the more negative, the earlier it is called. If the priority returned - * from this interface is positive, then this subscriber will be called after non-Prioritized subscribers, the more + * Subscribers that do not implement this interface are called on a FIFO basis, + * as are subscribers that implement this interface and return 0. If the + * priority returned from this interface is negative, then this subscriber will + * be called before non-Prioritized subscribers, the more negative, the earlier + * it is called. If the priority returned from this interface is positive, then + * this subscriber will be called after non-Prioritized subscribers, the more * positive, the later it is called. */ interface Prioritized { - int getPriority(); + + int getPriority(); } diff --git a/src/main/java/org/scijava/event/bushe/ProxySubscriber.java b/src/main/java/org/scijava/event/bushe/ProxySubscriber.java index 04ac3ce0a..9f6395d73 100644 --- a/src/main/java/org/scijava/event/bushe/ProxySubscriber.java +++ b/src/main/java/org/scijava/event/bushe/ProxySubscriber.java @@ -13,31 +13,35 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.scijava.event.bushe; /** - * An interface that can be implemented when proxies are used for subscription, not needed in normal usage. When an - * unsubscribe method is called on an EventService, the EventService is required to check if any of subscribed objects - * are ProxySubscribers and if the object to be unsubscribed is the ProxySubscriber's proxiedSubscriber. If so, the - * EventService proxy is unsubscribed and the ProxySubscriber's proxyUnsubscribed() method is called to allow the proxy - * to perform any cleanup if necessary. ProxySubscribers should set their references to their proxied objects to null - * for strong subscriptions to allow garbage collection. + * An interface that can be implemented when proxies are used for subscription, + * not needed in normal usage. When an unsubscribe method is called on an + * EventService, the EventService is required to check if any of subscribed + * objects are ProxySubscribers and if the object to be unsubscribed is the + * ProxySubscriber's proxiedSubscriber. If so, the EventService proxy is + * unsubscribed and the ProxySubscriber's proxyUnsubscribed() method is called + * to allow the proxy to perform any cleanup if necessary. ProxySubscribers + * should set their references to their proxied objects to null for strong + * subscriptions to allow garbage collection. * * @author Michael Bushe */ interface ProxySubscriber { - /** @return the object this proxy is subscribed on behalf of */ - public Object getProxiedSubscriber(); + /** @return the object this proxy is subscribed on behalf of */ + public Object getProxiedSubscriber(); - /** - * Called by EventServices to inform the proxy that it is unsubscribed. The ProxySubscriber should null the - * reference to it's proxied subscriber - */ - public void proxyUnsubscribed(); + /** + * Called by EventServices to inform the proxy that it is unsubscribed. The + * ProxySubscriber should null the reference to it's proxied subscriber + */ + public void proxyUnsubscribed(); - /** - * @return the reference strength from this proxy to the proxied subscriber - */ - public ReferenceStrength getReferenceStrength(); + /** + * @return the reference strength from this proxy to the proxied subscriber + */ + public ReferenceStrength getReferenceStrength(); } diff --git a/src/main/java/org/scijava/event/bushe/PublicationStatus.java b/src/main/java/org/scijava/event/bushe/PublicationStatus.java index 84c0090d0..1c6951354 100644 --- a/src/main/java/org/scijava/event/bushe/PublicationStatus.java +++ b/src/main/java/org/scijava/event/bushe/PublicationStatus.java @@ -1,30 +1,39 @@ + package org.scijava.event.bushe; /** - * The status of an event as it makes its way from publication through processing by subscribers. + * The status of an event as it makes its way from publication through + * processing by subscribers. *

    - * EventServices are required to stamp any event object or payload that implements the PublicationStatusTracker - * with the corresponding PublicationStatus as the event object is processed. The EventService is not + * EventServices are required to stamp any event object or payload that + * implements the PublicationStatusTracker with the corresponding + * PublicationStatus as the event object is processed. The EventService is not * required to set the Unpublished state. */ enum PublicationStatus { - /** Recommended default.*/ - Unpublished, - /** Set directly after publication on an EventService.*/ - Initiated, - /** End status for events that are vetoed and never sent to subscribers.*/ - Vetoed, - /** State set after veto test is passed before the event is send to any subscribers.*/ - Queued, - /** Set while the event is sent to it's subscribers. EventService implementations - * such as the ThreadSafeEventService and the SwingEventService will transition from Queued to - * Publishing immediately. Others implementations that call subscribers on threads different - * from veto subscribers are free to leave an event in the Queued state and wait until - * the event is passed to the thread(s) that subscribers are called on to set the - * Publishing state */ - Publishing, - /** - * Called when all subscribers have finished handling the event publication. - */ - Completed + /** Recommended default. */ + Unpublished, + /** Set directly after publication on an EventService. */ + Initiated, + /** End status for events that are vetoed and never sent to subscribers. */ + Vetoed, + /** + * State set after veto test is passed before the event is send to any + * subscribers. + */ + Queued, + /** + * Set while the event is sent to it's subscribers. EventService + * implementations such as the ThreadSafeEventService and the + * SwingEventService will transition from Queued to Publishing immediately. + * Others implementations that call subscribers on threads different from + * veto subscribers are free to leave an event in the Queued state and wait + * until the event is passed to the thread(s) that subscribers are called on + * to set the Publishing state + */ + Publishing, + /** + * Called when all subscribers have finished handling the event publication. + */ + Completed } diff --git a/src/main/java/org/scijava/event/bushe/PublicationStatusTracker.java b/src/main/java/org/scijava/event/bushe/PublicationStatusTracker.java index cc6a98595..a9417847c 100644 --- a/src/main/java/org/scijava/event/bushe/PublicationStatusTracker.java +++ b/src/main/java/org/scijava/event/bushe/PublicationStatusTracker.java @@ -1,24 +1,29 @@ + package org.scijava.event.bushe; /** - * An optional interface that can be implemented by Events objects or topic Payloads - * to enable the events' status to be stamped on the event by an event service. + * An optional interface that can be implemented by Events objects or topic + * Payloads to enable the events' status to be stamped on the event by an event + * service. *

    - * EventService implementations must call setEventStatus(status) on event objects and - * payloads that implement this interface. + * EventService implementations must call setEventStatus(status) on event + * objects and payloads that implement this interface. */ interface PublicationStatusTracker { - /** - * Implementations of this method must be made thread safe. - * @return last value set by setPublicationStatus(), or - * {@link PublicationStatus#Unpublished} if setPublicationStatus was never called. - */ - public PublicationStatus getPublicationStatus(); + /** + * Implementations of this method must be made thread safe. + * + * @return last value set by setPublicationStatus(), or + * {@link PublicationStatus#Unpublished} if setPublicationStatus was + * never called. + */ + public PublicationStatus getPublicationStatus(); - /** - * Implementations of this method must be made thread safe. - * @param status the status of the event during it's current publication - */ - public void setPublicationStatus(PublicationStatus status); + /** + * Implementations of this method must be made thread safe. + * + * @param status the status of the event during it's current publication + */ + public void setPublicationStatus(PublicationStatus status); } diff --git a/src/main/java/org/scijava/event/bushe/ReferenceStrength.java b/src/main/java/org/scijava/event/bushe/ReferenceStrength.java index 15e7a7eb5..57582c07a 100644 --- a/src/main/java/org/scijava/event/bushe/ReferenceStrength.java +++ b/src/main/java/org/scijava/event/bushe/ReferenceStrength.java @@ -1,3 +1,4 @@ + package org.scijava.event.bushe; /** @@ -6,6 +7,5 @@ * @author Michael Bushe */ public enum ReferenceStrength { - WEAK, - STRONG + WEAK, STRONG } diff --git a/src/main/java/org/scijava/event/bushe/SwingException.java b/src/main/java/org/scijava/event/bushe/SwingException.java index f36fc36d6..4d93b0b0f 100644 --- a/src/main/java/org/scijava/event/bushe/SwingException.java +++ b/src/main/java/org/scijava/event/bushe/SwingException.java @@ -13,116 +13,136 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.scijava.event.bushe; import java.io.PrintStream; import java.io.PrintWriter; /** - * Aids in troubleshooting Swing application exceptions or any exception where the caller's stack may not be the - * exception stack (such as producer-consumer patterns that cross threads). + * Aids in troubleshooting Swing application exceptions or any exception where + * the caller's stack may not be the exception stack (such as producer-consumer + * patterns that cross threads). *

    - * Swing exceptions usually occur on the Swing Event Dispatch Thread, and often occur when code puts events on the EDT. - * This code is often in a non-EDT thread such as a thread that is receiving data from a server. If the non-EDT threads - * puts a call on the EDT and that EDT call causes and exception, the stack trace of the exception is lost, and it often - * difficult or impossible to determine where the non-EDT call came from. + * Swing exceptions usually occur on the Swing Event Dispatch Thread, and often + * occur when code puts events on the EDT. This code is often in a non-EDT + * thread such as a thread that is receiving data from a server. If the non-EDT + * threads puts a call on the EDT and that EDT call causes and exception, the + * stack trace of the exception is lost, and it often difficult or impossible to + * determine where the non-EDT call came from. *

    *

    - * This Exception class is used to handle exceptions that occur when events are posted on the Swing EDT or occur on - * another thread from the Swing EDT. It includes a "swing" call stack to record from where the event occurred, and - * overrides so that the exception and the swing calling stack print nicely to logs. + * This Exception class is used to handle exceptions that occur when events are + * posted on the Swing EDT or occur on another thread from the Swing EDT. It + * includes a "swing" call stack to record from where the event occurred, and + * overrides so that the exception and the swing calling stack print nicely to + * logs. *

    *

    - * The swing calling stack is different from the cause of the exception since it is gathered before the exception occurs - * in a different stack from the cause and used after the exception in a new thread occurs. + * The swing calling stack is different from the cause of the exception since it + * is gathered before the exception occurs in a different stack from the cause + * and used after the exception in a new thread occurs. *

    * * @author Michael Bushe michael@bushe.com */ class SwingException extends Exception { - protected StackTraceElement[] callingStackTrace; - /** Default constructor */ - public SwingException() { - super(); - } + protected StackTraceElement[] callingStackTrace; - /** - * Constructor for compatibility with Exception. Use ClientException(String, Throwable, StackTraceElement[]) - * instead - */ - public SwingException(String message) { - super(message); - } + /** Default constructor */ + public SwingException() { + super(); + } - /** Constructor for compatibility with Exception Use ClientException(String, Throwable, StackTraceElement[]) instead */ - public SwingException(Throwable cause) { - super(cause); - } + /** + * Constructor for compatibility with Exception. Use ClientException(String, + * Throwable, StackTraceElement[]) instead + */ + public SwingException(String message) { + super(message); + } - /** Constructor for compatibility with Exception Use ClientException(String, Throwable, StackTraceElement[]) instead */ - public SwingException(String message, Throwable cause) { - super(message, cause); - } + /** + * Constructor for compatibility with Exception Use ClientException(String, + * Throwable, StackTraceElement[]) instead + */ + public SwingException(Throwable cause) { + super(cause); + } - /** - * Preferred constructor. - * - * @param message The message of exception - * @param cause The cause of the exception in the same call stack - * @param callingStack the stack trace that the client used to call the exception to occur. - */ - public SwingException(String message, Throwable cause, StackTraceElement[] callingStack) { - super(message, cause); - setCallingStack(callingStack); - } + /** + * Constructor for compatibility with Exception Use ClientException(String, + * Throwable, StackTraceElement[]) instead + */ + public SwingException(String message, Throwable cause) { + super(message, cause); + } - /** - * Swing exceptions often have two stacks - one thread causes the posting of an action on another thread - usually - * the Swing EDT thread. The other is the stack of the actual thread the exception occurred on, the exception occurs - * after the post. - * - * @param swingCallingStack the stack trace that the client used to cause the exception to occur. - */ - public void setCallingStack(StackTraceElement[] swingCallingStack) { - this.callingStackTrace = swingCallingStack; - } + /** + * Preferred constructor. + * + * @param message The message of exception + * @param cause The cause of the exception in the same call stack + * @param callingStack the stack trace that the client used to call the + * exception to occur. + */ + public SwingException(String message, Throwable cause, + StackTraceElement[] callingStack) + { + super(message, cause); + setCallingStack(callingStack); + } - /** - * Client exceptions often have two stacks - one thread causes the posting of an action on another thread - usually - * the Swing EDT thread. The other is the stack of the actual thread the exception occurred on. - * - * @return the stack trace that the client used to cause the exception to occur. - */ - public StackTraceElement[] getCallingStack() { - return callingStackTrace; - } + /** + * Swing exceptions often have two stacks - one thread causes the posting of + * an action on another thread - usually the Swing EDT thread. The other is + * the stack of the actual thread the exception occurred on, the exception + * occurs after the post. + * + * @param swingCallingStack the stack trace that the client used to cause the + * exception to occur. + */ + public void setCallingStack(StackTraceElement[] swingCallingStack) { + this.callingStackTrace = swingCallingStack; + } - /** - * Calls printWriter(ps, true) - * - * @param ps the print stream - */ - public void printStackTrace(PrintStream ps) { - PrintWriter pw = new PrintWriter(ps, true); - printStackTrace(pw); - } + /** + * Client exceptions often have two stacks - one thread causes the posting of + * an action on another thread - usually the Swing EDT thread. The other is + * the stack of the actual thread the exception occurred on. + * + * @return the stack trace that the client used to cause the exception to + * occur. + */ + public StackTraceElement[] getCallingStack() { + return callingStackTrace; + } - /** - * Prints the calling stack and the exception stack trace. - * - * @param pw - */ - public void printStackTrace(PrintWriter pw) { - pw.println(this); - if (callingStackTrace != null) { - pw.println("Calling stack:"); - for (int i = 0; i < callingStackTrace.length; i++) { - pw.println("\tat " + callingStackTrace[i]); - } - pw.println("Stack after call:"); - } - super.printStackTrace(pw); - } -} + /** + * Calls printWriter(ps, true) + * + * @param ps the print stream + */ + public void printStackTrace(PrintStream ps) { + PrintWriter pw = new PrintWriter(ps, true); + printStackTrace(pw); + } + /** + * Prints the calling stack and the exception stack trace. + * + * @param pw + */ + public void printStackTrace(PrintWriter pw) { + pw.println(this); + if (callingStackTrace != null) { + pw.println("Calling stack:"); + for (int i = 0; i < callingStackTrace.length; i++) { + pw.println("\tat " + callingStackTrace[i]); + } + pw.println("Stack after call:"); + } + super.printStackTrace(pw); + } +} diff --git a/src/main/java/org/scijava/event/bushe/ThreadSafeEventService.java b/src/main/java/org/scijava/event/bushe/ThreadSafeEventService.java index 920d0add4..46a2c3d43 100644 --- a/src/main/java/org/scijava/event/bushe/ThreadSafeEventService.java +++ b/src/main/java/org/scijava/event/bushe/ThreadSafeEventService.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.scijava.event.bushe; import java.lang.ref.WeakReference; @@ -37,2144 +38,2480 @@ /** * A thread-safe EventService implementation. - *

    Multithreading

    + *

    Multithreading

    *

    - * This implementation is not Swing thread-safe. If publication occurs on a thread other than the Swing - * EventDispatchThread, subscribers will receive the event on the calling thread, and not the EDT. Swing components - * should use the SwingEventService instead, which is the implementation used by the EventBus. + * This implementation is not Swing thread-safe. If publication occurs on + * a thread other than the Swing EventDispatchThread, subscribers will receive + * the event on the calling thread, and not the EDT. Swing components should use + * the SwingEventService instead, which is the implementation used by the + * EventBus. *

    *

    - * Two threads may be accessing the ThreadSafeEventService at the same time, one unsubscribing a - * listener for topic "A" and the other publishing on topic "A". If the unsubscribing thread gets the lock first, - * then it is unsubscribed, end of story. If the publisher gets the lock first, then a snapshot copy of the current - * subscribers is made during the publication, the lock is released and the subscribers are called. Between the time - * the lock is released and the time that the listener is called, the unsubscribing thread can unsubscribe, resulting - * in an unsubscribed object receiving notification of the event after it was unsubscribed (but just once). + * Two threads may be accessing the ThreadSafeEventService at the same time, one + * unsubscribing a listener for topic "A" and the other publishing on topic "A". + * If the unsubscribing thread gets the lock first, then it is unsubscribed, end + * of story. If the publisher gets the lock first, then a snapshot copy of the + * current subscribers is made during the publication, the lock is released and + * the subscribers are called. Between the time the lock is released and the + * time that the listener is called, the unsubscribing thread can unsubscribe, + * resulting in an unsubscribed object receiving notification of the event after + * it was unsubscribed (but just once). *

    *

    - * On event publication, subscribers are called in the order in which they subscribed. + * On event publication, subscribers are called in the order in which they + * subscribed. *

    *

    - * Events and/or topic data can be cached, but are not by default. To cache events or topic data, call - * {@link #setDefaultCacheSizePerClassOrTopic(int)}, {@link #setCacheSizeForEventClass(Class, int)}, or - * {@link #setCacheSizeForTopic(String, int)}, {@link #setCacheSizeForTopic(Pattern, int)}. Retrieve cached values - * with {@link #getLastEvent(Class)}, {@link #getLastTopicData(String)}, {@link #getCachedEvents(Class)}, or - * {@link #getCachedTopicData(String)}. Using caching while subscribing - * is most likely to make sense only if you subscribe and publish on the same thread (so caching is very useful for - * Swing applications since both happen on the EDT in a single-threaded manner). In multithreaded applications, you - * never know if your subscriber has handled an event while it was being subscribed (before the subscribe() method - * returned) that is newer or older than the retrieved cached value (taken before or after subscribe() respectively). + * Events and/or topic data can be cached, but are not by default. To cache + * events or topic data, call {@link #setDefaultCacheSizePerClassOrTopic(int)}, + * {@link #setCacheSizeForEventClass(Class, int)}, or + * {@link #setCacheSizeForTopic(String, int)}, + * {@link #setCacheSizeForTopic(Pattern, int)}. Retrieve cached values with + * {@link #getLastEvent(Class)}, {@link #getLastTopicData(String)}, + * {@link #getCachedEvents(Class)}, or {@link #getCachedTopicData(String)}. + * Using caching while subscribing is most likely to make sense only if you + * subscribe and publish on the same thread (so caching is very useful for Swing + * applications since both happen on the EDT in a single-threaded manner). In + * multithreaded applications, you never know if your subscriber has handled an + * event while it was being subscribed (before the subscribe() method returned) + * that is newer or older than the retrieved cached value (taken before or after + * subscribe() respectively). *

    - *

    Logging

    + *

    Logging

    *

    - * All logging goes through the {@link Logger}. The Logger is configurable and supports multiple logging systems. + * All logging goes through the {@link Logger}. The Logger is configurable and + * supports multiple logging systems. *

    *

    - * Exceptions are logged by default, override {@link #handleException(String,Object,String,Object,Throwable, - * StackTraceElement[],String)} to handleException exceptions in another way. Each call to a subscriber is wrapped in - * a try block to ensure one listener does not interfere with another. + * Exceptions are logged by default, override + * {@link #handleException(String,Object,String,Object,Throwable, StackTraceElement[],String)} + * to handleException exceptions in another way. Each call to a subscriber is + * wrapped in a try block to ensure one listener does not interfere with + * another. *

    - *

    Cleanup of Stale WeakReferences and Stale Annotation Proxies

    + *

    Cleanup of Stale WeakReferences and Stale Annotation Proxies

    *

    - * The EventService may need to clean up stale WeakReferences and ProxySubscribers created for EventBus annotations. (Aside: EventBus - * Annotations are handled by the creation of proxies to the annotated objects. Since the annotations create weak references - * by default, annotation proxies must held strongly by the EventService, otherwise the proxy is garbage collected.) When - * a WeakReference's referent or an ProxySubscriber's proxiedObject (the annotated object) is claimed by the garbage collector, - * the EventService still holds onto the actual WeakReference or ProxySubscriber subscribed to the EventService (which are pretty tiny). + * The EventService may need to clean up stale WeakReferences and + * ProxySubscribers created for EventBus annotations. (Aside: EventBus + * Annotations are handled by the creation of proxies to the annotated objects. + * Since the annotations create weak references by default, annotation proxies + * must held strongly by the EventService, otherwise the proxy is garbage + * collected.) When a WeakReference's referent or an ProxySubscriber's + * proxiedObject (the annotated object) is claimed by the garbage collector, the + * EventService still holds onto the actual WeakReference or ProxySubscriber + * subscribed to the EventService (which are pretty tiny). *

    *

    - * There are two ways that these stale WeakReferences and ProxySubscribers are cleaned up. + * There are two ways that these stale WeakReferences and ProxySubscribers are + * cleaned up. *

    *
      - *
    1. On every publish, subscribe and unsubscribe, every subscriber and veto subscriber to a class or topic is checked to see - * if it is a stale WeakReference or a stale ProxySubscriber (one whose getProxySubscriber() returns null). If the subscriber - * is stale, it is unsubscribed from the EventService immediately. If it is a ProxySubscriber, it's proxyUnsubscribed() - * method is called after it is unsubscribed. (This isn't as expensive as it sounds, since checks to avoid double subscription is + *
    2. On every publish, subscribe and unsubscribe, every subscriber and veto + * subscriber to a class or topic is checked to see if it is a stale + * WeakReference or a stale ProxySubscriber (one whose getProxySubscriber() + * returns null). If the subscriber is stale, it is unsubscribed from the + * EventService immediately. If it is a ProxySubscriber, it's + * proxyUnsubscribed() method is called after it is unsubscribed. (This isn't as + * expensive as it sounds, since checks to avoid double subscription is * necessary anyway). - *
    3. Another cleanup thread may get started to clean up remaining stale subscribers. This cleanup thread only comes into - * play for subscribers to topic or classes that haven't been used (published/subscribed/unsibscribed to). A detailed description - * of the cleanup thread follows. + *
    4. Another cleanup thread may get started to clean up remaining stale + * subscribers. This cleanup thread only comes into play for subscribers to + * topic or classes that haven't been used (published/subscribed/unsibscribed + * to). A detailed description of the cleanup thread follows. *
    *

    The Cleanup Thread

    *

    - * If a topic or class is never published to again, WeakReferences and ProxySubscribers can be left behind if they - * are not cleaned up. To prevent loitering stale subscribers, the ThreadSafeEventService may periodically run through - * all the EventSubscribers and VetoSubscribers for all topics and classes and clean up stale proxies. Proxies for - * Annotations that have a ReferenceStrength.STRONG are never cleaned up in normal usage. (By specifying - * ReferenceStrength.STRONG, the programmer is buying into unsubscribing annotated objects themselves. There is - * one caveat: If getProxiedSubscriber() returns null, even for a ProxySubscriber with a STRONG reference strength, that proxy - * is cleaned up as it is assumed it is stale or just wrong. This would not occur normally in EventBus usage, but only - * if someone is implementing their own custom ProxySubscriber and/or AnnotationProcessor.) + * If a topic or class is never published to again, WeakReferences and + * ProxySubscribers can be left behind if they are not cleaned up. To prevent + * loitering stale subscribers, the ThreadSafeEventService may periodically run + * through all the EventSubscribers and VetoSubscribers for all topics and + * classes and clean up stale proxies. Proxies for Annotations that have a + * ReferenceStrength.STRONG are never cleaned up in normal usage. (By specifying + * ReferenceStrength.STRONG, the programmer is buying into unsubscribing + * annotated objects themselves. There is one caveat: If getProxiedSubscriber() + * returns null, even for a ProxySubscriber with a STRONG reference strength, + * that proxy is cleaned up as it is assumed it is stale or just wrong. This + * would not occur normally in EventBus usage, but only if someone is + * implementing their own custom ProxySubscriber and/or AnnotationProcessor.) *

    *

    - * Cleanup is pretty rare in general. Not only are stale subscribers cleaned up with regular usage, stale - * subscribers on abandoned topics and classes do not take up a lot of memory, hence, they are allowed to build up to a certain degree. - * Cleanup does not occur until the number of WeakReferences and SubscriptionsProxy's with WeakReference strength - * subscribed to an EventService for all the EventService's subscriptions in total exceed the cleanupStartThreshhold, - * which is set to CLEANUP_START_THRESHOLD_DEFAULT (500) by default. The default is overridable in the constructor - * or via #setCleanupStartThreshhold(Integer). If set to null, cleanup will never start. + * Cleanup is pretty rare in general. Not only are stale subscribers cleaned up + * with regular usage, stale subscribers on abandoned topics and classes do not + * take up a lot of memory, hence, they are allowed to build up to a certain + * degree. Cleanup does not occur until the number of WeakReferences and + * SubscriptionsProxy's with WeakReference strength subscribed to an + * EventService for all the EventService's subscriptions in total exceed the + * cleanupStartThreshhold, which is set to + * CLEANUP_START_THRESHOLD_DEFAULT (500) by default. The default is + * overridable in the constructor or via #setCleanupStartThreshhold(Integer). If + * set to null, cleanup will never start. *

    *

    - * Once the cleanup start threshold is exceeded, a java.util.Timer is started to clean up stale subscribers periodically - * in another thread. The timer will fire every cleanupPeriodMS milliseconds, which is set to the - * CLEANUP_PERIOD_MS_DEFAULT (20 minutes) by default. The default is overridable in the constructor or - * via #setCleanupPeriodMS(Integer). If set to null, cleanup will not start. This is implemented with a java.util.Timer, - * so Timer's warnings apply - setting this too low will cause cleanups to bunch up and hog the cleanup thread. + * Once the cleanup start threshold is exceeded, a java.util.Timer is + * started to clean up stale subscribers periodically in another thread. The + * timer will fire every cleanupPeriodMS milliseconds, which is set to + * the CLEANUP_PERIOD_MS_DEFAULT (20 minutes) by default. The default + * is overridable in the constructor or via #setCleanupPeriodMS(Integer). If set + * to null, cleanup will not start. This is implemented with a + * java.util.Timer, so Timer's warnings apply - setting this too low + * will cause cleanups to bunch up and hog the cleanup thread. *

    *

    - * After a cleanup cycle completes, if the number of stale subscribers falls at or below the cleanupStopThreshhold - * cleanup stops until the cleanupStartThreshhold is exceeded again. The cleanupStopThreshhold is set - * to CLEANUP_STOP_THRESHOLD_DEFAULT (100) by default. The default is overridable in the constructor or via - * #setCleanupStopThreshhold(Integer). If set to null or 0, cleanup will not stop if it is ever started. + * After a cleanup cycle completes, if the number of stale subscribers falls at + * or below the cleanupStopThreshhold cleanup stops until the + * cleanupStartThreshhold is exceeded again. The + * cleanupStopThreshhold is set to + * CLEANUP_STOP_THRESHOLD_DEFAULT (100) by default. The default is + * overridable in the constructor or via #setCleanupStopThreshhold(Integer). If + * set to null or 0, cleanup will not stop if it is ever started. *

    *

    - * All cleanup parameters are tunable "live" and checked after each subscription and after each cleanup cycle. - * To make cleanup never run, set cleanupStartThreshhold to Integer.MAX_VALUE and cleanupPeriodMS to null. - * To get cleanup to run continuously, set set cleanupStartThreshhold to 0 and cleanupPeriodMS to some reasonable value, - * perhaps 1000 (1 second) or so (not recommended, cleanup is conducted with regular usage and the cleanup thread is - * rarely created or invoked). + * All cleanup parameters are tunable "live" and checked after each subscription + * and after each cleanup cycle. To make cleanup never run, set + * cleanupStartThreshhold to Integer.MAX_VALUE and cleanupPeriodMS to null. To + * get cleanup to run continuously, set set cleanupStartThreshhold to 0 and + * cleanupPeriodMS to some reasonable value, perhaps 1000 (1 second) or so (not + * recommended, cleanup is conducted with regular usage and the cleanup thread + * is rarely created or invoked). *

    *

    - * Cleanup is not run in a daemon thread, and thus will not stop the JVM from exiting. + * Cleanup is not run in a daemon thread, and thus will not stop the JVM from + * exiting. *

    - * + * * @author Michael Bushe michael@bushe.com * @see EventService for a complete description of the API */ -@SuppressWarnings({"unchecked"}) +@SuppressWarnings({ "unchecked" }) public class ThreadSafeEventService implements EventService { - public static final Integer CLEANUP_START_THRESHOLD_DEFAULT = 250; - public static final Integer CLEANUP_STOP_THRESHOLD_DEFAULT = 100; - public static final Long CLEANUP_PERIOD_MS_DEFAULT = 20L*60L*1000L; - - protected static final Logger LOG = Logger.getLogger(EventService.class.getName()); - - //Making these generic collections is a bad idea, it doesn't compile since it's better to have all the maps - //go through the same set of code to do all the real publish and subscribe work - private Map subscribersByEventType = new HashMap(); - private Map subscribersByEventClass = new HashMap(); - private Map subscribersByExactEventClass = new HashMap(); - private Map subscribersByTopic = new HashMap(); - private Map subscribersByTopicPattern = new HashMap(); - private Map vetoListenersByClass = new HashMap(); - private Map vetoListenersByExactClass = new HashMap(); - private Map vetoListenersByTopic = new HashMap(); - private Map vetoListenersByTopicPattern = new HashMap(); - private final Object listenerLock = new Object(); - private final Object cacheLock = new Object(); - private Long timeThresholdForEventTimingEventPublication; - private Map cacheByEvent = new HashMap(); - private int defaultCacheSizePerClassOrTopic = 0; - private Map cacheSizesForEventClass; - private Map rawCacheSizesForEventClass; - private boolean rawCacheSizesForEventClassChanged; - private Map cacheByTopic = new HashMap(); - private Map cacheSizesForTopic; - private Map rawCacheSizesForTopic; - private boolean rawCacheSizesForTopicChanged; - private Map rawCacheSizesForPattern; - private boolean rawCacheSizesForPatternChanged; - private Integer cleanupStartThreshhold; - private Integer cleanupStopThreshold; - private Long cleanupPeriodMS; - private int weakRefPlusProxySubscriberCount; - private Timer cleanupTimer; - private TimerTask cleanupTimerTask; - private static final Comparator PRIORITIZED_SUBSCRIBER_COMPARATOR = new PrioritizedSubscriberComparator(); - private boolean hasEverUsedPrioritized; - - /** Creates a ThreadSafeEventService that does not monitor timing of handlers. */ - public ThreadSafeEventService() { - this(null, null, null, null); - } - - /** - * Creates a ThreadSafeEventService while providing time monitoring options. - * - * @param timeThresholdForEventTimingEventPublication the longest time a subscriber should spend handling an event, - * The service will publish an SubscriberTimingEvent after listener processing if the time was exceeded. If null, no - * EventSubscriberTimingEvent will be issued. - */ - public ThreadSafeEventService(Long timeThresholdForEventTimingEventPublication) { - this(timeThresholdForEventTimingEventPublication, null, null, null); - } - - /** - * Creates a ThreadSafeEventService while providing proxy cleanup customization. - * Proxies are used with Annotations. - * - * @param cleanupStartThreshold see class javadoc. - * @param cleanupStopThreshold see class javadoc. - * @param cleanupPeriodMS see class javadoc. - */ - public ThreadSafeEventService(Integer cleanupStartThreshold, - Integer cleanupStopThreshold, Long cleanupPeriodMS) { - this(null, cleanupStartThreshold, cleanupStopThreshold, cleanupPeriodMS); - } - - /** - * Creates a ThreadSafeEventService while providing time monitoring options. - * - * @param timeThresholdForEventTimingEventPublication the longest time a subscriber should spend handling an event. - * The service will publish an SubscriberTimingEvent after listener processing if the time was exceeded. If null, no - * SubscriberTimingEvent will be issued. - * @param cleanupStartThreshold see class javadoc. - * @param cleanupStopThreshold see class javadoc. - * @param cleanupPeriodMS see class javadoc. - */ - public ThreadSafeEventService(Long timeThresholdForEventTimingEventPublication, - Integer cleanupStartThreshold, Integer cleanupStopThreshold, Long cleanupPeriodMS) { - this.timeThresholdForEventTimingEventPublication = timeThresholdForEventTimingEventPublication; - if (cleanupStartThreshold == null) { - this.cleanupStartThreshhold = CLEANUP_START_THRESHOLD_DEFAULT; - } else { - this.cleanupStartThreshhold = cleanupStartThreshold; - } - if (cleanupStopThreshold == null) { - this.cleanupStopThreshold = CLEANUP_STOP_THRESHOLD_DEFAULT; - } else { - this.cleanupStopThreshold = cleanupStopThreshold; - } - if (cleanupPeriodMS == null) { - this.cleanupPeriodMS = CLEANUP_PERIOD_MS_DEFAULT; - } else { - this.cleanupPeriodMS = cleanupPeriodMS; - } - } - - /** - * Gets the threshold above which cleanup starts. See the class javadoc on cleanup. - * @return the threshold at which cleanup starts - */ - public Integer getCleanupStartThreshhold() { - synchronized (listenerLock) { - return cleanupStartThreshhold; - } - } - - /** - * Sets the threshold above which cleanup starts. See the class javadoc on cleanup. - * @param cleanupStartThreshhold threshold at which cleanup starts - */ - public void setCleanupStartThreshhold(Integer cleanupStartThreshhold) { - synchronized (listenerLock) { - this.cleanupStartThreshhold = cleanupStartThreshhold; - } - } - - /** - * Gets the threshold below which cleanup stops. See the class javadoc on cleanup. - * @return threshold at which cleanup stops (it may start again) - */ - public Integer getCleanupStopThreshold() { - synchronized (listenerLock) { - return cleanupStopThreshold; - } - } - - /** - * Sets the threshold below which cleanup stops. See the class javadoc on cleanup. - * @param cleanupStopThreshold threshold at which cleanup stops (it may start again). - */ - public void setCleanupStopThreshold(Integer cleanupStopThreshold) { - synchronized (listenerLock) { - this.cleanupStopThreshold = cleanupStopThreshold; - } - } - - /** - * Get the cleanup interval. See the class javadoc on cleanup. - * @return interval in milliseconds between cleanup runs. - */ - public Long getCleanupPeriodMS() { - synchronized (listenerLock) { - return cleanupPeriodMS; - } - } - - /** - * Sets the cleanup interval. See the class javadoc on cleanup. - * @param cleanupPeriodMS interval in milliseconds between cleanup runs. Passing null - * stops cleanup. - */ - public void setCleanupPeriodMS(Long cleanupPeriodMS) { - synchronized (listenerLock) { - this.cleanupPeriodMS = cleanupPeriodMS; - } - } - - /** @see EventService#subscribe(Class,EventSubscriber) */ - public boolean subscribe(Class cl, EventSubscriber eh) { - if (cl == null) { - throw new IllegalArgumentException("Event class must not be null"); - } - if (eh == null) { - throw new IllegalArgumentException("Event subscriber must not be null"); - } - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("Subscribing by class, class:" + cl + ", subscriber:" + eh); - } - return subscribe(cl, subscribersByEventClass, new WeakReference(eh)); - } - - /** @see EventService#subscribe(java.lang.reflect.Type, EventSubscriber) */ - public boolean subscribe(Type type, EventSubscriber eh) { - return subscribe(type, subscribersByEventType, new WeakReference(eh)); - } - - /** @see EventService#subscribeExactly(Class,EventSubscriber) */ - public boolean subscribeExactly(Class cl, EventSubscriber eh) { - if (cl == null) { - throw new IllegalArgumentException("Event class must not be null"); - } - if (eh == null) { - throw new IllegalArgumentException("Event subscriber must not be null"); - } - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("Subscribing by class, class:" + cl + ", subscriber:" + eh); - } - return subscribe(cl, subscribersByExactEventClass, new WeakReference(eh)); - } - - /** @see EventService#subscribe(String,EventTopicSubscriber) */ - public boolean subscribe(String topic, EventTopicSubscriber eh) { - if (topic == null) { - throw new IllegalArgumentException("Topic must not be null"); - } - if (eh == null) { - throw new IllegalArgumentException("Event topic subscriber must not be null"); - } - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("Subscribing by topic name, name:" + topic + ", subscriber:" + eh); - } - return subscribe(topic, subscribersByTopic, new WeakReference(eh)); - } - - /** @see EventService#subscribe(Pattern,EventTopicSubscriber) */ - public boolean subscribe(Pattern pat, EventTopicSubscriber eh) { - if (pat == null) { - throw new IllegalArgumentException("Pattern must not be null"); - } - if (eh == null) { - throw new IllegalArgumentException("Event subscriber must not be null"); - } - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("Subscribing by pattern, pattern:" + pat + ", subscriber:" + eh); - } - PatternWrapper patternWrapper = new PatternWrapper(pat); - return subscribe(patternWrapper, subscribersByTopicPattern, new WeakReference(eh)); - } - - /** @see EventService#subscribeStrongly(Class,EventSubscriber) */ - public boolean subscribeStrongly(Class cl, EventSubscriber eh) { - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("Subscribing weakly by class, class:" + cl + ", subscriber:" + eh); - } - if (eh == null) { - throw new IllegalArgumentException("Subscriber cannot be null."); - } - return subscribe(cl, subscribersByEventClass, eh); - } - - /** @see EventService#subscribeExactlyStrongly(Class,EventSubscriber) */ - public boolean subscribeExactlyStrongly(Class cl, EventSubscriber eh) { - if (cl == null) { - throw new IllegalArgumentException("Event class must not be null"); - } - if (eh == null) { - throw new IllegalArgumentException("Event subscriber must not be null"); - } - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("Subscribing by class, class:" + cl + ", subscriber:" + eh); - } - return subscribe(cl, subscribersByExactEventClass, eh); - } - - /** @see EventService#subscribeStrongly(String,EventTopicSubscriber) */ - public boolean subscribeStrongly(String name, EventTopicSubscriber eh) { - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("Subscribing weakly by topic name, name:" + name + ", subscriber:" + eh); - } - if (eh == null) { - throw new IllegalArgumentException("Subscriber cannot be null."); - } - return subscribe(name, subscribersByTopic, eh); - } - - /** @see EventService#subscribeStrongly(Pattern,EventTopicSubscriber) */ - public boolean subscribeStrongly(Pattern pat, EventTopicSubscriber eh) { - if (pat == null) { - throw new IllegalArgumentException("Pattern must not be null"); - } - if (eh == null) { - throw new IllegalArgumentException("Event subscriber must not be null"); - } - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("Subscribing by pattern, pattern:" + pat + ", subscriber:" + eh); - } - PatternWrapper patternWrapper = new PatternWrapper(pat); - return subscribe(patternWrapper, subscribersByTopicPattern, eh); - } - - - /** @see org.scijava.event.bushe.EventService#clearAllSubscribers() */ - public void clearAllSubscribers() { - synchronized (listenerLock) { - unsubscribeAllInMap(subscribersByEventType); - unsubscribeAllInMap(subscribersByEventClass); - unsubscribeAllInMap(subscribersByExactEventClass); - unsubscribeAllInMap(subscribersByTopic); - unsubscribeAllInMap(subscribersByTopicPattern); - unsubscribeAllInMap(vetoListenersByClass); - unsubscribeAllInMap(vetoListenersByExactClass); - unsubscribeAllInMap(vetoListenersByTopic); - unsubscribeAllInMap(vetoListenersByTopicPattern); - } - } - - private void unsubscribeAllInMap(Map subscriberMap) { - synchronized (listenerLock) { - Set subscriptionKeys = subscriberMap.keySet(); - for (Object key : subscriptionKeys) { - List subscribers = (List) subscriberMap.get(key); - while (!subscribers.isEmpty()) { - unsubscribe(key, subscriberMap, subscribers.get(0)); - } - } - } - } - - /** @see EventService#subscribeVetoListener(Class,VetoEventListener) */ - public boolean subscribeVetoListener(Class eventClass, VetoEventListener vetoListener) { - if (vetoListener == null) { - throw new IllegalArgumentException("VetoEventListener cannot be null."); - } - if (eventClass == null) { - throw new IllegalArgumentException("eventClass cannot be null."); - } - return subscribeVetoListener(eventClass, vetoListenersByClass, new WeakReference(vetoListener)); - } - - /** @see EventService#subscribeVetoListenerExactly(Class,VetoEventListener) */ - public boolean subscribeVetoListenerExactly(Class eventClass, VetoEventListener vetoListener) { - if (vetoListener == null) { - throw new IllegalArgumentException("VetoEventListener cannot be null."); - } - if (eventClass == null) { - throw new IllegalArgumentException("eventClass cannot be null."); - } - return subscribeVetoListener(eventClass, vetoListenersByExactClass, new WeakReference(vetoListener)); - } - - /** @see EventService#subscribeVetoListener(String,VetoTopicEventListener) */ - public boolean subscribeVetoListener(String topic, VetoTopicEventListener vetoListener) { - if (vetoListener == null) { - throw new IllegalArgumentException("VetoEventListener cannot be null."); - } - if (topic == null) { - throw new IllegalArgumentException("topic cannot be null."); - } - return subscribeVetoListener(topic, vetoListenersByTopic, new WeakReference(vetoListener)); - } - - /** @see EventService#subscribeVetoListener(Pattern,VetoTopicEventListener) */ - public boolean subscribeVetoListener(Pattern topicPattern, VetoTopicEventListener vetoListener) { - if (vetoListener == null) { - throw new IllegalArgumentException("VetoEventListener cannot be null."); - } - if (topicPattern == null) { - throw new IllegalArgumentException("topicPattern cannot be null."); - } - PatternWrapper patternWrapper = new PatternWrapper(topicPattern); - return subscribeVetoListener(patternWrapper, vetoListenersByTopicPattern, new WeakReference(vetoListener)); - } - - /** @see EventService#subscribeVetoListenerStrongly(Class,VetoEventListener) */ - public boolean subscribeVetoListenerStrongly(Class eventClass, VetoEventListener vetoListener) { - if (vetoListener == null) { - throw new IllegalArgumentException("VetoEventListener cannot be null."); - } - if (eventClass == null) { - throw new IllegalArgumentException("eventClass cannot be null."); - } - return subscribeVetoListener(eventClass, vetoListenersByClass, vetoListener); - } - - /** @see EventService#subscribeVetoListenerExactlyStrongly(Class,VetoEventListener) */ - public boolean subscribeVetoListenerExactlyStrongly(Class eventClass, VetoEventListener vetoListener) { - if (vetoListener == null) { - throw new IllegalArgumentException("VetoEventListener cannot be null."); - } - if (eventClass == null) { - throw new IllegalArgumentException("eventClass cannot be null."); - } - return subscribeVetoListener(eventClass, vetoListenersByExactClass, vetoListener); - } - - /** @see EventService#subscribeVetoListenerStrongly(String,VetoTopicEventListener) */ - public boolean subscribeVetoListenerStrongly(String topic, VetoTopicEventListener vetoListener) { - if (vetoListener == null) { - throw new IllegalArgumentException("VetoListener cannot be null."); - } - if (topic == null) { - throw new IllegalArgumentException("topic cannot be null."); - } - return subscribeVetoListener(topic, vetoListenersByTopic, vetoListener); - } - - /** @see EventService#subscribeVetoListenerStrongly(Pattern,VetoTopicEventListener) */ - public boolean subscribeVetoListenerStrongly(Pattern topicPattern, VetoTopicEventListener vetoListener) { - if (vetoListener == null) { - throw new IllegalArgumentException("VetoTopicEventListener cannot be null."); - } - if (topicPattern == null) { - throw new IllegalArgumentException("topicPattern cannot be null."); - } - PatternWrapper patternWrapper = new PatternWrapper(topicPattern); - return subscribeVetoListener(patternWrapper, vetoListenersByTopicPattern, vetoListener); - } - - /** - * All veto subscriptions methods call this method. Extending classes only have to override this method to subscribe - * all veto subscriptions. - * - * @param subscription the topic, Pattern, or event class to subscribe to - * @param vetoListenerMap the internal map of veto listeners to use (by topic of class) - * @param vetoListener the veto listener to subscribe, may be a VetoEventListener or a WeakReference to one - * - * @return boolean if the veto listener is subscribed (was not subscribed). - * - * @throws IllegalArgumentException if vl or o is null - */ - protected boolean subscribeVetoListener(final Object subscription, final Map vetoListenerMap, final Object vetoListener) { - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("subscribeVetoListener(" + subscription + "," + vetoListener + ")"); - } - if (vetoListener == null) { - throw new IllegalArgumentException("Can't subscribe null veto listener to " + subscription); - } - if (subscription == null) { - throw new IllegalArgumentException("Can't subscribe veto listener to null."); - } - return subscribe(subscription, vetoListenerMap, vetoListener); - } - - /** - * All subscribe methods call this method, including veto subscriptions. - * Extending classes only have to override this method to subscribe all - * subscriber subscriptions. - *

    - * Overriding this method is only for the adventurous. This basically gives you just enough rope to hang yourself. - *

    - * - * @param classTopicOrPatternWrapper the topic String, event Class, or PatternWrapper to subscribe to - * @param subscriberMap the internal map of subscribers to use (by topic or class) - * @param subscriber the EventSubscriber or EventTopicSubscriber to subscribe, or a WeakReference to either - * - * @return boolean if the subscriber is subscribed (was not subscribed). - * - * @throws IllegalArgumentException if subscriber or topicOrClass is null - */ - protected boolean subscribe(final Object classTopicOrPatternWrapper, final Map subscriberMap, final Object subscriber) { - if (classTopicOrPatternWrapper == null) { - throw new IllegalArgumentException("Can't subscribe to null."); - } - if (subscriber == null) { - throw new IllegalArgumentException("Can't subscribe null subscriber to " + classTopicOrPatternWrapper); - } - boolean alreadyExists = false; - - //Find the real subscriber underlying weak refs and proxies - Object realSubscriber = subscriber; - boolean isWeakRef = subscriber instanceof WeakReference; - if (isWeakRef) { - realSubscriber = ((WeakReference) subscriber).get(); - } - if (realSubscriber instanceof Prioritized) { - hasEverUsedPrioritized = true; - } - boolean isWeakProxySubscriber = false; - if (subscriber instanceof ProxySubscriber) { - ProxySubscriber proxySubscriber = (ProxySubscriber) subscriber; - if (proxySubscriber instanceof Prioritized) { - hasEverUsedPrioritized = true; - } - isWeakProxySubscriber = proxySubscriber.getReferenceStrength() == ReferenceStrength.WEAK; - if (isWeakProxySubscriber) { - realSubscriber = ((ProxySubscriber) subscriber).getProxiedSubscriber(); - } - } - if (isWeakRef && isWeakProxySubscriber) { - throw new IllegalArgumentException("ProxySubscribers should always be subscribed strongly."); - } - if (realSubscriber == null) { - return false;//already garbage collected? Weird. - } - synchronized (listenerLock) { - List currentSubscribers = (List) subscriberMap.get(classTopicOrPatternWrapper); - if (currentSubscribers == null) { - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("Creating new subscriber map for:" + classTopicOrPatternWrapper); - } - currentSubscribers = new ArrayList(); - subscriberMap.put(classTopicOrPatternWrapper, currentSubscribers); - } else { - //Double subscription check and stale subscriber cleanup - //Need to compare the underlying referents for WeakReferences and ProxySubscribers - //to make sure a weak ref and a hard ref aren't both subscribed - //to the same topic and object. - //Use the proxied subscriber for comparison if a ProxySubscribers is used - //Subscribing the same object by proxy and subscribing explicitly should - //not subscribe the same object twice - for (Iterator iterator = currentSubscribers.iterator(); iterator.hasNext();) { - Object currentSubscriber = iterator.next(); - Object realCurrentSubscriber = getRealSubscriberAndCleanStaleSubscriberIfNecessary(iterator, currentSubscriber); - if (realSubscriber.equals(realCurrentSubscriber)) { - //Already subscribed. - //Remove temporarily, to add to the end of the calling list - iterator.remove(); - alreadyExists = true; - } - } - } - currentSubscribers.add(subscriber); - if (isWeakProxySubscriber || isWeakRef) { - incWeakRefPlusProxySubscriberCount(); - } - return !alreadyExists; - } - } - - /** @see EventService#unsubscribe(Class,EventSubscriber) */ - public boolean unsubscribe(Class cl, EventSubscriber eh) { - return unsubscribe(cl, subscribersByEventClass, eh); - } - - /** @see EventService#unsubscribeExactly(Class,EventSubscriber) */ - public boolean unsubscribeExactly(Class cl, EventSubscriber eh) { - return unsubscribe(cl, subscribersByExactEventClass, eh); - } - - /** @see EventService#unsubscribe(String,EventTopicSubscriber) */ - public boolean unsubscribe(String name, EventTopicSubscriber eh) { - return unsubscribe(name, subscribersByTopic, eh); - } - - /** @see EventService#unsubscribe(String,EventTopicSubscriber) */ - public boolean unsubscribe(Pattern topicPattern, EventTopicSubscriber eh) { - PatternWrapper patternWrapper = new PatternWrapper(topicPattern); - return unsubscribe(patternWrapper, subscribersByTopicPattern, eh); - } - - /** @see EventService#unsubscribe(Class,Object) */ - public boolean unsubscribe(Class eventClass, Object subscribedByProxy) { - EventSubscriber subscriber = (EventSubscriber) getProxySubscriber(eventClass, subscribedByProxy); - if (subscriber == null) { - return false; - } else { - return unsubscribe(eventClass, subscriber); - } - } - - /** @see EventService#unsubscribeExactly(Class,Object) */ - public boolean unsubscribeExactly(Class eventClass, Object subscribedByProxy) { - EventSubscriber subscriber = (EventSubscriber) getProxySubscriber(eventClass, subscribedByProxy); - if (subscriber == null) { - return false; - } else { - return unsubscribeExactly(eventClass, subscriber); - } - } - - /** @see EventService#unsubscribe(String,Object) */ - public boolean unsubscribe(String topic, Object subscribedByProxy) { - EventTopicSubscriber subscriber = (EventTopicSubscriber) getProxySubscriber(topic, subscribedByProxy); - if (subscriber == null) { - return false; - } else { - return unsubscribe(topic, subscriber); - } - } - - /** @see EventService#unsubscribe(java.util.regex.Pattern,Object) */ - public boolean unsubscribe(Pattern pattern, Object subscribedByProxy) { - EventTopicSubscriber subscriber = (EventTopicSubscriber) getProxySubscriber(pattern, subscribedByProxy); - if (subscriber == null) { - return false; - } else { - return unsubscribe(pattern, subscriber); - } - } - - /** - * All event subscriber unsubscriptions call this method. Extending classes only have to override this method to - * subscribe all subscriber unsubscriptions. - * - * @param o the topic or event class to unsubscribe from - * @param subscriberMap the map of subscribers to use (by topic of class) - * @param subscriber the subscriber to unsubscribe, either an EventSubscriber or an EventTopicSubscriber, or a WeakReference - * to either - * - * @return boolean if the subscriber is unsubscribed (was subscribed). - */ - protected boolean unsubscribe(Object o, Map subscriberMap, Object subscriber) { - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("unsubscribe(" + o + "," + subscriber + ")"); - } - if (o == null) { - throw new IllegalArgumentException("Can't unsubscribe to null."); - } - if (subscriber == null) { - throw new IllegalArgumentException("Can't unsubscribe null subscriber to " + o); - } - synchronized (listenerLock) { - return removeFromSetResolveWeakReferences(subscriberMap, o, subscriber); - } - } - - /** @see EventService#unsubscribeVeto(Class,Object) */ - public boolean unsubscribeVeto(Class eventClass, Object subscribedByProxy) { - VetoEventListener subscriber = (VetoEventListener) getVetoProxySubscriber(eventClass, subscribedByProxy); - if (subscriber == null) { - return false; - } else { - return unsubscribeVetoListener(eventClass, subscriber); - } - } - - /** @see EventService#unsubscribeVetoExactly(Class,Object) */ - public boolean unsubscribeVetoExactly(Class eventClass, Object subscribedByProxy) { - VetoEventListener subscriber = (VetoEventListener) getVetoProxySubscriber(eventClass, subscribedByProxy); - if (subscriber == null) { - return false; - } else { - return unsubscribeVetoListenerExactly(eventClass, subscriber); - } - } - - /** @see EventService#unsubscribeVeto(String,Object) */ - public boolean unsubscribeVeto(String topic, Object subscribedByProxy) { - VetoTopicEventListener subscriber = (VetoTopicEventListener) getVetoProxySubscriber(topic, subscribedByProxy); - if (subscriber == null) { - return false; - } else { - return unsubscribeVetoListener(topic, subscriber); - } - } - - /** @see EventService#unsubscribeVeto(java.util.regex.Pattern,Object) */ - public boolean unsubscribeVeto(Pattern pattern, Object subscribedByProxy) { - VetoTopicEventListener subscriber = (VetoTopicEventListener) getVetoProxySubscriber(pattern, subscribedByProxy); - if (subscriber == null) { - return false; - } else { - return unsubscribeVetoListener(pattern, subscriber); - } - } - - /** @see EventService#unsubscribeVetoListener(Class,VetoEventListener) */ - public boolean unsubscribeVetoListener(Class eventClass, VetoEventListener vetoListener) { - return unsubscribeVetoListener(eventClass, vetoListenersByClass, vetoListener); - } - - /** @see EventService#unsubscribeVetoListenerExactly(Class,VetoEventListener) */ - public boolean unsubscribeVetoListenerExactly(Class eventClass, VetoEventListener vetoListener) { - return unsubscribeVetoListener(eventClass, vetoListenersByExactClass, vetoListener); - } - - /** @see EventService#unsubscribeVetoListener(String,VetoTopicEventListener) */ - public boolean unsubscribeVetoListener(String topic, VetoTopicEventListener vetoListener) { - return unsubscribeVetoListener(topic, vetoListenersByTopic, vetoListener); - } - - /** @see EventService#unsubscribeVetoListener(Pattern,VetoTopicEventListener) */ - public boolean unsubscribeVetoListener(Pattern topicPattern, VetoTopicEventListener vetoListener) { - PatternWrapper patternWrapper = new PatternWrapper(topicPattern); - return unsubscribeVetoListener(patternWrapper, vetoListenersByTopicPattern, vetoListener); - } - - /** - * All veto unsubscriptions methods call this method. Extending classes only have to override this method to - * subscribe all veto unsubscriptions. - * - * @param o the topic or event class to unsubscribe from - * @param vetoListenerMap the map of veto listeners to use (by topic or class) - * @param vl the veto listener to unsubscribe, or a WeakReference to one - * - * @return boolean if the veto listener is unsubscribed (was subscribed). - */ - protected boolean unsubscribeVetoListener(Object o, Map vetoListenerMap, Object vl) { - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("unsubscribeVetoListener(" + o + "," + vl + ")"); - } - if (o == null) { - throw new IllegalArgumentException("Can't unsubscribe veto listener to null."); - } - if (vl == null) { - throw new IllegalArgumentException("Can't unsubscribe null veto listener to " + o); - } - synchronized (listenerLock) { - return removeFromSetResolveWeakReferences(vetoListenerMap, o, vl); - } - } - - private ProxySubscriber getProxySubscriber(Class eventClass, Object subscribedByProxy) { - List subscribers = getSubscribers(eventClass); - return getProxySubscriber(subscribers, subscribedByProxy); - } - - private ProxySubscriber getProxySubscriber(String topic, Object subscribedByProxy) { - List subscribers = getSubscribers(topic); - return getProxySubscriber(subscribers, subscribedByProxy); - } - - private ProxySubscriber getProxySubscriber(Pattern pattern, Object subscribedByProxy) { - List subscribers = getSubscribersToPattern(pattern); - return getProxySubscriber(subscribers, subscribedByProxy); - } - - private ProxySubscriber getVetoProxySubscriber(Class eventClass, Object subscribedByProxy) { - List subscribers = getVetoSubscribers(eventClass); - return getProxySubscriber(subscribers, subscribedByProxy); - } - - private ProxySubscriber getVetoProxySubscriber(String topic, Object subscribedByProxy) { - List subscribers = getVetoSubscribers(topic); - return getProxySubscriber(subscribers, subscribedByProxy); - } - - private ProxySubscriber getVetoProxySubscriber(Pattern pattern, Object subscribedByProxy) { - List subscribers = getVetoSubscribers(pattern); - return getProxySubscriber(subscribers, subscribedByProxy); - } - - private ProxySubscriber getProxySubscriber(List subscribers, Object subscribedByProxy) { - for (Iterator iter = subscribers.iterator(); iter.hasNext();) { - Object subscriber = iter.next(); - if (subscriber instanceof WeakReference) { - WeakReference wr = (WeakReference) subscriber; - subscriber = wr.get(); - } - if (subscriber instanceof ProxySubscriber) { - ProxySubscriber proxy = (ProxySubscriber) subscriber; - subscriber = proxy.getProxiedSubscriber(); - if (subscriber == subscribedByProxy) { - return proxy; - } - } - } - return null; - } - - /** @see EventService#publish(Object) */ - public void publish(Object event) { - if (event == null) { - throw new IllegalArgumentException("Cannot publish null event."); - } - publish(event, null, null, getSubscribers(event.getClass()), getVetoSubscribers(event.getClass()), null); - } - - /** @see EventService#publish(java.lang.reflect.Type, Object) */ - public void publish(Type genericType, Object event) { - if (genericType == null) { - throw new IllegalArgumentException("genericType must not be null."); - } - if (event == null) { - throw new IllegalArgumentException("Cannot publish null event."); - } - publish(event, null, null, getSubscribers(genericType), null/*getVetoSubscribers(genericType)*/, null); - } - - /** @see EventService#publish(String,Object) */ - public void publish(String topicName, Object eventObj) { - publish(null, topicName, eventObj, getSubscribers(topicName), getVetoEventListeners(topicName), null); - } - - /** - * All publish methods call this method. Extending classes only have to override this method to handle all - * publishing cases. - * - * @param event the event to publish, null if publishing on a topic - * @param topic if publishing on a topic, the topic to publish on, else null - * @param eventObj if publishing on a topic, the eventObj to publish, else null - * @param subscribers the subscribers to publish to - must be a snapshot copy - * @param vetoSubscribers the veto subscribers to publish to - must be a snapshot copy. - * @param callingStack the stack that called this publication, helpful for reporting errors on other threads - * @throws IllegalArgumentException if eh or o is null - */ - protected void publish(final Object event, final String topic, final Object eventObj, - final List subscribers, final List vetoSubscribers, StackTraceElement[] callingStack) { - - if (event == null && topic == null) { - throw new IllegalArgumentException("Can't publish to null topic/event."); - } - - setStatus(PublicationStatus.Initiated, event, topic, eventObj); - //topic or event - logEvent(event, topic, eventObj); - - //Check all veto subscribers, if any veto, then don't publish or cache - if (checkVetoSubscribers(event, topic, eventObj, vetoSubscribers, callingStack)) { - setStatus(PublicationStatus.Vetoed, event, topic, eventObj); - return; - } else { - setStatus(PublicationStatus.Queued, event, topic, eventObj); - } - - addEventToCache(event, topic, eventObj); - - if (subscribers == null || subscribers.isEmpty()) { - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("No subscribers for event or topic. Event:" + event + ", Topic:" + topic); - } - } else { - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("Publishing to subscribers:" + subscribers); - } - setStatus(PublicationStatus.Publishing, event, topic, eventObj); - for (int i = 0; i < subscribers.size(); i++) { - Object eh = subscribers.get(i); - if (event != null) { - EventSubscriber eventSubscriber = (EventSubscriber) eh; - long start = System.currentTimeMillis(); - try { - eventSubscriber.onEvent(event); - } catch (Throwable e) { - handleException(event, e, callingStack, eventSubscriber); - } - } else { - EventTopicSubscriber eventTopicSubscriber = (EventTopicSubscriber) eh; - try { - eventTopicSubscriber.onEvent(topic, eventObj); - } catch (Throwable e) { - onEventException(topic, eventObj, e, callingStack, eventTopicSubscriber); - } - } - } - } - setStatus(PublicationStatus.Completed, event, topic, eventObj); - } - - /** - * Called during publication to set the status on an event. Can be used by subclasses - * to be notified when an event transitions from one state to another. Implementers - * are required to call setPublicationStatus - * @param status the status to set on the object - * @param event the event being published, will be null if topic is not null - * @param topic the topic eventObj is being published on, will be null if event is not null - * @param eventObj the payload being published on the topic , will be null if event is not null - */ - @SuppressWarnings({"UnusedDeclaration"}) - protected void setStatus(PublicationStatus status, Object event, String topic, Object eventObj) { - if (event instanceof PublicationStatusTracker) { - ((PublicationStatusTracker)event).setPublicationStatus(status); - } - if (eventObj instanceof PublicationStatusTracker) { - ((PublicationStatusTracker)eventObj).setPublicationStatus(status); - } - } - - /** - * Handles subscribers that are Prioritized by putting the most negative prioritized subscribers - * first, the most positive prioritized subscribers last, and leaving non-Prioritized in their - * original FIFO order. - * @param subscribers the subscribers to sort - * @return the same list if there are no prioritized subscribers in the list, otherwise a new sorted result - */ - private List sortSubscribers(List subscribers) { - if (subscribers == null) { - return null; - } - List prioritizedSubscribers = null; - Iterator iterator = subscribers.iterator(); - while (iterator.hasNext()) { - Object subscriber = iterator.next(); - if (subscriber instanceof Prioritized) { - Prioritized prioritized = ((Prioritized)subscriber); - if (prioritized.getPriority() != 0) { - iterator.remove(); - if (prioritizedSubscribers == null) { - prioritizedSubscribers = new ArrayList(); - } - prioritizedSubscribers.add(prioritized); - } - } - } - if (prioritizedSubscribers == null) { - return subscribers; - } else { - List result = new ArrayList(prioritizedSubscribers.size()+subscribers.size()); - Collections.sort(prioritizedSubscribers, PRIORITIZED_SUBSCRIBER_COMPARATOR); - boolean haveAddedFIFOSubscribers = false; - for (Prioritized prioritizedSubscriber : prioritizedSubscribers) { - if (prioritizedSubscriber.getPriority() > 0 && !haveAddedFIFOSubscribers) { - for (Object subscriber : subscribers) { - result.add(subscriber); - } - haveAddedFIFOSubscribers = true; - } - result.add(prioritizedSubscriber); - } - //Issue 26 - of all priorities are negative, then add the FIFO after processing all of them - if (!haveAddedFIFOSubscribers) { - for (Object subscriber : subscribers) { - result.add(subscriber); - } - } - return result; - } - } - - private boolean checkVetoSubscribers(Object event, String topic, Object eventObj, List vetoSubscribers, - StackTraceElement[] callingStack) { - if (vetoSubscribers != null && !vetoSubscribers.isEmpty()) { - for (Iterator vlIter = vetoSubscribers.iterator(); vlIter.hasNext();) { - Object vetoer = vlIter.next(); - VetoEventListener vl = null; - VetoTopicEventListener vtl = null; - if (event == null) { - vtl = (VetoTopicEventListener) vetoer; - } else { - vl = (VetoEventListener) vetoer; - } - long start = System.currentTimeMillis(); - try { - boolean shouldVeto = false; - if (event == null) { - shouldVeto = vtl.shouldVeto(topic, eventObj); - } else { - shouldVeto = vl.shouldVeto(event); - } - if (shouldVeto) { - handleVeto(vl, event, vtl, topic, eventObj); - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("Publication vetoed. Event:" + event + ", Topic:" + topic + ", veto subscriber:" + vl); - } - return true; - } - } catch (Throwable ex) { - subscribeVetoException(event, topic, eventObj, ex, callingStack, vl); - } - } - } - return false; - } - - private void logEvent(Object event, String topic, Object eventObj) { - if (LOG.isLoggable(Level.DEBUG)) { - if (event != null) { - LOG.debug("Publishing event: class=" + event.getClass() + ", event=" + event); - } else if (topic != null) { - LOG.debug("Publishing event: topic=" + topic + ", eventObj=" + eventObj); - } - } - } - - /** - * Adds an event to the event cache, if appropriate. This method is called just before publication to listeners, - * after the event passes any veto listeners. - *

    - * Using protected visibility to open the caching to other implementations. - *

    - * - * @param event the event about to be published, null if topic is non-null - * @param topic the topic about to be published to, null if the event is non-null - * @param eventObj the eventObj about to be published on a topic, null if the event is non-null - */ - protected void addEventToCache(Object event, String topic, Object eventObj) { - //Taking the listener lock here, since a listener that is now subscribing will want - //this event since they are not in this subscriber list. - synchronized (listenerLock) { - if (event != null) { - int cacheSizeForEventClass = getCacheSizeForEventClass(event.getClass()); - List eventClassCache = (List) cacheByEvent.get(event.getClass()); - if (cacheSizeForEventClass <= 0) { - if (eventClassCache != null) { - //the cache threshold was lowered to 0 - cacheByEvent.remove(event.getClass()); - } - } else { - if (eventClassCache == null) { - eventClassCache = new LinkedList(); - cacheByEvent.put(event.getClass(), eventClassCache); - } - eventClassCache.add(0, event); - while (eventClassCache.size() > cacheSizeForEventClass) { - eventClassCache.remove(eventClassCache.size() - 1); - } - } - } else { - //topic - int cacheSizeForTopic = getCacheSizeForTopic(topic); - List topicCache = (List) cacheByTopic.get(topic); - if (cacheSizeForTopic <= 0) { - if (topicCache != null) { - //the cache threshold was lowered to 0 - topicCache.remove(topic); - } - } else { - if (topicCache == null) { - topicCache = new LinkedList(); - cacheByTopic.put(topic, topicCache); - } - topicCache.add(0, eventObj); - while (topicCache.size() > cacheSizeForTopic) { - topicCache.remove(topicCache.size() - 1); - } - } - } - } - } - - /** @see EventService#getSubscribers(Class) */ - public List getSubscribers(Class eventClass) { - List hierarchyMatches; - List exactMatches; - synchronized (listenerLock) { - hierarchyMatches = getSubscribersToClass(eventClass); - exactMatches = getSubscribersToExactClass(eventClass); - } - List result = new ArrayList(); - if (exactMatches != null) { - result.addAll(exactMatches); - } - if (hierarchyMatches != null) { - result.addAll(hierarchyMatches); - } - if (hasEverUsedPrioritized) { - result = sortSubscribers(result); - } - return result; - - } - - /** @see EventService#getSubscribersToClass(Class) */ - public List getSubscribersToClass(Class eventClass) { - synchronized (listenerLock) { - Map classMap = subscribersByEventClass; - List result = getEventOrVetoSubscribersToClass(classMap, eventClass); - if (hasEverUsedPrioritized) { - result = sortSubscribers(result); - } - return result; - } - } - - /** @see EventService#getSubscribersToExactClass(Class) */ - public List getSubscribersToExactClass(Class eventClass) { - synchronized (listenerLock) { - return getSubscribers(eventClass, subscribersByExactEventClass); - } - } - - /** @see EventService#getSubscribers(Type) */ - public List getSubscribers(Type eventType) { - List result; - synchronized (listenerLock) { - result = getEventOrVetoSubscribersToType(subscribersByEventType, eventType); - } - if (hasEverUsedPrioritized) { - result = sortSubscribers(result); - } - return result; - } - - /** @see EventService#getSubscribers(String) */ - public List getSubscribers(String topic) { - List result = new ArrayList(); - List exactMatches; - List patternMatches; - synchronized (listenerLock) { - exactMatches = getSubscribersToTopic(topic); - patternMatches = getSubscribersByPattern(topic); - } - if (exactMatches != null) { - result.addAll(exactMatches); - } - if (patternMatches != null) { - result.addAll(patternMatches); - } - if (hasEverUsedPrioritized) { - result = sortSubscribers(result); - } - return result; - } - - /** @see EventService#getSubscribersToTopic(String) */ - public List getSubscribersToTopic(String topic) { - synchronized (listenerLock) { - return getSubscribers(topic, subscribersByTopic); - } - } - - /** @see EventService#getSubscribers(Pattern) */ - public List getSubscribers(Pattern pattern) { - synchronized (listenerLock) { - return getSubscribers(pattern, subscribersByTopicPattern); - } - } - - /** @see EventService#getSubscribersByPattern(String) */ - public List getSubscribersByPattern(String topic) { - return getSubscribersByPattern(topic, subscribersByTopicPattern); - } - - /** @see EventService#getVetoSubscribers(Class) */ - public List getVetoSubscribers(Class eventClass) { - List result = new ArrayList(); - List exactMatches; - List hierarchyMatches; - synchronized (listenerLock) { - exactMatches = getVetoSubscribersToClass(eventClass); - hierarchyMatches = getVetoSubscribersToExactClass(eventClass); - } - if (exactMatches != null) { - result.addAll(exactMatches); - } - if (hierarchyMatches != null) { - result.addAll(hierarchyMatches); - } - if (hasEverUsedPrioritized) { - result = sortSubscribers(result); - } - return result; - } - - /** @see EventService#getVetoSubscribersToClass(Class) */ - public List getVetoSubscribersToClass(Class eventClass) { - List result; - synchronized (listenerLock) { - Map classMap = vetoListenersByClass; - result = getEventOrVetoSubscribersToClass(classMap, eventClass); - } - if (hasEverUsedPrioritized) { - result = sortSubscribers(result); - } - return result; - } - - /** @see EventService#getVetoSubscribersToExactClass(Class) */ - public List getVetoSubscribersToExactClass(Class eventClass) { - synchronized (listenerLock) { - return getSubscribers(eventClass, vetoListenersByExactClass); - } - } - - /** @see EventService#getVetoEventListeners(String) */ - public List getVetoEventListeners(String topicOrPattern) { - List result = new ArrayList(); - List exactMatches; - List patternMatches; - synchronized (listenerLock) { - exactMatches = getVetoSubscribersToTopic(topicOrPattern); - patternMatches = getVetoSubscribersByPattern(topicOrPattern); - } - if (exactMatches != null) { - result.addAll(exactMatches); - } - if (patternMatches != null) { - result.addAll(patternMatches); - } - if (hasEverUsedPrioritized) { - result = sortSubscribers(result); - } - return result; - } - - /** @see EventService#getVetoSubscribersToTopic(String) */ - public List getVetoSubscribersToTopic(String topic) { - synchronized (listenerLock) { - return getSubscribers(topic, vetoListenersByTopic); - } - } - - /** - * Note: this is inconsistent with getSubscribers(String) - * @see EventService#getVetoSubscribersToTopic(String) - * @deprecated use getVetoSubscribersToTopic instead for direct replacement, - * or use getVetoEventListeners to get topic and pattern matchers. - * In EventBus 2.0 this name will replace getVetoEventListeners() - * and have it's union functionality - */ - public List getVetoSubscribers(String topic) { - synchronized (listenerLock) { - return getVetoSubscribersToTopic(topic); - } - } - - /** @see EventService#getVetoSubscribers(Pattern) */ - public List getVetoSubscribers(Pattern topicPattern) { - synchronized (listenerLock) { - PatternWrapper patternWrapper = new PatternWrapper(topicPattern); - return getSubscribers(patternWrapper, vetoListenersByTopicPattern); - } - } - - /** @see EventService#getVetoSubscribersByPattern(String) */ - public List getVetoSubscribersByPattern(String pattern) { - return getSubscribersByPattern(pattern, vetoListenersByTopicPattern); - } - - /** Used for subscribers and veto subscribers */ - private List getSubscribersByPattern(String topic, Map subscribersByTopicPattern) { - List result = new ArrayList(); - synchronized (listenerLock) { - Set keys = subscribersByTopicPattern.keySet(); - for (Iterator iterator = keys.iterator(); iterator.hasNext();) { - PatternWrapper patternKey = (PatternWrapper) iterator.next(); - if (patternKey.matches(topic)) { - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("Pattern " + patternKey + " matched topic name " + topic); - } - Collection subscribers = (Collection) subscribersByTopicPattern.get(patternKey); - result.addAll(createCopyOfContentsRemoveWeakRefs(subscribers)); - } - } - if (hasEverUsedPrioritized) { - result = sortSubscribers(result); - } - return result; - } - } - - protected List getSubscribersToPattern(Pattern topicPattern) { - synchronized (listenerLock) { - PatternWrapper patternWrapper = new PatternWrapper(topicPattern); - return getSubscribers(patternWrapper, subscribersByTopicPattern); - } - } - - private List getSubscribers(Object classOrTopic, Map subscriberMap) { - List result; - synchronized (listenerLock) { - List subscribers = (List) subscriberMap.get(classOrTopic); - //Make a defensive copy of subscribers and veto listeners so listeners - //can change the listener list while the listeners are being called - //Resolve WeakReferences and unsubscribe if necessary. - result = createCopyOfContentsRemoveWeakRefs(subscribers); - } - if (hasEverUsedPrioritized) { - result = sortSubscribers(result); - } - return result; - } - - private List getEventOrVetoSubscribersToClass(Map classMap, Class eventClass) { - List result = new ArrayList(); - Set keys = classMap.keySet(); - for (Iterator iterator = keys.iterator(); iterator.hasNext();) { - Class cl = (Class) iterator.next(); - if (cl.isAssignableFrom(eventClass)) { - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("Hierarchical match " + cl + " matched event of class " + eventClass); - } - Collection subscribers = (Collection) classMap.get(cl); - result.addAll(createCopyOfContentsRemoveWeakRefs(subscribers)); - } - } - return result; - } - - private List getEventOrVetoSubscribersToType(Map typeMap, Type eventType) { - List result = new ArrayList(); - Set mapKeySet = typeMap.keySet(); - for (Object mapKey : mapKeySet) { - Type subscriberType = (Type) mapKey; - if (eventType instanceof ParameterizedType && subscriberType instanceof ParameterizedType) { - ParameterizedType subscriberPT = (ParameterizedType) subscriberType; - ParameterizedType eventPT = (ParameterizedType) eventType; - if (eventPT.getRawType().equals(subscriberPT.getRawType())) { - Type[] mapTypeArgs = subscriberPT.getActualTypeArguments(); - Type[] eventTypeArgs = eventPT.getActualTypeArguments(); - if (mapTypeArgs == null || eventTypeArgs == null || mapTypeArgs.length != eventTypeArgs.length) { - continue; - } - boolean parameterArgsMatch = true; - for (int argCount = 0; argCount < mapTypeArgs.length; argCount++) { - Type eventTypeArg = eventTypeArgs[argCount]; - if (eventTypeArg instanceof WildcardType) { - throw new IllegalArgumentException("Only simple Class parameterized types can be published, not wildcards, etc. Published attempt made for:"+eventTypeArg); - } - Type subscriberTypeArg = mapTypeArgs[argCount]; - if (subscriberTypeArg instanceof WildcardType) { - WildcardType wildcardSubscriberTypeArg = (WildcardType) subscriberTypeArg; - Type[] upperBound = wildcardSubscriberTypeArg.getUpperBounds(); - Type[] lowerBound = wildcardSubscriberTypeArg.getLowerBounds(); - if (upperBound != null && upperBound.length > 0) { - if (upperBound[0] instanceof Class) { - Class upper = (Class) upperBound[0]; - if (eventTypeArg instanceof Class) { - if (!upper.isAssignableFrom((Class) eventTypeArg)) { - parameterArgsMatch = false; - break; - } - } else { - parameterArgsMatch = false; - break; - } - } else { - throw new IllegalArgumentException("Only Class and Interface types are supported as types of wildcard subscriptions. Type:"+upperBound[0]); - } - } - if (lowerBound != null && lowerBound.length > 0) { - if (lowerBound[0] instanceof Class) { - Class lower = (Class) lowerBound[0]; - if (eventTypeArg instanceof Class) { - if (!((Class)eventTypeArg).isAssignableFrom(lower)) { - parameterArgsMatch = false; - break; - } - } else { - parameterArgsMatch = false; - break; - } - } else { - throw new IllegalArgumentException("Only Class and Interface types are supported as types of wildcard subscriptions. Type:"+upperBound[0]); - } - } - } else if (!subscriberTypeArg.equals(eventTypeArg)) { - parameterArgsMatch = false; - break; - } - } - if (parameterArgsMatch) { - if (LOG.isLoggable(Level.DEBUG)) { - LOG.debug("Exact parameterized subscriberType match for event subscriberType " + eventType); - } - Collection subscribers = (Collection) typeMap.get(subscriberType); - if (subscribers != null) { - result.addAll(createCopyOfContentsRemoveWeakRefs(subscribers)); - } - } - } - } - } - return result; + + public static final Integer CLEANUP_START_THRESHOLD_DEFAULT = 250; + public static final Integer CLEANUP_STOP_THRESHOLD_DEFAULT = 100; + public static final Long CLEANUP_PERIOD_MS_DEFAULT = 20L * 60L * 1000L; + + protected static final Logger LOG = Logger.getLogger(EventService.class + .getName()); + + // Making these generic collections is a bad idea, it doesn't compile since + // it's better to have all the maps + // go through the same set of code to do all the real publish and subscribe + // work + private Map subscribersByEventType = new HashMap(); + private Map subscribersByEventClass = new HashMap(); + private Map subscribersByExactEventClass = new HashMap(); + private Map subscribersByTopic = new HashMap(); + private Map subscribersByTopicPattern = new HashMap(); + private Map vetoListenersByClass = new HashMap(); + private Map vetoListenersByExactClass = new HashMap(); + private Map vetoListenersByTopic = new HashMap(); + private Map vetoListenersByTopicPattern = new HashMap(); + private final Object listenerLock = new Object(); + private final Object cacheLock = new Object(); + private Long timeThresholdForEventTimingEventPublication; + private Map cacheByEvent = new HashMap(); + private int defaultCacheSizePerClassOrTopic = 0; + private Map cacheSizesForEventClass; + private Map rawCacheSizesForEventClass; + private boolean rawCacheSizesForEventClassChanged; + private Map cacheByTopic = new HashMap(); + private Map cacheSizesForTopic; + private Map rawCacheSizesForTopic; + private boolean rawCacheSizesForTopicChanged; + private Map rawCacheSizesForPattern; + private boolean rawCacheSizesForPatternChanged; + private Integer cleanupStartThreshhold; + private Integer cleanupStopThreshold; + private Long cleanupPeriodMS; + private int weakRefPlusProxySubscriberCount; + private Timer cleanupTimer; + private TimerTask cleanupTimerTask; + private static final Comparator PRIORITIZED_SUBSCRIBER_COMPARATOR = + new PrioritizedSubscriberComparator(); + private boolean hasEverUsedPrioritized; + + /** + * Creates a ThreadSafeEventService that does not monitor timing of handlers. + */ + public ThreadSafeEventService() { + this(null, null, null, null); + } + + /** + * Creates a ThreadSafeEventService while providing time monitoring options. + * + * @param timeThresholdForEventTimingEventPublication the longest time a + * subscriber should spend handling an event, The service will + * publish an SubscriberTimingEvent after listener processing if the + * time was exceeded. If null, no EventSubscriberTimingEvent will be + * issued. + */ + public ThreadSafeEventService( + Long timeThresholdForEventTimingEventPublication) + { + this(timeThresholdForEventTimingEventPublication, null, null, null); + } + + /** + * Creates a ThreadSafeEventService while providing proxy cleanup + * customization. Proxies are used with Annotations. + * + * @param cleanupStartThreshold see class javadoc. + * @param cleanupStopThreshold see class javadoc. + * @param cleanupPeriodMS see class javadoc. + */ + public ThreadSafeEventService(Integer cleanupStartThreshold, + Integer cleanupStopThreshold, Long cleanupPeriodMS) + { + this(null, cleanupStartThreshold, cleanupStopThreshold, cleanupPeriodMS); + } + + /** + * Creates a ThreadSafeEventService while providing time monitoring options. + * + * @param timeThresholdForEventTimingEventPublication the longest time a + * subscriber should spend handling an event. The service will + * publish an SubscriberTimingEvent after listener processing if the + * time was exceeded. If null, no SubscriberTimingEvent will be + * issued. + * @param cleanupStartThreshold see class javadoc. + * @param cleanupStopThreshold see class javadoc. + * @param cleanupPeriodMS see class javadoc. + */ + public ThreadSafeEventService( + Long timeThresholdForEventTimingEventPublication, + Integer cleanupStartThreshold, Integer cleanupStopThreshold, + Long cleanupPeriodMS) + { + this.timeThresholdForEventTimingEventPublication = + timeThresholdForEventTimingEventPublication; + if (cleanupStartThreshold == null) { + this.cleanupStartThreshhold = CLEANUP_START_THRESHOLD_DEFAULT; + } + else { + this.cleanupStartThreshhold = cleanupStartThreshold; + } + if (cleanupStopThreshold == null) { + this.cleanupStopThreshold = CLEANUP_STOP_THRESHOLD_DEFAULT; + } + else { + this.cleanupStopThreshold = cleanupStopThreshold; + } + if (cleanupPeriodMS == null) { + this.cleanupPeriodMS = CLEANUP_PERIOD_MS_DEFAULT; + } + else { + this.cleanupPeriodMS = cleanupPeriodMS; + } + } + + /** + * Gets the threshold above which cleanup starts. See the class javadoc on + * cleanup. + * + * @return the threshold at which cleanup starts + */ + public Integer getCleanupStartThreshhold() { + synchronized (listenerLock) { + return cleanupStartThreshhold; + } + } + + /** + * Sets the threshold above which cleanup starts. See the class javadoc on + * cleanup. + * + * @param cleanupStartThreshhold threshold at which cleanup starts + */ + public void setCleanupStartThreshhold(Integer cleanupStartThreshhold) { + synchronized (listenerLock) { + this.cleanupStartThreshhold = cleanupStartThreshhold; + } + } + + /** + * Gets the threshold below which cleanup stops. See the class javadoc on + * cleanup. + * + * @return threshold at which cleanup stops (it may start again) + */ + public Integer getCleanupStopThreshold() { + synchronized (listenerLock) { + return cleanupStopThreshold; + } + } + + /** + * Sets the threshold below which cleanup stops. See the class javadoc on + * cleanup. + * + * @param cleanupStopThreshold threshold at which cleanup stops (it may start + * again). + */ + public void setCleanupStopThreshold(Integer cleanupStopThreshold) { + synchronized (listenerLock) { + this.cleanupStopThreshold = cleanupStopThreshold; + } + } + + /** + * Get the cleanup interval. See the class javadoc on cleanup. + * + * @return interval in milliseconds between cleanup runs. + */ + public Long getCleanupPeriodMS() { + synchronized (listenerLock) { + return cleanupPeriodMS; + } + } + + /** + * Sets the cleanup interval. See the class javadoc on cleanup. + * + * @param cleanupPeriodMS interval in milliseconds between cleanup runs. + * Passing null stops cleanup. + */ + public void setCleanupPeriodMS(Long cleanupPeriodMS) { + synchronized (listenerLock) { + this.cleanupPeriodMS = cleanupPeriodMS; + } + } + + /** @see EventService#subscribe(Class,EventSubscriber) */ + public boolean subscribe(Class cl, EventSubscriber eh) { + if (cl == null) { + throw new IllegalArgumentException("Event class must not be null"); + } + if (eh == null) { + throw new IllegalArgumentException("Event subscriber must not be null"); + } + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("Subscribing by class, class:" + cl + ", subscriber:" + eh); + } + return subscribe(cl, subscribersByEventClass, + new WeakReference(eh)); + } + + /** @see EventService#subscribe(java.lang.reflect.Type, EventSubscriber) */ + public boolean subscribe(Type type, EventSubscriber eh) { + return subscribe(type, subscribersByEventType, + new WeakReference(eh)); + } + + /** @see EventService#subscribeExactly(Class,EventSubscriber) */ + public boolean subscribeExactly(Class cl, EventSubscriber eh) { + if (cl == null) { + throw new IllegalArgumentException("Event class must not be null"); + } + if (eh == null) { + throw new IllegalArgumentException("Event subscriber must not be null"); + } + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("Subscribing by class, class:" + cl + ", subscriber:" + eh); + } + return subscribe(cl, subscribersByExactEventClass, + new WeakReference(eh)); + } + + /** @see EventService#subscribe(String,EventTopicSubscriber) */ + public boolean subscribe(String topic, EventTopicSubscriber eh) { + if (topic == null) { + throw new IllegalArgumentException("Topic must not be null"); + } + if (eh == null) { + throw new IllegalArgumentException( + "Event topic subscriber must not be null"); + } + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("Subscribing by topic name, name:" + topic + ", subscriber:" + + eh); + } + return subscribe(topic, subscribersByTopic, + new WeakReference(eh)); + } + + /** @see EventService#subscribe(Pattern,EventTopicSubscriber) */ + public boolean subscribe(Pattern pat, EventTopicSubscriber eh) { + if (pat == null) { + throw new IllegalArgumentException("Pattern must not be null"); + } + if (eh == null) { + throw new IllegalArgumentException("Event subscriber must not be null"); + } + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("Subscribing by pattern, pattern:" + pat + ", subscriber:" + + eh); + } + PatternWrapper patternWrapper = new PatternWrapper(pat); + return subscribe(patternWrapper, subscribersByTopicPattern, + new WeakReference(eh)); + } + + /** @see EventService#subscribeStrongly(Class,EventSubscriber) */ + public boolean subscribeStrongly(Class cl, EventSubscriber eh) { + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("Subscribing weakly by class, class:" + cl + ", subscriber:" + + eh); + } + if (eh == null) { + throw new IllegalArgumentException("Subscriber cannot be null."); + } + return subscribe(cl, subscribersByEventClass, eh); + } + + /** @see EventService#subscribeExactlyStrongly(Class,EventSubscriber) */ + public boolean subscribeExactlyStrongly(Class cl, EventSubscriber eh) { + if (cl == null) { + throw new IllegalArgumentException("Event class must not be null"); + } + if (eh == null) { + throw new IllegalArgumentException("Event subscriber must not be null"); + } + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("Subscribing by class, class:" + cl + ", subscriber:" + eh); + } + return subscribe(cl, subscribersByExactEventClass, eh); + } + + /** @see EventService#subscribeStrongly(String,EventTopicSubscriber) */ + public boolean subscribeStrongly(String name, EventTopicSubscriber eh) { + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("Subscribing weakly by topic name, name:" + name + + ", subscriber:" + eh); + } + if (eh == null) { + throw new IllegalArgumentException("Subscriber cannot be null."); + } + return subscribe(name, subscribersByTopic, eh); + } + + /** @see EventService#subscribeStrongly(Pattern,EventTopicSubscriber) */ + public boolean subscribeStrongly(Pattern pat, EventTopicSubscriber eh) { + if (pat == null) { + throw new IllegalArgumentException("Pattern must not be null"); + } + if (eh == null) { + throw new IllegalArgumentException("Event subscriber must not be null"); + } + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("Subscribing by pattern, pattern:" + pat + ", subscriber:" + + eh); + } + PatternWrapper patternWrapper = new PatternWrapper(pat); + return subscribe(patternWrapper, subscribersByTopicPattern, eh); + } + + /** @see org.scijava.event.bushe.EventService#clearAllSubscribers() */ + public void clearAllSubscribers() { + synchronized (listenerLock) { + unsubscribeAllInMap(subscribersByEventType); + unsubscribeAllInMap(subscribersByEventClass); + unsubscribeAllInMap(subscribersByExactEventClass); + unsubscribeAllInMap(subscribersByTopic); + unsubscribeAllInMap(subscribersByTopicPattern); + unsubscribeAllInMap(vetoListenersByClass); + unsubscribeAllInMap(vetoListenersByExactClass); + unsubscribeAllInMap(vetoListenersByTopic); + unsubscribeAllInMap(vetoListenersByTopicPattern); + } + } + + private void unsubscribeAllInMap(Map subscriberMap) { + synchronized (listenerLock) { + Set subscriptionKeys = subscriberMap.keySet(); + for (Object key : subscriptionKeys) { + List subscribers = (List) subscriberMap.get(key); + while (!subscribers.isEmpty()) { + unsubscribe(key, subscriberMap, subscribers.get(0)); + } + } + } + } + + /** @see EventService#subscribeVetoListener(Class,VetoEventListener) */ + public boolean subscribeVetoListener(Class eventClass, + VetoEventListener vetoListener) + { + if (vetoListener == null) { + throw new IllegalArgumentException("VetoEventListener cannot be null."); + } + if (eventClass == null) { + throw new IllegalArgumentException("eventClass cannot be null."); + } + return subscribeVetoListener(eventClass, vetoListenersByClass, + new WeakReference(vetoListener)); + } + + /** @see EventService#subscribeVetoListenerExactly(Class,VetoEventListener) */ + public boolean subscribeVetoListenerExactly(Class eventClass, + VetoEventListener vetoListener) + { + if (vetoListener == null) { + throw new IllegalArgumentException("VetoEventListener cannot be null."); + } + if (eventClass == null) { + throw new IllegalArgumentException("eventClass cannot be null."); + } + return subscribeVetoListener(eventClass, vetoListenersByExactClass, + new WeakReference(vetoListener)); + } + + /** @see EventService#subscribeVetoListener(String,VetoTopicEventListener) */ + public boolean subscribeVetoListener(String topic, + VetoTopicEventListener vetoListener) + { + if (vetoListener == null) { + throw new IllegalArgumentException("VetoEventListener cannot be null."); + } + if (topic == null) { + throw new IllegalArgumentException("topic cannot be null."); + } + return subscribeVetoListener(topic, vetoListenersByTopic, + new WeakReference(vetoListener)); + } + + /** @see EventService#subscribeVetoListener(Pattern,VetoTopicEventListener) */ + public boolean subscribeVetoListener(Pattern topicPattern, + VetoTopicEventListener vetoListener) + { + if (vetoListener == null) { + throw new IllegalArgumentException("VetoEventListener cannot be null."); + } + if (topicPattern == null) { + throw new IllegalArgumentException("topicPattern cannot be null."); + } + PatternWrapper patternWrapper = new PatternWrapper(topicPattern); + return subscribeVetoListener(patternWrapper, vetoListenersByTopicPattern, + new WeakReference(vetoListener)); + } + + /** + * @see EventService#subscribeVetoListenerStrongly(Class,VetoEventListener) + */ + public boolean subscribeVetoListenerStrongly(Class eventClass, + VetoEventListener vetoListener) + { + if (vetoListener == null) { + throw new IllegalArgumentException("VetoEventListener cannot be null."); + } + if (eventClass == null) { + throw new IllegalArgumentException("eventClass cannot be null."); + } + return subscribeVetoListener(eventClass, vetoListenersByClass, + vetoListener); + } + + /** + * @see EventService#subscribeVetoListenerExactlyStrongly(Class,VetoEventListener) + */ + public boolean subscribeVetoListenerExactlyStrongly(Class eventClass, + VetoEventListener vetoListener) + { + if (vetoListener == null) { + throw new IllegalArgumentException("VetoEventListener cannot be null."); + } + if (eventClass == null) { + throw new IllegalArgumentException("eventClass cannot be null."); + } + return subscribeVetoListener(eventClass, vetoListenersByExactClass, + vetoListener); + } + + /** + * @see EventService#subscribeVetoListenerStrongly(String,VetoTopicEventListener) + */ + public boolean subscribeVetoListenerStrongly(String topic, + VetoTopicEventListener vetoListener) + { + if (vetoListener == null) { + throw new IllegalArgumentException("VetoListener cannot be null."); + } + if (topic == null) { + throw new IllegalArgumentException("topic cannot be null."); + } + return subscribeVetoListener(topic, vetoListenersByTopic, vetoListener); + } + + /** + * @see EventService#subscribeVetoListenerStrongly(Pattern,VetoTopicEventListener) + */ + public boolean subscribeVetoListenerStrongly(Pattern topicPattern, + VetoTopicEventListener vetoListener) + { + if (vetoListener == null) { + throw new IllegalArgumentException( + "VetoTopicEventListener cannot be null."); + } + if (topicPattern == null) { + throw new IllegalArgumentException("topicPattern cannot be null."); + } + PatternWrapper patternWrapper = new PatternWrapper(topicPattern); + return subscribeVetoListener(patternWrapper, vetoListenersByTopicPattern, + vetoListener); + } + + /** + * All veto subscriptions methods call this method. Extending classes only + * have to override this method to subscribe all veto subscriptions. + * + * @param subscription the topic, Pattern, or event class to subscribe to + * @param vetoListenerMap the internal map of veto listeners to use (by topic + * of class) + * @param vetoListener the veto listener to subscribe, may be a + * VetoEventListener or a WeakReference to one + * @return boolean if the veto listener is subscribed (was not subscribed). + * @throws IllegalArgumentException if vl or o is null + */ + protected boolean subscribeVetoListener(final Object subscription, + final Map vetoListenerMap, final Object vetoListener) + { + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("subscribeVetoListener(" + subscription + "," + vetoListener + + ")"); + } + if (vetoListener == null) { + throw new IllegalArgumentException( + "Can't subscribe null veto listener to " + subscription); + } + if (subscription == null) { + throw new IllegalArgumentException( + "Can't subscribe veto listener to null."); + } + return subscribe(subscription, vetoListenerMap, vetoListener); + } + + /** + * All subscribe methods call this method, including veto subscriptions. + * Extending classes only have to override this method to subscribe all + * subscriber subscriptions. + *

    + * Overriding this method is only for the adventurous. This basically gives + * you just enough rope to hang yourself. + *

    + * + * @param classTopicOrPatternWrapper the topic String, event Class, or + * PatternWrapper to subscribe to + * @param subscriberMap the internal map of subscribers to use (by topic or + * class) + * @param subscriber the EventSubscriber or EventTopicSubscriber to subscribe, + * or a WeakReference to either + * @return boolean if the subscriber is subscribed (was not subscribed). + * @throws IllegalArgumentException if subscriber or topicOrClass is null + */ + protected boolean subscribe(final Object classTopicOrPatternWrapper, + final Map subscriberMap, final Object subscriber) + { + if (classTopicOrPatternWrapper == null) { + throw new IllegalArgumentException("Can't subscribe to null."); + } + if (subscriber == null) { + throw new IllegalArgumentException("Can't subscribe null subscriber to " + + classTopicOrPatternWrapper); + } + boolean alreadyExists = false; + + // Find the real subscriber underlying weak refs and proxies + Object realSubscriber = subscriber; + boolean isWeakRef = subscriber instanceof WeakReference; + if (isWeakRef) { + realSubscriber = ((WeakReference) subscriber).get(); + } + if (realSubscriber instanceof Prioritized) { + hasEverUsedPrioritized = true; + } + boolean isWeakProxySubscriber = false; + if (subscriber instanceof ProxySubscriber) { + ProxySubscriber proxySubscriber = (ProxySubscriber) subscriber; + if (proxySubscriber instanceof Prioritized) { + hasEverUsedPrioritized = true; + } + isWeakProxySubscriber = proxySubscriber + .getReferenceStrength() == ReferenceStrength.WEAK; + if (isWeakProxySubscriber) { + realSubscriber = ((ProxySubscriber) subscriber).getProxiedSubscriber(); + } + } + if (isWeakRef && isWeakProxySubscriber) { + throw new IllegalArgumentException( + "ProxySubscribers should always be subscribed strongly."); + } + if (realSubscriber == null) { + return false;// already garbage collected? Weird. + } + synchronized (listenerLock) { + List currentSubscribers = (List) subscriberMap.get( + classTopicOrPatternWrapper); + if (currentSubscribers == null) { + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("Creating new subscriber map for:" + + classTopicOrPatternWrapper); + } + currentSubscribers = new ArrayList(); + subscriberMap.put(classTopicOrPatternWrapper, currentSubscribers); + } + else { + // Double subscription check and stale subscriber cleanup + // Need to compare the underlying referents for WeakReferences and + // ProxySubscribers + // to make sure a weak ref and a hard ref aren't both subscribed + // to the same topic and object. + // Use the proxied subscriber for comparison if a ProxySubscribers is + // used + // Subscribing the same object by proxy and subscribing explicitly + // should + // not subscribe the same object twice + for (Iterator iterator = currentSubscribers.iterator(); iterator + .hasNext();) + { + Object currentSubscriber = iterator.next(); + Object realCurrentSubscriber = + getRealSubscriberAndCleanStaleSubscriberIfNecessary(iterator, + currentSubscriber); + if (realSubscriber.equals(realCurrentSubscriber)) { + // Already subscribed. + // Remove temporarily, to add to the end of the calling list + iterator.remove(); + alreadyExists = true; + } + } + } + currentSubscribers.add(subscriber); + if (isWeakProxySubscriber || isWeakRef) { + incWeakRefPlusProxySubscriberCount(); + } + return !alreadyExists; + } + } + + /** @see EventService#unsubscribe(Class,EventSubscriber) */ + public boolean unsubscribe(Class cl, EventSubscriber eh) { + return unsubscribe(cl, subscribersByEventClass, eh); + } + + /** @see EventService#unsubscribeExactly(Class,EventSubscriber) */ + public boolean unsubscribeExactly(Class cl, EventSubscriber eh) { + return unsubscribe(cl, subscribersByExactEventClass, eh); + } + + /** @see EventService#unsubscribe(String,EventTopicSubscriber) */ + public boolean unsubscribe(String name, EventTopicSubscriber eh) { + return unsubscribe(name, subscribersByTopic, eh); + } + + /** @see EventService#unsubscribe(String,EventTopicSubscriber) */ + public boolean unsubscribe(Pattern topicPattern, EventTopicSubscriber eh) { + PatternWrapper patternWrapper = new PatternWrapper(topicPattern); + return unsubscribe(patternWrapper, subscribersByTopicPattern, eh); + } + + /** @see EventService#unsubscribe(Class,Object) */ + public boolean unsubscribe(Class eventClass, Object subscribedByProxy) { + EventSubscriber subscriber = (EventSubscriber) getProxySubscriber( + eventClass, subscribedByProxy); + if (subscriber == null) { + return false; + } + else { + return unsubscribe(eventClass, subscriber); + } + } + + /** @see EventService#unsubscribeExactly(Class,Object) */ + public boolean unsubscribeExactly(Class eventClass, + Object subscribedByProxy) + { + EventSubscriber subscriber = (EventSubscriber) getProxySubscriber( + eventClass, subscribedByProxy); + if (subscriber == null) { + return false; + } + else { + return unsubscribeExactly(eventClass, subscriber); + } + } + + /** @see EventService#unsubscribe(String,Object) */ + public boolean unsubscribe(String topic, Object subscribedByProxy) { + EventTopicSubscriber subscriber = (EventTopicSubscriber) getProxySubscriber( + topic, subscribedByProxy); + if (subscriber == null) { + return false; + } + else { + return unsubscribe(topic, subscriber); + } + } + + /** @see EventService#unsubscribe(java.util.regex.Pattern,Object) */ + public boolean unsubscribe(Pattern pattern, Object subscribedByProxy) { + EventTopicSubscriber subscriber = (EventTopicSubscriber) getProxySubscriber( + pattern, subscribedByProxy); + if (subscriber == null) { + return false; + } + else { + return unsubscribe(pattern, subscriber); + } + } + + /** + * All event subscriber unsubscriptions call this method. Extending classes + * only have to override this method to subscribe all subscriber + * unsubscriptions. + * + * @param o the topic or event class to unsubscribe from + * @param subscriberMap the map of subscribers to use (by topic of class) + * @param subscriber the subscriber to unsubscribe, either an EventSubscriber + * or an EventTopicSubscriber, or a WeakReference to either + * @return boolean if the subscriber is unsubscribed (was subscribed). + */ + protected boolean unsubscribe(Object o, Map subscriberMap, + Object subscriber) + { + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("unsubscribe(" + o + "," + subscriber + ")"); + } + if (o == null) { + throw new IllegalArgumentException("Can't unsubscribe to null."); + } + if (subscriber == null) { + throw new IllegalArgumentException( + "Can't unsubscribe null subscriber to " + o); + } + synchronized (listenerLock) { + return removeFromSetResolveWeakReferences(subscriberMap, o, subscriber); + } + } + + /** @see EventService#unsubscribeVeto(Class,Object) */ + public boolean unsubscribeVeto(Class eventClass, Object subscribedByProxy) { + VetoEventListener subscriber = (VetoEventListener) getVetoProxySubscriber( + eventClass, subscribedByProxy); + if (subscriber == null) { + return false; + } + else { + return unsubscribeVetoListener(eventClass, subscriber); + } + } + + /** @see EventService#unsubscribeVetoExactly(Class,Object) */ + public boolean unsubscribeVetoExactly(Class eventClass, + Object subscribedByProxy) + { + VetoEventListener subscriber = (VetoEventListener) getVetoProxySubscriber( + eventClass, subscribedByProxy); + if (subscriber == null) { + return false; + } + else { + return unsubscribeVetoListenerExactly(eventClass, subscriber); + } + } + + /** @see EventService#unsubscribeVeto(String,Object) */ + public boolean unsubscribeVeto(String topic, Object subscribedByProxy) { + VetoTopicEventListener subscriber = + (VetoTopicEventListener) getVetoProxySubscriber(topic, subscribedByProxy); + if (subscriber == null) { + return false; + } + else { + return unsubscribeVetoListener(topic, subscriber); + } + } + + /** @see EventService#unsubscribeVeto(java.util.regex.Pattern,Object) */ + public boolean unsubscribeVeto(Pattern pattern, Object subscribedByProxy) { + VetoTopicEventListener subscriber = + (VetoTopicEventListener) getVetoProxySubscriber(pattern, + subscribedByProxy); + if (subscriber == null) { + return false; + } + else { + return unsubscribeVetoListener(pattern, subscriber); + } + } + + /** @see EventService#unsubscribeVetoListener(Class,VetoEventListener) */ + public boolean unsubscribeVetoListener(Class eventClass, + VetoEventListener vetoListener) + { + return unsubscribeVetoListener(eventClass, vetoListenersByClass, + vetoListener); + } + + /** + * @see EventService#unsubscribeVetoListenerExactly(Class,VetoEventListener) + */ + public boolean unsubscribeVetoListenerExactly(Class eventClass, + VetoEventListener vetoListener) + { + return unsubscribeVetoListener(eventClass, vetoListenersByExactClass, + vetoListener); + } + + /** + * @see EventService#unsubscribeVetoListener(String,VetoTopicEventListener) + */ + public boolean unsubscribeVetoListener(String topic, + VetoTopicEventListener vetoListener) + { + return unsubscribeVetoListener(topic, vetoListenersByTopic, vetoListener); + } + + /** + * @see EventService#unsubscribeVetoListener(Pattern,VetoTopicEventListener) + */ + public boolean unsubscribeVetoListener(Pattern topicPattern, + VetoTopicEventListener vetoListener) + { + PatternWrapper patternWrapper = new PatternWrapper(topicPattern); + return unsubscribeVetoListener(patternWrapper, vetoListenersByTopicPattern, + vetoListener); + } + + /** + * All veto unsubscriptions methods call this method. Extending classes only + * have to override this method to subscribe all veto unsubscriptions. + * + * @param o the topic or event class to unsubscribe from + * @param vetoListenerMap the map of veto listeners to use (by topic or class) + * @param vl the veto listener to unsubscribe, or a WeakReference to one + * @return boolean if the veto listener is unsubscribed (was subscribed). + */ + protected boolean unsubscribeVetoListener(Object o, Map vetoListenerMap, + Object vl) + { + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("unsubscribeVetoListener(" + o + "," + vl + ")"); + } + if (o == null) { + throw new IllegalArgumentException( + "Can't unsubscribe veto listener to null."); + } + if (vl == null) { + throw new IllegalArgumentException( + "Can't unsubscribe null veto listener to " + o); + } + synchronized (listenerLock) { + return removeFromSetResolveWeakReferences(vetoListenerMap, o, vl); + } + } + + private ProxySubscriber getProxySubscriber(Class eventClass, + Object subscribedByProxy) + { + List subscribers = getSubscribers(eventClass); + return getProxySubscriber(subscribers, subscribedByProxy); + } + + private ProxySubscriber getProxySubscriber(String topic, + Object subscribedByProxy) + { + List subscribers = getSubscribers(topic); + return getProxySubscriber(subscribers, subscribedByProxy); + } + + private ProxySubscriber getProxySubscriber(Pattern pattern, + Object subscribedByProxy) + { + List subscribers = getSubscribersToPattern(pattern); + return getProxySubscriber(subscribers, subscribedByProxy); + } + + private ProxySubscriber getVetoProxySubscriber(Class eventClass, + Object subscribedByProxy) + { + List subscribers = getVetoSubscribers(eventClass); + return getProxySubscriber(subscribers, subscribedByProxy); + } + + private ProxySubscriber getVetoProxySubscriber(String topic, + Object subscribedByProxy) + { + List subscribers = getVetoSubscribers(topic); + return getProxySubscriber(subscribers, subscribedByProxy); + } + + private ProxySubscriber getVetoProxySubscriber(Pattern pattern, + Object subscribedByProxy) + { + List subscribers = getVetoSubscribers(pattern); + return getProxySubscriber(subscribers, subscribedByProxy); + } + + private ProxySubscriber getProxySubscriber(List subscribers, + Object subscribedByProxy) + { + for (Iterator iter = subscribers.iterator(); iter.hasNext();) { + Object subscriber = iter.next(); + if (subscriber instanceof WeakReference) { + WeakReference wr = (WeakReference) subscriber; + subscriber = wr.get(); + } + if (subscriber instanceof ProxySubscriber) { + ProxySubscriber proxy = (ProxySubscriber) subscriber; + subscriber = proxy.getProxiedSubscriber(); + if (subscriber == subscribedByProxy) { + return proxy; + } + } + } + return null; + } + + /** @see EventService#publish(Object) */ + public void publish(Object event) { + if (event == null) { + throw new IllegalArgumentException("Cannot publish null event."); + } + publish(event, null, null, getSubscribers(event.getClass()), + getVetoSubscribers(event.getClass()), null); + } + + /** @see EventService#publish(java.lang.reflect.Type, Object) */ + public void publish(Type genericType, Object event) { + if (genericType == null) { + throw new IllegalArgumentException("genericType must not be null."); + } + if (event == null) { + throw new IllegalArgumentException("Cannot publish null event."); + } + publish(event, null, null, getSubscribers(genericType), + null/*getVetoSubscribers(genericType)*/, null); + } + + /** @see EventService#publish(String,Object) */ + public void publish(String topicName, Object eventObj) { + publish(null, topicName, eventObj, getSubscribers(topicName), + getVetoEventListeners(topicName), null); + } + + /** + * All publish methods call this method. Extending classes only have to + * override this method to handle all publishing cases. + * + * @param event the event to publish, null if publishing on a topic + * @param topic if publishing on a topic, the topic to publish on, else null + * @param eventObj if publishing on a topic, the eventObj to publish, else + * null + * @param subscribers the subscribers to publish to - must be a snapshot copy + * @param vetoSubscribers the veto subscribers to publish to - must be a + * snapshot copy. + * @param callingStack the stack that called this publication, helpful for + * reporting errors on other threads + * @throws IllegalArgumentException if eh or o is null + */ + protected void publish(final Object event, final String topic, + final Object eventObj, final List subscribers, final List vetoSubscribers, + StackTraceElement[] callingStack) + { + + if (event == null && topic == null) { + throw new IllegalArgumentException("Can't publish to null topic/event."); + } + + setStatus(PublicationStatus.Initiated, event, topic, eventObj); + // topic or event + logEvent(event, topic, eventObj); + + // Check all veto subscribers, if any veto, then don't publish or cache + if (checkVetoSubscribers(event, topic, eventObj, vetoSubscribers, + callingStack)) + { + setStatus(PublicationStatus.Vetoed, event, topic, eventObj); + return; + } + else { + setStatus(PublicationStatus.Queued, event, topic, eventObj); + } + + addEventToCache(event, topic, eventObj); + + if (subscribers == null || subscribers.isEmpty()) { + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("No subscribers for event or topic. Event:" + event + + ", Topic:" + topic); + } + } + else { + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("Publishing to subscribers:" + subscribers); + } + setStatus(PublicationStatus.Publishing, event, topic, eventObj); + for (int i = 0; i < subscribers.size(); i++) { + Object eh = subscribers.get(i); + if (event != null) { + EventSubscriber eventSubscriber = (EventSubscriber) eh; + long start = System.currentTimeMillis(); + try { + eventSubscriber.onEvent(event); + } + catch (Throwable e) { + handleException(event, e, callingStack, eventSubscriber); + } + } + else { + EventTopicSubscriber eventTopicSubscriber = (EventTopicSubscriber) eh; + try { + eventTopicSubscriber.onEvent(topic, eventObj); + } + catch (Throwable e) { + onEventException(topic, eventObj, e, callingStack, + eventTopicSubscriber); + } + } + } + } + setStatus(PublicationStatus.Completed, event, topic, eventObj); + } + + /** + * Called during publication to set the status on an event. Can be used by + * subclasses to be notified when an event transitions from one state to + * another. Implementers are required to call setPublicationStatus + * + * @param status the status to set on the object + * @param event the event being published, will be null if topic is not null + * @param topic the topic eventObj is being published on, will be null if + * event is not null + * @param eventObj the payload being published on the topic , will be null if + * event is not null + */ + @SuppressWarnings({ "UnusedDeclaration" }) + protected void setStatus(PublicationStatus status, Object event, String topic, + Object eventObj) + { + if (event instanceof PublicationStatusTracker) { + ((PublicationStatusTracker) event).setPublicationStatus(status); + } + if (eventObj instanceof PublicationStatusTracker) { + ((PublicationStatusTracker) eventObj).setPublicationStatus(status); + } + } + + /** + * Handles subscribers that are Prioritized by putting the most negative + * prioritized subscribers first, the most positive prioritized subscribers + * last, and leaving non-Prioritized in their original FIFO order. + * + * @param subscribers the subscribers to sort + * @return the same list if there are no prioritized subscribers in the list, + * otherwise a new sorted result + */ + private List sortSubscribers(List subscribers) { + if (subscribers == null) { + return null; + } + List prioritizedSubscribers = null; + Iterator iterator = subscribers.iterator(); + while (iterator.hasNext()) { + Object subscriber = iterator.next(); + if (subscriber instanceof Prioritized) { + Prioritized prioritized = ((Prioritized) subscriber); + if (prioritized.getPriority() != 0) { + iterator.remove(); + if (prioritizedSubscribers == null) { + prioritizedSubscribers = new ArrayList(); + } + prioritizedSubscribers.add(prioritized); + } + } + } + if (prioritizedSubscribers == null) { + return subscribers; + } + else { + List result = new ArrayList(prioritizedSubscribers.size() + subscribers + .size()); + Collections.sort(prioritizedSubscribers, + PRIORITIZED_SUBSCRIBER_COMPARATOR); + boolean haveAddedFIFOSubscribers = false; + for (Prioritized prioritizedSubscriber : prioritizedSubscribers) { + if (prioritizedSubscriber.getPriority() > 0 && + !haveAddedFIFOSubscribers) + { + for (Object subscriber : subscribers) { + result.add(subscriber); + } + haveAddedFIFOSubscribers = true; + } + result.add(prioritizedSubscriber); + } + // Issue 26 - of all priorities are negative, then add the FIFO after + // processing all of them + if (!haveAddedFIFOSubscribers) { + for (Object subscriber : subscribers) { + result.add(subscriber); + } + } + return result; + } + } + + private boolean checkVetoSubscribers(Object event, String topic, + Object eventObj, List vetoSubscribers, StackTraceElement[] callingStack) + { + if (vetoSubscribers != null && !vetoSubscribers.isEmpty()) { + for (Iterator vlIter = vetoSubscribers.iterator(); vlIter.hasNext();) { + Object vetoer = vlIter.next(); + VetoEventListener vl = null; + VetoTopicEventListener vtl = null; + if (event == null) { + vtl = (VetoTopicEventListener) vetoer; + } + else { + vl = (VetoEventListener) vetoer; + } + long start = System.currentTimeMillis(); + try { + boolean shouldVeto = false; + if (event == null) { + shouldVeto = vtl.shouldVeto(topic, eventObj); + } + else { + shouldVeto = vl.shouldVeto(event); + } + if (shouldVeto) { + handleVeto(vl, event, vtl, topic, eventObj); + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("Publication vetoed. Event:" + event + ", Topic:" + + topic + ", veto subscriber:" + vl); + } + return true; + } + } + catch (Throwable ex) { + subscribeVetoException(event, topic, eventObj, ex, callingStack, vl); + } + } + } + return false; + } + + private void logEvent(Object event, String topic, Object eventObj) { + if (LOG.isLoggable(Level.DEBUG)) { + if (event != null) { + LOG.debug("Publishing event: class=" + event.getClass() + ", event=" + + event); + } + else if (topic != null) { + LOG.debug("Publishing event: topic=" + topic + ", eventObj=" + + eventObj); + } + } + } + + /** + * Adds an event to the event cache, if appropriate. This method is called + * just before publication to listeners, after the event passes any veto + * listeners. + *

    + * Using protected visibility to open the caching to other implementations. + *

    + * + * @param event the event about to be published, null if topic is non-null + * @param topic the topic about to be published to, null if the event is + * non-null + * @param eventObj the eventObj about to be published on a topic, null if the + * event is non-null + */ + protected void addEventToCache(Object event, String topic, Object eventObj) { + // Taking the listener lock here, since a listener that is now subscribing + // will want + // this event since they are not in this subscriber list. + synchronized (listenerLock) { + if (event != null) { + int cacheSizeForEventClass = getCacheSizeForEventClass(event + .getClass()); + List eventClassCache = (List) cacheByEvent.get(event.getClass()); + if (cacheSizeForEventClass <= 0) { + if (eventClassCache != null) { + // the cache threshold was lowered to 0 + cacheByEvent.remove(event.getClass()); + } + } + else { + if (eventClassCache == null) { + eventClassCache = new LinkedList(); + cacheByEvent.put(event.getClass(), eventClassCache); + } + eventClassCache.add(0, event); + while (eventClassCache.size() > cacheSizeForEventClass) { + eventClassCache.remove(eventClassCache.size() - 1); + } + } + } + else { + // topic + int cacheSizeForTopic = getCacheSizeForTopic(topic); + List topicCache = (List) cacheByTopic.get(topic); + if (cacheSizeForTopic <= 0) { + if (topicCache != null) { + // the cache threshold was lowered to 0 + topicCache.remove(topic); + } + } + else { + if (topicCache == null) { + topicCache = new LinkedList(); + cacheByTopic.put(topic, topicCache); + } + topicCache.add(0, eventObj); + while (topicCache.size() > cacheSizeForTopic) { + topicCache.remove(topicCache.size() - 1); + } + } + } + } + } + + /** @see EventService#getSubscribers(Class) */ + public List getSubscribers(Class eventClass) { + List hierarchyMatches; + List exactMatches; + synchronized (listenerLock) { + hierarchyMatches = getSubscribersToClass(eventClass); + exactMatches = getSubscribersToExactClass(eventClass); + } + List result = new ArrayList(); + if (exactMatches != null) { + result.addAll(exactMatches); + } + if (hierarchyMatches != null) { + result.addAll(hierarchyMatches); + } + if (hasEverUsedPrioritized) { + result = sortSubscribers(result); + } + return result; + + } + + /** @see EventService#getSubscribersToClass(Class) */ + public List getSubscribersToClass(Class eventClass) { + synchronized (listenerLock) { + Map classMap = subscribersByEventClass; + List result = getEventOrVetoSubscribersToClass(classMap, eventClass); + if (hasEverUsedPrioritized) { + result = sortSubscribers(result); + } + return result; + } + } + + /** @see EventService#getSubscribersToExactClass(Class) */ + public List getSubscribersToExactClass(Class eventClass) { + synchronized (listenerLock) { + return getSubscribers(eventClass, subscribersByExactEventClass); + } + } + + /** @see EventService#getSubscribers(Type) */ + public List getSubscribers(Type eventType) { + List result; + synchronized (listenerLock) { + result = getEventOrVetoSubscribersToType(subscribersByEventType, + eventType); + } + if (hasEverUsedPrioritized) { + result = sortSubscribers(result); + } + return result; + } + + /** @see EventService#getSubscribers(String) */ + public List getSubscribers(String topic) { + List result = new ArrayList(); + List exactMatches; + List patternMatches; + synchronized (listenerLock) { + exactMatches = getSubscribersToTopic(topic); + patternMatches = getSubscribersByPattern(topic); + } + if (exactMatches != null) { + result.addAll(exactMatches); + } + if (patternMatches != null) { + result.addAll(patternMatches); + } + if (hasEverUsedPrioritized) { + result = sortSubscribers(result); + } + return result; + } + + /** @see EventService#getSubscribersToTopic(String) */ + public List getSubscribersToTopic(String topic) { + synchronized (listenerLock) { + return getSubscribers(topic, subscribersByTopic); + } + } + + /** @see EventService#getSubscribers(Pattern) */ + public List getSubscribers(Pattern pattern) { + synchronized (listenerLock) { + return getSubscribers(pattern, subscribersByTopicPattern); + } + } + + /** @see EventService#getSubscribersByPattern(String) */ + public List getSubscribersByPattern(String topic) { + return getSubscribersByPattern(topic, subscribersByTopicPattern); + } + + /** @see EventService#getVetoSubscribers(Class) */ + public List getVetoSubscribers(Class eventClass) { + List result = new ArrayList(); + List exactMatches; + List hierarchyMatches; + synchronized (listenerLock) { + exactMatches = getVetoSubscribersToClass(eventClass); + hierarchyMatches = getVetoSubscribersToExactClass(eventClass); + } + if (exactMatches != null) { + result.addAll(exactMatches); + } + if (hierarchyMatches != null) { + result.addAll(hierarchyMatches); + } + if (hasEverUsedPrioritized) { + result = sortSubscribers(result); + } + return result; + } + + /** @see EventService#getVetoSubscribersToClass(Class) */ + public List getVetoSubscribersToClass(Class eventClass) { + List result; + synchronized (listenerLock) { + Map classMap = vetoListenersByClass; + result = getEventOrVetoSubscribersToClass(classMap, eventClass); + } + if (hasEverUsedPrioritized) { + result = sortSubscribers(result); + } + return result; + } + + /** @see EventService#getVetoSubscribersToExactClass(Class) */ + public List getVetoSubscribersToExactClass(Class eventClass) { + synchronized (listenerLock) { + return getSubscribers(eventClass, vetoListenersByExactClass); + } + } + + /** @see EventService#getVetoEventListeners(String) */ + public List getVetoEventListeners(String topicOrPattern) { + List result = new ArrayList(); + List exactMatches; + List patternMatches; + synchronized (listenerLock) { + exactMatches = getVetoSubscribersToTopic(topicOrPattern); + patternMatches = getVetoSubscribersByPattern(topicOrPattern); + } + if (exactMatches != null) { + result.addAll(exactMatches); + } + if (patternMatches != null) { + result.addAll(patternMatches); + } + if (hasEverUsedPrioritized) { + result = sortSubscribers(result); + } + return result; + } + + /** @see EventService#getVetoSubscribersToTopic(String) */ + public List getVetoSubscribersToTopic(String topic) { + synchronized (listenerLock) { + return getSubscribers(topic, vetoListenersByTopic); + } + } + + /** + * Note: this is inconsistent with getSubscribers(String) + * + * @see EventService#getVetoSubscribersToTopic(String) + * @deprecated use getVetoSubscribersToTopic instead for direct replacement, + * or use getVetoEventListeners to get topic and pattern matchers. + * In EventBus 2.0 this name will replace getVetoEventListeners() + * and have it's union functionality + */ + public List getVetoSubscribers(String topic) { + synchronized (listenerLock) { + return getVetoSubscribersToTopic(topic); + } + } + + /** @see EventService#getVetoSubscribers(Pattern) */ + public List getVetoSubscribers(Pattern topicPattern) { + synchronized (listenerLock) { + PatternWrapper patternWrapper = new PatternWrapper(topicPattern); + return getSubscribers(patternWrapper, vetoListenersByTopicPattern); + } + } + + /** @see EventService#getVetoSubscribersByPattern(String) */ + public List getVetoSubscribersByPattern(String pattern) { + return getSubscribersByPattern(pattern, vetoListenersByTopicPattern); + } + + /** Used for subscribers and veto subscribers */ + private List getSubscribersByPattern(String topic, + Map subscribersByTopicPattern) + { + List result = new ArrayList(); + synchronized (listenerLock) { + Set keys = subscribersByTopicPattern.keySet(); + for (Iterator iterator = keys.iterator(); iterator.hasNext();) { + PatternWrapper patternKey = (PatternWrapper) iterator.next(); + if (patternKey.matches(topic)) { + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("Pattern " + patternKey + " matched topic name " + topic); + } + Collection subscribers = (Collection) subscribersByTopicPattern.get( + patternKey); + result.addAll(createCopyOfContentsRemoveWeakRefs(subscribers)); + } + } + if (hasEverUsedPrioritized) { + result = sortSubscribers(result); + } + return result; + } + } + + protected List getSubscribersToPattern(Pattern topicPattern) { + synchronized (listenerLock) { + PatternWrapper patternWrapper = new PatternWrapper(topicPattern); + return getSubscribers(patternWrapper, subscribersByTopicPattern); + } + } + + private List getSubscribers(Object classOrTopic, Map subscriberMap) { + List result; + synchronized (listenerLock) { + List subscribers = (List) subscriberMap.get(classOrTopic); + // Make a defensive copy of subscribers and veto listeners so listeners + // can change the listener list while the listeners are being called + // Resolve WeakReferences and unsubscribe if necessary. + result = createCopyOfContentsRemoveWeakRefs(subscribers); + } + if (hasEverUsedPrioritized) { + result = sortSubscribers(result); + } + return result; + } + + private List getEventOrVetoSubscribersToClass(Map classMap, + Class eventClass) + { + List result = new ArrayList(); + Set keys = classMap.keySet(); + for (Iterator iterator = keys.iterator(); iterator.hasNext();) { + Class cl = (Class) iterator.next(); + if (cl.isAssignableFrom(eventClass)) { + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug("Hierarchical match " + cl + " matched event of class " + + eventClass); + } + Collection subscribers = (Collection) classMap.get(cl); + result.addAll(createCopyOfContentsRemoveWeakRefs(subscribers)); + } + } + return result; + } + + private List getEventOrVetoSubscribersToType(Map typeMap, Type eventType) { + List result = new ArrayList(); + Set mapKeySet = typeMap.keySet(); + for (Object mapKey : mapKeySet) { + Type subscriberType = (Type) mapKey; + if (eventType instanceof ParameterizedType && + subscriberType instanceof ParameterizedType) + { + ParameterizedType subscriberPT = (ParameterizedType) subscriberType; + ParameterizedType eventPT = (ParameterizedType) eventType; + if (eventPT.getRawType().equals(subscriberPT.getRawType())) { + Type[] mapTypeArgs = subscriberPT.getActualTypeArguments(); + Type[] eventTypeArgs = eventPT.getActualTypeArguments(); + if (mapTypeArgs == null || eventTypeArgs == null || + mapTypeArgs.length != eventTypeArgs.length) + { + continue; + } + boolean parameterArgsMatch = true; + for (int argCount = 0; argCount < mapTypeArgs.length; argCount++) { + Type eventTypeArg = eventTypeArgs[argCount]; + if (eventTypeArg instanceof WildcardType) { + throw new IllegalArgumentException( + "Only simple Class parameterized types can be published, not wildcards, etc. Published attempt made for:" + + eventTypeArg); + } + Type subscriberTypeArg = mapTypeArgs[argCount]; + if (subscriberTypeArg instanceof WildcardType) { + WildcardType wildcardSubscriberTypeArg = + (WildcardType) subscriberTypeArg; + Type[] upperBound = wildcardSubscriberTypeArg.getUpperBounds(); + Type[] lowerBound = wildcardSubscriberTypeArg.getLowerBounds(); + if (upperBound != null && upperBound.length > 0) { + if (upperBound[0] instanceof Class) { + Class upper = (Class) upperBound[0]; + if (eventTypeArg instanceof Class) { + if (!upper.isAssignableFrom((Class) eventTypeArg)) { + parameterArgsMatch = false; + break; + } + } + else { + parameterArgsMatch = false; + break; + } + } + else { + throw new IllegalArgumentException( + "Only Class and Interface types are supported as types of wildcard subscriptions. Type:" + + upperBound[0]); + } + } + if (lowerBound != null && lowerBound.length > 0) { + if (lowerBound[0] instanceof Class) { + Class lower = (Class) lowerBound[0]; + if (eventTypeArg instanceof Class) { + if (!((Class) eventTypeArg).isAssignableFrom(lower)) { + parameterArgsMatch = false; + break; + } + } + else { + parameterArgsMatch = false; + break; + } + } + else { + throw new IllegalArgumentException( + "Only Class and Interface types are supported as types of wildcard subscriptions. Type:" + + upperBound[0]); + } + } + } + else if (!subscriberTypeArg.equals(eventTypeArg)) { + parameterArgsMatch = false; + break; + } + } + if (parameterArgsMatch) { + if (LOG.isLoggable(Level.DEBUG)) { + LOG.debug( + "Exact parameterized subscriberType match for event subscriberType " + + eventType); + } + Collection subscribers = (Collection) typeMap.get(subscriberType); + if (subscribers != null) { + result.addAll(createCopyOfContentsRemoveWeakRefs(subscribers)); + } + } + } + } + } + return result; // Type o = p.getOwnerType(); // if (o != null) { // // } // p.getActualTypeArguments(); // } - /* - } else if (type instanceof TypeVariable) { - TypeVariable v = (TypeVariable)type; - out.print(v.getName()); - } else if (type instanceof GenericArrayType) { - GenericArrayType a = (GenericArrayType)type; - printType(a.getGenericComponentType()); - out.print("[]"); - } else if (type instanceof WildcardType) { - WildcardType w = (WildcardType)type; - Type[] upper = w.getUpperBounds(); - Type[] lower = w.getLowerBounds(); - if (upper.length==1 && lower.length==0) { + /* + } else if (type instanceof TypeVariable) { + TypeVariable v = (TypeVariable)type; + out.print(v.getName()); + } else if (type instanceof GenericArrayType) { + GenericArrayType a = (GenericArrayType)type; + printType(a.getGenericComponentType()); + out.print("[]"); + } else if (type instanceof WildcardType) { + WildcardType w = (WildcardType)type; + Type[] upper = w.getUpperBounds(); + Type[] lower = w.getLowerBounds(); + if (upper.length==1 && lower.length==0) { out.print("? extends "); printType(upper[0]); - } else if (upper.length==0 && lower.length==1) { + } else if (upper.length==0 && lower.length==1) { out.print("? super "); printType(lower[0]); - } else assert false; - } - */ - } - - /** - * Handle vetos of an event or topic, by default logs finely. - * - * @param vl the veto listener for an event - * @param event the event, can be null if topic is not - * @param vtl the veto listener for a topic - * @param topic can be null if event is not - * @param eventObj the object published with the topic - */ - protected void handleVeto(VetoEventListener vl, Object event, - VetoTopicEventListener vtl, String topic, Object eventObj) { - if (LOG.isLoggable(Level.DEBUG)) { - if (event != null) { - LOG.debug("Vetoing event: class=" + event.getClass() + ", event=" + event + ", vetoer:" + vl); - } else { - LOG.debug("Vetoing event: topic=" + topic + ", eventObj=" + eventObj + ", vetoer:" + vtl); - } - } - } - - /** - * Given a Map (of Lists of subscribers or veto listeners), removes the toRemove element from the List in the map for - * the given key. The entire map is checked for WeakReferences and ProxySubscribers and they are all unsubscribed - * if stale. - * - * @param map map of lists - * @param key key for a List in the map - * @param toRemove the object to remove form the list with the key of the map - * - * @return true if toRemove was unsubscribed - */ - private boolean removeFromSetResolveWeakReferences(Map map, Object key, Object toRemove) { - List subscribers = (List) map.get(key); - if (subscribers == null) { - return false; - } - if (subscribers.remove(toRemove)) { - if (toRemove instanceof WeakReference) { - decWeakRefPlusProxySubscriberCount(); - } - if (toRemove instanceof ProxySubscriber) { - ((ProxySubscriber)toRemove).proxyUnsubscribed(); - decWeakRefPlusProxySubscriberCount(); - } - return true; - } - - //search for WeakReferences and ProxySubscribers - for (Iterator iter = subscribers.iterator(); iter.hasNext();) { - Object existingSubscriber = iter.next(); - if (existingSubscriber instanceof ProxySubscriber) { - ProxySubscriber proxy = (ProxySubscriber) existingSubscriber; - existingSubscriber = proxy.getProxiedSubscriber(); - if (existingSubscriber == toRemove) { - removeProxySubscriber(proxy, iter); - return true; - } - } - if (existingSubscriber instanceof WeakReference) { - WeakReference wr = (WeakReference) existingSubscriber; - Object realRef = wr.get(); - if (realRef == null) { - //clean up a garbage collected reference - iter.remove(); - decWeakRefPlusProxySubscriberCount(); - return true; - } else if (realRef == toRemove) { - iter.remove(); - decWeakRefPlusProxySubscriberCount(); - return true; - } else if (realRef instanceof ProxySubscriber) { - ProxySubscriber proxy = (ProxySubscriber) realRef; - existingSubscriber = proxy.getProxiedSubscriber(); - if (existingSubscriber == toRemove) { - removeProxySubscriber(proxy, iter); - return true; - } - } - } - } - return false; - } - - /** - * Given a set (or subscribers or veto listeners), makes a copy of the set, resolving WeakReferences to hard - * references, and removing garbage collected references from the original set. - * - * @param subscribersOrVetoListeners - * - * @return a copy of the set - */ - private List createCopyOfContentsRemoveWeakRefs(Collection subscribersOrVetoListeners) { - if (subscribersOrVetoListeners == null) { - return null; - } - List copyOfSubscribersOrVetolisteners = new ArrayList(subscribersOrVetoListeners.size()); - for (Iterator iter = subscribersOrVetoListeners.iterator(); iter.hasNext();) { - Object elem = iter.next(); - if (elem instanceof ProxySubscriber) { - ProxySubscriber proxy = (ProxySubscriber)elem; - elem = proxy.getProxiedSubscriber(); - if (elem == null) { - removeProxySubscriber(proxy, iter); - } else { - copyOfSubscribersOrVetolisteners.add(proxy); - } - } else if (elem instanceof WeakReference) { - Object hardRef = ((WeakReference) elem).get(); - if (hardRef == null) { - //Was reclaimed, unsubscribe - iter.remove(); - decWeakRefPlusProxySubscriberCount(); - } else { - copyOfSubscribersOrVetolisteners.add(hardRef); - } - } else { - copyOfSubscribersOrVetolisteners.add(elem); - } - } - return copyOfSubscribersOrVetolisteners; - } - - /** - * Sets the default cache size for each kind of event, default is 0 (no caching). - *

    - * If this value is set to a positive number, then when an event is published, the EventService caches the event or - * topic payload data for later retrieval. This allows subscribers to find out what has most recently happened - * before they subscribed. The cached event(s) are returned from #getLastEvent(Class), #getLastTopicData(String), - * #getCachedEvents(Class), or #getCachedTopicData(String) - *

    - *

    - * The default can be overridden on a by-event-class or by-topic basis. - *

    - * - * @param defaultCacheSizePerClassOrTopic - */ - public void setDefaultCacheSizePerClassOrTopic(int defaultCacheSizePerClassOrTopic) { - synchronized (cacheLock) { - this.defaultCacheSizePerClassOrTopic = defaultCacheSizePerClassOrTopic; - } - } - - /** @return the default number of event payloads kept per event class or topic */ - public int getDefaultCacheSizePerClassOrTopic() { - synchronized (cacheLock) { - return defaultCacheSizePerClassOrTopic; - } - } - - /** - * Set the number of events cached for a particular class of event. By default, no events are cached. - *

    - * This overrides any setting for the DefaultCacheSizePerClassOrTopic. - *

    - *

    - * Class hierarchy semantics are respected. That is, if there are three events, A, X and Y, and X and Y are both - * derived from A, then setting the cache size for A applies the cache size for all three. Setting the cache size - * for X applies to X and leaves the settings for A and Y in tact. Interfaces can be passed to this method, but they - * only take effect if the cache size of a class or it's superclasses has been set. Just like Class.getInterfaces(), - * if multiple cache sizes are set, the interface names declared earliest in the implements clause of the eventClass - * takes effect. - *

    - *

    - * The cache for an event is not adjusted until the next event of that class is published. - *

    - * - * @param eventClass the class of event - * @param cacheSize the number of published events to cache for this event - */ - public void setCacheSizeForEventClass(Class eventClass, int cacheSize) { - synchronized (cacheLock) { - if (rawCacheSizesForEventClass == null) { - rawCacheSizesForEventClass = new HashMap(); - } - rawCacheSizesForEventClass.put(eventClass, new Integer(cacheSize)); - rawCacheSizesForEventClassChanged = true; - } - } - - /** - * Returns the number of events cached for a particular class of event. By default, no events are cached. - *

    - * This result is computed for a particular class from the values passed to #setCacheSizeForEventClass(Class, int), - * and respects the class hierarchy. - *

    - * - * @param eventClass the class of event - * - * @return the maximum size of the event cache for the given event class - * - * @see #setCacheSizeForEventClass(Class,int) - */ - public int getCacheSizeForEventClass(Class eventClass) { - if (eventClass == null) { - throw new IllegalArgumentException("eventClass must not be null."); - } - synchronized (cacheLock) { - if (rawCacheSizesForEventClass == null || rawCacheSizesForEventClass.size() == 0) { - return getDefaultCacheSizePerClassOrTopic(); - } - if (cacheSizesForEventClass == null) { - cacheSizesForEventClass = new HashMap(); - } - if (rawCacheSizesForEventClassChanged) { - cacheSizesForEventClass.clear(); - cacheSizesForEventClass.putAll(rawCacheSizesForEventClass); - rawCacheSizesForEventClassChanged = false; - } - - //Has this been computed yet or set directly? - Integer size = (Integer) cacheSizesForEventClass.get(eventClass); - if (size != null) { - return size.intValue(); - } else { - //must be computed - Class parent = eventClass.getSuperclass(); - while (parent != null) { - Integer parentSize = (Integer) cacheSizesForEventClass.get(parent); - if (parentSize != null) { - cacheSizesForEventClass.put(eventClass, parentSize); - return parentSize.intValue(); - } - parent = parent.getSuperclass(); - } - //try interfaces - Class[] interfaces = eventClass.getInterfaces(); - for (int i = 0; i < interfaces.length; i++) { - Class anInterface = interfaces[i]; - Integer interfaceSize = (Integer) cacheSizesForEventClass.get(anInterface); - if (interfaceSize != null) { - cacheSizesForEventClass.put(eventClass, interfaceSize); - return interfaceSize.intValue(); - } - } - } - return getDefaultCacheSizePerClassOrTopic(); - } - } - - /** - * Set the number of published data objects cached for a particular event topic. By default, no caching is done. - *

    - * This overrides any setting for the DefaultCacheSizePerClassOrTopic. - *

    - *

    - * Settings for exact topic names take precedence over pattern matching. - *

    - *

    - * The cache for a topic is not adjusted until the next publication on that topic. - *

    - * - * @param topicName the topic name - * @param cacheSize the number of published data Objects to cache for this topic - */ - public void setCacheSizeForTopic(String topicName, int cacheSize) { - synchronized (cacheLock) { - if (rawCacheSizesForTopic == null) { - rawCacheSizesForTopic = new HashMap(); - } - rawCacheSizesForTopic.put(topicName, new Integer(cacheSize)); - rawCacheSizesForTopicChanged = true; - } - } - - /** - * Set the number of published data objects cached for topics matching a pattern. By default, caching is done. - *

    - * This overrides any setting for the DefaultCacheSizePerClassOrTopic. - *

    - *

    - * Settings for exact topic names take precedence over pattern matching. If a topic matches the cache settings for - * more than one pattern, the cache size chosen is an undetermined one from one of the matched pattern settings. - *

    - *

    - * The cache for a topic is not adjusted until the next publication on that topic. - *

    - * - * @param pattern the pattern matching topic names - * @param cacheSize the number of data Objects to cache for this topic - */ - public void setCacheSizeForTopic(Pattern pattern, int cacheSize) { - synchronized (cacheLock) { - if (rawCacheSizesForPattern == null) { - rawCacheSizesForPattern = new HashMap(); - } - PatternWrapper patternWrapper = new PatternWrapper(pattern); - rawCacheSizesForPattern.put(patternWrapper, new Integer(cacheSize)); - rawCacheSizesForPatternChanged = true; - } - } - - /** - * Returns the number of cached data objects published on a particular topic. By default, no caching is performed. - *

    - * This result is computed for a particular topic from the values passed to #setCacheSizeForTopic(String, int) and - * #setCacheSizeForTopic(Pattern, int). - *

    - * - * @param topic the topic name - * - * @return the maximum size of the data Object cache for the given topic - * - * @see #setCacheSizeForTopic(String,int) - * @see #setCacheSizeForTopic(java.util.regex.Pattern,int) - */ - public int getCacheSizeForTopic(String topic) { - if (topic == null) { - throw new IllegalArgumentException("topic must not be null."); - } - synchronized (cacheLock) { - if ((rawCacheSizesForTopic == null || (rawCacheSizesForTopic != null && rawCacheSizesForTopic.size() == 0)) && - (rawCacheSizesForPattern == null || (rawCacheSizesForPattern != null && rawCacheSizesForPattern.size() == 0))) { - return getDefaultCacheSizePerClassOrTopic(); - } - if (cacheSizesForTopic == null) { - cacheSizesForTopic = new HashMap(); - } - if (rawCacheSizesForTopicChanged || rawCacheSizesForPatternChanged) { - cacheSizesForTopic.clear(); - cacheSizesForTopic.putAll(rawCacheSizesForTopic); - rawCacheSizesForTopicChanged = false; - rawCacheSizesForPatternChanged = false; - } - - //Is this an exact match or has it been matched to a pattern yet? - Integer size = cacheSizesForTopic.get(topic); - if (size != null) { - return size; - } else { - //try matching patterns - if (rawCacheSizesForPattern != null) { - Set patterns = rawCacheSizesForPattern.keySet(); - for (Iterator iterator = patterns.iterator(); iterator.hasNext();) { - PatternWrapper pattern = (PatternWrapper) iterator.next(); - if (pattern.matches(topic)) { - size = rawCacheSizesForPattern.get(pattern); - cacheSizesForTopic.put(topic, size); - return size; - } - } - } - } - return getDefaultCacheSizePerClassOrTopic(); - } - } - - /** - * @param eventClass an index into the cache, cannot be an interface - * - * @return the last event published for this event class, or null if caching is turned off (the default) - */ - public Object getLastEvent(Class eventClass) { - if (eventClass.isInterface()) { - throw new IllegalArgumentException("Interfaces are not accepted in get last event, use a specific event class."); - } - synchronized (cacheLock) { - List eventCache = cacheByEvent.get(eventClass); - if (eventCache == null || eventCache.size() == 0) { - return null; - } - return eventCache.get(0); - } - } - - /** - * @param eventClass an index into the cache, cannot be an interface - * - * @return the last events published for this event class, or null if caching is turned off (the default) - */ - public List getCachedEvents(Class eventClass) { - if (eventClass.isInterface()) { - throw new IllegalArgumentException("Interfaces are not accepted in get last event, use a specific event class."); - } - synchronized (cacheLock) { - List eventCache = cacheByEvent.get(eventClass); - if (eventCache == null || eventCache.size() == 0) { - return null; - } - return eventCache; - } - } - - /** - * @param topic an index into the cache - * - * @return the last data Object published on this topic, or null if caching is turned off (the default) - */ - public Object getLastTopicData(String topic) { - synchronized (cacheLock) { - List topicCache = cacheByTopic.get(topic); - if (topicCache == null || topicCache.size() == 0) { - return null; - } - return topicCache.get(0); - } - } - - /** - * @param topic an index into the cache - * - * @return the last data Objects published on this topic, or null if caching is turned off (the default) - */ - public List getCachedTopicData(String topic) { - synchronized (cacheLock) { - List topicCache = cacheByTopic.get(topic); - if (topicCache == null || topicCache.size() == 0) { - return null; - } - return topicCache; - } - } - - /** - * Clears the event cache for a specific event class or interface and it's any of it's subclasses or implementing - * classes. - * - * @param eventClassToClear the event class to clear the cache for - */ - public void clearCache(Class eventClassToClear) { - synchronized (cacheLock) { - Set classes = cacheByEvent.keySet(); - for (Iterator iterator = classes.iterator(); iterator.hasNext();) { - Class cachedClass = (Class) iterator.next(); - if (eventClassToClear.isAssignableFrom(cachedClass)) { - iterator.remove(); - } - } - } - } - - /** - * Clears the topic data cache for a specific topic name. - * - * @param topic the topic name to clear the cache for - */ - public void clearCache(String topic) { - synchronized (cacheLock) { - cacheByTopic.remove(topic); - } - } - - /** - * Clears the topic data cache for all topics that match a particular pattern. - * - * @param pattern the pattern to match topic caches to - */ - public void clearCache(Pattern pattern) { - synchronized (cacheLock) { - Set classes = cacheByTopic.keySet(); - for (Iterator iterator = classes.iterator(); iterator.hasNext();) { - String cachedTopic = (String) iterator.next(); - if (pattern.matcher(cachedTopic).matches()) { - iterator.remove(); - } - } - } - } - - /** Clear all event caches for all topics and event. */ - public void clearCache() { - synchronized (cacheLock) { - cacheByEvent.clear(); - cacheByTopic.clear(); - } - } - - /** Called during veto exceptions, calls handleException */ - protected void subscribeVetoException(final Object event, final String topic, final Object eventObj, - Throwable e, StackTraceElement[] callingStack, VetoEventListener vetoer) { - String str = "EventService veto event listener r:" + vetoer; - if (vetoer != null) { - str = str + ". Vetoer class:" + vetoer.getClass(); - } - handleException("vetoing", event, topic, eventObj, e, callingStack, str); - } - - /** Called during event handling exceptions, calls handleException */ - protected void onEventException(final String topic, final Object eventObj, Throwable e, - StackTraceElement[] callingStack, EventTopicSubscriber eventTopicSubscriber) { - String str = "EventService topic subscriber:" + eventTopicSubscriber; - if (eventTopicSubscriber != null) { - str = str + ". Subscriber class:" + eventTopicSubscriber.getClass(); - } - handleException("handling event", null, topic, eventObj, e, callingStack, str); - } - - /** Called during event handling exceptions, calls handleException */ - protected void handleException(final Object event, Throwable e, - StackTraceElement[] callingStack, EventSubscriber eventSubscriber) { - String str = "EventService subscriber:" + eventSubscriber; - if (eventSubscriber != null) { - str = str + ". Subscriber class:" + eventSubscriber.getClass(); - } - handleException("handling event topic", event, null, null, e, callingStack, str); - } - - /** - * All exception handling goes through this method. Logs a warning by default. - */ - protected void handleException(final String action, final Object event, final String topic, - final Object eventObj, Throwable e, StackTraceElement[] callingStack, String sourceString) { - String eventClassString = (event == null ? "none" : event.getClass().getName()); - String eventString = event + ""; - String contextMsg = "Exception " + action + " event class=" + eventClassString - + ", event=" + eventString + ", topic=" + topic + ", eventObj=" + eventObj; - SwingException clientEx = new SwingException(contextMsg, e, callingStack); - String msg = "Exception thrown by;" + sourceString; - LOG.log(Level.WARN, msg, clientEx); - } - - /** - * Unsubscribe a subscriber if it is a stale ProxySubscriber. Used during subscribe() and - * in the cleanup Timer. See the class javadoc. - *

    - * Not private since I don't claim I'm smart enough to anticipate all needs, but I - * am smart enough to doc the rules you must follow to override this method. Those - * rules may change (changes will be doc'ed), override at your own risk. - *

    - *

    - * Overriders MUST call iterator.remove() to unsubscribe the proxy if the subscriber is - * a ProxySubscriber and is stale and should be cleaned up. If the ProxySubscriber - * is unsubscribed, then implementers MUST also call proxyUnsubscribed() on the subscriber. - * Overriders MUST also remove the proxy from the weakProxySubscriber list by calling - * removeStaleProxyFromList. Method assumes caller is holding the listenerList - * lock (else how can you pass the iterator?). - *

    - * @param iterator current iterator - * @param existingSubscriber the current value of the iterator - * @return the real value of the param, or the proxied subscriber of the param if - * the param is a a ProxySubscriber - */ - protected Object getRealSubscriberAndCleanStaleSubscriberIfNecessary(Iterator iterator, Object existingSubscriber) { - ProxySubscriber existingProxySubscriber = null; - if (existingSubscriber instanceof WeakReference) { - existingSubscriber = ((WeakReference) existingSubscriber).get(); - if (existingSubscriber == null) { - iterator.remove(); - decWeakRefPlusProxySubscriberCount(); - } - } - if (existingSubscriber instanceof ProxySubscriber) { - existingProxySubscriber = (ProxySubscriber) existingSubscriber; - existingSubscriber = existingProxySubscriber.getProxiedSubscriber(); - if (existingProxySubscriber == null) { - removeProxySubscriber(existingProxySubscriber, iterator); - } - } - return existingSubscriber; - } - - protected void removeProxySubscriber(ProxySubscriber proxy, Iterator iter) { - iter.remove(); - proxy.proxyUnsubscribed(); - decWeakRefPlusProxySubscriberCount(); - } - - /** - * Increment the count of stale proxies and start a cleanup task if necessary - */ - protected void incWeakRefPlusProxySubscriberCount() { - synchronized(listenerLock) { - weakRefPlusProxySubscriberCount++; - if (cleanupStartThreshhold == null || cleanupPeriodMS == null) { - return; - } - if (weakRefPlusProxySubscriberCount >= cleanupStartThreshhold) { - startCleanup(); - } - } - } - - /** - * Decrement the count of stale proxies - */ - protected void decWeakRefPlusProxySubscriberCount() { - synchronized(listenerLock) { - weakRefPlusProxySubscriberCount--; - if (weakRefPlusProxySubscriberCount < 0) { - weakRefPlusProxySubscriberCount = 0; - } - } - } - - private void startCleanup() { - synchronized(listenerLock) { - if (cleanupTimer == null) { - cleanupTimer = new Timer(true); - } - if (cleanupTimerTask == null) { - cleanupTimerTask = new CleanupTimerTask(); - cleanupTimer.schedule(cleanupTimerTask, 0L, cleanupPeriodMS); - } - } - } - - class CleanupTimerTask extends TimerTask { - @Override - public void run() { - synchronized(listenerLock) { - if (weakRefPlusProxySubscriberCount <= cleanupStopThreshold) { - this.cancel(); - cleanupTimer = null; - cleanupTimerTask = null; - LOG.debug("Cancelled scheduled weak reference and proxy cleanup."); - return; - } - LOG.debug("Starting a weak reference and proxy cleanup."); - List allSubscriberMaps = new ArrayList(); - allSubscriberMaps.add(subscribersByEventType); - allSubscriberMaps.add(subscribersByEventClass); - allSubscriberMaps.add(subscribersByExactEventClass); - allSubscriberMaps.add(subscribersByTopic); - allSubscriberMaps.add(subscribersByTopicPattern); - allSubscriberMaps.add(vetoListenersByClass); - allSubscriberMaps.add(vetoListenersByExactClass); - allSubscriberMaps.add(vetoListenersByTopic); - allSubscriberMaps.add(vetoListenersByTopicPattern); - - int staleCount = 0; - for (Map subscriberMap : allSubscriberMaps) { - Set subscriptions = subscriberMap.keySet(); - for (Object subscription : subscriptions) { - List subscribers = (List) subscriberMap.get(subscription); - for (Iterator iter = subscribers.iterator(); iter.hasNext();) { - Object subscriber = iter.next(); - Object realSubscriber = getRealSubscriberAndCleanStaleSubscriberIfNecessary(iter, subscriber); - if (realSubscriber == null) { - staleCount++; - } - } - } - } - } - } - } - - private static class PrioritizedSubscriberComparator implements Comparator { - public int compare(Prioritized prioritized1, Prioritized prioritized2) { - if (prioritized1 == null) { - return -1; - } - if (prioritized2 == null) { - return 1; - } - if (prioritized1.getPriority() < prioritized2.getPriority()) { - return -1; - } else if (prioritized1.getPriority() > prioritized2.getPriority()) { - return 1; - } else { - return 0; - } - } - } - - /** - * Since Pattern doesn't implement equals(), we need one of these - */ - private class PatternWrapper { - private Pattern pattern; - - public PatternWrapper(Pattern pat) { - pattern = pat; - } - - public boolean matches(CharSequence input) { - return pattern.matcher(input).matches(); - } - - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - PatternWrapper that = (PatternWrapper) o; - - if (pattern != null) { - if (!pattern.equals(that.pattern)) {//give the JVM a shot for forward compatibility - return pattern.pattern() != null && this.pattern.pattern().equals(this.pattern.pattern()); - } - } else { - if (that.pattern != null) { - return false; - } - } - - return true; - } - - public int hashCode() { - if (this.pattern != null && this.pattern.pattern() != null) { - return this.pattern.pattern().hashCode(); - } - return (pattern != null ? pattern.hashCode() : 0); - } - } + } else assert false; + } + */ + } + + /** + * Handle vetos of an event or topic, by default logs finely. + * + * @param vl the veto listener for an event + * @param event the event, can be null if topic is not + * @param vtl the veto listener for a topic + * @param topic can be null if event is not + * @param eventObj the object published with the topic + */ + protected void handleVeto(VetoEventListener vl, Object event, + VetoTopicEventListener vtl, String topic, Object eventObj) + { + if (LOG.isLoggable(Level.DEBUG)) { + if (event != null) { + LOG.debug("Vetoing event: class=" + event.getClass() + ", event=" + + event + ", vetoer:" + vl); + } + else { + LOG.debug("Vetoing event: topic=" + topic + ", eventObj=" + eventObj + + ", vetoer:" + vtl); + } + } + } + + /** + * Given a Map (of Lists of subscribers or veto listeners), removes the + * toRemove element from the List in the map for the given key. The entire map + * is checked for WeakReferences and ProxySubscribers and they are all + * unsubscribed if stale. + * + * @param map map of lists + * @param key key for a List in the map + * @param toRemove the object to remove form the list with the key of the map + * @return true if toRemove was unsubscribed + */ + private boolean removeFromSetResolveWeakReferences(Map map, Object key, + Object toRemove) + { + List subscribers = (List) map.get(key); + if (subscribers == null) { + return false; + } + if (subscribers.remove(toRemove)) { + if (toRemove instanceof WeakReference) { + decWeakRefPlusProxySubscriberCount(); + } + if (toRemove instanceof ProxySubscriber) { + ((ProxySubscriber) toRemove).proxyUnsubscribed(); + decWeakRefPlusProxySubscriberCount(); + } + return true; + } + + // search for WeakReferences and ProxySubscribers + for (Iterator iter = subscribers.iterator(); iter.hasNext();) { + Object existingSubscriber = iter.next(); + if (existingSubscriber instanceof ProxySubscriber) { + ProxySubscriber proxy = (ProxySubscriber) existingSubscriber; + existingSubscriber = proxy.getProxiedSubscriber(); + if (existingSubscriber == toRemove) { + removeProxySubscriber(proxy, iter); + return true; + } + } + if (existingSubscriber instanceof WeakReference) { + WeakReference wr = (WeakReference) existingSubscriber; + Object realRef = wr.get(); + if (realRef == null) { + // clean up a garbage collected reference + iter.remove(); + decWeakRefPlusProxySubscriberCount(); + return true; + } + else if (realRef == toRemove) { + iter.remove(); + decWeakRefPlusProxySubscriberCount(); + return true; + } + else if (realRef instanceof ProxySubscriber) { + ProxySubscriber proxy = (ProxySubscriber) realRef; + existingSubscriber = proxy.getProxiedSubscriber(); + if (existingSubscriber == toRemove) { + removeProxySubscriber(proxy, iter); + return true; + } + } + } + } + return false; + } + + /** + * Given a set (or subscribers or veto listeners), makes a copy of the set, + * resolving WeakReferences to hard references, and removing garbage collected + * references from the original set. + * + * @param subscribersOrVetoListeners + * @return a copy of the set + */ + private List createCopyOfContentsRemoveWeakRefs( + Collection subscribersOrVetoListeners) + { + if (subscribersOrVetoListeners == null) { + return null; + } + List copyOfSubscribersOrVetolisteners = new ArrayList( + subscribersOrVetoListeners.size()); + for (Iterator iter = subscribersOrVetoListeners.iterator(); iter + .hasNext();) + { + Object elem = iter.next(); + if (elem instanceof ProxySubscriber) { + ProxySubscriber proxy = (ProxySubscriber) elem; + elem = proxy.getProxiedSubscriber(); + if (elem == null) { + removeProxySubscriber(proxy, iter); + } + else { + copyOfSubscribersOrVetolisteners.add(proxy); + } + } + else if (elem instanceof WeakReference) { + Object hardRef = ((WeakReference) elem).get(); + if (hardRef == null) { + // Was reclaimed, unsubscribe + iter.remove(); + decWeakRefPlusProxySubscriberCount(); + } + else { + copyOfSubscribersOrVetolisteners.add(hardRef); + } + } + else { + copyOfSubscribersOrVetolisteners.add(elem); + } + } + return copyOfSubscribersOrVetolisteners; + } + + /** + * Sets the default cache size for each kind of event, default is 0 (no + * caching). + *

    + * If this value is set to a positive number, then when an event is published, + * the EventService caches the event or topic payload data for later + * retrieval. This allows subscribers to find out what has most recently + * happened before they subscribed. The cached event(s) are returned from + * #getLastEvent(Class), #getLastTopicData(String), #getCachedEvents(Class), + * or #getCachedTopicData(String) + *

    + *

    + * The default can be overridden on a by-event-class or by-topic basis. + *

    + * + * @param defaultCacheSizePerClassOrTopic + */ + public void setDefaultCacheSizePerClassOrTopic( + int defaultCacheSizePerClassOrTopic) + { + synchronized (cacheLock) { + this.defaultCacheSizePerClassOrTopic = defaultCacheSizePerClassOrTopic; + } + } + + /** + * @return the default number of event payloads kept per event class or topic + */ + public int getDefaultCacheSizePerClassOrTopic() { + synchronized (cacheLock) { + return defaultCacheSizePerClassOrTopic; + } + } + + /** + * Set the number of events cached for a particular class of event. By + * default, no events are cached. + *

    + * This overrides any setting for the DefaultCacheSizePerClassOrTopic. + *

    + *

    + * Class hierarchy semantics are respected. That is, if there are three + * events, A, X and Y, and X and Y are both derived from A, then setting the + * cache size for A applies the cache size for all three. Setting the cache + * size for X applies to X and leaves the settings for A and Y in tact. + * Interfaces can be passed to this method, but they only take effect if the + * cache size of a class or it's superclasses has been set. Just like + * Class.getInterfaces(), if multiple cache sizes are set, the interface names + * declared earliest in the implements clause of the eventClass takes effect. + *

    + *

    + * The cache for an event is not adjusted until the next event of that class + * is published. + *

    + * + * @param eventClass the class of event + * @param cacheSize the number of published events to cache for this event + */ + public void setCacheSizeForEventClass(Class eventClass, int cacheSize) { + synchronized (cacheLock) { + if (rawCacheSizesForEventClass == null) { + rawCacheSizesForEventClass = new HashMap(); + } + rawCacheSizesForEventClass.put(eventClass, new Integer(cacheSize)); + rawCacheSizesForEventClassChanged = true; + } + } + + /** + * Returns the number of events cached for a particular class of event. By + * default, no events are cached. + *

    + * This result is computed for a particular class from the values passed to + * #setCacheSizeForEventClass(Class, int), and respects the class hierarchy. + *

    + * + * @param eventClass the class of event + * @return the maximum size of the event cache for the given event class + * @see #setCacheSizeForEventClass(Class,int) + */ + public int getCacheSizeForEventClass(Class eventClass) { + if (eventClass == null) { + throw new IllegalArgumentException("eventClass must not be null."); + } + synchronized (cacheLock) { + if (rawCacheSizesForEventClass == null || rawCacheSizesForEventClass + .size() == 0) + { + return getDefaultCacheSizePerClassOrTopic(); + } + if (cacheSizesForEventClass == null) { + cacheSizesForEventClass = new HashMap(); + } + if (rawCacheSizesForEventClassChanged) { + cacheSizesForEventClass.clear(); + cacheSizesForEventClass.putAll(rawCacheSizesForEventClass); + rawCacheSizesForEventClassChanged = false; + } + + // Has this been computed yet or set directly? + Integer size = (Integer) cacheSizesForEventClass.get(eventClass); + if (size != null) { + return size.intValue(); + } + else { + // must be computed + Class parent = eventClass.getSuperclass(); + while (parent != null) { + Integer parentSize = (Integer) cacheSizesForEventClass.get(parent); + if (parentSize != null) { + cacheSizesForEventClass.put(eventClass, parentSize); + return parentSize.intValue(); + } + parent = parent.getSuperclass(); + } + // try interfaces + Class[] interfaces = eventClass.getInterfaces(); + for (int i = 0; i < interfaces.length; i++) { + Class anInterface = interfaces[i]; + Integer interfaceSize = (Integer) cacheSizesForEventClass.get( + anInterface); + if (interfaceSize != null) { + cacheSizesForEventClass.put(eventClass, interfaceSize); + return interfaceSize.intValue(); + } + } + } + return getDefaultCacheSizePerClassOrTopic(); + } + } + + /** + * Set the number of published data objects cached for a particular event + * topic. By default, no caching is done. + *

    + * This overrides any setting for the DefaultCacheSizePerClassOrTopic. + *

    + *

    + * Settings for exact topic names take precedence over pattern matching. + *

    + *

    + * The cache for a topic is not adjusted until the next publication on that + * topic. + *

    + * + * @param topicName the topic name + * @param cacheSize the number of published data Objects to cache for this + * topic + */ + public void setCacheSizeForTopic(String topicName, int cacheSize) { + synchronized (cacheLock) { + if (rawCacheSizesForTopic == null) { + rawCacheSizesForTopic = new HashMap(); + } + rawCacheSizesForTopic.put(topicName, new Integer(cacheSize)); + rawCacheSizesForTopicChanged = true; + } + } + + /** + * Set the number of published data objects cached for topics matching a + * pattern. By default, caching is done. + *

    + * This overrides any setting for the DefaultCacheSizePerClassOrTopic. + *

    + *

    + * Settings for exact topic names take precedence over pattern matching. If a + * topic matches the cache settings for more than one pattern, the cache size + * chosen is an undetermined one from one of the matched pattern settings. + *

    + *

    + * The cache for a topic is not adjusted until the next publication on that + * topic. + *

    + * + * @param pattern the pattern matching topic names + * @param cacheSize the number of data Objects to cache for this topic + */ + public void setCacheSizeForTopic(Pattern pattern, int cacheSize) { + synchronized (cacheLock) { + if (rawCacheSizesForPattern == null) { + rawCacheSizesForPattern = new HashMap(); + } + PatternWrapper patternWrapper = new PatternWrapper(pattern); + rawCacheSizesForPattern.put(patternWrapper, new Integer(cacheSize)); + rawCacheSizesForPatternChanged = true; + } + } + + /** + * Returns the number of cached data objects published on a particular topic. + * By default, no caching is performed. + *

    + * This result is computed for a particular topic from the values passed to + * #setCacheSizeForTopic(String, int) and #setCacheSizeForTopic(Pattern, int). + *

    + * + * @param topic the topic name + * @return the maximum size of the data Object cache for the given topic + * @see #setCacheSizeForTopic(String,int) + * @see #setCacheSizeForTopic(java.util.regex.Pattern,int) + */ + public int getCacheSizeForTopic(String topic) { + if (topic == null) { + throw new IllegalArgumentException("topic must not be null."); + } + synchronized (cacheLock) { + if ((rawCacheSizesForTopic == null || (rawCacheSizesForTopic != null && + rawCacheSizesForTopic.size() == 0)) && + (rawCacheSizesForPattern == null || (rawCacheSizesForPattern != null && + rawCacheSizesForPattern.size() == 0))) + { + return getDefaultCacheSizePerClassOrTopic(); + } + if (cacheSizesForTopic == null) { + cacheSizesForTopic = new HashMap(); + } + if (rawCacheSizesForTopicChanged || rawCacheSizesForPatternChanged) { + cacheSizesForTopic.clear(); + cacheSizesForTopic.putAll(rawCacheSizesForTopic); + rawCacheSizesForTopicChanged = false; + rawCacheSizesForPatternChanged = false; + } + + // Is this an exact match or has it been matched to a pattern yet? + Integer size = cacheSizesForTopic.get(topic); + if (size != null) { + return size; + } + else { + // try matching patterns + if (rawCacheSizesForPattern != null) { + Set patterns = rawCacheSizesForPattern.keySet(); + for (Iterator iterator = patterns.iterator(); iterator.hasNext();) { + PatternWrapper pattern = (PatternWrapper) iterator.next(); + if (pattern.matches(topic)) { + size = rawCacheSizesForPattern.get(pattern); + cacheSizesForTopic.put(topic, size); + return size; + } + } + } + } + return getDefaultCacheSizePerClassOrTopic(); + } + } + + /** + * @param eventClass an index into the cache, cannot be an interface + * @return the last event published for this event class, or null if caching + * is turned off (the default) + */ + public Object getLastEvent(Class eventClass) { + if (eventClass.isInterface()) { + throw new IllegalArgumentException( + "Interfaces are not accepted in get last event, use a specific event class."); + } + synchronized (cacheLock) { + List eventCache = cacheByEvent.get(eventClass); + if (eventCache == null || eventCache.size() == 0) { + return null; + } + return eventCache.get(0); + } + } + + /** + * @param eventClass an index into the cache, cannot be an interface + * @return the last events published for this event class, or null if caching + * is turned off (the default) + */ + public List getCachedEvents(Class eventClass) { + if (eventClass.isInterface()) { + throw new IllegalArgumentException( + "Interfaces are not accepted in get last event, use a specific event class."); + } + synchronized (cacheLock) { + List eventCache = cacheByEvent.get(eventClass); + if (eventCache == null || eventCache.size() == 0) { + return null; + } + return eventCache; + } + } + + /** + * @param topic an index into the cache + * @return the last data Object published on this topic, or null if caching is + * turned off (the default) + */ + public Object getLastTopicData(String topic) { + synchronized (cacheLock) { + List topicCache = cacheByTopic.get(topic); + if (topicCache == null || topicCache.size() == 0) { + return null; + } + return topicCache.get(0); + } + } + + /** + * @param topic an index into the cache + * @return the last data Objects published on this topic, or null if caching + * is turned off (the default) + */ + public List getCachedTopicData(String topic) { + synchronized (cacheLock) { + List topicCache = cacheByTopic.get(topic); + if (topicCache == null || topicCache.size() == 0) { + return null; + } + return topicCache; + } + } + + /** + * Clears the event cache for a specific event class or interface and it's any + * of it's subclasses or implementing classes. + * + * @param eventClassToClear the event class to clear the cache for + */ + public void clearCache(Class eventClassToClear) { + synchronized (cacheLock) { + Set classes = cacheByEvent.keySet(); + for (Iterator iterator = classes.iterator(); iterator.hasNext();) { + Class cachedClass = (Class) iterator.next(); + if (eventClassToClear.isAssignableFrom(cachedClass)) { + iterator.remove(); + } + } + } + } + + /** + * Clears the topic data cache for a specific topic name. + * + * @param topic the topic name to clear the cache for + */ + public void clearCache(String topic) { + synchronized (cacheLock) { + cacheByTopic.remove(topic); + } + } + + /** + * Clears the topic data cache for all topics that match a particular pattern. + * + * @param pattern the pattern to match topic caches to + */ + public void clearCache(Pattern pattern) { + synchronized (cacheLock) { + Set classes = cacheByTopic.keySet(); + for (Iterator iterator = classes.iterator(); iterator.hasNext();) { + String cachedTopic = (String) iterator.next(); + if (pattern.matcher(cachedTopic).matches()) { + iterator.remove(); + } + } + } + } + + /** Clear all event caches for all topics and event. */ + public void clearCache() { + synchronized (cacheLock) { + cacheByEvent.clear(); + cacheByTopic.clear(); + } + } + + /** Called during veto exceptions, calls handleException */ + protected void subscribeVetoException(final Object event, final String topic, + final Object eventObj, Throwable e, StackTraceElement[] callingStack, + VetoEventListener vetoer) + { + String str = "EventService veto event listener r:" + vetoer; + if (vetoer != null) { + str = str + ". Vetoer class:" + vetoer.getClass(); + } + handleException("vetoing", event, topic, eventObj, e, callingStack, str); + } + + /** Called during event handling exceptions, calls handleException */ + protected void onEventException(final String topic, final Object eventObj, + Throwable e, StackTraceElement[] callingStack, + EventTopicSubscriber eventTopicSubscriber) + { + String str = "EventService topic subscriber:" + eventTopicSubscriber; + if (eventTopicSubscriber != null) { + str = str + ". Subscriber class:" + eventTopicSubscriber.getClass(); + } + handleException("handling event", null, topic, eventObj, e, callingStack, + str); + } + + /** Called during event handling exceptions, calls handleException */ + protected void handleException(final Object event, Throwable e, + StackTraceElement[] callingStack, EventSubscriber eventSubscriber) + { + String str = "EventService subscriber:" + eventSubscriber; + if (eventSubscriber != null) { + str = str + ". Subscriber class:" + eventSubscriber.getClass(); + } + handleException("handling event topic", event, null, null, e, callingStack, + str); + } + + /** + * All exception handling goes through this method. Logs a warning by default. + */ + protected void handleException(final String action, final Object event, + final String topic, final Object eventObj, Throwable e, + StackTraceElement[] callingStack, String sourceString) + { + String eventClassString = (event == null ? "none" : event.getClass() + .getName()); + String eventString = event + ""; + String contextMsg = "Exception " + action + " event class=" + + eventClassString + ", event=" + eventString + ", topic=" + topic + + ", eventObj=" + eventObj; + SwingException clientEx = new SwingException(contextMsg, e, callingStack); + String msg = "Exception thrown by;" + sourceString; + LOG.log(Level.WARN, msg, clientEx); + } + + /** + * Unsubscribe a subscriber if it is a stale ProxySubscriber. Used during + * subscribe() and in the cleanup Timer. See the class javadoc. + *

    + * Not private since I don't claim I'm smart enough to anticipate all needs, + * but I am smart enough to doc the rules you must follow to override this + * method. Those rules may change (changes will be doc'ed), override at your + * own risk. + *

    + *

    + * Overriders MUST call iterator.remove() to unsubscribe the proxy if the + * subscriber is a ProxySubscriber and is stale and should be cleaned up. If + * the ProxySubscriber is unsubscribed, then implementers MUST also call + * proxyUnsubscribed() on the subscriber. Overriders MUST also remove the + * proxy from the weakProxySubscriber list by calling + * removeStaleProxyFromList. Method assumes caller is holding the listenerList + * lock (else how can you pass the iterator?). + *

    + * + * @param iterator current iterator + * @param existingSubscriber the current value of the iterator + * @return the real value of the param, or the proxied subscriber of the param + * if the param is a a ProxySubscriber + */ + protected Object getRealSubscriberAndCleanStaleSubscriberIfNecessary( + Iterator iterator, Object existingSubscriber) + { + ProxySubscriber existingProxySubscriber = null; + if (existingSubscriber instanceof WeakReference) { + existingSubscriber = ((WeakReference) existingSubscriber).get(); + if (existingSubscriber == null) { + iterator.remove(); + decWeakRefPlusProxySubscriberCount(); + } + } + if (existingSubscriber instanceof ProxySubscriber) { + existingProxySubscriber = (ProxySubscriber) existingSubscriber; + existingSubscriber = existingProxySubscriber.getProxiedSubscriber(); + if (existingProxySubscriber == null) { + removeProxySubscriber(existingProxySubscriber, iterator); + } + } + return existingSubscriber; + } + + protected void removeProxySubscriber(ProxySubscriber proxy, Iterator iter) { + iter.remove(); + proxy.proxyUnsubscribed(); + decWeakRefPlusProxySubscriberCount(); + } + + /** + * Increment the count of stale proxies and start a cleanup task if necessary + */ + protected void incWeakRefPlusProxySubscriberCount() { + synchronized (listenerLock) { + weakRefPlusProxySubscriberCount++; + if (cleanupStartThreshhold == null || cleanupPeriodMS == null) { + return; + } + if (weakRefPlusProxySubscriberCount >= cleanupStartThreshhold) { + startCleanup(); + } + } + } + + /** + * Decrement the count of stale proxies + */ + protected void decWeakRefPlusProxySubscriberCount() { + synchronized (listenerLock) { + weakRefPlusProxySubscriberCount--; + if (weakRefPlusProxySubscriberCount < 0) { + weakRefPlusProxySubscriberCount = 0; + } + } + } + + private void startCleanup() { + synchronized (listenerLock) { + if (cleanupTimer == null) { + cleanupTimer = new Timer(true); + } + if (cleanupTimerTask == null) { + cleanupTimerTask = new CleanupTimerTask(); + cleanupTimer.schedule(cleanupTimerTask, 0L, cleanupPeriodMS); + } + } + } + + class CleanupTimerTask extends TimerTask { + + @Override + public void run() { + synchronized (listenerLock) { + if (weakRefPlusProxySubscriberCount <= cleanupStopThreshold) { + this.cancel(); + cleanupTimer = null; + cleanupTimerTask = null; + LOG.debug("Cancelled scheduled weak reference and proxy cleanup."); + return; + } + LOG.debug("Starting a weak reference and proxy cleanup."); + List allSubscriberMaps = new ArrayList(); + allSubscriberMaps.add(subscribersByEventType); + allSubscriberMaps.add(subscribersByEventClass); + allSubscriberMaps.add(subscribersByExactEventClass); + allSubscriberMaps.add(subscribersByTopic); + allSubscriberMaps.add(subscribersByTopicPattern); + allSubscriberMaps.add(vetoListenersByClass); + allSubscriberMaps.add(vetoListenersByExactClass); + allSubscriberMaps.add(vetoListenersByTopic); + allSubscriberMaps.add(vetoListenersByTopicPattern); + + int staleCount = 0; + for (Map subscriberMap : allSubscriberMaps) { + Set subscriptions = subscriberMap.keySet(); + for (Object subscription : subscriptions) { + List subscribers = (List) subscriberMap.get(subscription); + for (Iterator iter = subscribers.iterator(); iter.hasNext();) { + Object subscriber = iter.next(); + Object realSubscriber = + getRealSubscriberAndCleanStaleSubscriberIfNecessary(iter, + subscriber); + if (realSubscriber == null) { + staleCount++; + } + } + } + } + } + } + } + + private static class PrioritizedSubscriberComparator implements + Comparator + { + + public int compare(Prioritized prioritized1, Prioritized prioritized2) { + if (prioritized1 == null) { + return -1; + } + if (prioritized2 == null) { + return 1; + } + if (prioritized1.getPriority() < prioritized2.getPriority()) { + return -1; + } + else if (prioritized1.getPriority() > prioritized2.getPriority()) { + return 1; + } + else { + return 0; + } + } + } + + /** + * Since Pattern doesn't implement equals(), we need one of these + */ + private class PatternWrapper { + + private Pattern pattern; + + public PatternWrapper(Pattern pat) { + pattern = pat; + } + + public boolean matches(CharSequence input) { + return pattern.matcher(input).matches(); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + PatternWrapper that = (PatternWrapper) o; + + if (pattern != null) { + if (!pattern.equals(that.pattern)) {// give the JVM a shot for forward + // compatibility + return pattern.pattern() != null && this.pattern.pattern().equals( + this.pattern.pattern()); + } + } + else { + if (that.pattern != null) { + return false; + } + } + + return true; + } + + public int hashCode() { + if (this.pattern != null && this.pattern.pattern() != null) { + return this.pattern.pattern().hashCode(); + } + return (pattern != null ? pattern.hashCode() : 0); + } + } } diff --git a/src/main/java/org/scijava/event/bushe/TypeReference.java b/src/main/java/org/scijava/event/bushe/TypeReference.java index 06ff73a8c..074ad6386 100644 --- a/src/main/java/org/scijava/event/bushe/TypeReference.java +++ b/src/main/java/org/scijava/event/bushe/TypeReference.java @@ -1,3 +1,4 @@ + package org.scijava.event.bushe; import java.lang.reflect.Type; @@ -6,47 +7,45 @@ import java.lang.reflect.InvocationTargetException; /** - * Courtesy of Neil Gafter's blog. - * Thanks to Curt Cox for the pointer. + * Courtesy of Neil Gafter's blog. Thanks to Curt Cox for the pointer. */ abstract class TypeReference { - private final Type type; - private volatile Constructor constructor; + private final Type type; + private volatile Constructor constructor; - protected TypeReference() { - Type superclass = getClass().getGenericSuperclass(); - if (superclass instanceof Class) { - throw new RuntimeException("Missing type parameter."); - } - this.type = ((ParameterizedType) superclass).getActualTypeArguments()[0]; - } + protected TypeReference() { + Type superclass = getClass().getGenericSuperclass(); + if (superclass instanceof Class) { + throw new RuntimeException("Missing type parameter."); + } + this.type = ((ParameterizedType) superclass).getActualTypeArguments()[0]; + } - /** - * @return a new instance of {@code T} using the default, no-arg - * constructor. - * @throws IllegalAccessException on security reflection issues - * @throws NoSuchMethodException there's not getRawType on the type - * @throws java.lang.reflect.InvocationTargetException if a reflective call causes an exception in the underlying instance - * @throws InstantiationException if the instance cannot be instantiated - */ - @SuppressWarnings("unchecked") - public T newInstance() - throws NoSuchMethodException, IllegalAccessException, - InvocationTargetException, InstantiationException { - if (constructor == null) { - Class rawType = type instanceof Class - ? (Class) type - : (Class) ((ParameterizedType) type).getRawType(); - constructor = rawType.getConstructor(); - } - return (T) constructor.newInstance(); - } + /** + * @return a new instance of {@code T} using the default, no-arg constructor. + * @throws IllegalAccessException on security reflection issues + * @throws NoSuchMethodException there's not getRawType on the type + * @throws java.lang.reflect.InvocationTargetException if a reflective call + * causes an exception in the underlying instance + * @throws InstantiationException if the instance cannot be instantiated + */ + @SuppressWarnings("unchecked") + public T newInstance() throws NoSuchMethodException, IllegalAccessException, + InvocationTargetException, InstantiationException + { + if (constructor == null) { + Class rawType = type instanceof Class ? (Class) type + : (Class) ((ParameterizedType) type).getRawType(); + constructor = rawType.getConstructor(); + } + return (T) constructor.newInstance(); + } - /** - * @return the referenced type. - */ - public Type getType() { - return this.type; - } + /** + * @return the referenced type. + */ + public Type getType() { + return this.type; + } } diff --git a/src/main/java/org/scijava/event/bushe/VetoEventListener.java b/src/main/java/org/scijava/event/bushe/VetoEventListener.java index 4b377c1c1..4289fa288 100644 --- a/src/main/java/org/scijava/event/bushe/VetoEventListener.java +++ b/src/main/java/org/scijava/event/bushe/VetoEventListener.java @@ -13,27 +13,36 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.scijava.event.bushe; /** - * Interface for classes that can veto class-based event publication from the {@link EventService}. + * Interface for classes that can veto class-based event publication from the + * {@link EventService}. * * @author Michael Bushe michael@bushe.com */ interface VetoEventListener { - /** - * Determine whether an event should be vetoed or published. - *

    - * The EventService calls this method before class-based publication of objects. If any of the - * VetoEventListeners return true, then none of the subscribers for that event are called.

    Prerequisite: - * VetoEventListener has to be subscribed with the EventService for the event object's class.

    Guaranteed to be - * called in the SwingEventThread when using the SwingEventService (EventBus). See {@link EventService}

    - *

    - * - * @param event The event object to veto or allow to be published. - * - * @return true if the event should be vetoed and not published, false if the event should be published. - */ - public boolean shouldVeto(T event); + /** + * Determine whether an event should be vetoed or published. + *

    + * The EventService calls this method before class-based publication of + * objects. If any of the VetoEventListeners return true, then none of the + * subscribers for that event are called. + *

    + * Prerequisite: VetoEventListener has to be subscribed with the EventService + * for the event object's class. + *

    + *

    + * Guaranteed to be called in the SwingEventThread when using the + * SwingEventService (EventBus). See {@link EventService} + *

    + *

    + * + * @param event The event object to veto or allow to be published. + * @return true if the event should be vetoed and not published, false if the + * event should be published. + */ + public boolean shouldVeto(T event); } diff --git a/src/main/java/org/scijava/event/bushe/VetoTopicEventListener.java b/src/main/java/org/scijava/event/bushe/VetoTopicEventListener.java index f44d9693a..febd5c6e2 100644 --- a/src/main/java/org/scijava/event/bushe/VetoTopicEventListener.java +++ b/src/main/java/org/scijava/event/bushe/VetoTopicEventListener.java @@ -1,26 +1,34 @@ + package org.scijava.event.bushe; /** - * Interface for classes that can veto publication on topic names from the {@link org.scijava.event.bushe.EventService}. + * Interface for classes that can veto publication on topic names from the + * {@link org.scijava.event.bushe.EventService}. * * @author Michael Bushe michael@bushe.com */ interface VetoTopicEventListener { - /** - * Determine whether a topic publication should be vetoed or allowed. - *

    - * The EventService calls this method before publication of on a topic name. If any of the - * VetoTopicEventListeners return true, then none of the subscribers to that topic are called.

    Prerequisite: - * VetoTopicEventListener has to be subscribed with the EventService for the topic name.

    Guaranteed to be - * called in the SwingEventThread when using the SwingEventService (EventBus). See {@link EventService}

    - *

    - * - * @param topic The topic name the data object is published on. - * @param data The data object being published on the topic. - * - * @return true if the publication on the topic should be vetoed and not published, false if the data should be - * published on the topic. - */ - public boolean shouldVeto(String topic, T data); + /** + * Determine whether a topic publication should be vetoed or allowed. + *

    + * The EventService calls this method before publication of on a topic + * name. If any of the VetoTopicEventListeners return true, then none of the + * subscribers to that topic are called. + *

    + * Prerequisite: VetoTopicEventListener has to be subscribed with the + * EventService for the topic name. + *

    + *

    + * Guaranteed to be called in the SwingEventThread when using the + * SwingEventService (EventBus). See {@link EventService} + *

    + *

    + * + * @param topic The topic name the data object is published on. + * @param data The data object being published on the topic. + * @return true if the publication on the topic should be vetoed and not + * published, false if the data should be published on the topic. + */ + public boolean shouldVeto(String topic, T data); } diff --git a/src/main/java/org/scijava/input/Accelerator.java b/src/main/java/org/scijava/input/Accelerator.java index c1296cfb6..574605316 100644 --- a/src/main/java/org/scijava/input/Accelerator.java +++ b/src/main/java/org/scijava/input/Accelerator.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * A keyboard shortcut, consisting of a {@link KeyCode} plus * {@link InputModifiers}. - * + * * @author Curtis Rueden * @author Barry DeZonia */ @@ -92,14 +92,14 @@ public String toString() { /** * Creates an accelerator from the given string representation. The string * must have the following syntax: - * + * *
     	 * 	    <modifiers>* <keyCode>
    -	 * 
    +	 *
     	 * 	    modifiers := alt | altGraph | control | meta | shift
     	 * 	    keyCode := {@link KeyCode} field (e.g., COMMA or UP)
     	 * 
    - * + * * For convenience: *
      *
    • "control" may be shortened to "ctrl"
    • @@ -114,7 +114,7 @@ public String toString() { *
    • "alt shift X"
    • *
    • "^C"
    • *
    - * + * * @see javax.swing.KeyStroke#getKeyStroke(String) for the syntax from which * this one is derived. * @see KeyCode for the complete list of special character codes. @@ -133,13 +133,13 @@ public static Accelerator create(final String acc) { boolean ctrl = false, meta = false, shift = false; for (int i = 0; i < components.length - 1; i++) { if (components[i].equalsIgnoreCase("alt")) alt = true; - else if (components[i].equalsIgnoreCase("altGr") || - components[i].equalsIgnoreCase("altGraph")) + else if (components[i].equalsIgnoreCase("altGr") || components[i] + .equalsIgnoreCase("altGraph")) { altGr = true; } - else if (components[i].equalsIgnoreCase("control") || - components[i].equalsIgnoreCase("ctrl")) + else if (components[i].equalsIgnoreCase("control") || components[i] + .equalsIgnoreCase("ctrl")) { ctrl = true; } @@ -147,8 +147,8 @@ else if (components[i].equalsIgnoreCase("control") || else if (components[i].equalsIgnoreCase("shift")) shift = true; } - final InputModifiers modifiers = - new InputModifiers(alt, altGr, ctrl, meta, shift, false, false, false); + final InputModifiers modifiers = new InputModifiers(alt, altGr, ctrl, meta, + shift, false, false, false); // upper case the key code final String code = components[components.length - 1].toUpperCase(); diff --git a/src/main/java/org/scijava/input/DefaultInputService.java b/src/main/java/org/scijava/input/DefaultInputService.java index 2b3506c07..5790dac49 100644 --- a/src/main/java/org/scijava/input/DefaultInputService.java +++ b/src/main/java/org/scijava/input/DefaultInputService.java @@ -6,13 +6,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 @@ -48,7 +48,7 @@ /** * Default implementation of {@link InputService}. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) diff --git a/src/main/java/org/scijava/input/InputModifiers.java b/src/main/java/org/scijava/input/InputModifiers.java index 21df50b23..357045136 100644 --- a/src/main/java/org/scijava/input/InputModifiers.java +++ b/src/main/java/org/scijava/input/InputModifiers.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * A UI-independent representation of keyboard and mouse modifier states. - * + * * @author Curtis Rueden */ public class InputModifiers { diff --git a/src/main/java/org/scijava/input/InputService.java b/src/main/java/org/scijava/input/InputService.java index a38c638bc..4b377cb82 100644 --- a/src/main/java/org/scijava/input/InputService.java +++ b/src/main/java/org/scijava/input/InputService.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * Interface for service that tracks the current status of input devices * (keyboard and mouse in particular). - * + * * @author Barry DeZonia * @author Curtis Rueden */ @@ -63,7 +63,7 @@ default EventService eventService() { /** * Gets the display associated with the last observed mouse cursor. - * + * * @return The display in question, or null if the display has been deleted, * or the mouse cursor is outside all known displays, or no mouse * events have ever been observed. @@ -73,7 +73,7 @@ default EventService eventService() { /** * Gets the last observed X coordinate of the mouse cursor, relative to a * specific display. - * + * * @see #getDisplay() */ int getX(); @@ -81,14 +81,14 @@ default EventService eventService() { /** * Gets the last observed Y coordinate of the mouse cursor, relative to a * specific display. - * + * * @see #getDisplay() */ int getY(); /** * Gets whether the given mouse button is currently pressed. - * + * * @param button One of: *
      *
    • {@link MsButtonEvent#LEFT_BUTTON}
    • diff --git a/src/main/java/org/scijava/input/KeyCode.java b/src/main/java/org/scijava/input/KeyCode.java index 2c2dc7444..85d898e76 100644 --- a/src/main/java/org/scijava/input/KeyCode.java +++ b/src/main/java/org/scijava/input/KeyCode.java @@ -6,13 +6,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 @@ -34,575 +34,573 @@ /** * A UI-independent enumeration of keyboard key codes. - * + * * @author Curtis Rueden */ public enum KeyCode { - /** Enter (a.k.a. Return). */ - ENTER(0x0a), + /** Enter (a.k.a. Return). */ + ENTER(0x0a), - /** Backspace. */ - BACK_SPACE(0x08), + /** Backspace. */ + BACK_SPACE(0x08), - /** Tab. */ - TAB(0x09), + /** Tab. */ + TAB(0x09), - /** Cancel. */ - CANCEL(0x03), + /** Cancel. */ + CANCEL(0x03), - /** Clear. */ - CLEAR(0x0C), + /** Clear. */ + CLEAR(0x0C), - /** Shift (left or right). */ - SHIFT(0x10), + /** Shift (left or right). */ + SHIFT(0x10), - /** Control (left or right). */ - CONTROL(0x11), + /** Control (left or right). */ + CONTROL(0x11), - /** Alt (left or right). */ - ALT(0x12), + /** Alt (left or right). */ + ALT(0x12), - /** Pause. */ - PAUSE(0x13), + /** Pause. */ + PAUSE(0x13), - /** Caps Lock. */ - CAPS_LOCK(0x14), + /** Caps Lock. */ + CAPS_LOCK(0x14), - /** Escape. */ - ESCAPE(0x1B), + /** Escape. */ + ESCAPE(0x1B), - /** Space (' '). */ - SPACE(0x20), + /** Space (' '). */ + SPACE(0x20), - /** Page Up. */ - PAGE_UP(0x21), + /** Page Up. */ + PAGE_UP(0x21), - /** Page Down. */ - PAGE_DOWN(0x22), + /** Page Down. */ + PAGE_DOWN(0x22), - /** End. */ - END(0x23), + /** End. */ + END(0x23), - /** Home. */ - HOME(0x24), + /** Home. */ + HOME(0x24), - /** Left arrow (non-numpad). */ - LEFT(0x25), + /** Left arrow (non-numpad). */ + LEFT(0x25), - /** Up arrow (non-numpad). */ - UP(0x26), + /** Up arrow (non-numpad). */ + UP(0x26), - /** Right arrow (non-numpad). */ - RIGHT(0x27), + /** Right arrow (non-numpad). */ + RIGHT(0x27), - /** Down arrow (non-numpad). */ - DOWN(0x28), + /** Down arrow (non-numpad). */ + DOWN(0x28), - /** Comma (','). */ - COMMA(0x2C), + /** Comma (','). */ + COMMA(0x2C), - /** Minus ('-'). */ - MINUS(0x2D), + /** Minus ('-'). */ + MINUS(0x2D), - /** Period ('.'). */ - PERIOD(0x2E), + /** Period ('.'). */ + PERIOD(0x2E), - /** Forward slash ('/'). */ - SLASH(0x2F), + /** Forward slash ('/'). */ + SLASH(0x2F), - /** Zero ('0', non-numpad). */ - NUM0(0x30), + /** Zero ('0', non-numpad). */ + NUM0(0x30), - /** One ('1', non-numpad). */ - NUM1(0x31), + /** One ('1', non-numpad). */ + NUM1(0x31), - /** Two ('2', non-numpad). */ - NUM2(0x32), + /** Two ('2', non-numpad). */ + NUM2(0x32), - /** Three ('3', non-numpad). */ - NUM3(0x33), + /** Three ('3', non-numpad). */ + NUM3(0x33), - /** Four ('4', non-numpad). */ - NUM4(0x34), + /** Four ('4', non-numpad). */ + NUM4(0x34), - /** Five ('5', non-numpad). */ - NUM5(0x35), + /** Five ('5', non-numpad). */ + NUM5(0x35), - /** Six ('6', non-numpad). */ - NUM6(0x36), + /** Six ('6', non-numpad). */ + NUM6(0x36), - /** Seven ('7', non-numpad). */ - NUM7(0x37), + /** Seven ('7', non-numpad). */ + NUM7(0x37), - /** Eight ('8', non-numpad). */ - NUM8(0x38), + /** Eight ('8', non-numpad). */ + NUM8(0x38), - /** Nine ('9', non-numpad). */ - NUM9(0x39), + /** Nine ('9', non-numpad). */ + NUM9(0x39), - /** Semicolon (';'). */ - SEMICOLON(0x3B), + /** Semicolon (';'). */ + SEMICOLON(0x3B), - /** Equals ('='). */ - EQUALS(0x3D), + /** Equals ('='). */ + EQUALS(0x3D), - /** The letter A. */ - A(0x41), + /** The letter A. */ + A(0x41), - /** The letter B. */ - B(0x42), + /** The letter B. */ + B(0x42), - /** The letter C. */ - C(0x43), + /** The letter C. */ + C(0x43), - /** The letter D. */ - D(0x44), + /** The letter D. */ + D(0x44), - /** The letter E. */ - E(0x45), + /** The letter E. */ + E(0x45), - /** The letter F. */ - F(0x46), + /** The letter F. */ + F(0x46), - /** The letter G. */ - G(0x47), + /** The letter G. */ + G(0x47), - /** The letter H. */ - H(0x48), + /** The letter H. */ + H(0x48), - /** The letter I. */ - I(0x49), + /** The letter I. */ + I(0x49), - /** The letter J. */ - J(0x4A), + /** The letter J. */ + J(0x4A), - /** The letter K. */ - K(0x4B), + /** The letter K. */ + K(0x4B), - /** The letter L. */ - L(0x4C), + /** The letter L. */ + L(0x4C), - /** The letter M. */ - M(0x4D), + /** The letter M. */ + M(0x4D), - /** The letter N. */ - N(0x4E), + /** The letter N. */ + N(0x4E), - /** The letter O. */ - O(0x4F), + /** The letter O. */ + O(0x4F), - /** The letter P. */ - P(0x50), + /** The letter P. */ + P(0x50), - /** The letter Q. */ - Q(0x51), + /** The letter Q. */ + Q(0x51), - /** The letter R. */ - R(0x52), + /** The letter R. */ + R(0x52), - /** The letter S. */ - S(0x53), + /** The letter S. */ + S(0x53), - /** The letter T. */ - T(0x54), + /** The letter T. */ + T(0x54), - /** The letter U. */ - U(0x55), + /** The letter U. */ + U(0x55), - /** The letter V. */ - V(0x56), + /** The letter V. */ + V(0x56), - /** The letter W. */ - W(0x57), + /** The letter W. */ + W(0x57), - /** The letter X. */ - X(0x58), + /** The letter X. */ + X(0x58), - /** The letter Y. */ - Y(0x59), + /** The letter Y. */ + Y(0x59), - /** The letter Z. */ - Z(0x5A), + /** The letter Z. */ + Z(0x5A), - /** Left bracket ('['). */ - OPEN_BRACKET(0x5B), + /** Left bracket ('['). */ + OPEN_BRACKET(0x5B), - /** Backslash ('\\'). */ - BACK_SLASH(0x5C), + /** Backslash ('\\'). */ + BACK_SLASH(0x5C), - /** Right bracket (']'). */ - CLOSE_BRACKET(0x5D), + /** Right bracket (']'). */ + CLOSE_BRACKET(0x5D), - /** Zero ('0') on numeric keypad. */ - NUMPAD_0(0x60), + /** Zero ('0') on numeric keypad. */ + NUMPAD_0(0x60), - /** One ('1') on numeric keypad. */ - NUMPAD_1(0x61), + /** One ('1') on numeric keypad. */ + NUMPAD_1(0x61), - /** Two ('2') on numeric keypad. */ - NUMPAD_2(0x62), + /** Two ('2') on numeric keypad. */ + NUMPAD_2(0x62), - /** Three ('3') on numeric keypad. */ - NUMPAD_3(0x63), + /** Three ('3') on numeric keypad. */ + NUMPAD_3(0x63), - /** Four ('4') on numeric keypad. */ - NUMPAD_4(0x64), + /** Four ('4') on numeric keypad. */ + NUMPAD_4(0x64), - /** Five ('5') on numeric keypad. */ - NUMPAD_5(0x65), + /** Five ('5') on numeric keypad. */ + NUMPAD_5(0x65), - /** Six ('6') on numeric keypad. */ - NUMPAD_6(0x66), + /** Six ('6') on numeric keypad. */ + NUMPAD_6(0x66), - /** Seven ('7') on numeric keypad. */ - NUMPAD_7(0x67), + /** Seven ('7') on numeric keypad. */ + NUMPAD_7(0x67), - /** Eight ('8') on numeric keypad. */ - NUMPAD_8(0x68), + /** Eight ('8') on numeric keypad. */ + NUMPAD_8(0x68), - /** Nine ('9') on numeric keypad. */ - NUMPAD_9(0x69), + /** Nine ('9') on numeric keypad. */ + NUMPAD_9(0x69), - /** Asterisk ('*') on numeric keypad. */ - NUMPAD_ASTERISK(0x6A), + /** Asterisk ('*') on numeric keypad. */ + NUMPAD_ASTERISK(0x6A), - /** Plus ('+') on numeric keypad. */ - NUMPAD_PLUS(0x6B), + /** Plus ('+') on numeric keypad. */ + NUMPAD_PLUS(0x6B), - NUMPAD_SEPARATOR(0x6C), + NUMPAD_SEPARATOR(0x6C), - /** Minus ('-') on numeric keypad. */ - NUMPAD_MINUS(0x6D), + /** Minus ('-') on numeric keypad. */ + NUMPAD_MINUS(0x6D), - /** Period ('.') on numeric keypad. */ - NUMPAD_PERIOD(0x6E), + /** Period ('.') on numeric keypad. */ + NUMPAD_PERIOD(0x6E), - /** Slash ('/') on numeric keypad. */ - NUMPAD_SLASH(0x6F), + /** Slash ('/') on numeric keypad. */ + NUMPAD_SLASH(0x6F), - /** Delete (non-numpad). */ - DELETE(0x7F), + /** Delete (non-numpad). */ + DELETE(0x7F), - /** Num Lock. */ - NUM_LOCK(0x90), + /** Num Lock. */ + NUM_LOCK(0x90), - /** Scroll Lock. */ - SCROLL_LOCK(0x91), + /** Scroll Lock. */ + SCROLL_LOCK(0x91), - /** F1. */ - F1(0x70), + /** F1. */ + F1(0x70), - /** F2. */ - F2(0x71), + /** F2. */ + F2(0x71), - /** F3. */ - F3(0x72), + /** F3. */ + F3(0x72), - /** F4. */ - F4(0x73), + /** F4. */ + F4(0x73), - /** F5. */ - F5(0x74), + /** F5. */ + F5(0x74), - /** F6. */ - F6(0x75), + /** F6. */ + F6(0x75), - /** F7. */ - F7(0x76), + /** F7. */ + F7(0x76), - /** F8. */ - F8(0x77), + /** F8. */ + F8(0x77), - /** F9. */ - F9(0x78), + /** F9. */ + F9(0x78), - /** F10. */ - F10(0x79), + /** F10. */ + F10(0x79), - /** F11. */ - F11(0x7A), + /** F11. */ + F11(0x7A), - /** F12. */ - F12(0x7B), + /** F12. */ + F12(0x7B), - /** F13. */ - F13(0xF000), + /** F13. */ + F13(0xF000), - /** F14. */ - F14(0xF001), + /** F14. */ + F14(0xF001), - /** F15. */ - F15(0xF002), + /** F15. */ + F15(0xF002), - /** F16. */ - F16(0xF003), + /** F16. */ + F16(0xF003), - /** F17. */ - F17(0xF004), + /** F17. */ + F17(0xF004), - /** F18 */ - F18(0xF005), + /** F18 */ + F18(0xF005), - /** F19. */ - F19(0xF006), + /** F19. */ + F19(0xF006), - /** F20. */ - F20(0xF007), + /** F20. */ + F20(0xF007), - /** F21. */ - F21(0xF008), + /** F21. */ + F21(0xF008), - /** F22. */ - F22(0xF009), + /** F22. */ + F22(0xF009), - /** F23. */ - F23(0xF00A), + /** F23. */ + F23(0xF00A), - /** F24. */ - F24(0xF00B), + /** F24. */ + F24(0xF00B), - /** Print Screen. */ - PRINTSCREEN(0x9A), + /** Print Screen. */ + PRINTSCREEN(0x9A), - /** Insert. */ - INSERT(0x9B), + /** Insert. */ + INSERT(0x9B), - /** Help. */ - HELP(0x9C), + /** Help. */ + HELP(0x9C), - /** Meta. */ - META(0x9D), + /** Meta. */ + META(0x9D), - /** Backquote ('`'). */ - BACK_QUOTE(0xC0), + /** Backquote ('`'). */ + BACK_QUOTE(0xC0), - /** Single quote ('\''). */ - QUOTE(0xDE), + /** Single quote ('\''). */ + QUOTE(0xDE), - /** Up arrow on numeric keypad. */ - KP_UP(0xE0), + /** Up arrow on numeric keypad. */ + KP_UP(0xE0), - /** Down arrow on numeric keypad. */ - KP_DOWN(0xE1), + /** Down arrow on numeric keypad. */ + KP_DOWN(0xE1), - /** Left arrow on numeric keypad. */ - KP_LEFT(0xE2), + /** Left arrow on numeric keypad. */ + KP_LEFT(0xE2), - /** Right arrow on numeric keypad. */ - KP_RIGHT(0xE3), + /** Right arrow on numeric keypad. */ + KP_RIGHT(0xE3), - /** TODO. */ - DEAD_GRAVE(0x80), + /** TODO. */ + DEAD_GRAVE(0x80), - /** TODO. */ - DEAD_ACUTE(0x81), + /** TODO. */ + DEAD_ACUTE(0x81), - /** TODO. */ - DEAD_CIRCUMFLEX(0x82), + /** TODO. */ + DEAD_CIRCUMFLEX(0x82), - /** TODO. */ - DEAD_TILDE(0x83), + /** TODO. */ + DEAD_TILDE(0x83), - /** TODO. */ - DEAD_MACRON(0x84), + /** TODO. */ + DEAD_MACRON(0x84), - /** TODO. */ - DEAD_BREVE(0x85), + /** TODO. */ + DEAD_BREVE(0x85), - /** TODO. */ - DEAD_ABOVEDOT(0x86), + /** TODO. */ + DEAD_ABOVEDOT(0x86), - /** TODO. */ - DEAD_DIAERESIS(0x87), + /** TODO. */ + DEAD_DIAERESIS(0x87), - /** TODO. */ - DEAD_ABOVERING(0x88), + /** TODO. */ + DEAD_ABOVERING(0x88), - /** TODO. */ - DEAD_DOUBLEACUTE(0x89), + /** TODO. */ + DEAD_DOUBLEACUTE(0x89), - /** TODO. */ - DEAD_CARON(0x8a), + /** TODO. */ + DEAD_CARON(0x8a), - /** TODO. */ - DEAD_CEDILLA(0x8b), + /** TODO. */ + DEAD_CEDILLA(0x8b), - /** TODO. */ - DEAD_OGONEK(0x8c), + /** TODO. */ + DEAD_OGONEK(0x8c), - /** TODO. */ - DEAD_IOTA(0x8d), + /** TODO. */ + DEAD_IOTA(0x8d), - /** TODO. */ - DEAD_VOICED_SOUND(0x8e), + /** TODO. */ + DEAD_VOICED_SOUND(0x8e), - /** TODO. */ - DEAD_SEMIVOICED_SOUND(0x8f), + /** TODO. */ + DEAD_SEMIVOICED_SOUND(0x8f), - /** Ampersand ('&'). */ - AMPERSAND(0x96), + /** Ampersand ('&'). */ + AMPERSAND(0x96), - /** Asterisk ('*'). */ - ASTERISK(0x97), + /** Asterisk ('*'). */ + ASTERISK(0x97), - /** Double quote ('"'). */ - QUOTEDBL(0x98), + /** Double quote ('"'). */ + QUOTEDBL(0x98), - /** Less than ('<'). */ - LESS(0x99), + /** Less than ('<'). */ + LESS(0x99), - /** Greater than ('>'). */ - GREATER(0xa0), + /** Greater than ('>'). */ + GREATER(0xa0), - /** Left curly brace ('{'). */ - BRACELEFT(0xa1), + /** Left curly brace ('{'). */ + BRACELEFT(0xa1), - /** Right curly brace ('}'). */ - BRACERIGHT(0xa2), + /** Right curly brace ('}'). */ + BRACERIGHT(0xa2), - /** At sign ('@'). */ - AT(0x0200), + /** At sign ('@'). */ + AT(0x0200), - /** Colon (':'). */ - COLON(0x0201), + /** Colon (':'). */ + COLON(0x0201), - /** Caret ('^'). */ - CIRCUMFLEX(0x0202), + /** Caret ('^'). */ + CIRCUMFLEX(0x0202), - /** Dollar sign ('$'). */ - DOLLAR(0x0203), + /** Dollar sign ('$'). */ + DOLLAR(0x0203), - /** Euro sign. */ - EURO_SIGN(0x0204), + /** Euro sign. */ + EURO_SIGN(0x0204), - /** Bang ('!'). */ - EXCLAMATION_MARK(0x0205), + /** Bang ('!'). */ + EXCLAMATION_MARK(0x0205), - /** Inverted bang. */ - INVERTED_EXCLAMATION_MARK(0x0206), + /** Inverted bang. */ + INVERTED_EXCLAMATION_MARK(0x0206), - /** Left parenthesis ('('). */ - LEFT_PARENTHESIS(0x0207), + /** Left parenthesis ('('). */ + LEFT_PARENTHESIS(0x0207), - /** Pound sign ('#'). */ - NUMBER_SIGN(0x0208), + /** Pound sign ('#'). */ + NUMBER_SIGN(0x0208), - /** Plus ('+'). */ - PLUS(0x0209), + /** Plus ('+'). */ + PLUS(0x0209), - /** Right parenthesis (')'). */ - RIGHT_PARENTHESIS(0x020A), + /** Right parenthesis (')'). */ + RIGHT_PARENTHESIS(0x020A), - /** Underscore ('_'). */ - UNDERSCORE(0x020B), + /** Underscore ('_'). */ + UNDERSCORE(0x020B), - /** Windows key (both left and right). */ - WINDOWS(0x020C), + /** Windows key (both left and right). */ + WINDOWS(0x020C), - /** Windows Context Menu key. */ - CONTEXT_MENU(0x020D), + /** Windows Context Menu key. */ + CONTEXT_MENU(0x020D), - FINAL(0x0018), + FINAL(0x0018), - /** Convert function key. */ - CONVERT(0x001C), + /** Convert function key. */ + CONVERT(0x001C), - /** Don't Convert function key. */ - NONCONVERT(0x001D), + /** Don't Convert function key. */ + NONCONVERT(0x001D), - /** Accept or Commit function key. */ - ACCEPT(0x001E), + /** Accept or Commit function key. */ + ACCEPT(0x001E), - MODECHANGE(0x001F), + MODECHANGE(0x001F), - KANA(0x0015), + KANA(0x0015), - KANJI(0x0019), + KANJI(0x0019), - /** Alphanumeric function key. */ - ALPHANUMERIC(0x00F0), + /** Alphanumeric function key. */ + ALPHANUMERIC(0x00F0), - /** Katakana function key. */ - KATAKANA(0x00F1), + /** Katakana function key. */ + KATAKANA(0x00F1), - /** Hiragana function key. */ - HIRAGANA(0x00F2), + /** Hiragana function key. */ + HIRAGANA(0x00F2), - /** Full-Width Characters function key. */ - FULL_WIDTH(0x00F3), + /** Full-Width Characters function key. */ + FULL_WIDTH(0x00F3), - /** Half-Width Characters function key. */ - HALF_WIDTH(0x00F4), + /** Half-Width Characters function key. */ + HALF_WIDTH(0x00F4), - /** Roman Characters function key. */ - ROMAN_CHARACTERS(0x00F5), + /** Roman Characters function key. */ + ROMAN_CHARACTERS(0x00F5), - /** All Candidates function key. */ - ALL_CANDIDATES(0x0100), + /** All Candidates function key. */ + ALL_CANDIDATES(0x0100), - /** Previous Candidate function key. */ - PREVIOUS_CANDIDATE(0x0101), + /** Previous Candidate function key. */ + PREVIOUS_CANDIDATE(0x0101), - /** Code Input function key. */ - CODE_INPUT(0x0102), + /** Code Input function key. */ + CODE_INPUT(0x0102), - /** Japanese-Katakana function key. */ - JAPANESE_KATAKANA(0x0103), + /** Japanese-Katakana function key. */ + JAPANESE_KATAKANA(0x0103), - /** Japanese-Hiragana function key. */ - JAPANESE_HIRAGANA(0x0104), + /** Japanese-Hiragana function key. */ + JAPANESE_HIRAGANA(0x0104), - /** Japanese-Roman function key. */ - JAPANESE_ROMAN(0x0105), + /** Japanese-Roman function key. */ + JAPANESE_ROMAN(0x0105), - /** Locking Kana function key. */ - KANA_LOCK(0x0106), + /** Locking Kana function key. */ + KANA_LOCK(0x0106), - /** Input method on/off key. */ - INPUT_METHOD_ON_OFF(0x0107), + /** Input method on/off key. */ + INPUT_METHOD_ON_OFF(0x0107), - /** Cut (Sun keyboard). */ - CUT(0xFFD1), + /** Cut (Sun keyboard). */ + CUT(0xFFD1), - /** Copy (Sun keyboard). */ - COPY(0xFFCD), + /** Copy (Sun keyboard). */ + COPY(0xFFCD), - /** Paste (Sun keyboard). */ - PASTE(0xFFCF), + /** Paste (Sun keyboard). */ + PASTE(0xFFCF), - /** Undo (Sun keyboard). */ - UNDO(0xFFCB), + /** Undo (Sun keyboard). */ + UNDO(0xFFCB), - /** Again (Sun keyboard). */ - AGAIN(0xFFC9), + /** Again (Sun keyboard). */ + AGAIN(0xFFC9), - /** Find (Sun keyboard). */ - FIND(0xFFD0), + /** Find (Sun keyboard). */ + FIND(0xFFD0), - /** Props (Sun keyboard). */ - PROPS(0xFFCA), + /** Props (Sun keyboard). */ + PROPS(0xFFCA), - /** Stop (Sun keyboard). */ - STOP(0xFFC8), + /** Stop (Sun keyboard). */ + STOP(0xFFC8), - /** Compose function key. */ - COMPOSE(0xFF20), + /** Compose function key. */ + COMPOSE(0xFF20), - /** AltGraph function key. */ - ALT_GRAPH(0xFF7E), + /** AltGraph function key. */ + ALT_GRAPH(0xFF7E), - /** Begin key. */ - BEGIN(0xFF58), + /** Begin key. */ + BEGIN(0xFF58), - /** Unknown code. */ - UNDEFINED(0x0); + /** Unknown code. */ + UNDEFINED(0x0); - private static final Map CODES = - new HashMap<>(); + private static final Map CODES = new HashMap<>(); - private static final Map NAMES = - new HashMap<>(); + private static final Map NAMES = new HashMap<>(); static { for (final KeyCode keyCode : values()) { diff --git a/src/main/java/org/scijava/input/MouseCursor.java b/src/main/java/org/scijava/input/MouseCursor.java index 8d6d55991..15aaf0b53 100644 --- a/src/main/java/org/scijava/input/MouseCursor.java +++ b/src/main/java/org/scijava/input/MouseCursor.java @@ -6,13 +6,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 @@ -31,58 +31,58 @@ /** * A UI-independent enumeration of mouse cursors. - * + * * @author Grant Harris * @author Curtis Rueden */ public enum MouseCursor { - /** Default pointer. */ - DEFAULT, + /** Default pointer. */ + DEFAULT, - /** No cursor (invisible). */ - OFF, + /** No cursor (invisible). */ + OFF, - /** Custom cursor. */ - CUSTOM, + /** Custom cursor. */ + CUSTOM, - /** A crosshair cursor. */ - CROSSHAIR, + /** A crosshair cursor. */ + CROSSHAIR, - /** A hand-shaped cursor. */ - HAND, + /** A hand-shaped cursor. */ + HAND, - /** Four-way arrow cursor. */ - MOVE, + /** Four-way arrow cursor. */ + MOVE, - /** Vertical bar cursor, for text selection. */ - TEXT, + /** Vertical bar cursor, for text selection. */ + TEXT, - /** Hourglass cursor. */ - WAIT, + /** Hourglass cursor. */ + WAIT, - /** Cursor for resizing an edge northward. */ - N_RESIZE, + /** Cursor for resizing an edge northward. */ + N_RESIZE, - /** Cursor for resizing an edge southward. */ - S_RESIZE, + /** Cursor for resizing an edge southward. */ + S_RESIZE, - /** Cursor for resizing an edge westward. */ - W_RESIZE, + /** Cursor for resizing an edge westward. */ + W_RESIZE, - /** Cursor for resizing an edge eastward. */ - E_RESIZE, + /** Cursor for resizing an edge eastward. */ + E_RESIZE, - /** Cursor for resizing an edge northwest. */ - NW_RESIZE, + /** Cursor for resizing an edge northwest. */ + NW_RESIZE, - /** Cursor for resizing an edge northeast. */ - NE_RESIZE, + /** Cursor for resizing an edge northeast. */ + NE_RESIZE, - /** Cursor for resizing an edge southwest. */ - SW_RESIZE, + /** Cursor for resizing an edge southwest. */ + SW_RESIZE, - /** Cursor for resizing an edge southeast. */ - SE_RESIZE + /** Cursor for resizing an edge southeast. */ + SE_RESIZE } diff --git a/src/main/java/org/scijava/io/AbstractIOPlugin.java b/src/main/java/org/scijava/io/AbstractIOPlugin.java index 7e7782572..e499e4fed 100644 --- a/src/main/java/org/scijava/io/AbstractIOPlugin.java +++ b/src/main/java/org/scijava/io/AbstractIOPlugin.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * Abstract base class for {@link IOPlugin}s. - * + * * @author Curtis Rueden */ public abstract class AbstractIOPlugin extends @@ -53,7 +53,8 @@ public abstract class AbstractIOPlugin extends public boolean supportsOpen(final String source) { try { return supportsOpen(locationService.resolve(source)); - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { return false; } } @@ -62,7 +63,8 @@ public boolean supportsOpen(final String source) { public boolean supportsSave(final String destination) { try { return supportsSave(locationService.resolve(destination)); - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { return false; } } @@ -71,7 +73,8 @@ public boolean supportsSave(final String destination) { public void save(final D data, final String destination) throws IOException { try { save(data, locationService.resolve(destination)); - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { throw new IOException(e); } } @@ -80,7 +83,8 @@ public void save(final D data, final String destination) throws IOException { public D open(final String destination) throws IOException { try { return open(locationService.resolve(destination)); - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { throw new IOException(e); } } diff --git a/src/main/java/org/scijava/io/AbstractTypedIOService.java b/src/main/java/org/scijava/io/AbstractTypedIOService.java index 28cd7b96f..274b8b1d2 100644 --- a/src/main/java/org/scijava/io/AbstractTypedIOService.java +++ b/src/main/java/org/scijava/io/AbstractTypedIOService.java @@ -6,13 +6,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 @@ -39,11 +39,12 @@ /** * Abstract base class for typed {@link IOPlugin}s. - * + * * @author Curtis Rueden * @author Deborah Schmidt */ -public abstract class AbstractTypedIOService extends AbstractHandlerService> implements TypedIOService +public abstract class AbstractTypedIOService extends + AbstractHandlerService> implements TypedIOService { @Parameter @@ -56,7 +57,8 @@ public abstract class AbstractTypedIOService extends AbstractHandlerService ignored = (Class) opener.getDataType(); return (D) opener.open(source); } - catch(ClassCastException e) { + catch (ClassCastException e) { throw new UnsupportedOperationException("No compatible opener found."); } } @@ -77,7 +79,8 @@ public D open(Location source) throws IOException { public void save(D data, String destination) throws IOException { try { save(data, locationService.resolve(destination)); - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { throw new IOException(e); } } @@ -97,7 +100,8 @@ public void save(D data, Location destination) throws IOException { public boolean canOpen(String source) { try { return canOpen(locationService.resolve(source)); - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { return false; } } @@ -109,7 +113,8 @@ public boolean canOpen(Location source) { try { Class ignored = (Class) (opener.getDataType()); return true; - } catch(ClassCastException e) { + } + catch (ClassCastException e) { return false; } } @@ -118,7 +123,8 @@ public boolean canOpen(Location source) { public boolean canSave(D data, String source) { try { return canSave(data, locationService.resolve(source)); - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { return false; } } diff --git a/src/main/java/org/scijava/io/ByteArrayByteBank.java b/src/main/java/org/scijava/io/ByteArrayByteBank.java index 277f9abf2..ed3678c11 100644 --- a/src/main/java/org/scijava/io/ByteArrayByteBank.java +++ b/src/main/java/org/scijava/io/ByteArrayByteBank.java @@ -6,13 +6,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/io/ByteBank.java b/src/main/java/org/scijava/io/ByteBank.java index fa6352140..7db9fb0fe 100644 --- a/src/main/java/org/scijava/io/ByteBank.java +++ b/src/main/java/org/scijava/io/ByteBank.java @@ -6,13 +6,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 @@ -63,7 +63,7 @@ default int getBytes(long startPos, byte[] bytes) { /** * Copies part of this buffer into a newly allocated byte array. - * + * * @param offset the initial position in the buffer * @param len the number of bytes to copy * @return The newly allocated byte array containing the data. @@ -79,7 +79,7 @@ default byte[] toByteArray(final long offset, final int len) { /** * Copies this entire buffer into a newly allocated byte array. - * + * * @return The newly allocated byte array containing the data. */ default byte[] toByteArray() { diff --git a/src/main/java/org/scijava/io/DefaultIOService.java b/src/main/java/org/scijava/io/DefaultIOService.java index 183dbcd07..09d328a0d 100644 --- a/src/main/java/org/scijava/io/DefaultIOService.java +++ b/src/main/java/org/scijava/io/DefaultIOService.java @@ -6,13 +6,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 @@ -45,12 +45,12 @@ /** * Default implementation of {@link IOService}. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) -public final class DefaultIOService - extends AbstractHandlerService> implements IOService +public final class DefaultIOService extends + AbstractHandlerService> implements IOService { @Parameter @@ -61,21 +61,25 @@ public final class DefaultIOService @Parameter private LocationService locationService; - + @Override public IOPlugin getOpener(final String source) throws IOException { try { return getOpener(locationService.resolve(source)); - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { throw new IOException(e); } } @Override - public IOPlugin getSaver(D data, String destination) throws IOException { + public IOPlugin getSaver(D data, String destination) + throws IOException + { try { return getSaver(data, locationService.resolve(destination)); - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { throw new IOException(e); } } @@ -84,18 +88,20 @@ public IOPlugin getSaver(D data, String destination) throws IOException { public Object open(final String source) throws IOException { try { return open(locationService.resolve(source)); - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { throw new IOException(e); } } @Override public void save(final Object data, final String destination) - throws IOException + throws IOException { try { save(data, locationService.resolve(destination)); - } catch (URISyntaxException e) { + } + catch (URISyntaxException e) { throw new IOException(e); } } @@ -126,9 +132,10 @@ public void save(final Object data, final Location destination) if (saver != null) { saver.save(data, destination); eventService.publish(new DataSavedEvent(destination, data)); - } else { + } + else { log.error("No Saver IOPlugin found for " + data.toString() + "."); } } - + } diff --git a/src/main/java/org/scijava/io/DefaultRecentFileService.java b/src/main/java/org/scijava/io/DefaultRecentFileService.java index 1e7f0a85f..3a958d1fb 100644 --- a/src/main/java/org/scijava/io/DefaultRecentFileService.java +++ b/src/main/java/org/scijava/io/DefaultRecentFileService.java @@ -6,13 +6,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 @@ -65,7 +65,7 @@ * the top of the list. If data has been saved as a new file, its path is added * to the top of the list. *

      - * + * * @author Grant Harris * @author Curtis Rueden */ diff --git a/src/main/java/org/scijava/io/IOPlugin.java b/src/main/java/org/scijava/io/IOPlugin.java index ed42dee25..a4020ebfa 100644 --- a/src/main/java/org/scijava/io/IOPlugin.java +++ b/src/main/java/org/scijava/io/IOPlugin.java @@ -6,13 +6,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 @@ -46,7 +46,7 @@ * implementing this interface, it is encouraged to instead extend * {@link AbstractIOPlugin}, for convenience. *

      - * + * * @author Curtis Rueden * @see Plugin * @see IOService @@ -59,7 +59,8 @@ public interface IOPlugin extends HandlerPlugin { /** Checks whether the I/O plugin can open data from the given source. */ default boolean supportsOpen(final String source) { try { - return supportsOpen(context().service(LocationService.class).resolve(source)); + return supportsOpen(context().service(LocationService.class).resolve( + source)); } catch (final URISyntaxException exc) { return false; @@ -75,7 +76,8 @@ default boolean supportsOpen(final Location source) { /** Checks whether the I/O plugin can save data to the given destination. */ default boolean supportsSave(final String destination) { try { - return supportsSave(context().service(LocationService.class).resolve(destination)); + return supportsSave(context().service(LocationService.class).resolve( + destination)); } catch (final URISyntaxException exc) { return false; @@ -124,7 +126,9 @@ default void save(final D data, final String destination) throws IOException { /** Saves the given data to the specified location. */ @SuppressWarnings("unused") - default void save(final D data, final Location destination) throws IOException { + default void save(final D data, final Location destination) + throws IOException + { throw new UnsupportedOperationException(); } diff --git a/src/main/java/org/scijava/io/IOService.java b/src/main/java/org/scijava/io/IOService.java index d26c66ce9..9e88498a1 100644 --- a/src/main/java/org/scijava/io/IOService.java +++ b/src/main/java/org/scijava/io/IOService.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * Interface for high-level data I/O: opening and saving data. - * + * * @author Curtis Rueden */ public interface IOService extends HandlerService>, @@ -65,7 +65,8 @@ default IOPlugin getOpener(Location source) { * Gets the most appropriate {@link IOPlugin} for saving data to the given * location. */ - IOPlugin getSaver(final D data, final String destination) throws IOException; + IOPlugin getSaver(final D data, final String destination) + throws IOException; /** * Gets the most appropriate {@link IOPlugin} for saving data to the given @@ -136,7 +137,7 @@ default Object open(Location source) throws IOException { * The saver to use is automatically determined based on available * {@link IOPlugin}s; see {@link #getSaver(Object, Location)}. *

      - * + * * @param data The data to be saved to the destination. * @param destination The destination location to which data should be saved. * @throws IOException if something goes wrong saving the data. diff --git a/src/main/java/org/scijava/io/RecentFileService.java b/src/main/java/org/scijava/io/RecentFileService.java index 38c6385a1..f6abdc2e2 100644 --- a/src/main/java/org/scijava/io/RecentFileService.java +++ b/src/main/java/org/scijava/io/RecentFileService.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * Interface for services that manage the Recently Used Files menu. - * + * * @author Grant Harris * @author Curtis Rueden */ diff --git a/src/main/java/org/scijava/io/TypedIOService.java b/src/main/java/org/scijava/io/TypedIOService.java index 89fffd060..4060fc886 100644 --- a/src/main/java/org/scijava/io/TypedIOService.java +++ b/src/main/java/org/scijava/io/TypedIOService.java @@ -6,13 +6,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 @@ -39,13 +39,14 @@ import org.scijava.service.SciJavaService; /** - * Interface for high-level data I/O: opening and saving data of a specific type. + * Interface for high-level data I/O: opening and saving data of a specific + * type. * * @author Curtis Rueden * @author Deborah Schmidt */ -public interface TypedIOService extends HandlerService>, - SciJavaService +public interface TypedIOService extends + HandlerService>, SciJavaService { /** @@ -54,7 +55,8 @@ public interface TypedIOService extends HandlerService> */ default IOPlugin getOpener(final String source) { try { - return getOpener(context().service(LocationService.class).resolve(source)); + return getOpener(context().service(LocationService.class).resolve( + source)); } catch (final URISyntaxException exc) { return null; @@ -78,7 +80,8 @@ default IOPlugin getOpener(Location source) { */ default IOPlugin getSaver(final D data, final String destination) { try { - return getSaver(data, context().service(LocationService.class).resolve(destination)); + return getSaver(data, context().service(LocationService.class).resolve( + destination)); } catch (final URISyntaxException exc) { return null; diff --git a/src/main/java/org/scijava/io/console/OpenArgument.java b/src/main/java/org/scijava/io/console/OpenArgument.java index ab7aa259b..068afeda7 100644 --- a/src/main/java/org/scijava/io/console/OpenArgument.java +++ b/src/main/java/org/scijava/io/console/OpenArgument.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ /** * Handles the {@code --open} command line argument. - * + * * @author Curtis Rueden */ @Plugin(type = ConsoleArgument.class) diff --git a/src/main/java/org/scijava/io/event/DataOpenedEvent.java b/src/main/java/org/scijava/io/event/DataOpenedEvent.java index b42d9fb0f..907e400b1 100644 --- a/src/main/java/org/scijava/io/event/DataOpenedEvent.java +++ b/src/main/java/org/scijava/io/event/DataOpenedEvent.java @@ -6,13 +6,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 @@ -29,13 +29,12 @@ package org.scijava.io.event; - import org.scijava.io.location.FileLocation; import org.scijava.io.location.Location; /** * An event indicating that data has been opened from a location. - * + * * @author Curtis Rueden */ public class DataOpenedEvent extends IOEvent { diff --git a/src/main/java/org/scijava/io/event/DataSavedEvent.java b/src/main/java/org/scijava/io/event/DataSavedEvent.java index 74eaa8925..143166c0e 100644 --- a/src/main/java/org/scijava/io/event/DataSavedEvent.java +++ b/src/main/java/org/scijava/io/event/DataSavedEvent.java @@ -6,13 +6,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 @@ -29,13 +29,12 @@ package org.scijava.io.event; - import org.scijava.io.location.FileLocation; import org.scijava.io.location.Location; /** * An event indicating that data has been saved to a destination. - * + * * @author Curtis Rueden */ public class DataSavedEvent extends IOEvent { diff --git a/src/main/java/org/scijava/io/event/IOEvent.java b/src/main/java/org/scijava/io/event/IOEvent.java index e254fb0a8..85592850a 100644 --- a/src/main/java/org/scijava/io/event/IOEvent.java +++ b/src/main/java/org/scijava/io/event/IOEvent.java @@ -6,13 +6,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,7 +38,7 @@ /** * An event indicating that I/O (e.g., opening or saving) has occurred. - * + * * @author Curtis Rueden */ public abstract class IOEvent extends SciJavaEvent { diff --git a/src/main/java/org/scijava/io/handle/AbstractDataHandle.java b/src/main/java/org/scijava/io/handle/AbstractDataHandle.java index 9a8a57973..b60abf55a 100644 --- a/src/main/java/org/scijava/io/handle/AbstractDataHandle.java +++ b/src/main/java/org/scijava/io/handle/AbstractDataHandle.java @@ -6,13 +6,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 @@ -42,12 +42,12 @@ public abstract class AbstractDataHandle extends { private byte[] conversionBuffer = new byte[8]; - + @Override public byte[] conversionBuffer() { return conversionBuffer; } - + // -- Fields -- private ByteOrder order = ByteOrder.BIG_ENDIAN; diff --git a/src/main/java/org/scijava/io/handle/AbstractHigherOrderHandle.java b/src/main/java/org/scijava/io/handle/AbstractHigherOrderHandle.java index a27fd185c..8b7bbcc92 100644 --- a/src/main/java/org/scijava/io/handle/AbstractHigherOrderHandle.java +++ b/src/main/java/org/scijava/io/handle/AbstractHigherOrderHandle.java @@ -6,13 +6,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/io/handle/AbstractSeekableStreamHandle.java b/src/main/java/org/scijava/io/handle/AbstractSeekableStreamHandle.java index a28428328..a4ca1f2d1 100644 --- a/src/main/java/org/scijava/io/handle/AbstractSeekableStreamHandle.java +++ b/src/main/java/org/scijava/io/handle/AbstractSeekableStreamHandle.java @@ -6,13 +6,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 @@ -77,7 +77,7 @@ else if (delta > 0) { /** * Recreates the internal input stream available through {@link #in()}, so * that it starts from the specified position. - * + * * @param pos * @throws IOException */ @@ -86,7 +86,7 @@ else if (delta > 0) { /** * In some implementations of this class, the ability to recreate the stream * depends on external factors (e.g. server support). This influences a - * + * * @return if recreate is actually possible. * @throws IOException */ diff --git a/src/main/java/org/scijava/io/handle/AbstractStreamHandle.java b/src/main/java/org/scijava/io/handle/AbstractStreamHandle.java index 9660e9300..72866a36e 100644 --- a/src/main/java/org/scijava/io/handle/AbstractStreamHandle.java +++ b/src/main/java/org/scijava/io/handle/AbstractStreamHandle.java @@ -6,13 +6,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/io/handle/BytesHandle.java b/src/main/java/org/scijava/io/handle/BytesHandle.java index b4cc82b4f..c58b2c8bb 100644 --- a/src/main/java/org/scijava/io/handle/BytesHandle.java +++ b/src/main/java/org/scijava/io/handle/BytesHandle.java @@ -6,13 +6,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 @@ -50,7 +50,7 @@ public class BytesHandle extends AbstractDataHandle { // -- Constructors -- - public BytesHandle() { } + public BytesHandle() {} public BytesHandle(final BytesLocation location) { set(location); @@ -92,11 +92,11 @@ public void setLength(final long length) throws IOException { @Override public int read(final byte[] b, final int off, int len) throws IOException { - if(len == 0) return 0; + if (len == 0) return 0; if (offset + len > length()) { len = (int) (length() - offset); } - if(len == 0) { // EOF + if (len == 0) { // EOF return -1; } bytes().getBytes(offset, b, off, len); diff --git a/src/main/java/org/scijava/io/handle/DataHandle.java b/src/main/java/org/scijava/io/handle/DataHandle.java index f5728f2cd..7d10f8822 100644 --- a/src/main/java/org/scijava/io/handle/DataHandle.java +++ b/src/main/java/org/scijava/io/handle/DataHandle.java @@ -6,13 +6,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 @@ -45,7 +45,7 @@ /** * A data handle is a plugin which provides both streaming and random * access to bytes at a {@link Location} (e.g., files or arrays). - * + * * @author Curtis Rueden * @see DataHandleInputStream * @see DataHandleOutputStream @@ -55,7 +55,7 @@ public interface DataHandle extends WrapperPlugin, { public enum ByteOrder { - LITTLE_ENDIAN, BIG_ENDIAN + LITTLE_ENDIAN, BIG_ENDIAN } /** Default block size to use when searching through the stream. */ @@ -72,7 +72,7 @@ public enum ByteOrder { /** * Tests whether this handle's location actually exists at the source. - * + * * @return True if the location exists; false if not. * @throws IOException If something goes wrong with the existence check. */ @@ -80,7 +80,7 @@ public enum ByteOrder { /** * Gets the last modified timestamp of the location. - * + * * @return The last modified timestamp, or null if the handle does not support * this feature or if the location does not exist. * @throws IOException If something goes wrong with the last modified check. @@ -104,7 +104,7 @@ default Date lastModified() throws IOException { * the checksum is still the same, the contents are highly likely to be * unchanged. *

      - * + * * @return The checksum, or null if the handle does not support this feature. * @throws IOException If something goes wrong when accessing the checksum. */ @@ -123,22 +123,22 @@ default String checksum() throws IOException { /** * Returns the length of the data in bytes. - * + * * @return The length, or -1 if the length is unknown. */ long length() throws IOException; /** * Sets the new length of the handle. - * + * * @param length New length. * @throws IOException If there is an error changing the handle's length. */ void setLength(long length) throws IOException; /** - * Gets the number of bytes which can be read from, or written to, the - * data handle, bounded by the specified number of bytes. + * Gets the number of bytes which can be read from, or written to, the data + * handle, bounded by the specified number of bytes. *

      * In the case of reading, attempting to read the returned number of bytes is * guaranteed not to throw {@link EOFException}. However, be aware that the @@ -158,8 +158,8 @@ default String checksum() throws IOException { *

      * * @param count Desired number of bytes to read/write. - * @return The actual number of bytes which could be read/written, - * which might be less than the requested value. + * @return The actual number of bytes which could be read/written, which might + * be less than the requested value. * @throws IOException If something goes wrong with the check. */ default long available(final long count) throws IOException { @@ -169,7 +169,7 @@ default long available(final long count) throws IOException { /** * Ensures that the handle has sufficient bytes available to read. - * + * * @param count Number of bytes to read. * @see #available(long) * @throws EOFException If there are insufficient bytes available. @@ -184,7 +184,7 @@ default void ensureReadable(final long count) throws IOException { /** * Ensures that the handle has the correct length to be written to, and * extends it as required. - * + * * @param count Number of bytes to write. * @return {@code true} if the handle's length was sufficient, or * {@code false} if the handle's length required an extension. @@ -268,7 +268,7 @@ default String readString(final int n) throws IOException { /** * Reads a string ending with one of the characters in the given string. - * + * * @see #findString(String...) */ default String readString(final String lastChars) throws IOException { @@ -282,7 +282,7 @@ default String readString(final String lastChars) throws IOException { /** * Reads a string ending with one of the given terminating substrings. - * + * * @param terminators The strings for which to search. * @return The string from the initial position through the end of the * terminating sequence, or through the end of the stream if no diff --git a/src/main/java/org/scijava/io/handle/DataHandleInputStream.java b/src/main/java/org/scijava/io/handle/DataHandleInputStream.java index e37ef5948..6802b4304 100644 --- a/src/main/java/org/scijava/io/handle/DataHandleInputStream.java +++ b/src/main/java/org/scijava/io/handle/DataHandleInputStream.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * {@link InputStream} backed by a {@link DataHandle}. - * + * * @author Curtis Rueden * @author Melissa Linkert */ diff --git a/src/main/java/org/scijava/io/handle/DataHandleOutputStream.java b/src/main/java/org/scijava/io/handle/DataHandleOutputStream.java index 510a68e51..01747507c 100644 --- a/src/main/java/org/scijava/io/handle/DataHandleOutputStream.java +++ b/src/main/java/org/scijava/io/handle/DataHandleOutputStream.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * {@link OutputStream} backed by a {@link DataHandle}. - * + * * @author Curtis Rueden * @author Melissa Linkert */ diff --git a/src/main/java/org/scijava/io/handle/DataHandleService.java b/src/main/java/org/scijava/io/handle/DataHandleService.java index 16782658f..7c6b3a104 100644 --- a/src/main/java/org/scijava/io/handle/DataHandleService.java +++ b/src/main/java/org/scijava/io/handle/DataHandleService.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * Interface for low-level data I/O: reading and writing bytes using * {@link DataHandle}s. - * + * * @author Curtis Rueden * @see IOService * @see Location diff --git a/src/main/java/org/scijava/io/handle/DataHandles.java b/src/main/java/org/scijava/io/handle/DataHandles.java index abdcc0afb..d3b6d82d1 100644 --- a/src/main/java/org/scijava/io/handle/DataHandles.java +++ b/src/main/java/org/scijava/io/handle/DataHandles.java @@ -6,13 +6,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 @@ -109,7 +109,7 @@ private static synchronized void initUTFMethod() { "No usable DataOutputStream.writeUTF(String, DataOutput)", exc); } } - + protected static IOException readOnlyException() { return new IOException("This handle is read-only!"); } @@ -118,7 +118,6 @@ protected static IOException writeOnlyException() { return new IOException("This handle is write-only!"); } - /** * Copies all bytes from the input to the output handle. Reading and writing * start at the current positions of the handles. diff --git a/src/main/java/org/scijava/io/handle/DefaultDataHandleService.java b/src/main/java/org/scijava/io/handle/DefaultDataHandleService.java index e820ca6ac..825a0e985 100644 --- a/src/main/java/org/scijava/io/handle/DefaultDataHandleService.java +++ b/src/main/java/org/scijava/io/handle/DefaultDataHandleService.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * Default implementation of {@link DataHandleService}. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) diff --git a/src/main/java/org/scijava/io/handle/DummyHandle.java b/src/main/java/org/scijava/io/handle/DummyHandle.java index bb9cd70ac..0886b32c6 100644 --- a/src/main/java/org/scijava/io/handle/DummyHandle.java +++ b/src/main/java/org/scijava/io/handle/DummyHandle.java @@ -6,13 +6,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 @@ -50,7 +50,7 @@ public class DummyHandle extends AbstractDataHandle { // -- Constructors -- - public DummyHandle() { } + public DummyHandle() {} public DummyHandle(final DummyLocation location) { set(location); diff --git a/src/main/java/org/scijava/io/handle/FileHandle.java b/src/main/java/org/scijava/io/handle/FileHandle.java index dbaedd134..5057ee347 100644 --- a/src/main/java/org/scijava/io/handle/FileHandle.java +++ b/src/main/java/org/scijava/io/handle/FileHandle.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ /** * {@link DataHandle} for a {@link FileLocation}. - * + * * @author Curtis Rueden */ @Plugin(type = DataHandle.class) @@ -60,7 +60,7 @@ public class FileHandle extends AbstractDataHandle { // -- Constructors -- - public FileHandle() { } + public FileHandle() {} public FileHandle(final FileLocation location) { set(location); diff --git a/src/main/java/org/scijava/io/handle/ReadBufferDataHandle.java b/src/main/java/org/scijava/io/handle/ReadBufferDataHandle.java index af306b73b..d4b423e77 100644 --- a/src/main/java/org/scijava/io/handle/ReadBufferDataHandle.java +++ b/src/main/java/org/scijava/io/handle/ReadBufferDataHandle.java @@ -6,13 +6,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 @@ -44,7 +44,9 @@ * Read-only buffered {@link DataHandle}. It buffers the underlying handle into * a fixed number of pages, swapping them out when necessary. */ -public class ReadBufferDataHandle extends AbstractHigherOrderHandle { +public class ReadBufferDataHandle extends + AbstractHigherOrderHandle +{ private static final int DEFAULT_PAGE_SIZE = 10_000; private static final int DEFAULT_NUM_PAGES = 10; @@ -57,8 +59,8 @@ public class ReadBufferDataHandle extends AbstractHigherOrde /** * Cached length value, for performance. When reading data, length is not - * expected to change, but querying it (e.g. via native filesystem access) - * can be slow, and we need to query the length frequently. + * expected to change, but querying it (e.g. via native filesystem access) can + * be slow, and we need to query the length frequently. */ private long length = -1; private long offset = 0l; @@ -66,25 +68,22 @@ public class ReadBufferDataHandle extends AbstractHigherOrde private int currentPageID = -1; /** - * Creates a {@link ReadBufferDataHandle} wrapping the provided handle using the - * default values for the size of the pages ({@value #DEFAULT_PAGE_SIZE} byte) - * and number of pages ({@link #DEFAULT_NUM_PAGES}). + * Creates a {@link ReadBufferDataHandle} wrapping the provided handle using + * the default values for the size of the pages ({@value #DEFAULT_PAGE_SIZE} + * byte) and number of pages ({@link #DEFAULT_NUM_PAGES}). * - * @param handle - * the handle to wrap + * @param handle the handle to wrap */ public ReadBufferDataHandle(final DataHandle handle) { this(handle, DEFAULT_PAGE_SIZE); } /** - * Creates a {@link ReadBufferDataHandle} wrapping the provided handle using the - * default value for the number of pages ({@link #DEFAULT_NUM_PAGES}). + * Creates a {@link ReadBufferDataHandle} wrapping the provided handle using + * the default value for the number of pages ({@link #DEFAULT_NUM_PAGES}). * - * @param handle - * the handle to wrap - * @param pageSize - * the size of the used pages + * @param handle the handle to wrap + * @param pageSize the size of the used pages */ public ReadBufferDataHandle(final DataHandle handle, final int pageSize) { this(handle, pageSize, DEFAULT_NUM_PAGES); @@ -93,14 +92,13 @@ public ReadBufferDataHandle(final DataHandle handle, final int pageSize) { /** * Creates a {@link ReadBufferDataHandle} wrapping the provided handle. * - * @param handle - * the handle to wrap - * @param pageSize - * the size of the used pages - * @param numPages - * the number of pages to use + * @param handle the handle to wrap + * @param pageSize the size of the used pages + * @param numPages the number of pages to use */ - public ReadBufferDataHandle(final DataHandle handle, final int pageSize, final int numPages) { + public ReadBufferDataHandle(final DataHandle handle, final int pageSize, + final int numPages) + { super(handle); this.pageSize = pageSize; @@ -124,10 +122,10 @@ public ReadBufferDataHandle(final DataHandle handle, final int pageSize, fina private void ensureBuffered(final long globalOffset) throws IOException { ensureOpen(); final int pageID = (int) (globalOffset / pageSize); - if (pageID == currentPageID) - return; + if (pageID == currentPageID) return; - final int slotID = pageToSlot.computeIfAbsent(pageID, replacementStrategy::pickVictim); + final int slotID = pageToSlot.computeIfAbsent(pageID, + replacementStrategy::pickVictim); final int inSlotID = slotToPage[slotID]; if (inSlotID != pageID) { // desired page is not buffered @@ -138,7 +136,8 @@ private void ensureBuffered(final long globalOffset) throws IOException { // read the page currentPage = readPage(pageID, slotID); - } else { + } + else { currentPage = pages.get(slotID); } replacementStrategy.accessed(slotID); @@ -149,15 +148,14 @@ private void ensureBuffered(final long globalOffset) throws IOException { * Reads the page with the id pageID into the slot with the id * slotID. * - * @param pageID - * the id of the page to read - * @param slotID - * the id of the slot to read the page into + * @param pageID the id of the page to read + * @param slotID the id of the slot to read the page into * @return the read page - * @throws IOException - * if the reading fails + * @throws IOException if the reading fails */ - private byte[] readPage(final int pageID, final int slotID) throws IOException { + private byte[] readPage(final int pageID, final int slotID) + throws IOException + { replacementStrategy.accessed(slotID); byte[] page = pages.get(slotID); if (page == null) { @@ -267,7 +265,9 @@ public void write(final int b) throws IOException { } @Override - public void write(final byte[] b, final int off, final int len) throws IOException { + public void write(final byte[] b, final int off, final int len) + throws IOException + { throw DataHandles.readOnlyException(); } @@ -285,10 +285,10 @@ private class LRUReplacementStrategy { private final Deque queue; /** - * Creates a {@link LRUReplacementStrategy} with the specified number of slots. + * Creates a {@link LRUReplacementStrategy} with the specified number of + * slots. * - * @param numSlots - * the number of slots to use + * @param numSlots the number of slots to use */ public LRUReplacementStrategy(final int numSlots) { queue = new ArrayDeque<>(numSlots); @@ -300,11 +300,10 @@ public LRUReplacementStrategy(final int numSlots) { } /** - * Notifies this strategy that a slot has been accessed, pushing it to the end - * of the queue. + * Notifies this strategy that a slot has been accessed, pushing it to the + * end of the queue. * - * @param slotID - * the id of the slot that has been accessed + * @param slotID the id of the slot that has been accessed */ public void accessed(final int slotID) { // put accessed element to the end of the queue diff --git a/src/main/java/org/scijava/io/handle/ResettableStreamHandle.java b/src/main/java/org/scijava/io/handle/ResettableStreamHandle.java index c202ad53d..9f3991ae7 100644 --- a/src/main/java/org/scijava/io/handle/ResettableStreamHandle.java +++ b/src/main/java/org/scijava/io/handle/ResettableStreamHandle.java @@ -6,13 +6,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/io/handle/SeekableStreamHandle.java b/src/main/java/org/scijava/io/handle/SeekableStreamHandle.java index bf517df16..05ce8fed7 100644 --- a/src/main/java/org/scijava/io/handle/SeekableStreamHandle.java +++ b/src/main/java/org/scijava/io/handle/SeekableStreamHandle.java @@ -6,13 +6,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/io/handle/StreamHandle.java b/src/main/java/org/scijava/io/handle/StreamHandle.java index f134315cb..62462cd21 100644 --- a/src/main/java/org/scijava/io/handle/StreamHandle.java +++ b/src/main/java/org/scijava/io/handle/StreamHandle.java @@ -6,13 +6,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/io/handle/WriteBufferDataHandle.java b/src/main/java/org/scijava/io/handle/WriteBufferDataHandle.java index 44c8b5064..9f09cfff7 100644 --- a/src/main/java/org/scijava/io/handle/WriteBufferDataHandle.java +++ b/src/main/java/org/scijava/io/handle/WriteBufferDataHandle.java @@ -6,13 +6,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/io/location/AbstractLocation.java b/src/main/java/org/scijava/io/location/AbstractLocation.java index 045d6fc37..7faf885b8 100644 --- a/src/main/java/org/scijava/io/location/AbstractLocation.java +++ b/src/main/java/org/scijava/io/location/AbstractLocation.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Abstract base class for {@link Location} implementations. - * + * * @author Curtis Rueden */ public abstract class AbstractLocation implements Location { diff --git a/src/main/java/org/scijava/io/location/AbstractLocationResolver.java b/src/main/java/org/scijava/io/location/AbstractLocationResolver.java index 675a4c775..349d36d58 100644 --- a/src/main/java/org/scijava/io/location/AbstractLocationResolver.java +++ b/src/main/java/org/scijava/io/location/AbstractLocationResolver.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * Abstract super class for {@link LocationResolver} plugins. - * + * * @author Gabriel Einsdorf */ public abstract class AbstractLocationResolver extends diff --git a/src/main/java/org/scijava/io/location/AbstractRemoteLocation.java b/src/main/java/org/scijava/io/location/AbstractRemoteLocation.java index 2d211157f..0d5af6a92 100644 --- a/src/main/java/org/scijava/io/location/AbstractRemoteLocation.java +++ b/src/main/java/org/scijava/io/location/AbstractRemoteLocation.java @@ -6,13 +6,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/io/location/BrowsableLocation.java b/src/main/java/org/scijava/io/location/BrowsableLocation.java index 234d2c88b..2b2512b0c 100644 --- a/src/main/java/org/scijava/io/location/BrowsableLocation.java +++ b/src/main/java/org/scijava/io/location/BrowsableLocation.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ public interface BrowsableLocation extends Location { /** * Obtains a location pointing to the parent directory of this one. - * + * * @return the parent location of this one, or null if this * location has no parent. * @throws IOException if something goes wrong obtaining the parent. @@ -55,7 +55,7 @@ public interface BrowsableLocation extends Location { * Obtains a collection of locations for whom this location is the parent. * Note that this will only succeed if calls to {@link #isDirectory()} on this * location return true. - * + * * @return A set containing the children of this location, or * {@link Collections#EMPTY_SET} if this location has no children. * @throws IOException if something goes wrong obtaining the children. @@ -65,8 +65,8 @@ public interface BrowsableLocation extends Location { Set children() throws IOException; /** - * Obtains a location relative to this one, which will be configured - * like the current location, but point to a the file specified by the + * Obtains a location relative to this one, which will be configured like the + * current location, but point to a the file specified by the * path parameter. * * @param path the relative path of the desired location. @@ -80,7 +80,7 @@ public interface BrowsableLocation extends Location { * children. It is recommended to use this method before calling * {@link #child(String)} or {@link #children()}, to ensure those calls * succeed. - * + * * @return True iff the location represents a directory. */ boolean isDirectory(); diff --git a/src/main/java/org/scijava/io/location/BytesLocation.java b/src/main/java/org/scijava/io/location/BytesLocation.java index d16e83c69..a3962d4ce 100644 --- a/src/main/java/org/scijava/io/location/BytesLocation.java +++ b/src/main/java/org/scijava/io/location/BytesLocation.java @@ -6,13 +6,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 @@ -46,8 +46,7 @@ public class BytesLocation extends AbstractLocation { private final String name; /** - * Creates a {@link BytesLocation} backed by the specified - * {@link ByteBank}. + * Creates a {@link BytesLocation} backed by the specified {@link ByteBank}. * * @param bytes the {@link ByteBank} that will back this {@link Location} */ @@ -88,8 +87,8 @@ public BytesLocation(final int initialCapacity, final String name) { } /** - * Creates a {@link BytesLocation} backed by a {@link ByteArrayByteBank} - * that wraps the specified {@link ByteArray}. + * Creates a {@link BytesLocation} backed by a {@link ByteArrayByteBank} that + * wraps the specified {@link ByteArray}. */ public BytesLocation(final ByteArray bytes) { this(bytes, null); @@ -107,8 +106,8 @@ public BytesLocation(final ByteArray bytes, final String name) { } /** - * Creates a {@link BytesLocation} backed by a {@link ByteArrayByteBank} - * which wraps the specified array. + * Creates a {@link BytesLocation} backed by a {@link ByteArrayByteBank} which + * wraps the specified array. * * @param bytes the array to wrap */ @@ -131,7 +130,7 @@ public BytesLocation(final byte[] bytes, final String name) { /** * Creates a {@link BytesLocation} backed by a {@link ByteArrayByteBank} with * the specified initial capacity and the provided data. - * + * * @param bytes the bytes to copy into the new {@link BytesLocation} * @param offset the offset in the bytes array to start copying from * @param length the number of bytes to copy, starting from the offset diff --git a/src/main/java/org/scijava/io/location/DefaultLocationService.java b/src/main/java/org/scijava/io/location/DefaultLocationService.java index d4ea0845a..7ed771507 100644 --- a/src/main/java/org/scijava/io/location/DefaultLocationService.java +++ b/src/main/java/org/scijava/io/location/DefaultLocationService.java @@ -6,13 +6,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 @@ -37,13 +37,12 @@ /** * Default {@link LocationService} implementation. - * + * * @author Gabriel Einsdorf */ @Plugin(type = Service.class) public class DefaultLocationService extends - AbstractHandlerService implements - LocationService + AbstractHandlerService implements LocationService { // NB: No implementation needed. } diff --git a/src/main/java/org/scijava/io/location/DummyLocation.java b/src/main/java/org/scijava/io/location/DummyLocation.java index f1e2b4f64..784600f6a 100644 --- a/src/main/java/org/scijava/io/location/DummyLocation.java +++ b/src/main/java/org/scijava/io/location/DummyLocation.java @@ -6,13 +6,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/io/location/FileLocation.java b/src/main/java/org/scijava/io/location/FileLocation.java index 195389196..0bb216b0d 100644 --- a/src/main/java/org/scijava/io/location/FileLocation.java +++ b/src/main/java/org/scijava/io/location/FileLocation.java @@ -6,13 +6,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/io/location/FileLocationResolver.java b/src/main/java/org/scijava/io/location/FileLocationResolver.java index 67c57420c..a9bc5f6e2 100644 --- a/src/main/java/org/scijava/io/location/FileLocationResolver.java +++ b/src/main/java/org/scijava/io/location/FileLocationResolver.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * Implementation of {@link LocationResolver} for {@link FileLocation}. - * + * * @author Gabriel Einsdorf */ @Plugin(type = LocationResolver.class) diff --git a/src/main/java/org/scijava/io/location/Location.java b/src/main/java/org/scijava/io/location/Location.java index 1d2510c54..01d15f017 100644 --- a/src/main/java/org/scijava/io/location/Location.java +++ b/src/main/java/org/scijava/io/location/Location.java @@ -6,13 +6,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 @@ -37,14 +37,14 @@ * A location is a data descriptor, such as a file on disk, a remote * URL, or a database connection. *

      - * Analogous to a uniform + * Analogous to a + * uniform * resource identifier ({@link URI}), a location identifies where * the data resides, without necessarily specifying how to access that * data. The {@link DataHandle} interface defines a plugin that knows how to * read and/or write bytes for a particular kind of location. *

      - * + * * @author Curtis Rueden * @author Gabriel Einsdorf */ @@ -78,7 +78,7 @@ default String getName() { * {@code Location} will assign some non-default name. But in cases where that * does not occur, this value can be useful to detect the situation. *

      - * + * * @return The default name string. */ default String defaultName() { diff --git a/src/main/java/org/scijava/io/location/LocationResolver.java b/src/main/java/org/scijava/io/location/LocationResolver.java index 0f325a002..bfc9f71d7 100644 --- a/src/main/java/org/scijava/io/location/LocationResolver.java +++ b/src/main/java/org/scijava/io/location/LocationResolver.java @@ -6,13 +6,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,14 +38,14 @@ * {@link LocationResolver} plugins allow resolving an {@link URI} to a * {@link Location}. Extending {@link AbstractLocationResolver} is recommended * for easy implementation. - * + * * @author Gabriel Einsdorf */ public interface LocationResolver extends HandlerPlugin { /** * Resolves the given {@link URI} to a {@link Location} - * + * * @return the resolved Location * @throws URISyntaxException */ diff --git a/src/main/java/org/scijava/io/location/LocationService.java b/src/main/java/org/scijava/io/location/LocationService.java index 1af4e1e26..5ee1e2140 100644 --- a/src/main/java/org/scijava/io/location/LocationService.java +++ b/src/main/java/org/scijava/io/location/LocationService.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * A service that allows resolving of URIs to Locations, using * {@link LocationResolver} plugins for translation. - * + * * @author Gabriel Einsdorf */ public interface LocationService extends HandlerService, @@ -55,16 +55,18 @@ public interface LocationService extends HandlerService, * @throws URISyntaxException if the URI is malformed */ default Location resolve(final String uriString) throws URISyntaxException { - try { - Location loc = resolve(new URI(uriString)); - if (loc != null) return loc; - } - catch (final URISyntaxException exc) { - // In general, filenames are not valid URI strings. - // Particularly on Windows, there are backslashes, which are invalid in URIs. - // So we explicitly turn this string into a file if an error happens above. - } - return resolve(new File(uriString).toURI()); + try { + Location loc = resolve(new URI(uriString)); + if (loc != null) return loc; + } + catch (final URISyntaxException exc) { + // In general, filenames are not valid URI strings. + // Particularly on Windows, there are backslashes, which are invalid in + // URIs. + // So we explicitly turn this string into a file if an error happens + // above. + } + return resolve(new File(uriString).toURI()); } /** diff --git a/src/main/java/org/scijava/io/location/RemoteLocation.java b/src/main/java/org/scijava/io/location/RemoteLocation.java index a39282b4f..87699525c 100644 --- a/src/main/java/org/scijava/io/location/RemoteLocation.java +++ b/src/main/java/org/scijava/io/location/RemoteLocation.java @@ -6,13 +6,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 @@ -31,21 +31,21 @@ /** * A {@link Location} which resides on a remote machine. - * + * * @author Gabriel Einsdorf */ public interface RemoteLocation extends Location { /** * Sets the connection timeout for this location. - * + * * @param timeout The timeout in milliseconds. */ void setTimeout(long timeout); /** * Gets the connection timeout for this location. - * + * * @return The connection timeout in milliseconds. */ long getTimeout(); diff --git a/src/main/java/org/scijava/io/location/URILocation.java b/src/main/java/org/scijava/io/location/URILocation.java index 0e5165a4a..5bc16fb8a 100644 --- a/src/main/java/org/scijava/io/location/URILocation.java +++ b/src/main/java/org/scijava/io/location/URILocation.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ /** * {@link Location} backed by a {@link URI} string. - * + * * @author Curtis Rueden */ public class URILocation extends AbstractLocation { @@ -85,7 +85,7 @@ public URI getURI() { /** * Decodes a query string of ampersand-separated key/value pairs. E.g.: * {@code apples=yummy&bananas=delicious&grapefruits=scrumptious}. - * + * * @param query The query string to decode. * @return A map of the decoded key/value pairs. */ @@ -108,7 +108,7 @@ private Map decodeQuery(final String query) { /** * Decodes a single uuencoded string. - * + * * @see URLDecoder */ private String decode(final String s) { diff --git a/src/main/java/org/scijava/io/location/URLLocation.java b/src/main/java/org/scijava/io/location/URLLocation.java index 73c4781f2..aff2dc75c 100644 --- a/src/main/java/org/scijava/io/location/URLLocation.java +++ b/src/main/java/org/scijava/io/location/URLLocation.java @@ -6,13 +6,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/io/nio/ByteBufferByteBank.java b/src/main/java/org/scijava/io/nio/ByteBufferByteBank.java index 99588b672..eb55bb2d0 100644 --- a/src/main/java/org/scijava/io/nio/ByteBufferByteBank.java +++ b/src/main/java/org/scijava/io/nio/ByteBufferByteBank.java @@ -6,13 +6,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 @@ -144,8 +144,8 @@ public boolean isReadOnly() { // Since these read-only types are not public, we compare class names rather // than checking for type equality or using instanceof. final String className = buffer.getClass().getName(); - return className.equals("java.nio.HeapByteBufferR") || - className.equals("java.nio.DirectByteBufferR"); + return className.equals("java.nio.HeapByteBufferR") || className.equals( + "java.nio.DirectByteBufferR"); } // -- Helper methods -- diff --git a/src/main/java/org/scijava/io/nio/DefaultNIOService.java b/src/main/java/org/scijava/io/nio/DefaultNIOService.java index 6e0ef72da..0b798ac99 100644 --- a/src/main/java/org/scijava/io/nio/DefaultNIOService.java +++ b/src/main/java/org/scijava/io/nio/DefaultNIOService.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ /** * Default service for working with the {@link java.nio} package, particularly * NIO {@link ByteBuffer} objects. - * + * * @author Chris Allan * @author Curtis Rueden */ @@ -78,7 +78,7 @@ public ByteBuffer allocate(final FileChannel channel, final MapMode mapMode, /** * Allocates memory and copies the desired file data into it. - * + * * @param channel File channel to allocate or map byte buffers from. * @param bufferStartPosition The absolute position of the start of the * buffer. @@ -96,7 +96,7 @@ private ByteBuffer allocateDirect(final FileChannel channel, /** * Memory maps the desired file data into memory. - * + * * @param channel File channel to allocate or map byte buffers from. * @param mapMode The map mode. Required but only used if memory mapped I/O is * to occur. diff --git a/src/main/java/org/scijava/io/nio/NIOService.java b/src/main/java/org/scijava/io/nio/NIOService.java index ea5c6696c..16fdf3bc4 100644 --- a/src/main/java/org/scijava/io/nio/NIOService.java +++ b/src/main/java/org/scijava/io/nio/NIOService.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * Interface for services that work with the {@link java.nio} package, * particularly NIO {@link ByteBuffer} objects. - * + * * @author Chris Allan * @author Curtis Rueden */ @@ -52,7 +52,7 @@ public interface NIOService extends SciJavaService { * FileChannel.map() usage on platforms where it's unlikely to * give us problems and heap allocation where it is. *

      - * + * * @param channel File channel to allocate or map byte buffers from. * @param mapMode The map mode. Required but only used if memory mapped I/O is * to occur. diff --git a/src/main/java/org/scijava/log/AbstractLogService.java b/src/main/java/org/scijava/log/AbstractLogService.java index 1227ea134..347356a34 100644 --- a/src/main/java/org/scijava/log/AbstractLogService.java +++ b/src/main/java/org/scijava/log/AbstractLogService.java @@ -6,13 +6,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/log/CallingClassUtils.java b/src/main/java/org/scijava/log/CallingClassUtils.java index 34a52d894..f73d5fade 100644 --- a/src/main/java/org/scijava/log/CallingClassUtils.java +++ b/src/main/java/org/scijava/log/CallingClassUtils.java @@ -6,13 +6,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 @@ -45,11 +45,11 @@ private CallingClassUtils() { } /** - * Inspects the stack trace to return the name of the class that calls - * this method, but ignores every class annotated with @IgnoreAsCallingClass. + * Inspects the stack trace to return the name of the class that calls this + * method, but ignores every class annotated with @IgnoreAsCallingClass. *

      - * If every class on the stack trace is annotated, then the class at the - * root of the stack trace is returned. + * If every class on the stack trace is annotated, then the class at the root + * of the stack trace is returned. */ public static String getCallingClassName() { StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); @@ -62,7 +62,7 @@ public static String getCallingClassName() { private static boolean hasIgnoreAsCallingClassAnnotation(String className) { try { - Class< ? > clazz = Context.getClassLoader().loadClass(className); + Class clazz = Context.getClassLoader().loadClass(className); return clazz.isAnnotationPresent(IgnoreAsCallingClass.class); } catch (ClassNotFoundException ignore) { @@ -71,14 +71,12 @@ private static boolean hasIgnoreAsCallingClassAnnotation(String className) { } /** - * @deprecated Use {@link #getCallingClassName()} instead. - * - * Warning: This method throws a IllegalStateException as soon as it comes - * across a class that can't be loaded with the default class loader. - * - * Inspects the stack trace to return the class that calls this method, but - * ignores every class annotated with @IgnoreAsCallingClass. - * + * @deprecated Use {@link #getCallingClassName()} instead. Warning: This + * method throws a IllegalStateException as soon as it comes + * across a class that can't be loaded with the default class + * loader. Inspects the stack trace to return the class that calls + * this method, but ignores every class annotated + * with @IgnoreAsCallingClass. * @throws IllegalStateException if every method on the stack, is in a class * annotated with @IgnoreAsCallingClass. */ diff --git a/src/main/java/org/scijava/log/DefaultLogger.java b/src/main/java/org/scijava/log/DefaultLogger.java index 9f148f647..f4a37c61f 100644 --- a/src/main/java/org/scijava/log/DefaultLogger.java +++ b/src/main/java/org/scijava/log/DefaultLogger.java @@ -6,13 +6,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 @@ -49,8 +49,8 @@ public class DefaultLogger implements Logger, LogListener { private final List listeners = new CopyOnWriteArrayList<>(); - public DefaultLogger(final LogListener destination, - final LogSource source, final int level) + public DefaultLogger(final LogListener destination, final LogSource source, + final int level) { this.destination = destination; this.source = source; diff --git a/src/main/java/org/scijava/log/DefaultUncaughtExceptionHandler.java b/src/main/java/org/scijava/log/DefaultUncaughtExceptionHandler.java index 1d3e9704e..12ed5b7fb 100644 --- a/src/main/java/org/scijava/log/DefaultUncaughtExceptionHandler.java +++ b/src/main/java/org/scijava/log/DefaultUncaughtExceptionHandler.java @@ -6,13 +6,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,7 +38,7 @@ * otherwise be missed; e.g., when things go awry on the AWT Event Dispatch * Thread. *

      - * + * * @author Johannes Schindelin */ public class DefaultUncaughtExceptionHandler implements @@ -52,8 +52,8 @@ public DefaultUncaughtExceptionHandler(final LogService log) { } @Override - public void - uncaughtException(final Thread thread, final Throwable throwable) + public void uncaughtException(final Thread thread, + final Throwable throwable) { log.error("Uncaught exception in thread " + thread, throwable); } diff --git a/src/main/java/org/scijava/log/IgnoreAsCallingClass.java b/src/main/java/org/scijava/log/IgnoreAsCallingClass.java index faa0da4d8..42f7e30b3 100644 --- a/src/main/java/org/scijava/log/IgnoreAsCallingClass.java +++ b/src/main/java/org/scijava/log/IgnoreAsCallingClass.java @@ -6,13 +6,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/log/LogLevel.java b/src/main/java/org/scijava/log/LogLevel.java index cc36aba55..172a1ec92 100644 --- a/src/main/java/org/scijava/log/LogLevel.java +++ b/src/main/java/org/scijava/log/LogLevel.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Constants for specifying a logger's level of verbosity. - * + * * @author Curtis Rueden */ public final class LogLevel { @@ -66,7 +66,7 @@ public static String prefix(final int level) { /** * Extracts the log level value from a string. - * + * * @return The log level, or -1 if the level cannot be parsed. */ public static int value(final String s) { diff --git a/src/main/java/org/scijava/log/LogListener.java b/src/main/java/org/scijava/log/LogListener.java index fabbfa435..b29743b88 100644 --- a/src/main/java/org/scijava/log/LogListener.java +++ b/src/main/java/org/scijava/log/LogListener.java @@ -6,13 +6,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/log/LogMessage.java b/src/main/java/org/scijava/log/LogMessage.java index fde5af3b9..4a7a53352 100644 --- a/src/main/java/org/scijava/log/LogMessage.java +++ b/src/main/java/org/scijava/log/LogMessage.java @@ -6,13 +6,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 @@ -83,7 +83,7 @@ public LogSource source() { /** * Log level of the message. - * + * * @see LogLevel */ public int level() { @@ -130,7 +130,7 @@ public String toString() { final StringWriter sw = new StringWriter(); final PrintWriter printer = new PrintWriter(sw); printer.print("[" + LogLevel.prefix(level()) + "] "); - if(text() != null) printer.println(text()); + if (text() != null) printer.println(text()); if (throwable() != null) { throwable().printStackTrace(printer); } diff --git a/src/main/java/org/scijava/log/LogService.java b/src/main/java/org/scijava/log/LogService.java index 7d7eac93f..40b9ca4f9 100644 --- a/src/main/java/org/scijava/log/LogService.java +++ b/src/main/java/org/scijava/log/LogService.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ * extensible to additional levels as needed. It provides methods for logging * messages, exception stack traces and combinations of the two. *

      - * + * * @author Curtis Rueden * @author Matthias Arzt */ @@ -56,7 +56,7 @@ public interface LogService extends SciJavaService, Logger { /** * For messages that are logged directly to the LogService. The log level can * be set depending on the class that makes the log. - * + * * @param classOrPackageName If this is the name of a class. Messages logged * directly by this class are logged, if the message's level is less * or equal to the given level. If this is a package, the same holds diff --git a/src/main/java/org/scijava/log/LogSource.java b/src/main/java/org/scijava/log/LogSource.java index 4338e3a8a..6dbc34a73 100644 --- a/src/main/java/org/scijava/log/LogSource.java +++ b/src/main/java/org/scijava/log/LogSource.java @@ -6,13 +6,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/log/Logged.java b/src/main/java/org/scijava/log/Logged.java index 7f44f3f75..3eae16d01 100644 --- a/src/main/java/org/scijava/log/Logged.java +++ b/src/main/java/org/scijava/log/Logged.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Interface for the objects which want to log their activities. - * + * * @author Curtis Rueden */ public interface Logged { diff --git a/src/main/java/org/scijava/log/Logger.java b/src/main/java/org/scijava/log/Logger.java index 8806a1dde..8fea57c60 100644 --- a/src/main/java/org/scijava/log/Logger.java +++ b/src/main/java/org/scijava/log/Logger.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ * It provides methods for logging messages, exception stack traces and * combinations of the two. *

      - * + * * @author Curtis Rueden * @see LogLevel * @see LogService @@ -135,7 +135,7 @@ default boolean isLevel(final int level) { /** * Logs a message. - * + * * @param level The level at which the message will be logged. If the current * level (given by {@link #getLevel()} is below this one, no logging * is performed. @@ -147,7 +147,7 @@ default void log(final int level, final Object msg) { /** * Logs an exception. - * + * * @param level The level at which the exception will be logged. If the * current level (given by {@link #getLevel()} is below this one, no * logging is performed. diff --git a/src/main/java/org/scijava/log/StderrLogService.java b/src/main/java/org/scijava/log/StderrLogService.java index 184f11d52..de6084849 100644 --- a/src/main/java/org/scijava/log/StderrLogService.java +++ b/src/main/java/org/scijava/log/StderrLogService.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ * and {@code ERROR} messages to stderr, but messages at lesser severities to * stdout. *

      - * + * * @author Johannes Schindelin * @author Curtis Rueden */ diff --git a/src/main/java/org/scijava/main/DefaultMainService.java b/src/main/java/org/scijava/main/DefaultMainService.java index faffc2546..e54e4778e 100644 --- a/src/main/java/org/scijava/main/DefaultMainService.java +++ b/src/main/java/org/scijava/main/DefaultMainService.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ /** * Default implementation of {@link MainService}. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) @@ -78,6 +78,7 @@ public Main[] getMains() { /** Default implementation of {@link MainService.Main}. */ private class DefaultMain implements Main { + private String className; private String[] args; diff --git a/src/main/java/org/scijava/main/MainService.java b/src/main/java/org/scijava/main/MainService.java index ac21af8f0..266375930 100644 --- a/src/main/java/org/scijava/main/MainService.java +++ b/src/main/java/org/scijava/main/MainService.java @@ -6,13 +6,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,14 +33,14 @@ /** * 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(); diff --git a/src/main/java/org/scijava/main/console/MainArgument.java b/src/main/java/org/scijava/main/console/MainArgument.java index f9139ff6c..a4b69a814 100644 --- a/src/main/java/org/scijava/main/console/MainArgument.java +++ b/src/main/java/org/scijava/main/console/MainArgument.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ /** * Handles the {@code --main} command line argument, which launches an * alternative main class. - * + * * @author Curtis Rueden */ @Plugin(type = ConsoleArgument.class) diff --git a/src/main/java/org/scijava/main/run/MainCodeRunner.java b/src/main/java/org/scijava/main/run/MainCodeRunner.java index 627e8ece3..088cec45e 100644 --- a/src/main/java/org/scijava/main/run/MainCodeRunner.java +++ b/src/main/java/org/scijava/main/run/MainCodeRunner.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ /** * Executes the given class's {@code main} method. - * + * * @author Curtis Rueden */ @Plugin(type = CodeRunner.class, priority = Priority.LOW) diff --git a/src/main/java/org/scijava/menu/AbstractMenuCreator.java b/src/main/java/org/scijava/menu/AbstractMenuCreator.java index 94dd1f596..1b3eaeb6f 100644 --- a/src/main/java/org/scijava/menu/AbstractMenuCreator.java +++ b/src/main/java/org/scijava/menu/AbstractMenuCreator.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ * {@link javax.swing.JMenuBar}), and hierarchical menu components (such as * {@link javax.swing.JMenu}). *

      - * + * * @author Curtis Rueden * @param Top-level menu class to populate (e.g., * {@link javax.swing.JMenuBar} or {@link javax.swing.JMenu} or diff --git a/src/main/java/org/scijava/menu/DefaultMenuService.java b/src/main/java/org/scijava/menu/DefaultMenuService.java index 37863c869..702e22837 100644 --- a/src/main/java/org/scijava/menu/DefaultMenuService.java +++ b/src/main/java/org/scijava/menu/DefaultMenuService.java @@ -6,13 +6,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 @@ -49,13 +49,12 @@ /** * Default service for keeping track of the application's menu structure. - * + * * @author Curtis Rueden * @see ShadowMenu */ @Plugin(type = Service.class) -public class DefaultMenuService extends AbstractService implements MenuService -{ +public class DefaultMenuService extends AbstractService implements MenuService { @Parameter private EventService eventService; diff --git a/src/main/java/org/scijava/menu/MenuConstants.java b/src/main/java/org/scijava/menu/MenuConstants.java index c68b5171c..ebb382b88 100644 --- a/src/main/java/org/scijava/menu/MenuConstants.java +++ b/src/main/java/org/scijava/menu/MenuConstants.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Useful constants when defining application menu entries. - * + * * @author Curtis Rueden */ public final class MenuConstants { diff --git a/src/main/java/org/scijava/menu/MenuCreator.java b/src/main/java/org/scijava/menu/MenuCreator.java index 571ea192e..1c7d798e0 100644 --- a/src/main/java/org/scijava/menu/MenuCreator.java +++ b/src/main/java/org/scijava/menu/MenuCreator.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * A menu builder responsible for translating a {@link ShadowMenu} structure * into a menu for a particular user interface. - * + * * @author Curtis Rueden * @param Top-level menu class to populate (e.g., * {@link javax.swing.JMenuBar} or {@link javax.swing.JMenu}) diff --git a/src/main/java/org/scijava/menu/MenuService.java b/src/main/java/org/scijava/menu/MenuService.java index 8455284ac..c80a5b9b5 100644 --- a/src/main/java/org/scijava/menu/MenuService.java +++ b/src/main/java/org/scijava/menu/MenuService.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * Interface for service that tracks the application's menu structure. - * + * * @author Curtis Rueden */ public interface MenuService extends SciJavaService { @@ -47,7 +47,7 @@ default ShadowMenu getMenu() { /** * Gets the root node of a menu structure. - * + * * @param menuRoot the root of the desired menu structure (see * {@link ModuleInfo#getMenuRoot()}). */ @@ -55,7 +55,7 @@ default ShadowMenu getMenu() { /** * Populates a UI-specific application menu structure. - * + * * @param creator the {@link MenuCreator} to use to populate the menus. * @param menu the destination menu structure to populate. */ @@ -65,14 +65,14 @@ default T createMenus(final MenuCreator creator, final T menu) { /** * Populates a UI-specific menu structure. - * + * * @param menuRoot the root of the menu structure to generate (see * {@link ModuleInfo#getMenuRoot()}). * @param creator the {@link MenuCreator} to use to populate the menus. * @param menu the destination menu structure to populate. */ - default T createMenus(final String menuRoot, - final MenuCreator creator, final T menu) + default T createMenus(final String menuRoot, final MenuCreator creator, + final T menu) { creator.createMenus(getMenu(menuRoot), menu); return menu; diff --git a/src/main/java/org/scijava/menu/ShadowMenu.java b/src/main/java/org/scijava/menu/ShadowMenu.java index e0cecb326..0b7dd311c 100644 --- a/src/main/java/org/scijava/menu/ShadowMenu.java +++ b/src/main/java/org/scijava/menu/ShadowMenu.java @@ -6,13 +6,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 @@ -72,7 +72,7 @@ * corresponding {@link ModuleInfo}, and executing that module when * {@link #run()} is called. *

      - * + * * @author Curtis Rueden * @see MenuCreator * @see MenuPath @@ -186,8 +186,7 @@ public ShadowMenu getParent() { /** Gets this node's children, sorted by weight. */ public List getChildren() { // copy the children table into an ordered list - final List childList = - new ArrayList<>(children.values()); + final List childList = new ArrayList<>(children.values()); // sort the list by weight then alphabetically Collections.sort(childList); return childList; @@ -220,7 +219,7 @@ public boolean isRadioButton() { /** * Gets the URL of the icon associated with this node's {@link MenuEntry}. - * + * * @see org.scijava.plugin.PluginInfo#getIconURL() */ public URL getIconURL() { @@ -239,15 +238,15 @@ public URL getIconURL() { return iconURL; } catch (final ClassNotFoundException exc) { - final String message = "Failed to load class: " + - moduleInfo.getDelegateClassName(); + final String message = "Failed to load class: " + moduleInfo + .getDelegateClassName(); if (log.isDebug()) log.debug(message, exc); else log.error(message); return null; } catch (final IllegalArgumentException exc) { - final String message = "Could not load icon for class: " + - moduleInfo.getDelegateClassName(); + final String message = "Could not load icon for class: " + moduleInfo + .getDelegateClassName(); if (log.isDebug()) log.debug(message, exc); else log.error(message); return null; @@ -257,7 +256,7 @@ public URL getIconURL() { /** * Updates the menu structure to reflect changes in the given module. Does * nothing unless the module is already in the menu structure. - * + * * @return true if the module was successfully updated */ public boolean update(final ModuleInfo module) { @@ -273,7 +272,7 @@ public boolean update(final ModuleInfo module) { * Updates the menu structure to reflect changes in the given modules. Does * nothing unless at least one of the modules is already in the menu * structure. - * + * * @return true if at least one module was successfully updated */ public boolean updateAll(final Collection c) { @@ -315,7 +314,7 @@ public int compareTo(final ShadowMenu c) { // if weights are equal, sort alphabetically final String n1 = menuEntry.getName(); final String n2 = c.menuEntry.getName(); - return MiscUtils.compare(n1, n2); + return MiscUtils.compare(n1, n2); } @Override @@ -497,7 +496,8 @@ public T[] toArray(final T[] a) { // -- Helper methods -- private ShadowMenu addInternal(final ModuleInfo o) { - if (o.getMenuPath() == null || o.getMenuPath().isEmpty()) return null; // no menu + if (o.getMenuPath() == null || o.getMenuPath().isEmpty()) return null; // no + // menu return addChild(o, 0); } @@ -536,8 +536,8 @@ private ShadowMenu addChild(final ModuleInfo info, final int depth) { if (existingChild == null) { // create new child and add to table final String menuName = entry.getName(); - final ShadowMenu newChild = - new ShadowMenu(getContext(), info, depth, this); + final ShadowMenu newChild = new ShadowMenu(getContext(), info, depth, + this); children.put(menuName, newChild); child = newChild; } diff --git a/src/main/java/org/scijava/menu/ShadowMenuIterator.java b/src/main/java/org/scijava/menu/ShadowMenuIterator.java index 45dfc836e..6bd236dfa 100644 --- a/src/main/java/org/scijava/menu/ShadowMenuIterator.java +++ b/src/main/java/org/scijava/menu/ShadowMenuIterator.java @@ -6,13 +6,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,7 +38,7 @@ /** * Recursive iterator for {@link ShadowMenu} hierarchies. - * + * * @author Curtis Rueden */ public class ShadowMenuIterator implements Iterator { diff --git a/src/main/java/org/scijava/menu/event/MenuEvent.java b/src/main/java/org/scijava/menu/event/MenuEvent.java index c1e81f70e..c3ce64c51 100644 --- a/src/main/java/org/scijava/menu/event/MenuEvent.java +++ b/src/main/java/org/scijava/menu/event/MenuEvent.java @@ -6,13 +6,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,7 +38,7 @@ /** * An event indicating something has happened to the {@link MenuService}'s * {@link ShadowMenu}. - * + * * @author Curtis Rueden */ public abstract class MenuEvent extends ListEvent { diff --git a/src/main/java/org/scijava/menu/event/MenusAddedEvent.java b/src/main/java/org/scijava/menu/event/MenusAddedEvent.java index 796bd039b..8ad638675 100644 --- a/src/main/java/org/scijava/menu/event/MenusAddedEvent.java +++ b/src/main/java/org/scijava/menu/event/MenusAddedEvent.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * An event indicating one or more menu items have been added to the * {@link MenuService}'s {@link ShadowMenu}. - * + * * @author Curtis Rueden */ public class MenusAddedEvent extends MenuEvent { diff --git a/src/main/java/org/scijava/menu/event/MenusRemovedEvent.java b/src/main/java/org/scijava/menu/event/MenusRemovedEvent.java index fe156cde6..64fabe626 100644 --- a/src/main/java/org/scijava/menu/event/MenusRemovedEvent.java +++ b/src/main/java/org/scijava/menu/event/MenusRemovedEvent.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * An event indicating one or more menu items have been removed from the * {@link MenuService}'s {@link ShadowMenu}. - * + * * @author Curtis Rueden */ public class MenusRemovedEvent extends MenuEvent { diff --git a/src/main/java/org/scijava/menu/event/MenusUpdatedEvent.java b/src/main/java/org/scijava/menu/event/MenusUpdatedEvent.java index 01df28f33..44a720728 100644 --- a/src/main/java/org/scijava/menu/event/MenusUpdatedEvent.java +++ b/src/main/java/org/scijava/menu/event/MenusUpdatedEvent.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * An event indicating one or more menu items have been adjusted in the * {@link MenuService}'s {@link ShadowMenu}. - * + * * @author Curtis Rueden */ public class MenusUpdatedEvent extends MenuEvent { diff --git a/src/main/java/org/scijava/module/AbstractModule.java b/src/main/java/org/scijava/module/AbstractModule.java index e6400f7cc..0124ec8d7 100644 --- a/src/main/java/org/scijava/module/AbstractModule.java +++ b/src/main/java/org/scijava/module/AbstractModule.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ *

      * By default, input and output values are stored in {@link HashMap}s. *

      - * + * * @author Curtis Rueden */ public abstract class AbstractModule implements Module { diff --git a/src/main/java/org/scijava/module/AbstractModuleInfo.java b/src/main/java/org/scijava/module/AbstractModuleInfo.java index 78747cacb..6960de878 100644 --- a/src/main/java/org/scijava/module/AbstractModuleInfo.java +++ b/src/main/java/org/scijava/module/AbstractModuleInfo.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ * By default, {@link ModuleItem}s are stored in {@link HashMap}s and * {@link ArrayList}s, internally. *

      - * + * * @author Curtis Rueden */ public abstract class AbstractModuleInfo extends AbstractUIDetails implements diff --git a/src/main/java/org/scijava/module/AbstractModuleItem.java b/src/main/java/org/scijava/module/AbstractModuleItem.java index ad9b863d2..a38528beb 100644 --- a/src/main/java/org/scijava/module/AbstractModuleItem.java +++ b/src/main/java/org/scijava/module/AbstractModuleItem.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ /** * Abstract superclass of {@link ModuleItem} implementations. - * + * * @author Curtis Rueden */ public abstract class AbstractModuleItem extends AbstractBasicDetails @@ -193,8 +193,8 @@ public String getInitializer() { public void initialize(final Module module) throws MethodCallException { final Object delegateObject = module.getDelegateObject(); if (initializerRef == null) { - initializerRef = - new MethodRef(delegateObject.getClass(), getInitializer()); + initializerRef = new MethodRef(delegateObject.getClass(), + getInitializer()); } initializerRef.execute(module.getDelegateObject()); } diff --git a/src/main/java/org/scijava/module/DefaultModuleService.java b/src/main/java/org/scijava/module/DefaultModuleService.java index b6d3fa025..c45750f0d 100644 --- a/src/main/java/org/scijava/module/DefaultModuleService.java +++ b/src/main/java/org/scijava/module/DefaultModuleService.java @@ -6,13 +6,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 @@ -64,7 +64,7 @@ /** * Default service for keeping track of and executing available modules. - * + * * @author Curtis Rueden * @see Module * @see ModuleInfo @@ -170,7 +170,8 @@ public Module createModule(final ModuleInfo info) { return module; } catch (final ModuleException exc) { - if (log != null) log.error("Cannot create module: " + info.getDelegateClassName(), exc); + if (log != null) log.error("Cannot create module: " + info + .getDelegateClassName(), exc); } return null; } @@ -209,15 +210,15 @@ public Future run(final ModuleInfo info, } @Override - public Future run(final M module, - final boolean process, final Object... inputs) + public Future run(final M module, final boolean process, + final Object... inputs) { return run(module, pre(process), post(process), inputs); } @Override - public Future run(final M module, - final boolean process, final Map inputMap) + public Future run(final M module, final boolean process, + final Map inputMap) { return run(module, pre(process), post(process), inputMap); } @@ -237,8 +238,8 @@ public Future run(final M module, final Map inputMap) { assignInputs(module, inputMap); - final ModuleRunner runner = - new ModuleRunner(getContext(), module, pre, post); + final ModuleRunner runner = new ModuleRunner(getContext(), module, pre, + post); @SuppressWarnings("unchecked") final Callable callable = (Callable) runner; final Future future = threadService.run(callable); @@ -274,12 +275,16 @@ public ModuleItem getSingleOutput(final Module module, } @Override - public ModuleItem getSingleInput(Module module, Collection> types) { + public ModuleItem getSingleInput(Module module, + Collection> types) + { return getSingleItem(module, types, module.getInfo().inputs()); } @Override - public ModuleItem getSingleOutput(Module module, Collection> types) { + public ModuleItem getSingleOutput(Module module, + Collection> types) + { return getSingleItem(module, types, module.getInfo().outputs()); } @@ -295,7 +300,8 @@ public void save(final ModuleItem item, final T value) { return; } - final String sValue = value == null ? "" : convertService.convert(value, String.class); + final String sValue = value == null ? "" : convertService.convert(value, + String.class); // do not persist if object cannot be converted back from a string if (!convertService.supports(sValue, item.getType())) return; @@ -315,7 +321,7 @@ public T load(final ModuleItem item) { return convertService.convert(sValue, item.getType()); } - + @Override public T getDefaultValue(final ModuleItem item) { final T defaultValue = item.getDefaultValue(); @@ -429,7 +435,8 @@ private Map createMap(final Object[] values) { } if (values.length % 2 != 0) { - if (log != null) log.error("Ignoring extraneous argument: " + values[values.length - 1]); + if (log != null) log.error("Ignoring extraneous argument: " + + values[values.length - 1]); } // loop over list of key/value pairs @@ -459,7 +466,8 @@ private void assignInputs(final Module module, final Object value = inputMap.get(name); final Object converted; if (input == null) { - // inputs whose name starts with a dot are implicitly known by convention + // inputs whose name starts with a dot are implicitly known by + // convention if (!name.startsWith(".")) { if (log != null) log.warn("Unmatched input: " + name); } @@ -470,8 +478,8 @@ private void assignInputs(final Module module, converted = convertService.convert(value, type); if (value != null && converted == null) { if (log != null) { - log.error("For input " + name + ": incompatible object " + - value.getClass().getName() + " for type " + type.getName()); + log.error("For input " + name + ": incompatible object " + value + .getClass().getName() + " for type " + type.getName()); } continue; } @@ -552,8 +560,8 @@ private void loadInput(final Module module, final ModuleItem item) { item.setValue(module, value); } - private T getBestValue(final Object prefValue, - final Object defaultValue, final Class type) + private T getBestValue(final Object prefValue, final Object defaultValue, + final Class type) { if (prefValue != null) return convertService.convert(prefValue, type); if (defaultValue != null) { diff --git a/src/main/java/org/scijava/module/DefaultMutableModule.java b/src/main/java/org/scijava/module/DefaultMutableModule.java index 2d483797a..54f45cfd0 100644 --- a/src/main/java/org/scijava/module/DefaultMutableModule.java +++ b/src/main/java/org/scijava/module/DefaultMutableModule.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Default {@link MutableModule} implementation, intended for subclassing. - * + * * @author Curtis Rueden */ public class DefaultMutableModule extends AbstractModule implements diff --git a/src/main/java/org/scijava/module/DefaultMutableModuleInfo.java b/src/main/java/org/scijava/module/DefaultMutableModuleInfo.java index e41f52465..a8a86110c 100644 --- a/src/main/java/org/scijava/module/DefaultMutableModuleInfo.java +++ b/src/main/java/org/scijava/module/DefaultMutableModuleInfo.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ * {@link #createModule()} methods will fail if the module class has not been * set. *

      - * + * * @author Curtis Rueden */ public class DefaultMutableModuleInfo extends AbstractModuleInfo implements diff --git a/src/main/java/org/scijava/module/DefaultMutableModuleItem.java b/src/main/java/org/scijava/module/DefaultMutableModuleItem.java index 956d245d6..9694f3992 100644 --- a/src/main/java/org/scijava/module/DefaultMutableModuleItem.java +++ b/src/main/java/org/scijava/module/DefaultMutableModuleItem.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ /** * Default {@link MutableModuleItem} implementation, for use with custom * {@link MutableModule} implementations. - * + * * @author Curtis Rueden */ public class DefaultMutableModuleItem extends AbstractModuleItem diff --git a/src/main/java/org/scijava/module/MethodCallException.java b/src/main/java/org/scijava/module/MethodCallException.java index 5dd89a0d6..fc6f50786 100644 --- a/src/main/java/org/scijava/module/MethodCallException.java +++ b/src/main/java/org/scijava/module/MethodCallException.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An exception thrown when a reflective method execution fails. - * + * * @author Curtis Rueden */ public class MethodCallException extends ModuleException { diff --git a/src/main/java/org/scijava/module/MethodRef.java b/src/main/java/org/scijava/module/MethodRef.java index 8dff15695..ff4a0009d 100644 --- a/src/main/java/org/scijava/module/MethodRef.java +++ b/src/main/java/org/scijava/module/MethodRef.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * A reference to a {@link Method}, which can be invoked at will. - * + * * @author Curtis Rueden */ public class MethodRef implements Validated { @@ -48,8 +48,7 @@ public class MethodRef implements Validated { private final String label; /** List of problems when initializing the method reference. */ - private final List problems = - new ArrayList<>(); + private final List problems = new ArrayList<>(); public MethodRef(final Class clazz, final String methodName, final Class... params) @@ -91,8 +90,8 @@ private Method findMethod(final Class clazz, final String methodName, break; } } - final String problem = - "Method not found: " + clazz.getName() + "#" + methodName; + final String problem = "Method not found: " + clazz.getName() + "#" + + methodName; problems.add(new ValidityProblem(problem)); return null; } diff --git a/src/main/java/org/scijava/module/Module.java b/src/main/java/org/scijava/module/Module.java index a60bd7d3e..b3f89b1db 100644 --- a/src/main/java/org/scijava/module/Module.java +++ b/src/main/java/org/scijava/module/Module.java @@ -6,13 +6,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 @@ -48,7 +48,7 @@ * while the corresponding {@link ModuleInfo} represents metadata about that * module, particularly its input and output names and types. *

      - * + * * @author Aivar Grislis * @author Curtis Rueden */ @@ -59,7 +59,7 @@ public interface Module extends Runnable { * preview is a quick approximation of the results that would be obtained by * actually executing the module with {@link #run()}. Not all modules support * previews. - * + * * @see ModuleInfo#canPreview() */ void preview(); @@ -68,7 +68,7 @@ public interface Module extends Runnable { * Performs necessary cleanup in response to cancellation of the module * execution. This is useful in conjunction with {@link #preview()} to undo * any changes made as a result of the preview. - * + * * @see ModuleInfo#canCancel() */ void cancel(); @@ -80,7 +80,7 @@ public interface Module extends Runnable { * by each individual {@link ModuleItem} initializer method (i.e., * {@link ModuleItem#initialize(Module)}). *

      - * + * * @see ModuleInfo#getInitializer() * @see ModuleItem#initialize(Module) */ @@ -130,14 +130,14 @@ public interface Module extends Runnable { /** * 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); @@ -166,14 +166,14 @@ public interface Module extends Runnable { /** * Marks the input with the given name as unresolved. - * + * * @see #resolveInput(String) */ void unresolveInput(String name); /** * Marks the output with the given name as unresolved. - * + * * @see #resolveOutput(String) */ void unresolveOutput(String name); diff --git a/src/main/java/org/scijava/module/ModuleCanceledException.java b/src/main/java/org/scijava/module/ModuleCanceledException.java index cd8cb0cf4..598189c75 100644 --- a/src/main/java/org/scijava/module/ModuleCanceledException.java +++ b/src/main/java/org/scijava/module/ModuleCanceledException.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An exception thrown when a module execution is canceled. - * + * * @author Curtis Rueden */ public class ModuleCanceledException extends ModuleException { diff --git a/src/main/java/org/scijava/module/ModuleException.java b/src/main/java/org/scijava/module/ModuleException.java index c178e6a39..185eef81a 100644 --- a/src/main/java/org/scijava/module/ModuleException.java +++ b/src/main/java/org/scijava/module/ModuleException.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An exception thrown when something goes wrong with a module. - * + * * @author Curtis Rueden */ public class ModuleException extends Exception { diff --git a/src/main/java/org/scijava/module/ModuleIndex.java b/src/main/java/org/scijava/module/ModuleIndex.java index 0b11c9f52..f9c2b9b94 100644 --- a/src/main/java/org/scijava/module/ModuleIndex.java +++ b/src/main/java/org/scijava/module/ModuleIndex.java @@ -6,13 +6,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,7 +33,7 @@ /** * Data structure for managing registered modules. - * + * * @author Curtis Rueden */ public class ModuleIndex extends SortedObjectIndex { diff --git a/src/main/java/org/scijava/module/ModuleInfo.java b/src/main/java/org/scijava/module/ModuleInfo.java index 73e1a59a9..c773717d5 100644 --- a/src/main/java/org/scijava/module/ModuleInfo.java +++ b/src/main/java/org/scijava/module/ModuleInfo.java @@ -6,13 +6,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 @@ -51,7 +51,7 @@ * {@code name} starts with a dot (e.g. {@code .helloWorld}), no warning is * issued about an unmatched input. *

      - * + * * @author Aivar Grislis * @author Curtis Rueden */ @@ -64,7 +64,7 @@ public interface ModuleInfo extends UIDetails, Validated, Identifiable, /** * Gets the input item with the given name and type. - * + * * @throws IllegalArgumentException if the given type is incompatible with the * named input item */ @@ -75,7 +75,7 @@ public interface ModuleInfo extends UIDetails, Validated, Identifiable, /** * Gets the output item with the given name and type. - * + * * @throws IllegalArgumentException if the given type is incompatible with the * named output item */ @@ -111,7 +111,7 @@ public interface ModuleInfo extends UIDetails, Validated, Identifiable, * Loads the class containing the module's actual implementation. The name of * the loaded class will match the value returned by * {@link #getDelegateClassName()}. - * + * * @see org.scijava.Instantiable#loadClass() */ Class loadDelegateClass() throws ClassNotFoundException; diff --git a/src/main/java/org/scijava/module/ModuleItem.java b/src/main/java/org/scijava/module/ModuleItem.java index 0007ee040..4f36c2d07 100644 --- a/src/main/java/org/scijava/module/ModuleItem.java +++ b/src/main/java/org/scijava/module/ModuleItem.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * A ModuleItem represents metadata about one input or output of a module. - * + * * @author Aivar Grislis * @author Curtis Rueden */ @@ -58,7 +58,7 @@ public interface ModuleItem extends BasicDetails { * {@link #getType()}, but some module inputs or outputs may be backed by a * generic type such as {@code List} or {@code Iterable}. *

      - * + * * @see Field#getGenericType() */ Type getGenericType(); @@ -116,7 +116,7 @@ public interface ModuleItem extends BasicDetails { /** * Invokes this item's initializer function, if any, on the given module. - * + * * @see #getInitializer() */ void initialize(Module module) throws MethodCallException; @@ -126,7 +126,7 @@ public interface ModuleItem extends BasicDetails { /** * Invokes this item's validation function, if any, on the given module. - * + * * @see #getValidater() */ void validate(Module module) throws MethodCallException; @@ -143,7 +143,7 @@ public interface ModuleItem extends BasicDetails { /** * Invokes this item's callback function, if any, on the given module. - * + * * @see #getCallback() */ void callback(Module module) throws MethodCallException; diff --git a/src/main/java/org/scijava/module/ModuleRunner.java b/src/main/java/org/scijava/module/ModuleRunner.java index 49879fe71..df2ebed2b 100644 --- a/src/main/java/org/scijava/module/ModuleRunner.java +++ b/src/main/java/org/scijava/module/ModuleRunner.java @@ -6,13 +6,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 @@ -58,7 +58,7 @@ * easier to invoke in a variety of ways, such as with the * {@link java.util.concurrent} package. *

      - * + * * @author Curtis Rueden */ public class ModuleRunner extends AbstractContextual implements @@ -92,7 +92,7 @@ public ModuleRunner(final Context context, final Module module, /** * Feeds the module through the {@link ModulePreprocessor}s. - * + * * @return The preprocessor that canceled the execution, or null if all * preprocessors completed successfully. */ @@ -213,8 +213,8 @@ private boolean isCanceled() { } private String getCancelReason() { - return module instanceof Cancelable ? - ((Cancelable) module).getCancelReason() : null; + return module instanceof Cancelable ? ((Cancelable) module) + .getCancelReason() : null; } private void cancel(final String reason) { diff --git a/src/main/java/org/scijava/module/ModuleService.java b/src/main/java/org/scijava/module/ModuleService.java index 8b8ed2f51..aaa0d550a 100644 --- a/src/main/java/org/scijava/module/ModuleService.java +++ b/src/main/java/org/scijava/module/ModuleService.java @@ -6,13 +6,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 @@ -57,14 +57,14 @@ * methods. *

      *

      - * A module is distinct from a plugin in that plugins extend - * a program's functionality in some way, taking many forms, whereas modules - * are always runnable code with typed inputs and outputs. There is a - * particular type of plugin called a {@link org.scijava.command.Command} which - * is also a module, but many plugins (e.g., {@link org.scijava.tool.Tool}s and + * A module is distinct from a plugin in that plugins extend a + * program's functionality in some way, taking many forms, whereas modules are + * always runnable code with typed inputs and outputs. There is a particular + * type of plugin called a {@link org.scijava.command.Command} which is also a + * module, but many plugins (e.g., {@link org.scijava.tool.Tool}s and * {@link org.scijava.display.Display}s) are not modules. *

      - * + * * @author Curtis Rueden * @see Module * @see org.scijava.plugin.PluginService @@ -91,7 +91,7 @@ public interface ModuleService extends SciJavaService { /** * 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. */ @@ -99,7 +99,7 @@ public interface ModuleService extends SciJavaService { /** * Gets the module for a given keyboard shortcut. - * + * * @param acc the accelerator for which to search. * @return the module info for the corresponding module, or null. */ @@ -122,7 +122,7 @@ public interface ModuleService extends SciJavaService { /** * Executes the given module. - * + * * @param info The module to instantiate and run. * @param process If true, executes the module with pre- and postprocessing * steps from all available {@link PreprocessorPlugin}s and @@ -141,7 +141,7 @@ public interface ModuleService extends SciJavaService { /** * Executes the given module. - * + * * @param info The module to instantiate and run. * @param process If true, executes the module with pre- and postprocessing * steps from all available {@link PreprocessorPlugin}s and @@ -159,7 +159,7 @@ Future run(ModuleInfo info, boolean process, /** * Executes the given module. - * + * * @param info The module to instantiate and run. * @param pre List of preprocessing steps to perform. * @param post List of postprocessing steps to perform. @@ -177,7 +177,7 @@ Future run(ModuleInfo info, List pre, /** * Executes the given module. - * + * * @param info The module to instantiate and run. * @param pre List of preprocessing steps to perform. * @param post List of postprocessing steps to perform. @@ -193,7 +193,7 @@ Future run(ModuleInfo info, List pre, /** * Executes the given module. - * + * * @param module The module to run. * @param process If true, executes the module with pre- and postprocessing * steps from all available {@link PreprocessorPlugin}s and @@ -212,7 +212,7 @@ Future run(ModuleInfo info, List pre, /** * Executes the given module. - * + * * @param module The module to run. * @param process If true, executes the module with pre- and postprocessing * steps from all available {@link PreprocessorPlugin}s and @@ -230,7 +230,7 @@ Future run(M module, boolean process, /** * Executes the given module. - * + * * @param module The module to run. * @param pre List of preprocessing steps to perform. * @param post List of postprocessing steps to perform. @@ -249,7 +249,7 @@ Future run(M module, /** * Executes the given module. - * + * * @param module The module to run. * @param pre List of preprocessing steps to perform. * @param post List of postprocessing steps to perform. diff --git a/src/main/java/org/scijava/module/MutableModule.java b/src/main/java/org/scijava/module/MutableModule.java index 87e839206..8737d73fa 100644 --- a/src/main/java/org/scijava/module/MutableModule.java +++ b/src/main/java/org/scijava/module/MutableModule.java @@ -6,13 +6,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,7 +38,7 @@ * A {@code MutableModule} always has {@link MutableModuleInfo} attached to it, * accessible via the {@link #getInfo()} method. *

      - * + * * @author Curtis Rueden * @see org.scijava.command.DynamicCommand */ @@ -48,8 +48,8 @@ public interface MutableModule extends Module { default MutableModuleItem addInput(final String name, final Class type) { - final DefaultMutableModuleItem item = - new DefaultMutableModuleItem<>(this, name, type); + final DefaultMutableModuleItem item = new DefaultMutableModuleItem<>( + this, name, type); addInput(item); return item; } @@ -63,8 +63,8 @@ default void addInput(final ModuleItem input) { default MutableModuleItem addOutput(final String name, final Class type) { - final DefaultMutableModuleItem item = - new DefaultMutableModuleItem<>(this, name, type); + final DefaultMutableModuleItem item = new DefaultMutableModuleItem<>( + this, name, type); addOutput(item); return item; } diff --git a/src/main/java/org/scijava/module/MutableModuleInfo.java b/src/main/java/org/scijava/module/MutableModuleInfo.java index fd3cbbb2d..a48e786c5 100644 --- a/src/main/java/org/scijava/module/MutableModuleInfo.java +++ b/src/main/java/org/scijava/module/MutableModuleInfo.java @@ -6,13 +6,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,7 +38,7 @@ * Note that a {@code MutableModuleInfo} does not necessarily have * {@link MutableModuleItem}s! *

      - * + * * @author Curtis Rueden * @see org.scijava.command.DynamicCommand */ diff --git a/src/main/java/org/scijava/module/MutableModuleItem.java b/src/main/java/org/scijava/module/MutableModuleItem.java index a3b4ccc09..08b6dd7d0 100644 --- a/src/main/java/org/scijava/module/MutableModuleItem.java +++ b/src/main/java/org/scijava/module/MutableModuleItem.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * {@link ModuleItem} extension allowing manipulation of its metadata. - * + * * @author Curtis Rueden * @see org.scijava.command.DynamicCommand */ diff --git a/src/main/java/org/scijava/module/event/ModuleCanceledEvent.java b/src/main/java/org/scijava/module/event/ModuleCanceledEvent.java index 9016e323a..704053d97 100644 --- a/src/main/java/org/scijava/module/event/ModuleCanceledEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleCanceledEvent.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ * declaring itself canceled (via the {@link Cancelable#isCanceled()} method * returning true) after its {@link Module#run()} method returns. *

      - * + * * @author Curtis Rueden */ public class ModuleCanceledEvent extends ModuleExecutionEvent { diff --git a/src/main/java/org/scijava/module/event/ModuleErroredEvent.java b/src/main/java/org/scijava/module/event/ModuleErroredEvent.java index 364772b38..41d2aa959 100644 --- a/src/main/java/org/scijava/module/event/ModuleErroredEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleErroredEvent.java @@ -6,13 +6,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/module/event/ModuleEvent.java b/src/main/java/org/scijava/module/event/ModuleEvent.java index 96c3ddca3..87c8b3819 100644 --- a/src/main/java/org/scijava/module/event/ModuleEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An event indicating something has happened to a module. - * + * * @author Curtis Rueden */ public abstract class ModuleEvent extends SciJavaEvent { diff --git a/src/main/java/org/scijava/module/event/ModuleExecutedEvent.java b/src/main/java/org/scijava/module/event/ModuleExecutedEvent.java index 2942ea56d..2793f1d29 100644 --- a/src/main/java/org/scijava/module/event/ModuleExecutedEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleExecutedEvent.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ * This event occurs after all preprocessors have successfully run, as well as * the module itself, but before any postprocessors have been invoked. *

      - * + * * @author Curtis Rueden */ public class ModuleExecutedEvent extends ModuleExecutionEvent { diff --git a/src/main/java/org/scijava/module/event/ModuleExecutingEvent.java b/src/main/java/org/scijava/module/event/ModuleExecutingEvent.java index f1fd53f5c..10bd550e8 100644 --- a/src/main/java/org/scijava/module/event/ModuleExecutingEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleExecutingEvent.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ * This event occurs after all preprocessors have successfully run, but before * the module itself has run. *

      - * + * * @author Curtis Rueden */ public class ModuleExecutingEvent extends ModuleExecutionEvent { diff --git a/src/main/java/org/scijava/module/event/ModuleExecutionEvent.java b/src/main/java/org/scijava/module/event/ModuleExecutionEvent.java index 940a9d8e0..ef16f36da 100644 --- a/src/main/java/org/scijava/module/event/ModuleExecutionEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleExecutionEvent.java @@ -6,13 +6,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,7 +33,7 @@ /** * An event relating to execution of a {@link Module}. - * + * * @author Curtis Rueden */ public abstract class ModuleExecutionEvent extends ModuleEvent { diff --git a/src/main/java/org/scijava/module/event/ModuleFinishedEvent.java b/src/main/java/org/scijava/module/event/ModuleFinishedEvent.java index 692be5b92..f744b41c3 100644 --- a/src/main/java/org/scijava/module/event/ModuleFinishedEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleFinishedEvent.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ *

      * This event occurs after all postprocessors have been invoked. *

      - * + * * @author Curtis Rueden */ public class ModuleFinishedEvent extends ModuleExecutionEvent { diff --git a/src/main/java/org/scijava/module/event/ModulePostprocessEvent.java b/src/main/java/org/scijava/module/event/ModulePostprocessEvent.java index 9d42be6ab..6cb891f4e 100644 --- a/src/main/java/org/scijava/module/event/ModulePostprocessEvent.java +++ b/src/main/java/org/scijava/module/event/ModulePostprocessEvent.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * An event indicating a {@link ModulePostprocessor} has been invoked as part of * a module execution. - * + * * @author Curtis Rueden */ public class ModulePostprocessEvent extends ModuleProcessEvent { diff --git a/src/main/java/org/scijava/module/event/ModulePreprocessEvent.java b/src/main/java/org/scijava/module/event/ModulePreprocessEvent.java index 760c2c55f..f1627e276 100644 --- a/src/main/java/org/scijava/module/event/ModulePreprocessEvent.java +++ b/src/main/java/org/scijava/module/event/ModulePreprocessEvent.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * An event indicating a {@link ModulePreprocessor} has been invoked as part of * a module execution. - * + * * @author Curtis Rueden */ public class ModulePreprocessEvent extends ModuleProcessEvent { diff --git a/src/main/java/org/scijava/module/event/ModuleProcessEvent.java b/src/main/java/org/scijava/module/event/ModuleProcessEvent.java index b58046091..2acf832ab 100644 --- a/src/main/java/org/scijava/module/event/ModuleProcessEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleProcessEvent.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * An event indicating a {@link ModuleProcessor} has been invoked as part of a * module execution. - * + * * @author Curtis Rueden */ public abstract class ModuleProcessEvent extends ModuleExecutionEvent { diff --git a/src/main/java/org/scijava/module/event/ModuleStartedEvent.java b/src/main/java/org/scijava/module/event/ModuleStartedEvent.java index 975c5e8af..0b5a96574 100644 --- a/src/main/java/org/scijava/module/event/ModuleStartedEvent.java +++ b/src/main/java/org/scijava/module/event/ModuleStartedEvent.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ *

      * This event occurs even before any preprocessors have been run. *

      - * + * * @author Curtis Rueden */ public class ModuleStartedEvent extends ModuleExecutionEvent { diff --git a/src/main/java/org/scijava/module/event/ModulesAddedEvent.java b/src/main/java/org/scijava/module/event/ModulesAddedEvent.java index aa3b3877c..273ba46f4 100644 --- a/src/main/java/org/scijava/module/event/ModulesAddedEvent.java +++ b/src/main/java/org/scijava/module/event/ModulesAddedEvent.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * An event indicating one or more modules have been added to the * {@link ModuleService}. - * + * * @author Curtis Rueden */ public class ModulesAddedEvent extends ModulesListEvent { diff --git a/src/main/java/org/scijava/module/event/ModulesListEvent.java b/src/main/java/org/scijava/module/event/ModulesListEvent.java index 95b2c1c28..5d99b8b01 100644 --- a/src/main/java/org/scijava/module/event/ModulesListEvent.java +++ b/src/main/java/org/scijava/module/event/ModulesListEvent.java @@ -6,13 +6,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,7 +38,7 @@ /** * An event indicating something has happened to the list of plugins registered * with the {@link ModuleService}. - * + * * @author Curtis Rueden */ public abstract class ModulesListEvent extends ListEvent { diff --git a/src/main/java/org/scijava/module/event/ModulesRemovedEvent.java b/src/main/java/org/scijava/module/event/ModulesRemovedEvent.java index f60959dbc..5d454bb75 100644 --- a/src/main/java/org/scijava/module/event/ModulesRemovedEvent.java +++ b/src/main/java/org/scijava/module/event/ModulesRemovedEvent.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * An event indicating one or more modules have been removed from the * {@link ModuleService}. - * + * * @author Curtis Rueden */ public class ModulesRemovedEvent extends ModulesListEvent { diff --git a/src/main/java/org/scijava/module/event/ModulesUpdatedEvent.java b/src/main/java/org/scijava/module/event/ModulesUpdatedEvent.java index a0a14f75d..cdf2a4fe7 100644 --- a/src/main/java/org/scijava/module/event/ModulesUpdatedEvent.java +++ b/src/main/java/org/scijava/module/event/ModulesUpdatedEvent.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * An event indicating one or more module details have been updated. - * + * * @author Curtis Rueden */ public class ModulesUpdatedEvent extends ModulesListEvent { diff --git a/src/main/java/org/scijava/module/process/AbstractPostprocessorPlugin.java b/src/main/java/org/scijava/module/process/AbstractPostprocessorPlugin.java index 8ac5886d5..68c731f95 100644 --- a/src/main/java/org/scijava/module/process/AbstractPostprocessorPlugin.java +++ b/src/main/java/org/scijava/module/process/AbstractPostprocessorPlugin.java @@ -6,13 +6,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,7 +33,7 @@ /** * Abstract base class for plugin postprocessors. - * + * * @author Curtis Rueden */ public abstract class AbstractPostprocessorPlugin extends AbstractContextual diff --git a/src/main/java/org/scijava/module/process/AbstractPreprocessorPlugin.java b/src/main/java/org/scijava/module/process/AbstractPreprocessorPlugin.java index 4f5f625ca..11ffaad77 100644 --- a/src/main/java/org/scijava/module/process/AbstractPreprocessorPlugin.java +++ b/src/main/java/org/scijava/module/process/AbstractPreprocessorPlugin.java @@ -6,13 +6,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,7 +33,7 @@ /** * Abstract base class for plugin preprocessors. - * + * * @author Curtis Rueden */ public abstract class AbstractPreprocessorPlugin extends AbstractContextual diff --git a/src/main/java/org/scijava/module/process/AbstractSingleInputPreprocessor.java b/src/main/java/org/scijava/module/process/AbstractSingleInputPreprocessor.java index b373722ee..f8e996514 100644 --- a/src/main/java/org/scijava/module/process/AbstractSingleInputPreprocessor.java +++ b/src/main/java/org/scijava/module/process/AbstractSingleInputPreprocessor.java @@ -6,13 +6,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/module/process/CheckInputsPreprocessor.java b/src/main/java/org/scijava/module/process/CheckInputsPreprocessor.java index fff89a404..f540bb104 100644 --- a/src/main/java/org/scijava/module/process/CheckInputsPreprocessor.java +++ b/src/main/java/org/scijava/module/process/CheckInputsPreprocessor.java @@ -6,13 +6,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,7 +38,7 @@ /** * A preprocessor plugin that does a final check of input parameters, * complaining if any required ones are null. - * + * * @author Curtis Rueden */ @Plugin(type = PreprocessorPlugin.class, diff --git a/src/main/java/org/scijava/module/process/DebugPostprocessor.java b/src/main/java/org/scijava/module/process/DebugPostprocessor.java index 2760cea81..f4ebccc99 100644 --- a/src/main/java/org/scijava/module/process/DebugPostprocessor.java +++ b/src/main/java/org/scijava/module/process/DebugPostprocessor.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * A postprocessor plugin that dumps parameter values to the log. - * + * * @author Curtis Rueden */ @Plugin(type = PostprocessorPlugin.class, priority = Priority.FIRST) diff --git a/src/main/java/org/scijava/module/process/DebugPreprocessor.java b/src/main/java/org/scijava/module/process/DebugPreprocessor.java index 59db93a4e..f03f675f4 100644 --- a/src/main/java/org/scijava/module/process/DebugPreprocessor.java +++ b/src/main/java/org/scijava/module/process/DebugPreprocessor.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * A preprocessor plugin that dumps information to the log. - * + * * @author Curtis Rueden */ @Plugin(type = PreprocessorPlugin.class, priority = Priority.FIRST) diff --git a/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java b/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java index b85d7ce60..15ad91425 100644 --- a/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java +++ b/src/main/java/org/scijava/module/process/DefaultValuePreprocessor.java @@ -6,13 +6,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/module/process/GatewayPreprocessor.java b/src/main/java/org/scijava/module/process/GatewayPreprocessor.java index c080e8100..2177a51f6 100644 --- a/src/main/java/org/scijava/module/process/GatewayPreprocessor.java +++ b/src/main/java/org/scijava/module/process/GatewayPreprocessor.java @@ -6,13 +6,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 @@ -47,7 +47,7 @@ * Gateways are instantiated as needed, wrapping this preprocessor instance's * application context. *

      - * + * * @author Curtis Rueden */ @Plugin(type = PreprocessorPlugin.class, priority = 2 * Priority.VERY_HIGH) @@ -62,7 +62,8 @@ public class GatewayPreprocessor extends AbstractPreprocessorPlugin { public void process(final Module module) { for (final ModuleItem input : module.getInfo().inputs()) { if (!input.isAutoFill()) continue; // skip unfillable inputs - if (module.isInputResolved(input.getName())) continue; // skip resolved inputs + if (module.isInputResolved(input.getName())) continue; // skip resolved + // inputs final Class type = input.getType(); if (Gateway.class.isAssignableFrom(type)) { // input is a gateway diff --git a/src/main/java/org/scijava/module/process/InitPreprocessor.java b/src/main/java/org/scijava/module/process/InitPreprocessor.java index 7cbe03d34..9a7d39bd7 100644 --- a/src/main/java/org/scijava/module/process/InitPreprocessor.java +++ b/src/main/java/org/scijava/module/process/InitPreprocessor.java @@ -6,13 +6,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 @@ -42,7 +42,7 @@ *

      * This is done via a single call to {@link Module#initialize()}. *

      - * + * * @author Curtis Rueden */ @Plugin(type = PreprocessorPlugin.class, priority = Priority.HIGH) diff --git a/src/main/java/org/scijava/module/process/LoadInputsPreprocessor.java b/src/main/java/org/scijava/module/process/LoadInputsPreprocessor.java index abf184e9f..8553db21a 100644 --- a/src/main/java/org/scijava/module/process/LoadInputsPreprocessor.java +++ b/src/main/java/org/scijava/module/process/LoadInputsPreprocessor.java @@ -6,13 +6,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 @@ -40,14 +40,13 @@ *

      * This preprocessor runs late in the chain, to give other preprocessors a * chance to populate the inputs first. However, its priority immediately - * precedes the {@link org.scijava.widget.InputHarvester}'s, so that user-specified - * values from last time are populated in the user dialog. + * precedes the {@link org.scijava.widget.InputHarvester}'s, so that + * user-specified values from last time are populated in the user dialog. *

      - * + * * @author Curtis Rueden */ -@Plugin(type = PreprocessorPlugin.class, - priority = InputHarvester.PRIORITY + 1) +@Plugin(type = PreprocessorPlugin.class, priority = InputHarvester.PRIORITY + 1) public class LoadInputsPreprocessor extends AbstractPreprocessorPlugin { @Parameter diff --git a/src/main/java/org/scijava/module/process/LoggerPreprocessor.java b/src/main/java/org/scijava/module/process/LoggerPreprocessor.java index 2be46df60..ee919a265 100644 --- a/src/main/java/org/scijava/module/process/LoggerPreprocessor.java +++ b/src/main/java/org/scijava/module/process/LoggerPreprocessor.java @@ -6,13 +6,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 @@ -65,8 +65,8 @@ public void process(final Module module) { if (loggerInput == null || !loggerInput.isAutoFill()) return; String loggerName = loggerInput.getLabel(); - if(loggerName == null || loggerName.isEmpty()) - loggerName = module.getDelegateObject().getClass().getSimpleName(); + if (loggerName == null || loggerName.isEmpty()) loggerName = module + .getDelegateObject().getClass().getSimpleName(); Logger logger = logService.subLogger(loggerName); final String name = loggerInput.getName(); diff --git a/src/main/java/org/scijava/module/process/ModulePostprocessor.java b/src/main/java/org/scijava/module/process/ModulePostprocessor.java index 528c6a815..2ba1203b7 100644 --- a/src/main/java/org/scijava/module/process/ModulePostprocessor.java +++ b/src/main/java/org/scijava/module/process/ModulePostprocessor.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ * actual execution of a {@link Module}. Typically, a postprocessor does * something with the results of a module, such as displaying its outputs on * screen. - * + * * @author Curtis Rueden */ public interface ModulePostprocessor extends ModuleProcessor { diff --git a/src/main/java/org/scijava/module/process/ModulePreprocessor.java b/src/main/java/org/scijava/module/process/ModulePreprocessor.java index a1b65e315..1d771029f 100644 --- a/src/main/java/org/scijava/module/process/ModulePreprocessor.java +++ b/src/main/java/org/scijava/module/process/ModulePreprocessor.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ * return true, and its {@link #getCancelReason()} method may optionally explain * why. *

      - * + * * @author Curtis Rueden */ public interface ModulePreprocessor extends ModuleProcessor, Cancelable { diff --git a/src/main/java/org/scijava/module/process/ModuleProcessor.java b/src/main/java/org/scijava/module/process/ModuleProcessor.java index 696e06602..06d8bb298 100644 --- a/src/main/java/org/scijava/module/process/ModuleProcessor.java +++ b/src/main/java/org/scijava/module/process/ModuleProcessor.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ * A module processor defines some sort of processing that occurs on a module * instance, typically immediately preceding (see {@link ModulePreprocessor}) or * following (see {@link ModulePostprocessor}) the module execution. - * + * * @author Curtis Rueden */ public interface ModuleProcessor { diff --git a/src/main/java/org/scijava/module/process/PostprocessorPlugin.java b/src/main/java/org/scijava/module/process/PostprocessorPlugin.java index 8c0dc970b..38bf21077 100644 --- a/src/main/java/org/scijava/module/process/PostprocessorPlugin.java +++ b/src/main/java/org/scijava/module/process/PostprocessorPlugin.java @@ -6,13 +6,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 @@ -45,7 +45,7 @@ * postprocessor plugin merely by implementing this interface, it is encouraged * to instead extend {@link AbstractPostprocessorPlugin}, for convenience. *

      - * + * * @author Curtis Rueden * @see ModulePostprocessor */ diff --git a/src/main/java/org/scijava/module/process/PreprocessorPlugin.java b/src/main/java/org/scijava/module/process/PreprocessorPlugin.java index 2a13be6e0..4e6a1fd82 100644 --- a/src/main/java/org/scijava/module/process/PreprocessorPlugin.java +++ b/src/main/java/org/scijava/module/process/PreprocessorPlugin.java @@ -6,13 +6,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 @@ -45,7 +45,7 @@ * plugin merely by implementing this interface, it is encouraged to instead * extend {@link AbstractPreprocessorPlugin}, for convenience. *

      - * + * * @author Curtis Rueden * @see ModulePreprocessor */ diff --git a/src/main/java/org/scijava/module/process/SaveInputsPreprocessor.java b/src/main/java/org/scijava/module/process/SaveInputsPreprocessor.java index 0cabffa55..7550348bd 100644 --- a/src/main/java/org/scijava/module/process/SaveInputsPreprocessor.java +++ b/src/main/java/org/scijava/module/process/SaveInputsPreprocessor.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ * {@link org.scijava.widget.InputHarvester} has run, so that user-specified * values are persisted for next time. *

      - * + * * @author Curtis Rueden */ @Plugin(type = PreprocessorPlugin.class, diff --git a/src/main/java/org/scijava/module/process/ServicePreprocessor.java b/src/main/java/org/scijava/module/process/ServicePreprocessor.java index c195ffa93..6e034099e 100644 --- a/src/main/java/org/scijava/module/process/ServicePreprocessor.java +++ b/src/main/java/org/scijava/module/process/ServicePreprocessor.java @@ -6,13 +6,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 @@ -56,7 +56,7 @@ * rather than declared via the @{@link Parameter} annotation. In such cases, we * need this service preprocessor to fill in the service values. *

      - * + * * @author Curtis Rueden */ @Plugin(type = PreprocessorPlugin.class, priority = 2 * Priority.VERY_HIGH) @@ -68,7 +68,8 @@ public class ServicePreprocessor extends AbstractPreprocessorPlugin { public void process(final Module module) { for (final ModuleItem input : module.getInfo().inputs()) { if (!input.isAutoFill()) continue; // skip unfillable inputs - if (module.isInputResolved(input.getName())) continue; // skip resolved inputs + if (module.isInputResolved(input.getName())) continue; // skip resolved + // inputs final Class type = input.getType(); if (Service.class.isAssignableFrom(type)) { // input is a service diff --git a/src/main/java/org/scijava/module/process/ValidityPreprocessor.java b/src/main/java/org/scijava/module/process/ValidityPreprocessor.java index 78666b9bf..c6c64788e 100644 --- a/src/main/java/org/scijava/module/process/ValidityPreprocessor.java +++ b/src/main/java/org/scijava/module/process/ValidityPreprocessor.java @@ -6,13 +6,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,7 +38,7 @@ /** * A preprocessor plugin that verifies module validity. If the module is not * valid, the module execution is canceled. - * + * * @author Curtis Rueden */ @Plugin(type = PreprocessorPlugin.class, priority = 3 * Priority.VERY_HIGH) @@ -52,9 +52,8 @@ public void process(final Module module) { if (info.isValid()) return; - final StringBuilder sb = - new StringBuilder("The module \"" + info.getDelegateClassName() + - "\" is invalid:\n"); + final StringBuilder sb = new StringBuilder("The module \"" + info + .getDelegateClassName() + "\" is invalid:\n"); for (final ValidityProblem problem : info.getProblems()) { sb.append("- " + problem.getMessage()); sb.append("\n"); diff --git a/src/main/java/org/scijava/module/run/ModuleCodeRunner.java b/src/main/java/org/scijava/module/run/ModuleCodeRunner.java index 1e6ee836b..fcd7a6a9f 100644 --- a/src/main/java/org/scijava/module/run/ModuleCodeRunner.java +++ b/src/main/java/org/scijava/module/run/ModuleCodeRunner.java @@ -6,13 +6,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 @@ -42,7 +42,7 @@ /** * Runs the given {@link Identifiable} SciJava module. - * + * * @author Curtis Rueden * @see ModuleInfo */ diff --git a/src/main/java/org/scijava/object/DefaultObjectService.java b/src/main/java/org/scijava/object/DefaultObjectService.java index ccd8218a1..b69e08957 100644 --- a/src/main/java/org/scijava/object/DefaultObjectService.java +++ b/src/main/java/org/scijava/object/DefaultObjectService.java @@ -6,13 +6,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 @@ -49,7 +49,7 @@ * {@link org.scijava.widget.ObjectWidget}, which provide the user with a * multiple-choice selection. *

      - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) diff --git a/src/main/java/org/scijava/object/LazyObjects.java b/src/main/java/org/scijava/object/LazyObjects.java index 7a2ac555a..3f117c6a5 100644 --- a/src/main/java/org/scijava/object/LazyObjects.java +++ b/src/main/java/org/scijava/object/LazyObjects.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ * Interface for objects created lazily. This interface provides a mechanism to * register a callback of sorts, so that the {@link ObjectIndex} can request * creation of objects only when they are needed. - * + * * @author Curtis Rueden */ public interface LazyObjects extends Supplier> { diff --git a/src/main/java/org/scijava/object/NamedObjectIndex.java b/src/main/java/org/scijava/object/NamedObjectIndex.java index a05f326f1..145ee4ce8 100644 --- a/src/main/java/org/scijava/object/NamedObjectIndex.java +++ b/src/main/java/org/scijava/object/NamedObjectIndex.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.object; import java.util.WeakHashMap; @@ -36,7 +37,7 @@ * @author Jan Eglinger */ public class NamedObjectIndex extends ObjectIndex { - + private WeakHashMap nameMap; public NamedObjectIndex(final Class baseClass) { @@ -45,14 +46,12 @@ public NamedObjectIndex(final Class baseClass) { } public boolean add(E object, String name) { - if (name != null) - nameMap.put(object, name); + if (name != null) nameMap.put(object, name); return add(object); } public boolean add(E object, Class type, String name, boolean batch) { - if (name != null) - nameMap.put(object, name); + if (name != null) nameMap.put(object, name); return add(object, type, batch); } diff --git a/src/main/java/org/scijava/object/ObjectIndex.java b/src/main/java/org/scijava/object/ObjectIndex.java index c8c9df2c5..984b813e0 100644 --- a/src/main/java/org/scijava/object/ObjectIndex.java +++ b/src/main/java/org/scijava/object/ObjectIndex.java @@ -6,13 +6,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 @@ -68,7 +68,7 @@ * added to the index more than once, in which case it will appear on compatible * type lists multiple times. *

      - * + * * @author Curtis Rueden */ public class ObjectIndex implements Collection { @@ -77,14 +77,12 @@ public class ObjectIndex implements Collection { * "Them as counts counts moren them as dont count."
      * —Russell Hoban, Riddley Walker */ - protected final Map, List> hoard = - new ConcurrentHashMap<>(); + protected final Map, List> hoard = new ConcurrentHashMap<>(); private final Class baseClass; /** List of objects to add later as needed (i.e., lazily). */ - private final List> pending = - new LinkedList<>(); + private final List> pending = new LinkedList<>(); public ObjectIndex(final Class baseClass) { this.baseClass = baseClass; @@ -99,7 +97,7 @@ public Class getBaseClass() { /** * Gets a list of all registered objects. - * + * * @return Read-only list of all registered objects, or an empty list if none * (this method never returns null). */ @@ -121,9 +119,9 @@ public List getAll() { /** * Gets a list of registered objects compatible with the given type. - * - * @return New list of registered objects of the given type, or an empty - * list if no such objects exist (this method never returns null). + * + * @return New list of registered objects of the given type, or an empty list + * if no such objects exist (this method never returns null). */ public List get(final Class type) { // lazily register any pending objects @@ -282,8 +280,7 @@ protected boolean remove(final Object o, final boolean batch) { return remove(o, getType(e), batch); } - private Map, List[]> type2Lists = - new HashMap<>(); + private Map, List[]> type2Lists = new HashMap<>(); protected synchronized List[] retrieveListsForType(final Class type) { final List[] lists = type2Lists.get(type); @@ -295,8 +292,8 @@ protected synchronized List[] retrieveListsForType(final Class type) { } // convert list of lists to array of lists @SuppressWarnings("rawtypes") - final List[] arrayOfRawLists = - listOfLists.toArray(new List[listOfLists.size()]); + final List[] arrayOfRawLists = listOfLists.toArray(new List[listOfLists + .size()]); @SuppressWarnings({ "unchecked" }) final List[] arrayOfLists = arrayOfRawLists; type2Lists.put(type, arrayOfLists); @@ -309,7 +306,7 @@ protected synchronized List[] retrieveListsForType(final Class type) { protected boolean add(final E o, final Class type, final boolean batch) { boolean result = false; for (final List list : retrieveListsForType(type)) { - if (addToList(o, (List)list, batch)) result = true; + if (addToList(o, (List) list, batch)) result = true; } return result; } @@ -339,14 +336,13 @@ protected boolean removeFromList(final Object obj, final List list, // -- Helper methods -- - private static Map, Class[]> typeMap = - new HashMap<>(); + private static Map, Class[]> typeMap = 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()]); diff --git a/src/main/java/org/scijava/object/ObjectService.java b/src/main/java/org/scijava/object/ObjectService.java index 478be8af1..d968c5cbc 100644 --- a/src/main/java/org/scijava/object/ObjectService.java +++ b/src/main/java/org/scijava/object/ObjectService.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * Interface for object management service. - * + * * @author Curtis Rueden */ public interface ObjectService extends SciJavaService { diff --git a/src/main/java/org/scijava/object/SortedObjectIndex.java b/src/main/java/org/scijava/object/SortedObjectIndex.java index 0ffec7b19..7dcd3a5ce 100644 --- a/src/main/java/org/scijava/object/SortedObjectIndex.java +++ b/src/main/java/org/scijava/object/SortedObjectIndex.java @@ -6,13 +6,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 @@ -48,7 +48,7 @@ * at once (i.e., with {@link #addAll(Collection)}), the items are appended and * the list is then resorted (O(n log n) time for all items). *

      - * + * * @author Curtis Rueden */ public class SortedObjectIndex> extends @@ -142,7 +142,7 @@ private void mergeAfterSorting(final Collection c) { 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); @@ -166,7 +166,8 @@ private void mergeInto(final List sorted, final List into) { } int index1 = into.size() - 1; int index2 = sorted.size() - 1; - for (int i = 0; i < count; i++) into.add(null); + for (int i = 0; i < count; i++) + into.add(null); int writeIndex = into.size() - 1; E e1 = into.get(index1); E e2 = sorted.get(index2); @@ -175,7 +176,8 @@ private void mergeInto(final List sorted, final List into) { into.set(writeIndex--, e2); if (--index2 < 0) break; e2 = sorted.get(index2); - } else { + } + else { into.set(writeIndex--, e1); if (--index1 < 0) break; e1 = into.get(index1); diff --git a/src/main/java/org/scijava/object/event/ListEvent.java b/src/main/java/org/scijava/object/event/ListEvent.java index d13533817..90743bd0c 100644 --- a/src/main/java/org/scijava/object/event/ListEvent.java +++ b/src/main/java/org/scijava/object/event/ListEvent.java @@ -6,13 +6,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,7 +38,7 @@ /** * An event indicating something has happened to a list of items. - * + * * @author Curtis Rueden */ public abstract class ListEvent extends SciJavaEvent { diff --git a/src/main/java/org/scijava/object/event/ObjectCreatedEvent.java b/src/main/java/org/scijava/object/event/ObjectCreatedEvent.java index 53ad97b26..b7021d5e5 100644 --- a/src/main/java/org/scijava/object/event/ObjectCreatedEvent.java +++ b/src/main/java/org/scijava/object/event/ObjectCreatedEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An event indicating a new object has been created. The {@link ObjectService} * responds to this event by adding the object to its index. - * + * * @author Curtis Rueden */ public abstract class ObjectCreatedEvent extends ObjectEvent { diff --git a/src/main/java/org/scijava/object/event/ObjectDeletedEvent.java b/src/main/java/org/scijava/object/event/ObjectDeletedEvent.java index 1825bbc87..15819c54f 100644 --- a/src/main/java/org/scijava/object/event/ObjectDeletedEvent.java +++ b/src/main/java/org/scijava/object/event/ObjectDeletedEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An event indicating an object has been deleted. The {@link ObjectService} * responds to this event by removing the object from its index. - * + * * @author Curtis Rueden */ public abstract class ObjectDeletedEvent extends ObjectEvent { diff --git a/src/main/java/org/scijava/object/event/ObjectEvent.java b/src/main/java/org/scijava/object/event/ObjectEvent.java index e2b5abe73..421ad9114 100644 --- a/src/main/java/org/scijava/object/event/ObjectEvent.java +++ b/src/main/java/org/scijava/object/event/ObjectEvent.java @@ -6,13 +6,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,7 +33,7 @@ /** * An event indicating something has happened to an object. - * + * * @author Curtis Rueden */ public abstract class ObjectEvent extends SciJavaEvent { diff --git a/src/main/java/org/scijava/object/event/ObjectModifiedEvent.java b/src/main/java/org/scijava/object/event/ObjectModifiedEvent.java index e87836338..89adcf8c9 100644 --- a/src/main/java/org/scijava/object/event/ObjectModifiedEvent.java +++ b/src/main/java/org/scijava/object/event/ObjectModifiedEvent.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An event indicating an object has been modified somehow. - * + * * @author Curtis Rueden */ public abstract class ObjectModifiedEvent extends ObjectEvent { diff --git a/src/main/java/org/scijava/object/event/ObjectsAddedEvent.java b/src/main/java/org/scijava/object/event/ObjectsAddedEvent.java index 7487ee5ed..b73ae6d2f 100644 --- a/src/main/java/org/scijava/object/event/ObjectsAddedEvent.java +++ b/src/main/java/org/scijava/object/event/ObjectsAddedEvent.java @@ -6,13 +6,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 @@ -29,7 +29,6 @@ package org.scijava.object.event; - import java.util.Collection; import org.scijava.object.ObjectService; @@ -37,7 +36,7 @@ /** * An event indicating one or more objects have been added to the * {@link ObjectService}. - * + * * @author Curtis Rueden */ public class ObjectsAddedEvent extends ObjectsListEvent { diff --git a/src/main/java/org/scijava/object/event/ObjectsListEvent.java b/src/main/java/org/scijava/object/event/ObjectsListEvent.java index de8aaf9e2..b4e968314 100644 --- a/src/main/java/org/scijava/object/event/ObjectsListEvent.java +++ b/src/main/java/org/scijava/object/event/ObjectsListEvent.java @@ -6,13 +6,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 @@ -29,7 +29,6 @@ package org.scijava.object.event; - import java.util.Collection; import org.scijava.object.ObjectService; @@ -37,7 +36,7 @@ /** * An event indicating something has happened to the list of objects registered * with the {@link ObjectService}. - * + * * @author Grant Harris * @author Curtis Rueden */ diff --git a/src/main/java/org/scijava/object/event/ObjectsRemovedEvent.java b/src/main/java/org/scijava/object/event/ObjectsRemovedEvent.java index 2bf0f49ff..d640ba272 100644 --- a/src/main/java/org/scijava/object/event/ObjectsRemovedEvent.java +++ b/src/main/java/org/scijava/object/event/ObjectsRemovedEvent.java @@ -6,13 +6,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 @@ -29,7 +29,6 @@ package org.scijava.object.event; - import java.util.Collection; import org.scijava.object.ObjectService; @@ -37,7 +36,7 @@ /** * An event indicating one or more objects have been removed from the * {@link ObjectService}. - * + * * @author Curtis Rueden */ public class ObjectsRemovedEvent extends ObjectsListEvent { diff --git a/src/main/java/org/scijava/options/DefaultOptionsService.java b/src/main/java/org/scijava/options/DefaultOptionsService.java index a7239d833..3032ee8d6 100644 --- a/src/main/java/org/scijava/options/DefaultOptionsService.java +++ b/src/main/java/org/scijava/options/DefaultOptionsService.java @@ -6,13 +6,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 @@ -42,7 +42,7 @@ /** * Default service for keeping track of the available options and their * settings. - * + * * @author Curtis Rueden * @author Barry DeZonia * @see OptionsPlugin diff --git a/src/main/java/org/scijava/options/OptionsPlugin.java b/src/main/java/org/scijava/options/OptionsPlugin.java index 815c640e9..75fa02dc1 100644 --- a/src/main/java/org/scijava/options/OptionsPlugin.java +++ b/src/main/java/org/scijava/options/OptionsPlugin.java @@ -6,13 +6,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 @@ -64,7 +64,7 @@ /** * Base class for all options-oriented plugins. - * + * * @author Barry DeZonia * @author Curtis Rueden */ diff --git a/src/main/java/org/scijava/options/OptionsService.java b/src/main/java/org/scijava/options/OptionsService.java index fcb68ed08..ecf32daff 100644 --- a/src/main/java/org/scijava/options/OptionsService.java +++ b/src/main/java/org/scijava/options/OptionsService.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * Interface for the options handling service. - * + * * @author Curtis Rueden * @author Barry DeZonia * @see OptionsPlugin @@ -50,7 +50,7 @@ public interface OptionsService extends SingletonService, /** * Clears all option values from persistent storage. - * + * * @see OptionsPlugin#reset() */ default void reset() { diff --git a/src/main/java/org/scijava/options/event/OptionsEvent.java b/src/main/java/org/scijava/options/event/OptionsEvent.java index 20cc74f48..c5c8d4022 100644 --- a/src/main/java/org/scijava/options/event/OptionsEvent.java +++ b/src/main/java/org/scijava/options/event/OptionsEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Fired when an {@link OptionsPlugin} has changed an option. - * + * * @author Barry DeZonia * @author Curtis Rueden */ diff --git a/src/main/java/org/scijava/parse/DefaultParseService.java b/src/main/java/org/scijava/parse/DefaultParseService.java index b686d558b..41c572b2c 100644 --- a/src/main/java/org/scijava/parse/DefaultParseService.java +++ b/src/main/java/org/scijava/parse/DefaultParseService.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ /** * Default service for parsing strings. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) @@ -72,8 +72,7 @@ public ItemsList(final String arg, final boolean strict) { @Override public Map asMap() { - final LinkedHashMap map = - new LinkedHashMap<>(); + final LinkedHashMap map = new LinkedHashMap<>(); for (final Item item : this) { map.put(item.name(), item.value()); } diff --git a/src/main/java/org/scijava/parse/Item.java b/src/main/java/org/scijava/parse/Item.java index 4cba11748..42b37be06 100644 --- a/src/main/java/org/scijava/parse/Item.java +++ b/src/main/java/org/scijava/parse/Item.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ * 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 { diff --git a/src/main/java/org/scijava/parse/Items.java b/src/main/java/org/scijava/parse/Items.java index 49dbaf9ad..ef9f23fc9 100644 --- a/src/main/java/org/scijava/parse/Items.java +++ b/src/main/java/org/scijava/parse/Items.java @@ -6,13 +6,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 @@ -35,14 +35,14 @@ /** * 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. + * Gets the parsed items as a map. The map will have the same iteration order + * as the original list. */ Map asMap(); @@ -53,4 +53,3 @@ public interface Items extends List { boolean isList(); } - diff --git a/src/main/java/org/scijava/parse/ParseService.java b/src/main/java/org/scijava/parse/ParseService.java index ba20fb813..e20062106 100644 --- a/src/main/java/org/scijava/parse/ParseService.java +++ b/src/main/java/org/scijava/parse/ParseService.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ public interface ParseService extends SciJavaService { * 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 @@ -60,7 +60,7 @@ default Items parse(final String arg) { * 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. diff --git a/src/main/java/org/scijava/platform/AbstractPlatform.java b/src/main/java/org/scijava/platform/AbstractPlatform.java index f20f49b14..cc9c82db6 100644 --- a/src/main/java/org/scijava/platform/AbstractPlatform.java +++ b/src/main/java/org/scijava/platform/AbstractPlatform.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Abstract superclass of platform implementations. - * + * * @author Curtis Rueden */ public abstract class AbstractPlatform implements Platform { diff --git a/src/main/java/org/scijava/platform/AppEventService.java b/src/main/java/org/scijava/platform/AppEventService.java index 16b191878..9f8740ac8 100644 --- a/src/main/java/org/scijava/platform/AppEventService.java +++ b/src/main/java/org/scijava/platform/AppEventService.java @@ -6,13 +6,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/platform/DefaultAppEventService.java b/src/main/java/org/scijava/platform/DefaultAppEventService.java index bd0c34424..799a92184 100644 --- a/src/main/java/org/scijava/platform/DefaultAppEventService.java +++ b/src/main/java/org/scijava/platform/DefaultAppEventService.java @@ -6,13 +6,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 @@ -77,7 +77,8 @@ public List> getCommands() { } @Deprecated - protected void onEvent(@SuppressWarnings("unused") final AppAboutEvent event) + protected void onEvent( + @SuppressWarnings("unused") final AppAboutEvent event) { about(); } diff --git a/src/main/java/org/scijava/platform/DefaultPlatform.java b/src/main/java/org/scijava/platform/DefaultPlatform.java index f9d971b58..740c8c495 100644 --- a/src/main/java/org/scijava/platform/DefaultPlatform.java +++ b/src/main/java/org/scijava/platform/DefaultPlatform.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * A platform implementation for default handling of platform issues. - * + * * @author Curtis Rueden * @author Johannes Schindelin */ @@ -49,8 +49,8 @@ public class DefaultPlatform extends AbstractPlatform { /** * Falls back to calling known browsers. *

      - * Based on BareBonesBrowserLaunch. + * Based on BareBonesBrowserLaunch. *

      *

      * The utility 'xdg-open' launches the URL in the user's preferred browser, @@ -59,9 +59,8 @@ public class DefaultPlatform extends AbstractPlatform { */ @Override public void open(final URL url) throws IOException { - final String[] browsers = - { "xdg-open", "netscape", "firefox", "konqueror", "mozilla", "opera", - "epiphany", "lynx" }; + final String[] browsers = { "xdg-open", "netscape", "firefox", "konqueror", + "mozilla", "opera", "epiphany", "lynx" }; for (final String browser : browsers) { try { final int exitCode = getPlatformService().exec(browser, url.toString()); diff --git a/src/main/java/org/scijava/platform/DefaultPlatformService.java b/src/main/java/org/scijava/platform/DefaultPlatformService.java index e5effaaf1..75d7959af 100644 --- a/src/main/java/org/scijava/platform/DefaultPlatformService.java +++ b/src/main/java/org/scijava/platform/DefaultPlatformService.java @@ -6,13 +6,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 @@ -47,7 +47,7 @@ /** * Default service for handling platform-specific deployment issues. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) @@ -118,8 +118,8 @@ public int exec(final String... args) throws IOException { return process.exitValue(); } catch (final InterruptedException ie) { - throw new IOException("InterruptedException during execution: " + - ie.getMessage()); + throw new IOException("InterruptedException during execution: " + ie + .getMessage()); } } diff --git a/src/main/java/org/scijava/platform/Platform.java b/src/main/java/org/scijava/platform/Platform.java index 96e0e6743..ca24e7e82 100644 --- a/src/main/java/org/scijava/platform/Platform.java +++ b/src/main/java/org/scijava/platform/Platform.java @@ -6,13 +6,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 @@ -46,7 +46,7 @@ * implementing this interface, it is encouraged to instead extend * {@link AbstractPlatform}, for convenience. *

      - * + * * @author Curtis Rueden * @see Plugin * @see PlatformService @@ -116,7 +116,7 @@ default boolean isTarget() { /** * Informs the platform of a UI's newly created application menu structure. * The platform may choose to do something platform-specific with the menus. - * + * * @param menus The UI's newly created menu structure * @return true iff the menus should not be added to the UI as normal because * the platform did something platform-specific with them instead. diff --git a/src/main/java/org/scijava/platform/PlatformService.java b/src/main/java/org/scijava/platform/PlatformService.java index 68e07fe9f..b6241912a 100644 --- a/src/main/java/org/scijava/platform/PlatformService.java +++ b/src/main/java/org/scijava/platform/PlatformService.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ /** * Interface for service that handles platform-specific deployment issues. A * "platform" can be an operating system, CPU architecture, or version of Java. - * + * * @author Curtis Rueden */ public interface PlatformService extends SingletonService, @@ -70,7 +70,7 @@ default CommandService commandService() { /** * Executes a native program and waits for it to return. - * + * * @return the exit code of the execution. */ int exec(String... args) throws IOException; @@ -79,7 +79,7 @@ default CommandService commandService() { * Informs the active platform handlers of a UI's newly created application * menu structure. Each active platform handler may choose to do something * platform-specific with the menus. - * + * * @param menus The UI's newly created menu structure * @return true iff the menus should not be added to the UI as normal because * a platform handler did something platform-specific with them diff --git a/src/main/java/org/scijava/platform/event/AppAboutEvent.java b/src/main/java/org/scijava/platform/event/AppAboutEvent.java index 251d253a7..79661a1ee 100644 --- a/src/main/java/org/scijava/platform/event/AppAboutEvent.java +++ b/src/main/java/org/scijava/platform/event/AppAboutEvent.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An event sent when the application is asked to open its about window. - * + * * @author Curtis Rueden */ public class AppAboutEvent extends ApplicationEvent { diff --git a/src/main/java/org/scijava/platform/event/AppFocusEvent.java b/src/main/java/org/scijava/platform/event/AppFocusEvent.java index 8d1278a2f..51eda2274 100644 --- a/src/main/java/org/scijava/platform/event/AppFocusEvent.java +++ b/src/main/java/org/scijava/platform/event/AppFocusEvent.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * An event sent when the application has become the foreground app, or when it * has resigned being the foreground app. - * + * * @author Curtis Rueden */ public class AppFocusEvent extends ApplicationEvent { diff --git a/src/main/java/org/scijava/platform/event/AppMenusCreatedEvent.java b/src/main/java/org/scijava/platform/event/AppMenusCreatedEvent.java index 23b119891..db2a0be75 100644 --- a/src/main/java/org/scijava/platform/event/AppMenusCreatedEvent.java +++ b/src/main/java/org/scijava/platform/event/AppMenusCreatedEvent.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An event sent when the application has created and populated its menus. - * + * * @author Curtis Rueden */ public class AppMenusCreatedEvent extends ApplicationEvent { diff --git a/src/main/java/org/scijava/platform/event/AppOpenFilesEvent.java b/src/main/java/org/scijava/platform/event/AppOpenFilesEvent.java index 0a5d85fa7..8a8cf890e 100644 --- a/src/main/java/org/scijava/platform/event/AppOpenFilesEvent.java +++ b/src/main/java/org/scijava/platform/event/AppOpenFilesEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An event sent when the application is asked to re-open itself. - * + * * @author Curtis Rueden */ public class AppOpenFilesEvent extends ApplicationEvent { diff --git a/src/main/java/org/scijava/platform/event/AppPreferencesEvent.java b/src/main/java/org/scijava/platform/event/AppPreferencesEvent.java index c5221df29..4c8d8e146 100644 --- a/src/main/java/org/scijava/platform/event/AppPreferencesEvent.java +++ b/src/main/java/org/scijava/platform/event/AppPreferencesEvent.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An event sent when the application is asked to open its preferences window. - * + * * @author Curtis Rueden */ public class AppPreferencesEvent extends ApplicationEvent { diff --git a/src/main/java/org/scijava/platform/event/AppPrintEvent.java b/src/main/java/org/scijava/platform/event/AppPrintEvent.java index 0c764a718..ee25304af 100644 --- a/src/main/java/org/scijava/platform/event/AppPrintEvent.java +++ b/src/main/java/org/scijava/platform/event/AppPrintEvent.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An event sent when the app is asked to print a list of files. - * + * * @author Curtis Rueden */ public class AppPrintEvent extends ApplicationEvent { diff --git a/src/main/java/org/scijava/platform/event/AppQuitEvent.java b/src/main/java/org/scijava/platform/event/AppQuitEvent.java index c3198e627..02c93d54c 100644 --- a/src/main/java/org/scijava/platform/event/AppQuitEvent.java +++ b/src/main/java/org/scijava/platform/event/AppQuitEvent.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An event sent when the application is asked to quit. - * + * * @author Curtis Rueden */ public class AppQuitEvent extends ApplicationEvent { diff --git a/src/main/java/org/scijava/platform/event/AppReOpenEvent.java b/src/main/java/org/scijava/platform/event/AppReOpenEvent.java index 47a252476..507da88b7 100644 --- a/src/main/java/org/scijava/platform/event/AppReOpenEvent.java +++ b/src/main/java/org/scijava/platform/event/AppReOpenEvent.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An event sent when the application is asked to re-open itself. - * + * * @author Curtis Rueden */ public class AppReOpenEvent extends ApplicationEvent { diff --git a/src/main/java/org/scijava/platform/event/AppScreenSleepEvent.java b/src/main/java/org/scijava/platform/event/AppScreenSleepEvent.java index c78337b1a..b94a86148 100644 --- a/src/main/java/org/scijava/platform/event/AppScreenSleepEvent.java +++ b/src/main/java/org/scijava/platform/event/AppScreenSleepEvent.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * An event sent when the displays attached to the system enter and exit power * save sleep. - * + * * @author Curtis Rueden */ public class AppScreenSleepEvent extends AppSleepEvent { diff --git a/src/main/java/org/scijava/platform/event/AppSleepEvent.java b/src/main/java/org/scijava/platform/event/AppSleepEvent.java index eb3b09762..8a7b06c02 100644 --- a/src/main/java/org/scijava/platform/event/AppSleepEvent.java +++ b/src/main/java/org/scijava/platform/event/AppSleepEvent.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An event sent when a device enters or exits power save sleep. - * + * * @author Curtis Rueden */ public abstract class AppSleepEvent extends ApplicationEvent { diff --git a/src/main/java/org/scijava/platform/event/AppSystemSleepEvent.java b/src/main/java/org/scijava/platform/event/AppSystemSleepEvent.java index 8e29b17a3..551486f12 100644 --- a/src/main/java/org/scijava/platform/event/AppSystemSleepEvent.java +++ b/src/main/java/org/scijava/platform/event/AppSystemSleepEvent.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An event sent when the system enters and exits power save sleep. - * + * * @author Curtis Rueden */ public class AppSystemSleepEvent extends AppSleepEvent { diff --git a/src/main/java/org/scijava/platform/event/AppUserSessionEvent.java b/src/main/java/org/scijava/platform/event/AppUserSessionEvent.java index b5d608118..e22bfe637 100644 --- a/src/main/java/org/scijava/platform/event/AppUserSessionEvent.java +++ b/src/main/java/org/scijava/platform/event/AppUserSessionEvent.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * An event sent when the the user session has been changed via Fast User * Switching. - * + * * @author Curtis Rueden */ public class AppUserSessionEvent extends ApplicationEvent { diff --git a/src/main/java/org/scijava/platform/event/AppVisibleEvent.java b/src/main/java/org/scijava/platform/event/AppVisibleEvent.java index 8a029561d..7b3e3d6f6 100644 --- a/src/main/java/org/scijava/platform/event/AppVisibleEvent.java +++ b/src/main/java/org/scijava/platform/event/AppVisibleEvent.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An event sent when the application has been hidden or shown. - * + * * @author Curtis Rueden */ public class AppVisibleEvent extends ApplicationEvent { diff --git a/src/main/java/org/scijava/platform/event/ApplicationEvent.java b/src/main/java/org/scijava/platform/event/ApplicationEvent.java index 4856c0748..7e8ad76ee 100644 --- a/src/main/java/org/scijava/platform/event/ApplicationEvent.java +++ b/src/main/java/org/scijava/platform/event/ApplicationEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An event indicating an application-level occurrence. Exists mainly to * facility handling of Mac-specific menu items. - * + * * @author Curtis Rueden */ public abstract class ApplicationEvent extends SciJavaEvent { diff --git a/src/main/java/org/scijava/plugin/AbstractHandlerPlugin.java b/src/main/java/org/scijava/plugin/AbstractHandlerPlugin.java index 995bde741..7d3454de1 100644 --- a/src/main/java/org/scijava/plugin/AbstractHandlerPlugin.java +++ b/src/main/java/org/scijava/plugin/AbstractHandlerPlugin.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Abstract base class for {@link HandlerPlugin} implementations. - * + * * @author Curtis Rueden */ public abstract class AbstractHandlerPlugin extends AbstractTypedPlugin diff --git a/src/main/java/org/scijava/plugin/AbstractHandlerService.java b/src/main/java/org/scijava/plugin/AbstractHandlerService.java index af501d619..4c48baf14 100644 --- a/src/main/java/org/scijava/plugin/AbstractHandlerService.java +++ b/src/main/java/org/scijava/plugin/AbstractHandlerService.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Abstract base class for {@link HandlerService}s. - * + * * @author Curtis Rueden * @param
      Base data type handled by the handlers. * @param Plugin type of the handlers. diff --git a/src/main/java/org/scijava/plugin/AbstractPTService.java b/src/main/java/org/scijava/plugin/AbstractPTService.java index e84ad8c07..37b7354fa 100644 --- a/src/main/java/org/scijava/plugin/AbstractPTService.java +++ b/src/main/java/org/scijava/plugin/AbstractPTService.java @@ -6,13 +6,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,7 +33,7 @@ /** * Abstract base class for {@link PTService}s. - * + * * @author Curtis Rueden * @param Plugin type of the {@link SciJavaPlugin}s being managed. */ diff --git a/src/main/java/org/scijava/plugin/AbstractRichPlugin.java b/src/main/java/org/scijava/plugin/AbstractRichPlugin.java index 73c37cb3f..7423c0b12 100644 --- a/src/main/java/org/scijava/plugin/AbstractRichPlugin.java +++ b/src/main/java/org/scijava/plugin/AbstractRichPlugin.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Abstract base class for {@link RichPlugin} implementations. - * + * * @author Curtis Rueden */ public abstract class AbstractRichPlugin extends AbstractContextual implements diff --git a/src/main/java/org/scijava/plugin/AbstractSingletonService.java b/src/main/java/org/scijava/plugin/AbstractSingletonService.java index 497528dc8..ebcc5da20 100644 --- a/src/main/java/org/scijava/plugin/AbstractSingletonService.java +++ b/src/main/java/org/scijava/plugin/AbstractSingletonService.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ /** * Abstract base class for {@link SingletonService}s. - * + * * @author Curtis Rueden * @param Plugin type of the {@link SingletonPlugin}s being managed. */ diff --git a/src/main/java/org/scijava/plugin/AbstractTypedPlugin.java b/src/main/java/org/scijava/plugin/AbstractTypedPlugin.java index 46dc75ead..b9308c62e 100644 --- a/src/main/java/org/scijava/plugin/AbstractTypedPlugin.java +++ b/src/main/java/org/scijava/plugin/AbstractTypedPlugin.java @@ -6,13 +6,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,7 +33,7 @@ /** * Abstract base class for {@link TypedPlugin}s. - * + * * @author Curtis Rueden * @param Data type associated with the plugin. * @see Typed diff --git a/src/main/java/org/scijava/plugin/AbstractTypedService.java b/src/main/java/org/scijava/plugin/AbstractTypedService.java index 9929517f2..ce2eb8efc 100644 --- a/src/main/java/org/scijava/plugin/AbstractTypedService.java +++ b/src/main/java/org/scijava/plugin/AbstractTypedService.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Abstract base class for {@link TypedService}s. - * + * * @author Curtis Rueden * @param
      Base data type of the {@link TypedPlugin}s. * @param Plugin type of the {@link TypedPlugin}s. diff --git a/src/main/java/org/scijava/plugin/AbstractWrapperPlugin.java b/src/main/java/org/scijava/plugin/AbstractWrapperPlugin.java index 9f0281c74..f55f145d7 100644 --- a/src/main/java/org/scijava/plugin/AbstractWrapperPlugin.java +++ b/src/main/java/org/scijava/plugin/AbstractWrapperPlugin.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Abstract base class for {@link WrapperPlugin}s. - * + * * @author Curtis Rueden * @param Data type wrapped by the plugin. */ diff --git a/src/main/java/org/scijava/plugin/AbstractWrapperService.java b/src/main/java/org/scijava/plugin/AbstractWrapperService.java index b60bca1ae..7f860ea8e 100644 --- a/src/main/java/org/scijava/plugin/AbstractWrapperService.java +++ b/src/main/java/org/scijava/plugin/AbstractWrapperService.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Abstract base class for {@link WrapperService}s. - * + * * @author Curtis Rueden * @param
      Base data type wrapped by the wrappers. * @param Plugin type of the wrappers. diff --git a/src/main/java/org/scijava/plugin/Attr.java b/src/main/java/org/scijava/plugin/Attr.java index 717550439..c30703412 100644 --- a/src/main/java/org/scijava/plugin/Attr.java +++ b/src/main/java/org/scijava/plugin/Attr.java @@ -6,13 +6,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,7 +33,7 @@ /** * A name/value attribute pair, used to extend the @{@link Plugin} annotation. - * + * * @author Curtis Rueden * @see Plugin#attrs() * @see PluginInfo#get(String) diff --git a/src/main/java/org/scijava/plugin/DefaultPluginFinder.java b/src/main/java/org/scijava/plugin/DefaultPluginFinder.java index e2eb4949c..bada04363 100644 --- a/src/main/java/org/scijava/plugin/DefaultPluginFinder.java +++ b/src/main/java/org/scijava/plugin/DefaultPluginFinder.java @@ -6,13 +6,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 @@ -42,10 +42,10 @@ /** * Default SciJava plugin discovery mechanism. *

      - * It works by scanning the classpath for {@link Plugin} annotations - * previously indexed by scijava-common itself. + * It works by scanning the classpath for {@link Plugin} annotations previously + * indexed by scijava-common itself. *

      - * + * * @author Curtis Rueden */ public class DefaultPluginFinder implements PluginFinder { @@ -72,13 +72,11 @@ public DefaultPluginFinder(final ClassLoader classLoader) { public HashMap findPlugins( final List> plugins) { - final HashMap exceptions = - new HashMap<>(); + final HashMap exceptions = new HashMap<>(); // load the annotation indexes final ClassLoader classLoader = getClassLoader(); - final Index annotationIndex = - Index.load(Plugin.class, classLoader); + final Index annotationIndex = Index.load(Plugin.class, classLoader); // create a PluginInfo object for each item in the index for (final IndexItem item : annotationIndex) { @@ -97,15 +95,15 @@ public HashMap findPlugins( // -- Helper methods -- - private PluginInfo createInfo( - final IndexItem item, final ClassLoader classLoader) + private PluginInfo createInfo(final IndexItem item, + final ClassLoader classLoader) { final String className = item.className(); final Plugin plugin = item.annotation(); @SuppressWarnings("unchecked") - final Class pluginType = - (Class) plugin.type(); + final Class pluginType = (Class) plugin + .type(); return new PluginInfo<>(className, pluginType, plugin, classLoader); } @@ -118,6 +116,7 @@ private ClassLoader getClassLoader() { // -- Helper classes -- private interface PluginBlocklist { + boolean contains(String className); } @@ -130,6 +129,7 @@ private interface PluginBlocklist { *

      */ private class SysPropBlocklist implements PluginBlocklist { + private final List patterns; public SysPropBlocklist() { diff --git a/src/main/java/org/scijava/plugin/DefaultPluginService.java b/src/main/java/org/scijava/plugin/DefaultPluginService.java index 8193d8d5e..cfb775889 100644 --- a/src/main/java/org/scijava/plugin/DefaultPluginService.java +++ b/src/main/java/org/scijava/plugin/DefaultPluginService.java @@ -6,13 +6,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 @@ -48,15 +48,15 @@ * Default service for keeping track of available plugins. *

      * Available plugins are discovered using indexes generated by using - * scijava-common as annotation processor. Loading of the actual plugin - * classes can be deferred until a particular plugin is actually needed. + * scijava-common as annotation processor. Loading of the actual plugin classes + * can be deferred until a particular plugin is actually needed. *

      *

      * Plugins are added or removed via the plugin service are reported via the * event service. (No events are published for plugins directly added to or * removed from the {@link PluginIndex}.) *

      - * + * * @author Curtis Rueden * @author Johannes Schindelin * @see SciJavaPlugin @@ -110,8 +110,8 @@ public void addPlugin(final PluginInfo plugin) { } @Override - public > void - addPlugins(final Collection plugins) + public > void addPlugins( + final Collection plugins) { if (pluginIndex.addAll(plugins)) { eventService.publish(new PluginsAddedEvent(plugins)); @@ -147,8 +147,8 @@ public

      PluginInfo getPlugin( } @Override - public PluginInfo - getPlugin(final Class

      pluginClass, final Class type) + public PluginInfo getPlugin( + final Class

      pluginClass, final Class type) { return ListUtils.first(getPluginsOfClass(pluginClass, type)); } @@ -200,8 +200,7 @@ public List> getPluginsOfClass( public List> getPluginsOfClass(final String className, final Class type) { - final ArrayList> result = - new ArrayList<>(); + final ArrayList> result = new ArrayList<>(); findPluginsOfClass(className, getPluginsOfType(type), result); return result; } @@ -227,8 +226,8 @@ public List createInstances( } @Override - public PT - createInstance(final PluginInfo info) + public PT createInstance( + final PluginInfo info) { try { final PT p = info.createInstance(); @@ -268,7 +267,7 @@ public void initialize() { * Transfers plugins of the given class from the source list to the * destination list. Note that because this method compares class name * strings, it does not need to actually load the class in question. - * + * * @param className The class name of the desired plugins. * @param srcList The list to scan for matching plugins. * @param destList The list to which matching plugins are added. @@ -289,13 +288,13 @@ public static > void findPluginsOfClass( /** * Gets the plugin type of the given plugin class, as declared by its * {@code @Plugin} annotation (i.e., {@link Plugin#type()}). - * + * * @param pluginClass The plugin class whose plugin type is needed. * @return The plugin type, or null if no {@link Plugin} annotation exists for * the given class. */ - public static Class getPluginType( - final Class

      pluginClass) + public static Class + getPluginType(final Class

      pluginClass) { final Plugin annotation = pluginClass.getAnnotation(Plugin.class); if (annotation == null) return null; @@ -310,7 +309,7 @@ public static Class getPluginType( * Transfers plugins of the given class from the source list to the * destination list. Note that because this method compares class objects, it * must load the classes in question. - * + * * @param pluginClass The class of the desired plugins. * @param srcList The list to scan for matching plugins. * @param destList The list to which matching plugins are added. @@ -323,8 +322,8 @@ private > void findPluginsOfClass( for (final PluginInfo info : srcList) { try { final Class clazz2 = info.getPluginClass(); - if (clazz2 == pluginClass || - (info.getClassName().equals(className) && info.loadClass() == pluginClass)) + if (clazz2 == pluginClass || (info.getClassName().equals(className) && + info.loadClass() == pluginClass)) { @SuppressWarnings("unchecked") final T match = (T) info; @@ -345,8 +344,8 @@ private > void findPluginsOfClass( filterNonmatchingClasses(final Class

      pluginClass, final ArrayList> result) { - for (final Iterator> iter = result.iterator(); - iter.hasNext(); ) + for (final Iterator> iter = result.iterator(); iter + .hasNext();) { try { if (iter.next().loadClass() != pluginClass) iter.remove(); diff --git a/src/main/java/org/scijava/plugin/HandlerPlugin.java b/src/main/java/org/scijava/plugin/HandlerPlugin.java index 33f179bfb..1c7ab8e49 100644 --- a/src/main/java/org/scijava/plugin/HandlerPlugin.java +++ b/src/main/java/org/scijava/plugin/HandlerPlugin.java @@ -6,13 +6,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 @@ -46,7 +46,7 @@ * other required inputs, or may provide more than one possible avenue of * handling (i.e., more than one "handle"-style method). *

      - * + * * @author Curtis Rueden * @param Data type associated with the plugin. * @see HandlerService diff --git a/src/main/java/org/scijava/plugin/HandlerService.java b/src/main/java/org/scijava/plugin/HandlerService.java index 65a3374b8..88eb73935 100644 --- a/src/main/java/org/scijava/plugin/HandlerService.java +++ b/src/main/java/org/scijava/plugin/HandlerService.java @@ -6,13 +6,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,7 +38,7 @@ * appropriate handler by sequentially querying each handler plugin on its list * (via {@link HandlerPlugin#supports}). *

      - * + * * @author Curtis Rueden * @param
      Base data type handled by the handlers. * @param Plugin type of the handlers. @@ -58,7 +58,8 @@ default PT getHandler(final DT data) { if (handler.supports(data)) return handler; } catch (final Throwable t) { - log().error("Malfunctioning plugin: " + handler.getClass().getName(), t); + log().error("Malfunctioning plugin: " + handler.getClass().getName(), + t); } } return null; diff --git a/src/main/java/org/scijava/plugin/HasPluginInfo.java b/src/main/java/org/scijava/plugin/HasPluginInfo.java index ee65fb550..65174ab90 100644 --- a/src/main/java/org/scijava/plugin/HasPluginInfo.java +++ b/src/main/java/org/scijava/plugin/HasPluginInfo.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * A object with associated {@link PluginInfo} metadata. Typically the object is * also a {@link SciJavaPlugin}, but it is not a hard requirement. - * + * * @author Curtis Rueden */ public interface HasPluginInfo { diff --git a/src/main/java/org/scijava/plugin/Menu.java b/src/main/java/org/scijava/plugin/Menu.java index a0b504779..9abf8c5d0 100644 --- a/src/main/java/org/scijava/plugin/Menu.java +++ b/src/main/java/org/scijava/plugin/Menu.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ * {@link Plugin#menuPath}, but more powerful in that it allows specification of * various menu attributes (e.g., {@link #weight}, {@link #mnemonic}, * {@link #accelerator} and {@link #iconPath}). - * + * * @author Curtis Rueden */ @Target({}) @@ -64,7 +64,7 @@ /** * Keyboard shortcut to activate the menu item. - * + * * @see Accelerator#create(String) for information on the syntax. */ String accelerator() default ""; diff --git a/src/main/java/org/scijava/plugin/PTService.java b/src/main/java/org/scijava/plugin/PTService.java index 8157261cf..29198d37f 100644 --- a/src/main/java/org/scijava/plugin/PTService.java +++ b/src/main/java/org/scijava/plugin/PTService.java @@ -6,13 +6,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 @@ -72,7 +72,7 @@ * in a type hierarchy intended to ease creation of services that fit its * pattern. *

      - * + * * @author Curtis Rueden * @param Plugin type of the plugins being managed. * @see SingletonService @@ -99,8 +99,8 @@ default List> getPlugins() { /** Creates an instance of the given plugin class. */ default

      P create(final Class

      pluginClass) { - final PluginInfo info = - pluginService().getPlugin(pluginClass, getPluginType()); + 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/Parameter.java b/src/main/java/org/scijava/plugin/Parameter.java index c21d89fbc..7eb188d95 100644 --- a/src/main/java/org/scijava/plugin/Parameter.java +++ b/src/main/java/org/scijava/plugin/Parameter.java @@ -6,13 +6,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 @@ -42,7 +42,7 @@ * An annotation for indicating a field is an input or output parameter. This * annotation is a useful way for plugins to declare their inputs and outputs * simply. - * + * * @author Johannes Schindelin * @author Grant Harris * @author Curtis Rueden @@ -85,7 +85,8 @@ *

    • NORMAL: parameter is included in the history for purposes of data * provenance, and included as a parameter when recording scripts.
    • *
    • TRANSIENT: parameter is excluded from the history for the purposes of - * data provenance, but still included as a parameter when recording scripts.
    • + * data provenance, but still included as a parameter when recording + * scripts. *
    • INVISIBLE: parameter is excluded from the history for the purposes of * data provenance, and also excluded as a parameter when recording scripts. * This option should only be used for parameters with no effect on the final @@ -117,7 +118,7 @@ /** * Defines a function that is called to validate the parameter value after it * is marked as resolved. - * + * * @see Module#resolveInput(String) */ String validater() default ""; diff --git a/src/main/java/org/scijava/plugin/Plugin.java b/src/main/java/org/scijava/plugin/Plugin.java index 5e64f9411..75b58fc46 100644 --- a/src/main/java/org/scijava/plugin/Plugin.java +++ b/src/main/java/org/scijava/plugin/Plugin.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ /** * Annotation identifying a plugin, which gets loaded by SciJava's dynamic * discovery mechanism. - * + * * @author Curtis Rueden * @see SciJavaPlugin * @see PluginService @@ -121,7 +121,7 @@ *
    • {@link Priority#VERY_LOW}
    • *
    • {@link Priority#LAST}
    • *
    - * + * * @see org.scijava.service.Service */ double priority() default Priority.NORMAL; diff --git a/src/main/java/org/scijava/plugin/PluginFinder.java b/src/main/java/org/scijava/plugin/PluginFinder.java index 3539c7861..7147e92ef 100644 --- a/src/main/java/org/scijava/plugin/PluginFinder.java +++ b/src/main/java/org/scijava/plugin/PluginFinder.java @@ -6,13 +6,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 @@ -34,14 +34,14 @@ /** * Interface for mechanisms that define how SciJava plugins are discovered. - * + * * @author Curtis Rueden */ public interface PluginFinder { /** * Populates the given list with all available SciJava plugins. - * + * * @return A table of exceptions which occurred during plugin discovery. Keys * correspond to plugin name in some fashion (e.g., a class name), * while values correspond to the exception which occurred when diff --git a/src/main/java/org/scijava/plugin/PluginIndex.java b/src/main/java/org/scijava/plugin/PluginIndex.java index 73153bcb9..78ba6500c 100644 --- a/src/main/java/org/scijava/plugin/PluginIndex.java +++ b/src/main/java/org/scijava/plugin/PluginIndex.java @@ -6,13 +6,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 @@ -55,14 +55,14 @@ * class would need to be loaded, which SciJava makes an effort not to do until * the plugin is actually needed for the first time. *

    - * + * * @author Curtis Rueden */ public class PluginIndex extends SortedObjectIndex> { /** * The plugin finder which will be used to discover plugins. - * + * * @see #discover() */ private final PluginFinder pluginFinder; @@ -77,7 +77,7 @@ public class PluginIndex extends SortedObjectIndex> { public PluginIndex() { this(new DefaultPluginFinder()); } - + /** * Constructs a new plugin index which uses the given {@link PluginFinder} to * discover plugins. @@ -119,9 +119,11 @@ public Map getExceptions() { *

    * This method is more specific than {@link #get(Class)} since that method * returns only a {@code List>}, whereas this one is guaranteed - * to return a {@code List>}. + * to return a {@code List + * >}. *

    - * + * * @return Read-only list of registered objects of the given type, or an empty * list if no such objects exist (this method never returns null). */ @@ -138,7 +140,7 @@ public List> getPlugins( /** * Overrides the type by which the entries are indexed. - * + * * @see PluginInfo#getPluginType() */ @Override @@ -154,7 +156,7 @@ protected Class getType(final PluginInfo info) { * object's actual type hierarchy is not used for classification, but rather * the object is classified according to {@link PluginInfo#getPluginType()}. *

    - * + * * @see PluginInfo#getPluginType() */ @Override diff --git a/src/main/java/org/scijava/plugin/PluginInfo.java b/src/main/java/org/scijava/plugin/PluginInfo.java index 8e4a4ce85..9dfcbde67 100644 --- a/src/main/java/org/scijava/plugin/PluginInfo.java +++ b/src/main/java/org/scijava/plugin/PluginInfo.java @@ -6,13 +6,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 @@ -57,7 +57,7 @@ * very quickly build a complex structure containing all available plugins * without waiting for the Java class loader. *

    - * + * * @param The type of plugin described by this metadata. See * {@link SciJavaPlugin} for a list of common plugin types. * @author Curtis Rueden @@ -85,7 +85,7 @@ public class PluginInfo extends AbstractUIDetails /** * Creates a new plugin metadata object. - * + * * @param className The name of the class, which must implement * {@link SciJavaPlugin}. * @param pluginType The type of plugin described by this metadata. @@ -97,7 +97,7 @@ public PluginInfo(final String className, final Class pluginType) { /** * Creates a new plugin metadata object. - * + * * @param className The name of the class, which must implement * {@link SciJavaPlugin}. * @param pluginType The type of plugin described by this metadata. @@ -113,7 +113,7 @@ public PluginInfo(final String className, final Class pluginType, /** * Creates a new plugin metadata object. - * + * * @param className The name of the class, which must implement * {@link SciJavaPlugin}. * @param pluginType The type of plugin described by this metadata. @@ -132,7 +132,7 @@ public PluginInfo(final String className, final Class pluginType, /** * Creates a new plugin metadata object. - * + * * @param pluginClass The plugin class, which must implement * {@link SciJavaPlugin}. * @param pluginType The type of plugin described by this metadata. @@ -146,7 +146,7 @@ public PluginInfo(final Class pluginClass, /** * Creates a new plugin metadata object. - * + * * @param pluginClass The plugin class, which must implement * {@link SciJavaPlugin}. * @param pluginType The type of plugin described by this metadata. @@ -204,7 +204,7 @@ public void setPluginClass(final Class pluginClass) { /** * Obtains the {@link Class} of the item objects, if that class has already * been loaded. - * + * * @return The {@link Class}, or null if it has not yet been loaded by * {@link #loadClass}. */ @@ -214,6 +214,7 @@ public Class getPluginClass() { /** * Sets the type of plugin described by the metadata. + * * @see SciJavaPlugin for a list of common plugin types. */ public void setPluginType(final Class pluginType) { @@ -222,6 +223,7 @@ public void setPluginType(final Class pluginType) { /** * Gets the type of plugin described by the metadata. + * * @see SciJavaPlugin for a list of common plugin types. */ public Class getPluginType() { @@ -235,7 +237,7 @@ public Plugin getAnnotation() { /** * Gets the URL corresponding to the icon resource path. - * + * * @see #getIconPath() */ public URL getIconURL() throws InstantiableException { @@ -247,7 +249,7 @@ public URL getIconURL() throws InstantiableException { /** * Injects the metadata into the given object. Note that this is only possible * if the given object implements the {@link HasPluginInfo} interface. - * + * * @param o The object to which the metadata should be assigned. * @return true If the metadata was successfully injected. */ @@ -351,7 +353,7 @@ public String getVersion() { * Finds a {@link PluginInfo} of the given plugin class in the specified * {@link PluginIndex}. Note that to avoid loading plugin classes, class * identity is determined by class name equality only. - * + * * @param pluginClass The concrete class of the plugin whose * {@link PluginInfo} is desired. * @param pluginIndex The {@link PluginIndex} to search for a matching @@ -369,7 +371,7 @@ public static

    PluginInfo get( * Finds a {@link PluginInfo} of the given plugin class and plugin type in the * specified {@link PluginIndex}. Note that to avoid loading plugin * classes, class identity is determined by class name equality only. - * + * * @param pluginClass The concrete class of the plugin whose * {@link PluginInfo} is desired. * @param pluginType The type of the plugin; see {@link #getPluginType()}. @@ -388,7 +390,7 @@ public static

    PluginInfo get( * Finds a {@link PluginInfo} of the given plugin class in the specified list * of plugins. Note that to avoid loading plugin classes, class identity * is determined by class name equality only. - * + * * @param pluginClass The concrete class of the plugin whose * {@link PluginInfo} is desired. * @param plugins The list of plugins to search for a match. @@ -409,7 +411,7 @@ public static

    PluginInfo get( * Creates a {@link PluginInfo} for the given plugin class. The class must be * a concrete class annotated with the @{@link Plugin} annotation, from which * the plugin type will be inferred. - * + * * @param pluginClass The concrete class of the plugin for which a new * {@link PluginInfo} is desired. * @return A newly created {@link PluginInfo} for the given plugin class. @@ -429,7 +431,7 @@ public static PluginInfo create( /** * Creates a {@link PluginInfo} for the given plugin class of the specified * plugin type. - * + * * @param pluginClass The concrete class of the plugin for which a new * {@link PluginInfo} is desired. * @param pluginType The type of the plugin; see {@link #getPluginType()}. @@ -446,7 +448,7 @@ public static

    PluginInfo create( * exists in the specified {@link PluginIndex}, it is retrieved (see * {@link #get(Class, PluginIndex)}); otherwise, a new one is created (see * {@link #create(Class)}) but not added to the index. - * + * * @param pluginClass The concrete class of the plugin whose * {@link PluginInfo} is desired. * @param pluginIndex The {@link PluginIndex} to search for a matching @@ -467,7 +469,7 @@ public static

    PluginInfo getOrCreate( * exists in the specified {@link PluginIndex}, it is retrieved (see * {@link #get(Class, PluginIndex)}); otherwise, a new one is created (see * {@link #create(Class)}) but not added to the index. - * + * * @param pluginClass The concrete class of the plugin whose * {@link PluginInfo} is desired. * @param pluginType The type of the plugin; see {@link #getPluginType()}. diff --git a/src/main/java/org/scijava/plugin/PluginService.java b/src/main/java/org/scijava/plugin/PluginService.java index dc579969a..61223c5ac 100644 --- a/src/main/java/org/scijava/plugin/PluginService.java +++ b/src/main/java/org/scijava/plugin/PluginService.java @@ -6,13 +6,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 @@ -29,7 +29,6 @@ package org.scijava.plugin; - import java.util.Collection; import java.util.Collections; import java.util.Comparator; @@ -51,7 +50,7 @@ *

    * The default plugin service discovers available plugins on the classpath. *

    - * + * * @author Curtis Rueden * @see SciJavaPlugin */ @@ -83,21 +82,21 @@ public interface PluginService extends SciJavaService { /** * Gets the first available plugin of the given class, or null if none. - * + * * @param

    The class of the plugin to look up. */ -

    PluginInfo - getPlugin(Class

    pluginClass); +

    PluginInfo getPlugin( + Class

    pluginClass); /** * Gets the first available plugin of the given class, or null if none. - * + * * @param The type of the plugin to look up; e.g., * {@code Service.class}. * @param

    The class of the plugin to look up. */ - PluginInfo - getPlugin(Class

    pluginClass, Class type); + PluginInfo getPlugin( + Class

    pluginClass, Class type); /** * Gets the first available plugin of the given class name, or null if none. @@ -107,12 +106,12 @@ public interface PluginService extends SciJavaService { /** * Gets the list of plugins of the given type (e.g., * {@link org.scijava.service.Service}). - * + * * @param The type of plugins to look up; e.g., * {@code Service.class}. */ - List> - getPluginsOfType(Class type); + List> getPluginsOfType( + Class type); /** * Gets the list of plugins of the given class. @@ -130,13 +129,13 @@ public interface PluginService extends SciJavaService { * the specified class will not match. For this behavior, use * {@link #getPluginsOfType(Class)} on a common parent interface. *

    - * + * * @param

    The class of plugins to look up. * @param pluginClass The class for which to obtain the list of matching * plugins. */ -

    List> - getPluginsOfClass(Class

    pluginClass); +

    List> getPluginsOfClass( + Class

    pluginClass); /** * Gets the list of plugins of the given class. @@ -154,7 +153,7 @@ public interface PluginService extends SciJavaService { * the specified class will not match. For this behavior, use * {@link #getPluginsOfType(Class)} on a common parent interface. *

    - * + * * @param The type of plugins to look up; e.g., * {@code Service.class}. * @param

    The class of plugins to look up. @@ -177,7 +176,7 @@ public interface PluginService extends SciJavaService { * the specified class will not match. For this behavior, use * {@link #getPluginsOfType(Class)} on a common parent interface. *

    - * + * * @param className The class name for which to obtain the list of matching * plugins. */ @@ -194,7 +193,7 @@ public interface PluginService extends SciJavaService { * the specified class will not match. For this behavior, use * {@link #getPluginsOfType(Class)} on a common parent interface. *

    - * + * * @param The type of plugins to look up; e.g., * {@code Service.class}. * @param className The class name for which to obtain the list of matching @@ -202,8 +201,8 @@ public interface PluginService extends SciJavaService { * @param type The type of plugins to which the search should be * limited. */ - List> - getPluginsOfClass(final String className, final Class type); + List> getPluginsOfClass( + final String className, final Class type); /** * Creates one instance each of the available plugins of the given type. @@ -212,7 +211,7 @@ public interface PluginService extends SciJavaService { * preprocessing on the command instances, so parameters will not be * auto-populated, initializers will not be executed, etc. *

    - * + * * @param The type of plugins to instantiate; e.g., * {@code Service.class}. */ @@ -231,12 +230,12 @@ public interface PluginService extends SciJavaService { * preprocessing on the command instances, so parameters will not be * auto-populated, initializers will not be executed, etc. *

    - * + * * @param The type of plugins to instantiate; e.g., * {@code Service.class}. */ - List - createInstances(List> infos); + List createInstances( + List> infos); /** * Creates an instance of the given plugin. @@ -251,7 +250,7 @@ public interface PluginService extends SciJavaService { * preprocessing on the command instances, so parameters will not be * auto-populated, initializers will not be executed, etc. *

    - * + * * @param The type of plugin to instantiate; e.g., * {@code Service.class}. */ @@ -259,7 +258,7 @@ public interface PluginService extends SciJavaService { /** * Sorts the given list of plugin instances by priority. - * + * * @param instances List of plugin instances to sort. * @param type The type of plugin these instances represent. */ diff --git a/src/main/java/org/scijava/plugin/RichPlugin.java b/src/main/java/org/scijava/plugin/RichPlugin.java index aa5c1d546..816aba2c2 100644 --- a/src/main/java/org/scijava/plugin/RichPlugin.java +++ b/src/main/java/org/scijava/plugin/RichPlugin.java @@ -6,13 +6,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 @@ -42,7 +42,7 @@ * retain access to their associated {@link PluginInfo} metadata via the * {@link HasPluginInfo} interface. This interface is intended as a convenient * extension point for new types of plugins. - * + * * @author Curtis Rueden */ public interface RichPlugin extends SciJavaPlugin, Contextual, Prioritized, diff --git a/src/main/java/org/scijava/plugin/SciJavaPlugin.java b/src/main/java/org/scijava/plugin/SciJavaPlugin.java index 4bef823d5..a0547cfce 100644 --- a/src/main/java/org/scijava/plugin/SciJavaPlugin.java +++ b/src/main/java/org/scijava/plugin/SciJavaPlugin.java @@ -6,13 +6,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 @@ -70,7 +70,7 @@ *
  • {@link org.scijava.widget.InputWidget} - plugins that render UI widgets * for the {@link org.scijava.widget.InputHarvester} preprocessor.
  • * - * + * * @author Curtis Rueden * @see Plugin * @see PluginService diff --git a/src/main/java/org/scijava/plugin/SingletonPlugin.java b/src/main/java/org/scijava/plugin/SingletonPlugin.java index 87e3afba9..97d6bc35c 100644 --- a/src/main/java/org/scijava/plugin/SingletonPlugin.java +++ b/src/main/java/org/scijava/plugin/SingletonPlugin.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ * placeholder for any potential singleton-plugin-specific API added in the * future. *

    - * + * * @author Curtis Rueden * @see SingletonService */ diff --git a/src/main/java/org/scijava/plugin/SingletonService.java b/src/main/java/org/scijava/plugin/SingletonService.java index 9171d8f8d..9e3e1f096 100644 --- a/src/main/java/org/scijava/plugin/SingletonService.java +++ b/src/main/java/org/scijava/plugin/SingletonService.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ * more general layer in a type hierarchy intended to ease creation of services * that fit its pattern. *

    - * + * * @author Curtis Rueden * @param Plugin type of the plugins being managed. * @see PTService @@ -69,7 +69,7 @@ default ObjectService objectService() { /** * 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 */ @@ -82,8 +82,8 @@ default List filterInstances(final List list) { @Override default

    P create(final Class

    pluginClass) { throw new UnsupportedOperationException( - "Cannot create singleton plugin instance. " - + "Use getInstance(Class) instead."); + "Cannot create singleton plugin instance. " + + "Use getInstance(Class) instead."); } // -- Service methods -- diff --git a/src/main/java/org/scijava/plugin/SortablePlugin.java b/src/main/java/org/scijava/plugin/SortablePlugin.java index 5b29d8a12..8fa132498 100644 --- a/src/main/java/org/scijava/plugin/SortablePlugin.java +++ b/src/main/java/org/scijava/plugin/SortablePlugin.java @@ -6,13 +6,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/plugin/TypedPlugin.java b/src/main/java/org/scijava/plugin/TypedPlugin.java index c6d04b019..5c21d966f 100644 --- a/src/main/java/org/scijava/plugin/TypedPlugin.java +++ b/src/main/java/org/scijava/plugin/TypedPlugin.java @@ -6,13 +6,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,7 +33,7 @@ /** * Interface for plugins with an associated type (i.e., {@link Class}). - * + * * @author Curtis Rueden * @param Data type associated with the plugin. * @see Typed diff --git a/src/main/java/org/scijava/plugin/TypedService.java b/src/main/java/org/scijava/plugin/TypedService.java index a49b329bb..271059195 100644 --- a/src/main/java/org/scijava/plugin/TypedService.java +++ b/src/main/java/org/scijava/plugin/TypedService.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ * more general layer in a type hierarchy intended to ease creation of services * that fit its pattern. *

    - * + * * @author Curtis Rueden * @param
    Base data type of the {@link TypedPlugin}s. * @param Plugin type of the {@link TypedPlugin}s. @@ -59,7 +59,7 @@ public interface TypedService> extends * 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) */ diff --git a/src/main/java/org/scijava/plugin/WrapperPlugin.java b/src/main/java/org/scijava/plugin/WrapperPlugin.java index 62efbea8c..8337537d8 100644 --- a/src/main/java/org/scijava/plugin/WrapperPlugin.java +++ b/src/main/java/org/scijava/plugin/WrapperPlugin.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ *

    * For a concrete example, see {@code org.scijava.widget.InputWidget}. *

    - * + * * @author Curtis Rueden * @param Data type wrapped by the plugin. */ @@ -44,7 +44,7 @@ public interface WrapperPlugin extends TypedPlugin { /** * Associates the given data object with this plugin. It must be a compatible * object (i.e., {@link #supports} must return true). - * + * * @param data The data object to associate with the plugin. * @throws IllegalArgumentException if the data object is not compatible. */ diff --git a/src/main/java/org/scijava/plugin/WrapperService.java b/src/main/java/org/scijava/plugin/WrapperService.java index 593a4f797..af593afd5 100644 --- a/src/main/java/org/scijava/plugin/WrapperService.java +++ b/src/main/java/org/scijava/plugin/WrapperService.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ * more general layer in a type hierarchy intended to ease creation of services * that fit its pattern. *

    - * + * * @author Curtis Rueden * @param
    Base data type * @param Plugin type @@ -56,7 +56,7 @@ public interface WrapperService> extends /** * Creates a new plugin instance wrapping the given associated data object. - * + * * @return An appropriate plugin instance, or null if the data is not * compatible with any available plugin. */ @@ -71,8 +71,8 @@ default PT create(final D data) { @Override default void initialize() { if (log() != null) { - log().debug("Found " + getPlugins().size() + " " + - getPluginType().getSimpleName() + " plugins."); + log().debug("Found " + getPlugins().size() + " " + getPluginType() + .getSimpleName() + " plugins."); } } diff --git a/src/main/java/org/scijava/plugin/event/PluginsAddedEvent.java b/src/main/java/org/scijava/plugin/event/PluginsAddedEvent.java index 0caad3bfb..5a15131cc 100644 --- a/src/main/java/org/scijava/plugin/event/PluginsAddedEvent.java +++ b/src/main/java/org/scijava/plugin/event/PluginsAddedEvent.java @@ -6,13 +6,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 @@ -29,7 +29,6 @@ package org.scijava.plugin.event; - import java.util.Collection; import org.scijava.plugin.PluginInfo; @@ -38,7 +37,7 @@ /** * An event indicating one or more plugins have been added to the * {@link PluginService}. - * + * * @author Curtis Rueden */ public class PluginsAddedEvent extends PluginsListEvent { diff --git a/src/main/java/org/scijava/plugin/event/PluginsListEvent.java b/src/main/java/org/scijava/plugin/event/PluginsListEvent.java index edaf3dbb1..10a72e593 100644 --- a/src/main/java/org/scijava/plugin/event/PluginsListEvent.java +++ b/src/main/java/org/scijava/plugin/event/PluginsListEvent.java @@ -6,13 +6,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,7 +38,7 @@ /** * An event indicating something has happened to the list of plugins registered * with the {@link PluginService}. - * + * * @author Curtis Rueden */ public abstract class PluginsListEvent extends ListEvent> { diff --git a/src/main/java/org/scijava/plugin/event/PluginsRemovedEvent.java b/src/main/java/org/scijava/plugin/event/PluginsRemovedEvent.java index 1709f484c..3219628ce 100644 --- a/src/main/java/org/scijava/plugin/event/PluginsRemovedEvent.java +++ b/src/main/java/org/scijava/plugin/event/PluginsRemovedEvent.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * An event indicating one or more plugins have been removed from the * {@link PluginService}. - * + * * @author Curtis Rueden */ public class PluginsRemovedEvent extends PluginsListEvent { diff --git a/src/main/java/org/scijava/prefs/AbstractPrefService.java b/src/main/java/org/scijava/prefs/AbstractPrefService.java index 1bf55eb1a..e67ae85bb 100644 --- a/src/main/java/org/scijava/prefs/AbstractPrefService.java +++ b/src/main/java/org/scijava/prefs/AbstractPrefService.java @@ -6,13 +6,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/prefs/DefaultPrefService.java b/src/main/java/org/scijava/prefs/DefaultPrefService.java index 78efeae4a..d398a8305 100644 --- a/src/main/java/org/scijava/prefs/DefaultPrefService.java +++ b/src/main/java/org/scijava/prefs/DefaultPrefService.java @@ -6,13 +6,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 @@ -84,8 +84,8 @@ public float getFloat(final Class c, final String name, } @Override - public int - getInt(final Class c, final String name, final int defaultValue) + public int getInt(final Class c, final String name, + final int defaultValue) { return prefs(c).getInt(name, defaultValue); } @@ -227,8 +227,8 @@ public void putMap(final String absolutePath, final Map map) { @Deprecated @Override - public Map - getMap(final String absolutePath, final String key) + public Map getMap(final String absolutePath, + final String key) { return prefs(absolutePath).node(key).getMap(); } @@ -334,7 +334,6 @@ public void putList(final Iterable list) { } } - public List getList() { final List list = new ArrayList<>(); for (int index = 0; index < Integer.MAX_VALUE; index++) { @@ -347,9 +346,11 @@ public List getList() { public Iterable getIterable() { return new Iterable() { + @Override public Iterator iterator() { return new Iterator() { + private String value; private int index; { diff --git a/src/main/java/org/scijava/prefs/PrefService.java b/src/main/java/org/scijava/prefs/PrefService.java index d2e285d0d..3a3c4f741 100644 --- a/src/main/java/org/scijava/prefs/PrefService.java +++ b/src/main/java/org/scijava/prefs/PrefService.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ public interface PrefService extends SciJavaService { /** * Gets a persisted key as a {@link String}. - * + * * @param c The class with which the key is associated. * @param name The key to retrieve. * @return The value of the key as a {@link String}, or null if the key is not @@ -56,7 +56,7 @@ default String get(final Class c, final String name) { /** * Gets a persisted key as a {@link String}. - * + * * @param c The class with which the key is associated. * @param name The key to retrieve. * @param defaultValue The value to return if the key is not present. @@ -66,7 +66,7 @@ default String get(final Class c, final String name) { /** * Gets a persisted key as a {@code boolean}. - * + * * @param c The class with which the key is associated. * @param name The key to retrieve. * @param defaultValue The value to return if the key is not present. @@ -76,7 +76,7 @@ default String get(final Class c, final String name) { /** * Gets a persisted key as a {@code double}. - * + * * @param c The class with which the key is associated. * @param name The key to retrieve. * @param defaultValue The value to return if the key is not present. @@ -86,7 +86,7 @@ default String get(final Class c, final String name) { /** * Gets a persisted key as a {@code float}. - * + * * @param c The class with which the key is associated. * @param name The key to retrieve. * @param defaultValue The value to return if the key is not present. @@ -96,7 +96,7 @@ default String get(final Class c, final String name) { /** * Gets a persisted key as an {@code int}. - * + * * @param c The class with which the key is associated. * @param name The key to retrieve. * @param defaultValue The value to return if the key is not present. @@ -106,7 +106,7 @@ default String get(final Class c, final String name) { /** * Gets a persisted key as a {@code long}. - * + * * @param c The class with which the key is associated. * @param name The key to retrieve. * @param defaultValue The value to return if the key is not present. @@ -116,7 +116,7 @@ default String get(final Class c, final String name) { /** * Gets a persisted key as a {@code Map}. - * + * * @param c The class with which the key is associated. * @param name The key to retrieve. * @return The value of the key as an {@code Map}, or null if the key is not @@ -126,7 +126,7 @@ default String get(final Class c, final String name) { /** * Gets a persisted key as a {@code List}. - * + * * @param c The class with which the key is associated. * @param name The key to retrieve. * @return The value of the key as an {@code List}, or null if the key is not @@ -136,7 +136,7 @@ default String get(final Class c, final String name) { /** * Saves a key/value pair in persistent storage. - * + * * @param c The class with which the key/value pair is associated. * @param name The key where the value should be stored. * @param value The value to store. @@ -147,7 +147,7 @@ default String get(final Class c, final String name) { /** * Saves a key/value pair in persistent storage. - * + * * @param c The class with which the key/value pair is associated. * @param name The key where the value should be stored. * @param value The value to store. @@ -157,7 +157,7 @@ default String get(final Class c, final String name) { /** * Saves a key/value pair in persistent storage. - * + * * @param c The class with which the key/value pair is associated. * @param name The key where the value should be stored. * @param value The value to store. @@ -167,7 +167,7 @@ default String get(final Class c, final String name) { /** * Saves a key/value pair in persistent storage. - * + * * @param c The class with which the key/value pair is associated. * @param name The key where the value should be stored. * @param value The value to store. @@ -177,7 +177,7 @@ default String get(final Class c, final String name) { /** * Saves a key/value pair in persistent storage. - * + * * @param c The class with which the key/value pair is associated. * @param name The key where the value should be stored. * @param value The value to store. @@ -187,7 +187,7 @@ default String get(final Class c, final String name) { /** * Saves a key/value pair in persistent storage. - * + * * @param c The class with which the key/value pair is associated. * @param name The key where the value should be stored. * @param value The value to store. @@ -197,7 +197,7 @@ default String get(final Class c, final String name) { /** * Saves a key/value pair in persistent storage. - * + * * @param c The class with which the key/value pair is associated. * @param name The key where the value should be stored. * @param value The value to store. @@ -207,7 +207,7 @@ default String get(final Class c, final String name) { /** * Saves a key/value pair in persistent storage. - * + * * @param c The class with which the key/value pair is associated. * @param name The key where the value should be stored. * @param value The value to store. @@ -217,7 +217,7 @@ default String get(final Class c, final String name) { /** * Deletes a key from persistent storage. - * + * * @param c The class with which the key is associated. * @param name The key to remove. */ @@ -225,6 +225,7 @@ default String get(final Class c, final String name) { /** * Deletes all of the given {@link Class}'s keys from persistent storage. + * * @param c The class whose keys should be removed. */ void clear(Class c); diff --git a/src/main/java/org/scijava/run/AbstractCodeRunner.java b/src/main/java/org/scijava/run/AbstractCodeRunner.java index e60bc4f64..d7190dfd8 100644 --- a/src/main/java/org/scijava/run/AbstractCodeRunner.java +++ b/src/main/java/org/scijava/run/AbstractCodeRunner.java @@ -6,13 +6,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 @@ -37,11 +37,11 @@ /** * Abstract superclass of {@link CodeRunner} implementations. - * + * * @author Curtis Rueden */ -public abstract class AbstractCodeRunner extends - AbstractHandlerPlugin implements CodeRunner +public abstract class AbstractCodeRunner extends AbstractHandlerPlugin + implements CodeRunner { // -- Internal methods -- diff --git a/src/main/java/org/scijava/run/CodeRunner.java b/src/main/java/org/scijava/run/CodeRunner.java index 9bef19655..41680f2b4 100644 --- a/src/main/java/org/scijava/run/CodeRunner.java +++ b/src/main/java/org/scijava/run/CodeRunner.java @@ -6,13 +6,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 @@ -42,20 +42,20 @@ * {@code main} method of a Java {@link Class}, or an {@link Identifiable} * SciJava module. *

    - * Code runner plugins discoverable at runtime must implement this interface - * and be annotated with @{@link Plugin} with attribute {@link Plugin#type()} = + * 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 * {@link AbstractCodeRunner}, for convenience. *

    - * + * * @author Curtis Rueden */ public interface CodeRunner extends HandlerPlugin { /** - * Executes the code identified by the given object, passing the - * specified arguments as inputs. + * 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 ef8bee6e3..0fe11ebd6 100644 --- a/src/main/java/org/scijava/run/DefaultRunService.java +++ b/src/main/java/org/scijava/run/DefaultRunService.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * Default service for managing available {@link CodeRunner} plugins. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) diff --git a/src/main/java/org/scijava/run/RunService.java b/src/main/java/org/scijava/run/RunService.java index 0c030b383..9dbaaa476 100644 --- a/src/main/java/org/scijava/run/RunService.java +++ b/src/main/java/org/scijava/run/RunService.java @@ -6,13 +6,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 @@ -37,11 +37,11 @@ /** * Interface for service that manages available {@link CodeRunner} plugins. - * + * * @author Curtis Rueden */ -public interface RunService extends - HandlerService, SciJavaService +public interface RunService extends HandlerService, + SciJavaService { /** diff --git a/src/main/java/org/scijava/run/console/RunArgument.java b/src/main/java/org/scijava/run/console/RunArgument.java index ce84a31cf..ba5ef92a1 100644 --- a/src/main/java/org/scijava/run/console/RunArgument.java +++ b/src/main/java/org/scijava/run/console/RunArgument.java @@ -6,13 +6,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/AbstractAutoCompleter.java b/src/main/java/org/scijava/script/AbstractAutoCompleter.java index b5b784448..bdaebb383 100644 --- a/src/main/java/org/scijava/script/AbstractAutoCompleter.java +++ b/src/main/java/org/scijava/script/AbstractAutoCompleter.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ /** * Abstract base class for {@link AutoCompleter} implementations. - * + * * @author Hadrien Mary */ public abstract class AbstractAutoCompleter implements AutoCompleter { @@ -73,8 +73,8 @@ else if (code.contains(".")) { final List codeList = Arrays.asList(code.split("\\.")); final String objectString = codeList.get(codeList.size() - 2); final String prefix = codeList.get(codeList.size() - 1); - matches.addAll(engineAttributesCompleter(objectString + ".", - prefix, index, engine)); + matches.addAll(engineAttributesCompleter(objectString + ".", prefix, + index, engine)); } else { diff --git a/src/main/java/org/scijava/script/AbstractScriptContext.java b/src/main/java/org/scijava/script/AbstractScriptContext.java index 30ccac002..696cf9823 100644 --- a/src/main/java/org/scijava/script/AbstractScriptContext.java +++ b/src/main/java/org/scijava/script/AbstractScriptContext.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * A minimal implementation of {@link javax.script.ScriptContext} for use in the * {@link AbstractScriptEngine}. - * + * * @author Johannes Schindelin */ public class AbstractScriptContext implements ScriptContext { @@ -111,8 +111,8 @@ public Object removeAttribute(final String key, final int scope) { } @Override - public void - setAttribute(final String key, final Object value, final int scope) + public void setAttribute(final String key, final Object value, + final int scope) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/org/scijava/script/AbstractScriptEngine.java b/src/main/java/org/scijava/script/AbstractScriptEngine.java index 6875cd203..e8eba9d08 100644 --- a/src/main/java/org/scijava/script/AbstractScriptEngine.java +++ b/src/main/java/org/scijava/script/AbstractScriptEngine.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ /** * This class implements dummy versions for ScriptEngine's methods that are not * needed by the SciJava scripting framework. - * + * * @author Johannes Schindelin */ public abstract class AbstractScriptEngine implements ScriptEngine, Logged { diff --git a/src/main/java/org/scijava/script/AbstractScriptHeader.java b/src/main/java/org/scijava/script/AbstractScriptHeader.java index 131ebe7bb..9437a5df3 100644 --- a/src/main/java/org/scijava/script/AbstractScriptHeader.java +++ b/src/main/java/org/scijava/script/AbstractScriptHeader.java @@ -6,13 +6,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/AbstractScriptLanguage.java b/src/main/java/org/scijava/script/AbstractScriptLanguage.java index 1aa04fbba..b55264b46 100644 --- a/src/main/java/org/scijava/script/AbstractScriptLanguage.java +++ b/src/main/java/org/scijava/script/AbstractScriptLanguage.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ * This class implements dummy versions of {@link ScriptEngineFactory}'s methods * that are not needed by the SciJava scripting framework. *

    - * + * * @author Johannes Schindelin */ public abstract class AbstractScriptLanguage extends AbstractRichPlugin diff --git a/src/main/java/org/scijava/script/AdaptedScriptEngine.java b/src/main/java/org/scijava/script/AdaptedScriptEngine.java index 3c7acd8ef..d4b8c79d1 100644 --- a/src/main/java/org/scijava/script/AdaptedScriptEngine.java +++ b/src/main/java/org/scijava/script/AdaptedScriptEngine.java @@ -6,13 +6,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/AdaptedScriptLanguage.java b/src/main/java/org/scijava/script/AdaptedScriptLanguage.java index 449068235..4a8b15ef9 100644 --- a/src/main/java/org/scijava/script/AdaptedScriptLanguage.java +++ b/src/main/java/org/scijava/script/AdaptedScriptLanguage.java @@ -6,13 +6,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 @@ -45,7 +45,7 @@ * 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 AdaptedScriptLanguage extends AbstractScriptLanguage { @@ -141,7 +141,8 @@ public ScriptEngine getScriptEngine() { // -- Helper methods -- private static ScriptEngineFactory findFactory(final String factoryName) { - final ScriptEngineManager manager = new ScriptEngineManager(Context.getClassLoader()); + final ScriptEngineManager manager = new ScriptEngineManager(Context + .getClassLoader()); for (final ScriptEngineFactory factory : manager.getEngineFactories()) { for (final String name : factory.getNames()) { if (factoryName.equals(name)) return factory; diff --git a/src/main/java/org/scijava/script/AutoCompleter.java b/src/main/java/org/scijava/script/AutoCompleter.java index 632e7498b..bc53ad186 100644 --- a/src/main/java/org/scijava/script/AutoCompleter.java +++ b/src/main/java/org/scijava/script/AutoCompleter.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.script; import javax.script.ScriptEngine; diff --git a/src/main/java/org/scijava/script/AutoCompletionResult.java b/src/main/java/org/scijava/script/AutoCompletionResult.java index d3eecd426..802e73eeb 100644 --- a/src/main/java/org/scijava/script/AutoCompletionResult.java +++ b/src/main/java/org/scijava/script/AutoCompletionResult.java @@ -6,13 +6,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,7 +33,7 @@ /** * Data structure housing suggestions given by {@link AutoCompleter} helpers. - * + * * @author Hadrien Mary */ public class AutoCompletionResult { diff --git a/src/main/java/org/scijava/script/CodeGenerator.java b/src/main/java/org/scijava/script/CodeGenerator.java index fa2e6d624..e9340ce22 100644 --- a/src/main/java/org/scijava/script/CodeGenerator.java +++ b/src/main/java/org/scijava/script/CodeGenerator.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Code Generator Interface - * + * * @author Grant Harris * @deprecated To be removed in SciJava Common 3.0.0. */ diff --git a/src/main/java/org/scijava/script/CodeGeneratorJava.java b/src/main/java/org/scijava/script/CodeGeneratorJava.java index 61135865c..a87f47992 100644 --- a/src/main/java/org/scijava/script/CodeGeneratorJava.java +++ b/src/main/java/org/scijava/script/CodeGeneratorJava.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * {@link CodeGenerator} for Java. - * + * * @author Grant Harris * @deprecated To be removed in SciJava Common 3.0.0. */ diff --git a/src/main/java/org/scijava/script/DefaultAutoCompleter.java b/src/main/java/org/scijava/script/DefaultAutoCompleter.java index ef3890a16..b16f2af7d 100644 --- a/src/main/java/org/scijava/script/DefaultAutoCompleter.java +++ b/src/main/java/org/scijava/script/DefaultAutoCompleter.java @@ -6,13 +6,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/DefaultScriptHeaderService.java b/src/main/java/org/scijava/script/DefaultScriptHeaderService.java index 3593d98da..fe6b79cb3 100644 --- a/src/main/java/org/scijava/script/DefaultScriptHeaderService.java +++ b/src/main/java/org/scijava/script/DefaultScriptHeaderService.java @@ -6,13 +6,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/DefaultScriptInterpreter.java b/src/main/java/org/scijava/script/DefaultScriptInterpreter.java index b0e569824..2767add44 100644 --- a/src/main/java/org/scijava/script/DefaultScriptInterpreter.java +++ b/src/main/java/org/scijava/script/DefaultScriptInterpreter.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.script; import java.lang.reflect.Method; @@ -48,7 +49,7 @@ * Credit to Jason Sachs for the multi-line evaluation (see * his post on StackOverflow). *

    - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -81,7 +82,7 @@ public DefaultScriptInterpreter(final PrefService prefs, /** * Creates a new script interpreter for the given script language. - * + * * @param language {@link ScriptLanguage} of the interpreter */ public DefaultScriptInterpreter(final ScriptLanguage language) { @@ -91,7 +92,7 @@ public DefaultScriptInterpreter(final ScriptLanguage language) { /** * 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 @@ -102,8 +103,8 @@ public DefaultScriptInterpreter(final ScriptLanguage language, language.getContext().inject(this); this.language = language; this.engine = engine == null ? language.getScriptEngine() : engine; - history = prefs == null ? null : - new History(prefs, this.engine.getClass().getName()); + history = prefs == null ? null : new History(prefs, this.engine.getClass() + .getName()); readHistory(); buffer = new StringBuilder(); reset(); @@ -363,7 +364,7 @@ private static T callMethod(final Object object, final String methodName, } // -- Helper classes -- - + /** Container for a script language's interpreter history. */ private static class History { @@ -375,14 +376,14 @@ private static 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; /** * Constructs a history object for a given scripting language. - * + * * @param name the name of the scripting language */ public History(final PrefService prefs, final String name) { @@ -402,7 +403,7 @@ public void read() { /** * Persist the history. - * + * * @see PrefService */ public void write() { @@ -411,7 +412,7 @@ public void write() { /** * Adds the most recently issued command. - * + * * @param command the most recent command to add to the history */ public void add(final String command) { @@ -434,7 +435,7 @@ public boolean replace(final String command) { * This method wraps around, i.e. it returns {@code null} when there is no * more-recent command in the history. *

    - * + * * @return the next command */ public String next() { @@ -448,7 +449,7 @@ public String next() { * This method wraps around, i.e. it returns {@code null} when there is no * less-recent command in the history. *

    - * + * * @return the previous command */ public String previous() { diff --git a/src/main/java/org/scijava/script/DefaultScriptService.java b/src/main/java/org/scijava/script/DefaultScriptService.java index ba308b947..8df821032 100644 --- a/src/main/java/org/scijava/script/DefaultScriptService.java +++ b/src/main/java/org/scijava/script/DefaultScriptService.java @@ -6,13 +6,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 @@ -67,7 +67,7 @@ /** * Default service for working with scripts. - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -374,8 +374,8 @@ private void addAliases(final HashMap> map, } } - private void - addAlias(final HashMap> map, final Class type) + private void addAlias(final HashMap> map, + final Class type) { if (type == null) return; map.put(type.getSimpleName(), type); @@ -387,16 +387,15 @@ private void addAliases(final HashMap> map, private Class[] pluginClasses(final Class type) { return pluginService.getPluginsOfType(type).stream() // .filter(info -> !info.is("noAlias")) // - .map(info -> - { - try { - return info.loadClass(); - } - catch (final InstantiableException exc) { - log.warn("Invalid class: " + info.getClassName(), exc); - return null; - } - }).toArray(Class[]::new); + .map(info -> { + try { + return info.loadClass(); + } + catch (final InstantiableException exc) { + log.warn("Invalid class: " + info.getClassName(), exc); + return null; + } + }).toArray(Class[]::new); } private String stripArrayNotation(final String alias) { diff --git a/src/main/java/org/scijava/script/InvocationObject.java b/src/main/java/org/scijava/script/InvocationObject.java index 6ec2e5260..f3114e369 100644 --- a/src/main/java/org/scijava/script/InvocationObject.java +++ b/src/main/java/org/scijava/script/InvocationObject.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Holds a module or plugin reference that was invoked in a macro recording, and * the parameters that were passed to it. - * + * * @author Grant Harris * @deprecated To be removed in SciJava Common 3.0.0. */ @@ -42,8 +42,7 @@ public class InvocationObject { public String moduleCalled; - public ArrayList parameterObjects = - new ArrayList<>(); + public ArrayList parameterObjects = new ArrayList<>(); public InvocationObject(final String moduleCalled) { this.moduleCalled = moduleCalled; diff --git a/src/main/java/org/scijava/script/ParameterObject.java b/src/main/java/org/scijava/script/ParameterObject.java index f6d2ada7d..30e2044e3 100644 --- a/src/main/java/org/scijava/script/ParameterObject.java +++ b/src/main/java/org/scijava/script/ParameterObject.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Holds a parameter, its type and value, for a recorded macro. - * + * * @author Grant Harris * @deprecated To be removed in SciJava Common 3.0.0. */ diff --git a/src/main/java/org/scijava/script/ScriptCLI.java b/src/main/java/org/scijava/script/ScriptCLI.java index f04d344b5..4bf411972 100644 --- a/src/main/java/org/scijava/script/ScriptCLI.java +++ b/src/main/java/org/scijava/script/ScriptCLI.java @@ -6,13 +6,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 @@ -65,7 +65,7 @@ public class ScriptCLI { "\n" + // "For script-args, give space-separated key=value pairs,\n" + // "while will be passed in as SciJava script arguments."; - + public static void main(String... args) throws Exception { final Map inputs = new HashMap<>(); File file = null; @@ -75,7 +75,7 @@ public static void main(String... args) throws Exception { boolean parsingOptions = true; try (final Context context = new Context()) { // Parse command-line arguments. - if (args.length == 0) args = new String[] {"-h"}; + if (args.length == 0) args = new String[] { "-h" }; for (int i = 0; i < args.length; i++) { if (parsingOptions) { // Parse options and filename. @@ -95,7 +95,9 @@ else if (i < args.length - 1 && // else if (args[i].equals("-o") || args[i].equals("--print-outputs")) { printOutputs = true; } - else if (args[i].equals("-r") || args[i].equals("--print-return-value")) { + else if (args[i].equals("-r") || args[i].equals( + "--print-return-value")) + { printReturnValue = true; } else if (args[i].equals("-")) { diff --git a/src/main/java/org/scijava/script/ScriptFinder.java b/src/main/java/org/scijava/script/ScriptFinder.java index 27a7aa7b7..5b8ea6eb0 100644 --- a/src/main/java/org/scijava/script/ScriptFinder.java +++ b/src/main/java/org/scijava/script/ScriptFinder.java @@ -6,13 +6,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 @@ -55,7 +55,7 @@ * include the {@code scripts} and {@code plugins/Scripts} folders off the * SciJava application's base directory. *

    - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -73,7 +73,7 @@ public class ScriptFinder extends AbstractContextual { /** * Creates a new script finder. - * + * * @param context The SciJava application context housing needed services. */ public ScriptFinder(final Context context) { @@ -82,7 +82,7 @@ public ScriptFinder(final Context context) { /** * 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. @@ -96,7 +96,7 @@ public ScriptFinder(final Context context, final String pathPrefix) { /** * Discovers the scripts. - * + * * @param scripts The collection to which the discovered scripts are added. */ public void findScripts(final List scripts) { @@ -120,7 +120,9 @@ public void findScripts(final List scripts) { // -- Helper methods -- /** Scans classpath resources for scripts (e.g., inside JAR files). */ - private int scanResources(final List scripts, final Set urls) { + private int scanResources(final List scripts, + final Set urls) + { if (pathPrefix == null) return 0; // NB: We leave the baseDirectory argument null, because scripts on disk @@ -180,7 +182,7 @@ private int createInfos(final List scripts, final Set urls, // menuPath = File > Import > Movie File... // Place base-level scripts in the "Plugins>Scripts" submenu - if (menuPath.size() == 1){ + if (menuPath.size() == 1) { menuPath.add(0, new MenuEntry("Plugins")); menuPath.add(1, new MenuEntry("Scripts")); } diff --git a/src/main/java/org/scijava/script/ScriptHeader.java b/src/main/java/org/scijava/script/ScriptHeader.java index c1a3d3269..55bd842cb 100644 --- a/src/main/java/org/scijava/script/ScriptHeader.java +++ b/src/main/java/org/scijava/script/ScriptHeader.java @@ -6,13 +6,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/ScriptHeaderService.java b/src/main/java/org/scijava/script/ScriptHeaderService.java index c697d90f2..981a2f6f3 100644 --- a/src/main/java/org/scijava/script/ScriptHeaderService.java +++ b/src/main/java/org/scijava/script/ScriptHeaderService.java @@ -6,13 +6,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 @@ -37,9 +37,9 @@ * {@link ScriptLanguage}s to {@link ScriptHeader}s. *

    * NB: although individual/highest priority handlers can be queried as normal - * via a {@code HandlerService}, the - * {@link #getHeader(ScriptLanguage)} method will combine the headers - * for all available {@code ScriptHeader}s for a given {@code ScriptLanguage}. + * via a {@code HandlerService}, the {@link #getHeader(ScriptLanguage)} method + * will combine the headers for all available {@code ScriptHeader}s for a given + * {@code ScriptLanguage}. *

    * * @author Mark Hiner diff --git a/src/main/java/org/scijava/script/ScriptInfo.java b/src/main/java/org/scijava/script/ScriptInfo.java index a6c00d5c6..76bc466a1 100644 --- a/src/main/java/org/scijava/script/ScriptInfo.java +++ b/src/main/java/org/scijava/script/ScriptInfo.java @@ -6,13 +6,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 @@ -59,7 +59,7 @@ /** * Metadata about a script. - * + * * @author Curtis Rueden * @author Johannes Schindelin */ @@ -97,7 +97,7 @@ public class ScriptInfo extends AbstractModuleInfo implements Contextual { /** * Creates a script metadata object which describes the given script file. - * + * * @param context The SciJava application context to use when populating * service inputs. * @param file The script file. @@ -108,7 +108,7 @@ public ScriptInfo(final Context context, final File file) { /** * Creates a script metadata object which describes the given script file. - * + * * @param context The SciJava application context to use when populating * service inputs. * @param path Path to the script file. @@ -119,7 +119,7 @@ public ScriptInfo(final Context context, final String path) { /** * 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. @@ -130,13 +130,14 @@ public ScriptInfo(final Context context, final String path) { public ScriptInfo(final Context context, final URL url, final String path) throws IOException { - this(context, url, path, new InputStreamReader(url.openStream(), StandardCharsets.UTF_8)); + this(context, url, path, new InputStreamReader(url.openStream(), + StandardCharsets.UTF_8)); } /** * Creates a script metadata object which describes a script provided by the * given {@link Reader}. - * + * * @param context The SciJava application context to use when populating * service inputs. * @param path Pseudo-path to the script file. This file does not actually @@ -220,7 +221,7 @@ public BufferedReader getReader() { /** * Gets the script contents after script processing. - * + * * @return The processed script. * @see ScriptProcessorService#process */ @@ -265,7 +266,7 @@ public void setReturnValueAppended(final boolean appendReturnValue) { /** * Gets the list of routines which should be invoked each time the script is * about to execute. - * + * * @return Reference to the mutable list of {@link Runnable} objects which the * {@link ScriptModule} will run prior to executing the script itself. */ @@ -278,7 +279,7 @@ public List callbacks() { /** * Performs script processing. In particular, parses the script parameters. - * + * * @see ParameterScriptProcessor * @see ScriptProcessorService#process */ @@ -385,8 +386,8 @@ public String getVersion() { log.error(exc); } final Date lastModified = FileUtils.getModifiedTime(file); - final String datestamp = - new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss").format(lastModified); + final String datestamp = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss").format( + lastModified); return datestamp; } diff --git a/src/main/java/org/scijava/script/ScriptInterpreter.java b/src/main/java/org/scijava/script/ScriptInterpreter.java index 8faebc3c3..7efb201bd 100644 --- a/src/main/java/org/scijava/script/ScriptInterpreter.java +++ b/src/main/java/org/scijava/script/ScriptInterpreter.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * The contract for script interpreters. - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -60,7 +60,7 @@ public interface ScriptInterpreter { /** * Obtains the next/previous command in the command history. - * + * * @param currentCommand the current command (will be stored in the history) * @param forward if true, the next history entry is returned (more recent), * if false, the previous one @@ -70,7 +70,7 @@ public interface ScriptInterpreter { /** * Evaluates a command. - * + * * @param command the command to evaluate * @return result of the evaluation * @throws ScriptException @@ -80,7 +80,7 @@ public interface ScriptInterpreter { /** * 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 @@ -92,7 +92,7 @@ public interface ScriptInterpreter { * 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(); @@ -104,7 +104,7 @@ public interface ScriptInterpreter { /** * Returns the associated {@link ScriptEngine}. - * + * * @return the script engine */ ScriptEngine getEngine(); diff --git a/src/main/java/org/scijava/script/ScriptLanguage.java b/src/main/java/org/scijava/script/ScriptLanguage.java index 4a5446292..caa303c19 100644 --- a/src/main/java/org/scijava/script/ScriptLanguage.java +++ b/src/main/java/org/scijava/script/ScriptLanguage.java @@ -6,13 +6,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 @@ -61,7 +61,7 @@ * language adapter merely by implementing this interface, it is encouraged to * instead extend {@link AbstractScriptLanguage}, for convenience. *

    - * + * * @author Johannes Schindelin * @author Curtis Rueden * @author Hadrien Mary @@ -75,10 +75,20 @@ default boolean isCompiledLanguage() { return false; } + /** + * Flag for complex languages that need to limit execution to a specific + * context. + * + * @return true if this language is available for selection + */ + default boolean isActive() { + return true; + } + /** * Performs any necessary conversion of an encoded object retrieved from the * language's script engine. - * + * * @see ScriptEngine#get(String) */ default Object decode(final Object object) { diff --git a/src/main/java/org/scijava/script/ScriptLanguageIndex.java b/src/main/java/org/scijava/script/ScriptLanguageIndex.java index f3680e18b..c2c55ccf8 100644 --- a/src/main/java/org/scijava/script/ScriptLanguageIndex.java +++ b/src/main/java/org/scijava/script/ScriptLanguageIndex.java @@ -6,13 +6,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 @@ -39,11 +39,10 @@ import org.scijava.log.LogService; import org.scijava.util.FileUtils; -import org.scijava.util.Types; /** * Data structure for managing registered scripting languages. - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -51,43 +50,41 @@ public class ScriptLanguageIndex extends ArrayList { private static final long serialVersionUID = 1L; - private final Map byExtension = - new HashMap<>(); + private final Map> byExtension = new HashMap<>(); - private final Map byName = - new HashMap<>(); + private final Map> byName = new HashMap<>(); private final LogService log; - @Deprecated - public ScriptLanguageIndex() { - this(null); - } - /** * Instantiates an index of the available script languages. - * + * * @param log the log service for errors and warnings */ public ScriptLanguageIndex(final LogService log) { this.log = log; } - public boolean add(final ScriptEngineFactory factory, final boolean gently) { + /** + * @deprecated Gently flag is no longer respected. Use + * {@link #add(ScriptLanguage)}. + */ + @Deprecated + boolean add(final ScriptEngineFactory factory, final boolean gently) { boolean result = false; final ScriptLanguage language = wrap(factory); // add language names - result |= put("name", byName, language.getLanguageName(), language, gently); + result |= put(byName, language.getLanguageName(), language, gently); for (final String name : language.getNames()) { - result |= put("name", byName, name, language, gently); + result |= put(byName, name, language, gently); } // add file extensions for (final String extension : language.getExtensions()) { if ("".equals(extension)) continue; - result |= put("extension", byExtension, extension, language, gently); + result |= put(byExtension, extension, language, gently); } result |= super.add(language); @@ -95,11 +92,21 @@ public boolean add(final ScriptEngineFactory factory, final boolean gently) { } public ScriptLanguage getByExtension(final String extension) { - return byExtension.get(extension); + List langs = byExtension.get(extension); + if (langs == null) return null; + for (ScriptLanguage lang : langs) { + if (lang.isActive()) return lang; + } + return null; } public ScriptLanguage getByName(final String name) { - return byName.get(name); + List langs = byName.get(name); + if (langs == null) return null; + for (ScriptLanguage lang : langs) { + if (lang.isActive()) return lang; + } + return null; } public String[] getFileExtensions(final ScriptLanguage language) { @@ -128,37 +135,15 @@ public boolean add(final ScriptLanguage language) { // -- Helper methods -- - private boolean put(final String type, final Map map, + private boolean put(final Map> map, final String key, final ScriptLanguage value, final boolean gently) { - 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; + List list = map.get(key); + if (list == null) { + list = new ArrayList<>(); + map.put(key, list); } - - if (existing != null) { - // Conflicting value; behavior depends on mode. - if (gently) { - // Do not overwrite the previous value. - if (log != null && log.isDebug()) { - log.debug(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; + return list.add(value); } /** Helper method of {@link #add(ScriptEngineFactory, boolean)}. */ @@ -166,21 +151,4 @@ private ScriptLanguage wrap(final ScriptEngineFactory factory) { if (factory instanceof ScriptLanguage) return (ScriptLanguage) 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 = " + 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() + " [" + Types.location(c); - } } diff --git a/src/main/java/org/scijava/script/ScriptModule.java b/src/main/java/org/scijava/script/ScriptModule.java index b686b52a9..a100172f5 100644 --- a/src/main/java/org/scijava/script/ScriptModule.java +++ b/src/main/java/org/scijava/script/ScriptModule.java @@ -6,13 +6,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 @@ -50,7 +50,7 @@ /** * A {@link Module} which executes a script. - * + * * @author Curtis Rueden * @author Johannes Schindelin */ diff --git a/src/main/java/org/scijava/script/ScriptREPL.java b/src/main/java/org/scijava/script/ScriptREPL.java index 9c1b838dd..7bb438732 100644 --- a/src/main/java/org/scijava/script/ScriptREPL.java +++ b/src/main/java/org/scijava/script/ScriptREPL.java @@ -6,13 +6,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 @@ -138,7 +138,7 @@ public void loop() throws IOException { /** * 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 { @@ -164,8 +164,8 @@ public void loop(final InputStream in) throws IOException { } /** - * Starts a Read-Eval-Print-Loop from the given source, returning when - * the loop terminates. + * Starts a Read-Eval-Print-Loop from the given source, returning when the + * loop terminates. * * @param in Source from which commands are read. */ @@ -190,7 +190,7 @@ public void initialize() { /** * Sets up the initial language and variables of the REPL. - * + * * @param verbose Whether to output an initial greeting. */ public void initialize(final boolean verbose) { @@ -202,10 +202,13 @@ public void initialize(final boolean verbose) { final List langs = getInterpretedLanguages(); if (verbose) { if (langs.isEmpty()) { - println("--------------------------------------------------------------"); + println( + "--------------------------------------------------------------"); println("Uh oh! There are no SciJava script languages available!"); - println("Are any on your classpath? E.g.: org.scijava:scripting-groovy?"); - println("--------------------------------------------------------------"); + println( + "Are any on your classpath? E.g.: org.scijava:scripting-groovy?"); + println( + "--------------------------------------------------------------"); println(); return; } @@ -220,9 +223,9 @@ public void initialize(final boolean verbose) { } private void selectPreferredLanguage(List langs) { - final ScriptLanguage preference = langs.stream() - .filter(lang -> languagePreference.equals(lang.getLanguageName())) - .findFirst().orElse(langs.get(0)); + final ScriptLanguage preference = langs.stream().filter( + lang -> languagePreference.equals(lang.getLanguageName())).findFirst() + .orElse(langs.get(0)); lang(preference); } @@ -234,7 +237,7 @@ public void prompt() { /** * Evaluates the line, including handling of special colon-prefixed REPL * commands. - * + * * @param line The line to evaluate. * @return False iff the REPL should exit. */ @@ -309,7 +312,7 @@ public void vars() { /** * 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. @@ -328,12 +331,12 @@ public void lang(final String langName) { /** * Creates a new {@link ScriptInterpreter} to interpret statements, preserving * existing variables from the previous interpreter. - * + * * @param language The script language of the new interpreter. */ public void lang(final ScriptLanguage language) { - final ScriptInterpreter newInterpreter = - new DefaultScriptInterpreter(language); + final ScriptInterpreter newInterpreter = new DefaultScriptInterpreter( + language); // preserve state of the previous interpreter try { @@ -371,10 +374,11 @@ public static void main(final String... args) throws Exception { // see if we have a preferred language // and create the script interpreter final ScriptREPL scriptCLI; - if(args.length > 0) { + if (args.length > 0) { final String preference = args[0]; scriptCLI = new ScriptREPL(context, preference); - } else { + } + else { scriptCLI = new ScriptREPL(context); } @@ -431,12 +435,12 @@ private List gateways() { // 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); + final List> infos = pluginService.getPluginsOfType( + Gateway.class); for (final PluginInfo info : infos) { try { - final Constructor ctor = - info.loadClass().getConstructor(Context.class); + final Constructor ctor = info.loadClass() + .getConstructor(Context.class); final Gateway gateway = ctor.newInstance(context); gateways.add(gateway); } @@ -454,8 +458,8 @@ private String serviceName(final Service service) { if (pluginName != null && !pluginName.isEmpty()) return pluginName; // No name was given; synthesize one from the class name. final String serviceName = service.getClass().getSimpleName(); - final String shortName = lowerCamelCase( - serviceName.replaceAll("^(Default)?(.*)Service$", "$2")); + final String shortName = lowerCamelCase(serviceName.replaceAll( + "^(Default)?(.*)Service$", "$2")); return shortName; } @@ -467,9 +471,18 @@ private String type(final Object value) { } private static final String NL = System.getProperty("line.separator"); - private void print(String s) { out.accept(s); } - private void println() { print(NL); } - private void println(final String s) { print(s + NL); } + + private void print(String s) { + out.accept(s); + } + + private void println() { + print(NL); + } + + private void println(final String s) { + print(s + NL); + } private void printStackTrace(final Throwable t) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -508,14 +521,17 @@ private void printColumns(final List... columns) { } private static Consumer outputStreamConsumer(final OutputStream out) { - final PrintStream ps = out instanceof PrintStream ? - (PrintStream) out : new PrintStream(out); - return s -> { ps.print(s); ps.flush(); }; + final PrintStream ps = out instanceof PrintStream ? (PrintStream) out + : new PrintStream(out); + return s -> { + ps.print(s); + ps.flush(); + }; } 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; diff --git a/src/main/java/org/scijava/script/ScriptService.java b/src/main/java/org/scijava/script/ScriptService.java index 6d1d5f5b5..77d186515 100644 --- a/src/main/java/org/scijava/script/ScriptService.java +++ b/src/main/java/org/scijava/script/ScriptService.java @@ -6,13 +6,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 @@ -50,7 +50,7 @@ /** * Interface for service that works with scripts. This service discovers * available scripts, and provides convenience methods to interact with them. - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -60,7 +60,7 @@ public interface ScriptService extends SingletonService, /** * System property for overriding the list of directories to scan for scripts. - * + * * @see #getScriptDirectories() */ String SCRIPTS_PATH_PROPERTY = "scijava.scripts.path"; @@ -129,7 +129,7 @@ default ScriptLanguage getLanguageByName(final String name) { /** * Executes the script in the given file. - * + * * @param file File containing the script to execute. * @param process If true, executes the script with pre- and postprocessing * steps from all available {@link PreprocessorPlugin}s and @@ -149,7 +149,7 @@ Future run(File file, boolean process, Object... inputs) /** * Executes the script in the given file. - * + * * @param file File containing the script to execute. * @param process If true, executes the script with pre- and postprocessing * steps from all available {@link PreprocessorPlugin}s and @@ -167,7 +167,7 @@ Future run(File file, boolean process, /** * Executes the given script. - * + * * @param path Pseudo-path to the script. This is important mostly for the * path's file extension, which provides an important hint as to the * language of the script. @@ -193,7 +193,7 @@ default Future run(final String path, final String script, /** * Executes the given script. - * + * * @param path Pseudo-path to the script. This is important mostly for the * path's file extension, which provides an important hint as to the * language of the script. @@ -217,7 +217,7 @@ default Future run(final String path, final String script, /** * Executes the given script. - * + * * @param path Pseudo-path to the script. This is important mostly for the * path's file extension, which provides an important hint as to the * language of the script. @@ -243,7 +243,7 @@ default Future run(final String path, final Reader reader, /** * Executes the given script. - * + * * @param path Pseudo-path to the script. This is important mostly for the * path's file extension, which provides an important hint as to the * language of the script. @@ -267,7 +267,7 @@ default Future run(final String path, final Reader reader, /** * Executes the given script. - * + * * @param info The script to instantiate and run. * @param process If true, executes the script with pre- and postprocessing * steps from all available {@link PreprocessorPlugin}s and @@ -286,7 +286,7 @@ default Future run(final String path, final Reader reader, /** * Executes the given script. - * + * * @param info The script to instantiate and run. * @param process If true, executes the script with pre- and postprocessing * steps from all available {@link PreprocessorPlugin}s and diff --git a/src/main/java/org/scijava/script/console/RunScriptArgument.java b/src/main/java/org/scijava/script/console/RunScriptArgument.java index df7335169..6a5480450 100644 --- a/src/main/java/org/scijava/script/console/RunScriptArgument.java +++ b/src/main/java/org/scijava/script/console/RunScriptArgument.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.script.console; import java.io.File; @@ -64,15 +65,15 @@ public RunScriptArgument() { @Override public void handle(final LinkedList args) { - if (!supports(args)) - return; + if (!supports(args)) return; 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() : ""; + final String paramString = ConsoleUtils.hasParam(args) ? args.removeFirst() + : ""; run(scriptToRun, paramString); } @@ -81,8 +82,7 @@ public void handle(final LinkedList args) { @Override public boolean supports(final LinkedList args) { - if (!super.supports(args)) - return false; + if (!super.supports(args)) return false; return getScript(args.get(1)) != null; } @@ -102,21 +102,24 @@ private void run(final String scriptToRun, final String paramString) { final ScriptInfo info = scriptService.getScript(script); - final Map inputMap = ConsoleUtils.parseParameterString(paramString, info, log); + final Map inputMap = ConsoleUtils.parseParameterString( + paramString, info, log); try { scriptService.run(info, true, inputMap).get(); - } catch (final Exception exc) { + } + catch (final Exception exc) { log.error(exc); } } /** - * Try to convert the given string to a {@link File} representing a - * supported script type. + * 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; + return scriptFile.exists() && scriptService.canHandleFile(scriptFile) + ? scriptFile : null; } } diff --git a/src/main/java/org/scijava/script/io/ScriptIOPlugin.java b/src/main/java/org/scijava/script/io/ScriptIOPlugin.java index dec94b517..6f9a55c57 100644 --- a/src/main/java/org/scijava/script/io/ScriptIOPlugin.java +++ b/src/main/java/org/scijava/script/io/ScriptIOPlugin.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ /** * {@link IOPlugin} for scripts. - * + * * @author Curtis Rueden * @see ScriptService */ diff --git a/src/main/java/org/scijava/script/process/DefaultScriptProcessorService.java b/src/main/java/org/scijava/script/process/DefaultScriptProcessorService.java index 99fd73812..947c95a6d 100644 --- a/src/main/java/org/scijava/script/process/DefaultScriptProcessorService.java +++ b/src/main/java/org/scijava/script/process/DefaultScriptProcessorService.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * Default implementation of {@link ScriptProcessorService}. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) diff --git a/src/main/java/org/scijava/script/process/DirectiveScriptProcessor.java b/src/main/java/org/scijava/script/process/DirectiveScriptProcessor.java index 4b1fe8c34..783417ec5 100644 --- a/src/main/java/org/scijava/script/process/DirectiveScriptProcessor.java +++ b/src/main/java/org/scijava/script/process/DirectiveScriptProcessor.java @@ -6,13 +6,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 @@ -43,9 +43,9 @@ import org.scijava.script.ScriptInfo; /** - * Abstract base class for {@link ScriptProcessor} plugins that parse lines - * of the form {@code #@directive(...) ...}. - * + * Abstract base class for {@link ScriptProcessor} plugins that parse lines of + * the form {@code #@directive(...) ...}. + * * @author Curtis Rueden */ public abstract class DirectiveScriptProcessor implements ScriptProcessor { diff --git a/src/main/java/org/scijava/script/process/ParameterScriptProcessor.java b/src/main/java/org/scijava/script/process/ParameterScriptProcessor.java index d3988e9ef..224f42901 100644 --- a/src/main/java/org/scijava/script/process/ParameterScriptProcessor.java +++ b/src/main/java/org/scijava/script/process/ParameterScriptProcessor.java @@ -6,13 +6,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 @@ -97,7 +97,7 @@ * Parameters will be parsed and filled just like @{@link Parameter}-annotated * fields in {@link Command}s. *

    - * + * * @author Curtis Rueden */ @Plugin(type = ScriptProcessor.class) @@ -140,8 +140,10 @@ public String process(final String line) { // NB: Check if line contains an '@' with no prior alphameric // characters. This assumes that only non-alphanumeric characters can // be used as comment line markers. - // NB: In addition, to allow for commented-out new-style parameters, we exclude - // lines that have the new-style #@ preceded by non-alphanumeric characters. + // NB: In addition, to allow for commented-out new-style parameters, we + // exclude + // lines that have the new-style #@ preceded by non-alphanumeric + // characters. if (line.matches("^[^\\w]*[^\\w#]@.*")) { final int at = line.indexOf('@'); return process(line, line.substring(at + 1)); @@ -175,8 +177,8 @@ private boolean parseParam(final String param) { final int rParen = param.lastIndexOf(")"); if (rParen < lParen) return false; if (lParen < 0) return parseParam(param, parseAttrs("()")); - final String cutParam = - param.substring(0, lParen) + param.substring(rParen + 1); + final String cutParam = param.substring(0, lParen) + param.substring( + rParen + 1); final String attrs = param.substring(lParen + 1, rParen); return parseParam(cutParam, parseAttrs(attrs)); } @@ -238,8 +240,8 @@ private boolean isIOType(final String token) { private void addItem(final String name, final Class type, final Map attrs, final boolean explicit) { - final DefaultMutableModuleItem item = - new DefaultMutableModuleItem<>(info, name, type); + final DefaultMutableModuleItem item = new DefaultMutableModuleItem<>( + info, name, type); for (final String key : attrs.keySet()) { final Object value = attrs.get(key); assignAttribute(item, key, value); @@ -277,7 +279,8 @@ private void assignAttribute(final DefaultMutableModuleItem item, 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, "visibility")) item.setVisibility(as(v, + ItemVisibility.class)); else if (is(k, "value")) item.setDefaultValue(as(v, item.getType())); else item.set(k, v.toString()); } diff --git a/src/main/java/org/scijava/script/process/ScriptCallback.java b/src/main/java/org/scijava/script/process/ScriptCallback.java index eaedad35c..3688921c6 100644 --- a/src/main/java/org/scijava/script/process/ScriptCallback.java +++ b/src/main/java/org/scijava/script/process/ScriptCallback.java @@ -6,13 +6,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 @@ -42,9 +42,9 @@ public interface ScriptCallback { /** * Invokes the callback routine. - * - * @param module The {@link ScriptModule} instance which will - * execute the script. + * + * @param module The {@link ScriptModule} instance which will execute the + * script. */ void invoke(final ScriptModule module) throws ScriptException; } diff --git a/src/main/java/org/scijava/script/process/ScriptDirectiveScriptProcessor.java b/src/main/java/org/scijava/script/process/ScriptDirectiveScriptProcessor.java index 40b905ede..0c98b1d01 100644 --- a/src/main/java/org/scijava/script/process/ScriptDirectiveScriptProcessor.java +++ b/src/main/java/org/scijava/script/process/ScriptDirectiveScriptProcessor.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ *

    * The syntax is: *

    - * + * *
      * #@script(key1=value1, key2=value2, ...)
      * 
    @@ -90,10 +90,10 @@ *
  • {@code #@script(headless = true)}
  • *
  • {@code #@script(menuPath = "Image > Import > Text...")}
  • * - * + * * @author Curtis Rueden */ -@Plugin(type = ScriptProcessor.class, priority=Priority.HIGH) +@Plugin(type = ScriptProcessor.class, priority = Priority.HIGH) public class ScriptDirectiveScriptProcessor extends DirectiveScriptProcessor { public ScriptDirectiveScriptProcessor() { @@ -102,7 +102,7 @@ public ScriptDirectiveScriptProcessor() { @Parameter private LogService log; - + @Parameter private ModuleService moduleService; diff --git a/src/main/java/org/scijava/script/process/ScriptProcessor.java b/src/main/java/org/scijava/script/process/ScriptProcessor.java index edeec681b..e9f387550 100644 --- a/src/main/java/org/scijava/script/process/ScriptProcessor.java +++ b/src/main/java/org/scijava/script/process/ScriptProcessor.java @@ -6,13 +6,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 @@ -40,13 +40,15 @@ * beginning with distinctive character sequences like {@code #@}, and then * perform some action in response. *

    - * + * * @author Curtis Rueden */ public interface ScriptProcessor extends SciJavaPlugin { void begin(ScriptInfo info); + String process(String line); + default void end() {} } diff --git a/src/main/java/org/scijava/script/process/ScriptProcessorService.java b/src/main/java/org/scijava/script/process/ScriptProcessorService.java index a73b4ebb7..d9d14aa75 100644 --- a/src/main/java/org/scijava/script/process/ScriptProcessorService.java +++ b/src/main/java/org/scijava/script/process/ScriptProcessorService.java @@ -6,13 +6,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 @@ -42,11 +42,11 @@ * Interface for service that processes scripts. This service discovers * available {@link ScriptProcessor} plugins, and provides convenience methods * to interact with them. - * + * * @author Curtis Rueden */ -public interface ScriptProcessorService extends - PTService, SciJavaService +public interface ScriptProcessorService extends PTService, + SciJavaService { /** diff --git a/src/main/java/org/scijava/script/process/ShebangScriptProcessor.java b/src/main/java/org/scijava/script/process/ShebangScriptProcessor.java index 6e3991590..9bd32ae78 100644 --- a/src/main/java/org/scijava/script/process/ShebangScriptProcessor.java +++ b/src/main/java/org/scijava/script/process/ShebangScriptProcessor.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * A {@link ScriptProcessor} which looks for a {@code #!} at the beginning of a * script, and set the language accordingly. - * + * * @author Curtis Rueden */ @Plugin(type = ScriptProcessor.class) diff --git a/src/main/java/org/scijava/script/run/ScriptCodeRunner.java b/src/main/java/org/scijava/script/run/ScriptCodeRunner.java index d016431ee..699b44186 100644 --- a/src/main/java/org/scijava/script/run/ScriptCodeRunner.java +++ b/src/main/java/org/scijava/script/run/ScriptCodeRunner.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ /** * Runs the given script. - * + * * @author Curtis Rueden * @author Mark Hiner */ diff --git a/src/main/java/org/scijava/service/AbstractService.java b/src/main/java/org/scijava/service/AbstractService.java index ce04e97e7..e5b3878c0 100644 --- a/src/main/java/org/scijava/service/AbstractService.java +++ b/src/main/java/org/scijava/service/AbstractService.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Abstract superclass of {@link Service} implementations. - * + * * @author Curtis Rueden */ public abstract class AbstractService extends AbstractRichPlugin implements diff --git a/src/main/java/org/scijava/service/SciJavaService.java b/src/main/java/org/scijava/service/SciJavaService.java index eb311bd80..15fe5df64 100644 --- a/src/main/java/org/scijava/service/SciJavaService.java +++ b/src/main/java/org/scijava/service/SciJavaService.java @@ -6,13 +6,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 @@ -39,14 +39,16 @@ * only. The idea is that this interface can be used to create a * {@link Context} containing core SciJava services using the invocation: *

    + * *
    + *
      * final Context context = new Context(SciJavaService.class);
      * 
    *

    * If you have a collection of services which you want to be grouped similarly, * just create your own marker interface for the same purpose. *

    - * + * * @author Mark Hiner */ public interface SciJavaService extends Service { diff --git a/src/main/java/org/scijava/service/Service.java b/src/main/java/org/scijava/service/Service.java index 13f2c1081..f090ad694 100644 --- a/src/main/java/org/scijava/service/Service.java +++ b/src/main/java/org/scijava/service/Service.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ * implementing this interface, it is encouraged to instead extend * {@link AbstractService}, for convenience. *

    - * + * * @author Curtis Rueden * @see Plugin */ @@ -53,9 +53,9 @@ public interface Service extends RichPlugin, Initializable, Disposable { /** * 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. + * 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() { @@ -71,9 +71,9 @@ default void registerEventHandlers() { /** * 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. + * 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. *

    */ @Override diff --git a/src/main/java/org/scijava/service/ServiceHelper.java b/src/main/java/org/scijava/service/ServiceHelper.java index 3b06233ca..161ba6464 100644 --- a/src/main/java/org/scijava/service/ServiceHelper.java +++ b/src/main/java/org/scijava/service/ServiceHelper.java @@ -6,13 +6,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 @@ -50,7 +50,7 @@ /** * Helper class for discovering and instantiating available services. - * + * * @author Curtis Rueden */ public class ServiceHelper extends AbstractContextual { @@ -78,7 +78,7 @@ public class ServiceHelper extends AbstractContextual { /** * Creates a new service helper for discovering and instantiating services. - * + * * @param context The application context for which services should be * instantiated. */ @@ -88,7 +88,7 @@ public ServiceHelper(final Context context) { /** * Creates a new service helper for discovering and instantiating services. - * + * * @param context The application context to which services should be added. * @param serviceClasses The service classes to instantiate. */ @@ -100,7 +100,7 @@ public ServiceHelper(final Context context, /** * Creates a new service helper for discovering and instantiating services. - * + * * @param context The application context to which services should be added. * @param serviceClasses The service classes to instantiate. * @param strict Whether service loading will fail fast when there is an error @@ -152,7 +152,7 @@ public ServiceHelper(final Context context, * priority services will go unused in many cases, it is critical that service * loading (initialization) is as lightweight as possible. *

    - * + * * @throws IllegalArgumentException if one of the requested services is * required (i.e., not marked {@link Optional}) but cannot be * filled. @@ -181,7 +181,7 @@ public void loadServices() { /** * Obtains a service compatible with the given class, instantiating it (and * registering it in the index) if necessary. - * + * * @return an existing compatible service if one is already registered; or * else a newly created instance of the service with highest priority; * or null if no suitable service can be created @@ -194,7 +194,7 @@ public S loadService(final Class c) { /** * Instantiates a service of the given class, registering it in the index. - * + * * @return the newly created service, or null if the given class cannot be * instantiated */ @@ -207,7 +207,7 @@ public S createExactService(final Class c) { /** * Obtains a service compatible with the given class, instantiating it (and * registering it in the index) if necessary. - * + * * @return an existing compatible service if one is already registered; or * else a newly created instance of the service with highest priority; * or null if no suitable service can be created @@ -248,10 +248,9 @@ private S loadService(final Class c, /** * Instantiates a service of the given class, registering it in the index. - * + * * @return the newly created service, or null if the given class cannot be * instantiated - * * @throws IllegalArgumentException if there is an error creating the service * and the {@code required} flag is {@code true} */ @@ -311,8 +310,8 @@ private S createServiceRecursively(final Class c) boolean eventServiceRequired = true; // populate service parameters - final List fields = - ClassUtils.getAnnotatedFields(c, Parameter.class); + final List fields = ClassUtils.getAnnotatedFields(c, + Parameter.class); for (final Field f : fields) { f.setAccessible(true); // expose private fields @@ -323,8 +322,8 @@ private S createServiceRecursively(final Class c) continue; } if (!Service.class.isAssignableFrom(type)) { - final String error = "Invalid parameter: " + - f.getDeclaringClass().getName() + "#" + f.getName(); + final String error = "Invalid parameter: " + f.getDeclaringClass() + .getName() + "#" + f.getName(); if (strict) throw new IllegalArgumentException(error); log.error(error); continue; @@ -360,8 +359,8 @@ private void findServiceClasses( final List> serviceList) { // ask the plugin index for the (sorted) list of available services - final List> services = - context().getPluginIndex().getPlugins(Service.class); + final List> services = context().getPluginIndex() + .getPlugins(Service.class); for (final PluginInfo info : services) { try { diff --git a/src/main/java/org/scijava/service/ServiceIndex.java b/src/main/java/org/scijava/service/ServiceIndex.java index f926883a0..a8a3ee01f 100644 --- a/src/main/java/org/scijava/service/ServiceIndex.java +++ b/src/main/java/org/scijava/service/ServiceIndex.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * Data structure for tracking registered services. - * + * * @author Curtis Rueden */ public class ServiceIndex extends SortedObjectIndex { @@ -101,7 +101,8 @@ private S getService(final Class c, if (ref != null) { // find the ref class's index - for (; index < list.size() && !list.get(index).getClass().equals(ref); index++) + for (; index < list.size() && !list.get(index).getClass().equals( + ref); index++) {} // ref class wasn't on the list diff --git a/src/main/java/org/scijava/service/event/ServicesLoadedEvent.java b/src/main/java/org/scijava/service/event/ServicesLoadedEvent.java index fe0109129..6b6eb2936 100644 --- a/src/main/java/org/scijava/service/event/ServicesLoadedEvent.java +++ b/src/main/java/org/scijava/service/event/ServicesLoadedEvent.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * An event which fires when a {@link Context} finishes initializing all its * services. - * + * * @author Barry DeZonia */ public class ServicesLoadedEvent extends SciJavaEvent { diff --git a/src/main/java/org/scijava/startup/DefaultStartupService.java b/src/main/java/org/scijava/startup/DefaultStartupService.java index 8131b6bc2..2bb9cae91 100644 --- a/src/main/java/org/scijava/startup/DefaultStartupService.java +++ b/src/main/java/org/scijava/startup/DefaultStartupService.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ /** * Default implementation of {@link StartupService}. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) diff --git a/src/main/java/org/scijava/startup/StartupService.java b/src/main/java/org/scijava/startup/StartupService.java index 35e747b39..5c873f15d 100644 --- a/src/main/java/org/scijava/startup/StartupService.java +++ b/src/main/java/org/scijava/startup/StartupService.java @@ -6,13 +6,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,7 +33,7 @@ /** * Interface for service managing startup operations. - * + * * @author Curtis Rueden */ public interface StartupService extends SciJavaService { diff --git a/src/main/java/org/scijava/task/DefaultTask.java b/src/main/java/org/scijava/task/DefaultTask.java index 048f7b773..d01226591 100644 --- a/src/main/java/org/scijava/task/DefaultTask.java +++ b/src/main/java/org/scijava/task/DefaultTask.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.task; import java.util.concurrent.ExecutionException; @@ -37,30 +38,28 @@ /** * Default implementation of {@link Task}. Throughout the task (or job), - * {@link Task#setProgressValue(long)} can be called to inform - * how the job is progressing. + * {@link Task#setProgressValue(long)} can be called to inform how the job is + * progressing. *

    - * Asynchronous case: - * A job (runnable) is sent for execution to the linked {@link ThreadService}. - * It reports status updates via the linked {@link EventService}. - * A {@link org.scijava.task.event.TaskEvent} is sent before the job - * is started and when finished. - * In the asynchronous case, upon task cancellation ({@link Task#cancel(String)} call), - * the runnable associated to the ThreadService is attempted to be stopped - * by calling {@link Future#cancel(boolean)}. - * This default behaviour can be supplemented by an additional - * custom callback which can be set in {@link Task#setCancelCallBack(Runnable)}. + * Asynchronous case: A job (runnable) is sent for execution to the linked + * {@link ThreadService}. It reports status updates via the linked + * {@link EventService}. A {@link org.scijava.task.event.TaskEvent} is sent + * before the job is started and when finished. In the asynchronous case, upon + * task cancellation ({@link Task#cancel(String)} call), the runnable associated + * to the ThreadService is attempted to be stopped by calling + * {@link Future#cancel(boolean)}. This default behaviour can be supplemented by + * an additional custom callback which can be set in + * {@link Task#setCancelCallBack(Runnable)}. *

    *

    - * Synchronous case: - * A job that reports its status in between calls of {@link Task#start()}, - * and {@link Task#finish()}. It also reports its status via - * the linked {@link EventService}. - * Start and finish calls allow publishing proper {@link org.scijava.task.event.TaskEvent} - * to subscribers (with the EventService). - * Upon cancellation of a synchronous task, it is the responsibility - * of the synchronous task to handle its own cancellation through - * a custom callback which can be set via {@link Task#setCancelCallBack(Runnable)}. + * Synchronous case: A job that reports its status in between calls of + * {@link Task#start()}, and {@link Task#finish()}. It also reports its status + * via the linked {@link EventService}. Start and finish calls allow publishing + * proper {@link org.scijava.task.event.TaskEvent} to subscribers (with the + * EventService). Upon cancellation of a synchronous task, it is the + * responsibility of the synchronous task to handle its own cancellation through + * a custom callback which can be set via + * {@link Task#setCancelCallBack(Runnable)}. *

    * * @author Curtis Rueden diff --git a/src/main/java/org/scijava/task/DefaultTaskService.java b/src/main/java/org/scijava/task/DefaultTaskService.java index 147fd0eec..9a5082039 100644 --- a/src/main/java/org/scijava/task/DefaultTaskService.java +++ b/src/main/java/org/scijava/task/DefaultTaskService.java @@ -6,13 +6,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 @@ -42,9 +42,7 @@ * @author Curtis Rueden */ @Plugin(type = Service.class) -public class DefaultTaskService extends AbstractService implements - TaskService -{ +public class DefaultTaskService extends AbstractService implements TaskService { @Parameter private ThreadService threadService; diff --git a/src/main/java/org/scijava/task/Task.java b/src/main/java/org/scijava/task/Task.java index 1e8004e53..7c82aa180 100644 --- a/src/main/java/org/scijava/task/Task.java +++ b/src/main/java/org/scijava/task/Task.java @@ -6,13 +6,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 @@ -35,27 +35,22 @@ import org.scijava.Named; /** - * A self-aware job which reports its status and progress as it runs. - * - * There are two ways to use a Task object: - * - A job can be run asynchronously by using {@link Task#run(Runnable)}, and - * can report its progression from within the Runnable. - * - * - A {@link Task} object can simply be used to report in a synchronous manner - * the progression of a piece of code. In the case of synchronous reporting, - * the job is considered started when {@link Task#start()} is called and - * finished when {@link Task#finish()} is called. A finished job can be finished - * either because it is done or because it has been cancelled. - * - * A cancel callback can be set with {@link Task#setCancelCallBack(Runnable)}. - * The runnable argument will be executed in the case of an external event - * requesting a cancellation of the task - typically, if a user clicks - * a cancel button on the GUI, task.cancel("User cancellation requested") will - * be called. As a result, the task implementors should run the callback. - * This callback can be used to make the task aware that a cancellation - * has been requested, and should proceed to stop its execution. - * - * See also {@link TaskService}, {@link DefaultTask} + * A self-aware job which reports its status and progress as it runs. There are + * two ways to use a Task object: - A job can be run asynchronously by using + * {@link Task#run(Runnable)}, and can report its progression from within the + * Runnable. - A {@link Task} object can simply be used to report in a + * synchronous manner the progression of a piece of code. In the case of + * synchronous reporting, the job is considered started when + * {@link Task#start()} is called and finished when {@link Task#finish()} is + * called. A finished job can be finished either because it is done or because + * it has been cancelled. A cancel callback can be set with + * {@link Task#setCancelCallBack(Runnable)}. The runnable argument will be + * executed in the case of an external event requesting a cancellation of the + * task - typically, if a user clicks a cancel button on the GUI, + * task.cancel("User cancellation requested") will be called. As a result, the + * task implementors should run the callback. This callback can be used to make + * the task aware that a cancellation has been requested, and should proceed to + * stop its execution. See also {@link TaskService}, {@link DefaultTask} * * @author Curtis Rueden, Nicolas Chiaruttini */ diff --git a/src/main/java/org/scijava/task/TaskService.java b/src/main/java/org/scijava/task/TaskService.java index dfe5c0ffd..1cb7b3cd4 100644 --- a/src/main/java/org/scijava/task/TaskService.java +++ b/src/main/java/org/scijava/task/TaskService.java @@ -6,13 +6,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 @@ -42,7 +42,7 @@ public interface TaskService extends SciJavaService { /** * Creates a new, empty {@link Task}. It is the responsibility of the caller * to then launch the task via the {@link Task#run(Runnable)} method. - * + * * @param name The task's name, to differentiate it from others. * @return A newly created task which awaits execution. */ diff --git a/src/main/java/org/scijava/task/event/TaskEvent.java b/src/main/java/org/scijava/task/event/TaskEvent.java index 83a5d662c..857145022 100644 --- a/src/main/java/org/scijava/task/event/TaskEvent.java +++ b/src/main/java/org/scijava/task/event/TaskEvent.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.task.event; import org.scijava.event.SciJavaEvent; @@ -33,7 +34,7 @@ /** * An event indicating a {@link Task} has been updated. - * + * * @author Curtis Rueden */ public class TaskEvent extends SciJavaEvent { diff --git a/src/main/java/org/scijava/test/TestUtils.java b/src/main/java/org/scijava/test/TestUtils.java index c375f6994..c8d64462c 100644 --- a/src/main/java/org/scijava/test/TestUtils.java +++ b/src/main/java/org/scijava/test/TestUtils.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ /** * A bunch of helpful functions for unit tests. - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -49,7 +49,7 @@ public class TestUtils { /** * Creates an empty file at the given path, creating intermediate directories * as necessary. - * + * * @param parent The parent directory of the relative path. * @param path The forward-slash-separated path to create. * @return a {@link File} pointing at the newly created empty path. @@ -60,7 +60,7 @@ public static File createPath(final File parent, final String path) { File file = parent; final String[] elements = path.split("/"); - for (int i=0; i - * + * * @param prefix the prefix for the directory's name * @return the reference to the newly-created temporary directory * @throws IOException */ - public static File createTemporaryDirectory(final String prefix) throws IOException { + public static File createTemporaryDirectory(final String prefix) + throws IOException + { final Map.Entry, String> calling = getCallingCodeLocation(null); - return createTemporaryDirectory(prefix, calling.getKey(), calling.getValue()); + return createTemporaryDirectory(prefix, calling.getKey(), calling + .getValue()); } /** @@ -92,7 +95,7 @@ public static File createTemporaryDirectory(final String prefix) throws IOExcept * created in the corresponding {@code target/} directory instead of * {@code /tmp/}. *

    - * + * * @param prefix the prefix for the directory's name * @param forClass the class for context (to determine whether there's a * {@code target/} directory) @@ -102,7 +105,8 @@ public static File createTemporaryDirectory(final String prefix) throws IOExcept public static File createTemporaryDirectory(final String prefix, final Class forClass) throws IOException { - return createTemporaryDirectory(prefix, forClass, "" + temporaryDirectoryCounter++); + return createTemporaryDirectory(prefix, forClass, "" + + temporaryDirectoryCounter++); } private static int temporaryDirectoryCounter = 1; @@ -114,7 +118,7 @@ public static File createTemporaryDirectory(final String prefix, * created in the corresponding {@code target/} directory instead of * {@code /tmp/}. *

    - * + * * @param prefix the prefix for the directory's name * @param forClass the class for context (to determine whether there's a * {@code target/} directory) @@ -133,11 +137,13 @@ public static File createTemporaryDirectory(final String prefix, throw new IllegalArgumentException("Invalid directory: " + directory); } final String path = directory.getPath(); - if (path == null) throw new IllegalArgumentException("Directory has null path"); + if (path == null) throw new IllegalArgumentException( + "Directory has null path"); final File baseDirectory; if (path.endsWith("/target/test-classes/")) { baseDirectory = new File(path).getParentFile(); - } else { + } + else { baseDirectory = new File(path); } @@ -153,7 +159,8 @@ public static File createTemporaryDirectory(final String prefix, else if (file.exists() && !file.delete()) { throw new IOException("Could not remove " + file); } - if (!file.mkdir()) throw new IOException("Could not make directory " + file); + if (!file.mkdir()) throw new IOException("Could not make directory " + + file); return file; } @@ -165,7 +172,7 @@ else if (file.exists() && !file.delete()) { * the location of the caller's class would end in * {@code target/test-classes/}). *

    - * + * * @param excluding the class to exclude (or null) * @return the class of the caller */ @@ -174,48 +181,56 @@ public static Class getCallingClass(final Class excluding) { } /** - * Returns the class and the method/line number of the caller (excluding the specified class). + * Returns the class and the method/line number of the caller (excluding the + * specified class). *

    * Sometimes it is convenient to determine the caller's context, e.g. to * determine whether running in a maven-surefire-plugin context (in which case * the location of the caller's class would end in * {@code target/test-classes/}). *

    - * + * * @param excluding the class to exclude (or null) * @return the class of the caller and the method and line number */ - public static Map.Entry, String> getCallingCodeLocation(final Class excluding) { + public static Map.Entry, String> getCallingCodeLocation( + final Class excluding) + { final String thisClassName = TestUtils.class.getName(); - final String thisClassName2 = excluding == null ? null : excluding.getName(); + final String thisClassName2 = excluding == null ? null : excluding + .getName(); final Thread currentThread = Thread.currentThread(); for (final StackTraceElement element : currentThread.getStackTrace()) { final String thatClassName = element.getClassName(); if (thatClassName == null || thatClassName.equals(thisClassName) || - thatClassName.equals(thisClassName2) || - thatClassName.endsWith("TestUtils") || - thatClassName.startsWith("java.lang.")) { + thatClassName.equals(thisClassName2) || thatClassName.endsWith( + "TestUtils") || thatClassName.startsWith("java.lang.")) + { continue; } final ClassLoader loader = currentThread.getContextClassLoader(); final Class clazz; try { clazz = loader.loadClass(element.getClassName()); - final URL url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class"); + final URL url = clazz.getResource("/" + clazz.getName().replace('.', + '/') + ".class"); if (url == null || !"file".equals(url.getProtocol())) { - // the calling code location must be unpacked; Maven artifacts in $HOME/.m2/ are excluded + // the calling code location must be unpacked; Maven artifacts in + // $HOME/.m2/ are excluded continue; } } catch (ClassNotFoundException e) { - throw new UnsupportedOperationException("Could not load " + - element.getClassName() + " with the current context class loader (" + + throw new UnsupportedOperationException("Could not load " + element + .getClassName() + " with the current context class loader (" + loader + ")!"); } - final String suffix = element.getMethodName() + "-L" + element.getLineNumber(); + final String suffix = element.getMethodName() + "-L" + element + .getLineNumber(); return new AbstractMap.SimpleEntry<>(clazz, suffix); } - throw new UnsupportedOperationException("No calling class outside " + thisClassName + " found!"); + throw new UnsupportedOperationException("No calling class outside " + + thisClassName + " found!"); } } diff --git a/src/main/java/org/scijava/text/AbstractTextFormat.java b/src/main/java/org/scijava/text/AbstractTextFormat.java index 766cb0874..9ded33ed1 100644 --- a/src/main/java/org/scijava/text/AbstractTextFormat.java +++ b/src/main/java/org/scijava/text/AbstractTextFormat.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * Abstract superclass of {@link TextFormat} implementations. - * + * * @author Curtis Rueden */ public abstract class AbstractTextFormat extends AbstractHandlerPlugin diff --git a/src/main/java/org/scijava/text/DefaultTextService.java b/src/main/java/org/scijava/text/DefaultTextService.java index 211fd25f2..4df5715d2 100644 --- a/src/main/java/org/scijava/text/DefaultTextService.java +++ b/src/main/java/org/scijava/text/DefaultTextService.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ /** * Default service for working with text formats. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) @@ -62,8 +62,8 @@ public String open(final File file) throws IOException { // This routine is from: https://stackoverflow.com/a/326440 try (final FileInputStream stream = new FileInputStream(file)) { final FileChannel fc = stream.getChannel(); - final MappedByteBuffer bb = - fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); + final MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc + .size()); return Charset.defaultCharset().decode(bb).toString(); } } diff --git a/src/main/java/org/scijava/text/TextFormat.java b/src/main/java/org/scijava/text/TextFormat.java index 2ef04da75..fc1c6abde 100644 --- a/src/main/java/org/scijava/text/TextFormat.java +++ b/src/main/java/org/scijava/text/TextFormat.java @@ -6,13 +6,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 @@ -46,7 +46,7 @@ * implementing this interface, it is encouraged to instead extend * {@link AbstractTextFormat}, for convenience. *

    - * + * * @author Curtis Rueden * @see Plugin * @see TextService diff --git a/src/main/java/org/scijava/text/TextService.java b/src/main/java/org/scijava/text/TextService.java index 5149b2a38..83740d62c 100644 --- a/src/main/java/org/scijava/text/TextService.java +++ b/src/main/java/org/scijava/text/TextService.java @@ -6,13 +6,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,7 +38,7 @@ /** * Interface for service that works with text formats. - * + * * @author Curtis Rueden */ public interface TextService extends HandlerService, diff --git a/src/main/java/org/scijava/text/io/DefaultTextIOService.java b/src/main/java/org/scijava/text/io/DefaultTextIOService.java index 21937f384..099d8225a 100644 --- a/src/main/java/org/scijava/text/io/DefaultTextIOService.java +++ b/src/main/java/org/scijava/text/io/DefaultTextIOService.java @@ -6,13 +6,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 @@ -39,5 +39,6 @@ * @author Deborah Schmidt */ @Plugin(type = Service.class) -public class DefaultTextIOService extends AbstractTypedIOService implements TextIOService { -} +public class DefaultTextIOService extends AbstractTypedIOService + implements TextIOService +{} diff --git a/src/main/java/org/scijava/text/io/TextIOPlugin.java b/src/main/java/org/scijava/text/io/TextIOPlugin.java index 3e3d20efd..37430265f 100644 --- a/src/main/java/org/scijava/text/io/TextIOPlugin.java +++ b/src/main/java/org/scijava/text/io/TextIOPlugin.java @@ -6,13 +6,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 @@ -42,7 +42,7 @@ /** * {@link IOPlugin} for text conversion to HTML. - * + * * @author Curtis Rueden * @see TextService */ diff --git a/src/main/java/org/scijava/text/io/TextIOService.java b/src/main/java/org/scijava/text/io/TextIOService.java index ed48ab424..08b64281a 100644 --- a/src/main/java/org/scijava/text/io/TextIOService.java +++ b/src/main/java/org/scijava/text/io/TextIOService.java @@ -6,13 +6,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 @@ -36,5 +36,4 @@ * * @author Deborah Schmidt */ -public interface TextIOService extends TypedIOService { -} +public interface TextIOService extends TypedIOService {} diff --git a/src/main/java/org/scijava/thread/DefaultThreadService.java b/src/main/java/org/scijava/thread/DefaultThreadService.java index f34c38a6a..0dd0ce359 100644 --- a/src/main/java/org/scijava/thread/DefaultThreadService.java +++ b/src/main/java/org/scijava/thread/DefaultThreadService.java @@ -6,13 +6,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 @@ -49,7 +49,7 @@ /** * Default service for managing active threads. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) @@ -61,8 +61,7 @@ public final class DefaultThreadService extends AbstractService implements private static final long SHUTDOWN_TIMEOUT = 5000; - private static WeakHashMap parents = - new WeakHashMap<>(); + private static WeakHashMap parents = new WeakHashMap<>(); @Parameter private LogService log; diff --git a/src/main/java/org/scijava/thread/ThreadService.java b/src/main/java/org/scijava/thread/ThreadService.java index b809a9a4b..04728411e 100644 --- a/src/main/java/org/scijava/thread/ThreadService.java +++ b/src/main/java/org/scijava/thread/ThreadService.java @@ -6,13 +6,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 @@ -46,23 +46,23 @@ public interface ThreadService extends SciJavaService, ThreadFactory { public enum ThreadContext { - /** - * The thread was spawned by this thread service; i.e., it belongs to the - * same {@link Context}. - */ - SAME, - - /** - * The thread was spawned by a SciJava thread service, but not this one; - * i.e., it belongs to a different {@link Context}. - */ - OTHER, - - /** - * The thread was not spawned via a SciJava thread service, and its - * {@link Context} is unknown or inapplicable. - */ - NONE + /** + * The thread was spawned by this thread service; i.e., it belongs to the + * same {@link Context}. + */ + SAME, + + /** + * The thread was spawned by a SciJava thread service, but not this one; + * i.e., it belongs to a different {@link Context}. + */ + OTHER, + + /** + * The thread was not spawned via a SciJava thread service, and its + * {@link Context} is unknown or inapplicable. + */ + NONE } /** @@ -92,7 +92,7 @@ public enum ThreadContext { /** * Gets the {@link ExecutorService} object used when {@link #run} is called. - * + * * @return the {@link ExecutorService}, or null if an {@link ExecutorService} * is not used in this {@link ThreadService} implementation. */ @@ -100,7 +100,7 @@ public enum ThreadContext { /** * Sets the {@link ExecutorService} object used when {@link #run} is called. - * + * * @param executor The {@link ExecutorService} for this {@link ThreadService} * to use internally for {@link #run} calls. * @throws UnsupportedOperationException if this {@link ThreadService} does diff --git a/src/main/java/org/scijava/tool/AbstractTool.java b/src/main/java/org/scijava/tool/AbstractTool.java index e83ada645..d97198d65 100644 --- a/src/main/java/org/scijava/tool/AbstractTool.java +++ b/src/main/java/org/scijava/tool/AbstractTool.java @@ -6,13 +6,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,7 +33,7 @@ /** * Abstract base class for {@link Tool} implementations. - * + * * @author Curtis Rueden * @author Grant Harris */ diff --git a/src/main/java/org/scijava/tool/CustomDrawnTool.java b/src/main/java/org/scijava/tool/CustomDrawnTool.java index 4222b14b0..5fc4903f6 100644 --- a/src/main/java/org/scijava/tool/CustomDrawnTool.java +++ b/src/main/java/org/scijava/tool/CustomDrawnTool.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Tools that would like to define how they are drawn implement this interface. - * + * * @author Barry DeZonia */ public interface CustomDrawnTool { diff --git a/src/main/java/org/scijava/tool/DefaultToolService.java b/src/main/java/org/scijava/tool/DefaultToolService.java index d7d653399..5dba4d521 100644 --- a/src/main/java/org/scijava/tool/DefaultToolService.java +++ b/src/main/java/org/scijava/tool/DefaultToolService.java @@ -6,13 +6,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 @@ -57,7 +57,7 @@ /** * Default service for keeping track of available tools, including which tool is * active, and delegating UI events to the active tool. - * + * * @author Grant Harris * @author Curtis Rueden * @see Tool diff --git a/src/main/java/org/scijava/tool/DummyTool.java b/src/main/java/org/scijava/tool/DummyTool.java index c2e858e00..287c035ac 100644 --- a/src/main/java/org/scijava/tool/DummyTool.java +++ b/src/main/java/org/scijava/tool/DummyTool.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * A tool that does nothing. - * + * * @author Curtis Rueden */ public class DummyTool extends AbstractTool { diff --git a/src/main/java/org/scijava/tool/IconDrawer.java b/src/main/java/org/scijava/tool/IconDrawer.java index ff4b83a40..82dce32c5 100644 --- a/src/main/java/org/scijava/tool/IconDrawer.java +++ b/src/main/java/org/scijava/tool/IconDrawer.java @@ -6,13 +6,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 @@ -34,11 +34,14 @@ /** * {@link CustomDrawnTool}s use {@link IconDrawer}s to draw their icon on * screen. - * + * * @author Barry DeZonia */ public interface IconDrawer { + int getIconRectangleWidth(); + int getIconRectangleHeight(); + void setIconPixel(int x, int y, ColorRGB pixel); } diff --git a/src/main/java/org/scijava/tool/IconService.java b/src/main/java/org/scijava/tool/IconService.java index 02be9b223..c68ad7128 100644 --- a/src/main/java/org/scijava/tool/IconService.java +++ b/src/main/java/org/scijava/tool/IconService.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * {@link IconService} allows a {@link Tool} to obtain the {@link IconDrawer}. * Using this it can render its custom icon if desired. - * + * * @author Barry DeZonia */ public interface IconService extends SciJavaService { diff --git a/src/main/java/org/scijava/tool/Tool.java b/src/main/java/org/scijava/tool/Tool.java index c2a0d00f0..a1f6e2338 100644 --- a/src/main/java/org/scijava/tool/Tool.java +++ b/src/main/java/org/scijava/tool/Tool.java @@ -6,13 +6,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 @@ -57,7 +57,7 @@ * it possible to create a tool merely by implementing this interface, it is * encouraged to instead extend {@link AbstractTool}, for convenience. *

    - * + * * @author Rick Lentz * @author Grant Harris * @author Curtis Rueden diff --git a/src/main/java/org/scijava/tool/ToolService.java b/src/main/java/org/scijava/tool/ToolService.java index 020a3e891..74261405a 100644 --- a/src/main/java/org/scijava/tool/ToolService.java +++ b/src/main/java/org/scijava/tool/ToolService.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * Interface for service that tracks available tools. - * + * * @author Grant Harris * @author Curtis Rueden */ @@ -49,7 +49,7 @@ public interface ToolService extends SingletonService, SciJavaService { /** * Get a tool given its class. - * + * * @param the tool's type * @param toolClass the class of the tool to fetch * @return the tool, or null if no such tool diff --git a/src/main/java/org/scijava/tool/event/ToolActivatedEvent.java b/src/main/java/org/scijava/tool/event/ToolActivatedEvent.java index 6df9190ef..3b4a9e1fa 100644 --- a/src/main/java/org/scijava/tool/event/ToolActivatedEvent.java +++ b/src/main/java/org/scijava/tool/event/ToolActivatedEvent.java @@ -6,13 +6,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,7 +33,7 @@ /** * An event indicating a tool has been activated. - * + * * @author Curtis Rueden */ public class ToolActivatedEvent extends ToolEvent { diff --git a/src/main/java/org/scijava/tool/event/ToolDeactivatedEvent.java b/src/main/java/org/scijava/tool/event/ToolDeactivatedEvent.java index 78569c9ea..68a8b38d8 100644 --- a/src/main/java/org/scijava/tool/event/ToolDeactivatedEvent.java +++ b/src/main/java/org/scijava/tool/event/ToolDeactivatedEvent.java @@ -6,13 +6,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,7 +33,7 @@ /** * An event indicating a tool has been deactivated. - * + * * @author Curtis Rueden */ public class ToolDeactivatedEvent extends ToolEvent { diff --git a/src/main/java/org/scijava/tool/event/ToolEvent.java b/src/main/java/org/scijava/tool/event/ToolEvent.java index 85aed4d60..e2ea041f9 100644 --- a/src/main/java/org/scijava/tool/event/ToolEvent.java +++ b/src/main/java/org/scijava/tool/event/ToolEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An event indicating something has happened to a tool. - * + * * @author Curtis Rueden */ public abstract class ToolEvent extends SciJavaEvent { diff --git a/src/main/java/org/scijava/ui/ARGBPlane.java b/src/main/java/org/scijava/ui/ARGBPlane.java index ff21f7bd7..1d0b70b9b 100644 --- a/src/main/java/org/scijava/ui/ARGBPlane.java +++ b/src/main/java/org/scijava/ui/ARGBPlane.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * Represents a plane of ARGB pixel data. Useful for passing around data during * copy/paste operations to external programs. - * + * * @author Barry DeZonia */ public class ARGBPlane { diff --git a/src/main/java/org/scijava/ui/AbstractInputHarvesterPlugin.java b/src/main/java/org/scijava/ui/AbstractInputHarvesterPlugin.java index a31e09d59..69788231b 100644 --- a/src/main/java/org/scijava/ui/AbstractInputHarvesterPlugin.java +++ b/src/main/java/org/scijava/ui/AbstractInputHarvesterPlugin.java @@ -6,13 +6,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 @@ -45,7 +45,7 @@ * its implementation; for example, the Swing-based input harvester plugin will * only harvest inputs if the Swing UI is currently the default one. *

    - * + * * @author Curtis Rueden * @author Barry DeZonia * @param

    The type of UI component housing the input panel itself. diff --git a/src/main/java/org/scijava/ui/AbstractUIInputWidget.java b/src/main/java/org/scijava/ui/AbstractUIInputWidget.java index 32d324ef1..46b944529 100644 --- a/src/main/java/org/scijava/ui/AbstractUIInputWidget.java +++ b/src/main/java/org/scijava/ui/AbstractUIInputWidget.java @@ -6,13 +6,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,24 +38,24 @@ import org.scijava.widget.InputWidget; /** - * Abstract superclass of {@link InputWidget} implementations that - * belong to a specific UI. + * Abstract superclass of {@link InputWidget} implementations that belong to a + * specific UI. *

    - * {@link #refreshWidget()} implementation determines if this widget - * needs to be refreshed on the EDT, and invokes it as needed if so. + * {@link #refreshWidget()} implementation determines if this widget needs to be + * refreshed on the EDT, and invokes it as needed if so. *

    *

    - * Subclasses should implement {@link #doRefresh()} as they would - * have {@link #refreshWidget()}. A common abstract superclass - * for each UserInterface type should be sufficient for - * {@link #ui()}, which can delegate to {@link #ui(String)} with - * the appropriate UI name. + * Subclasses should implement {@link #doRefresh()} as they would have + * {@link #refreshWidget()}. A common abstract superclass for each UserInterface + * type should be sufficient for {@link #ui()}, which can delegate to + * {@link #ui(String)} with the appropriate UI name. *

    - * + * * @author Mark Hiner - * */ -public abstract class AbstractUIInputWidget extends AbstractInputWidget { +public abstract class AbstractUIInputWidget extends + AbstractInputWidget +{ // -- Fields -- @@ -69,12 +69,12 @@ public abstract class AbstractUIInputWidget extends AbstractInputWidget doRefresh()); @@ -92,23 +92,23 @@ public void refreshWidget() { } // -- AbstractUIInputWidget methods -- - + /** * Performs the intended {@link #refreshWidget()} operation. */ protected abstract void doRefresh(); - + /** - * @return The {@link UserInterface} instance associated - * with this InputWidget. + * @return The {@link UserInterface} instance associated with this + * InputWidget. */ protected abstract UserInterface ui(); - + /** * @return the UserInterface matching the provided String */ protected UserInterface ui(String uiName) { - + return uiService.getUI(uiName); } -} +} diff --git a/src/main/java/org/scijava/ui/AbstractUserInterface.java b/src/main/java/org/scijava/ui/AbstractUserInterface.java index d1b91e527..4dd558a9a 100644 --- a/src/main/java/org/scijava/ui/AbstractUserInterface.java +++ b/src/main/java/org/scijava/ui/AbstractUserInterface.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ /** * Abstract superclass for {@link UserInterface} implementations. - * + * * @author Curtis Rueden */ public abstract class AbstractUserInterface extends AbstractRichPlugin @@ -112,8 +112,8 @@ public void show(final Display display) { return; } - final List>> viewers = - uiService.getViewerPlugins(); + final List>> viewers = uiService + .getViewerPlugins(); DisplayViewer displayViewer = null; for (final PluginInfo> info : viewers) { @@ -133,6 +133,7 @@ public void show(final Display display) { final DisplayViewer finalViewer = displayViewer; threadService.queue(new Runnable() { + @Override public void run() { uiService.addDisplayViewer(finalViewer); diff --git a/src/main/java/org/scijava/ui/ApplicationFrame.java b/src/main/java/org/scijava/ui/ApplicationFrame.java index 57fc6083f..5dd3ef8a8 100644 --- a/src/main/java/org/scijava/ui/ApplicationFrame.java +++ b/src/main/java/org/scijava/ui/ApplicationFrame.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Common interface for top-level application frames. - * + * * @author Grant Harris * @author Curtis Rueden */ diff --git a/src/main/java/org/scijava/ui/Arrangeable.java b/src/main/java/org/scijava/ui/Arrangeable.java index 2385868c5..91863db9c 100644 --- a/src/main/java/org/scijava/ui/Arrangeable.java +++ b/src/main/java/org/scijava/ui/Arrangeable.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ * Copyright (c) 1996-2010 by the original authors of JHotDraw and all its * contributors. All rights reserved. * - * You may not use, copy or modify this file, except in compliance with the + * You may not use, copy or modify this file, except in compliance with the * license agreement you entered into with the copyright holders. For details * see accompanying license terms. */ @@ -52,13 +52,13 @@ /** * Arrangeable. - * + * * @author Werner Randelshofer */ public interface Arrangeable { enum Arrangement { - VERTICAL, HORIZONTAL, CASCADE + VERTICAL, HORIZONTAL, CASCADE } public void setArrangement(Arrangement newValue); diff --git a/src/main/java/org/scijava/ui/CloseConfirmable.java b/src/main/java/org/scijava/ui/CloseConfirmable.java index 331f50861..b95965104 100644 --- a/src/main/java/org/scijava/ui/CloseConfirmable.java +++ b/src/main/java/org/scijava/ui/CloseConfirmable.java @@ -6,13 +6,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/ui/DefaultUIService.java b/src/main/java/org/scijava/ui/DefaultUIService.java index 5d4d7299d..4f6f658d1 100644 --- a/src/main/java/org/scijava/ui/DefaultUIService.java +++ b/src/main/java/org/scijava/ui/DefaultUIService.java @@ -6,13 +6,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 @@ -68,7 +68,7 @@ /** * Default service for handling SciJava user interfaces. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) @@ -123,8 +123,9 @@ public final class DefaultUIService extends AbstractService implements /** * When true, {@link #isHeadless()} will return true regardless of the value - * of the {@code java.awt.headless} system property. When false, {@link - * #isHeadless()} matches the global JVM headless state defined by {@code + * of the {@code java.awt.headless} system property. When false, + * {@link #isHeadless()} matches the global JVM headless state defined by + * {@code * java.awt.headless}. */ private boolean forceHeadless; @@ -203,8 +204,7 @@ public void setHeadless(final boolean headless) { @Override public boolean isHeadless() { - return forceHeadless || - Boolean.getBoolean("java.awt.headless") || + return forceHeadless || Boolean.getBoolean("java.awt.headless") || GraphicsEnvironment.isHeadless(); } @@ -248,8 +248,8 @@ public List getVisibleUIs() { @Override public List>> getViewerPlugins() { @SuppressWarnings({ "rawtypes", "unchecked" }) - final List>> viewers = - (List) pluginService.getPluginsOfType(DisplayViewer.class); + final List>> viewers = (List) pluginService + .getPluginsOfType(DisplayViewer.class); return viewers; } @@ -287,7 +287,8 @@ public DialogPrompt.Result showDialog(final String message) { } @Override - public Result showDialog(final String message, final MessageType messageType) + public Result showDialog(final String message, + final MessageType messageType) { return showDialog(message, getTitle(), messageType); } @@ -300,8 +301,8 @@ public Result showDialog(final String message, final MessageType messageType, } @Override - public DialogPrompt.Result - showDialog(final String message, final String title) + public DialogPrompt.Result showDialog(final String message, + final String title) { return showDialog(message, title, DialogPrompt.MessageType.INFORMATION_MESSAGE); @@ -331,19 +332,23 @@ public File chooseFile(final File file, final String style) { } @Override - public File - chooseFile(final String title, final File file, final String style) + public File chooseFile(final String title, final File file, + final String style) { return activeUI().chooseFile(title, file, style); } @Override - public File[] chooseFiles(File parent, File[] files, FileFilter filter, String style) { + public File[] chooseFiles(File parent, File[] files, FileFilter filter, + String style) + { return activeUI().chooseFiles(parent, files, filter, style); } - + @Override - public List chooseFiles(File parent, List fileList, FileFilter filter, String style) { + public List chooseFiles(File parent, List fileList, + FileFilter filter, String style) + { return activeUI().chooseFiles(parent, fileList, filter, style); } @@ -439,8 +444,8 @@ protected void onEvent(final DisplayActivatedEvent e) { public void run() { final Display activeDisplay = displayService.getActiveDisplay(); if (activeDisplay != null) { - final DisplayViewer displayViewer = - getDisplayViewer(activeDisplay); + final DisplayViewer displayViewer = getDisplayViewer( + activeDisplay); if (displayViewer != null) displayViewer.onDisplayActivatedEvent(e); } activationInvocationPending = false; @@ -512,8 +517,8 @@ private synchronized void discoverUIs() { uiList = new ArrayList<>(); uiMap = new HashMap<>(); - final List> infos = - pluginService.getPluginsOfType(UserInterface.class); + final List> infos = pluginService + .getPluginsOfType(UserInterface.class); for (final PluginInfo info : infos) { // instantiate user interface final UserInterface ui = pluginService.createInstance(info); diff --git a/src/main/java/org/scijava/ui/Desktop.java b/src/main/java/org/scijava/ui/Desktop.java index 11aa766f4..e5150f712 100644 --- a/src/main/java/org/scijava/ui/Desktop.java +++ b/src/main/java/org/scijava/ui/Desktop.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Marker interface for MDI Desktop manager - * + * * @author Grant Harris */ public interface Desktop extends Arrangeable { diff --git a/src/main/java/org/scijava/ui/DialogPrompt.java b/src/main/java/org/scijava/ui/DialogPrompt.java index fc59a3c05..f4a193774 100644 --- a/src/main/java/org/scijava/ui/DialogPrompt.java +++ b/src/main/java/org/scijava/ui/DialogPrompt.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * TODO - * + * * @author Grant Harris */ public interface DialogPrompt { @@ -39,16 +39,16 @@ public interface DialogPrompt { Result prompt(); enum MessageType { - ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, + ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, PLAIN_MESSAGE } enum OptionType { - DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION, OK_CANCEL_OPTION + DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION, OK_CANCEL_OPTION } enum Result { - YES_OPTION, NO_OPTION, CANCEL_OPTION, OK_OPTION, CLOSED_OPTION + YES_OPTION, NO_OPTION, CANCEL_OPTION, OK_OPTION, CLOSED_OPTION } } diff --git a/src/main/java/org/scijava/ui/FileListPreprocessor.java b/src/main/java/org/scijava/ui/FileListPreprocessor.java index c18810629..a10f4def4 100644 --- a/src/main/java/org/scijava/ui/FileListPreprocessor.java +++ b/src/main/java/org/scijava/ui/FileListPreprocessor.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.ui; import java.io.File; @@ -38,7 +39,8 @@ import org.scijava.plugin.Plugin; import org.scijava.widget.InputHarvester; -@Plugin(type = PreprocessorPlugin.class, priority = InputHarvester.PRIORITY + 1.0) +@Plugin(type = PreprocessorPlugin.class, priority = InputHarvester.PRIORITY + + 1.0) public class FileListPreprocessor extends AbstractPreprocessorPlugin { @Parameter(required = false) @@ -55,7 +57,8 @@ public void process(final Module module) { // show file chooser dialog box // TODO decide how to create filter from style attributes // TODO retrieve parent folder?? - final File[] result = uiService.chooseFiles(null, files, null, fileInput.getWidgetStyle()); + final File[] result = uiService.chooseFiles(null, files, null, fileInput + .getWidgetStyle()); if (result == null) { cancel(""); return; diff --git a/src/main/java/org/scijava/ui/FilePreprocessor.java b/src/main/java/org/scijava/ui/FilePreprocessor.java index 909e84c06..4159d4d42 100644 --- a/src/main/java/org/scijava/ui/FilePreprocessor.java +++ b/src/main/java/org/scijava/ui/FilePreprocessor.java @@ -6,13 +6,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 @@ -42,12 +42,12 @@ /** * A preprocessor plugin that handles single unresolved parameters of type * {@link File} using a UI prompt. - * + * * @author Curtis Rueden * @see UserInterface#chooseFile(File, String) */ -@Plugin(type = PreprocessorPlugin.class, - priority = InputHarvester.PRIORITY + 0.5) +@Plugin(type = PreprocessorPlugin.class, priority = InputHarvester.PRIORITY + + 0.5) public class FilePreprocessor extends AbstractPreprocessorPlugin { @Parameter(required = false) diff --git a/src/main/java/org/scijava/ui/StatusBar.java b/src/main/java/org/scijava/ui/StatusBar.java index 19ad8acb8..4cab894f2 100644 --- a/src/main/java/org/scijava/ui/StatusBar.java +++ b/src/main/java/org/scijava/ui/StatusBar.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * Common interface for status bars, which have a text area and progress bar, * similar to ImageJ 1.x. - * + * * @author Curtis Rueden */ public interface StatusBar { diff --git a/src/main/java/org/scijava/ui/SystemClipboard.java b/src/main/java/org/scijava/ui/SystemClipboard.java index d897285e7..b6beba770 100644 --- a/src/main/java/org/scijava/ui/SystemClipboard.java +++ b/src/main/java/org/scijava/ui/SystemClipboard.java @@ -6,13 +6,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 @@ -29,15 +29,13 @@ package org.scijava.ui; - /** * UI agnostic representation of the system clipboard. - * - * @author Barry DeZonia * + * @author Barry DeZonia */ public interface SystemClipboard { - + /** method that accepts a plane of ARGB data */ void pixelsToSystemClipboard(ARGBPlane plane); } diff --git a/src/main/java/org/scijava/ui/ToolBar.java b/src/main/java/org/scijava/ui/ToolBar.java index b14ceb0fa..1f2395a65 100644 --- a/src/main/java/org/scijava/ui/ToolBar.java +++ b/src/main/java/org/scijava/ui/ToolBar.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * Common interface for tool bars, which are button bars with selectable tools, * similar to ImageJ 1.x. - * + * * @author Curtis Rueden */ public interface ToolBar { diff --git a/src/main/java/org/scijava/ui/UIPreprocessor.java b/src/main/java/org/scijava/ui/UIPreprocessor.java index 36fd91147..155477178 100644 --- a/src/main/java/org/scijava/ui/UIPreprocessor.java +++ b/src/main/java/org/scijava/ui/UIPreprocessor.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ /** * The UI preprocessor automatically populates module {@link UserInterface} * inputs with the {@link UIService}'s default UI instance, if compatible. - * + * * @author Curtis Rueden */ @Plugin(type = PreprocessorPlugin.class, priority = Priority.VERY_HIGH) @@ -60,7 +60,8 @@ public void process(final Module module) { for (final ModuleItem input : module.getInfo().inputs()) { if (!input.isAutoFill()) continue; // skip unfillable inputs - if (module.isInputResolved(input.getName())) continue; // skip resolved inputs + if (module.isInputResolved(input.getName())) continue; // skip resolved + // inputs final Class type = input.getType(); if (UserInterface.class.isAssignableFrom(type) && // type.isAssignableFrom(ui.getClass())) diff --git a/src/main/java/org/scijava/ui/UIService.java b/src/main/java/org/scijava/ui/UIService.java index 84f4b23ef..03cb71be9 100644 --- a/src/main/java/org/scijava/ui/UIService.java +++ b/src/main/java/org/scijava/ui/UIService.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ /** * Interface for service that handles user interfaces. - * + * * @author Curtis Rueden */ public interface UIService extends SciJavaService { @@ -59,7 +59,7 @@ public interface UIService extends SciJavaService { * Note that a UI added explicitly via this method will never be considered * the default UI unless {@link #setDefaultUI(UserInterface)} is also called. *

    - * + * * @param ui The UI to add. */ void addUI(UserInterface ui); @@ -70,7 +70,7 @@ public interface UIService extends SciJavaService { * Note that a UI added explicitly via this method will never be considered * the default UI unless {@link #setDefaultUI(UserInterface)} is also called. *

    - * + * * @param name The nickname for the UI. * @param ui The UI to add. */ @@ -78,7 +78,7 @@ public interface UIService extends SciJavaService { /** * Displays the UI for the default user interface. - * + * * @see #getDefaultUI() * @see #setDefaultUI(UserInterface) */ @@ -92,7 +92,7 @@ public interface UIService extends SciJavaService { /** * Gets whether the default UI is visible. - * + * * @see #getDefaultUI() * @see #setDefaultUI(UserInterface) */ @@ -122,9 +122,9 @@ public interface UIService extends SciJavaService { /** * Gets whether the UI is running in headless mode (no UI). *

    - * More precisely: returns true when {@code java.awt.headless} system - * property is set, and/or {@link java.awt.GraphicsEnvironment#isHeadless()} - * returns true, and/or {@link #setHeadless(boolean)} was called with {@code + * More precisely: returns true when {@code java.awt.headless} system property + * is set, and/or {@link java.awt.GraphicsEnvironment#isHeadless()} returns + * true, and/or {@link #setHeadless(boolean)} was called with {@code * true} to force headless behavior in an otherwise headful environment. *

    */ @@ -132,7 +132,7 @@ public interface UIService extends SciJavaService { /** * Gets the default user interface. - * + * * @see #showUI() * @see #isVisible() */ @@ -140,7 +140,7 @@ public interface UIService extends SciJavaService { /** * Sets the default user interface. - * + * * @see #showUI() */ void setDefaultUI(UserInterface ui); @@ -177,7 +177,7 @@ public interface UIService extends SciJavaService { /** * Creates a {@link Display} for the given object, and shows it using an * appropriate UI widget of the default user interface. - * + * * @param name The name to use when displaying the object. * @param o The object to be displayed. */ @@ -194,7 +194,7 @@ public interface UIService extends SciJavaService { *

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

    - * + * * @param message The message in the dialog itself. * @return The choice selected by the user when dismissing the dialog. */ @@ -205,7 +205,7 @@ public interface UIService extends SciJavaService { *

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

    - * + * * @param message The message in the dialog itself. * @param messageType The type of message. This typically is rendered as an * icon next to the message. For example, @@ -221,7 +221,7 @@ DialogPrompt.Result showDialog(String message, *

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

    - * + * * @param message The message in the dialog itself. * @param messageType The type of message. This typically is rendered as an * icon next to the message. For example, @@ -239,7 +239,7 @@ DialogPrompt.Result showDialog(String message, *

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

    - * + * * @param message The message in the dialog itself. * @param title The title of the dialog. * @return The choice selected by the user when dismissing the dialog. @@ -251,7 +251,7 @@ DialogPrompt.Result showDialog(String message, *

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

    - * + * * @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 @@ -268,7 +268,7 @@ DialogPrompt.Result showDialog(String message, String title, *

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

    - * + * * @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 @@ -287,7 +287,7 @@ DialogPrompt.Result showDialog(String message, String title, *

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

    - * + * * @param file The initial value displayed in the file chooser prompt. * @param style The style of chooser to use: *
      @@ -303,7 +303,7 @@ DialogPrompt.Result showDialog(String message, String title, *

      * 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: @@ -320,22 +320,24 @@ DialogPrompt.Result showDialog(String message, String title, *

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

      - * + * * @param files The initial value displayed in the file chooser prompt. * @param filter A filter allowing to restrict the choice of files */ - File[] chooseFiles(File parent, File[] files, FileFilter filter, String style); + File[] chooseFiles(File parent, File[] files, FileFilter filter, + String style); /** * Prompts the user to select one or multiple files. *

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

      - * + * * @param fileList The initial value displayed in the file chooser prompt. * @param filter A filter allowing to restrict the choice of files */ - List chooseFiles(File parent, List fileList, FileFilter filter, String style); + List chooseFiles(File parent, List fileList, FileFilter filter, + String style); /** * Displays a popup context menu for the given display at the specified @@ -348,7 +350,7 @@ DialogPrompt.Result showDialog(String message, String title, /** * Gets the status message associated with the given event. - * + * * @see StatusService#getStatusMessage(String, StatusEvent) */ String getStatusMessage(StatusEvent statusEvent); diff --git a/src/main/java/org/scijava/ui/UserInterface.java b/src/main/java/org/scijava/ui/UserInterface.java index 5133008eb..efbe7f25d 100644 --- a/src/main/java/org/scijava/ui/UserInterface.java +++ b/src/main/java/org/scijava/ui/UserInterface.java @@ -6,13 +6,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 @@ -162,8 +162,10 @@ default File chooseFile(final File file, final String style) { final String title; // style can be a string with multiple comma-separated keywords if (style == null) title = "Choose a file"; - else if (WidgetStyle.isStyle(style, FileWidget.DIRECTORY_STYLE)) title = "Choose a directory"; - else if (WidgetStyle.isStyle(style, FileWidget.FILE_AND_DIRECTORY_STYLE)) title = "Choose a file or directory"; + else if (WidgetStyle.isStyle(style, FileWidget.DIRECTORY_STYLE)) title = + "Choose a directory"; + else if (WidgetStyle.isStyle(style, FileWidget.FILE_AND_DIRECTORY_STYLE)) + title = "Choose a file or directory"; else if (WidgetStyle.isStyle(style, FileWidget.OPEN_STYLE)) title = "Open"; else if (WidgetStyle.isStyle(style, FileWidget.SAVE_STYLE)) title = "Save"; else title = "Choose a file"; @@ -196,11 +198,14 @@ default File chooseFile(String title, File file, String style) { * @param parent Parent folder for file selection * @param files The initial value displayed in the file chooser prompt. * @param filter A filter allowing to restrict file choice. - * @param style File selection style (files, directories, or both) and optional filters - * @return The selected {@link File}s chosen by the user, or null if the - * user cancels the prompt. + * @param style File selection style (files, directories, or both) and + * optional filters + * @return The selected {@link File}s chosen by the user, or null if the user + * cancels the prompt. */ - default File[] chooseFiles(File parent, File[] files, FileFilter filter, String style) { + default File[] chooseFiles(File parent, File[] files, FileFilter filter, + String style) + { throw new UnsupportedOperationException(); } @@ -210,11 +215,14 @@ default File[] chooseFiles(File parent, File[] files, FileFilter filter, String * @param parent Parent folder for file selection * @param fileList The initial value displayed in the file chooser prompt. * @param filter A filter allowing to restrict file choice. - * @param style File selection style (files, directories, or both) and optional filters - * @return The selected {@link File}s chosen by the user, or null if the - * user cancels the prompt. + * @param style File selection style (files, directories, or both) and + * optional filters + * @return The selected {@link File}s chosen by the user, or null if the user + * cancels the prompt. */ - default List chooseFiles(File parent, List fileList, FileFilter filter, String style) { + default List chooseFiles(File parent, List fileList, + FileFilter filter, String style) + { final File[] initialFiles = fileList.toArray(new File[fileList.size()]); final File[] chosenFiles = chooseFiles(parent, initialFiles, filter, style); return chosenFiles == null ? null : Arrays.asList(chosenFiles); diff --git a/src/main/java/org/scijava/ui/console/AbstractConsolePane.java b/src/main/java/org/scijava/ui/console/AbstractConsolePane.java index abe9177e7..685dd64ea 100644 --- a/src/main/java/org/scijava/ui/console/AbstractConsolePane.java +++ b/src/main/java/org/scijava/ui/console/AbstractConsolePane.java @@ -6,13 +6,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/ui/console/ConsolePane.java b/src/main/java/org/scijava/ui/console/ConsolePane.java index c2214bd61..f62c978d8 100644 --- a/src/main/java/org/scijava/ui/console/ConsolePane.java +++ b/src/main/java/org/scijava/ui/console/ConsolePane.java @@ -6,13 +6,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/ui/console/HeadlessArgument.java b/src/main/java/org/scijava/ui/console/HeadlessArgument.java index ab4eea39e..b8cbdea45 100644 --- a/src/main/java/org/scijava/ui/console/HeadlessArgument.java +++ b/src/main/java/org/scijava/ui/console/HeadlessArgument.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.ui.console; import java.util.LinkedList; diff --git a/src/main/java/org/scijava/ui/console/ShowUIArgument.java b/src/main/java/org/scijava/ui/console/ShowUIArgument.java index b07e618e9..52e09a52e 100644 --- a/src/main/java/org/scijava/ui/console/ShowUIArgument.java +++ b/src/main/java/org/scijava/ui/console/ShowUIArgument.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.ui.console; import java.util.LinkedList; diff --git a/src/main/java/org/scijava/ui/console/UIArgument.java b/src/main/java/org/scijava/ui/console/UIArgument.java index 1622d1e0d..f07c5991a 100644 --- a/src/main/java/org/scijava/ui/console/UIArgument.java +++ b/src/main/java/org/scijava/ui/console/UIArgument.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ *

      * This argument overrides the default user interface. *

      - * + * * @author Curtis Rueden */ @Plugin(type = ConsoleArgument.class) @@ -71,13 +71,13 @@ public void handle(final LinkedList args) { args.removeFirst(); // --ui final String uiName = args.removeFirst(); - final UserInterface ui = uiService.getUI(uiName); - if (ui == null) { - log.error("No such UI: " + uiName); - } - else { - uiService.setDefaultUI(ui); - } + final UserInterface ui = uiService.getUI(uiName); + if (ui == null) { + log.error("No such UI: " + uiName); + } + else { + uiService.setDefaultUI(ui); + } } } diff --git a/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropData.java b/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropData.java index fe0b3da6a..18f98d80a 100644 --- a/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropData.java +++ b/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropData.java @@ -6,13 +6,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,7 +33,7 @@ /** * Abstract superclass for {@link DragAndDropData} implementations. - * + * * @author Curtis Rueden */ public abstract class AbstractDragAndDropData extends AbstractContextual diff --git a/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropHandler.java b/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropHandler.java index cb25e57ce..adc6d5cd5 100644 --- a/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropHandler.java +++ b/src/main/java/org/scijava/ui/dnd/AbstractDragAndDropHandler.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Abstract superclass for {@link DragAndDropHandler}s. - * + * * @author Curtis Rueden */ public abstract class AbstractDragAndDropHandler extends @@ -93,7 +93,8 @@ public D convertObject(final Object object) { } @Override - public boolean dropData(final DragAndDropData data, final Display display) + public boolean dropData(final DragAndDropData data, + final Display display) { return drop(convertData(data), display); } diff --git a/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropData.java b/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropData.java index 1c278a394..cd7c1e18a 100644 --- a/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropData.java +++ b/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropData.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * Default implementation of {@link DragAndDropData}, which provides a * UI-agnostic way to bundle an object together with its MIME type. - * + * * @author Barry DeZonia * @author Curtis Rueden */ diff --git a/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropService.java b/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropService.java index e18db980b..2ffbdde11 100644 --- a/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropService.java +++ b/src/main/java/org/scijava/ui/dnd/DefaultDragAndDropService.java @@ -6,13 +6,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 @@ -42,7 +42,7 @@ /** * Default service for handling drag and drop events. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) diff --git a/src/main/java/org/scijava/ui/dnd/DragAndDropData.java b/src/main/java/org/scijava/ui/dnd/DragAndDropData.java index 4dd73dbd0..c786bf065 100644 --- a/src/main/java/org/scijava/ui/dnd/DragAndDropData.java +++ b/src/main/java/org/scijava/ui/dnd/DragAndDropData.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * Interface for drag-and-drop data. - * + * * @author Curtis Rueden */ public interface DragAndDropData { @@ -56,7 +56,7 @@ default boolean isSupported(final Class type) { /** * Gets the data with respect to the given MIME type. - * + * * @return The data object for the given MIME type. May return null if the * data is requested too early in the drag-and-drop process, such as * during a {@link DragEnterEvent} rather than a {@link DropEvent}. diff --git a/src/main/java/org/scijava/ui/dnd/DragAndDropHandler.java b/src/main/java/org/scijava/ui/dnd/DragAndDropHandler.java index 1b793784c..8873fdd78 100644 --- a/src/main/java/org/scijava/ui/dnd/DragAndDropHandler.java +++ b/src/main/java/org/scijava/ui/dnd/DragAndDropHandler.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ * handler merely by implementing this interface, it is encouraged to instead * extend {@link AbstractDragAndDropHandler}, for convenience. *

      - * + * * @author Curtis Rueden * @see Plugin * @see DragAndDropService @@ -90,7 +90,7 @@ public interface DragAndDropHandler extends HandlerPlugin { /** * Converts the given {@link DragAndDropData} to the type of data object * supported by this handler. - * + * * @throws IllegalArgumentException if the handler does not support the given * {@link DragAndDropData}. */ @@ -99,7 +99,7 @@ public interface DragAndDropHandler extends HandlerPlugin { /** * Converts the given object to the type of data object supported by this * handler. - * + * * @throws IllegalArgumentException if the handler does not support the given * object. */ @@ -108,7 +108,7 @@ public interface DragAndDropHandler extends HandlerPlugin { /** * Performs a drop operation with the given data object in the specified * {@link Display}. - * + * * @throws IllegalArgumentException if the handler is not compatible with the * given data/display combination. */ @@ -117,7 +117,7 @@ public interface DragAndDropHandler extends HandlerPlugin { /** * Performs a drop operation with the given data in the specified * {@link Display}. - * + * * @throws IllegalArgumentException if the handler is not compatible with the * given data/display combination. */ @@ -126,7 +126,7 @@ public interface DragAndDropHandler extends HandlerPlugin { /** * Performs a drop operation with the given data in the specified * {@link Display}. - * + * * @throws IllegalArgumentException if the handler is not compatible with the * given data/display combination. */ diff --git a/src/main/java/org/scijava/ui/dnd/DragAndDropService.java b/src/main/java/org/scijava/ui/dnd/DragAndDropService.java index f1de3ddb9..259691f33 100644 --- a/src/main/java/org/scijava/ui/dnd/DragAndDropService.java +++ b/src/main/java/org/scijava/ui/dnd/DragAndDropService.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * Interface for service that handles drag and drop events. - * + * * @author Curtis Rueden */ public interface DragAndDropService extends @@ -48,7 +48,7 @@ public interface DragAndDropService extends * Checks whether the given {@link DragAndDropData} can be dropped onto the * specified display. A (data, display) pair is deemed compatible if a * compatible handler exists for them. - * + * * @see DragAndDropHandler */ default boolean supports(final DragAndDropData data, @@ -61,7 +61,7 @@ default boolean supports(final DragAndDropData data, * Checks whether the given object can be dropped onto the specified display. * An (object, display) pair is deemed compatible if a compatible handler * exists for them. - * + * * @see DragAndDropHandler */ default boolean supports(final Object object, final Display display) { @@ -71,7 +71,7 @@ default boolean supports(final Object object, final Display display) { /** * Performs a drag-and-drop operation in the given display with the specified * {@link DragAndDropData}, using the first available compatible handler. - * + * * @see DragAndDropHandler * @return true if the drop operation was successful * @throws IllegalArgumentException if the display and/or data object are @@ -86,7 +86,7 @@ default boolean drop(final DragAndDropData data, final Display display) { /** * Performs a drag-and-drop operation in the given display with the specified * data object, using the first available compatible handler. - * + * * @see DragAndDropHandler * @return true if the drop operation was successful * @throws IllegalArgumentException if the display and/or data object are @@ -101,7 +101,7 @@ default boolean drop(final Object data, final Display display) { /** * Gets the drag-and-drop handler which will be used to handle the given * {@link DragAndDropData} dragged onto the specified display. - * + * * @return The first compatible drag-and-drop handler, or null if none * available. */ @@ -117,7 +117,7 @@ default DragAndDropHandler getHandler(final DragAndDropData data, /** * Gets the drag-and-drop handler which will be used to handle the given * object dragged onto the specified display. - * + * * @return The first compatible drag-and-drop handler, or null if none * available. */ @@ -144,7 +144,7 @@ default DragAndDropHandler getHandler(final Object object, // -- PTService methods -- @Override - @SuppressWarnings({"rawtypes", "unchecked"}) + @SuppressWarnings({ "rawtypes", "unchecked" }) default Class> getPluginType() { return (Class) DragAndDropHandler.class; } diff --git a/src/main/java/org/scijava/ui/dnd/FileDragAndDropHandler.java b/src/main/java/org/scijava/ui/dnd/FileDragAndDropHandler.java index 62684957f..b577fa5a2 100644 --- a/src/main/java/org/scijava/ui/dnd/FileDragAndDropHandler.java +++ b/src/main/java/org/scijava/ui/dnd/FileDragAndDropHandler.java @@ -6,13 +6,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 @@ -43,14 +43,12 @@ /** * Drag-and-drop handler for files. - * + * * @author Curtis Rueden * @author Barry DeZonia */ @Plugin(type = DragAndDropHandler.class, priority = Priority.LOW) -public class FileDragAndDropHandler extends - AbstractDragAndDropHandler -{ +public class FileDragAndDropHandler extends AbstractDragAndDropHandler { @Parameter(required = false) private IOService ioService; diff --git a/src/main/java/org/scijava/ui/dnd/ListDragAndDropHandler.java b/src/main/java/org/scijava/ui/dnd/ListDragAndDropHandler.java index 64febfa13..97134cae4 100644 --- a/src/main/java/org/scijava/ui/dnd/ListDragAndDropHandler.java +++ b/src/main/java/org/scijava/ui/dnd/ListDragAndDropHandler.java @@ -6,13 +6,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 @@ -37,12 +37,13 @@ /** * Drag-and-drop handler for lists of objects. - * + * * @author Curtis Rueden * @author Barry DeZonia */ @Plugin(type = DragAndDropHandler.class) -public class ListDragAndDropHandler extends AbstractDragAndDropHandler> +public class ListDragAndDropHandler extends + AbstractDragAndDropHandler> { @Parameter(required = false) diff --git a/src/main/java/org/scijava/ui/dnd/MIMEType.java b/src/main/java/org/scijava/ui/dnd/MIMEType.java index 4d7f01307..50f50f778 100644 --- a/src/main/java/org/scijava/ui/dnd/MIMEType.java +++ b/src/main/java/org/scijava/ui/dnd/MIMEType.java @@ -6,13 +6,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 @@ -45,7 +45,7 @@ * there is no public MIME type class in core Java excluding AWT, which we could * use cross-environment in e.g. Android. *

      - * + * * @author Curtis Rueden */ public class MIMEType { @@ -64,7 +64,7 @@ public class MIMEType { /** * Constructs a new MIME type object from the given MIME type string. - * + * * @param mimeType The MIME type string, which may optionally include a list * of semicolon-separated parameters. */ @@ -74,7 +74,7 @@ public MIMEType(final String mimeType) { /** * Constructs a new MIME type object from the given MIME type string. - * + * * @param mimeType The MIME type string, which may optionally include a list * of semicolon-separated parameters. * @param javaType The associated Java class of the MIME type. If non-null, a diff --git a/src/main/java/org/scijava/ui/dnd/ScriptFileDragAndDropHandler.java b/src/main/java/org/scijava/ui/dnd/ScriptFileDragAndDropHandler.java index 5298fc946..892502803 100644 --- a/src/main/java/org/scijava/ui/dnd/ScriptFileDragAndDropHandler.java +++ b/src/main/java/org/scijava/ui/dnd/ScriptFileDragAndDropHandler.java @@ -6,13 +6,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,7 +38,7 @@ /** * Drag-and-drop handler for script files. - * + * * @author Curtis Rueden */ @Plugin(type = DragAndDropHandler.class) 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 83b15db9e..589e87953 100644 --- a/src/main/java/org/scijava/ui/dnd/event/DragAndDropEvent.java +++ b/src/main/java/org/scijava/ui/dnd/event/DragAndDropEvent.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * An event indicating drag-and-drop activity in a display. - * + * * @author Curtis Rueden */ public abstract class DragAndDropEvent extends InputEvent { @@ -47,7 +47,8 @@ public DragAndDropEvent(final Display display) { this(display, null); } - public DragAndDropEvent(final Display display, final DragAndDropData data) + public DragAndDropEvent(final Display display, + final DragAndDropData data) { this(display, null, -1, -1, data); } 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 5c93dff04..65bfa2f70 100644 --- a/src/main/java/org/scijava/ui/dnd/event/DragEnterEvent.java +++ b/src/main/java/org/scijava/ui/dnd/event/DragEnterEvent.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * An event indicating an object was dragged onto a display. - * + * * @author Curtis Rueden */ public class DragEnterEvent extends DragAndDropEvent { 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 0576666e8..dbf2d15a1 100644 --- a/src/main/java/org/scijava/ui/dnd/event/DragExitEvent.java +++ b/src/main/java/org/scijava/ui/dnd/event/DragExitEvent.java @@ -6,13 +6,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,7 +33,7 @@ /** * An event indicating an object was dragged off of a display. - * + * * @author Curtis Rueden */ public class DragExitEvent extends DragAndDropEvent { 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 df28afbb5..002bbae4e 100644 --- a/src/main/java/org/scijava/ui/dnd/event/DragOverEvent.java +++ b/src/main/java/org/scijava/ui/dnd/event/DragOverEvent.java @@ -6,13 +6,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 @@ -35,14 +35,13 @@ /** * An event indicating an object was dragged within a display. - * + * * @author Curtis Rueden */ public class DragOverEvent extends DragAndDropEvent { - public DragOverEvent(final Display display, - final InputModifiers modifiers, final int x, final int y, - final DragAndDropData data) + public DragOverEvent(final Display display, final InputModifiers modifiers, + final int x, final int y, final DragAndDropData data) { super(display, modifiers, x, y, data); } 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 d1000d5d3..1675cd50a 100644 --- a/src/main/java/org/scijava/ui/dnd/event/DropEvent.java +++ b/src/main/java/org/scijava/ui/dnd/event/DropEvent.java @@ -6,13 +6,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 @@ -35,16 +35,15 @@ /** * An event indicating an object was dropped onto a display. - * + * * @author Curtis Rueden */ public class DropEvent extends DragAndDropEvent { private boolean successful; - public DropEvent(final Display display, - final InputModifiers modifiers, final int x, final int y, - final DragAndDropData data) + public DropEvent(final Display display, final InputModifiers modifiers, + final int x, final int y, final DragAndDropData data) { super(display, modifiers, x, y, data); } diff --git a/src/main/java/org/scijava/ui/event/UIEvent.java b/src/main/java/org/scijava/ui/event/UIEvent.java index 8a0892f1a..da535388d 100644 --- a/src/main/java/org/scijava/ui/event/UIEvent.java +++ b/src/main/java/org/scijava/ui/event/UIEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An event indicating activity relating to a {@link UserInterface}. - * + * * @author Curtis Rueden */ public abstract class UIEvent extends SciJavaEvent { diff --git a/src/main/java/org/scijava/ui/event/UIShownEvent.java b/src/main/java/org/scijava/ui/event/UIShownEvent.java index 957efb500..bdd84591a 100644 --- a/src/main/java/org/scijava/ui/event/UIShownEvent.java +++ b/src/main/java/org/scijava/ui/event/UIShownEvent.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * An event indicating a user interface was shown. - * + * * @author Curtis Rueden * @see UIService#showUI */ diff --git a/src/main/java/org/scijava/ui/headless/HeadlessDisplayViewer.java b/src/main/java/org/scijava/ui/headless/HeadlessDisplayViewer.java index af6b6c902..d19b6f3f7 100644 --- a/src/main/java/org/scijava/ui/headless/HeadlessDisplayViewer.java +++ b/src/main/java/org/scijava/ui/headless/HeadlessDisplayViewer.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * A display viewer used when running headless. - * + * * @author Curtis Rueden */ @Plugin(type = DisplayViewer.class) diff --git a/src/main/java/org/scijava/ui/headless/HeadlessUI.java b/src/main/java/org/scijava/ui/headless/HeadlessUI.java index 654b42e7f..b61e4e48e 100644 --- a/src/main/java/org/scijava/ui/headless/HeadlessUI.java +++ b/src/main/java/org/scijava/ui/headless/HeadlessUI.java @@ -6,13 +6,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/ui/headlessUI/HeadlessUI.java b/src/main/java/org/scijava/ui/headlessUI/HeadlessUI.java index 3c55c9cd2..a94c04633 100644 --- a/src/main/java/org/scijava/ui/headlessUI/HeadlessUI.java +++ b/src/main/java/org/scijava/ui/headlessUI/HeadlessUI.java @@ -6,13 +6,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/ui/viewer/AbstractDisplayViewer.java b/src/main/java/org/scijava/ui/viewer/AbstractDisplayViewer.java index 3bda15d67..53f4cd189 100644 --- a/src/main/java/org/scijava/ui/viewer/AbstractDisplayViewer.java +++ b/src/main/java/org/scijava/ui/viewer/AbstractDisplayViewer.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ * The AbstractDisplayViewer provides some basic generic implementations for a * DisplayViewer such as storing and providing the display, window and panel for * a DisplayViewer. - * + * * @author Lee Kamentsky * @author Curtis Rueden */ diff --git a/src/main/java/org/scijava/ui/viewer/DisplayPanel.java b/src/main/java/org/scijava/ui/viewer/DisplayPanel.java index 691b42687..2e984d172 100644 --- a/src/main/java/org/scijava/ui/viewer/DisplayPanel.java +++ b/src/main/java/org/scijava/ui/viewer/DisplayPanel.java @@ -6,13 +6,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,7 +33,7 @@ /** * The panel housing a particular {@link Display}. - * + * * @author Grant Harris * @author Curtis Rueden */ diff --git a/src/main/java/org/scijava/ui/viewer/DisplayViewer.java b/src/main/java/org/scijava/ui/viewer/DisplayViewer.java index eb439e8f6..e88a0c886 100644 --- a/src/main/java/org/scijava/ui/viewer/DisplayViewer.java +++ b/src/main/java/org/scijava/ui/viewer/DisplayViewer.java @@ -6,13 +6,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 @@ -48,7 +48,7 @@ * merely by implementing this interface, it is encouraged to instead extend * {@link AbstractDisplayViewer}, for convenience. *

      - * + * * @author Lee Kamentsky * @author Curtis Rueden * @see Plugin @@ -73,7 +73,7 @@ public interface DisplayViewer extends RichPlugin, Disposable { * {@link #view(DisplayWindow, Display)}. Viewers needing to customize details * of the {@link DisplayWindow} creation can do so via this method. *

      - * + * * @param ui The user interface with which the viewer will be associated. * @param d the model for the display to show. */ @@ -87,7 +87,7 @@ default void view(final UserInterface ui, final Display d) { /** * Begins viewing the given display. - * + * * @param w The frame / window that will contain the GUI elements * @param d the model for the display to show. */ @@ -101,7 +101,7 @@ default void view(final UserInterface ui, final Display d) { /** * Installs the display panel. - * + * * @param panel the panel used to host the gui */ void setPanel(DisplayPanel panel); diff --git a/src/main/java/org/scijava/ui/viewer/DisplayWindow.java b/src/main/java/org/scijava/ui/viewer/DisplayWindow.java index 14654e681..42929e164 100644 --- a/src/main/java/org/scijava/ui/viewer/DisplayWindow.java +++ b/src/main/java/org/scijava/ui/viewer/DisplayWindow.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * A user interface window associated with a Display, containing a * {@link DisplayPanel}. - * + * * @author Grant Harris * @author Barry DeZonia */ @@ -55,7 +55,7 @@ public interface DisplayWindow { void requestFocus(); void close(); - + /** * Finds the x coordinate on the screen of the origin of the display window's * content. 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 b53271ee6..b25c1a744 100644 --- a/src/main/java/org/scijava/ui/viewer/text/AbstractTextDisplayViewer.java +++ b/src/main/java/org/scijava/ui/viewer/text/AbstractTextDisplayViewer.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Implements the UI-independent elements of a text viewer. - * + * * @author Lee Kamentsky */ public abstract class AbstractTextDisplayViewer extends 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 cd53bdc2d..45a533dbc 100644 --- a/src/main/java/org/scijava/ui/viewer/text/TextDisplayPanel.java +++ b/src/main/java/org/scijava/ui/viewer/text/TextDisplayPanel.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * This is a panel that can go inside a display window. It displays * {@link String}s. - * + * * @author Lee Kamentsky */ public interface TextDisplayPanel extends DisplayPanel { 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 8799c7ec7..75f2f3fe1 100644 --- a/src/main/java/org/scijava/ui/viewer/text/TextDisplayViewer.java +++ b/src/main/java/org/scijava/ui/viewer/text/TextDisplayViewer.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * A display viewer for {@link String}s. - * + * * @author Lee Kamentsky */ public interface TextDisplayViewer extends DisplayViewer { diff --git a/src/main/java/org/scijava/util/AbstractPrimitiveArray.java b/src/main/java/org/scijava/util/AbstractPrimitiveArray.java index def8f4eb9..dfb7c4f7f 100644 --- a/src/main/java/org/scijava/util/AbstractPrimitiveArray.java +++ b/src/main/java/org/scijava/util/AbstractPrimitiveArray.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ * frequent re-allocation, by default, the fixed-size array will be expanded by * 50% when running out of space. *

      - * + * * @author Johannes Schindelin * @author Curtis Rueden * @param Type of the primitive array; e.g., {@code double[]}. @@ -68,7 +68,7 @@ public abstract class AbstractPrimitiveArray extends /** * Constructs an extensible array of primitive type elements, backed by a * fixed-size array. - * + * * @param type the class of the primitive type */ public AbstractPrimitiveArray(final Class type) { @@ -78,7 +78,7 @@ public AbstractPrimitiveArray(final Class type) { /** * Constructs an extensible array of primitive type elements, backed by a * fixed-size array. - * + * * @param type the class of the primitive type * @param size the initial size */ @@ -91,7 +91,7 @@ public AbstractPrimitiveArray(final Class type, final int size) { /** * Constructs an extensible array of primitive type elements, backed by the * given fixed-size array. - * + * * @param array the array to wrap * @param type the class of the primitive type */ @@ -152,7 +152,7 @@ public void ensureCapacity(final int minCapacity) { /** * Shifts the array to insert space at a specified index. - * + * * @param index the index where the space should be inserted * @param count the number of values to insert */ @@ -178,7 +178,7 @@ public void insert(final int index, final int count) { /** * Shifts the array to delete space starting at a specified index. - * + * * @param index the index where the space should be deleted * @param count the number of values to delete */ diff --git a/src/main/java/org/scijava/util/AppUtils.java b/src/main/java/org/scijava/util/AppUtils.java index b65cce633..6e1460018 100644 --- a/src/main/java/org/scijava/util/AppUtils.java +++ b/src/main/java/org/scijava/util/AppUtils.java @@ -6,13 +6,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,7 +38,7 @@ /** * Useful methods for obtaining details of the SciJava application environment. - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -59,7 +59,7 @@ private AppUtils() { /** * Gets the class whose main method launched the application. - * + * * @return The launching class, or null if the main method terminated before * the {@code AppUtils} class was loaded. */ @@ -71,7 +71,7 @@ public static Class getMainClass() { * Gets the application root directory. If the given system property is set, * it is used. Otherwise, we scan up the tree from the given class for a * suitable directory. - * + * * @param sysProp System property which may point at the root directory. If * this is set to a valid directory, it is used. * @param c The class from which the base directory should be derived. @@ -111,7 +111,7 @@ public static File getBaseDirectory(final String sysProp, final Class c, /** * Gets the base file system directory containing the given class file. - * + * * @param c The class from which the base directory should be derived. * @see #getBaseDirectory(File, String) */ @@ -121,7 +121,7 @@ public static File getBaseDirectory(final Class c) { /** * Gets the base file system directory containing the given class file. - * + * * @param c The class from which the base directory should be derived. * @param baseSubdirectory A hint for what to expect for a directory structure * beneath the application base directory. @@ -170,8 +170,8 @@ public static File getBaseDirectory(final Class c, *
    • Within a JAR file in the Maven local repository cache. Typically * this cache is located in {@code ~/.m2/repository}. The location will be * {@code groupId/artifactId/version/artifactId-version.jar} where - * {@code groupId}, {@code artifactId} and {@code version} are the Maven GAV + * {@code groupId}, {@code artifactId} and {@code version} are the + * Maven GAV * coordinates. Note that in this case, no base directory with respect to * the given class can be found, and this method will return null.
    • *
    • Within a JAR file beneath the base directory. Common cases @@ -200,8 +200,8 @@ public static File getBaseDirectory(final Class c, * NetBeans or IntelliJ IDEA) then all dependencies will reside within JAR * files in the local Maven repository cache. But the executed project * itself will reside in its Maven build directory. So as long as you - * ask for the base directory relative to a class - * of the executed project it will be found.
    • + * ask for the base directory relative to a class of the executed + * project it will be found. *
    • Running as an application bundle (e.g., ImageJ). Typically this * means downloading ImageJ from the web site, unpacking it and running the * ImageJ launcher (double-clicking ImageJ-win32.exe on Windows, @@ -209,7 +209,7 @@ public static File getBaseDirectory(final Class c, * components reside in the {@code jars} folder of the application bundle, and * the base directory will be found one level above that.
    • * - * + * * @param classLocation The location from which the base directory should be * derived. * @param baseSubdirectory A hint for what to expect for a directory structure @@ -235,7 +235,7 @@ public static File getBaseDirectory(final File classLocation, final String targetClassesSuffix = basePrefix + "target/classes"; final String targetTestClassesSuffix = basePrefix + "target/test-classes"; - final String[] suffixes = {targetClassesSuffix, targetTestClassesSuffix}; + final String[] suffixes = { targetClassesSuffix, targetTestClassesSuffix }; for (final String suffix : suffixes) { if (!path.endsWith(suffix)) continue; @@ -246,8 +246,8 @@ public static File getBaseDirectory(final File classLocation, if (baseSubdirectory == null) { // NB: There is no hint as to the directory structure. // So we scan up the tree to find the topmost pom.xml file. - while (dir.getParentFile() != null && - new File(dir.getParentFile(), "pom.xml").exists()) + while (dir.getParentFile() != null && new File(dir.getParentFile(), + "pom.xml").exists()) { dir = dir.getParentFile(); } @@ -255,9 +255,8 @@ public static File getBaseDirectory(final File classLocation, return dir; } - final Pattern pattern = - Pattern.compile(".*(" + Pattern.quote(basePrefix + "target/") + - "[^/]*\\.jar)"); + final Pattern pattern = Pattern.compile(".*(" + Pattern.quote(basePrefix + + "target/") + "[^/]*\\.jar)"); final Matcher matcher = pattern.matcher(path); if (matcher.matches()) { // NB: The class is in the Maven build directory inside a JAR file diff --git a/src/main/java/org/scijava/util/ArrayUtils.java b/src/main/java/org/scijava/util/ArrayUtils.java index f2059c2c7..4b8262834 100644 --- a/src/main/java/org/scijava/util/ArrayUtils.java +++ b/src/main/java/org/scijava/util/ArrayUtils.java @@ -6,13 +6,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 @@ -63,7 +63,7 @@ /** * Utility class for working with arrays, particularly arrays of primitives. - * + * * @author Mark Hiner * @author Curtis Rueden * @author Melissa Linkert diff --git a/src/main/java/org/scijava/util/BoolArray.java b/src/main/java/org/scijava/util/BoolArray.java index 32ff8e8b4..c2ce2b1fc 100644 --- a/src/main/java/org/scijava/util/BoolArray.java +++ b/src/main/java/org/scijava/util/BoolArray.java @@ -6,13 +6,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,7 +33,7 @@ /** * An extensible array of {@code boolean} elements. - * + * * @author Mark Hiner * @author Johannes Schindelin * @author Curtis Rueden @@ -52,7 +52,7 @@ public BoolArray() { /** * Constructs an extensible array of booleans, backed by a fixed-size array. - * + * * @param size the initial size */ public BoolArray(final int size) { @@ -62,7 +62,7 @@ public BoolArray(final int size) { /** * Constructs an extensible array of booleans, backed by the given fixed-size * array. - * + * * @param array the array to wrap */ public BoolArray(final boolean[] array) { @@ -196,7 +196,8 @@ public boolean containsAll(final Collection c) { // NB: Overridden for performance. @Override - public boolean addAll(final int index, final Collection c) + public boolean addAll(final int index, + final Collection c) { if (c.size() == 0) return false; insert(index, c.size()); diff --git a/src/main/java/org/scijava/util/ByteArray.java b/src/main/java/org/scijava/util/ByteArray.java index 4d7a72d28..68d7aedc0 100644 --- a/src/main/java/org/scijava/util/ByteArray.java +++ b/src/main/java/org/scijava/util/ByteArray.java @@ -6,13 +6,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,7 +33,7 @@ /** * An extensible array of {@code byte} elements. - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -51,7 +51,7 @@ public ByteArray() { /** * Constructs an extensible array of bytes, backed by a fixed-size array. - * + * * @param size the initial size */ public ByteArray(final int size) { @@ -61,7 +61,7 @@ public ByteArray(final int size) { /** * Constructs an extensible array of bytes, backed by the given fixed-size * array. - * + * * @param array the array to wrap */ public ByteArray(final byte[] array) { @@ -195,8 +195,7 @@ public boolean containsAll(final Collection c) { // NB: Overridden for performance. @Override - public boolean addAll(final int index, final Collection c) - { + public boolean addAll(final int index, final Collection c) { if (c.size() == 0) return false; insert(index, c.size()); int i = index; diff --git a/src/main/java/org/scijava/util/Bytes.java b/src/main/java/org/scijava/util/Bytes.java index 45f8c70af..bf70cdee1 100644 --- a/src/main/java/org/scijava/util/Bytes.java +++ b/src/main/java/org/scijava/util/Bytes.java @@ -6,13 +6,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 @@ -86,9 +86,8 @@ public static short toShort(final byte[] bytes, final int off, int len, if (bytes.length - off < len) len = bytes.length - off; short total = 0; for (int i = 0, ndx = off; i < len; i++, ndx++) { - total |= - (bytes[ndx] < 0 ? 256 + bytes[ndx] : (int) bytes[ndx]) << ((little ? i - : len - i - 1) * 8); + total |= (bytes[ndx] < 0 ? 256 + bytes[ndx] + : (int) bytes[ndx]) << ((little ? i : len - i - 1) * 8); } return total; } @@ -162,9 +161,8 @@ public static int toInt(final byte[] bytes, final int off, int len, if (bytes.length - off < len) len = bytes.length - off; int total = 0; for (int i = 0, ndx = off; i < len; i++, ndx++) { - total |= - (bytes[ndx] < 0 ? 256 + bytes[ndx] : (int) bytes[ndx]) << ((little ? i - : len - i - 1) * 8); + total |= (bytes[ndx] < 0 ? 256 + bytes[ndx] + : (int) bytes[ndx]) << ((little ? i : len - i - 1) * 8); } return total; } @@ -264,8 +262,8 @@ public static float toFloat(final byte[] bytes, final boolean little) { * bytes available, the MSBs are all assumed to be zero (regardless of * endianness). */ - public static float toFloat(final short[] bytes, final int off, - final int len, final boolean little) + public static float toFloat(final short[] bytes, final int off, final int len, + final boolean little) { return Float.intBitsToFloat(toInt(bytes, off, len, little)); } @@ -302,9 +300,8 @@ public static long toLong(final byte[] bytes, final int off, int len, if (bytes.length - off < len) len = bytes.length - off; long total = 0; for (int i = 0, ndx = off; i < len; i++, ndx++) { - total |= - (bytes[ndx] < 0 ? 256L + bytes[ndx] : (long) bytes[ndx]) << ((little - ? i : len - i - 1) * 8); + total |= (bytes[ndx] < 0 ? 256L + bytes[ndx] + : (long) bytes[ndx]) << ((little ? i : len - i - 1) * 8); } return total; } @@ -460,7 +457,9 @@ public static byte[] fromLong(final long value, final boolean little) { return v; } - /** Translates the {@code double} value into an array of eight {@code byte}s. */ + /** + * Translates the {@code double} value into an array of eight {@code byte}s. + */ public static byte[] fromDouble(final double value, final boolean little) { final byte[] v = new byte[8]; unpack(Double.doubleToLongBits(value), v, 0, 8, little); @@ -519,7 +518,8 @@ public static byte[] fromLongs(final long[] values, final boolean little) { * Translates an array of {@code double} values into an array of {@code byte} * values. */ - public static byte[] fromDoubles(final double[] values, final boolean little) + public static byte[] fromDoubles(final double[] values, + final boolean little) { final byte[] v = new byte[values.length * 8]; for (int i = 0; i < values.length; i++) { diff --git a/src/main/java/org/scijava/util/CharArray.java b/src/main/java/org/scijava/util/CharArray.java index 099db97ec..0bbe847a4 100644 --- a/src/main/java/org/scijava/util/CharArray.java +++ b/src/main/java/org/scijava/util/CharArray.java @@ -6,13 +6,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,7 +33,7 @@ /** * An extensible array of {@code char} elements. - * + * * @author Mark Hiner * @author Johannes Schindelin * @author Curtis Rueden @@ -52,7 +52,7 @@ public CharArray() { /** * Constructs an extensible array of chars, backed by a fixed-size array. - * + * * @param size the initial size */ public CharArray(final int size) { @@ -62,7 +62,7 @@ public CharArray(final int size) { /** * Constructs an extensible array of chars, backed by the given fixed-size * array. - * + * * @param array the array to wrap */ public CharArray(final char[] array) { @@ -196,7 +196,8 @@ public boolean containsAll(final Collection c) { // NB: Overridden for performance. @Override - public boolean addAll(final int index, final Collection c) + public boolean addAll(final int index, + final Collection c) { if (c.size() == 0) return false; insert(index, c.size()); diff --git a/src/main/java/org/scijava/util/CheckSezpoz.java b/src/main/java/org/scijava/util/CheckSezpoz.java index fa9be7491..8c0accbec 100644 --- a/src/main/java/org/scijava/util/CheckSezpoz.java +++ b/src/main/java/org/scijava/util/CheckSezpoz.java @@ -6,13 +6,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 @@ -48,7 +48,7 @@ /** * Deprecated class. - * + * * @author Johannes Schindelin */ @Deprecated @@ -72,7 +72,7 @@ private CheckSezpoz() { * contrast to Maven, Eclipse usually does not build .jar files, though, so we * can have a very quick check at startup if the annotation processor was not * run correctly and undo the damage. - * + * * @param checkJars whether to inspect .jar components of the CLASSPATH * @return false, when the annotation processor had to be run * @throws IOException @@ -86,7 +86,7 @@ public static boolean check(final boolean checkJars) throws IOException { /** * Checks the annotations of a CLASSPATH component. - * + * * @param file the CLASSPATH component (.jar file or directory) * @return false, when the annotation processor had to be run * @throws IOException @@ -95,13 +95,14 @@ public static boolean check(final boolean checkJars) throws IOException { @Deprecated public static boolean check(final File file) throws IOException { System.err.println("Warning: Deprecated CheckSezpoz class was called!"); - EclipseHelper.updateAnnotationIndex(new URLClassLoader(new URL[] { file.toURI().toURL() })); + EclipseHelper.updateAnnotationIndex(new URLClassLoader(new URL[] { file + .toURI().toURL() })); return false; } /** * Checks the annotations of a directory in the CLASSPATH. - * + * * @param classes the CLASSPATH component directory * @return false, when the annotation processor had to be run * @throws IOException @@ -119,7 +120,7 @@ public static boolean checkDirectory(final File classes) throws IOException { * their corresponding {@code .java} files, or whether there are * {@code .class} files that were generated since last time we checked. *

      - * + * * @param classes the {@code classes/} directory where Maven puts the * {@code .class} files * @param source the {@code src/main/java/} directory where Maven expects the @@ -140,7 +141,7 @@ public static boolean checkDirectory(final File classes, final File source, * This method is broken at the moment since there is no good way to verify * that SezPoz ran before the {@code .jar} file was packaged. *

      - * + * * @param file the {@code .jar} file * @see EclipseHelper */ @@ -152,7 +153,7 @@ public static void checkJar(final File file) throws IOException { /** * Runs SezPoz on the sources, writing the annotations into the classes' * {@code META-INF/annotations/} directory. - * + * * @param classes the output directory * @param sources the directory containing the source files * @return whether anything in {@code META-INF/annotations/*} changed @@ -162,14 +163,15 @@ public static void checkJar(final File file) throws IOException { public static boolean fix(final File classes, final File sources) { try { return check(classes); - } catch (IOException e) { + } + catch (IOException e) { throw new RuntimeException(e); } } /** * Writes out a DOM as {@code .xml} file. - * + * * @param xml the DOM * @param file the file to write * @throws TransformerException diff --git a/src/main/java/org/scijava/util/ClassUtils.java b/src/main/java/org/scijava/util/ClassUtils.java index 09961183e..84d13103e 100644 --- a/src/main/java/org/scijava/util/ClassUtils.java +++ b/src/main/java/org/scijava/util/ClassUtils.java @@ -6,13 +6,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 @@ -62,7 +62,7 @@ private ClassUtils() { * This map serves as a cache, as these annotations should not change at * runtime and thus can alleviate the frequency field querying. *

      - * + * * @see issue * #142 */ @@ -76,7 +76,7 @@ private ClassUtils() { * This map serves as a cache, as these annotations should not change at * runtime and thus can alleviate the frequency of method querying. *

      - * + * * @see issue * #142 */ @@ -123,9 +123,9 @@ public static List getAnnotatedMethods( * @param annotationClass The type of annotation for which to scan. * @param methods The list to which matching methods will be added. */ - public static void - getAnnotatedMethods(final Class c, final Class annotationClass, - final List methods) + public static void getAnnotatedMethods( + final Class c, final Class annotationClass, + final List methods) { List cachedMethods = methodCache.getList(c, annotationClass); @@ -178,8 +178,8 @@ public static List getAnnotatedFields( * @param annotationClass The type of annotation for which to scan. * @param fields The list to which matching fields will be added. */ - public static void getAnnotatedFields( - final Class c, final Class annotationClass, final List fields) + public static void getAnnotatedFields(final Class c, + final Class annotationClass, final List fields) { List cachedFields = fieldCache.getList(c, annotationClass); @@ -195,8 +195,8 @@ public static void getAnnotatedFields( /** * This method scans the provided class, its superclasses and interfaces for - * all supported {@link Annotation} : {@link AnnotatedElement} pairs. - * These are then cached to remove the need for future queries. + * all supported {@link Annotation} : {@link AnnotatedElement} pairs. These + * are then cached to remove the need for future queries. *

      * By combining multiple {@code Annotation : AnnotatedElement} pairs in one * query, we can limit the number of times a class's superclass and interface @@ -217,10 +217,11 @@ public static void cacheAnnotatedObjects(final Class scannedClass, // same class by different threads, there are three scenarios: // 1) intersection of A + B is empty - then they can run on separate threads // 2) A == B - whichever was received second must wait for the first to - // finish. - // 3) A != B and intersection of A + B is not empty - the intersection subset - // can be safely performed on a separate thread, but the later query must - // still wait for the earlier query to complete. + // finish. + // 3) A != B and intersection of A + B is not empty - the intersection + // subset + // can be safely performed on a separate thread, but the later query must + // still wait for the earlier query to complete. // // NB: an alternative would be to update the getAnnotatedxxx methods to // return Sets instead of Lists. Then threads can pretty much go nuts @@ -239,8 +240,7 @@ public static void cacheAnnotatedObjects(final Class scannedClass, if (scannedClass == null || scannedClass == Object.class) return; // Initialize step - determine which queries are solved - final Set> keysToDrop = - new HashSet<>(); + final Set> keysToDrop = new HashSet<>(); for (final Class annotationClass : query.keySet()) { // Fields if (fieldCache.getList(scannedClass, annotationClass) != null) { @@ -278,8 +278,8 @@ else if (methodCache.getList(scannedClass, annotationClass) != null) { // Populate supported objects for scanned class for (final Class annotationClass : query.keySet()) { - final Class objectClass = - query.get(annotationClass); + final Class objectClass = query.get( + annotationClass); try { // Methods @@ -340,8 +340,8 @@ public static void setValue(final Field field, final Object instance, field.set(instance, compatibleValue); } catch (final IllegalAccessException e) { - throw new IllegalArgumentException("No access to field: " + - field.getName(), e); + throw new IllegalArgumentException("No access to field: " + field + .getName(), e); } } @@ -397,12 +397,12 @@ private static void populateCache( { // Add inherited elements for (final Class inheritedClass : inherited) { - final List annotatedElements = - cacheMap.getList(inheritedClass, annotationClass); + final List annotatedElements = cacheMap.getList(inheritedClass, + annotationClass); if (annotatedElements != null && !annotatedElements.isEmpty()) { - final List scannedElements = - cacheMap.makeList(scannedClass, annotationClass); + final List scannedElements = cacheMap.makeList(scannedClass, + annotationClass); scannedElements.addAll(annotatedElements); } @@ -607,11 +607,12 @@ public static T getNullValue(final Class type) { } /** - * @deprecated Use {@link Types#fieldType(Field, Class)} and {@link Types#raws} - * instead. + * @deprecated Use {@link Types#fieldType(Field, Class)} and + * {@link Types#raws} instead. */ @Deprecated - public static List> getTypes(final Field field, final Class type) + public static List> getTypes(final Field field, + final Class type) { return Types.raws(Types.fieldType(field, type)); } @@ -627,7 +628,8 @@ public static Type getGenericType(final Field field, final Class type) { public static Field getField(final String className, final String fieldName) { try { return Types.field(Types.load(className), fieldName); - } catch (final IllegalArgumentException e) { + } + catch (final IllegalArgumentException e) { return null; } } @@ -637,7 +639,8 @@ public static Field getField(final String className, final String fieldName) { public static Field getField(final Class c, final String fieldName) { try { return Types.field(c, fieldName); - } catch (final IllegalArgumentException e) { + } + catch (final IllegalArgumentException e) { return null; } } @@ -697,7 +700,8 @@ public List getList(final Class c, final Class annotationClass) { final Map, List> annotationTypes = get(c); - return annotationTypes == null ? null : annotationTypes.get(annotationClass); + return annotationTypes == null ? null : annotationTypes.get( + annotationClass); } /** diff --git a/src/main/java/org/scijava/util/ColorRGB.java b/src/main/java/org/scijava/util/ColorRGB.java index 305fbbbe0..b871d250d 100644 --- a/src/main/java/org/scijava/util/ColorRGB.java +++ b/src/main/java/org/scijava/util/ColorRGB.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ *

      * It exists mainly to avoid AWT references to {@link java.awt.Color}. *

      - * + * * @author Curtis Rueden * @author Lee Kamentsky * @author Barry DeZonia @@ -109,14 +109,14 @@ public int getARGB() { } /** - * Convert this ColorRGB to a string in the format specified by
      CSS Color Module Level 3 - W3C + * Convert this ColorRGB to a string in the format specified by + * CSS Color Module Level 3 - W3C * Recommendation 07 June 2011. *

      * We preferentially encode using one of the colors in the table and fall back * to the hex encoding. *

      - * + * * @return HTML-encoded string */ public String toHTMLColor() { @@ -154,10 +154,10 @@ public int hashCode() { // -- Static methods -- /** - * Convert a string in the format specified by CSS Color Module Level 3 - W3C + * Convert a string in the format specified by + * CSS Color Module Level 3 - W3C * Recommendation 07 June 2011 to a {@link ColorRGB} object. - * + * * @param color The color string to convert. * @return The resultant color object. */ @@ -173,10 +173,9 @@ public static ColorRGB fromHTMLColor(final String color) { if (color.startsWith("#")) { final String hexColor; if (color.length() == 4) { - hexColor = - new String(new char[] { color.charAt(0), color.charAt(1), - color.charAt(1), color.charAt(2), color.charAt(2), - color.charAt(3), color.charAt(3) }); + hexColor = new String(new char[] { color.charAt(0), color.charAt(1), + color.charAt(1), color.charAt(2), color.charAt(2), color.charAt(3), + color.charAt(3) }); } else hexColor = color; final int red = Integer.parseInt(hexColor.substring(1, 3), 16); @@ -215,12 +214,12 @@ private int parse(final String[] s, final int index) { * and returns {@code r}, {@code g}, and {@code b} in the set [0, 255]. *

      *

      - * Conversion formula adapted from Wikipedia's HSL and HSV article and - * Michael Jackson's blog post on additive + * Conversion formula adapted from Wikipedia's + * HSL and HSV article + * and Michael Jackson's blog post on additive * color model conversion algorithms. *

      - * + * * @param h The hue * @param s The saturation * @param v The value diff --git a/src/main/java/org/scijava/util/ColorRGBA.java b/src/main/java/org/scijava/util/ColorRGBA.java index 4bab90ddc..bbc0f5efb 100644 --- a/src/main/java/org/scijava/util/ColorRGBA.java +++ b/src/main/java/org/scijava/util/ColorRGBA.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ *

      * It exists mainly to avoid AWT references to {@link java.awt.Color}. *

      - * + * * @author Curtis Rueden */ public class ColorRGBA extends ColorRGB { diff --git a/src/main/java/org/scijava/util/Colors.java b/src/main/java/org/scijava/util/Colors.java index 60fa3dc8c..09c315164 100644 --- a/src/main/java/org/scijava/util/Colors.java +++ b/src/main/java/org/scijava/util/Colors.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ * Predefined {@link ColorRGB} objects and related utility methods. These colors * match those * defined in CSS. - * + * * @author Lee Kamentsky * @author Curtis Rueden */ @@ -194,8 +194,7 @@ public final class Colors { public static final ColorRGB YELLOW = new ColorRGB(255, 255, 0); public static final ColorRGB YELLOWGREEN = new ColorRGB(154, 205, 50); - private static final Map COLORS = - new HashMap<>(); + private static final Map COLORS = new HashMap<>(); static { for (final Field f : Colors.class.getDeclaredFields()) { diff --git a/src/main/java/org/scijava/util/CombineAnnotations.java b/src/main/java/org/scijava/util/CombineAnnotations.java index 11ed3f879..7e52c1654 100644 --- a/src/main/java/org/scijava/util/CombineAnnotations.java +++ b/src/main/java/org/scijava/util/CombineAnnotations.java @@ -6,13 +6,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 @@ -39,8 +39,7 @@ * @deprecated Use {@link org.scijava.annotations.AnnotationCombiner} instead. */ @Deprecated -public class CombineAnnotations -{ +public class CombineAnnotations { /** * @deprecated Use @@ -75,7 +74,9 @@ public void combine() throws IOException, ClassNotFoundException { } /** - * @deprecated Use {@link org.scijava.annotations.AnnotationCombiner#getAnnotationFiles()} instead. + * @deprecated Use + * {@link org.scijava.annotations.AnnotationCombiner#getAnnotationFiles()} + * instead. */ @Deprecated public Set getAnnotationFiles() throws IOException { diff --git a/src/main/java/org/scijava/util/Combiner.java b/src/main/java/org/scijava/util/Combiner.java index ce758eed0..8c6b52d53 100644 --- a/src/main/java/org/scijava/util/Combiner.java +++ b/src/main/java/org/scijava/util/Combiner.java @@ -6,13 +6,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/util/ConversionUtils.java b/src/main/java/org/scijava/util/ConversionUtils.java index b902d2335..619dcb0bf 100644 --- a/src/main/java/org/scijava/util/ConversionUtils.java +++ b/src/main/java/org/scijava/util/ConversionUtils.java @@ -6,13 +6,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 @@ -88,8 +88,7 @@ public class ConversionUtils { new org.scijava.convert.NumberConverters.ShortToIntegerConverter(), new org.scijava.convert.NumberConverters.ShortToLongConverter(), new org.scijava.convert.StringToNumberConverter(), - new org.scijava.convert.DefaultConverter() - ); + new org.scijava.convert.DefaultConverter()); private ConversionUtils() { // prevent instantiation of utility class @@ -172,7 +171,7 @@ public static boolean canConvert(final Object src, final Class dest) { @Deprecated public static T convertToEnum(final String src, final Class dest) { try { - return Types.enumValue(src, dest); + return Types.enumValue(src, dest); } catch (final IllegalArgumentException exc) { return null; @@ -253,6 +252,7 @@ public static T getNullValue(final Class type) { * @return The {@link Converter} to use for handling the given request. */ private static Converter handler(final ConversionRequest data) { - return converters.stream().filter(c -> c.supports(data)).findFirst().orElse(null); + return converters.stream().filter(c -> c.supports(data)).findFirst().orElse( + null); } } diff --git a/src/main/java/org/scijava/util/DebugUtils.java b/src/main/java/org/scijava/util/DebugUtils.java index e7ce7cb53..daf29975c 100644 --- a/src/main/java/org/scijava/util/DebugUtils.java +++ b/src/main/java/org/scijava/util/DebugUtils.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ /** * Useful methods for debugging programs. - * + * * @author Curtis Rueden */ public final class DebugUtils { @@ -98,12 +98,11 @@ public static String getStackDump(final Thread thread, public static String getStackDump() { final StringBuilder sb = new StringBuilder(); - final Map stackTraces = - Thread.getAllStackTraces(); + final Map stackTraces = Thread + .getAllStackTraces(); // sort list of threads by name - final ArrayList threads = - new ArrayList<>(stackTraces.keySet()); + final ArrayList threads = new ArrayList<>(stackTraces.keySet()); Collections.sort(threads, (t1, t2) -> t1.getName().compareTo(t2.getName())); for (final Thread t : threads) { @@ -140,8 +139,8 @@ public static String getFieldName(final Class c, final int value) { * will fail if the main thread has terminated before this method is called. */ public static String getMainClassName() { - final Map traceMap = - Thread.getAllStackTraces(); + final Map traceMap = Thread + .getAllStackTraces(); for (final Thread thread : traceMap.keySet()) { if (!"main".equals(thread.getName())) continue; final StackTraceElement[] trace = traceMap.get(thread); diff --git a/src/main/java/org/scijava/util/DefaultTreeNode.java b/src/main/java/org/scijava/util/DefaultTreeNode.java index 8c9290a78..839162b2c 100644 --- a/src/main/java/org/scijava/util/DefaultTreeNode.java +++ b/src/main/java/org/scijava/util/DefaultTreeNode.java @@ -6,13 +6,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 @@ -47,7 +47,7 @@ public class DefaultTreeNode implements TreeNode { /** * Creates a new tree node wrapping the given data, located in the tree * beneath the specified parent. - * + * * @param data The data to wrap. * @param parent The parent node of the tree. */ diff --git a/src/main/java/org/scijava/util/DigestUtils.java b/src/main/java/org/scijava/util/DigestUtils.java index 172f54a9a..e7c1429e3 100644 --- a/src/main/java/org/scijava/util/DigestUtils.java +++ b/src/main/java/org/scijava/util/DigestUtils.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * Utility class for computing cryptographic hashes. - * + * * @author Curtis Rueden * @author Johannes Schindelin */ @@ -77,12 +77,8 @@ public static byte[] bytes(final String s) { /** Converts the given integer into a byte array. */ public static byte[] bytes(final int i) { - return new byte[] { - (byte) (0xff & (i >>> 24)), - (byte) (0xff & (i >>> 16)), - (byte) (0xff & (i >>> 8)), - (byte) (0xff & i), - }; + return new byte[] { (byte) (0xff & (i >>> 24)), (byte) (0xff & (i >>> 16)), + (byte) (0xff & (i >>> 8)), (byte) (0xff & i), }; } /** Converts the given byte array to a hexidecimal string. */ @@ -102,7 +98,7 @@ public static String base64(final byte[] bytes) { /** * Gets the Java hash code of the given string, as a byte array. - * + * * @see String#hashCode() */ public static byte[] hash(final String s) { @@ -111,7 +107,7 @@ public static byte[] hash(final String s) { /** * Gets the hash code of the given byte array, as a byte array. - * + * * @see String#hashCode() * @see #string(byte[]) */ @@ -137,7 +133,7 @@ public static byte[] md5(final byte[] bytes) { /** * Gets the given byte array's hash value according to the specified * algorithm. - * + * * @param algorithm The algorithm to use when generating the hash value. * @param bytes The byte array for which to compute the hash value. * @return The computed hash value, or null if the digest algorithm is not @@ -158,7 +154,7 @@ public static byte[] digest(final String algorithm, final byte[] bytes) { /** * Gets the given string's best available hash. Tries SHA-1 first, then MD5, * then Java hash code. - * + * * @see #bytes(String) * @see #sha1(byte[]) * @see #md5(byte[]) @@ -175,7 +171,7 @@ public static byte[] best(final String s) { /** * Gets the given byte array's best available hash. Tries SHA-1 first, then * MD5, then Java hash code. - * + * * @see #sha1(byte[]) * @see #md5(byte[]) * @see #hash(byte[]) @@ -189,7 +185,7 @@ public static byte[] best(final byte[] bytes) { /** * Gets the hex string of the given string's best available hash. - * + * * @see #best(String) * @see #hex(byte[]) */ @@ -199,7 +195,7 @@ public static String bestHex(final String text) { /** * Gets the hex string of the given byte array's best available hash. - * + * * @see #best(byte[]) * @see #hex(byte[]) */ @@ -209,7 +205,7 @@ public static String bestHex(final byte[] bytes) { /** * Gets the base64 string of the given string's best available hash. - * + * * @see #best(String) * @see #base64(byte[]) */ @@ -219,7 +215,7 @@ public static String bestBase64(final String text) { /** * Gets the base64 string of the given byte array's best available hash. - * + * * @see #best(byte[]) * @see #base64(byte[]) */ diff --git a/src/main/java/org/scijava/util/DoubleArray.java b/src/main/java/org/scijava/util/DoubleArray.java index a75b9b266..e5ba16458 100644 --- a/src/main/java/org/scijava/util/DoubleArray.java +++ b/src/main/java/org/scijava/util/DoubleArray.java @@ -6,13 +6,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,7 +33,7 @@ /** * An extensible array of {@code double} elements. - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -51,7 +51,7 @@ public DoubleArray() { /** * Constructs an extensible array of doubles, backed by a fixed-size array. - * + * * @param size the initial size */ public DoubleArray(final int size) { @@ -61,7 +61,7 @@ public DoubleArray(final int size) { /** * Constructs an extensible array of doubles, backed by the given fixed-size * array. - * + * * @param array the array to wrap */ public DoubleArray(final double[] array) { diff --git a/src/main/java/org/scijava/util/FileUtils.java b/src/main/java/org/scijava/util/FileUtils.java index a233d7fd5..0cd794a11 100644 --- a/src/main/java/org/scijava/util/FileUtils.java +++ b/src/main/java/org/scijava/util/FileUtils.java @@ -6,13 +6,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 @@ -59,7 +59,7 @@ /** * Useful methods for working with file paths. - * + * * @author Johannes Schindelin * @author Curtis Rueden * @author Grant Harris @@ -83,7 +83,7 @@ private FileUtils() { /** * Gets the absolute path to the given file, with the directory separator * standardized to forward slash, like most platforms use. - * + * * @param file The file whose path will be obtained and standardized. * @return The file's standardized absolute path. */ @@ -97,7 +97,7 @@ public static String getPath(final File file) { * Gets a standardized path based on the given one, with the directory * separator standardized from the specific separator to forward slash, like * most platforms use. - * + * * @param path The path to standardize. * @param separator The directory separator to be standardized. * @return The standardized path. @@ -109,7 +109,7 @@ public static String getPath(final String path, final String separator) { /** * Extracts the file extension from a file. - * + * * @param file the file object * @return the file extension (excluding the dot), or the empty string when * the file name does not contain dots @@ -123,7 +123,7 @@ public static String getExtension(final File file) { /** * Extracts the file extension from a file path. - * + * * @param path the path to the file (relative or absolute) * @return the file extension (excluding the dot), or the empty string when * the file name does not contain dots @@ -142,7 +142,7 @@ public static Date getModifiedTime(final File file) { /** * Reads the contents of the given file into a new byte array. - * + * * @see DigestUtils#string(byte[]) To convert a byte array to a string. * @throws IOException If the file cannot be read. */ @@ -162,7 +162,7 @@ public static byte[] readFile(final File file) throws IOException { /** * Writes the given byte array to the specified file. - * + * * @see DigestUtils#bytes(String) To convert a string to a byte array. * @throws IOException If the file cannot be written. */ @@ -182,7 +182,7 @@ public static String stripFilenameVersion(final String filename) { /** * Lists all versions of a given (possibly versioned) file name. - * + * * @param directory the directory to scan * @param filename the file name to use * @return the list of matches @@ -204,7 +204,7 @@ public boolean accept(final File dir, final String name) { if (!name.startsWith(baseName)) return false; final Matcher matcher2 = VERSION_PATTERN.matcher(name); return matcher2.matches() && baseName.equals(matcher2.group(1)) && - equals(classifier, matcher2.group(6)); + equals(classifier, matcher2.group(6)); } private boolean equals(final String a, final String b) { @@ -222,7 +222,7 @@ private boolean equals(final String a, final String b) { * This method is similar to calling {@code new File(url.toURI())} except that * it also handles "jar:file:" URLs, returning the path to the JAR file. *

      - * + * * @param url The URL to convert. * @return A file path suitable for use with e.g. {@link FileInputStream} * @throws IllegalArgumentException if the URL does not correspond to a file. @@ -233,7 +233,7 @@ public static File urlToFile(final URL url) { /** * Converts the given URL string to its corresponding {@link File}. - * + * * @param url The URL to convert. * @return A file path suitable for use with e.g. {@link FileInputStream} * @throws IllegalArgumentException if the URL does not correspond to a file. @@ -267,7 +267,7 @@ public static File urlToFile(final String url) { /** * Shortens the path to a maximum of 4 path elements. - * + * * @param path the path to the file (relative or absolute) * @return shortened path */ @@ -278,7 +278,7 @@ public static String shortenPath(final String path) { /** * Shortens the path based on the given maximum number of path elements. E.g., * "C:/1/2/test.txt" returns "C:/1/.../test.txt" if threshold is 1. - * + * * @param path the path to the file (relative or absolute) * @param threshold the number of directories to keep unshortened * @return shortened path @@ -323,8 +323,8 @@ public static String shortenPath(final String path, final int threshold) { } } else { - final boolean isUNC = - path.substring(0, 2).equals(SHORTENER_BACKSLASH_REGEX); + final boolean isUNC = path.substring(0, 2).equals( + SHORTENER_BACKSLASH_REGEX); if (isUNC) { sb.append(SHORTENER_BACKSLASH).append(SHORTENER_BACKSLASH); } @@ -348,7 +348,7 @@ public static String shortenPath(final String path, final int threshold) { /** * Compacts a path into a given number of characters. The result is similar to * the Win32 API PathCompactPathExA. - * + * * @param path the path to the file (relative or absolute) * @param limit the number of characters to which the path should be limited * @return shortened path @@ -408,7 +408,7 @@ public static String limitPath(final String path, final int limit) { * It is the caller's responsibility to make sure that the directory is * deleted; see {@link #deleteRecursively(File)}. *

      - * + * * @param prefix The prefix string to be used in generating the file's name; * see {@link File#createTempFile(String, String, File)} * @return An abstract pathname denoting a newly-created empty directory @@ -432,7 +432,7 @@ public static File createTemporaryDirectory(final String prefix) * It is the caller's responsibility to make sure that the directory is * deleted; see {@link #deleteRecursively(File)}. *

      - * + * * @param prefix The prefix string to be used in generating the file's name; * see {@link File#createTempFile(String, String, File)} * @param suffix The suffix string to be used in generating the file's name; @@ -458,7 +458,7 @@ public static File createTemporaryDirectory(final String prefix, * It is the caller's responsibility to make sure that the directory is * deleted; see {@link #deleteRecursively(File)}. *

      - * + * * @param prefix The prefix string to be used in generating the file's name; * see {@link File#createTempFile(String, String, File)} * @param suffix The suffix string to be used in generating the file's name; @@ -487,7 +487,7 @@ public static File createTemporaryDirectory(final String prefix, /** * Deletes a directory recursively. - * + * * @param directory The directory to delete. * @return whether it succeeded (see also {@link File#delete()}) */ @@ -510,7 +510,7 @@ else if (file.isDirectory()) { * Recursively lists the contents of the referenced directory. Directories are * excluded from the result. Supported protocols include {@code file} and * {@code jar}. - * + * * @param directory The directory whose contents should be listed. * @return A collection of {@link URL}s representing the directory's contents. * @see #listContents(URL, boolean, boolean) @@ -522,7 +522,7 @@ public static Collection listContents(final URL directory) { /** * Lists all contents of the referenced directory. Supported protocols include * {@code file} and {@code jar}. - * + * * @param directory The directory whose contents should be listed. * @param recurse Whether to list contents recursively, as opposed to only the * directory's direct contents. @@ -540,7 +540,7 @@ public static Collection listContents(final URL directory, * Recursively adds contents from the referenced directory to an existing * collection. Directories are excluded from the result. Supported protocols * include {@code file} and {@code jar}. - * + * * @param result The collection to which contents should be added. * @param directory The directory whose contents should be listed. * @return A collection of {@link URL}s representing the directory's contents. @@ -555,7 +555,7 @@ public static Collection appendContents(final Collection result, /** * Add contents from the referenced directory to an existing collection. * Supported protocols include {@code file} and {@code jar}. - * + * * @param result The collection to which contents should be added. * @param directory The directory whose contents should be listed. * @param recurse Whether to append contents recursively, as opposed to only @@ -596,13 +596,14 @@ else if (protocol.equals("jar")) { final String prefix = url.substring(bang + 2); final String baseURL = url.substring(0, bang + 2); - final JarURLConnection connection = - (JarURLConnection) new URL(baseURL).openConnection(); + final JarURLConnection connection = (JarURLConnection) new URL(baseURL) + .openConnection(); try (final JarFile jar = connection.getJarFile()) { 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 + final String urlEncoded = new URI(null, null, entry.getName(), null) + .toString(); + if (urlEncoded.length() > prefix.length() && // omit directory + // itself urlEncoded.startsWith(prefix)) { if (filesOnly && urlEncoded.endsWith("/")) { @@ -722,17 +723,11 @@ private static Pattern buildVersionPattern() { /** Helper method of {@link #buildVersionPattern()}. */ private static String classifiers() { - final String[] classifiers = { - "swing", - "swt", - "shaded", - "sources", - "javadoc", - "natives?-?\\w*", + final String[] classifiers = { "swing", "swt", "shaded", "sources", + "javadoc", "natives?-?\\w*", "(natives-)?(android|linux|macosx|macos|solaris|windows)-" + "(aarch64|amd64|arm64|armv6hf|armv6|arm|" + - "i386|i486|i586|i686|universal|x86[_-]32|x86[_-]64|x86)", - }; + "i386|i486|i586|i686|universal|x86[_-]32|x86[_-]64|x86)", }; final StringBuilder sb = new StringBuilder("("); for (final String classifier : classifiers) { if (sb.length() > 1) sb.append("|"); @@ -785,7 +780,7 @@ private static String urlPath(final String path) { /** * Returns the {@link Matcher} object dissecting a versioned file name. - * + * * @param filename the file name * @return the {@link Matcher} object * @deprecated see {@link #stripFilenameVersion(String)} diff --git a/src/main/java/org/scijava/util/FloatArray.java b/src/main/java/org/scijava/util/FloatArray.java index 1911dcd7a..1af9ce35e 100644 --- a/src/main/java/org/scijava/util/FloatArray.java +++ b/src/main/java/org/scijava/util/FloatArray.java @@ -6,13 +6,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,7 +33,7 @@ /** * An extensible array of {@code float} elements. - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -51,7 +51,7 @@ public FloatArray() { /** * Constructs an extensible array of floats, backed by a fixed-size array. - * + * * @param size the initial size */ public FloatArray(final int size) { @@ -61,7 +61,7 @@ public FloatArray(final int size) { /** * Constructs an extensible array of floats, backed by the given fixed-size * array. - * + * * @param array the array to wrap */ public FloatArray(final float[] array) { diff --git a/src/main/java/org/scijava/util/GenericUtils.java b/src/main/java/org/scijava/util/GenericUtils.java index f73fc78f6..08f6a3d95 100644 --- a/src/main/java/org/scijava/util/GenericUtils.java +++ b/src/main/java/org/scijava/util/GenericUtils.java @@ -6,13 +6,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 @@ -78,8 +78,8 @@ public static Type getFieldType(final Field field, final Class type) { } /** - * @deprecated Use {@link Types#fieldType(Field, Class)} and {@link Types#raws} - * instead. + * @deprecated Use {@link Types#fieldType(Field, Class)} and + * {@link Types#raws} instead. */ @Deprecated public static List> getFieldClasses(final Field field, @@ -97,7 +97,8 @@ public static Type getMethodReturnType(final Method method, } /** - * @deprecated Use {@link Types#methodReturnType} and {@link Types#raws} instead. + * @deprecated Use {@link Types#methodReturnType} and {@link Types#raws} + * instead. */ @Deprecated public static List> getMethodReturnClasses(final Method method, diff --git a/src/main/java/org/scijava/util/IntArray.java b/src/main/java/org/scijava/util/IntArray.java index 4916ca205..3ec581c15 100644 --- a/src/main/java/org/scijava/util/IntArray.java +++ b/src/main/java/org/scijava/util/IntArray.java @@ -6,13 +6,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,7 +33,7 @@ /** * An extensible array of {@code int} elements. - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -51,7 +51,7 @@ public IntArray() { /** * Constructs an extensible array of ints, backed by a fixed-size array. - * + * * @param size the initial size */ public IntArray(final int size) { @@ -61,7 +61,7 @@ public IntArray(final int size) { /** * Constructs an extensible array of ints, backed by the given fixed-size * array. - * + * * @param array the array to wrap */ public IntArray(final int[] array) { @@ -195,7 +195,8 @@ public boolean containsAll(final Collection c) { // NB: Overridden for performance. @Override - public boolean addAll(final int index, final Collection c) + public boolean addAll(final int index, + final Collection c) { if (c.size() == 0) return false; insert(index, c.size()); diff --git a/src/main/java/org/scijava/util/IntCoords.java b/src/main/java/org/scijava/util/IntCoords.java index 8110aa996..1e6cb91a7 100644 --- a/src/main/java/org/scijava/util/IntCoords.java +++ b/src/main/java/org/scijava/util/IntCoords.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ *

      * It exists mainly to avoid AWT references to {@link java.awt.Point}. *

      - * + * * @author Grant Harris * @author Curtis Rueden */ diff --git a/src/main/java/org/scijava/util/IntRect.java b/src/main/java/org/scijava/util/IntRect.java index be12b1035..63eb2077d 100644 --- a/src/main/java/org/scijava/util/IntRect.java +++ b/src/main/java/org/scijava/util/IntRect.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ *

      * It exists mainly to avoid AWT references to {@link java.awt.Rectangle}. *

      - * + * * @author Barry DeZonia */ public class IntRect { @@ -78,9 +78,8 @@ public boolean intersects(final IntRect r) { rh += ry; tw += tx; th += ty; - final boolean rtn = - (rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && - (th < ty || th > ry); + final boolean rtn = (rw < rx || rw > tx) && (rh < ry || rh > ty) && + (tw < tx || tw > rx) && (th < ty || th > ry); return rtn; } diff --git a/src/main/java/org/scijava/util/IteratorPlus.java b/src/main/java/org/scijava/util/IteratorPlus.java index 5a28e023d..c8a105074 100644 --- a/src/main/java/org/scijava/util/IteratorPlus.java +++ b/src/main/java/org/scijava/util/IteratorPlus.java @@ -6,13 +6,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 @@ -37,8 +37,8 @@ * {@link Enumeration}, {@link Iterator} or {@link Iterable} object can be * provided to the constructor, and the resultant {@code IteratorPlus} will * provide all three access mechanisms. In the case of {@link #iterator()} it - * simply returns {@code this}, for more convenient usage with for-each loops. Note, however, that because of this fact, multiple calls * to {#iterator()} will produce the same {@link Iterator} every time (in fact, * the {@link IteratorPlus} object itself). @@ -54,7 +54,7 @@ *

      * The same technique works with {@link Iterator}. *

      - * + * * @author Curtis Rueden */ public class IteratorPlus implements Enumeration, Iterator, diff --git a/src/main/java/org/scijava/util/LastRecentlyUsed.java b/src/main/java/org/scijava/util/LastRecentlyUsed.java index 83afb110f..330dbd2d2 100644 --- a/src/main/java/org/scijava/util/LastRecentlyUsed.java +++ b/src/main/java/org/scijava/util/LastRecentlyUsed.java @@ -6,13 +6,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 @@ -39,10 +39,11 @@ /** * A simple container for {@code N} last-recently-used items. - * + * * @author Johannes Schindelin */ public class LastRecentlyUsed implements Collection { + private final Object[] entries; private final Map map; /** @@ -73,9 +74,11 @@ public LastRecentlyUsed(int size) { /** * Given the index of an entry, returns the index of the next newer entry. - * - * @param index the index of the current entry, or -1 to wrap around to the oldest entry. - * @return the index of the next newer entry, or -1 when there is no such entry. + * + * @param index the index of the current entry, or -1 to wrap around to the + * oldest entry. + * @return the index of the next newer entry, or -1 when there is no such + * entry. */ public int next(int index) { return index < 0 ? bottom - 1 : next[index] - 1; @@ -83,9 +86,11 @@ public int next(int index) { /** * Given the index of an entry, returns the index of the next older entry. - * - * @param index the index of the current entry, or -1 to wrap around to the newest entry. - * @return the index of the next older entry, or -1 when there is no such entry. + * + * @param index the index of the current entry, or -1 to wrap around to the + * newest entry. + * @return the index of the next older entry, or -1 when there is no such + * entry. */ public int previous(int index) { return index < 0 ? top - 1 : previous[index] - 1; @@ -93,7 +98,7 @@ public int previous(int index) { /** * Returns the entry for the given index. - * + * * @param index the index of the entry * @return the entry */ @@ -104,7 +109,7 @@ public T get(int index) { /** * Looks up the index for a given entry. - * + * * @param value the value of the entry to find * @return the corresponding index, or {@code -1} if the entry was not found */ @@ -115,7 +120,7 @@ public int lookup(final T value) { /** * Add a new newest entry. - * + * * @param value the value of the entry * @return whether the entry was added */ @@ -130,7 +135,7 @@ public boolean add(final T value) { * This method helps recreating {@link LastRecentlyUsed} instances given the * entries in the order newest first, oldest last. *

      - * + * * @param value the value of the entry to add */ public void addToEnd(final T value) { @@ -205,7 +210,7 @@ public boolean removeAll(Collection values) { @Override public boolean retainAll(Collection values) { - for (int index = top - 1; index >= 0; ) { + for (int index = top - 1; index >= 0;) { final int prev = previous[index] - 1; if (!values.contains(get(index))) { remove(index); @@ -223,8 +228,8 @@ public int size() { @Override public Object[] toArray() { final Object[] result = new Object[size()]; - for (int i = 0, index = top - 1; index >= 0; i++, index = - previous[index] - 1) + for (int i = 0, index = top - 1; index >= 0; i++, index = previous[index] - + 1) { result[i] = get(index); } @@ -237,25 +242,25 @@ public S[] toArray(final S[] array) { final int size = size(); if (array.length >= size) { for (int i = 0, index = top - 1; index >= 0; i++, index = - previous[index] - 1) - { - array[i] = (S) get(index); - } - return array; - } - final S[] result = - (S[]) Array.newInstance(array.getClass().getComponentType(), size); - for (int i = 0, index = top - 1; index >= 0; i++, index = previous[index] - 1) { - result[i] = (S) get(index); + array[i] = (S) get(index); } - return result; + return array; + } + final S[] result = (S[]) Array.newInstance(array.getClass() + .getComponentType(), size); + for (int i = 0, index = top - 1; index >= 0; i++, index = previous[index] - + 1) + { + result[i] = (S) get(index); + } + return result; } /** * Returns an {@link Iterator}. - * + * * @return the iterator */ @Override @@ -279,7 +284,8 @@ public T next() { @Override public void remove() { - LastRecentlyUsed.this.remove(position == 0 ? top - 1 : next[position] - 1); + LastRecentlyUsed.this.remove(position == 0 ? top - 1 : next[position] - + 1); } }; @@ -288,7 +294,7 @@ public void remove() { // -- private methods private void remove(int position) { - assert(entries[position] != null); + assert (entries[position] != null); map.remove(entries[position]); entries[position] = null; if (next[position] == 0) { @@ -320,16 +326,17 @@ else if (map.size() == entries.length / 2) { else { insert = value.hashCode() % entries.length; if (insert < 0) insert += entries.length; - while (insert < entries.length && entries[insert] != null) insert++; + while (insert < entries.length && entries[insert] != null) + insert++; } add(insert, value, addAtEnd); return existing == null; } private void add(int position, T value, boolean atEnd) { - assert(next[position] == 0); - assert(previous[position] == 0); - assert(entries[position] == null); + assert (next[position] == 0); + assert (previous[position] == 0); + assert (entries[position] == null); map.put(value, position); entries[position] = value; @@ -352,41 +359,41 @@ private void add(int position, T value, boolean atEnd) { // For testing protected void assertConsistency() { if (top == 0) { - assert(bottom == 0); - assert(map.size() == 0); + assert (bottom == 0); + assert (map.size() == 0); for (int i = 0; i < entries.length; i++) { - assert(entries[i] == null); - assert(next[i] == 0); - assert(previous[i] == 0); + assert (entries[i] == null); + assert (next[i] == 0); + assert (previous[i] == 0); } return; } - assert(bottom != 0); + assert (bottom != 0); final Set indices = new HashSet<>(map.values()); - assert(indices.size() == map.size()); + assert (indices.size() == map.size()); for (int i = 0; i < entries.length; i++) { if (indices.contains(i)) { - assert(entries[i] != null); - assert(map.get(entries[i]) == i); + assert (entries[i] != null); + assert (map.get(entries[i]) == i); if (i == top - 1 || top == bottom) { - assert(next[i] == 0); + assert (next[i] == 0); } else { - assert(next[i] > 0); - assert(previous[next[i] - 1] == i + 1); + assert (next[i] > 0); + assert (previous[next[i] - 1] == i + 1); } if (i == bottom - 1 || top == bottom) { - assert(previous[i] == 0); + assert (previous[i] == 0); } else { - assert(previous[i] > 0); - assert(next[previous[i] - 1] == i + 1); + assert (previous[i] > 0); + assert (next[previous[i] - 1] == i + 1); } } else { - assert(entries[i] == null); - assert(next[i] == 0); - assert(previous[i] == 0); + assert (entries[i] == null); + assert (next[i] == 0); + assert (previous[i] == 0); } } } diff --git a/src/main/java/org/scijava/util/LineOutputStream.java b/src/main/java/org/scijava/util/LineOutputStream.java index 2f4ad2d19..72b0b366a 100644 --- a/src/main/java/org/scijava/util/LineOutputStream.java +++ b/src/main/java/org/scijava/util/LineOutputStream.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ * other methods in {@link OutputStream} are overridden in this class already to * buffer lines until they are complete and then flush them. *

      - * + * * @author Johannes Schindelin */ public abstract class LineOutputStream extends OutputStream { @@ -49,7 +49,7 @@ public abstract class LineOutputStream extends OutputStream { /** * This method is all that needs to be implemented. - * + * * @param line the line to print */ public abstract void println(String line) throws IOException; @@ -57,7 +57,7 @@ public abstract class LineOutputStream extends OutputStream { /** * Adds a single byte to the current line buffer, or {@link #flush()} the * current line if it is a new-line character. - * + * * @param b the byte to write */ @Override @@ -70,7 +70,7 @@ public synchronized void write(final int b) throws IOException { /** * Adds bytes to the current line buffer. Whenever a new-line character is * encountered, {@link #flush()} the current line buffer. - * + * * @param buf the bytes to write */ @Override @@ -81,13 +81,15 @@ public synchronized void write(final byte[] buf) throws IOException { /** * Adds bytes to the current line buffer. Whenever a new-line character is * encountered, {@link #flush()} the current line buffer. - * + * * @param buf the bytes to write * @param offset the offset into the buffer * @param length how many bytes to add */ @Override - public synchronized void write(final byte[] buf, int offset, int length) throws IOException { + public synchronized void write(final byte[] buf, int offset, int length) + throws IOException + { int eol = length; while (eol > 0) { if (buf[eol - 1] == '\n') break; @@ -128,7 +130,7 @@ public synchronized void flush() throws IOException { /** * Increases the size of the line buffer if necessary. - * + * * @param length the required minimal length */ protected synchronized void ensure(final int length) { diff --git a/src/main/java/org/scijava/util/ListUtils.java b/src/main/java/org/scijava/util/ListUtils.java index e423fa616..34023b9f1 100644 --- a/src/main/java/org/scijava/util/ListUtils.java +++ b/src/main/java/org/scijava/util/ListUtils.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * Useful methods for working with {@link List}s. - * + * * @author Curtis Rueden */ public final class ListUtils { @@ -57,7 +57,7 @@ public static T first(final List list) { * The list elements will be separated by a comma then a space. The list will * be enclosed in square brackets. *

      - * + * * @param list The list to stringify. * @see #string(List, String, String, String, boolean) */ @@ -72,7 +72,7 @@ public static String string(final List list) { * be enclosed in square brackets unless it is a singleton with the * {@code encloseSingletons} flag set to false. *

      - * + * * @param list The list to stringify. * @param encloseSingletons Whether to enclose singleton lists in brackets. * @return The stringified list. @@ -91,7 +91,7 @@ public static String string(final List list, * brackets unless the list is a singleton with the {@code encloseSingletons} * flag set to false. *

      - * + * * @param list The list to stringify. * @param lDelimiter The left-hand symbol(s) in which to enclose the list. * @param rDelimiter The right-hand symbol(s) in which to enclose the list. diff --git a/src/main/java/org/scijava/util/LongArray.java b/src/main/java/org/scijava/util/LongArray.java index 351580338..9a7f3e1e0 100644 --- a/src/main/java/org/scijava/util/LongArray.java +++ b/src/main/java/org/scijava/util/LongArray.java @@ -6,13 +6,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,7 +33,7 @@ /** * An extensible array of {@code long} elements. - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -51,7 +51,7 @@ public LongArray() { /** * Constructs an extensible array of longs, backed by a fixed-size array. - * + * * @param size the initial size */ public LongArray(final int size) { @@ -61,7 +61,7 @@ public LongArray(final int size) { /** * Constructs an extensible array of longs, backed by the given fixed-size * array. - * + * * @param array the array to wrap */ public LongArray(final long[] array) { diff --git a/src/main/java/org/scijava/util/Manifest.java b/src/main/java/org/scijava/util/Manifest.java index 6e4cd5dd3..4fae7d4ab 100644 --- a/src/main/java/org/scijava/util/Manifest.java +++ b/src/main/java/org/scijava/util/Manifest.java @@ -6,13 +6,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 @@ -42,7 +42,7 @@ /** * Helper class for working with JAR manifests. - * + * * @author Curtis Rueden */ public class Manifest implements Versioned { diff --git a/src/main/java/org/scijava/util/MersenneTwisterFast.java b/src/main/java/org/scijava/util/MersenneTwisterFast.java index 9bad0ab73..85a94e054 100644 --- a/src/main/java/org/scijava/util/MersenneTwisterFast.java +++ b/src/main/java/org/scijava/util/MersenneTwisterFast.java @@ -6,13 +6,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 @@ -181,1248 +181,1198 @@ * @version 17 */ @SuppressWarnings("all") -public strictfp class MersenneTwisterFast implements Serializable, Cloneable - { - - // Note: this class is hard-inlined in all of its methods. This makes some - // of the methods well-nigh unreadable in their complexity. In fact, the - // Mersenne Twister is fairly easy code to understand: if you're trying to - // get a handle on the code, I strongly suggest looking at - // MersenneTwister.java first. - // -- Sean - - // Serialization - private static final long serialVersionUID = -8219700664442619525L; // locked as of Version 15 - - // Period parameters - private static final int N = 624; - private static final int M = 397; - private static final int MATRIX_A = 0x9908b0df; // private static final * constant vector a - private static final int UPPER_MASK = 0x80000000; // most significant w-r bits - private static final int LOWER_MASK = 0x7fffffff; // least significant r bits - - - // Tempering parameters - private static final int TEMPERING_MASK_B = 0x9d2c5680; - private static final int TEMPERING_MASK_C = 0xefc60000; - - private int mt[]; // the array for the state vector - private int mti; // mti==N+1 means mt[N] is not initialized - private int mag01[]; - - // a good initial seed (of int size, though stored in a long) - //private static final long GOOD_SEED = 4357; - - private double __nextNextGaussian; - private boolean __haveNextNextGaussian; - - /* We're overriding all internal data, to my knowledge, so this should be okay */ - @Override - public Object clone() - { - try - { - MersenneTwisterFast f = (MersenneTwisterFast)(super.clone()); - f.mt = (int[])(mt.clone()); - f.mag01 = (int[])(mag01.clone()); - return f; - } - catch (CloneNotSupportedException e) { throw new InternalError(); } // should never happen - } - - public boolean stateEquals(Object o) - { - if (o==this) return true; - if (o == null || !(o instanceof MersenneTwisterFast)) - return false; - MersenneTwisterFast other = (MersenneTwisterFast) o; - if (mti != other.mti) return false; - for(int x=0;x>> 30)) + mti); - /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ - /* In the previous versions, MSBs of the seed affect */ - /* only MSBs of the array mt[]. */ - /* 2002/01/09 modified by Makoto Matsumoto */ - mt[mti] &= 0xffffffff; - /* for >32 bit machines */ - } - } - - - /** - * Sets the seed of the MersenneTwister using an array of integers. - * Your array must have a non-zero length. Only the first 624 integers - * in the array are used; if the array is shorter than this then - * integers are repeatedly used in a wrap-around fashion. - */ - - synchronized public void setSeed(final int[] array) - { - if (array.length == 0) - throw new IllegalArgumentException("Array length must be greater than zero"); - int i, j, k; - setSeed(19650218); - i=1; j=0; - k = (N>array.length ? N : array.length); - for (; k!=0; k--) - { - mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >>> 30)) * 1664525)) + array[j] + j; /* non linear */ - mt[i] &= 0xffffffff; /* for WORDSIZE > 32 machines */ - i++; - j++; - if (i>=N) { mt[0] = mt[N-1]; i=1; } - if (j>=array.length) j=0; - } - for (k=N-1; k!=0; k--) - { - mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >>> 30)) * 1566083941)) - i; /* non linear */ - mt[i] &= 0xffffffff; /* for WORDSIZE > 32 machines */ - i++; - if (i>=N) - { - mt[0] = mt[N-1]; i=1; - } - } - mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */ - } - - - public final int nextInt() - { - int y; - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - return y; - } - - - - public final short nextShort() - { - int y; - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - return (short)(y >>> 16); - } - - - - public final char nextChar() - { - int y; - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - return (char)(y >>> 16); - } - - - public final boolean nextBoolean() - { - int y; - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - return (boolean)((y >>> 31) != 0); - } - - - - /** This generates a coin flip with a probability probability - of returning true, else returning false. probability must - be between 0.0 and 1.0, inclusive. Not as precise a random real - event as nextBoolean(double), but twice as fast. To explicitly - use this, remember you may need to cast to float first. */ - - public final boolean nextBoolean(final float probability) - { - int y; - - if (probability < 0.0f || probability > 1.0f) - throw new IllegalArgumentException ("probability must be between 0.0 and 1.0 inclusive."); - if (probability==0.0f) return false; // fix half-open issues - else if (probability==1.0f) return true; // fix half-open issues - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - return (y >>> 8) / ((float)(1 << 24)) < probability; - } - - - /** This generates a coin flip with a probability probability - of returning true, else returning false. probability must - be between 0.0 and 1.0, inclusive. */ - - public final boolean nextBoolean(final double probability) - { - int y; - int z; - - if (probability < 0.0 || probability > 1.0) - throw new IllegalArgumentException ("probability must be between 0.0 and 1.0 inclusive."); - if (probability==0.0) return false; // fix half-open issues - else if (probability==1.0) return true; // fix half-open issues - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - z = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (z >>> 1) ^ mag01[z & 0x1]; - } - for (; kk < N-1; kk++) - { - z = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (z >>> 1) ^ mag01[z & 0x1]; - } - z = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (z >>> 1) ^ mag01[z & 0x1]; - - mti = 0; - } - - z = mt[mti++]; - z ^= z >>> 11; // TEMPERING_SHIFT_U(z) - z ^= (z << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(z) - z ^= (z << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(z) - z ^= (z >>> 18); // TEMPERING_SHIFT_L(z) - - /* derived from nextDouble documentation in jdk 1.2 docs, see top */ - return ((((long)(y >>> 6)) << 27) + (z >>> 5)) / (double)(1L << 53) < probability; - } - - - public final byte nextByte() - { - int y; - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - return (byte)(y >>> 24); - } - - - public final void nextBytes(byte[] bytes) - { - int y; - - for (int x=0;x= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - bytes[x] = (byte)(y >>> 24); - } - } - - - public final long nextLong() - { - int y; - int z; - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - z = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (z >>> 1) ^ mag01[z & 0x1]; - } - for (; kk < N-1; kk++) - { - z = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (z >>> 1) ^ mag01[z & 0x1]; - } - z = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (z >>> 1) ^ mag01[z & 0x1]; - - mti = 0; - } - - z = mt[mti++]; - z ^= z >>> 11; // TEMPERING_SHIFT_U(z) - z ^= (z << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(z) - z ^= (z << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(z) - z ^= (z >>> 18); // TEMPERING_SHIFT_L(z) - - return (((long)y) << 32) + (long)z; - } - - - - /** Returns a long drawn uniformly from 0 to n-1. Suffice it to say, - n must be > 0, or an IllegalArgumentException is raised. */ - public final long nextLong(final long n) - { - if (n<=0) - throw new IllegalArgumentException("n must be positive, got: " + n); - - long bits, val; - do - { - int y; - int z; - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - z = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (z >>> 1) ^ mag01[z & 0x1]; - } - for (; kk < N-1; kk++) - { - z = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (z >>> 1) ^ mag01[z & 0x1]; - } - z = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (z >>> 1) ^ mag01[z & 0x1]; - - mti = 0; - } - - z = mt[mti++]; - z ^= z >>> 11; // TEMPERING_SHIFT_U(z) - z ^= (z << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(z) - z ^= (z << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(z) - z ^= (z >>> 18); // TEMPERING_SHIFT_L(z) - - bits = (((((long)y) << 32) + (long)z) >>> 1); - val = bits % n; - } while (bits - val + (n-1) < 0); - return val; - } - - /** Returns a random double in the half-open range from [0.0,1.0). Thus 0.0 is a valid - result but 1.0 is not. */ - public final double nextDouble() - { - int y; - int z; - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - z = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (z >>> 1) ^ mag01[z & 0x1]; - } - for (; kk < N-1; kk++) - { - z = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (z >>> 1) ^ mag01[z & 0x1]; - } - z = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (z >>> 1) ^ mag01[z & 0x1]; - - mti = 0; - } - - z = mt[mti++]; - z ^= z >>> 11; // TEMPERING_SHIFT_U(z) - z ^= (z << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(z) - z ^= (z << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(z) - z ^= (z >>> 18); // TEMPERING_SHIFT_L(z) - - /* derived from nextDouble documentation in jdk 1.2 docs, see top */ - return ((((long)(y >>> 6)) << 27) + (z >>> 5)) / (double)(1L << 53); - } - - - - /** Returns a double in the range from 0.0 to 1.0, possibly inclusive of 0.0 and 1.0 themselves. Thus: - - - - - - - -
      ExpressionInterval
      nextDouble(false, false)(0.0, 1.0)
      nextDouble(true, false)[0.0, 1.0)
      nextDouble(false, true)(0.0, 1.0]
      nextDouble(true, true)[0.0, 1.0]
      - -

      This version preserves all possible random values in the double range. - */ - public double nextDouble(boolean includeZero, boolean includeOne) - { - double d = 0.0; - do - { - d = nextDouble(); // grab a value, initially from half-open [0.0, 1.0) - if (includeOne && nextBoolean()) d += 1.0; // if includeOne, with 1/2 probability, push to [1.0, 2.0) - } - while ( (d > 1.0) || // everything above 1.0 is always invalid - (!includeZero && d == 0.0)); // if we're not including zero, 0.0 is invalid - return d; - } - - - - public final double nextGaussian() - { - if (__haveNextNextGaussian) - { - __haveNextNextGaussian = false; - return __nextNextGaussian; - } - else - { - double v1, v2, s; - do - { - int y; - int z; - int a; - int b; - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - z = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (z >>> 1) ^ mag01[z & 0x1]; - } - for (; kk < N-1; kk++) - { - z = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (z >>> 1) ^ mag01[z & 0x1]; - } - z = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (z >>> 1) ^ mag01[z & 0x1]; - - mti = 0; - } - - z = mt[mti++]; - z ^= z >>> 11; // TEMPERING_SHIFT_U(z) - z ^= (z << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(z) - z ^= (z << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(z) - z ^= (z >>> 18); // TEMPERING_SHIFT_L(z) - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - a = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (a >>> 1) ^ mag01[a & 0x1]; - } - for (; kk < N-1; kk++) - { - a = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (a >>> 1) ^ mag01[a & 0x1]; - } - a = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (a >>> 1) ^ mag01[a & 0x1]; - - mti = 0; - } - - a = mt[mti++]; - a ^= a >>> 11; // TEMPERING_SHIFT_U(a) - a ^= (a << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(a) - a ^= (a << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(a) - a ^= (a >>> 18); // TEMPERING_SHIFT_L(a) - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - b = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (b >>> 1) ^ mag01[b & 0x1]; - } - for (; kk < N-1; kk++) - { - b = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (b >>> 1) ^ mag01[b & 0x1]; - } - b = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (b >>> 1) ^ mag01[b & 0x1]; - - mti = 0; - } - - b = mt[mti++]; - b ^= b >>> 11; // TEMPERING_SHIFT_U(b) - b ^= (b << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(b) - b ^= (b << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(b) - b ^= (b >>> 18); // TEMPERING_SHIFT_L(b) - - /* derived from nextDouble documentation in jdk 1.2 docs, see top */ - v1 = 2 * - (((((long)(y >>> 6)) << 27) + (z >>> 5)) / (double)(1L << 53)) - - 1; - v2 = 2 * (((((long)(a >>> 6)) << 27) + (b >>> 5)) / (double)(1L << 53)) - - 1; - s = v1 * v1 + v2 * v2; - } while (s >= 1 || s==0); - double multiplier = StrictMath.sqrt(-2 * StrictMath.log(s)/s); - __nextNextGaussian = v2 * multiplier; - __haveNextNextGaussian = true; - return v1 * multiplier; - } - } - - - - - - /** Returns a random float in the half-open range from [0.0f,1.0f). Thus 0.0f is a valid - result but 1.0f is not. */ - public final float nextFloat() - { - int y; - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - return (y >>> 8) / ((float)(1 << 24)); - } - - - /** Returns a float in the range from 0.0f to 1.0f, possibly inclusive of 0.0f and 1.0f themselves. Thus: - - - - - - - -
      ExpressionInterval
      nextFloat(false, false)(0.0f, 1.0f)
      nextFloat(true, false)[0.0f, 1.0f)
      nextFloat(false, true)(0.0f, 1.0f]
      nextFloat(true, true)[0.0f, 1.0f]
      - -

      This version preserves all possible random values in the float range. - */ - public double nextFloat(boolean includeZero, boolean includeOne) - { - float d = 0.0f; - do - { - d = nextFloat(); // grab a value, initially from half-open [0.0f, 1.0f) - if (includeOne && nextBoolean()) d += 1.0f; // if includeOne, with 1/2 probability, push to [1.0f, 2.0f) - } - while ( (d > 1.0f) || // everything above 1.0f is always invalid - (!includeZero && d == 0.0f)); // if we're not including zero, 0.0f is invalid - return d; - } - - - - /** Returns an integer drawn uniformly from 0 to n-1. Suffice it to say, - n must be > 0, or an IllegalArgumentException is raised. */ - public final int nextInt(final int n) - { - if (n<=0) - throw new IllegalArgumentException("n must be positive, got: " + n); - - if ((n & -n) == n) // i.e., n is a power of 2 - { - int y; - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - return (int)((n * (long) (y >>> 1) ) >> 31); - } - - int bits, val; - do - { - int y; - - if (mti >= N) // generate N words at one time - { - int kk; - final int[] mt = this.mt; // locals are slightly faster - final int[] mag01 = this.mag01; // locals are slightly faster - - for (kk = 0; kk < N - M; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) - { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= y >>> 11; // TEMPERING_SHIFT_U(y) - y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) - y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) - y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) - - bits = (y >>> 1); - val = bits % n; - } while(bits - val + (n-1) < 0); - return val; - } - - - /** - * Tests the code. - */ - public static void main(String args[]) - { - int j; - - MersenneTwisterFast r; - - // CORRECTNESS TEST - // COMPARE WITH http://www.math.keio.ac.jp/matumoto/CODES/MT2002/mt19937ar.out - - r = new MersenneTwisterFast(new int[]{0x123, 0x234, 0x345, 0x456}); - System.out.println("Output of MersenneTwisterFast with new (2002/1/26) seeding mechanism"); - for (j=0;j<1000;j++) - { - // first, convert the int from signed to "unsigned" - long l = (long)r.nextInt(); - if (l < 0 ) l += 4294967296L; // max int value - String s = String.valueOf(l); - while(s.length() < 10) s = " " + s; // buffer - System.out.print(s + " "); - if (j%5==4) System.out.println(); - } - - // SPEED TEST - - final long SEED = 4357; - - int xx; long ms; - System.out.println("\nTime to test grabbing 100000000 ints"); - - Random rr = new Random(SEED); - xx = 0; - ms = System.currentTimeMillis(); - for (j = 0; j < 100000000; j++) - xx += rr.nextInt(); - System.out.println("java.util.Random: " + (System.currentTimeMillis()-ms) + " Ignore this: " + xx); - - r = new MersenneTwisterFast(SEED); - ms = System.currentTimeMillis(); - xx=0; - for (j = 0; j < 100000000; j++) - xx += r.nextInt(); - System.out.println("Mersenne Twister Fast: " + (System.currentTimeMillis()-ms) + " Ignore this: " + xx); - - // TEST TO COMPARE TYPE CONVERSION BETWEEN - // MersenneTwisterFast.java AND MersenneTwister.java - - System.out.println("\nGrab the first 1000 booleans"); - r = new MersenneTwisterFast(SEED); - for (j = 0; j < 1000; j++) - { - System.out.print(r.nextBoolean() + " "); - if (j%8==7) System.out.println(); - } - if (!(j%8==7)) System.out.println(); - - System.out.println("\nGrab 1000 booleans of increasing probability using nextBoolean(double)"); - r = new MersenneTwisterFast(SEED); - for (j = 0; j < 1000; j++) - { - System.out.print(r.nextBoolean((double)(j/999.0)) + " "); - if (j%8==7) System.out.println(); - } - if (!(j%8==7)) System.out.println(); - - System.out.println("\nGrab 1000 booleans of increasing probability using nextBoolean(float)"); - r = new MersenneTwisterFast(SEED); - for (j = 0; j < 1000; j++) - { - System.out.print(r.nextBoolean((float)(j/999.0f)) + " "); - if (j%8==7) System.out.println(); - } - if (!(j%8==7)) System.out.println(); - - byte[] bytes = new byte[1000]; - System.out.println("\nGrab the first 1000 bytes using nextBytes"); - r = new MersenneTwisterFast(SEED); - r.nextBytes(bytes); - for (j = 0; j < 1000; j++) - { - System.out.print(bytes[j] + " "); - if (j%16==15) System.out.println(); - } - if (!(j%16==15)) System.out.println(); - - byte b; - System.out.println("\nGrab the first 1000 bytes -- must be same as nextBytes"); - r = new MersenneTwisterFast(SEED); - for (j = 0; j < 1000; j++) - { - System.out.print((b = r.nextByte()) + " "); - if (b!=bytes[j]) System.out.print("BAD "); - if (j%16==15) System.out.println(); - } - if (!(j%16==15)) System.out.println(); - - System.out.println("\nGrab the first 1000 shorts"); - r = new MersenneTwisterFast(SEED); - for (j = 0; j < 1000; j++) - { - System.out.print(r.nextShort() + " "); - if (j%8==7) System.out.println(); - } - if (!(j%8==7)) System.out.println(); - - System.out.println("\nGrab the first 1000 ints"); - r = new MersenneTwisterFast(SEED); - for (j = 0; j < 1000; j++) - { - System.out.print(r.nextInt() + " "); - if (j%4==3) System.out.println(); - } - if (!(j%4==3)) System.out.println(); - - System.out.println("\nGrab the first 1000 ints of different sizes"); - r = new MersenneTwisterFast(SEED); - int max = 1; - for (j = 0; j < 1000; j++) - { - System.out.print(r.nextInt(max) + " "); - max *= 2; - if (max <= 0) max = 1; - if (j%4==3) System.out.println(); - } - if (!(j%4==3)) System.out.println(); - - System.out.println("\nGrab the first 1000 longs"); - r = new MersenneTwisterFast(SEED); - for (j = 0; j < 1000; j++) - { - System.out.print(r.nextLong() + " "); - if (j%3==2) System.out.println(); - } - if (!(j%3==2)) System.out.println(); - - System.out.println("\nGrab the first 1000 longs of different sizes"); - r = new MersenneTwisterFast(SEED); - long max2 = 1; - for (j = 0; j < 1000; j++) - { - System.out.print(r.nextLong(max2) + " "); - max2 *= 2; - if (max2 <= 0) max2 = 1; - if (j%4==3) System.out.println(); - } - if (!(j%4==3)) System.out.println(); - - System.out.println("\nGrab the first 1000 floats"); - r = new MersenneTwisterFast(SEED); - for (j = 0; j < 1000; j++) - { - System.out.print(r.nextFloat() + " "); - if (j%4==3) System.out.println(); - } - if (!(j%4==3)) System.out.println(); - - System.out.println("\nGrab the first 1000 doubles"); - r = new MersenneTwisterFast(SEED); - for (j = 0; j < 1000; j++) - { - System.out.print(r.nextDouble() + " "); - if (j%3==2) System.out.println(); - } - if (!(j%3==2)) System.out.println(); - - System.out.println("\nGrab the first 1000 gaussian doubles"); - r = new MersenneTwisterFast(SEED); - for (j = 0; j < 1000; j++) - { - System.out.print(r.nextGaussian() + " "); - if (j%3==2) System.out.println(); - } - if (!(j%3==2)) System.out.println(); - - } - } +public strictfp class MersenneTwisterFast implements Serializable, Cloneable { + + // Note: this class is hard-inlined in all of its methods. This makes some + // of the methods well-nigh unreadable in their complexity. In fact, the + // Mersenne Twister is fairly easy code to understand: if you're trying to + // get a handle on the code, I strongly suggest looking at + // MersenneTwister.java first. + // -- Sean + + // Serialization + private static final long serialVersionUID = -8219700664442619525L; // locked + // as of + // Version + // 15 + + // Period parameters + private static final int N = 624; + private static final int M = 397; + private static final int MATRIX_A = 0x9908b0df; // private static final * + // constant vector a + private static final int UPPER_MASK = 0x80000000; // most significant w-r bits + private static final int LOWER_MASK = 0x7fffffff; // least significant r bits + + // Tempering parameters + private static final int TEMPERING_MASK_B = 0x9d2c5680; + private static final int TEMPERING_MASK_C = 0xefc60000; + + private int mt[]; // the array for the state vector + private int mti; // mti==N+1 means mt[N] is not initialized + private int mag01[]; + + // a good initial seed (of int size, though stored in a long) + // private static final long GOOD_SEED = 4357; + + private double __nextNextGaussian; + private boolean __haveNextNextGaussian; + + /* We're overriding all internal data, to my knowledge, so this should be okay */ + @Override + public Object clone() { + try { + MersenneTwisterFast f = (MersenneTwisterFast) (super.clone()); + f.mt = (int[]) (mt.clone()); + f.mag01 = (int[]) (mag01.clone()); + return f; + } + catch (CloneNotSupportedException e) { + throw new InternalError(); + } // should never happen + } + + public boolean stateEquals(Object o) { + if (o == this) return true; + if (o == null || !(o instanceof MersenneTwisterFast)) return false; + MersenneTwisterFast other = (MersenneTwisterFast) o; + if (mti != other.mti) return false; + for (int x = 0; x < mag01.length; x++) + if (mag01[x] != other.mag01[x]) return false; + for (int x = 0; x < mt.length; x++) + if (mt[x] != other.mt[x]) return false; + return true; + } + + /** Reads the entire state of the MersenneTwister RNG from the stream */ + public void readState(DataInputStream stream) throws IOException { + int len = mt.length; + for (int x = 0; x < len; x++) + mt[x] = stream.readInt(); + + len = mag01.length; + for (int x = 0; x < len; x++) + mag01[x] = stream.readInt(); + + mti = stream.readInt(); + __nextNextGaussian = stream.readDouble(); + __haveNextNextGaussian = stream.readBoolean(); + } + + /** Writes the entire state of the MersenneTwister RNG to the stream */ + public void writeState(DataOutputStream stream) throws IOException { + int len = mt.length; + for (int x = 0; x < len; x++) + stream.writeInt(mt[x]); + + len = mag01.length; + for (int x = 0; x < len; x++) + stream.writeInt(mag01[x]); + + stream.writeInt(mti); + stream.writeDouble(__nextNextGaussian); + stream.writeBoolean(__haveNextNextGaussian); + } + + /** + * Constructor using the default seed. + */ + public MersenneTwisterFast() { + this(System.currentTimeMillis()); + } + + /** + * Constructor using a given seed. Though you pass this seed in as a long, + * it's best to make sure it's actually an integer. + */ + public MersenneTwisterFast(final long seed) { + setSeed(seed); + } + + /** + * Constructor using an array of integers as seed. Your array must have a + * non-zero length. Only the first 624 integers in the array are used; if the + * array is shorter than this then integers are repeatedly used in a + * wrap-around fashion. + */ + public MersenneTwisterFast(final int[] array) { + setSeed(array); + } + + /** + * Initalize the pseudo random number generator. Don't pass in a long that's + * bigger than an int (Mersenne Twister only uses the first 32 bits for its + * seed). + */ + + synchronized public void setSeed(final long seed) { + // Due to a bug in java.util.Random clear up to 1.2, we're + // doing our own Gaussian variable. + __haveNextNextGaussian = false; + + mt = new int[N]; + + mag01 = new int[2]; + mag01[0] = 0x0; + mag01[1] = MATRIX_A; + + mt[0] = (int) (seed & 0xffffffff); + for (mti = 1; mti < N; mti++) { + mt[mti] = (1812433253 * (mt[mti - 1] ^ (mt[mti - 1] >>> 30)) + mti); + /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ + /* In the previous versions, MSBs of the seed affect */ + /* only MSBs of the array mt[]. */ + /* 2002/01/09 modified by Makoto Matsumoto */ + mt[mti] &= 0xffffffff; + /* for >32 bit machines */ + } + } + + /** + * Sets the seed of the MersenneTwister using an array of integers. Your array + * must have a non-zero length. Only the first 624 integers in the array are + * used; if the array is shorter than this then integers are repeatedly used + * in a wrap-around fashion. + */ + + synchronized public void setSeed(final int[] array) { + if (array.length == 0) throw new IllegalArgumentException( + "Array length must be greater than zero"); + int i, j, k; + setSeed(19650218); + i = 1; + j = 0; + k = (N > array.length ? N : array.length); + for (; k != 0; k--) { + mt[i] = (mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >>> 30)) * 1664525)) + + array[j] + j; /* non linear */ + mt[i] &= 0xffffffff; /* for WORDSIZE > 32 machines */ + i++; + j++; + if (i >= N) { + mt[0] = mt[N - 1]; + i = 1; + } + if (j >= array.length) j = 0; + } + for (k = N - 1; k != 0; k--) { + mt[i] = (mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >>> 30)) * 1566083941)) - + i; /* non linear */ + mt[i] &= 0xffffffff; /* for WORDSIZE > 32 machines */ + i++; + if (i >= N) { + mt[0] = mt[N - 1]; + i = 1; + } + } + mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */ + } + + public final int nextInt() { + int y; + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + return y; + } + + public final short nextShort() { + int y; + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + return (short) (y >>> 16); + } + + public final char nextChar() { + int y; + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + return (char) (y >>> 16); + } + + public final boolean nextBoolean() { + int y; + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + return (boolean) ((y >>> 31) != 0); + } + + /** + * This generates a coin flip with a probability probability of + * returning true, else returning false. probability must be between + * 0.0 and 1.0, inclusive. Not as precise a random real event as + * nextBoolean(double), but twice as fast. To explicitly use this, remember + * you may need to cast to float first. + */ + + public final boolean nextBoolean(final float probability) { + int y; + + if (probability < 0.0f || probability > 1.0f) + throw new IllegalArgumentException( + "probability must be between 0.0 and 1.0 inclusive."); + if (probability == 0.0f) return false; // fix half-open issues + else if (probability == 1.0f) return true; // fix half-open issues + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + return (y >>> 8) / ((float) (1 << 24)) < probability; + } + + /** + * This generates a coin flip with a probability probability of + * returning true, else returning false. probability must be between + * 0.0 and 1.0, inclusive. + */ + + public final boolean nextBoolean(final double probability) { + int y; + int z; + + if (probability < 0.0 || probability > 1.0) + throw new IllegalArgumentException( + "probability must be between 0.0 and 1.0 inclusive."); + if (probability == 0.0) return false; // fix half-open issues + else if (probability == 1.0) return true; // fix half-open issues + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + z = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (z >>> 1) ^ mag01[z & 0x1]; + } + for (; kk < N - 1; kk++) { + z = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (z >>> 1) ^ mag01[z & 0x1]; + } + z = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (z >>> 1) ^ mag01[z & 0x1]; + + mti = 0; + } + + z = mt[mti++]; + z ^= z >>> 11; // TEMPERING_SHIFT_U(z) + z ^= (z << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(z) + z ^= (z << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(z) + z ^= (z >>> 18); // TEMPERING_SHIFT_L(z) + + /* derived from nextDouble documentation in jdk 1.2 docs, see top */ + return ((((long) (y >>> 6)) << 27) + (z >>> 5)) / + (double) (1L << 53) < probability; + } + + public final byte nextByte() { + int y; + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + return (byte) (y >>> 24); + } + + public final void nextBytes(byte[] bytes) { + int y; + + for (int x = 0; x < bytes.length; x++) { + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + bytes[x] = (byte) (y >>> 24); + } + } + + public final long nextLong() { + int y; + int z; + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + z = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (z >>> 1) ^ mag01[z & 0x1]; + } + for (; kk < N - 1; kk++) { + z = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (z >>> 1) ^ mag01[z & 0x1]; + } + z = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (z >>> 1) ^ mag01[z & 0x1]; + + mti = 0; + } + + z = mt[mti++]; + z ^= z >>> 11; // TEMPERING_SHIFT_U(z) + z ^= (z << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(z) + z ^= (z << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(z) + z ^= (z >>> 18); // TEMPERING_SHIFT_L(z) + + return (((long) y) << 32) + (long) z; + } + + /** + * Returns a long drawn uniformly from 0 to n-1. Suffice it to say, n must be + * > 0, or an IllegalArgumentException is raised. + */ + public final long nextLong(final long n) { + if (n <= 0) throw new IllegalArgumentException("n must be positive, got: " + + n); + + long bits, val; + do { + int y; + int z; + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + z = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (z >>> 1) ^ mag01[z & 0x1]; + } + for (; kk < N - 1; kk++) { + z = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (z >>> 1) ^ mag01[z & 0x1]; + } + z = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (z >>> 1) ^ mag01[z & 0x1]; + + mti = 0; + } + + z = mt[mti++]; + z ^= z >>> 11; // TEMPERING_SHIFT_U(z) + z ^= (z << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(z) + z ^= (z << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(z) + z ^= (z >>> 18); // TEMPERING_SHIFT_L(z) + + bits = (((((long) y) << 32) + (long) z) >>> 1); + val = bits % n; + } + while (bits - val + (n - 1) < 0); + return val; + } + + /** + * Returns a random double in the half-open range from [0.0,1.0). Thus 0.0 is + * a valid result but 1.0 is not. + */ + public final double nextDouble() { + int y; + int z; + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + z = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (z >>> 1) ^ mag01[z & 0x1]; + } + for (; kk < N - 1; kk++) { + z = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (z >>> 1) ^ mag01[z & 0x1]; + } + z = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (z >>> 1) ^ mag01[z & 0x1]; + + mti = 0; + } + + z = mt[mti++]; + z ^= z >>> 11; // TEMPERING_SHIFT_U(z) + z ^= (z << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(z) + z ^= (z << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(z) + z ^= (z >>> 18); // TEMPERING_SHIFT_L(z) + + /* derived from nextDouble documentation in jdk 1.2 docs, see top */ + return ((((long) (y >>> 6)) << 27) + (z >>> 5)) / (double) (1L << 53); + } + + /** + * Returns a double in the range from 0.0 to 1.0, possibly inclusive of 0.0 + * and 1.0 themselves. Thus: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
      ExpressionInterval
      nextDouble(false, false)(0.0, 1.0)
      nextDouble(true, false)[0.0, 1.0)
      nextDouble(false, true)(0.0, 1.0]
      nextDouble(true, true)[0.0, 1.0]
      + *

      + * This version preserves all possible random values in the double range. + */ + public double nextDouble(boolean includeZero, boolean includeOne) { + double d = 0.0; + do { + d = nextDouble(); // grab a value, initially from half-open [0.0, 1.0) + if (includeOne && nextBoolean()) d += 1.0; // if includeOne, with 1/2 + // probability, push to [1.0, + // 2.0) + } + while ((d > 1.0) || // everything above 1.0 is always invalid + (!includeZero && d == 0.0)); // if we're not including zero, 0.0 is + // invalid + return d; + } + + public final double nextGaussian() { + if (__haveNextNextGaussian) { + __haveNextNextGaussian = false; + return __nextNextGaussian; + } + else { + double v1, v2, s; + do { + int y; + int z; + int a; + int b; + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + z = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (z >>> 1) ^ mag01[z & 0x1]; + } + for (; kk < N - 1; kk++) { + z = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (z >>> 1) ^ mag01[z & 0x1]; + } + z = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (z >>> 1) ^ mag01[z & 0x1]; + + mti = 0; + } + + z = mt[mti++]; + z ^= z >>> 11; // TEMPERING_SHIFT_U(z) + z ^= (z << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(z) + z ^= (z << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(z) + z ^= (z >>> 18); // TEMPERING_SHIFT_L(z) + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + a = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (a >>> 1) ^ mag01[a & 0x1]; + } + for (; kk < N - 1; kk++) { + a = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (a >>> 1) ^ mag01[a & 0x1]; + } + a = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (a >>> 1) ^ mag01[a & 0x1]; + + mti = 0; + } + + a = mt[mti++]; + a ^= a >>> 11; // TEMPERING_SHIFT_U(a) + a ^= (a << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(a) + a ^= (a << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(a) + a ^= (a >>> 18); // TEMPERING_SHIFT_L(a) + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + b = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (b >>> 1) ^ mag01[b & 0x1]; + } + for (; kk < N - 1; kk++) { + b = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (b >>> 1) ^ mag01[b & 0x1]; + } + b = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (b >>> 1) ^ mag01[b & 0x1]; + + mti = 0; + } + + b = mt[mti++]; + b ^= b >>> 11; // TEMPERING_SHIFT_U(b) + b ^= (b << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(b) + b ^= (b << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(b) + b ^= (b >>> 18); // TEMPERING_SHIFT_L(b) + + /* derived from nextDouble documentation in jdk 1.2 docs, see top */ + v1 = 2 * (((((long) (y >>> 6)) << 27) + (z >>> 5)) / + (double) (1L << 53)) - 1; + v2 = 2 * (((((long) (a >>> 6)) << 27) + (b >>> 5)) / + (double) (1L << 53)) - 1; + s = v1 * v1 + v2 * v2; + } + while (s >= 1 || s == 0); + double multiplier = StrictMath.sqrt(-2 * StrictMath.log(s) / s); + __nextNextGaussian = v2 * multiplier; + __haveNextNextGaussian = true; + return v1 * multiplier; + } + } + + /** + * Returns a random float in the half-open range from [0.0f,1.0f). Thus 0.0f + * is a valid result but 1.0f is not. + */ + public final float nextFloat() { + int y; + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + return (y >>> 8) / ((float) (1 << 24)); + } + + /** + * Returns a float in the range from 0.0f to 1.0f, possibly inclusive of 0.0f + * and 1.0f themselves. Thus: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
      ExpressionInterval
      nextFloat(false, false)(0.0f, 1.0f)
      nextFloat(true, false)[0.0f, 1.0f)
      nextFloat(false, true)(0.0f, 1.0f]
      nextFloat(true, true)[0.0f, 1.0f]
      + *

      + * This version preserves all possible random values in the float range. + */ + public double nextFloat(boolean includeZero, boolean includeOne) { + float d = 0.0f; + do { + d = nextFloat(); // grab a value, initially from half-open [0.0f, 1.0f) + if (includeOne && nextBoolean()) d += 1.0f; // if includeOne, with 1/2 + // probability, push to [1.0f, + // 2.0f) + } + while ((d > 1.0f) || // everything above 1.0f is always invalid + (!includeZero && d == 0.0f)); // if we're not including zero, 0.0f is + // invalid + return d; + } + + /** + * Returns an integer drawn uniformly from 0 to n-1. Suffice it to say, n must + * be > 0, or an IllegalArgumentException is raised. + */ + public final int nextInt(final int n) { + if (n <= 0) throw new IllegalArgumentException("n must be positive, got: " + + n); + + if ((n & -n) == n) // i.e., n is a power of 2 + { + int y; + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + return (int) ((n * (long) (y >>> 1)) >> 31); + } + + int bits, val; + do { + int y; + + if (mti >= N) // generate N words at one time + { + int kk; + final int[] mt = this.mt; // locals are slightly faster + final int[] mag01 = this.mag01; // locals are slightly faster + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >>> 1) ^ mag01[y & 0x1]; + } + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= y >>> 11; // TEMPERING_SHIFT_U(y) + y ^= (y << 7) & TEMPERING_MASK_B; // TEMPERING_SHIFT_S(y) + y ^= (y << 15) & TEMPERING_MASK_C; // TEMPERING_SHIFT_T(y) + y ^= (y >>> 18); // TEMPERING_SHIFT_L(y) + + bits = (y >>> 1); + val = bits % n; + } + while (bits - val + (n - 1) < 0); + return val; + } + + /** + * Tests the code. + */ + public static void main(String args[]) { + int j; + + MersenneTwisterFast r; + + // CORRECTNESS TEST + // COMPARE WITH + // http://www.math.keio.ac.jp/matumoto/CODES/MT2002/mt19937ar.out + + r = new MersenneTwisterFast(new int[] { 0x123, 0x234, 0x345, 0x456 }); + System.out.println( + "Output of MersenneTwisterFast with new (2002/1/26) seeding mechanism"); + for (j = 0; j < 1000; j++) { + // first, convert the int from signed to "unsigned" + long l = (long) r.nextInt(); + if (l < 0) l += 4294967296L; // max int value + String s = String.valueOf(l); + while (s.length() < 10) + s = " " + s; // buffer + System.out.print(s + " "); + if (j % 5 == 4) System.out.println(); + } + + // SPEED TEST + + final long SEED = 4357; + + int xx; + long ms; + System.out.println("\nTime to test grabbing 100000000 ints"); + + Random rr = new Random(SEED); + xx = 0; + ms = System.currentTimeMillis(); + for (j = 0; j < 100000000; j++) + xx += rr.nextInt(); + System.out.println("java.util.Random: " + (System.currentTimeMillis() - + ms) + " Ignore this: " + xx); + + r = new MersenneTwisterFast(SEED); + ms = System.currentTimeMillis(); + xx = 0; + for (j = 0; j < 100000000; j++) + xx += r.nextInt(); + System.out.println("Mersenne Twister Fast: " + (System.currentTimeMillis() - + ms) + " Ignore this: " + xx); + + // TEST TO COMPARE TYPE CONVERSION BETWEEN + // MersenneTwisterFast.java AND MersenneTwister.java + + System.out.println("\nGrab the first 1000 booleans"); + r = new MersenneTwisterFast(SEED); + for (j = 0; j < 1000; j++) { + System.out.print(r.nextBoolean() + " "); + if (j % 8 == 7) System.out.println(); + } + if (!(j % 8 == 7)) System.out.println(); + + System.out.println( + "\nGrab 1000 booleans of increasing probability using nextBoolean(double)"); + r = new MersenneTwisterFast(SEED); + for (j = 0; j < 1000; j++) { + System.out.print(r.nextBoolean((double) (j / 999.0)) + " "); + if (j % 8 == 7) System.out.println(); + } + if (!(j % 8 == 7)) System.out.println(); + + System.out.println( + "\nGrab 1000 booleans of increasing probability using nextBoolean(float)"); + r = new MersenneTwisterFast(SEED); + for (j = 0; j < 1000; j++) { + System.out.print(r.nextBoolean((float) (j / 999.0f)) + " "); + if (j % 8 == 7) System.out.println(); + } + if (!(j % 8 == 7)) System.out.println(); + + byte[] bytes = new byte[1000]; + System.out.println("\nGrab the first 1000 bytes using nextBytes"); + r = new MersenneTwisterFast(SEED); + r.nextBytes(bytes); + for (j = 0; j < 1000; j++) { + System.out.print(bytes[j] + " "); + if (j % 16 == 15) System.out.println(); + } + if (!(j % 16 == 15)) System.out.println(); + + byte b; + System.out.println( + "\nGrab the first 1000 bytes -- must be same as nextBytes"); + r = new MersenneTwisterFast(SEED); + for (j = 0; j < 1000; j++) { + System.out.print((b = r.nextByte()) + " "); + if (b != bytes[j]) System.out.print("BAD "); + if (j % 16 == 15) System.out.println(); + } + if (!(j % 16 == 15)) System.out.println(); + + System.out.println("\nGrab the first 1000 shorts"); + r = new MersenneTwisterFast(SEED); + for (j = 0; j < 1000; j++) { + System.out.print(r.nextShort() + " "); + if (j % 8 == 7) System.out.println(); + } + if (!(j % 8 == 7)) System.out.println(); + + System.out.println("\nGrab the first 1000 ints"); + r = new MersenneTwisterFast(SEED); + for (j = 0; j < 1000; j++) { + System.out.print(r.nextInt() + " "); + if (j % 4 == 3) System.out.println(); + } + if (!(j % 4 == 3)) System.out.println(); + + System.out.println("\nGrab the first 1000 ints of different sizes"); + r = new MersenneTwisterFast(SEED); + int max = 1; + for (j = 0; j < 1000; j++) { + System.out.print(r.nextInt(max) + " "); + max *= 2; + if (max <= 0) max = 1; + if (j % 4 == 3) System.out.println(); + } + if (!(j % 4 == 3)) System.out.println(); + + System.out.println("\nGrab the first 1000 longs"); + r = new MersenneTwisterFast(SEED); + for (j = 0; j < 1000; j++) { + System.out.print(r.nextLong() + " "); + if (j % 3 == 2) System.out.println(); + } + if (!(j % 3 == 2)) System.out.println(); + + System.out.println("\nGrab the first 1000 longs of different sizes"); + r = new MersenneTwisterFast(SEED); + long max2 = 1; + for (j = 0; j < 1000; j++) { + System.out.print(r.nextLong(max2) + " "); + max2 *= 2; + if (max2 <= 0) max2 = 1; + if (j % 4 == 3) System.out.println(); + } + if (!(j % 4 == 3)) System.out.println(); + + System.out.println("\nGrab the first 1000 floats"); + r = new MersenneTwisterFast(SEED); + for (j = 0; j < 1000; j++) { + System.out.print(r.nextFloat() + " "); + if (j % 4 == 3) System.out.println(); + } + if (!(j % 4 == 3)) System.out.println(); + + System.out.println("\nGrab the first 1000 doubles"); + r = new MersenneTwisterFast(SEED); + for (j = 0; j < 1000; j++) { + System.out.print(r.nextDouble() + " "); + if (j % 3 == 2) System.out.println(); + } + if (!(j % 3 == 2)) System.out.println(); + + System.out.println("\nGrab the first 1000 gaussian doubles"); + r = new MersenneTwisterFast(SEED); + for (j = 0; j < 1000; j++) { + System.out.print(r.nextGaussian() + " "); + if (j % 3 == 2) System.out.println(); + } + if (!(j % 3 == 2)) System.out.println(); + + } +} diff --git a/src/main/java/org/scijava/util/MetaInfCombiner.java b/src/main/java/org/scijava/util/MetaInfCombiner.java index 63582c0cc..8bfd096bd 100644 --- a/src/main/java/org/scijava/util/MetaInfCombiner.java +++ b/src/main/java/org/scijava/util/MetaInfCombiner.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Accumulates information from the class path to make META-INF/ files * appropriate for an uber jar. - * + * * @author Johannes Schindelin */ public class MetaInfCombiner { diff --git a/src/main/java/org/scijava/util/MirrorWebsite.java b/src/main/java/org/scijava/util/MirrorWebsite.java index ec807ab8e..1f7d70a5d 100644 --- a/src/main/java/org/scijava/util/MirrorWebsite.java +++ b/src/main/java/org/scijava/util/MirrorWebsite.java @@ -6,13 +6,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 @@ -57,17 +57,19 @@ /** * This program mirrors a given website. *

      - * Its primary purpose is to provide the code necessary to keep ImageJ Mirror up-to-date. + * Its primary purpose is to provide the code necessary to keep + * ImageJ Mirror up-to-date. *

      - * + * * @author Johannes Schindelin */ public class MirrorWebsite { + public final static int THREAD_COUNT = 20; public final static long DELAY_IN_MICROSECONDS = 0; private String baseURL; - private String basePath; // the local directory for file:// baseURL, otherwise null + private String basePath; // the local directory for file:// baseURL, otherwise + // null private File localDirectory; private Map linkMap = new HashMap<>(); private Set missingLinks = new LinkedHashSet<>(); @@ -78,7 +80,8 @@ public class MirrorWebsite { private long delay; public MirrorWebsite(final String baseURL, final File localDirectory, - final int threadCount, final long delay) { + final int threadCount, final long delay) + { this.baseURL = baseURL + (baseURL.endsWith("/") ? "" : "/"); this.basePath = baseURL.startsWith("file:") ? baseURL.substring(5) : null; this.localDirectory = localDirectory; @@ -88,8 +91,8 @@ public MirrorWebsite(final String baseURL, final File localDirectory, public void run() throws InterruptedException { synchronized (this) { - if (jobs != null) - throw new RuntimeException("Mirroring already in progress!"); + if (jobs != null) throw new RuntimeException( + "Mirroring already in progress!"); executorService = Executors.newFixedThreadPool(threadCount); done = new TreeSet<>(); @@ -109,7 +112,8 @@ public void mirror(String path) { } try { executorService.execute(job); - } catch (Throwable t) { + } + catch (Throwable t) { t.printStackTrace(); done.add(path); } @@ -119,14 +123,14 @@ private static long getRemoteTimestamp(String url) throws IOException { URLConnection connection = null; try { connection = new URL(url).openConnection(); - } catch (FileNotFoundException e) { - if (url.endsWith("/index.html")) - connection = new URL(url.substring(0, url.length() - 10)).openConnection(); - else - throw e; + } + catch (FileNotFoundException e) { + if (url.endsWith("/index.html")) connection = new URL(url.substring(0, url + .length() - 10)).openConnection(); + else throw e; } if (connection instanceof HttpURLConnection) - ((HttpURLConnection)connection).setRequestMethod("HEAD"); + ((HttpURLConnection) connection).setRequestMethod("HEAD"); connection.setUseCaches(false); long lastModified = connection.getLastModified(); connection.getInputStream().close(); @@ -137,20 +141,18 @@ private static long getRemoteTimestamp(String url) throws IOException { private long upToDate(String path) throws IOException { long remote = getRemoteTimestamp(baseURL + path); File file = new File(localDirectory, path); - if (!file.exists()) - return remote; + if (!file.exists()) return remote; long local = file.lastModified(); return remote < 0 || local == remote ? 0 : remote; } private String getValue(String html, int startOffset) { int offset = startOffset; - while (offset < html.length() && - (html.charAt(offset) == '\n' || html.charAt(offset) == '\r' || html.charAt(offset) == ' ')) + while (offset < html.length() && (html.charAt(offset) == '\n' || html + .charAt(offset) == '\r' || html.charAt(offset) == ' ')) offset++; - if (offset + 1 >= html.length()) - return ""; + if (offset + 1 >= html.length()) return ""; char delim = ' ', delim2 = '>'; char c = html.charAt(offset); @@ -160,20 +162,20 @@ private String getValue(String html, int startOffset) { } for (int end = offset; end < html.length(); end++) - if (html.charAt(end) == delim || html.charAt(end) == delim2) - return html.substring(offset, end); + if (html.charAt(end) == delim || html.charAt(end) == delim2) return html + .substring(offset, end); return html.substring(offset); } - private void addLinkRelation(List result, String sourceURL, String url) { + private void addLinkRelation(List result, String sourceURL, + String url) + { String normalized = normalizeURL(url); - if (normalized == null) - return; + if (normalized == null) return; result.add(normalized); - synchronized(linkMap) { + synchronized (linkMap) { String previous = linkMap.get(normalized); - if (previous == null) - linkMap.put(normalized, sourceURL); + if (previous == null) linkMap.put(normalized, sourceURL); else if ((" " + previous + " ").indexOf(" " + sourceURL + " ") < 0) linkMap.put(normalized, previous + " " + sourceURL); } @@ -185,45 +187,41 @@ private List getLinks(String relativePath, String path, String html) { int offset = -1; for (;;) { int newOffset = -1; - for (String pattern : new String[] { " href=", " src=", " HREF=", " SRC=" }) { + for (String pattern : new String[] { " href=", " src=", " HREF=", + " SRC=" }) + { int tmp = html.indexOf(pattern, offset + 1); - if (tmp >= 0 && (newOffset < 0 || newOffset > tmp)) - newOffset = tmp + pattern.length(); + if (tmp >= 0 && (newOffset < 0 || newOffset > tmp)) newOffset = tmp + + pattern.length(); } - if (newOffset < 0) - break; + if (newOffset < 0) break; offset = newOffset; String value = getValue(html, offset); offset += value.length(); - if (value.startsWith("mailto:") || value.startsWith("MAILTO:")) - continue; + if (value.startsWith("mailto:") || value.startsWith("MAILTO:")) continue; for (char c : new char[] { '#', '?', ';' }) { int hash = value.indexOf(c); - if (hash >= 0) - value = value.substring(0, hash); + if (hash >= 0) value = value.substring(0, hash); } - if (value.endsWith("/")) - value += "index.html"; + if (value.endsWith("/")) value += "index.html"; if (value.startsWith("/")) { int colon = baseURL.indexOf("://"); int slash = baseURL.indexOf('/', colon + 3); value = baseURL.substring(0, slash) + value; } else if (value.indexOf("://") < 0) { - if (!value.equals("")) - addLinkRelation(result, path, relativePath + value); - if (offset < 0) - break; + if (!value.equals("")) addLinkRelation(result, path, relativePath + + value); + if (offset < 0) break; continue; } - if (value.startsWith(baseURL)) - addLinkRelation(result, path, value.substring(baseURL.length())); - if (offset < 0) - break; + if (value.startsWith(baseURL)) addLinkRelation(result, path, value + .substring(baseURL.length())); + if (offset < 0) break; } return result; @@ -234,20 +232,18 @@ private static boolean isHTML(String path) { return lower.endsWith(".htm") || lower.endsWith(".html"); } - private static void copyStream(InputStream in, StringBuffer string, OutputStream out) throws IOException { + private static void copyStream(InputStream in, StringBuffer string, + OutputStream out) throws IOException + { byte[] buffer = new byte[65536]; for (;;) { int count = in.read(buffer); - if (count < 0) - break; - if (string != null) - string.append(new String(buffer, 0, count)); - if (out != null) - out.write(buffer, 0, count); + if (count < 0) break; + if (string != null) string.append(new String(buffer, 0, count)); + if (out != null) out.write(buffer, 0, count); } in.close(); - if (out != null) - out.close(); + if (out != null) out.close(); } private List ensureUptodate(String path) throws IOException { @@ -256,13 +252,16 @@ private List ensureUptodate(String path) throws IOException { File file = new File(localDirectory, path); // special-case local case: file:/.../ does not list the directory contents - if (basePath != null && ("/" + path).endsWith("/index.html") && !new File(basePath + path).exists()) { + if (basePath != null && ("/" + path).endsWith("/index.html") && !new File( + basePath + path).exists()) + { 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<>(); for (final File item : list) { - if (item.isDirectory()) result.add(directory + item.getName() + "/index.html"); + if (item.isDirectory()) result.add(directory + item.getName() + + "/index.html"); else result.add(directory + item.getName()); } return result; @@ -272,14 +271,13 @@ private List ensureUptodate(String path) throws IOException { try { remoteLastModified = upToDate(path); if (remoteLastModified == 0) { - if (!isHTML(path)) - return Collections.emptyList(); + if (!isHTML(path)) return Collections.emptyList(); copyStream(new FileInputStream(file), string, null); return getLinks(relativePath, path, string.toString()); } - } catch (FileNotFoundException e) { - if (!path.endsWith("/index.html")) - throw e; + } + catch (FileNotFoundException e) { + if (!path.endsWith("/index.html")) throw e; remoteLastModified = -1; } @@ -291,10 +289,9 @@ private List ensureUptodate(String path) throws IOException { throw new MalformedURLException(baseURL + path); } catch (FileNotFoundException e) { - if (path.endsWith("/index.html")) - in = new URL(baseURL + path.substring(0, path.length() - 10)).openStream(); - else - throw e; + if (path.endsWith("/index.html")) in = new URL(baseURL + path.substring(0, + path.length() - 10)).openStream(); + else throw e; } System.err.println("Downloading " + path); File tmp = new File(localDirectory, path + ".download.tmp"); @@ -302,35 +299,30 @@ private List ensureUptodate(String path) throws IOException { FileOutputStream out = new FileOutputStream(tmp); if (isHTML(path)) { copyStream(in, string, null); - String rewritten = string.toString() - .replaceAll("http://rsb.info.nih.gov", - "http://imagej.nih.gov"); + String rewritten = string.toString().replaceAll("http://rsb.info.nih.gov", + "http://imagej.nih.gov"); String replacement = "", path2 = path; for (;;) { path2 = path2.substring(0, path2.lastIndexOf('/') + 1); rewritten = rewritten.replaceAll(baseURL + path2, replacement); // special-case rewriting from a local mirror if (basePath != null) { - rewritten = rewritten.replaceAll("http://imagej.nih.gov/ij/" + path2, replacement); + rewritten = rewritten.replaceAll("http://imagej.nih.gov/ij/" + path2, + replacement); } - if (path2.equals("")) - break; + if (path2.equals("")) break; // strip trailing slash path2 = path2.substring(0, path2.length() - 1); replacement = "../" + replacement; } - copyStream(new ByteArrayInputStream(rewritten.getBytes()), - null, out); + copyStream(new ByteArrayInputStream(rewritten.getBytes()), null, out); } - else - copyStream(in, null, out); + else copyStream(in, null, out); tmp.renameTo(file); - if (remoteLastModified >= 0) - file.setLastModified(remoteLastModified); + if (remoteLastModified >= 0) file.setLastModified(remoteLastModified); - if (!isHTML(path)) - return Collections.emptyList(); + if (!isHTML(path)) return Collections.emptyList(); return getLinks(relativePath, path, string.toString()); } @@ -343,17 +335,13 @@ private static String normalizeURL(String originalPath) { continue; } int dotdot = path.indexOf("/../"); - if (dotdot < 0) - break; - if (dotdot == 0) - return null; + if (dotdot < 0) break; + if (dotdot == 0) return null; int slash = path.lastIndexOf(dotdot - 1); - if (slash < 0) - return null; + if (slash < 0) return null; path = path.substring(0, slash) + path.substring(dotdot + 3); } - if (path.startsWith("../")) - throw new RuntimeException("ignore"); + if (path.startsWith("../")) throw new RuntimeException("ignore"); return path; } @@ -362,11 +350,13 @@ private void reportMissingLinks() { System.err.println("Found broken links:"); for (final String path : missingLinks) { final String source = linkMap.get(path); - System.err.println(path + (source == null ? "" : " (linked from " + source + ")")); + System.err.println(path + (source == null ? "" : " (linked from " + + source + ")")); } } private class MirrorJob implements Runnable { + private String path; public MirrorJob(String path) { @@ -376,17 +366,20 @@ public MirrorJob(String path) { @Override public void run() { try { - System.err.println("Looking at " + path + " (" + (1 + done.size()) + "/" + jobs.size() + ")"); - for (String path2 : ensureUptodate(path)) try { - mirror(path2); - } - catch (Throwable e) { - System.err.println("" + e); - } + System.err.println("Looking at " + path + " (" + (1 + done.size()) + + "/" + jobs.size() + ")"); + for (String path2 : ensureUptodate(path)) + try { + mirror(path2); + } + catch (Throwable e) { + System.err.println("" + e); + } } catch (FileNotFoundException e) { String source = linkMap.get(path); - System.err.println("" + e + (source == null ? "" : " (linked from " + source + ")")); + System.err.println("" + e + (source == null ? "" : " (linked from " + + source + ")")); missingLinks.add(path); } catch (Throwable e) { @@ -395,7 +388,8 @@ public void run() { } if (delay > 0) try { Thread.sleep(delay); - } catch (InterruptedException e) { + } + catch (InterruptedException e) { // ignore } synchronized (MirrorWebsite.this) { @@ -416,7 +410,8 @@ private static void usage() { System.err.println("--threads "); System.err.println("\tuse threads (default: " + THREAD_COUNT + ")"); System.err.println("--delay "); - System.err.println("\twait after each request (default: " + DELAY_IN_MICROSECONDS + ")"); + System.err.println("\twait after each request (default: " + + DELAY_IN_MICROSECONDS + ")"); System.exit(1); } @@ -427,31 +422,25 @@ public static void main(String[] args) { // option parsing int i = 0; while (i < args.length) { - if (!args[i].startsWith("--")) - break; + if (!args[i].startsWith("--")) break; final String option = args[i++]; - if (option.equals("--")) - break; + if (option.equals("--")) break; // no-arg options - if (option.equals("--help")) - usage(); + if (option.equals("--help")) usage(); // one-arg options if (i + 1 >= args.length) { System.err.println("Missing argument: " + option); usage(); } final String arg = args[i++]; - if (option.equals("--threads")) - threadCount = Integer.parseInt(arg); - else if (option.equals("--delay")) - delay = Long.parseLong(arg); + if (option.equals("--threads")) threadCount = Integer.parseInt(arg); + else if (option.equals("--delay")) delay = Long.parseLong(arg); else { System.err.println("Unknown option: " + option); usage(); } } - if (args.length - i != 2) - usage(); + if (args.length - i != 2) usage(); // now the fun starts final File directory = new File(args[i + 1]); @@ -462,7 +451,8 @@ else if (option.equals("--delay")) try { System.err.println("Mirroring " + args[i] + " to " + directory); new MirrorWebsite(args[i], directory, threadCount, delay).run(); - } catch (Throwable t) { + } + catch (Throwable t) { t.printStackTrace(); System.exit(1); } diff --git a/src/main/java/org/scijava/util/MiscUtils.java b/src/main/java/org/scijava/util/MiscUtils.java index 4476e9a4b..7fd1faa55 100644 --- a/src/main/java/org/scijava/util/MiscUtils.java +++ b/src/main/java/org/scijava/util/MiscUtils.java @@ -6,13 +6,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,7 +33,7 @@ /** * Miscellaneous utility methods. Every project needs a class like this, right? - * + * * @author Curtis Rueden */ public final class MiscUtils { @@ -48,7 +48,7 @@ private MiscUtils() { * By convention, nulls are considered less than non-nulls (and will hence * will appear first on sorted lists). *

      - * + * * @param o1 The first object to compare. * @param o2 The second object to compare. * @return The result of {@code o1.compareTo(o2)} unless one or both of them @@ -63,7 +63,7 @@ public static > int compare(final T o1, /** * Compares two comparable objects, even if one or both of them are null. - * + * * @param o1 The first object to compare. * @param o2 The second object to compare. * @param heavyNulls If true, nulls will be treated as greater than non-nulls, diff --git a/src/main/java/org/scijava/util/NumberUtils.java b/src/main/java/org/scijava/util/NumberUtils.java index 11a228345..cd3fa8c74 100644 --- a/src/main/java/org/scijava/util/NumberUtils.java +++ b/src/main/java/org/scijava/util/NumberUtils.java @@ -6,13 +6,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 @@ -34,10 +34,9 @@ import org.scijava.util.Types; - /** * Useful methods for working with {@link Number} objects. - * + * * @author Curtis Rueden * @author Barry DeZonia */ @@ -58,10 +57,10 @@ public static Number toNumber(final Object value, final Class type) { public static BigDecimal asBigDecimal(final Number n) { // Using .doubleValue on a long or BigInteger would cause loss of accuracy - if(BigInteger.class.isInstance(n)){ + if (BigInteger.class.isInstance(n)) { return new BigDecimal((BigInteger) n); } - else if(Long.class.isInstance(n)){ + else if (Long.class.isInstance(n)) { return new BigDecimal(n.longValue()); } return new BigDecimal(n.doubleValue()); diff --git a/src/main/java/org/scijava/util/ObjectArray.java b/src/main/java/org/scijava/util/ObjectArray.java index aa12acc08..9f48fe93c 100644 --- a/src/main/java/org/scijava/util/ObjectArray.java +++ b/src/main/java/org/scijava/util/ObjectArray.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ * also contains improved performance implementations of many {@link Collection} * methods. *

      - * + * * @author Mark Hiner * @author Johannes Schindelin * @author Curtis Rueden @@ -66,7 +66,7 @@ public ObjectArray(Class arrayType) { /** * Constructs an extensible array of objects, backed by a fixed-size array. - * + * * @param size the initial size */ public ObjectArray(Class arrayType, final int size) { @@ -77,7 +77,7 @@ public ObjectArray(Class arrayType, final int size) { /** * Constructs an extensible array of objects, backed by the given fixed-size * array. - * + * * @param array the array to wrap */ @SuppressWarnings("unchecked") diff --git a/src/main/java/org/scijava/util/POM.java b/src/main/java/org/scijava/util/POM.java index 54c0434ab..725749a5b 100644 --- a/src/main/java/org/scijava/util/POM.java +++ b/src/main/java/org/scijava/util/POM.java @@ -6,13 +6,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 @@ -46,7 +46,7 @@ /** * Helper class for working with Maven POMs. - * + * * @author Curtis Rueden */ public class POM extends XML implements Comparable, Versioned { @@ -54,8 +54,8 @@ public class POM extends XML implements Comparable, Versioned { private String version; /** Parses a POM from the given file. */ - public POM(final File file) throws ParserConfigurationException, - SAXException, IOException + public POM(final File file) throws ParserConfigurationException, SAXException, + IOException { super(file); } @@ -217,7 +217,7 @@ public String getVersion() { /** * Gets the Maven POM associated with the given class. - * + * * @param c The class to use as a base when searching for a pom.xml. * @return {@link POM} object representing the discovered POM, or null if no * POM could be found. @@ -228,7 +228,7 @@ public static POM getPOM(final Class c) { /** * Gets the Maven POM associated with the given class. - * + * * @param c The class to use as a base when searching for a pom.xml. * @param groupId The Maven groupId of the desired POM. * @param artifactId The Maven artifactId of the desired POM. @@ -240,8 +240,8 @@ public static POM getPOM(final Class c, final String groupId, { try { final URL location = Types.location(c); - if (!location.getProtocol().equals("file") || - location.toString().endsWith(".jar")) + if (!location.getProtocol().equals("file") || location.toString() + .endsWith(".jar")) { // look for pom.xml in JAR's META-INF/maven subdirectory if (groupId == null || artifactId == null) { @@ -256,10 +256,10 @@ public static POM getPOM(final Class c, final String groupId, } else { // known groupId and artifactId; grab it directly - final String pomPath = - "META-INF/maven/" + groupId + "/" + artifactId + "/pom.xml"; - final URL pomURL = - new URL("jar:" + location.toString() + "!/" + pomPath); + final String pomPath = "META-INF/maven/" + groupId + "/" + + artifactId + "/pom.xml"; + final URL pomURL = new URL("jar:" + location.toString() + "!/" + + pomPath); return new POM(pomURL); } } @@ -334,13 +334,13 @@ public static List getAllPOMs() { *
    • There is one exception: if two version strings are identical except * that one has a suffix beginning with a dash ({@code -}), the version with * suffix will be considered less than the one without a suffix. The - * reason for this is to accommodate the SemVer versioning scheme's usage of + * reason for this is to accommodate the + * SemVer versioning scheme's usage of * "prerelease" version suffixes. For example, {@code 2.0.0} will compare * greater than {@code 2.0.0-beta-1}, whereas {@code 2.0.0} will compare less * than {@code 2.0.0.1}.
    • *
    - * + * * @return a negative integer, zero, or a positive integer as the first * argument is less than, equal to, or greater than the second. * @see Comparator#compare(Object, Object) diff --git a/src/main/java/org/scijava/util/PlatformUtils.java b/src/main/java/org/scijava/util/PlatformUtils.java index 215759cac..af5f96a3f 100644 --- a/src/main/java/org/scijava/util/PlatformUtils.java +++ b/src/main/java/org/scijava/util/PlatformUtils.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Useful methods for platform-specific interrogation. - * + * * @author Curtis Rueden * @author Johannes Schindelin */ diff --git a/src/main/java/org/scijava/util/Prefs.java b/src/main/java/org/scijava/util/Prefs.java index 72f63bac7..cb4f7ad9a 100644 --- a/src/main/java/org/scijava/util/Prefs.java +++ b/src/main/java/org/scijava/util/Prefs.java @@ -6,13 +6,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 @@ -72,8 +72,8 @@ public static String get(final String name, final String defaultValue) { return service().get(name, defaultValue); } - public static boolean - getBoolean(final String name, final boolean defaultValue) + public static boolean getBoolean(final String name, + final boolean defaultValue) { return service().getBoolean(name, defaultValue); } @@ -160,8 +160,8 @@ public static long getLong(final Class c, final String name, return service().getLong(c, name, defaultValue); } - public static void - put(final Class c, final String name, final String value) + public static void put(final Class c, final String name, + final String value) { service().put(c, name, value); } @@ -172,14 +172,14 @@ public static void put(final Class c, final String name, service().put(c, name, value); } - public static void - put(final Class c, final String name, final double value) + public static void put(final Class c, final String name, + final double value) { service().put(c, name, value); } - public static void - put(final Class c, final String name, final float value) + public static void put(final Class c, final String name, + final float value) { service().put(c, name, value); } @@ -188,7 +188,8 @@ public static void put(final Class c, final String name, final int value) { service().put(c, name, value); } - public static void put(final Class c, final String name, final long value) + public static void put(final Class c, final String name, + final long value) { service().put(c, name, value); } diff --git a/src/main/java/org/scijava/util/PrimitiveArray.java b/src/main/java/org/scijava/util/PrimitiveArray.java index 51ac3f30a..277282ec2 100644 --- a/src/main/java/org/scijava/util/PrimitiveArray.java +++ b/src/main/java/org/scijava/util/PrimitiveArray.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ * because it uses boxing and unboxing to store the elements, leading to a large * memory footprint as well as performance penalties. *

    - * + * * @author Johannes Schindelin * @author Curtis Rueden * @param Type of the primitive array; e.g., {@code double[]}. @@ -51,14 +51,14 @@ public interface PrimitiveArray extends List, /** * Gets the fixed-size array backing this instance. - * + * * @return the backing array */ ArrayType getArray(); /** * Sets the fixed-size array backing this instance. - * + * * @param array the new backing array */ void setArray(ArrayType array); @@ -80,7 +80,7 @@ public interface PrimitiveArray extends List, *

    * The returned array is guaranteed to have {@link #size()} elements. *

    - * + * * @return the fixed-size array */ ArrayType copyArray(); @@ -94,14 +94,14 @@ public interface PrimitiveArray extends List, * After calling this method, the internal array will have at least * {@code minCapacity} elements. *

    - * + * * @param minCapacity the minimum capacity */ void ensureCapacity(int minCapacity); /** * Shifts the array to insert space at a specified index. - * + * * @param index the index where the space should be inserted * @param count the number of values to insert */ @@ -109,7 +109,7 @@ public interface PrimitiveArray extends List, /** * Shifts the array to delete space starting at a specified index. - * + * * @param index the index where the space should be deleted * @param count the number of values to delete */ diff --git a/src/main/java/org/scijava/util/ProcessUtils.java b/src/main/java/org/scijava/util/ProcessUtils.java index 3b23b3c1c..d31284430 100644 --- a/src/main/java/org/scijava/util/ProcessUtils.java +++ b/src/main/java/org/scijava/util/ProcessUtils.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * Useful methods for working with processes. - * + * * @author Johannes Schindelin */ public final class ProcessUtils { @@ -49,7 +49,7 @@ private ProcessUtils() { /** * Executes a program. This is a convenience method mainly to be able to catch * the output of programs as shell scripts can do by wrapping calls in $(...). - * + * * @param workingDirectory the directory in which to execute the program * @param err the {@link PrintStream} to print the program's error stream to; * if null is passed, the error goes straight to Nirvana (not the @@ -63,8 +63,8 @@ private ProcessUtils() { * @throws RuntimeException if interrupted or the program failed to execute * successfully. */ - public static String exec(final File workingDirectory, - final PrintStream err, final PrintStream out, final String... args) + public static String exec(final File workingDirectory, final PrintStream err, + final PrintStream out, final String... args) { return exec(workingDirectory, null, err, out, args); } @@ -72,9 +72,10 @@ public static String exec(final File workingDirectory, /** * Executes a program. This is a convenience method mainly to be able to catch * the output of programs as shell scripts can do by wrapping calls in $(...). - * + * * @param workingDirectory the directory in which to execute the program - * @param in the {@link InputStream} which gets fed to the program as standard input; + * @param in the {@link InputStream} which gets fed to the program as standard + * input; * @param err the {@link PrintStream} to print the program's error stream to; * if null is passed, the error goes straight to Nirvana (not the * band, though). @@ -87,19 +88,19 @@ public static String exec(final File workingDirectory, * @throws RuntimeException if interrupted or the program failed to execute * successfully. */ - public static String exec(final File workingDirectory, - final InputStream in, final PrintStream err, final PrintStream out, - final String... args) + public static String exec(final File workingDirectory, final InputStream in, + final PrintStream err, final PrintStream out, final String... args) { try { - final Process process = - Runtime.getRuntime().exec(args, null, workingDirectory); + final Process process = Runtime.getRuntime().exec(args, null, + workingDirectory); final ReadInto inThread; if (in == null) { inThread = null; process.getOutputStream().close(); - } else { + } + else { final PrintStream print = new PrintStream(process.getOutputStream()); inThread = new ReadInto(in, print, true); } @@ -126,8 +127,8 @@ public static String exec(final File workingDirectory, throw new RuntimeException(e); } if (process.exitValue() != 0) { - throw new RuntimeException("exit status " + process.exitValue() + - ": " + Arrays.toString(args) + "\n" + err); + throw new RuntimeException("exit status " + process.exitValue() + ": " + + Arrays.toString(args) + "\n" + err); } return outThread.toString(); } diff --git a/src/main/java/org/scijava/util/PropertiesHelper.java b/src/main/java/org/scijava/util/PropertiesHelper.java index bfbac09e2..151fdfc57 100644 --- a/src/main/java/org/scijava/util/PropertiesHelper.java +++ b/src/main/java/org/scijava/util/PropertiesHelper.java @@ -6,13 +6,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/util/Query.java b/src/main/java/org/scijava/util/Query.java index 008b84efa..e60be2844 100644 --- a/src/main/java/org/scijava/util/Query.java +++ b/src/main/java/org/scijava/util/Query.java @@ -6,13 +6,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,13 +38,15 @@ * * @author Mark Hiner */ -public class Query extends HashMap, Class> { +public class Query extends + HashMap, Class> +{ // -- Constructors -- public Query() { super(); - } + } public Query(final Query query) { super(query); diff --git a/src/main/java/org/scijava/util/ReadInto.java b/src/main/java/org/scijava/util/ReadInto.java index 559b87304..db1e95ec6 100644 --- a/src/main/java/org/scijava/util/ReadInto.java +++ b/src/main/java/org/scijava/util/ReadInto.java @@ -6,13 +6,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 @@ -42,7 +42,7 @@ * Its intended use is to catch the output and error streams of {@link Process} * instances. *

    - * + * * @author Johannes Schindelin */ public class ReadInto extends Thread { @@ -54,7 +54,7 @@ public class ReadInto extends Thread { /** * Construct a ReadInto thread and start it right away. - * + * * @param in the stream to read * @param out the stream to print to; if it is null, the {@link #toString()} * method will have the output instead @@ -65,16 +65,19 @@ public ReadInto(final InputStream in, final PrintStream out) { /** * Construct a ReadInto thread and start it right away. - * + * * @param in the stream to read * @param out the stream to print to; if it is null, the {@link #toString()} * method will have the output instead */ - public ReadInto(final InputStream in, final PrintStream out, final boolean closeOnEOF) { + public ReadInto(final InputStream in, final PrintStream out, + final boolean closeOnEOF) + { reader = new BufferedReader(new InputStreamReader(in)); this.out = out; this.closeOnEOF = closeOnEOF; - if (out == null && closeOnEOF) throw new IllegalArgumentException("Cannot close null output"); + if (out == null && closeOnEOF) throw new IllegalArgumentException( + "Cannot close null output"); start(); } @@ -112,7 +115,8 @@ public void run() { public void interrupt() { try { done(); - } catch (IOException e) { /* just stop */ } + } + catch (IOException e) { /* just stop */ } super.interrupt(); } diff --git a/src/main/java/org/scijava/util/RealCoords.java b/src/main/java/org/scijava/util/RealCoords.java index 97e61e00c..0e0a8fee0 100644 --- a/src/main/java/org/scijava/util/RealCoords.java +++ b/src/main/java/org/scijava/util/RealCoords.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * This class represents an (X, Y) coordinate pair in real coordinates. It is * required for high precision image coordinates translation. - * + * * @author Grant Harris * @author Curtis Rueden */ diff --git a/src/main/java/org/scijava/util/RealRect.java b/src/main/java/org/scijava/util/RealRect.java index 4f355cd73..eaaa9dd81 100644 --- a/src/main/java/org/scijava/util/RealRect.java +++ b/src/main/java/org/scijava/util/RealRect.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * A class for representing a rectangular region, in real coordinates. - * + * * @author Barry DeZonia * @author Curtis Rueden */ @@ -78,9 +78,8 @@ public boolean intersects(final RealRect r) { rh += ry; tw += tx; th += ty; - final boolean rtn = - (rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && - (th < ty || th > ry); + final boolean rtn = (rw < rx || rw > tx) && (rh < ry || rh > ty) && + (tw < tx || tw > rx) && (th < ty || th > ry); return rtn; } diff --git a/src/main/java/org/scijava/util/ReflectException.java b/src/main/java/org/scijava/util/ReflectException.java index 3402b78f9..f55c7d43c 100644 --- a/src/main/java/org/scijava/util/ReflectException.java +++ b/src/main/java/org/scijava/util/ReflectException.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * An exception thrown when something goes wrong performing a reflected * operation with {@link ReflectedUniverse}. - * + * * @author Curtis Rueden */ public class ReflectException extends Exception { diff --git a/src/main/java/org/scijava/util/ReflectedUniverse.java b/src/main/java/org/scijava/util/ReflectedUniverse.java index fd7aa908a..d5252cdee 100644 --- a/src/main/java/org/scijava/util/ReflectedUniverse.java +++ b/src/main/java/org/scijava/util/ReflectedUniverse.java @@ -6,13 +6,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 @@ -50,7 +50,7 @@ * can do with the vanilla {@link java.lang.reflect} API. Of course, debugging * such reflected code becomes much more difficult—caveat emptor! *

    - * + * * @author Curtis Rueden */ public class ReflectedUniverse { @@ -95,14 +95,12 @@ public ReflectedUniverse(final ClassLoader loader) { * the purposes of reflection. */ public static boolean isInstance(final Class c, final Object o) { - return (o == null || c.isInstance(o) || - (c == byte.class && o instanceof Byte) || - (c == short.class && o instanceof Short) || - (c == int.class && o instanceof Integer) || - (c == long.class && o instanceof Long) || - (c == float.class && o instanceof Float) || - (c == double.class && o instanceof Double) || - (c == boolean.class && o instanceof Boolean) || (c == char.class && o instanceof Character)); + return (o == null || c.isInstance(o) || (c == byte.class && + o instanceof Byte) || (c == short.class && o instanceof Short) || + (c == int.class && o instanceof Integer) || (c == long.class && + o instanceof Long) || (c == float.class && o instanceof Float) || + (c == double.class && o instanceof Double) || (c == boolean.class && + o instanceof Boolean) || (c == char.class && o instanceof Character)); } // -- ReflectedUniverse API methods -- @@ -182,8 +180,8 @@ public Object exec(String command) throws ReflectException { if (target != null) setVar(target, result); return result; } - else if (leftParen != command.lastIndexOf("(") || - command.indexOf(")") != command.length() - 1) + else if (leftParen != command.lastIndexOf("(") || command.indexOf( + ")") != command.length() - 1) { throw new ReflectException("Invalid parentheses"); } @@ -273,8 +271,8 @@ else if (!(var instanceof Class)) { if (var == null) { throw new ReflectException("No such variable: " + varName); } - final Class varClass = - var instanceof Class ? (Class) var : var.getClass(); + final Class varClass = var instanceof Class ? (Class) var : var + .getClass(); // Search for a method that matches the arguments. Unfortunately, // calling varClass.getMethod(methodName, argClasses) does not work, @@ -419,8 +417,8 @@ else if (varName.matches("-?\\d*\\.\\d*")) { if (var == null) { throw new ReflectException("No such class: " + className); } - final Class varClass = - var instanceof Class ? (Class) var : var.getClass(); + final Class varClass = var instanceof Class ? (Class) var : var + .getClass(); final String fieldName = varName.substring(dot + 1).trim(); Field field; try { @@ -461,14 +459,14 @@ public boolean isAccessibilityIgnored() { */ public static void main(final String[] args) throws IOException { final ReflectedUniverse r = new ReflectedUniverse(); - System.out.println("Reflected universe test environment. " - + "Type commands, or press ^D to quit."); + System.out.println("Reflected universe test environment. " + + "Type commands, or press ^D to quit."); if (args.length > 0) { r.setAccessibilityIgnored(true); System.out.println("Ignoring accessibility modifiers."); } - final BufferedReader in = - new BufferedReader(new InputStreamReader(System.in, "UTF-8")); + final BufferedReader in = new BufferedReader(new InputStreamReader( + System.in, "UTF-8")); while (true) { System.out.print("> "); final String line = in.readLine(); diff --git a/src/main/java/org/scijava/util/ServiceCombiner.java b/src/main/java/org/scijava/util/ServiceCombiner.java index ea9bd034c..8e5d497ed 100644 --- a/src/main/java/org/scijava/util/ServiceCombiner.java +++ b/src/main/java/org/scijava/util/ServiceCombiner.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ /** * Combines {@code Service} information from all JAR files on the classpath. - * + * * @author Johannes Schindelin * @author Mark Hiner */ @@ -55,10 +55,9 @@ public class ServiceCombiner implements Combiner { @Override public void combine(final File outputDirectory) throws IOException { - final Map files = - new HashMap<>(); - final Enumeration directories = - Context.getClassLoader().getResources(SERVICES_PREFIX); + final Map files = new HashMap<>(); + final Enumeration directories = Context.getClassLoader().getResources( + SERVICES_PREFIX); // Iterate over all the service files while (directories.hasMoreElements()) { @@ -67,16 +66,16 @@ public void combine(final File outputDirectory) throws IOException { if (urlString.endsWith("/")) { continue; } - final String fileName = - urlString.substring(urlString.lastIndexOf('/') + 1); + final String fileName = urlString.substring(urlString.lastIndexOf('/') + + 1); StringBuilder builder = files.get(fileName); if (builder == null) { builder = new StringBuilder(); // Create a base entry for a service type files.put(fileName, builder); } - final InputStreamReader reader = - new InputStreamReader(url.openStream()); + final InputStreamReader reader = new InputStreamReader(url + .openStream()); final BufferedReader buffered = new BufferedReader(reader); for (;;) { final String line = buffered.readLine(); @@ -97,8 +96,8 @@ public void combine(final File outputDirectory) throws IOException { final File servicesDirectory = new File(outputDirectory, SERVICES_PREFIX); servicesDirectory.mkdirs(); for (final Entry entry : files.entrySet()) { - final FileWriter writer = - new FileWriter(new File(servicesDirectory, entry.getKey())); + final FileWriter writer = new FileWriter(new File(servicesDirectory, entry + .getKey())); writer.write(entry.getValue().toString()); writer.close(); } diff --git a/src/main/java/org/scijava/util/ShortArray.java b/src/main/java/org/scijava/util/ShortArray.java index 354d31031..31eec1568 100644 --- a/src/main/java/org/scijava/util/ShortArray.java +++ b/src/main/java/org/scijava/util/ShortArray.java @@ -6,13 +6,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,7 +33,7 @@ /** * An extensible array of {@code short} elements. - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -51,7 +51,7 @@ public ShortArray() { /** * Constructs an extensible array of shorts, backed by a fixed-size array. - * + * * @param size the initial size */ public ShortArray(final int size) { @@ -61,7 +61,7 @@ public ShortArray(final int size) { /** * Constructs an extensible array of shorts, backed by the given fixed-size * array. - * + * * @param array the array to wrap */ public ShortArray(final short[] array) { @@ -195,8 +195,7 @@ public boolean containsAll(final Collection c) { // NB: Overridden for performance. @Override - public boolean addAll(final int index, final Collection c) - { + public boolean addAll(final int index, final Collection c) { if (c.size() == 0) return false; insert(index, c.size()); int i = index; diff --git a/src/main/java/org/scijava/util/Sizable.java b/src/main/java/org/scijava/util/Sizable.java index a1a8d82eb..12b4d32a1 100644 --- a/src/main/java/org/scijava/util/Sizable.java +++ b/src/main/java/org/scijava/util/Sizable.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An entity with a size. - * + * * @author Curtis Rueden */ public interface Sizable { @@ -39,5 +39,5 @@ public interface Sizable { int size(); void setSize(final int size); - + } diff --git a/src/main/java/org/scijava/util/SizableArrayList.java b/src/main/java/org/scijava/util/SizableArrayList.java index 11eb6bdc0..bad48498b 100644 --- a/src/main/java/org/scijava/util/SizableArrayList.java +++ b/src/main/java/org/scijava/util/SizableArrayList.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ * When sizing down, elements at the end of the list are removed in one * operation. When sizing up, null elements are appended to the list. *

    - * + * * @author Curtis Rueden * @param The type of data stored in the list. */ @@ -87,7 +87,8 @@ public void setSize(final int size) { final boolean hackSuccessful = hackSize(size); if (!hackSuccessful) { // explicitly increase the size by adding nulls - while (size() < size) add(null); + while (size() < size) + add(null); } } } diff --git a/src/main/java/org/scijava/util/StringMaker.java b/src/main/java/org/scijava/util/StringMaker.java index 809b1a5c9..6a17c9f0b 100644 --- a/src/main/java/org/scijava/util/StringMaker.java +++ b/src/main/java/org/scijava/util/StringMaker.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Helper class for building up {@link String}s of key/value pairs. - * + * * @author Curtis Rueden */ public final class StringMaker { diff --git a/src/main/java/org/scijava/util/StringUtils.java b/src/main/java/org/scijava/util/StringUtils.java index 90b2e9756..a945a4c17 100644 --- a/src/main/java/org/scijava/util/StringUtils.java +++ b/src/main/java/org/scijava/util/StringUtils.java @@ -6,13 +6,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/util/Timing.java b/src/main/java/org/scijava/util/Timing.java index 8a4dcfe39..74494cd33 100644 --- a/src/main/java/org/scijava/util/Timing.java +++ b/src/main/java/org/scijava/util/Timing.java @@ -6,13 +6,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 @@ -48,7 +48,7 @@ *

    * Use this class as following: *

    - * + * *
      * private static Timing timing = new Timing();
      * ...
    @@ -63,10 +63,11 @@
      *  timing.report("Operations");
      * }
      * 
    - * + * * @author Johannes Schindelin */ public class Timing { + private long total = 0, start = System.nanoTime(), tick = start; private List> list = new ArrayList<>(); @@ -75,7 +76,8 @@ public void reset() { } public void addTiming(final Object message) { - addTiming(System.nanoTime() - tick, message == null ? getCaller() : message); + addTiming(System.nanoTime() - tick, message == null ? getCaller() + : message); tick = System.nanoTime(); } @@ -91,7 +93,8 @@ public Long getKey() { @Override public String getValue() { - return message.toString() + ": " + ((now - start - duration) / 1e6) + " - " + ((now - start) / 1e6); + return message.toString() + ": " + ((now - start - duration) / 1e6) + + " - " + ((now - start) / 1e6); } @Override @@ -107,29 +110,29 @@ public void report(final String description) { Collections.sort(list, new Comparator>() { @Override - public int compare(Entry o1, - Entry o2) { + public int compare(Entry o1, Entry o2) { return Double.compare(o1.getKey(), o2.getKey()); } }); - for (final Entry e: list) { - System.err.printf("% 5.3f ms %s\n", ((Long)e.getKey()) / 1e6, e.getValue()); + for (final Entry e : list) { + System.err.printf("% 5.3f ms %s\n", ((Long) e.getKey()) / 1e6, e + .getValue()); } System.err.println("Total time: " + total + " = " + (total / 1e9) + " sec"); } private static String getCaller() { - final StackTraceElement[] trace = - Thread.currentThread().getStackTrace(); + final StackTraceElement[] trace = Thread.currentThread().getStackTrace(); int i = 1; - while (i + 1 < trace.length && - Timing.class.getName().equals(trace[i].getClassName())) { + while (i + 1 < trace.length && Timing.class.getName().equals(trace[i] + .getClassName())) + { i++; } - return i >= trace.length ? "?" : trace[i].getClassName() + "." - + trace[i].getMethodName() + "(" + trace[i].getFileName() + ":" - + trace[i].getLineNumber() + ")"; + return i >= trace.length ? "?" : trace[i].getClassName() + "." + trace[i] + .getMethodName() + "(" + trace[i].getFileName() + ":" + trace[i] + .getLineNumber() + ")"; } public static Timing start(boolean condition) { diff --git a/src/main/java/org/scijava/util/TreeNode.java b/src/main/java/org/scijava/util/TreeNode.java index 20af64acc..1b1fd1ab4 100644 --- a/src/main/java/org/scijava/util/TreeNode.java +++ b/src/main/java/org/scijava/util/TreeNode.java @@ -6,13 +6,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/util/TunePlayer.java b/src/main/java/org/scijava/util/TunePlayer.java index a36fa353d..82a7e6260 100644 --- a/src/main/java/org/scijava/util/TunePlayer.java +++ b/src/main/java/org/scijava/util/TunePlayer.java @@ -6,13 +6,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,7 +38,7 @@ /** * Any QBasic fans out there? ;-) - * + * * @author Curtis Rueden */ public class TunePlayer { @@ -225,8 +225,8 @@ private void play(final SourceDataLine line, final Integer tone) { play(line, tone, getMillis()); } - private void - play(final SourceDataLine line, final Integer tone, final int ms) + private void play(final SourceDataLine line, final Integer tone, + final int ms) { final int length = fill(tone, ms); int count = 0; diff --git a/src/main/java/org/scijava/util/Types.java b/src/main/java/org/scijava/util/Types.java index a75ef8311..68f93bc66 100644 --- a/src/main/java/org/scijava/util/Types.java +++ b/src/main/java/org/scijava/util/Types.java @@ -6,13 +6,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 @@ -365,8 +365,8 @@ public static String name(final Type t) { public static Class raw(final Type type) { if (type == null) return null; if (type instanceof Class) return (Class) type; - if (type instanceof GenericArrayType) - return array(raw(((GenericArrayType) type).getGenericComponentType())); + if (type instanceof GenericArrayType) return array(raw( + ((GenericArrayType) type).getGenericComponentType())); final List> c = raws(type); if (c == null || c.size() == 0) return null; return c.get(0); @@ -541,7 +541,7 @@ public static T nullValue(final Class type) { * use {@link Field#setAccessible(boolean)} in order to manipulate the field's * contents. *

    - * + * * @param c The class (or subclass thereof) containing the desired field. * @param name * @return The first field with the given name in the class's superclass @@ -573,7 +573,7 @@ public static Field field(final Class c, final String name) { * accessible; if the method is not {@code public}, calling code will need to * use {@link Method#setAccessible(boolean)} in order to invoke the method. *

    - * + * * @param c The class (or subclass thereof) containing the desired method. * @param name Name of the method. * @param parameterTypes Types of the method parameters. @@ -782,8 +782,8 @@ public static T cast(final Object src, final Class dest) { /** * Converts the given string value to an enumeration constant of the * specified type. For example, {@code enumValue("APPLE", Fruit.class)} - * returns {@code Fruit.APPLE} if such a value is among those of the - * requested enum class. + * returns {@code Fruit.APPLE} if such a value is among those of the requested + * enum class. * * @param name The value to convert. * @param dest The type of the enumeration constant. @@ -834,8 +834,8 @@ public static T enumFromLabel(final String label, final Class dest) { * @param s The name or label of the desired enum value. * @param dest The type of the enumeration constant. * @return The matching enumeration constant. - * @throws IllegalArgumentException if the type is not an enumeration type, - * or has no such constant with the given name nor label. + * @throws IllegalArgumentException if the type is not an enumeration type, or + * has no such constant with the given name nor label. */ public static T enumFromString(final String s, final Class dest) { if (!dest.isEnum()) throw iae("Not an enum type: " + name(dest)); @@ -851,7 +851,8 @@ public static T enumFromString(final String s, final Class dest) { catch (final IllegalArgumentException exc) { // NB: No action needed. } - throw iae("Enum class " + dest.getName() + " has no such value nor label: " + s); + throw iae("Enum class " + dest.getName() + + " has no such value nor label: " + s); } /** @@ -3207,7 +3208,7 @@ else if (type instanceof GenericArrayType) { /** * Maps type parameters in a type to their values. - * + * * @param toMapType Type possibly containing type arguments * @param typeAndParams must be either ParameterizedType, or (in case there * are no type arguments, or it's a raw type) Class @@ -3259,7 +3260,7 @@ else if (type instanceof ParameterizedType) { * unbound wildcard ("?"). For example, * addWildcardParameters(Map.class) returns a type representing * Map<?,?>. - * + * * @return *
      *
    • If clazz is a class or interface without type parameters, @@ -3340,7 +3341,7 @@ public static Type getExactSuperType(final Type type, * class StringList implements List<String>, * getTypeParameter(StringList.class, Collection.class.getTypeParameters()[0]) * returns String. - * + * * @param type The type to inspect. * @param variable The type variable to find the value for. * @return The type parameter for the given variable. Or null if type is not @@ -3677,7 +3678,7 @@ public static Type capture(final Type type) { * different sorts of types, and you are only really interested in concrete * classes and interfaces. *

      - * + * * @return A List of classes, each of them a supertype of the given type. If * the given type is a class or interface itself, returns a List * with just the given type. The list contains no duplicates, and is @@ -3746,7 +3747,7 @@ private static class CaptureTypeImpl implements CaptureType { /** * Creates an uninitialized CaptureTypeImpl. Before using this type, * {@link #init(VarMap)} must be called. - * + * * @param wildcard The wildcard this is a capture of * @param variable The type variable where the wildcard is a parameter for. */ @@ -3807,8 +3808,7 @@ public String toString() { */ private static class VarMap { - private final Map, Type> map = - new HashMap<>(); + private final Map, Type> map = new HashMap<>(); /** * Creates an empty VarMap diff --git a/src/main/java/org/scijava/util/UnitUtils.java b/src/main/java/org/scijava/util/UnitUtils.java index 445f16046..a1020275a 100644 --- a/src/main/java/org/scijava/util/UnitUtils.java +++ b/src/main/java/org/scijava/util/UnitUtils.java @@ -6,13 +6,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 @@ -29,10 +29,9 @@ package org.scijava.util; - /** * Utility methods for working with units. - * + * * @author Barry DeZonia * @author Curtis Rueden */ @@ -69,7 +68,8 @@ public static String getAbbreviatedByteLabel(final double totBytes) { } /** - * @return Format result with 0 decimal places for bytes, or 1 for larger values + * @return Format result with 0 decimal places for bytes, or 1 for larger + * values */ public static String format(final double power) { return power == 0 ? "%.0f%s" : "%.1f%s"; diff --git a/src/main/java/org/scijava/util/VersionUtils.java b/src/main/java/org/scijava/util/VersionUtils.java index ea012b9a1..2aa3d7268 100644 --- a/src/main/java/org/scijava/util/VersionUtils.java +++ b/src/main/java/org/scijava/util/VersionUtils.java @@ -6,13 +6,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 @@ -91,8 +91,8 @@ public static String getVersionFromManifest(final Class c) { * @param artifactId - Maven artifact ID containing class * @return Version of specified {@link Class} or null if not found. */ - public static String getVersionFromPOM(final Class c, - final String groupId, final String artifactId) + public static String getVersionFromPOM(final Class c, final String groupId, + final String artifactId) { final POM pom = POM.getPOM(c, groupId, artifactId); return pom == null ? null : pom.getVersion(); @@ -113,16 +113,16 @@ public static String getBuildNumber(final Class c) { /** * Compares two version strings. + * * @param v1 The first version string. * @param v2 The second version string. - * @return a negative integer, zero, or a positive integer as the - * first argument is less than, equal to, or greater than the - * second. + * @return a negative integer, zero, or a positive integer as the first + * argument is less than, equal to, or greater than the second. */ public static int compare(final String v1, final String v2) { final String[] t1 = splitDots(v1), t2 = splitDots(v2); final int count = Math.min(t1.length, t2.length); - for (int t=0; t '9') break; index++; diff --git a/src/main/java/org/scijava/util/XML.java b/src/main/java/org/scijava/util/XML.java index 5a3f0a049..b96f5b394 100644 --- a/src/main/java/org/scijava/util/XML.java +++ b/src/main/java/org/scijava/util/XML.java @@ -6,13 +6,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 @@ -62,7 +62,7 @@ /** * Helper class for working with XML documents. - * + * * @author Curtis Rueden */ public class XML { @@ -76,19 +76,19 @@ public class XML { /** XPath evaluation mechanism. */ private final XPath xpath; - private final boolean debug = - "debug".equals(System.getProperty("scijava.log.level")); + private final boolean debug = "debug".equals(System.getProperty( + "scijava.log.level")); /** Parses XML from the given file. */ - public XML(final File file) throws ParserConfigurationException, - SAXException, IOException + public XML(final File file) throws ParserConfigurationException, SAXException, + IOException { this(file.getAbsolutePath(), loadXML(file)); } /** Parses XML from the given URL. */ - public XML(final URL url) throws ParserConfigurationException, - SAXException, IOException + public XML(final URL url) throws ParserConfigurationException, SAXException, + IOException { this(url.getPath(), loadXML(url)); } @@ -101,8 +101,8 @@ public XML(final InputStream in) throws ParserConfigurationException, } /** Parses XML from the given string. */ - public XML(final String s) throws ParserConfigurationException, - SAXException, IOException + public XML(final String s) throws ParserConfigurationException, SAXException, + IOException { this(null, loadXML(s)); } @@ -119,7 +119,7 @@ public XML(final String path, final Document doc) { // Protect against class skew: some projects find it funny to ship outdated // xalan, causing problems due to incompatible xalan/xerces combinations. - // + // // We work around that by letting the XPathFactory try with the current // context class loader, and fall back onto its parent until it succeeds // (because the XPathFactory will ask the context class loader to find the @@ -141,7 +141,8 @@ public XML(final String path, final Document doc) { // make sure that the current xalan/xerces pair can evaluate // expressions (i.e. *not* throw NoSuchMethodErrors). xp.evaluate("//dummy", doc); - } catch (Throwable t) { + } + catch (Throwable t) { if (debug) { System.err.println("There was a problem with " + xp.getClass() + " in " + Types.location(xp.getClass()) + ":"); @@ -242,7 +243,7 @@ public static String cdata(final Element el, final String child) { public static ArrayList elements(final NodeList nodes) { final ArrayList elements = new ArrayList<>(); if (nodes != null) { - for (int i=0; i elements(final NodeList nodes) { } /** Gets the given element's specified child elements. */ - public static ArrayList - elements(final Element el, final String child) + public static ArrayList elements(final Element el, + final String child) { return elements(el.getElementsByTagName(child)); } diff --git a/src/main/java/org/scijava/welcome/DefaultWelcomeService.java b/src/main/java/org/scijava/welcome/DefaultWelcomeService.java index b9af9fd48..d06353b41 100644 --- a/src/main/java/org/scijava/welcome/DefaultWelcomeService.java +++ b/src/main/java/org/scijava/welcome/DefaultWelcomeService.java @@ -6,13 +6,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 @@ -51,7 +51,7 @@ /** * Default service for displaying the welcome greeting. - * + * * @author Curtis Rueden * @author Mark Hiner */ @@ -101,7 +101,8 @@ private void displayWelcome(final boolean force) { if (welcomeFile.exists()) { final String welcomeText = textService.asHTML(welcomeFile); final String checksum = DigestUtils.bestHex(welcomeText); - final String previousChecksum = prefService.get(getClass(), CHECKSUM_PREFS_KEY); + final String previousChecksum = prefService.get(getClass(), + CHECKSUM_PREFS_KEY); if (!force && checksum.equals(previousChecksum)) return; prefService.put(getClass(), CHECKSUM_PREFS_KEY, checksum); displayService.createDisplay(welcomeText); diff --git a/src/main/java/org/scijava/welcome/WelcomeService.java b/src/main/java/org/scijava/welcome/WelcomeService.java index ac690f3bc..f5b8b1db8 100644 --- a/src/main/java/org/scijava/welcome/WelcomeService.java +++ b/src/main/java/org/scijava/welcome/WelcomeService.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Interface for services to display the welcome greeting when the UI is shown * for the first time. - * + * * @author Curtis Rueden * @author Mark Hiner */ diff --git a/src/main/java/org/scijava/welcome/event/WelcomeEvent.java b/src/main/java/org/scijava/welcome/event/WelcomeEvent.java index 2f38dc848..addf1fe38 100644 --- a/src/main/java/org/scijava/welcome/event/WelcomeEvent.java +++ b/src/main/java/org/scijava/welcome/event/WelcomeEvent.java @@ -6,13 +6,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 @@ -26,15 +26,14 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.welcome.event; import org.scijava.event.SciJavaEvent; - /** - * Marker {@link SciJavaEvent} indicating the first time an application is - * run. - * + * Marker {@link SciJavaEvent} indicating the first time an application is run. + * * @author Mark Hiner */ public class WelcomeEvent extends SciJavaEvent { diff --git a/src/main/java/org/scijava/widget/AbstractInputHarvester.java b/src/main/java/org/scijava/widget/AbstractInputHarvester.java index 1eaea1045..1b6158cf7 100644 --- a/src/main/java/org/scijava/widget/AbstractInputHarvester.java +++ b/src/main/java/org/scijava/widget/AbstractInputHarvester.java @@ -6,13 +6,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 @@ -50,7 +50,7 @@ * An input harvester obtains a module's unresolved input parameter values from * the user. Parameters are collected using an {@link InputPanel} dialog box. *

      - * + * * @author Curtis Rueden * @param

      The type of UI component housing the input panel itself. * @param The type of UI component housing each input widget. @@ -104,8 +104,8 @@ private WidgetModel addInput(final InputPanel inputPanel, if (resolved) return null; // skip resolved inputs final Class type = item.getType(); - final WidgetModel model = - widgetService.createModel(inputPanel, module, item, getObjects(type)); + final WidgetModel model = widgetService.createModel(inputPanel, module, + item, getObjects(type)); final Class widgetType = inputPanel.getWidgetComponentType(); final InputWidget widget = widgetService.create(model); @@ -134,13 +134,18 @@ private List getObjects(final Class type) { List objects = new ArrayList<>(objectService.getObjects(type)); // Get all the known objects that can be converted to the destination type - Collection compatibleInputs = convertService.getCompatibleInputs(type); - - // HACK: Add each convertible object that doesn't share a name with any other object - // Our goal here is to de-duplicate by avoiding similar inputs that could be converted - // to the same effective output (e.g. an ImageDisplay and a Dataset that map to the same + Collection compatibleInputs = convertService.getCompatibleInputs( + type); + + // HACK: Add each convertible object that doesn't share a name with any + // other object + // Our goal here is to de-duplicate by avoiding similar inputs that could be + // converted + // to the same effective output (e.g. an ImageDisplay and a Dataset that map + // to the same // ImgPlus) - Set knownNames = objects.stream().map(Object::toString).collect(Collectors.toSet()); + Set knownNames = objects.stream().map(Object::toString).collect( + Collectors.toSet()); for (Object o : compatibleInputs) { final String s = o.toString(); if (!knownNames.contains(s)) { diff --git a/src/main/java/org/scijava/widget/AbstractInputPanel.java b/src/main/java/org/scijava/widget/AbstractInputPanel.java index 5b6637b19..b3f467e9a 100644 --- a/src/main/java/org/scijava/widget/AbstractInputPanel.java +++ b/src/main/java/org/scijava/widget/AbstractInputPanel.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * Abstract superclass of UI-specific {@link InputPanel} implementations. - * + * * @author Curtis Rueden * @param

      The type of UI component housing the input panel itself. * @param The type of UI component housing each input widget. @@ -42,8 +42,7 @@ public abstract class AbstractInputPanel implements InputPanel { /** Table of widgets. */ - protected Map> widgets = - new HashMap<>(); + protected Map> widgets = new HashMap<>(); // -- InputPanel methods -- @@ -51,7 +50,7 @@ public abstract class AbstractInputPanel implements InputPanel { public void addWidget(final InputWidget widget) { widgets.put(widget.get().getItem().getName(), widget); } - + @Override public InputWidget getWidget(final String name) { return widgets.get(name); diff --git a/src/main/java/org/scijava/widget/AbstractInputWidget.java b/src/main/java/org/scijava/widget/AbstractInputWidget.java index bedf6d594..95cbf758f 100644 --- a/src/main/java/org/scijava/widget/AbstractInputWidget.java +++ b/src/main/java/org/scijava/widget/AbstractInputWidget.java @@ -6,13 +6,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,7 +33,7 @@ /** * Base class for input widgets. - * + * * @author Curtis Rueden * @param The input type of the widget. * @param The type of UI component housing the widget. diff --git a/src/main/java/org/scijava/widget/Button.java b/src/main/java/org/scijava/widget/Button.java index 0768762a2..3e1e207eb 100644 --- a/src/main/java/org/scijava/widget/Button.java +++ b/src/main/java/org/scijava/widget/Button.java @@ -6,13 +6,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 @@ -34,7 +34,7 @@ /** * A interface used for marking input fields of plugin parameter dialogs as * button fields. - * + * * @author Barry DeZonia */ public interface Button extends Optional { diff --git a/src/main/java/org/scijava/widget/ButtonWidget.java b/src/main/java/org/scijava/widget/ButtonWidget.java index a56b33065..9bfb8a9a1 100644 --- a/src/main/java/org/scijava/widget/ButtonWidget.java +++ b/src/main/java/org/scijava/widget/ButtonWidget.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Widget interface for buttons. - * + * * @author Curtis Rueden */ public interface ButtonWidget extends InputWidget { diff --git a/src/main/java/org/scijava/widget/ChoiceWidget.java b/src/main/java/org/scijava/widget/ChoiceWidget.java index 25ff52afe..1a37557b9 100644 --- a/src/main/java/org/scijava/widget/ChoiceWidget.java +++ b/src/main/java/org/scijava/widget/ChoiceWidget.java @@ -6,13 +6,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 @@ -31,28 +31,28 @@ /** * Widget interface for multiple choice selectors. - * + * * @author Curtis Rueden */ public interface ChoiceWidget extends InputWidget { /** * Widget style for list boxes. - * + * * @see org.scijava.plugin.Parameter#style() */ String LIST_BOX_STYLE = "listBox"; /** * Widget style for radio buttons arranged on a single line. - * + * * @see org.scijava.plugin.Parameter#style() */ String RADIO_BUTTON_HORIZONTAL_STYLE = "radioButtonHorizontal"; /** * Widget style for radio buttons arranged one per line. - * + * * @see org.scijava.plugin.Parameter#style() */ String RADIO_BUTTON_VERTICAL_STYLE = "radioButtonVertical"; diff --git a/src/main/java/org/scijava/widget/ColorWidget.java b/src/main/java/org/scijava/widget/ColorWidget.java index 427f64922..9fae36442 100644 --- a/src/main/java/org/scijava/widget/ColorWidget.java +++ b/src/main/java/org/scijava/widget/ColorWidget.java @@ -6,13 +6,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,7 +33,7 @@ /** * Widget interface for color choosers. - * + * * @author Curtis Rueden */ public interface ColorWidget extends InputWidget { diff --git a/src/main/java/org/scijava/widget/DateWidget.java b/src/main/java/org/scijava/widget/DateWidget.java index 4cc60c0b5..52ea5da90 100644 --- a/src/main/java/org/scijava/widget/DateWidget.java +++ b/src/main/java/org/scijava/widget/DateWidget.java @@ -6,13 +6,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,7 +33,7 @@ /** * Widget interface for dates. - * + * * @author Curtis Rueden */ public interface DateWidget extends InputWidget { diff --git a/src/main/java/org/scijava/widget/DefaultWidgetModel.java b/src/main/java/org/scijava/widget/DefaultWidgetModel.java index 7bea4bc8c..fd3c179f7 100644 --- a/src/main/java/org/scijava/widget/DefaultWidgetModel.java +++ b/src/main/java/org/scijava/widget/DefaultWidgetModel.java @@ -6,13 +6,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 @@ -51,10 +51,12 @@ /** * The backing data model for a particular {@link InputWidget}. - * + * * @author Curtis Rueden */ -public class DefaultWidgetModel extends AbstractContextual implements WidgetModel { +public class DefaultWidgetModel extends AbstractContextual implements + WidgetModel +{ private final InputPanel inputPanel; private final Module module; @@ -79,8 +81,9 @@ public class DefaultWidgetModel extends AbstractContextual implements WidgetMode private boolean initialized; - public DefaultWidgetModel(final Context context, final InputPanel inputPanel, - final Module module, final ModuleItem item, final List objectPool) + public DefaultWidgetModel(final Context context, + final InputPanel inputPanel, final Module module, + final ModuleItem item, final List objectPool) { setContext(context); this.inputPanel = inputPanel; @@ -147,8 +150,8 @@ public void setValue(final Object value) { // Check if a converted value is present Object convertedInput = convertedObjects.get(value); - if (convertedInput != null && - Objects.equals(item.getValue(module), convertedInput)) + if (convertedInput != null && Objects.equals(item.getValue(module), + convertedInput)) { return; // no change } @@ -288,7 +291,7 @@ public boolean isInitialized() { /** * For multiple choice widgets, ensures the value is a valid choice. - * + * * @see ChoiceWidget */ private Object ensureValidChoice(final Object value) { @@ -297,7 +300,7 @@ private Object ensureValidChoice(final Object value) { /** * For object widgets, ensures the value is a valid object. - * + * * @see #getObjectPool() * @see ObjectWidget */ diff --git a/src/main/java/org/scijava/widget/DefaultWidgetService.java b/src/main/java/org/scijava/widget/DefaultWidgetService.java index 6f35b2efa..544f5a65e 100644 --- a/src/main/java/org/scijava/widget/DefaultWidgetService.java +++ b/src/main/java/org/scijava/widget/DefaultWidgetService.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * Default service for managing available {@link InputWidget}s. - * + * * @author Curtis Rueden */ @Plugin(type = Service.class) diff --git a/src/main/java/org/scijava/widget/FileListWidget.java b/src/main/java/org/scijava/widget/FileListWidget.java index fc310519b..ec3c0a482 100644 --- a/src/main/java/org/scijava/widget/FileListWidget.java +++ b/src/main/java/org/scijava/widget/FileListWidget.java @@ -6,13 +6,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 @@ -26,28 +26,30 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.widget; import java.io.File; public interface FileListWidget extends InputWidget { + /** * Widget style to allow file selection only - * + * * @see org.scijava.plugin.Parameter#style() */ String FILES_ONLY = "files"; /** * Widget style to allow directory selection only - * + * * @see org.scijava.plugin.Parameter#style() */ String DIRECTORIES_ONLY = "directories"; /** * Widget style to allow selection of both files and directories - * + * * @see org.scijava.plugin.Parameter#style() */ String FILES_AND_DIRECTORIES = "both"; diff --git a/src/main/java/org/scijava/widget/FileWidget.java b/src/main/java/org/scijava/widget/FileWidget.java index 5567cb967..fa6a3f74e 100644 --- a/src/main/java/org/scijava/widget/FileWidget.java +++ b/src/main/java/org/scijava/widget/FileWidget.java @@ -6,13 +6,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,28 +33,28 @@ /** * Widget interface for file selectors. - * + * * @author Curtis Rueden */ public interface FileWidget extends InputWidget { /** * Widget style for file opener dialogs. - * + * * @see org.scijava.plugin.Parameter#style() */ String OPEN_STYLE = "open"; /** * Widget style for file saver dialogs. - * + * * @see org.scijava.plugin.Parameter#style() */ String SAVE_STYLE = "save"; /** * Widget style for directory chooser dialogs. - * + * * @see org.scijava.plugin.Parameter#style() */ String DIRECTORY_STYLE = "directory"; diff --git a/src/main/java/org/scijava/widget/InputHarvester.java b/src/main/java/org/scijava/widget/InputHarvester.java index fe27f5480..b44d6e306 100644 --- a/src/main/java/org/scijava/widget/InputHarvester.java +++ b/src/main/java/org/scijava/widget/InputHarvester.java @@ -6,13 +6,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 @@ -47,7 +47,7 @@ *

    • Perform any other needed processing of the results (marking inputs as * resolved, storing persisted values to preferences, etc.).
    • * - * + * * @author Curtis Rueden * @param

      The type of UI component housing the input panel itself. * @param The type of UI component housing each input widget. @@ -58,7 +58,7 @@ public interface InputHarvester { /** * Performs the harvesting process. - * + * * @param module The module whose inputs should be harvest. * @throws ModuleException If the process goes wrong, or is canceled. */ @@ -82,7 +82,7 @@ default void harvest(final Module module) throws ModuleException { /** * Populates the given {@link InputPanel} with widgets corresponding to the * given {@link Module} instance. - * + * * @param inputPanel The panel to populate. * @param module The module whose inputs should be translated into widgets. * @throws ModuleException if the panel cannot be populated for some reason. diff --git a/src/main/java/org/scijava/widget/InputPanel.java b/src/main/java/org/scijava/widget/InputPanel.java index f937027bc..603de07ad 100644 --- a/src/main/java/org/scijava/widget/InputPanel.java +++ b/src/main/java/org/scijava/widget/InputPanel.java @@ -6,13 +6,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 @@ -32,7 +32,7 @@ /** * Flexible panel-building interface, for use with UIs that prompt for input * values of various types. - * + * * @author Curtis Rueden * @param

      The type of UI component housing the input panel itself. * @param The type of UI component housing each input widget. @@ -54,7 +54,7 @@ default boolean supports(final InputWidget widget) { /** * Returns the value of the given widget's input. - * + * * @param name unique name identifying this field */ Object getValue(String name); @@ -73,7 +73,7 @@ default boolean supports(final InputWidget widget) { /** 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); diff --git a/src/main/java/org/scijava/widget/InputWidget.java b/src/main/java/org/scijava/widget/InputWidget.java index 221c3770b..3452640b9 100644 --- a/src/main/java/org/scijava/widget/InputWidget.java +++ b/src/main/java/org/scijava/widget/InputWidget.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ * implementing this interface, it is encouraged to instead extend * {@link AbstractInputWidget}, for convenience. *

      - * + * * @author Curtis Rueden * @param The input type of the widget. * @param The type of UI component housing the widget. @@ -70,7 +70,7 @@ public interface InputWidget extends WrapperPlugin, * Returns true iff the widget should be labeled with the parameter label. * Most widgets are labeled this way, though some may not be; e.g., * {@link MessageWidget}s. - * + * * @see WidgetModel#getWidgetLabel() */ default boolean isLabeled() { diff --git a/src/main/java/org/scijava/widget/MessageWidget.java b/src/main/java/org/scijava/widget/MessageWidget.java index 20347c3b2..bd8105d47 100644 --- a/src/main/java/org/scijava/widget/MessageWidget.java +++ b/src/main/java/org/scijava/widget/MessageWidget.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Widget interface for message labels. - * + * * @author Curtis Rueden */ public interface MessageWidget extends InputWidget { diff --git a/src/main/java/org/scijava/widget/NumberWidget.java b/src/main/java/org/scijava/widget/NumberWidget.java index 79bfa46cd..9a380a4d4 100644 --- a/src/main/java/org/scijava/widget/NumberWidget.java +++ b/src/main/java/org/scijava/widget/NumberWidget.java @@ -6,13 +6,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 @@ -31,28 +31,28 @@ /** * Widget interface for number choosers. - * + * * @author Curtis Rueden */ public interface NumberWidget extends InputWidget { /** * Widget style for slider with spinner. - * + * * @see org.scijava.plugin.Parameter#style() */ String SLIDER_STYLE = "slider"; /** * Widget style for spinner only. - * + * * @see org.scijava.plugin.Parameter#style() */ String SPINNER_STYLE = "spinner"; /** * Widget style for scroll bar with spinner. - * + * * @see org.scijava.plugin.Parameter#style() */ String SCROLL_BAR_STYLE = "scroll bar"; diff --git a/src/main/java/org/scijava/widget/ObjectWidget.java b/src/main/java/org/scijava/widget/ObjectWidget.java index 27c9560c6..dda24fd46 100644 --- a/src/main/java/org/scijava/widget/ObjectWidget.java +++ b/src/main/java/org/scijava/widget/ObjectWidget.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Widget interface for object selectors. - * + * * @author Curtis Rueden */ public interface ObjectWidget extends InputWidget { diff --git a/src/main/java/org/scijava/widget/TextWidget.java b/src/main/java/org/scijava/widget/TextWidget.java index 716750d69..70b51b7e1 100644 --- a/src/main/java/org/scijava/widget/TextWidget.java +++ b/src/main/java/org/scijava/widget/TextWidget.java @@ -6,13 +6,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 @@ -31,28 +31,28 @@ /** * Widget interface for text fields and areas. - * + * * @author Curtis Rueden */ public interface TextWidget extends InputWidget { /** * Widget style for text fields. - * + * * @see org.scijava.plugin.Parameter#style() */ String FIELD_STYLE = "text field"; /** * Widget style for text areas. - * + * * @see org.scijava.plugin.Parameter#style() */ String AREA_STYLE = "text area"; /** * Widget style for password fields. - * + * * @see org.scijava.plugin.Parameter#style() */ String PASSWORD_STYLE = "password"; diff --git a/src/main/java/org/scijava/widget/ToggleWidget.java b/src/main/java/org/scijava/widget/ToggleWidget.java index 8a56a9662..43c97e35f 100644 --- a/src/main/java/org/scijava/widget/ToggleWidget.java +++ b/src/main/java/org/scijava/widget/ToggleWidget.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Widget interface for boolean toggles. - * + * * @author Curtis Rueden */ public interface ToggleWidget extends InputWidget { diff --git a/src/main/java/org/scijava/widget/UIComponent.java b/src/main/java/org/scijava/widget/UIComponent.java index 2b7f56e0a..dc3958a06 100644 --- a/src/main/java/org/scijava/widget/UIComponent.java +++ b/src/main/java/org/scijava/widget/UIComponent.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An interface identifying an object housed within a UI component. - * + * * @author Curtis Rueden * @param The type of UI component housing the object. */ diff --git a/src/main/java/org/scijava/widget/WidgetModel.java b/src/main/java/org/scijava/widget/WidgetModel.java index a2ee20dcd..536973188 100644 --- a/src/main/java/org/scijava/widget/WidgetModel.java +++ b/src/main/java/org/scijava/widget/WidgetModel.java @@ -6,13 +6,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,7 +38,7 @@ /** * The backing data model for a particular {@link InputWidget}. - * + * * @author Curtis Rueden */ public interface WidgetModel extends Contextual { @@ -61,7 +61,7 @@ public interface WidgetModel extends Contextual { * values, but rather provides a list of possibilities in cases where the * realm of values is not defined by the type in some other way. *

      - * + * * @see ObjectWidget */ List getObjectPool(); @@ -99,21 +99,21 @@ public interface WidgetModel extends Contextual { /** * Gets the minimum value for the module input. - * + * * @return The minimum value, or null if the type is unbounded. */ Number getMin(); /** * Gets the maximum value for the module input. - * + * * @return The maximum value, or null if the type is unbounded. */ Number getMax(); /** * Gets the "soft" minimum value for the module input. - * + * * @return The "soft" minimum value, or {@link #getMin()} if none. * @see ModuleItem#getSoftMinimum() */ @@ -121,7 +121,7 @@ public interface WidgetModel extends Contextual { /** * Gets the "soft" maximum value for the module input. - * + * * @return The "soft" maximum value, or {@link #getMax()} if none. * @see ModuleItem#getSoftMaximum() */ @@ -129,14 +129,14 @@ public interface WidgetModel extends Contextual { /** * Gets the step size between values for the module input. - * + * * @return The step size, or 1 by default. */ Number getStepSize(); /** * Gets the multiple choice list for the module input. - * + * * @return The available choices, or an empty list if not multiple choice. * @see ChoiceWidget */ @@ -144,7 +144,7 @@ public interface WidgetModel extends Contextual { /** * Gets the input's value rendered as a string. - * + * * @return String representation of the input value, or the empty string if * the value is null or the null character ('\0'). */ @@ -152,7 +152,7 @@ public interface WidgetModel extends Contextual { /** * Gets whether the input is a message. - * + * * @see ItemVisibility#MESSAGE */ boolean isMessage(); diff --git a/src/main/java/org/scijava/widget/WidgetService.java b/src/main/java/org/scijava/widget/WidgetService.java index 01857a29c..79f77f97f 100644 --- a/src/main/java/org/scijava/widget/WidgetService.java +++ b/src/main/java/org/scijava/widget/WidgetService.java @@ -6,13 +6,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,7 +38,7 @@ /** * Interface for services that manage available {@link InputWidget}s. - * + * * @author Curtis Rueden */ public interface WidgetService extends @@ -51,7 +51,7 @@ public interface WidgetService extends /** * Create a {@link WidgetModel} for the given module input. - * + * * @param inputPanel * @param module * @param item @@ -67,7 +67,7 @@ default WidgetModel createModel(InputPanel inputPanel, Module module, // -- PTService methods -- @Override - @SuppressWarnings({"rawtypes", "unchecked"}) + @SuppressWarnings({ "rawtypes", "unchecked" }) default Class> getPluginType() { return (Class) InputWidget.class; } diff --git a/src/main/java/org/scijava/widget/WidgetStyle.java b/src/main/java/org/scijava/widget/WidgetStyle.java index 65491717d..30f77e2c8 100644 --- a/src/main/java/org/scijava/widget/WidgetStyle.java +++ b/src/main/java/org/scijava/widget/WidgetStyle.java @@ -6,13 +6,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 @@ -26,28 +26,27 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.widget; import org.scijava.module.ModuleItem; public class WidgetStyle { + private WidgetStyle() { // prevent instantiation of utility class } /** * Check whether a given widget style contains the target style. - * - * @param widgetStyle - * The style declaration to test, usually a comma-separated - * {@code String}; trailing spaces are ignored. - * @param target - * The style being checked, case-insensitive. + * + * @param widgetStyle The style declaration to test, usually a comma-separated + * {@code String}; trailing spaces are ignored. + * @param target The style being checked, case-insensitive. * @return {@code true} if the target style matches. */ public static boolean isStyle(String widgetStyle, String target) { - if (widgetStyle == null || target == null) - return widgetStyle == target; + if (widgetStyle == null || target == null) return widgetStyle == target; for (final String s : widgetStyle.split(",")) { if (s.trim().toLowerCase().equals(target.toLowerCase())) return true; } @@ -56,11 +55,9 @@ public static boolean isStyle(String widgetStyle, String target) { /** * Check whether a given {@link ModuleItem} has the target style. - * - * @param item - * The module item to test. - * @param target - * The style being checked, case-insensitive. + * + * @param item The module item to test. + * @param target The style being checked, case-insensitive. * @return {@code true} if the module item has the target style. */ public static boolean isStyle(ModuleItem item, String target) { @@ -69,21 +66,18 @@ public static boolean isStyle(ModuleItem item, String target) { /** * Get the modifying value for a given style attribute in a style declaration. - * *

      * For example, for {@code style="format:#0.00"}, this will return * {@code "#0.00"}. *

      - * - * @param widgetStyle - * The style declaration string, e.g. "format:#0.00". - * @param target - * The target style attribute, e.g. "format". + * + * @param widgetStyle The style declaration string, e.g. + * "format:#0.00". + * @param target The target style attribute, e.g. "format". * @return The modifier for the given target, e.g. "#0.00". */ public static String getStyleModifier(String widgetStyle, String target) { - if (widgetStyle == null || target == null) - return null; + if (widgetStyle == null || target == null) return null; String[] styles = widgetStyle.split(","); for (String s : styles) { if (s.trim().toLowerCase().startsWith(target.toLowerCase())) { @@ -95,16 +89,16 @@ public static String getStyleModifier(String widgetStyle, String target) { /** * Get an array of all modifying values for a given style attribute. - * *

      - * For example, for {@code style="extensions:png/gif/bmp"}, this will return {@code ["png", "gif", "bmp"]}. + * For example, for {@code style="extensions:png/gif/bmp"}, this will return + * {@code ["png", "gif", "bmp"]}. *

      - * - * @param widgetStyle - * The style declaration string, e.g. "extensions:png/gif/bmp". - * @param target - * The target style attribute, e.g. "extensions". - * @return An array of modifiers for the given target, e.g. ["png", "gif", "bmp"]. + * + * @param widgetStyle The style declaration string, e.g. + * "extensions:png/gif/bmp". + * @param target The target style attribute, e.g. "extensions". + * @return An array of modifiers for the given target, e.g. + * ["png", "gif", "bmp"]. */ public static String[] getStyleModifiers(String widgetStyle, String target) { String suffix = getStyleModifier(widgetStyle, target); diff --git a/src/test/java/org/scijava/ContextCreationTest.java b/src/test/java/org/scijava/ContextCreationTest.java index 9b5769ef3..2fdd494b7 100644 --- a/src/test/java/org/scijava/ContextCreationTest.java +++ b/src/test/java/org/scijava/ContextCreationTest.java @@ -6,13 +6,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 @@ -55,7 +55,7 @@ /** * Tests {@link Context} creation with {@link Service} dependencies. - * + * * @author Curtis Rueden */ public class ContextCreationTest { @@ -84,48 +84,47 @@ public void testNoPlugins() { */ @Test public void testFull() { - final Class[] expected = - { org.scijava.event.DefaultEventService.class, - org.scijava.app.DefaultAppService.class, - org.scijava.app.DefaultStatusService.class, - org.scijava.command.DefaultCommandService.class, - org.scijava.console.DefaultConsoleService.class, - org.scijava.convert.DefaultConvertService.class, - org.scijava.display.DefaultDisplayService.class, - org.scijava.download.DefaultDownloadService.class, - org.scijava.event.DefaultEventHistory.class, - org.scijava.input.DefaultInputService.class, - org.scijava.io.DefaultIOService.class, - org.scijava.io.DefaultRecentFileService.class, - org.scijava.io.handle.DefaultDataHandleService.class, - org.scijava.io.location.DefaultLocationService.class, - org.scijava.io.nio.DefaultNIOService.class, - org.scijava.main.DefaultMainService.class, - org.scijava.menu.DefaultMenuService.class, - 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, - org.scijava.run.DefaultRunService.class, - org.scijava.script.DefaultScriptHeaderService.class, - org.scijava.script.DefaultScriptService.class, - org.scijava.script.process.DefaultScriptProcessorService.class, - org.scijava.startup.DefaultStartupService.class, - org.scijava.task.DefaultTaskService.class, - org.scijava.text.DefaultTextService.class, - org.scijava.text.io.DefaultTextIOService.class, - org.scijava.thread.DefaultThreadService.class, - org.scijava.tool.DefaultToolService.class, - org.scijava.ui.DefaultUIService.class, - org.scijava.ui.dnd.DefaultDragAndDropService.class, - org.scijava.welcome.DefaultWelcomeService.class, - org.scijava.widget.DefaultWidgetService.class, - org.scijava.log.StderrLogService.class, - org.scijava.platform.DefaultAppEventService.class, - org.scijava.cache.DefaultCacheService.class}; + final Class[] expected = { org.scijava.event.DefaultEventService.class, + org.scijava.app.DefaultAppService.class, + org.scijava.app.DefaultStatusService.class, + org.scijava.command.DefaultCommandService.class, + org.scijava.console.DefaultConsoleService.class, + org.scijava.convert.DefaultConvertService.class, + org.scijava.display.DefaultDisplayService.class, + org.scijava.download.DefaultDownloadService.class, + org.scijava.event.DefaultEventHistory.class, + org.scijava.input.DefaultInputService.class, + org.scijava.io.DefaultIOService.class, + org.scijava.io.DefaultRecentFileService.class, + org.scijava.io.handle.DefaultDataHandleService.class, + org.scijava.io.location.DefaultLocationService.class, + org.scijava.io.nio.DefaultNIOService.class, + org.scijava.main.DefaultMainService.class, + org.scijava.menu.DefaultMenuService.class, + 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, + org.scijava.run.DefaultRunService.class, + org.scijava.script.DefaultScriptHeaderService.class, + org.scijava.script.DefaultScriptService.class, + org.scijava.script.process.DefaultScriptProcessorService.class, + org.scijava.startup.DefaultStartupService.class, + org.scijava.task.DefaultTaskService.class, + org.scijava.text.DefaultTextService.class, + org.scijava.text.io.DefaultTextIOService.class, + org.scijava.thread.DefaultThreadService.class, + org.scijava.tool.DefaultToolService.class, + org.scijava.ui.DefaultUIService.class, + org.scijava.ui.dnd.DefaultDragAndDropService.class, + org.scijava.welcome.DefaultWelcomeService.class, + org.scijava.widget.DefaultWidgetService.class, + org.scijava.log.StderrLogService.class, + org.scijava.platform.DefaultAppEventService.class, + org.scijava.cache.DefaultCacheService.class }; final Context context = new Context(); verifyServiceOrder(expected, context); @@ -194,8 +193,8 @@ public void testMissingDirect() { fail("Expected IllegalArgumentException"); } catch (final IllegalArgumentException exc) { - final String expectedMessage = - "No compatible service: " + MissingService.class.getName(); + final String expectedMessage = "No compatible service: " + + MissingService.class.getName(); assertEquals(expectedMessage, exc.getMessage()); } } @@ -212,11 +211,11 @@ public void testMissingTransitive() { fail("Expected IllegalArgumentException"); } catch (final IllegalArgumentException exc) { - final String expectedMessage = - "Invalid service: " + ServiceRequiringMissingService.class.getName(); + final String expectedMessage = "Invalid service: " + + ServiceRequiringMissingService.class.getName(); assertEquals(expectedMessage, exc.getMessage()); - final String expectedCause = - "No compatible service: " + MissingService.class.getName(); + final String expectedCause = "No compatible service: " + + MissingService.class.getName(); assertEquals(expectedCause, exc.getCause().getMessage()); } } @@ -238,12 +237,11 @@ public void testOptionalMissingTransitive() { fail("Expected IllegalArgumentException"); } catch (final IllegalArgumentException exc) { - final String expectedMessage = - "Invalid service: " + - ServiceRequiringOptionalMissingService.class.getName(); + final String expectedMessage = "Invalid service: " + + ServiceRequiringOptionalMissingService.class.getName(); assertEquals(expectedMessage, exc.getMessage()); - final String expectedCause = - "No compatible service: " + OptionalMissingService.class.getName(); + final String expectedCause = "No compatible service: " + + OptionalMissingService.class.getName(); assertEquals(expectedCause, exc.getCause().getMessage()); } } @@ -255,8 +253,8 @@ public void testOptionalMissingTransitive() { */ @Test public void testNonStrictMissingDirect() { - final List> serviceClasses = - Context.serviceClassList(MissingService.class); + final List> serviceClasses = Context + .serviceClassList(MissingService.class); final Context context = new Context(serviceClasses, false); assertEquals(0, context.getServiceIndex().size()); } @@ -269,8 +267,8 @@ public void testNonStrictMissingDirect() { */ @Test public void testNonStrictMissingTransitive() { - final List> serviceClasses = - Context.serviceClassList(MissingService.class); + final List> serviceClasses = Context + .serviceClassList(MissingService.class); final Context context = new Context(serviceClasses, false); assertEquals(0, context.getServiceIndex().size()); } @@ -288,8 +286,8 @@ public void testNonStrictMissingTransitive() { */ @Test public void testNonStrictOptionalMissingTransitive() { - final List> serviceClasses = - Context.serviceClassList(ServiceRequiringOptionalMissingService.class); + final List> serviceClasses = Context + .serviceClassList(ServiceRequiringOptionalMissingService.class); final Context context = new Context(serviceClasses, false); final List services = context.getServiceIndex().getAll(); assertEquals(1, services.size()); @@ -359,8 +357,8 @@ public void testNoServicesCtor() { // Add another service, that is not indexed under Service.class index.add(new PluginInfo<>(ThreadService.class.getName(), SciJavaPlugin.class)); - final Context c = - new Context(pluginIndex(BaseImpl.class, ExtensionImpl.class)); + final Context c = new Context(pluginIndex(BaseImpl.class, + ExtensionImpl.class)); assertEquals(2, c.getServiceIndex().size()); } @@ -378,8 +376,8 @@ public void testNoServicesCtor() { public void testOptionalMissingDirect() { final Context context = new Context(OptionalMissingService.class); - final OptionalMissingService optionalMissingService = - context.getService(OptionalMissingService.class); + final OptionalMissingService optionalMissingService = context.getService( + OptionalMissingService.class); assertNull(optionalMissingService); // verify that there are *no* services in the context @@ -397,13 +395,13 @@ public void testNonRequiredMissingService() { final Context context = new Context(ServiceWantingMissingService.class); assertEquals(1, context.getServiceIndex().size()); - final ServiceWantingMissingService serviceWantingMissingService = - context.getService(ServiceWantingMissingService.class); + final ServiceWantingMissingService serviceWantingMissingService = context + .getService(ServiceWantingMissingService.class); assertNotNull(serviceWantingMissingService); assertNull(serviceWantingMissingService.missingService); - final MissingService missingService = - context.getService(MissingService.class); + final MissingService missingService = context.getService( + MissingService.class); assertNull(missingService); // verify that the *only* service is ServiceWantingMissing diff --git a/src/test/java/org/scijava/ContextDisposalTest.java b/src/test/java/org/scijava/ContextDisposalTest.java index 4f66ab6f9..acdca218a 100644 --- a/src/test/java/org/scijava/ContextDisposalTest.java +++ b/src/test/java/org/scijava/ContextDisposalTest.java @@ -6,13 +6,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,7 +33,7 @@ /** * Tests disposal of {@link Context}s. - * + * * @author Curtis Rueden */ public class ContextDisposalTest { diff --git a/src/test/java/org/scijava/ContextInjectionTest.java b/src/test/java/org/scijava/ContextInjectionTest.java index df3c46ece..6768ad013 100644 --- a/src/test/java/org/scijava/ContextInjectionTest.java +++ b/src/test/java/org/scijava/ContextInjectionTest.java @@ -6,13 +6,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 @@ -49,7 +49,7 @@ * Tests {@link Context} and {@link Service} injection via the * {@link Context#inject(Object)} and * {@link AbstractContextual#setContext(Context)} methods. - * + * * @author Curtis Rueden */ public class ContextInjectionTest { @@ -145,9 +145,8 @@ public void testNonContextualContextParameters() { fail("Expected IllegalStateException"); } catch (final IllegalStateException exc) { - final String expectedMessage = - "Context already injected: " + needsContext.getClass().getName() + - "#context"; + final String expectedMessage = "Context already injected: " + needsContext + .getClass().getName() + "#context"; assertEquals(expectedMessage, exc.getMessage()); } } diff --git a/src/test/java/org/scijava/SciJavaTest.java b/src/test/java/org/scijava/SciJavaTest.java index 9daf637c6..83a39205c 100644 --- a/src/test/java/org/scijava/SciJavaTest.java +++ b/src/test/java/org/scijava/SciJavaTest.java @@ -6,13 +6,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,7 +38,7 @@ /** * Tests {@link SciJava}. - * + * * @author Curtis Rueden */ public class SciJavaTest { diff --git a/src/test/java/org/scijava/annotations/AnnotatedA.java b/src/test/java/org/scijava/annotations/AnnotatedA.java index 4c9977496..eaa252eb1 100644 --- a/src/test/java/org/scijava/annotations/AnnotatedA.java +++ b/src/test/java/org/scijava/annotations/AnnotatedA.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * An indexed type. - * + * * @author Johannes Schindelin */ @Simple diff --git a/src/test/java/org/scijava/annotations/AnnotatedB.java b/src/test/java/org/scijava/annotations/AnnotatedB.java index 46ccb442c..9c4bca891 100644 --- a/src/test/java/org/scijava/annotations/AnnotatedB.java +++ b/src/test/java/org/scijava/annotations/AnnotatedB.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * Another indexed type. - * + * * @author Johannes Schindelin */ @Complex(simple = @Simple(string1 = "Hello")) diff --git a/src/test/java/org/scijava/annotations/AnnotatedC.java b/src/test/java/org/scijava/annotations/AnnotatedC.java index 777b949f4..ba327436f 100644 --- a/src/test/java/org/scijava/annotations/AnnotatedC.java +++ b/src/test/java/org/scijava/annotations/AnnotatedC.java @@ -6,13 +6,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 @@ -31,13 +31,13 @@ /** * Another indexed type. - * + * * @author Johannes Schindelin */ @Complex(bool0 = true, byte0 = -17, short0 = -19, int0 = -23, long0 = -29, float0 = -31, double0 = -37, char0 = (char) -41, string = "Narf!", clazz = Exception.class, fruit = Fruit.Banana, simple = @Simple( - string1 = "Hello"), array = { @Simple(string1 = "one"), - @Simple(string1 = "two"), @Simple(string1 = "three") }, array1 = { -43, - -47, -53, -59 }) + string1 = "Hello"), array = { @Simple(string1 = "one"), @Simple( + string1 = "two"), @Simple(string1 = "three") }, array1 = { -43, -47, -53, + -59 }) public class AnnotatedC {} diff --git a/src/test/java/org/scijava/annotations/AnnotatedD.java b/src/test/java/org/scijava/annotations/AnnotatedD.java index d898df6d7..a718c3932 100644 --- a/src/test/java/org/scijava/annotations/AnnotatedD.java +++ b/src/test/java/org/scijava/annotations/AnnotatedD.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * 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 96ed33157..9552365a8 100644 --- a/src/test/java/org/scijava/annotations/AnnotatedInnerClass.java +++ b/src/test/java/org/scijava/annotations/AnnotatedInnerClass.java @@ -6,13 +6,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 @@ -31,7 +31,7 @@ /** * A simple class with an annotated inner class. - * + * * @author Johannes Schindelin */ public class AnnotatedInnerClass { diff --git a/src/test/java/org/scijava/annotations/Complex.java b/src/test/java/org/scijava/annotations/Complex.java index f7cb7e0ec..29daad022 100644 --- a/src/test/java/org/scijava/annotations/Complex.java +++ b/src/test/java/org/scijava/annotations/Complex.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * An annotation using all possible field types. - * + * * @author Johannes Schindelin */ @Retention(RetentionPolicy.RUNTIME) diff --git a/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java b/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java index 8a6d243e4..7d245fb04 100644 --- a/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java +++ b/src/test/java/org/scijava/annotations/DirectoryIndexerTest.java @@ -6,13 +6,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 @@ -56,7 +56,7 @@ /** * Tests the {@link DirectoryIndexer}. - * + * * @author Johannes Schindelin */ public class DirectoryIndexerTest { @@ -69,8 +69,8 @@ public void testIndexer() throws Exception { String path = url.getFile(); assumeTrue(path.indexOf(':') < 0); assertTrue(path.endsWith("/" + suffix)); - final File directory = - new File(path.substring(0, path.length() - suffix.length())); + final File directory = new File(path.substring(0, path.length() - suffix + .length())); // delete all the test annotations final File jsonDirectory = new File(directory, Index.INDEX_PREFIX); @@ -87,18 +87,20 @@ public void testIndexer() throws Exception { assertTrue(directory.exists()); // read the index - final Map> map = - readIndex(Complex.class, DirectoryIndexerTest.class.getClassLoader()); + final Map> map = readIndex(Complex.class, + DirectoryIndexerTest.class.getClassLoader()); testDefaultAnnotations(map); - // verify that default values are not written to the serialized annotation index + // verify that default values are not written to the serialized annotation + // index final File complex = new File(jsonDirectory, Complex.class.getName()); final BufferedReader reader = new BufferedReader(new FileReader(complex)); for (;;) { final String line = reader.readLine(); if (line == null) break; - assertTrue("Contains default value 'Q' for char0: " + line, line.indexOf('Q') < 0); + assertTrue("Contains default value 'Q' for char0: " + line, line.indexOf( + 'Q') < 0); } reader.close(); } @@ -106,16 +108,13 @@ public void testIndexer() throws Exception { @Test public void testRepeatedClassPathElements() throws Exception { final String suffix = getResourcePath(AnnotatedA.class); - final String classURL = - getClass().getResource("/" + suffix).toString(); - final URL classPathURL = new URL(classURL.substring(0, - classURL.length() - suffix.length())); - final ClassLoader loader = new URLClassLoader(new URL[] { - classPathURL, classPathURL - }); + final String classURL = getClass().getResource("/" + suffix).toString(); + final URL classPathURL = new URL(classURL.substring(0, classURL.length() - + suffix.length())); + final ClassLoader loader = new URLClassLoader(new URL[] { classPathURL, + classPathURL }); final Set seen = new HashSet<>(); - for (final IndexItem item : - Index.load(Simple.class, loader)) { + for (final IndexItem item : Index.load(Simple.class, loader)) { final String name = item.className(); assertFalse(seen.contains(name)); seen.add(name); @@ -123,8 +122,8 @@ public void testRepeatedClassPathElements() throws Exception { assertEquals(3, seen.size()); } - public static void - testDefaultAnnotations(Map> map) + public static void testDefaultAnnotations( + Map> map) { assertEquals(4, map.size()); Complex a = map.get(AnnotatedA.class.getName()).annotation(); diff --git a/src/test/java/org/scijava/annotations/EclipseHelperTest.java b/src/test/java/org/scijava/annotations/EclipseHelperTest.java index 6bd63ace5..825976f12 100644 --- a/src/test/java/org/scijava/annotations/EclipseHelperTest.java +++ b/src/test/java/org/scijava/annotations/EclipseHelperTest.java @@ -6,13 +6,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 @@ -46,7 +46,7 @@ /** * Verifies that the {@link EclipseHelper} does its job correctly. - * + * * @author Johannes Schindelin */ public class EclipseHelperTest { @@ -57,9 +57,8 @@ public void testSkipIndexGeneration() throws Exception { copyClasses(dir, Complex.class, Simple.class); final File jsonDir = new File(dir, Index.INDEX_PREFIX); assertFalse(jsonDir.exists()); - final URLClassLoader loader = - new URLClassLoader(new URL[] { dir.toURI().toURL() }, getClass() - .getClassLoader().getParent()); + final URLClassLoader loader = new URLClassLoader(new URL[] { dir.toURI() + .toURL() }, getClass().getClassLoader().getParent()); EclipseHelper.indexed.clear(); EclipseHelper.updateAnnotationIndex(loader); assertFalse(jsonDir.exists()); @@ -68,31 +67,32 @@ public void testSkipIndexGeneration() throws Exception { @Test 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, AnnotatedD.class); + copyClasses(dir, Complex.class, Simple.class, Fruit.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 }) + for (final Class clazz : new Class[] { Complex.class, + Simple.class }) { assertFalse(new File(jsonDir, clazz.getName()).exists()); } - final URLClassLoader loader = - new URLClassLoader(new URL[] { dir.toURI().toURL() }, getClass() - .getClassLoader().getParent()) - { + final URLClassLoader loader = new URLClassLoader(new URL[] { dir.toURI() + .toURL() }, getClass().getClassLoader().getParent()) + { - @Override - public Class loadClass(final String className) - throws ClassNotFoundException - { - if (className.equals(Indexable.class.getName())) { - return Indexable.class; - } - return super.loadClass(className); + @Override + public Class loadClass(final String className) + throws ClassNotFoundException + { + if (className.equals(Indexable.class.getName())) { + return Indexable.class; } - }; + return super.loadClass(className); + } + }; EclipseHelper.indexed.clear(); EclipseHelper.updateAnnotationIndex(loader); - for (final Class clazz : new Class[] { Complex.class, Simple.class }) + for (final Class clazz : new Class[] { Complex.class, + Simple.class }) { assertTrue(new File(jsonDir, clazz.getName()).exists()); } @@ -125,8 +125,8 @@ private void copyClasses(final File dir, final Class... classes) final byte[] buffer = new byte[16384]; for (final Class clazz : classes) { final String classPath = DirectoryIndexerTest.getResourcePath(clazz); - final InputStream in = - getClass().getResource("/" + classPath).openStream(); + final InputStream in = getClass().getResource("/" + classPath) + .openStream(); final File outFile = new File(dir, classPath); final File parent = outFile.getParentFile(); assertTrue(parent.isDirectory() || parent.mkdirs()); diff --git a/src/test/java/org/scijava/annotations/Fruit.java b/src/test/java/org/scijava/annotations/Fruit.java index 9ffb333cd..97b9dd806 100644 --- a/src/test/java/org/scijava/annotations/Fruit.java +++ b/src/test/java/org/scijava/annotations/Fruit.java @@ -6,13 +6,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 @@ -31,11 +31,11 @@ /** * A simple enum. - * + * * @author Johannes Schindelin */ public enum Fruit { - Apple, Orange, Banana, Pear + Apple, Orange, Banana, Pear } diff --git a/src/test/java/org/scijava/annotations/LegacyTest.java b/src/test/java/org/scijava/annotations/LegacyTest.java index 6bf5d5d13..6fdc84db9 100644 --- a/src/test/java/org/scijava/annotations/LegacyTest.java +++ b/src/test/java/org/scijava/annotations/LegacyTest.java @@ -6,13 +6,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 @@ -35,16 +35,15 @@ /** * Verifies that legacy annotation indexes are used. - * + * * @author Johannes Schindelin */ public class LegacyTest { @Test public void testLegacy() throws Exception { - final Map> map = - DirectoryIndexerTest.readIndex(Complex.class, getClass().getResource( - "/legacy/")); + final Map> map = DirectoryIndexerTest.readIndex( + Complex.class, getClass().getResource("/legacy/")); DirectoryIndexerTest.testDefaultAnnotations(map); } } diff --git a/src/test/java/org/scijava/annotations/Simple.java b/src/test/java/org/scijava/annotations/Simple.java index 90b426367..cd01c3256 100644 --- a/src/test/java/org/scijava/annotations/Simple.java +++ b/src/test/java/org/scijava/annotations/Simple.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * A simple annotation for use with our annotation processor. - * + * * @author Johannes Schindelin */ @Retention(RetentionPolicy.RUNTIME) diff --git a/src/test/java/org/scijava/app/StatusServiceTest.java b/src/test/java/org/scijava/app/StatusServiceTest.java index 1209d4049..42f102ab1 100644 --- a/src/test/java/org/scijava/app/StatusServiceTest.java +++ b/src/test/java/org/scijava/app/StatusServiceTest.java @@ -6,13 +6,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 @@ -49,7 +49,7 @@ /** * Tests {@link StatusService}. - * + * * @author Lee Kamentsky */ public class StatusServiceTest { diff --git a/src/test/java/org/scijava/command/CommandArrayConverterTest.java b/src/test/java/org/scijava/command/CommandArrayConverterTest.java index 8531a3dfa..4d5cecab2 100644 --- a/src/test/java/org/scijava/command/CommandArrayConverterTest.java +++ b/src/test/java/org/scijava/command/CommandArrayConverterTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.command; import org.junit.Test; @@ -42,143 +43,149 @@ public class CommandArrayConverterTest { - @Test - public void testArrayCommandRaw() throws InterruptedException, - ExecutionException - { - final Context context = new Context(CommandService.class); - final CommandService commandService = context.service(CommandService.class); - - UserClass[] userObjects = new UserClass[2]; - userObjects[0] = new UserClass("User Object 0", new Object()); - userObjects[1] = new UserClass("User Object 1", new Object()); - - final CommandModule module = // - commandService.run(CommandRawArrayInput.class, true, "userObjects", userObjects ).get(); // - assertEquals("User Object 0;User Object 1;", module.getOutput("result")); - } - - @Test - public void testArrayConvertFromStringCommandRaw() throws InterruptedException, - ExecutionException - { - final Context context = new Context(CommandService.class); - final CommandService commandService = context.service(CommandService.class); - - final CommandModule module = // - commandService.run(CommandRawArrayInput.class, true, "userObjects", "User Object 0,User Object 1" ).get(); // - - assertEquals("User Object 0;User Object 1;", module.getOutput("result")); - } - - @Test - public void testArrayCommandWildcardGenerics() throws InterruptedException, - ExecutionException - { - final Context context = new Context(CommandService.class); - final CommandService commandService = context.service(CommandService.class); - - UserClass[] userObjects = new UserClass[2]; - userObjects[0] = new UserClass("User Object 0", new Object()); - userObjects[1] = new UserClass("User Object 1", new Object()); - - final CommandModule module = // - commandService.run(CommandGenericsWildcardArrayInput.class, true, "userObjects", userObjects ).get(); // - assertEquals("User Object 0;User Object 1;", module.getOutput("result")); - } - - @Test - public void testArrayConvertFromStringCommandWildcardGenerics() throws InterruptedException, - ExecutionException - { - final Context context = new Context(CommandService.class); - final CommandService commandService = context.service(CommandService.class); - - final CommandModule module = // - commandService.run(CommandGenericsWildcardArrayInput.class, true, "userObjects", "User Object 0,User Object 1" ).get(); // - - assertEquals("User Object 0;User Object 1;", module.getOutput("result")); - } - - /** A command which uses a UserClass Raw Array parameter. */ - @Plugin(type = Command.class) - public static class CommandRawArrayInput implements Command { - - @Parameter - private UserClass[] userObjects; - - @Parameter(type = ItemIO.OUTPUT) - private String result = "default"; - - @Override - public void run() { - final StringBuilder sb = new StringBuilder(); - for (UserClass obj : userObjects) { - sb.append(obj.toString()+";"); - } - result = sb.toString(); - } - } - - /** A command which uses a UserClass Array with generics wildcard */ - @Plugin(type = Command.class) - public static class CommandGenericsWildcardArrayInput implements Command { - - @Parameter - private UserClass[] userObjects; - - @Parameter(type = ItemIO.OUTPUT) - private String result = "default"; - - @Override - public void run() { - final StringBuilder sb = new StringBuilder(); - for (UserClass obj : userObjects) { - sb.append(obj.toString()+";"); - } - result = sb.toString(); - } - } - - @Plugin(type = org.scijava.convert.Converter.class, priority = Priority.LOW) - public static class StringToUserClassConverterNoGenerics extends AbstractConverter { - - @Override - public T convert(Object src, Class dest) { - String str = (String) src; - String[] names = str.split(","); - UserClass[] userObjects = new UserClass[names.length]; - for (int index = 0; index < names.length ; index++) { - userObjects[index] = new UserClass(names[index], new Object()); - } - return (T) userObjects; - } - - @Override - public Class getOutputType() { - return UserClass[].class; - } - - @Override - public Class getInputType() { - return String.class; - } - } - - /** - * Simple class to test input arrays in command - */ - public static class UserClass { - - String name; - - public UserClass(String objectName, T generic_object) { - name = objectName; - } - - public String toString() { - return name; - } - } + @Test + public void testArrayCommandRaw() throws InterruptedException, + ExecutionException + { + final Context context = new Context(CommandService.class); + final CommandService commandService = context.service(CommandService.class); + + UserClass[] userObjects = new UserClass[2]; + userObjects[0] = new UserClass("User Object 0", new Object()); + userObjects[1] = new UserClass("User Object 1", new Object()); + + final CommandModule module = // + commandService.run(CommandRawArrayInput.class, true, "userObjects", + userObjects).get(); // + assertEquals("User Object 0;User Object 1;", module.getOutput("result")); + } + + @Test + public void testArrayConvertFromStringCommandRaw() + throws InterruptedException, ExecutionException + { + final Context context = new Context(CommandService.class); + final CommandService commandService = context.service(CommandService.class); + + final CommandModule module = // + commandService.run(CommandRawArrayInput.class, true, "userObjects", + "User Object 0,User Object 1").get(); // + + assertEquals("User Object 0;User Object 1;", module.getOutput("result")); + } + + @Test + public void testArrayCommandWildcardGenerics() throws InterruptedException, + ExecutionException + { + final Context context = new Context(CommandService.class); + final CommandService commandService = context.service(CommandService.class); + + UserClass[] userObjects = new UserClass[2]; + userObjects[0] = new UserClass("User Object 0", new Object()); + userObjects[1] = new UserClass("User Object 1", new Object()); + + final CommandModule module = // + commandService.run(CommandGenericsWildcardArrayInput.class, true, + "userObjects", userObjects).get(); // + assertEquals("User Object 0;User Object 1;", module.getOutput("result")); + } + + @Test + public void testArrayConvertFromStringCommandWildcardGenerics() + throws InterruptedException, ExecutionException + { + final Context context = new Context(CommandService.class); + final CommandService commandService = context.service(CommandService.class); + + final CommandModule module = // + commandService.run(CommandGenericsWildcardArrayInput.class, true, + "userObjects", "User Object 0,User Object 1").get(); // + + assertEquals("User Object 0;User Object 1;", module.getOutput("result")); + } + + /** A command which uses a UserClass Raw Array parameter. */ + @Plugin(type = Command.class) + public static class CommandRawArrayInput implements Command { + + @Parameter + private UserClass[] userObjects; + + @Parameter(type = ItemIO.OUTPUT) + private String result = "default"; + + @Override + public void run() { + final StringBuilder sb = new StringBuilder(); + for (UserClass obj : userObjects) { + sb.append(obj.toString() + ";"); + } + result = sb.toString(); + } + } + + /** A command which uses a UserClass Array with generics wildcard */ + @Plugin(type = Command.class) + public static class CommandGenericsWildcardArrayInput implements Command { + + @Parameter + private UserClass[] userObjects; + + @Parameter(type = ItemIO.OUTPUT) + private String result = "default"; + + @Override + public void run() { + final StringBuilder sb = new StringBuilder(); + for (UserClass obj : userObjects) { + sb.append(obj.toString() + ";"); + } + result = sb.toString(); + } + } + + @Plugin(type = org.scijava.convert.Converter.class, priority = Priority.LOW) + public static class StringToUserClassConverterNoGenerics extends + AbstractConverter + { + + @Override + public T convert(Object src, Class dest) { + String str = (String) src; + String[] names = str.split(","); + UserClass[] userObjects = new UserClass[names.length]; + for (int index = 0; index < names.length; index++) { + userObjects[index] = new UserClass(names[index], new Object()); + } + return (T) userObjects; + } + + @Override + public Class getOutputType() { + return UserClass[].class; + } + + @Override + public Class getInputType() { + return String.class; + } + } + + /** + * Simple class to test input arrays in command + */ + public static class UserClass { + + String name; + + public UserClass(String objectName, T generic_object) { + name = objectName; + } + + public String toString() { + return name; + } + } } diff --git a/src/test/java/org/scijava/command/CommandInfoTest.java b/src/test/java/org/scijava/command/CommandInfoTest.java index 6f1cf1128..434c39f1f 100644 --- a/src/test/java/org/scijava/command/CommandInfoTest.java +++ b/src/test/java/org/scijava/command/CommandInfoTest.java @@ -6,13 +6,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 @@ -50,7 +50,7 @@ /** * Tests {@link CommandInfo}. - * + * * @author Curtis Rueden */ public class CommandInfoTest { @@ -115,7 +115,7 @@ public enum Choice { @Parameter private String freeform; - @Parameter(choices = {"foo", "bar", "fubar"}) + @Parameter(choices = { "foo", "bar", "fubar" }) private String constrained; @Parameter diff --git a/src/test/java/org/scijava/command/CommandModuleTest.java b/src/test/java/org/scijava/command/CommandModuleTest.java index 9fb32074f..af927e449 100644 --- a/src/test/java/org/scijava/command/CommandModuleTest.java +++ b/src/test/java/org/scijava/command/CommandModuleTest.java @@ -6,13 +6,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 @@ -66,7 +66,8 @@ public void testCancelable() throws InterruptedException, ExecutionException { assertEquals("Stop! Collaborate and listen!", ice.getCancelReason()); assertEquals("Stop! Collaborate and listen!", c.getCancelReason()); - final CommandModule crow = commandService.run(CrowCommand.class, true).get(); + final CommandModule crow = commandService.run(CrowCommand.class, true) + .get(); assertFalse(crow.isCanceled()); } @@ -76,7 +77,8 @@ public void testNotCancelable() throws InterruptedException, { final Context context = new Context(CommandService.class); final CommandService commandService = context.service(CommandService.class); - final CommandModule fire = commandService.run(FireCommand.class, true).get(); + final CommandModule fire = commandService.run(FireCommand.class, true) + .get(); assertFalse(fire.getDelegateObject() instanceof Cancelable); assertTrue(fire.isCanceled()); assertEquals("NO SINGING!", fire.getCancelReason()); @@ -283,6 +285,7 @@ public void run() { @Plugin(type = Command.class) public static class InitializableCommand implements Command, Initializable { + private int magicNumber = 7; @Parameter(type = ItemIO.OUTPUT) @@ -292,6 +295,7 @@ public static class InitializableCommand implements Command, Initializable { public void initialize() { magicNumber = 42; } + @Override public void run() { output = magicNumber; diff --git a/src/test/java/org/scijava/command/CommandServiceTest.java b/src/test/java/org/scijava/command/CommandServiceTest.java index ef34da9a4..859434a68 100644 --- a/src/test/java/org/scijava/command/CommandServiceTest.java +++ b/src/test/java/org/scijava/command/CommandServiceTest.java @@ -6,13 +6,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,7 +38,7 @@ /** * Tests {@link CommandService}. - * + * * @author Johannes Schindelin */ public class CommandServiceTest { @@ -46,8 +46,8 @@ public class CommandServiceTest { @Test public void runClass() throws Exception { final Context context = new Context(CommandService.class); - final CommandService commandService = - context.getService(CommandService.class); + final CommandService commandService = context.getService( + CommandService.class); final StringBuffer string = new StringBuffer(); commandService.run(TestCommand.class, true, "string", string).get(); assertEquals("Hello, World!", string.toString()); diff --git a/src/test/java/org/scijava/command/InputsTest.java b/src/test/java/org/scijava/command/InputsTest.java index 3cdc8c35b..efb02c746 100644 --- a/src/test/java/org/scijava/command/InputsTest.java +++ b/src/test/java/org/scijava/command/InputsTest.java @@ -6,13 +6,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 @@ -74,11 +74,14 @@ public void tearDown() { /** Tests single input, no configuration. */ @Test public void testSingleInput() { - setExpected(new HashMap() {{ - put("sigma", 3.9f); - }}); + setExpected(new HashMap() { + + { + put("sigma", 3.9f); + } + }); Inputs inputs = new Inputs(context); - inputs.getInfo().setName("testSingleInput");//TEMP + inputs.getInfo().setName("testSingleInput");// TEMP addTempInput(inputs, "sigma", Float.class); float sigma = (Float) inputs.harvest().get("sigma"); assertEquals(3.9f, sigma, 0); @@ -87,12 +90,15 @@ public void testSingleInput() { /** Tests two inputs, no configuration. */ @Test public void testTwoInputs() { - setExpected(new HashMap() {{ - put("name", "Chuckles"); - put("age", 37); - }}); + setExpected(new HashMap() { + + { + put("name", "Chuckles"); + put("age", 37); + } + }); Inputs inputs = new Inputs(context); - inputs.getInfo().setName("testTwoInputs");//TEMP + inputs.getInfo().setName("testTwoInputs");// TEMP addTempInput(inputs, "name", String.class); addTempInput(inputs, "age", Integer.class); Map values = inputs.harvest(); @@ -105,12 +111,15 @@ public void testTwoInputs() { /** Tests inputs with configuration. */ @Test public void testWithConfiguration() { - setExpected(new HashMap() {{ - put("word", "brown"); - put("opacity", 0.8); - }}); + setExpected(new HashMap() { + + { + put("word", "brown"); + put("opacity", 0.8); + } + }); Inputs inputs = new Inputs(context); - inputs.getInfo().setName("testWithConfiguration");//TEMP + inputs.getInfo().setName("testWithConfiguration");// TEMP MutableModuleItem wordInput = addTempInput(inputs, "word", String.class); wordInput.setLabel("Favorite word"); @@ -133,14 +142,17 @@ public void setExpected(final Map expected) { final PluginInfo info = new PluginInfo(MockInputHarvester.class, PreprocessorPlugin.class) - { - @Override - public PreprocessorPlugin createInstance() throws InstantiableException { - final PreprocessorPlugin pp = super.createInstance(); - ((MockInputHarvester) pp).setExpected(expected); - return pp; - } - }; + { + + @Override + public PreprocessorPlugin createInstance() + throws InstantiableException + { + final PreprocessorPlugin pp = super.createInstance(); + ((MockInputHarvester) pp).setExpected(expected); + return pp; + } + }; info.setPriority(InputHarvester.PRIORITY); context.service(PluginService.class).addPlugin(info); } @@ -158,7 +170,9 @@ private static MutableModuleItem addTempInput(Inputs inputs, } public static class MockInputHarvester extends AbstractPreprocessorPlugin { + private Map expected; + public void setExpected(final Map expected) { this.expected = expected; } diff --git a/src/test/java/org/scijava/command/InvalidCommandTest.java b/src/test/java/org/scijava/command/InvalidCommandTest.java index e3f64b268..3e1a389b0 100644 --- a/src/test/java/org/scijava/command/InvalidCommandTest.java +++ b/src/test/java/org/scijava/command/InvalidCommandTest.java @@ -6,13 +6,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 @@ -47,7 +47,7 @@ /** * Test commands for verifying that invalid module parameters are dealt with * using proper error handling. - * + * * @author Curtis Rueden */ public class InvalidCommandTest { @@ -69,7 +69,7 @@ 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()); @@ -89,12 +89,12 @@ public void testInvalid() { assertEquals("Delegate class is abstract", p0); final String p1 = problems.get(1).getMessage(); - assertEquals("Invalid duplicate parameter: private int " - + "org.scijava.command.InvalidCommandTest$InvalidCommand.x", p1); + assertEquals("Invalid duplicate parameter: private int " + + "org.scijava.command.InvalidCommandTest$InvalidCommand.x", p1); final String p2 = problems.get(2).getMessage(); - assertEquals("Invalid final parameter: private final float " - + "org.scijava.command.InvalidCommandTest$InvalidCommand.y", p2); + assertEquals("Invalid final parameter: private final float " + + "org.scijava.command.InvalidCommandTest$InvalidCommand.y", p2); } // -- Helper classes -- diff --git a/src/test/java/org/scijava/command/run/CommandCodeRunnerTest.java b/src/test/java/org/scijava/command/run/CommandCodeRunnerTest.java index 466df6426..a11d056c3 100644 --- a/src/test/java/org/scijava/command/run/CommandCodeRunnerTest.java +++ b/src/test/java/org/scijava/command/run/CommandCodeRunnerTest.java @@ -6,13 +6,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 @@ -49,7 +49,7 @@ /** * Tests {@link CommandCodeRunner}. - * + * * @author Curtis Rueden */ public class CommandCodeRunnerTest { diff --git a/src/test/java/org/scijava/console/ConsoleServiceTest.java b/src/test/java/org/scijava/console/ConsoleServiceTest.java index 8a2760e85..a033ec5e9 100644 --- a/src/test/java/org/scijava/console/ConsoleServiceTest.java +++ b/src/test/java/org/scijava/console/ConsoleServiceTest.java @@ -6,13 +6,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 @@ -103,8 +103,8 @@ public void testInfiniteLoopAvoidance() { public void testOutputListeners() throws InterruptedException, ExecutionException { - final ThreadService threadService = - consoleService.context().service(ThreadService.class); + final ThreadService threadService = consoleService.context().service( + ThreadService.class); final String stdoutBefore = "hoc"; final String stderrBefore = "us-"; diff --git a/src/test/java/org/scijava/console/SystemPropertyArgumentTest.java b/src/test/java/org/scijava/console/SystemPropertyArgumentTest.java index a45c7823e..32d27f19a 100644 --- a/src/test/java/org/scijava/console/SystemPropertyArgumentTest.java +++ b/src/test/java/org/scijava/console/SystemPropertyArgumentTest.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * Tests {@link SystemPropertyArgument}. - * + * * @author Curtis Rueden */ public class SystemPropertyArgumentTest { diff --git a/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java b/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java index 8e7aac26b..b160a25fe 100644 --- a/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java +++ b/src/test/java/org/scijava/convert/AbstractNumberConverterTests.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ /** * Tests converter plugins that convert from primitive numeric types to other * primitive numeric types. - * + * * @author Alison Walter */ public abstract class AbstractNumberConverterTests { @@ -94,9 +94,8 @@ public void nullInput() { @Test public void incorrectInputType() { final Number input = getInvalidInput(); - final String message = - "Expected input of type " + srcType.getSimpleName() + ", but got " + - input.getClass().getSimpleName(); + final String message = "Expected input of type " + srcType.getSimpleName() + + ", but got " + input.getClass().getSimpleName(); iae(message, input, destType); } @@ -107,9 +106,8 @@ public void incorrectInputType() { public void incorrectOutputType() { final Class output = getInvalidOutput(); final Number src = getSrc(); - final String message = - "Expected output class of " + destType.getSimpleName() + ", but got " + - output.getSimpleName(); + final String message = "Expected output class of " + destType + .getSimpleName() + ", but got " + output.getSimpleName(); iae(message, src, output); } @@ -117,8 +115,8 @@ public void incorrectOutputType() { public ExpectedException exception = ExpectedException.none(); // helper methods - protected void - iae(final String message, final Number src, final Class dest) + protected void iae(final String message, final Number src, + final Class dest) { exception(IllegalArgumentException.class, message, src, dest); } diff --git a/src/test/java/org/scijava/convert/ArrayToStringConverterTest.java b/src/test/java/org/scijava/convert/ArrayToStringConverterTest.java index 0d1f7ef28..7320001a8 100644 --- a/src/test/java/org/scijava/convert/ArrayToStringConverterTest.java +++ b/src/test/java/org/scijava/convert/ArrayToStringConverterTest.java @@ -6,13 +6,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 @@ -45,7 +45,7 @@ /** * Tests {@link ArrayToStringConverter}. - * + * * @author Gabriel Selzer */ public class ArrayToStringConverterTest { @@ -148,7 +148,7 @@ public void testEmptyArrayConversion() { */ @Test public void testCyclicConversion() { - byte[] expected = new byte[] {1, 2, 3}; + byte[] expected = new byte[] { 1, 2, 3 }; // Do the first conversion ArrayToStringConverter c1 = new ArrayToStringConverter(); context.inject(c1); @@ -165,7 +165,7 @@ public void testNullConversion() { // Do the first conversion ArrayToStringConverter c1 = new ArrayToStringConverter(); context.inject(c1); - String converted = c1.convert(new String[] {null}, String.class); + String converted = c1.convert(new String[] { null }, String.class); // Try to convert back StringToArrayConverter c2 = new StringToArrayConverter(); context.inject(c2); diff --git a/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java index 228ff9e3b..6ace854f5 100644 --- a/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/BigIntegerToBigDecimalConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java index 638b0caf0..1ef9a415c 100644 --- a/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToBigDecimalConverterTest.java @@ -6,13 +6,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 @@ -39,7 +39,8 @@ * * @author Alison Walter */ -public class ByteToBigDecimalConverterTest extends AbstractNumberConverterTests +public class ByteToBigDecimalConverterTest extends + AbstractNumberConverterTests { @Override diff --git a/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java index 381b2f5ac..4b952d700 100644 --- a/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToBigIntegerConverterTest.java @@ -6,13 +6,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 @@ -39,7 +39,8 @@ * * @author Alison Walter */ -public class ByteToBigIntegerConverterTest extends AbstractNumberConverterTests +public class ByteToBigIntegerConverterTest extends + AbstractNumberConverterTests { @Override diff --git a/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java b/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java index 43d2c62ef..451ef0a55 100644 --- a/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToDoubleConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/ByteToFloatConverterTest.java b/src/test/java/org/scijava/convert/ByteToFloatConverterTest.java index 286f358a5..e8288d5d5 100644 --- a/src/test/java/org/scijava/convert/ByteToFloatConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToFloatConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/ByteToIntegerConverterTest.java b/src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java index f4607db21..ac5a57c35 100644 --- a/src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToIntegerConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/ByteToLongConverterTest.java b/src/test/java/org/scijava/convert/ByteToLongConverterTest.java index 38ffd40aa..778e19e6e 100644 --- a/src/test/java/org/scijava/convert/ByteToLongConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToLongConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/ByteToShortConverterTest.java b/src/test/java/org/scijava/convert/ByteToShortConverterTest.java index c1e542e12..167e42bbd 100644 --- a/src/test/java/org/scijava/convert/ByteToShortConverterTest.java +++ b/src/test/java/org/scijava/convert/ByteToShortConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/ConvertServiceTest.java b/src/test/java/org/scijava/convert/ConvertServiceTest.java index 80fe29337..56b9e8196 100644 --- a/src/test/java/org/scijava/convert/ConvertServiceTest.java +++ b/src/test/java/org/scijava/convert/ConvertServiceTest.java @@ -6,13 +6,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 @@ -75,7 +75,7 @@ /** * Tests {@link ConvertService}. - * + * * @author Mark Hiner * @author Curtis Rueden */ @@ -98,32 +98,44 @@ public void tearDown() { @Test public void testNull() { // Test convertService.supports for null parameters - assertTrue(convertService.supports((Object)null, Object.class)); - assertTrue(convertService.supports((Class)null, Object.class)); - assertTrue(convertService.supports(Object.class, (Class)null)); - assertTrue(convertService.supports(Object.class, (Type)null)); - assertTrue(convertService.supports(new Object(), (Class)null)); - assertTrue(convertService.supports(new Object(), (Type)null)); - assertTrue(convertService.supports(new ConversionRequest((Object)null, Object.class))); - assertTrue(convertService.supports(new ConversionRequest((Class)null, Object.class))); - assertTrue(convertService.supports(new ConversionRequest(Object.class, (Class)null))); - assertTrue(convertService.supports(new ConversionRequest(Object.class, (Type)null))); - assertTrue(convertService.supports(new ConversionRequest(new Object(), (Class)null))); - assertTrue(convertService.supports(new ConversionRequest(new Object(), (Type)null))); + assertTrue(convertService.supports((Object) null, Object.class)); + assertTrue(convertService.supports((Class) null, Object.class)); + assertTrue(convertService.supports(Object.class, (Class) null)); + assertTrue(convertService.supports(Object.class, (Type) null)); + assertTrue(convertService.supports(new Object(), (Class) null)); + assertTrue(convertService.supports(new Object(), (Type) null)); + assertTrue(convertService.supports(new ConversionRequest((Object) null, + Object.class))); + assertTrue(convertService.supports(new ConversionRequest( + (Class) null, Object.class))); + assertTrue(convertService.supports(new ConversionRequest(Object.class, + (Class) null))); + assertTrue(convertService.supports(new ConversionRequest(Object.class, + (Type) null))); + assertTrue(convertService.supports(new ConversionRequest(new Object(), + (Class) null))); + assertTrue(convertService.supports(new ConversionRequest(new Object(), + (Type) null))); // Test convertService.convert for null parameters - assertNull(convertService.convert((Object)null, Object.class)); - assertNull(convertService.convert((Class)null, Object.class)); - assertNull(convertService.convert(Object.class, (Class)null)); - assertNull(convertService.convert(Object.class, (Type)null)); - assertNull(convertService.convert(new Object(), (Class)null)); - assertNull(convertService.convert(new Object(), (Type)null)); - assertNull(convertService.convert(new ConversionRequest((Object)null, Object.class))); - assertNull(convertService.convert(new ConversionRequest((Class)null, Object.class))); - assertNull(convertService.convert(new ConversionRequest(Object.class, (Class)null))); - assertNull(convertService.convert(new ConversionRequest(Object.class, (Type)null))); - assertNull(convertService.convert(new ConversionRequest(new Object(), (Class)null))); - assertNull(convertService.convert(new ConversionRequest(new Object(), (Type)null))); + assertNull(convertService.convert((Object) null, Object.class)); + assertNull(convertService.convert((Class) null, Object.class)); + assertNull(convertService.convert(Object.class, (Class) null)); + assertNull(convertService.convert(Object.class, (Type) null)); + assertNull(convertService.convert(new Object(), (Class) null)); + assertNull(convertService.convert(new Object(), (Type) null)); + assertNull(convertService.convert(new ConversionRequest((Object) null, + Object.class))); + assertNull(convertService.convert(new ConversionRequest( + (Class) null, Object.class))); + assertNull(convertService.convert(new ConversionRequest(Object.class, + (Class) null))); + assertNull(convertService.convert(new ConversionRequest(Object.class, + (Type) null))); + assertNull(convertService.convert(new ConversionRequest(new Object(), + (Class) null))); + assertNull(convertService.convert(new ConversionRequest(new Object(), + (Type) null))); } /** @@ -134,7 +146,7 @@ public void testPrimitives() { assertTrue(1d == convertService.convert(1, double.class)); assertTrue(1d == convertService.convert(1l, double.class)); assertTrue(1d == convertService.convert(1.0f, double.class)); - assertTrue(1d == convertService.convert((short)1, double.class)); + assertTrue(1d == convertService.convert((short) 1, double.class)); assertTrue(1d == convertService.convert(1.0, double.class)); } @@ -154,10 +166,11 @@ public void testArrays() { testIntechangeable(char[].class, CharArray.class); testIntechangeable(boolean[].class, BoolArray.class); - // Test that primitive [] can be cross-converted to mismatched PrimitiveArray + // Test that primitive [] can be cross-converted to mismatched + // PrimitiveArray assertTrue(convertService.supports(int[].class, LongArray.class)); final LongArray crossConverted = // - convertService.convert(new int[] {2, 3, 5}, LongArray.class); + convertService.convert(new int[] { 2, 3, 5 }, LongArray.class); assertEquals(3, crossConverted.size()); assertEquals(2L, (long) crossConverted.get(0)); assertEquals(3L, (long) crossConverted.get(1)); @@ -165,7 +178,8 @@ public void testArrays() { // Test that lists can be converted to any primitive [] final List list = new ArrayList<>(); - for (int i=0; i<100; i++) list.add((int) (10000 * Math.random())); + for (int i = 0; i < 100; i++) + list.add((int) (10000 * Math.random())); assertTrue(convertService.supports(list, int[].class)); assertTrue(convertService.supports(list, long[].class)); @@ -178,14 +192,15 @@ public void testArrays() { // Verify PrimitiveArray conversion final int[] primitives = convertService.convert(list, int[].class); - final IntArray intArray = convertService.convert(primitives, IntArray.class); + final IntArray intArray = convertService.convert(primitives, + IntArray.class); // Should just unwrap the IntArray assertTrue(primitives == convertService.convert(intArray, int[].class)); // Verify all our lists are the same - for (int i=0; i arrayList = new ArrayList<>(); - final Collection arrayListToCollection = - convertService.convert(arrayList, Collection.class); + final Collection arrayListToCollection = convertService.convert( + arrayList, Collection.class); assertSame(arrayList, arrayListToCollection); // check conversion to enum values (testConvertToEnum is more thorough) @@ -258,8 +273,8 @@ public void testConvert() { // check conversion of numeric primitives: float to double final float f = 6.2f; - final double floatToDouble = - convertService.convert(float.class, double.class); + final double floatToDouble = convertService.convert(float.class, + double.class); assertEquals(f, floatToDouble, 0.0); // boxing works @@ -288,8 +303,8 @@ public void testConvert() { set.add("Foo"); set.add("Bar"); @SuppressWarnings("unchecked") - final ArrayList setToArrayList = - convertService.convert(set, ArrayList.class); + final ArrayList setToArrayList = convertService.convert(set, + ArrayList.class); assertEquals(2, setToArrayList.size()); Collections.sort(setToArrayList); assertEquals("Bar", setToArrayList.get(0)); @@ -328,22 +343,22 @@ public void testConvertSubclass() { assertEquals("Bar", herList.get(1)); // ArrayList subclass to ArrayList subclass - final ObjectList objectList = - convertService.convert(hisList, ObjectList.class); + final ObjectList objectList = convertService.convert(hisList, + ObjectList.class); assertEquals(2, objectList.size()); assertEquals("Foo", objectList.get(0)); assertEquals("Bar", objectList.get(1)); // ArrayList subclass to ArrayList subclass - final HisList objectToHisList = - convertService.convert(objectList, HisList.class); + final HisList objectToHisList = convertService.convert(objectList, + HisList.class); assertEquals(2, objectToHisList.size()); assertEquals("Foo", objectToHisList.get(0)); assertEquals("Bar", objectToHisList.get(1)); // ArrayList subclass to ArrayList subclass - final NumberList hisToNumberList = - convertService.convert(hisList, NumberList.class); + final NumberList hisToNumberList = convertService.convert(hisList, + NumberList.class); assertEquals(2, hisToNumberList.size()); assertNull(hisToNumberList.get(0)); assertNull(hisToNumberList.get(1)); @@ -356,6 +371,7 @@ public void testConvertSubclass() { @Test public void testConvertTypeCasting() { class Struct { + private INumberList iNumberList; private List list; } @@ -537,11 +553,11 @@ class Struct { @Test public void testLegitimateSingletonInt() { class Struct { - + private IntWrapper intWrapper; } final Struct struct = new Struct(); - + setFieldValue(struct, "intWrapper", Integer.valueOf(12)); assertNotNull(struct.intWrapper); } @@ -579,15 +595,15 @@ class Struct { } /** - * Test that a {@link Converter} with the appropriate {@link - * Converter#populateInputCandidates(Collection)} implementation will populate - * candidate input lists with objects it can convert to a requested output - * type. + * Test that a {@link Converter} with the appropriate + * {@link Converter#populateInputCandidates(Collection)} implementation will + * populate candidate input lists with objects it can convert to a requested + * output type. */ @Test public void testGetCompatibleInputs() { - final List compatibleInputs = - new ArrayList<>(convertService.getCompatibleInputs(HisList.class)); + final List compatibleInputs = new ArrayList<>(convertService + .getCompatibleInputs(HisList.class)); assertEquals(4, compatibleInputs.size()); assertEquals(StringHisListConverter.S1, compatibleInputs.get(0)); @@ -745,6 +761,7 @@ private List getValueList(final T... values) { * another. */ public static class HerList extends ArrayList { + public HerList(final Collection c) { super(c); } @@ -755,9 +772,11 @@ public HerList(final Collection c) { * another. */ public static class HisList extends ArrayList { + public HisList() { super(); } + public HisList(final Collection c) { super(c); } @@ -768,6 +787,7 @@ public HisList(final Collection c) { * another. */ public static class ObjectList extends ArrayList { + public ObjectList(final Collection c) { super(c); } @@ -780,17 +800,19 @@ public ObjectList(final Collection c) { public static class NumberList extends ArrayList implements INumberList { + public NumberList() { super(); } + public NumberList(final Collection c) { super(c); } } /** - * Helper interface for testing conversion of an {@link ArrayList} subclass - * to one of its implementing interfaces. + * Helper interface for testing conversion of an {@link ArrayList} subclass to + * one of its implementing interfaces. */ private static interface INumberList extends List { // NB: No implementation needed. @@ -801,7 +823,7 @@ private static interface INumberList extends List { * constructors, auto-unboxing should work as expected. */ public static class IntWrapper { - + @SuppressWarnings("unused") public IntWrapper(final int gonnaWrapThisInt) { // nothing to do @@ -846,7 +868,7 @@ public static class StringListExtension extends ArrayList { /** Enumeration for testing conversion to enum types. */ public static enum Words { - FOO, BAR, FUBAR + FOO, BAR, FUBAR } /** diff --git a/src/test/java/org/scijava/convert/ConverterTest.java b/src/test/java/org/scijava/convert/ConverterTest.java index cf9564346..4adbf1056 100644 --- a/src/test/java/org/scijava/convert/ConverterTest.java +++ b/src/test/java/org/scijava/convert/ConverterTest.java @@ -6,13 +6,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 @@ -96,12 +96,14 @@ public void testCanConvertToGenericCollection() { assertTrue(cc.canConvert(ArrayList.class, destType)); } - private static class NumberConverter extends AbstractConverter { + private static class NumberConverter extends + AbstractConverter + { @SuppressWarnings("unchecked") @Override public T convert(Object src, Class dest) { - return (T)src; + return (T) src; } @Override @@ -113,6 +115,6 @@ public Class getOutputType() { public Class getInputType() { return Number.class; } - + } } diff --git a/src/test/java/org/scijava/convert/DefaultConverterTest.java b/src/test/java/org/scijava/convert/DefaultConverterTest.java index af04d34ad..b7f554d65 100644 --- a/src/test/java/org/scijava/convert/DefaultConverterTest.java +++ b/src/test/java/org/scijava/convert/DefaultConverterTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.convert; import static org.junit.Assert.assertArrayEquals; @@ -46,10 +47,11 @@ /** * Tests {@link DefaultConverter}. - * + * * @author Curtis Rueden - * */ + */ public class DefaultConverterTest { + private DefaultConverter converter; @Before @@ -142,6 +144,7 @@ public void testStringToStringArray() { public void testObjectToCollection() throws NoSuchFieldException { @SuppressWarnings("unused") class Struct { + private Collection collectionOfObjects; private List listOfObjects; private List listOfStrings; @@ -149,11 +152,16 @@ class Struct { private Set setOfObjects; } - Type collectionOfObjectsType = Struct.class.getDeclaredField("collectionOfObjects").getGenericType(); - Type listOfObjectsType = Struct.class.getDeclaredField("listOfObjects").getGenericType(); - Type listOfStringsType = Struct.class.getDeclaredField("listOfStrings").getGenericType(); - Type listOfDoublesType = Struct.class.getDeclaredField("listOfDoubles").getGenericType(); - Type setOfObjectsType = Struct.class.getDeclaredField("setOfObjects").getGenericType(); + Type collectionOfObjectsType = Struct.class.getDeclaredField( + "collectionOfObjects").getGenericType(); + Type listOfObjectsType = Struct.class.getDeclaredField("listOfObjects") + .getGenericType(); + Type listOfStringsType = Struct.class.getDeclaredField("listOfStrings") + .getGenericType(); + Type listOfDoublesType = Struct.class.getDeclaredField("listOfDoubles") + .getGenericType(); + Type setOfObjectsType = Struct.class.getDeclaredField("setOfObjects") + .getGenericType(); Object o = new Object(); @@ -161,7 +169,8 @@ class Struct { assertTrue(converter.canConvert(o, List.class)); assertTrue(converter.canConvert(o, Set.class)); - assertCollection(o, o, converter.convert(o, Collection.class), Collection.class); + assertCollection(o, o, converter.convert(o, Collection.class), + Collection.class); assertCollection(o, o, converter.convert(o, List.class), List.class); assertCollection(o, o, converter.convert(o, Set.class), Set.class); @@ -171,10 +180,13 @@ class Struct { assertTrue(converter.canConvert(o, listOfDoublesType)); assertTrue(converter.canConvert(o, setOfObjectsType)); - assertCollection(o, o, converter.convert(o, collectionOfObjectsType), Collection.class); + assertCollection(o, o, converter.convert(o, collectionOfObjectsType), + Collection.class); assertCollection(o, o, converter.convert(o, listOfObjectsType), List.class); - assertCollection(o, o.toString(), converter.convert(o, listOfStringsType), List.class); - assertCollection(o, null, converter.convert(o, listOfDoublesType), List.class); + assertCollection(o, o.toString(), converter.convert(o, listOfStringsType), + List.class); + assertCollection(o, null, converter.convert(o, listOfDoublesType), + List.class); assertCollection(o, o, converter.convert(o, setOfObjectsType), Set.class); String s = "Thingamawhatsit"; @@ -184,10 +196,12 @@ class Struct { assertTrue(converter.canConvert(s, listOfDoublesType)); assertTrue(converter.canConvert(s, setOfObjectsType)); - assertCollection(s, s, converter.convert(s, collectionOfObjectsType), Collection.class); + assertCollection(s, s, converter.convert(s, collectionOfObjectsType), + Collection.class); assertCollection(s, s, converter.convert(s, listOfObjectsType), List.class); assertCollection(s, s, converter.convert(s, listOfStringsType), List.class); - assertCollection(s, null, converter.convert(s, listOfDoublesType), List.class); + assertCollection(s, null, converter.convert(s, listOfDoublesType), + List.class); assertCollection(s, s, converter.convert(s, setOfObjectsType), Set.class); // TODO: Test more things, covering the equivalent of all *To*Array above. @@ -204,8 +218,11 @@ public void testNumberToNumber() { @Test public void testObjectToString() { Object friendly = new Object() { + @Override - public String toString() { return "Hello"; } + public String toString() { + return "Hello"; + } }; assertTrue(converter.canConvert(friendly, String.class)); assertEquals("Hello", converter.convert(friendly, String.class)); @@ -234,7 +251,7 @@ public void testStringToCharacterArray() { } private enum Gem { - RUBY, DIAMOND, EMERALD; + RUBY, DIAMOND, EMERALD; } @Test @@ -250,8 +267,12 @@ public void testStringToEnum() { } public static class StringWrapper { + public String s; - public StringWrapper(String s) { this.s = s; } + + public StringWrapper(String s) { + this.s = s; + } } @Test diff --git a/src/test/java/org/scijava/convert/DelegateConverterTest.java b/src/test/java/org/scijava/convert/DelegateConverterTest.java index ec1f4187c..bc0d8fafd 100644 --- a/src/test/java/org/scijava/convert/DelegateConverterTest.java +++ b/src/test/java/org/scijava/convert/DelegateConverterTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.convert; import static org.junit.Assert.assertSame; @@ -37,8 +38,8 @@ import org.scijava.Context; import org.scijava.plugin.Plugin; - public class DelegateConverterTest { + private Context context; @Before @@ -55,13 +56,13 @@ public void tearDown() { @Test public void testDelegateConverters() { ConvertService convertService = context.getService(ConvertService.class); - + // Test conversion from AType to BType AType a = new AType(); assertTrue(convertService.supports(a, BType.class)); BType b = convertService.convert(a, BType.class); assertSame(BType.class, b.getClass()); - + // Test conversion from BType to CType assertTrue(convertService.supports(b, CType.class)); CType c = convertService.convert(b, CType.class); @@ -85,7 +86,7 @@ public static class CType { // empty class } - @Plugin(type=Converter.class) + @Plugin(type = Converter.class) public static class ABConverter extends AbstractConverter { @SuppressWarnings("unchecked") @@ -102,10 +103,10 @@ public Class getOutputType() { @Override public Class getInputType() { return AType.class; - } + } } - @Plugin(type=Converter.class) + @Plugin(type = Converter.class) public static class BCConverter extends AbstractConverter { @SuppressWarnings("unchecked") @@ -122,11 +123,13 @@ public Class getOutputType() { @Override public Class getInputType() { return BType.class; - } + } } - @Plugin(type=Converter.class) - public static class DelegateConverter extends AbstractDelegateConverter { + @Plugin(type = Converter.class) + public static class DelegateConverter extends + AbstractDelegateConverter + { @Override public Class getOutputType() { diff --git a/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java index ff6714dba..f4df4ed2a 100644 --- a/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/DoubleToBigDecimalConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/FileListConverterTest.java b/src/test/java/org/scijava/convert/FileListConverterTest.java index f5b40b2e4..bfdf7bed7 100644 --- a/src/test/java/org/scijava/convert/FileListConverterTest.java +++ b/src/test/java/org/scijava/convert/FileListConverterTest.java @@ -6,13 +6,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 @@ -47,41 +47,39 @@ public class FileListConverterTest { public void testStringToFileConverter() { final StringToFileConverter conv = new StringToFileConverter(); final String path = "C:\\temp\\f,i;l-ename.txt"; - assertTrue("Cannot convert from String to File", - conv.canConvert(String.class, File.class)); - assertFalse("Can erroneously convert from String to File[]", - conv.canConvert(String.class, File[].class)); - assertEquals(new File(path), - conv.convert(path, File.class)); + assertTrue("Cannot convert from String to File", conv.canConvert( + String.class, File.class)); + assertFalse("Can erroneously convert from String to File[]", conv + .canConvert(String.class, File[].class)); + assertEquals(new File(path), conv.convert(path, File.class)); } @Test public void testStringToFileArrayConverter() { final StringToFileArrayConverter conv = new StringToFileArrayConverter(); final String path = "\"C:\\temp\\f,i;l-ename.txt\",C:\\temp"; - assertTrue("Cannot convert from String to File[]", - conv.canConvert(String.class, File[].class)); - assertFalse("Can erroneously convert from String to File", - conv.canConvert(String.class, File.class)); - assertEquals("Wrong array length", 2, - conv.convert(path, File[].class).length); - assertEquals("Wrong file name", new File("C:\\temp\\f,i;l-ename.txt"), - conv.convert(path, File[].class)[0]); - assertEquals("Wrong file name", new File("C:\\temp"), - conv.convert(path, File[].class)[1]); - assertEquals( 0, conv.convert( "", File[].class ).length ); + assertTrue("Cannot convert from String to File[]", conv.canConvert( + String.class, File[].class)); + assertFalse("Can erroneously convert from String to File", conv.canConvert( + String.class, File.class)); + assertEquals("Wrong array length", 2, conv.convert(path, + File[].class).length); + assertEquals("Wrong file name", new File("C:\\temp\\f,i;l-ename.txt"), conv + .convert(path, File[].class)[0]); + assertEquals("Wrong file name", new File("C:\\temp"), conv.convert(path, + File[].class)[1]); + assertEquals(0, conv.convert("", File[].class).length); } @Test public void testFileToStringConverter() { final FileToStringConverter conv = new FileToStringConverter(); final File file = new File("C:\\temp\\f,i;l-ename.txt"); - assertTrue("Cannot convert from File to String", - conv.canConvert(File.class, String.class)); - assertFalse("Can erroneously convert from File[] to String", - conv.canConvert(File[].class, String.class)); - assertEquals(file.getAbsolutePath(), - conv.convert(file, String.class)); + assertTrue("Cannot convert from File to String", conv.canConvert(File.class, + String.class)); + assertFalse("Can erroneously convert from File[] to String", conv + .canConvert(File[].class, String.class)); + assertEquals(file.getAbsolutePath(), conv.convert(file, String.class)); } @Test @@ -90,12 +88,13 @@ public void testFileArrayToStringConverter() { final File[] fileArray = new File[2]; fileArray[0] = new File("C:\\temp\\f,i;l-ename.txt"); fileArray[1] = new File("C:\\temp"); - final String expected = "\"" + fileArray[0].getAbsolutePath() + "\"," + fileArray[1].getAbsolutePath(); - assertTrue("Cannot convert from File[] to String", - conv.canConvert(File[].class, String.class)); - assertFalse("Can erroneously convert from File to String", - conv.canConvert(File.class, String.class)); - assertEquals("Wrong output string", expected, - conv.convert(fileArray, String.class)); + final String expected = "\"" + fileArray[0].getAbsolutePath() + "\"," + + fileArray[1].getAbsolutePath(); + assertTrue("Cannot convert from File[] to String", conv.canConvert( + File[].class, String.class)); + assertFalse("Can erroneously convert from File to String", conv.canConvert( + File.class, String.class)); + assertEquals("Wrong output string", expected, conv.convert(fileArray, + String.class)); } } diff --git a/src/test/java/org/scijava/convert/FileToPathConversionTest.java b/src/test/java/org/scijava/convert/FileToPathConversionTest.java index 7fd087514..1e9f54b5b 100644 --- a/src/test/java/org/scijava/convert/FileToPathConversionTest.java +++ b/src/test/java/org/scijava/convert/FileToPathConversionTest.java @@ -6,13 +6,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 @@ -44,7 +44,7 @@ /** * Tests conversion between {@link File}s and {@link Path}s. - * + * * @author Gabriel Selzer */ public class FileToPathConversionTest { diff --git a/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java index 7d49b6878..fd5fc8613 100644 --- a/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/FloatToBigDecimalConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/FloatToDoubleConverterTest.java b/src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java index 45c5c4dfb..26af86008 100644 --- a/src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java +++ b/src/test/java/org/scijava/convert/FloatToDoubleConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java index 4c375dcb8..9c96fc4c6 100644 --- a/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/IntegerToBigDecimalConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java index 79c89bcb1..b6aabea22 100644 --- a/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/IntegerToBigIntegerConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java b/src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java index 0e1106536..54fb5453d 100644 --- a/src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java +++ b/src/test/java/org/scijava/convert/IntegerToDoubleConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/IntegerToLongConverterTest.java b/src/test/java/org/scijava/convert/IntegerToLongConverterTest.java index 5611b7f26..57744f593 100644 --- a/src/test/java/org/scijava/convert/IntegerToLongConverterTest.java +++ b/src/test/java/org/scijava/convert/IntegerToLongConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java index 436730ee2..0b8a7391d 100644 --- a/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/LongToBigDecimalConverterTest.java @@ -6,13 +6,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 @@ -39,7 +39,8 @@ * * @author Alison Walter */ -public class LongToBigDecimalConverterTest extends AbstractNumberConverterTests +public class LongToBigDecimalConverterTest extends + AbstractNumberConverterTests { @Override diff --git a/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java index ec8a1c3ca..87c87e3c3 100644 --- a/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/LongToBigIntegerConverterTest.java @@ -6,13 +6,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 @@ -39,7 +39,8 @@ * * @author Alison Walter */ -public class LongToBigIntegerConverterTest extends AbstractNumberConverterTests +public class LongToBigIntegerConverterTest extends + AbstractNumberConverterTests { @Override diff --git a/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java b/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java index 642008214..69df02827 100644 --- a/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToBigDecimalConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java b/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java index bb39f8c50..03965534c 100644 --- a/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToBigIntegerConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/ShortToDoubleConverterTest.java b/src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java index 336001970..91decc296 100644 --- a/src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToDoubleConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/ShortToFloatConverterTest.java b/src/test/java/org/scijava/convert/ShortToFloatConverterTest.java index d893478ca..94649a7b4 100644 --- a/src/test/java/org/scijava/convert/ShortToFloatConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToFloatConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/ShortToIntegerConverterTest.java b/src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java index df9c62daf..9bf824e16 100644 --- a/src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToIntegerConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/ShortToLongConverterTest.java b/src/test/java/org/scijava/convert/ShortToLongConverterTest.java index a5803241a..aa958ce23 100644 --- a/src/test/java/org/scijava/convert/ShortToLongConverterTest.java +++ b/src/test/java/org/scijava/convert/ShortToLongConverterTest.java @@ -6,13 +6,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/test/java/org/scijava/convert/StringToArrayConverterTest.java b/src/test/java/org/scijava/convert/StringToArrayConverterTest.java index c68ddd568..7758f3c4c 100644 --- a/src/test/java/org/scijava/convert/StringToArrayConverterTest.java +++ b/src/test/java/org/scijava/convert/StringToArrayConverterTest.java @@ -6,13 +6,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 @@ -45,7 +45,7 @@ /** * Tests {@link StringToArrayConverter}. - * + * * @author Gabriel Selzer */ public class StringToArrayConverterTest { @@ -119,6 +119,7 @@ public void test2DArrayConversion() { Assert.assertEquals(2, actual[1][0]); Assert.assertEquals(3, actual[1][1]); } + /** * Tests the ability of {@link StringToArrayConverter} in converting * 3-dimensional arrays @@ -153,11 +154,11 @@ public void testEmptyArrayConversion() { @Test public void testStringArrayConversion() { String[] expected = new String[] { // - "{foo", "bar}", // - "ha\nha", // - "foo,bar", // - "lol\"lol", // - "foo\\\"bar" // + "{foo", "bar}", // + "ha\nha", // + "foo,bar", // + "lol\"lol", // + "foo\\\"bar" // }; String converted = convertService.convert(expected, String.class); Assert.assertEquals("{\"{foo\", \"bar}\", " + // @@ -175,11 +176,11 @@ public void testStringArrayConversion() { @Test public void testCharacterArrayConversion() { Character[] expected = new Character[] { // - 's', // - '\n', // - ',', // - '{', // - '}' // + 's', // + '\n', // + ',', // + '{', // + '}' // }; String converted = convertService.convert(expected, String.class); Assert.assertEquals("{\"s\", \"\n\", \",\", \"{\", \"}\"}", converted); @@ -189,68 +190,68 @@ public void testCharacterArrayConversion() { @Test public void testStringToDoubleArraySingleValue() { - assertArrayEquals(new double[] {5}, - converter.convert("5", double[].class), 0); - assertArrayEquals(new Double[] {6d}, - converter.convert("6", Double[].class)); - assertArrayEquals(new double[][] {{7}}, - converter.convert("7", double[][].class)); - assertArrayEquals(new Double[][] {{8d}}, - converter.convert("8", Double[][].class)); + assertArrayEquals(new double[] { 5 }, converter.convert("5", + double[].class), 0); + assertArrayEquals(new Double[] { 6d }, converter.convert("6", + Double[].class)); + assertArrayEquals(new double[][] { { 7 } }, converter.convert("7", + double[][].class)); + assertArrayEquals(new Double[][] { { 8d } }, converter.convert("8", + Double[][].class)); - assertArrayEquals(new double[] {0}, - converter.convert("spinach", double[].class), 0); - assertArrayEquals(new Double[] {null}, - converter.convert("kale", Double[].class)); - assertArrayEquals(new double[][] {{0}}, - converter.convert("broccoli", double[][].class)); - assertArrayEquals(new Double[][] {{null}}, - converter.convert("lettuce", Double[][].class)); + assertArrayEquals(new double[] { 0 }, converter.convert("spinach", + double[].class), 0); + assertArrayEquals(new Double[] { null }, converter.convert("kale", + Double[].class)); + assertArrayEquals(new double[][] { { 0 } }, converter.convert("broccoli", + double[][].class)); + assertArrayEquals(new Double[][] { { null } }, converter.convert("lettuce", + Double[][].class)); } @Test public void testStringToDoubleArray1D() { // all numbers - assertArrayEquals(new double[] {0, 1, 2, 3}, - converter.convert("{0, 1, 2, 3}", double[].class), 0); - assertArrayEquals(new Double[] {7d, 11d}, - converter.convert("{7, 11}", Double[].class)); - assertArrayEquals(new Double[] {0d, 1d, 2d, 3d}, - converter.convert("{0, 1, 2, 3}", Double[].class)); + assertArrayEquals(new double[] { 0, 1, 2, 3 }, converter.convert( + "{0, 1, 2, 3}", double[].class), 0); + assertArrayEquals(new Double[] { 7d, 11d }, converter.convert("{7, 11}", + Double[].class)); + assertArrayEquals(new Double[] { 0d, 1d, 2d, 3d }, converter.convert( + "{0, 1, 2, 3}", Double[].class)); // mixed numbers/non-numbers - assertArrayEquals(new double[] {0, 1, 0, 3}, - converter.convert("{0, 1, kumquat, 3}", double[].class), 0); - assertArrayEquals(new Double[] {4d, null, 5d}, - converter.convert("{4, eggplant, 5}", Double[].class)); + assertArrayEquals(new double[] { 0, 1, 0, 3 }, converter.convert( + "{0, 1, kumquat, 3}", double[].class), 0); + assertArrayEquals(new Double[] { 4d, null, 5d }, converter.convert( + "{4, eggplant, 5}", Double[].class)); // all non-numbers - assertArrayEquals(new double[] {0, 0, 0}, - converter.convert("{uno, dos, tres}", double[].class), 0); - assertArrayEquals(new Double[] {null, null, null, null}, - converter.convert("{cuatro, cinco, seis, siete}", Double[].class)); + assertArrayEquals(new double[] { 0, 0, 0 }, converter.convert( + "{uno, dos, tres}", double[].class), 0); + assertArrayEquals(new Double[] { null, null, null, null }, converter + .convert("{cuatro, cinco, seis, siete}", Double[].class)); } @Test public void testStringToDoubleArray2D() { // all numbers - assertArrayEquals(new double[][] {{0, 1}, {2, 3, 4}}, - converter.convert("{{0, 1}, {2, 3, 4}}", double[][].class)); - assertArrayEquals(new Double[][] {{7d, 11d}, {13d, 17d, 19d}}, + assertArrayEquals(new double[][] { { 0, 1 }, { 2, 3, 4 } }, converter + .convert("{{0, 1}, {2, 3, 4}}", double[][].class)); + assertArrayEquals(new Double[][] { { 7d, 11d }, { 13d, 17d, 19d } }, converter.convert("{{7, 11}, {13, 17, 19}}", Double[][].class)); - assertArrayEquals(new Double[][] {{0d, 1d}, {2d, 3d}}, - converter.convert("{{0, 1}, {2, 3}}", Double[][].class)); + assertArrayEquals(new Double[][] { { 0d, 1d }, { 2d, 3d } }, converter + .convert("{{0, 1}, {2, 3}}", Double[][].class)); // mixed numbers/non-numbers - assertArrayEquals(new double[][] {{0, 1}, {0, 3}}, - converter.convert("{{0, 1}, {kumquat, 3}}", double[][].class)); - assertArrayEquals(new Double[][] {{4d}, {null, 5d}, {null}}, + assertArrayEquals(new double[][] { { 0, 1 }, { 0, 3 } }, converter.convert( + "{{0, 1}, {kumquat, 3}}", double[][].class)); + assertArrayEquals(new Double[][] { { 4d }, { null, 5d }, { null } }, converter.convert("{{4}, {eggplant, 5}, {squash}}", Double[][].class)); // all non-numbers - assertArrayEquals(new double[][] {{0}, {0, 0}}, - converter.convert("{{uno}, {dos, tres}}", double[][].class)); - assertArrayEquals(new Double[][] {{null, null}, {null, null}}, + assertArrayEquals(new double[][] { { 0 }, { 0, 0 } }, converter.convert( + "{{uno}, {dos, tres}}", double[][].class)); + assertArrayEquals(new Double[][] { { null, null }, { null, null } }, converter.convert("{{cuatro, cinco}, {seis, siete}}", Double[][].class)); } @@ -258,11 +259,11 @@ public void testStringToDoubleArray2D() { public void testStringToDoubleArray3D() { final Random r = new Random(0xDA7ABA5E); final double[][][] ds = new double[r.nextInt(10)][][]; - for (int i=0; i display = - (Display) displayService.createDisplay(name, values[0]); + final Display display = (Display) displayService + .createDisplay(name, values[0]); assertNotNull(display); for (int i = 1; i < values.length; i++) { @@ -112,8 +112,8 @@ public void testAddRemove() { @Test public void testText() { final Context context = new Context(DisplayService.class); - final DisplayService displayService = - context.getService(DisplayService.class); + final DisplayService displayService = context.getService( + DisplayService.class); final String name = "Text"; final String value = "Hello"; final Display d = displayService.createDisplay(name, value); diff --git a/src/test/java/org/scijava/download/DownloadServiceTest.java b/src/test/java/org/scijava/download/DownloadServiceTest.java index a9bb2a421..171eeeb8d 100644 --- a/src/test/java/org/scijava/download/DownloadServiceTest.java +++ b/src/test/java/org/scijava/download/DownloadServiceTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.download; import static org.junit.Assert.assertArrayEquals; @@ -52,7 +53,7 @@ /** * Tests {@link DownloadService}. - * + * * @author Curtis Rueden */ public class DownloadServiceTest { @@ -170,7 +171,7 @@ private byte[] randomBytes(final long seed) { } private void assertBytesEqual(byte[] data, ByteBank byteBank) { - for (int i=0; i reference = - new WeakReference<>(new MyEventHandler()); + final WeakReference reference = new WeakReference<>( + new MyEventHandler()); gc(); assertNull(reference.get()); @@ -84,8 +85,8 @@ public void testWeakEventHandlers() { public void testEventHandlerDependencies() throws InterruptedException { final Context context = new Context(ServiceNeedingAnEventService.class); final EventService eventService = context.getService(EventService.class); - final ServiceNeedingAnEventService snaeService = - context.getService(ServiceNeedingAnEventService.class); + final ServiceNeedingAnEventService snaeService = context.getService( + ServiceNeedingAnEventService.class); assertNotNull(eventService); // NB: ServicesLoadedEvent is published asynchronously. synchronized (snaeService) { @@ -96,19 +97,22 @@ public void testEventHandlerDependencies() throws InterruptedException { private static void gc() { System.gc(); - // for some reason, some systems need extra encouragement to collect their garbage + // for some reason, some systems need extra encouragement to collect their + // garbage System.gc(); } private int counter = 0; private class MyEvent extends SciJavaEvent { + public void inc() { counter++; } } public static class MyEventHandler { + @EventHandler public void onEvent(final MyEvent e) { e.inc(); diff --git a/src/test/java/org/scijava/event/bushe/BadEventService.java b/src/test/java/org/scijava/event/bushe/BadEventService.java index 2046821a2..003a937f8 100644 --- a/src/test/java/org/scijava/event/bushe/BadEventService.java +++ b/src/test/java/org/scijava/event/bushe/BadEventService.java @@ -1,10 +1,12 @@ + package org.scijava.event.bushe; public class BadEventService extends ThreadSafeEventService { - - /** @see org.scijava.event.bushe.EventService#subscribe(String,org.scijava.event.bushe.EventTopicSubscriber) */ - public boolean subscribe(String topic, EventTopicSubscriber eh) { - throw new RuntimeException("For testing"); - } + /** + * @see org.scijava.event.bushe.EventService#subscribe(String,org.scijava.event.bushe.EventTopicSubscriber) + */ + public boolean subscribe(String topic, EventTopicSubscriber eh) { + throw new RuntimeException("For testing"); + } } diff --git a/src/test/java/org/scijava/event/bushe/DataRequestEvent.java b/src/test/java/org/scijava/event/bushe/DataRequestEvent.java index 236b44fa8..0939801ca 100644 --- a/src/test/java/org/scijava/event/bushe/DataRequestEvent.java +++ b/src/test/java/org/scijava/event/bushe/DataRequestEvent.java @@ -1,3 +1,4 @@ + package org.scijava.event.bushe; import java.util.List; @@ -5,5 +6,4 @@ /** * Test event for Bill Wholer's typed events. */ -public class DataRequestEvent { -} +public class DataRequestEvent {} diff --git a/src/test/java/org/scijava/event/bushe/EBTestCounter.java b/src/test/java/org/scijava/event/bushe/EBTestCounter.java index 8ebf75160..f24192831 100644 --- a/src/test/java/org/scijava/event/bushe/EBTestCounter.java +++ b/src/test/java/org/scijava/event/bushe/EBTestCounter.java @@ -1,3 +1,4 @@ + package org.scijava.event.bushe; /** @@ -5,6 +6,7 @@ * @since Nov 19, 2005 11:12:35 PM */ public class EBTestCounter { - public int eventsHandledCount; - public int subscribeExceptionCount; + + public int eventsHandledCount; + public int subscribeExceptionCount; } diff --git a/src/test/java/org/scijava/event/bushe/EDTUtil.java b/src/test/java/org/scijava/event/bushe/EDTUtil.java index c74d4846f..6bb9cb299 100644 --- a/src/test/java/org/scijava/event/bushe/EDTUtil.java +++ b/src/test/java/org/scijava/event/bushe/EDTUtil.java @@ -9,28 +9,29 @@ import java.awt.Toolkit; /** - * * @author Michael Bushe */ public class EDTUtil { - /** - * Since we are using the event bus from a non-awt thread, stay alive for a sec to give time for the EDT to start and - * post the message - */ - public static void waitForEDT() { - EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); - long start = System.currentTimeMillis(); - do { - //wait at least once - plenty of time for the event sent to the queue to get there - long now = System.currentTimeMillis(); - if (now > start + (1000*5) ) { - throw new RuntimeException("Waited too long for the EDT to finish."); - } - try { - Thread.sleep(100); - } catch (Throwable e) { - } - } while(eventQueue.peekEvent() != null); - } + /** + * Since we are using the event bus from a non-awt thread, stay alive for a + * sec to give time for the EDT to start and post the message + */ + public static void waitForEDT() { + EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); + long start = System.currentTimeMillis(); + do { + // wait at least once - plenty of time for the event sent to the queue to + // get there + long now = System.currentTimeMillis(); + if (now > start + (1000 * 5)) { + throw new RuntimeException("Waited too long for the EDT to finish."); + } + try { + Thread.sleep(100); + } + catch (Throwable e) {} + } + while (eventQueue.peekEvent() != null); + } } diff --git a/src/test/java/org/scijava/event/bushe/GenericReflection.java b/src/test/java/org/scijava/event/bushe/GenericReflection.java index d3d2954b3..0ac421b9c 100644 --- a/src/test/java/org/scijava/event/bushe/GenericReflection.java +++ b/src/test/java/org/scijava/event/bushe/GenericReflection.java @@ -1,3 +1,4 @@ + package org.scijava.event.bushe; import java.lang.reflect.TypeVariable; @@ -9,117 +10,135 @@ * From OReilly Book Java Generics */ public class GenericReflection { - DataRequestEvent dre; - private final static PrintStream out = System.out; - public static void printSuperclass (Type sup) { - if (sup != null && !sup.equals(Object.class)) { - out.print("extends "); - printType(sup); - out.println(); - } - } - public static void printInterfaces (Type[] implementations) { - if (implementations != null && implementations.length > 0) { - out.print("implements "); - int i = 0; - for (Type impl : implementations) { - if (i++ > 0) out.print(","); - printType(impl); - } - out.println(); - } - } - public static void printTypeParameters (TypeVariable[] vars) { - if (vars != null && vars.length > 0) { - out.print("<"); - int i = 0; - for (TypeVariable var : vars) { - if (i++ > 0) out.print(","); - out.print(var.getName()); - printBounds(var.getBounds()); - } - out.print(">"); + + DataRequestEvent dre; + private final static PrintStream out = System.out; + + public static void printSuperclass(Type sup) { + if (sup != null && !sup.equals(Object.class)) { + out.print("extends "); + printType(sup); + out.println(); + } } - } - public static void printBounds (Type[] bounds) { - if (bounds != null && bounds.length > 0 - && !(bounds.length==1 && bounds[0]==Object.class)) { - out.print(" extends "); - int i = 0; - for (Type bound : bounds) { - if (i++ > 0) out.print("&"); - printType(bound); - } + + public static void printInterfaces(Type[] implementations) { + if (implementations != null && implementations.length > 0) { + out.print("implements "); + int i = 0; + for (Type impl : implementations) { + if (i++ > 0) out.print(","); + printType(impl); + } + out.println(); + } } - } - public static void printParams (Type[] types) { - if (types != null && types.length > 0) { - out.print("<"); - int i = 0; - for (Type type : types) { - if (i++ > 0) out.print(","); - printType(type); - } - out.print(">"); + + public static void printTypeParameters(TypeVariable[] vars) { + if (vars != null && vars.length > 0) { + out.print("<"); + int i = 0; + for (TypeVariable var : vars) { + if (i++ > 0) out.print(","); + out.print(var.getName()); + printBounds(var.getBounds()); + } + out.print(">"); + } } - } - public static void printType (Type type) { - if (type instanceof Class) { - Class c = (Class)type; - out.print(c.getName()); - } else if (type instanceof ParameterizedType) { - ParameterizedType p = (ParameterizedType)type; - Class c = (Class)p.getRawType(); - Type o = p.getOwnerType(); - if (o != null) { printType(o); out.print("."); } - out.print(c.getName()); - printParams(p.getActualTypeArguments()); - } else if (type instanceof TypeVariable) { - TypeVariable v = (TypeVariable)type; - out.print(v.getName()); - } else if (type instanceof GenericArrayType) { - GenericArrayType a = (GenericArrayType)type; - printType(a.getGenericComponentType()); - out.print("[]"); - } else if (type instanceof WildcardType) { - WildcardType w = (WildcardType)type; - Type[] upper = w.getUpperBounds(); - Type[] lower = w.getLowerBounds(); - if (upper.length==1 && lower.length==0) { - out.print("? extends "); - printType(upper[0]); - } else if (upper.length==0 && lower.length==1) { - out.print("? super "); - printType(lower[0]); - } else assert false; + + public static void printBounds(Type[] bounds) { + if (bounds != null && bounds.length > 0 && !(bounds.length == 1 && + bounds[0] == Object.class)) + { + out.print(" extends "); + int i = 0; + for (Type bound : bounds) { + if (i++ > 0) out.print("&"); + printType(bound); + } + } } - } - public static void printClass (Class c) { - out.print("class "); - out.print(c.getName()); - printTypeParameters(c.getTypeParameters()); - out.println(); - printSuperclass(c.getGenericSuperclass()); - printInterfaces(c.getGenericInterfaces()); - /* - out.println("{"); - for (Field f : c.getFields()) { - out.println(" "+f.toGenericString()+";"); + + public static void printParams(Type[] types) { + if (types != null && types.length > 0) { + out.print("<"); + int i = 0; + for (Type type : types) { + if (i++ > 0) out.print(","); + printType(type); + } + out.print(">"); + } } - for (Constructor k : c.getConstructors()) { - out.println(" "+k.toGenericString()+";"); + + public static void printType(Type type) { + if (type instanceof Class) { + Class c = (Class) type; + out.print(c.getName()); + } + else if (type instanceof ParameterizedType) { + ParameterizedType p = (ParameterizedType) type; + Class c = (Class) p.getRawType(); + Type o = p.getOwnerType(); + if (o != null) { + printType(o); + out.print("."); + } + out.print(c.getName()); + printParams(p.getActualTypeArguments()); + } + else if (type instanceof TypeVariable) { + TypeVariable v = (TypeVariable) type; + out.print(v.getName()); + } + else if (type instanceof GenericArrayType) { + GenericArrayType a = (GenericArrayType) type; + printType(a.getGenericComponentType()); + out.print("[]"); + } + else if (type instanceof WildcardType) { + WildcardType w = (WildcardType) type; + Type[] upper = w.getUpperBounds(); + Type[] lower = w.getLowerBounds(); + if (upper.length == 1 && lower.length == 0) { + out.print("? extends "); + printType(upper[0]); + } + else if (upper.length == 0 && lower.length == 1) { + out.print("? super "); + printType(lower[0]); + } + else assert false; + } } - for (Method m : c.getMethods()) { - out.println(" "+m.toGenericString()+";"); + + public static void printClass(Class c) { + out.print("class "); + out.print(c.getName()); + printTypeParameters(c.getTypeParameters()); + out.println(); + printSuperclass(c.getGenericSuperclass()); + printInterfaces(c.getGenericInterfaces()); + /* + out.println("{"); + for (Field f : c.getFields()) { + out.println(" "+f.toGenericString()+";"); + } + for (Constructor k : c.getConstructors()) { + out.println(" "+k.toGenericString()+";"); + } + for (Method m : c.getMethods()) { + out.println(" "+m.toGenericString()+";"); + } + out.println("}"); + */ } - out.println("}"); - */ - } - public static void main (String[] args) throws ClassNotFoundException { - for (String name : args) { - Class c = Class.forName(name); - printClass(c); + + public static void main(String[] args) throws ClassNotFoundException { + for (String name : args) { + Class c = Class.forName(name); + printClass(c); + } } - } } - diff --git a/src/test/java/org/scijava/event/bushe/MyData.java b/src/test/java/org/scijava/event/bushe/MyData.java index 43be650c8..5815096a8 100644 --- a/src/test/java/org/scijava/event/bushe/MyData.java +++ b/src/test/java/org/scijava/event/bushe/MyData.java @@ -1,3 +1,4 @@ + package org.scijava.event.bushe; /** @@ -5,13 +6,14 @@ * https://eventbus.dev.java.net/servlets/ProjectForumMessageView?messageID=30702&forumID=1834 */ public class MyData { - private String classification = "foo"; - public String getClassification() { - return classification; - } + private String classification = "foo"; + + public String getClassification() { + return classification; + } - public void setClassification(String classification) { - this.classification = classification; - } + public void setClassification(String classification) { + this.classification = classification; + } } diff --git a/src/test/java/org/scijava/event/bushe/SubscriberForTest.java b/src/test/java/org/scijava/event/bushe/SubscriberForTest.java index 2fac88e57..dae44ded8 100644 --- a/src/test/java/org/scijava/event/bushe/SubscriberForTest.java +++ b/src/test/java/org/scijava/event/bushe/SubscriberForTest.java @@ -1,3 +1,4 @@ + package org.scijava.event.bushe; import java.util.Date; @@ -7,37 +8,42 @@ * @since Nov 19, 2005 11:01:06 PM */ public class SubscriberForTest implements EventSubscriber { - private boolean throwException; - private Long waitTime; - private EBTestCounter testDefaultEventService; - Date callTime = null; - - public SubscriberForTest(EBTestCounter testDefaultEventService, Long waitTime) { - this.testDefaultEventService = testDefaultEventService; - this.waitTime = waitTime; - } - - public SubscriberForTest(EBTestCounter testDefaultEventService, boolean throwException) { - this.testDefaultEventService = testDefaultEventService; - this.throwException = throwException; - } - - public void onEvent(Object evt) { - callTime = new Date(); - if (waitTime != null) { - try { - Thread.sleep(waitTime.longValue()); - } catch (InterruptedException e) { - } - } - testDefaultEventService.eventsHandledCount++; - if (throwException) { - testDefaultEventService.subscribeExceptionCount++; - throw new IllegalArgumentException(); - } - } - - public boolean equals(Object obj) { - return (this == obj); - } + + private boolean throwException; + private Long waitTime; + private EBTestCounter testDefaultEventService; + Date callTime = null; + + public SubscriberForTest(EBTestCounter testDefaultEventService, + Long waitTime) + { + this.testDefaultEventService = testDefaultEventService; + this.waitTime = waitTime; + } + + public SubscriberForTest(EBTestCounter testDefaultEventService, + boolean throwException) + { + this.testDefaultEventService = testDefaultEventService; + this.throwException = throwException; + } + + public void onEvent(Object evt) { + callTime = new Date(); + if (waitTime != null) { + try { + Thread.sleep(waitTime.longValue()); + } + catch (InterruptedException e) {} + } + testDefaultEventService.eventsHandledCount++; + if (throwException) { + testDefaultEventService.subscribeExceptionCount++; + throw new IllegalArgumentException(); + } + } + + public boolean equals(Object obj) { + return (this == obj); + } } diff --git a/src/test/java/org/scijava/event/bushe/SubscriberForTesting.java b/src/test/java/org/scijava/event/bushe/SubscriberForTesting.java index a0a0fdf2c..e475a352e 100644 --- a/src/test/java/org/scijava/event/bushe/SubscriberForTesting.java +++ b/src/test/java/org/scijava/event/bushe/SubscriberForTesting.java @@ -1,5 +1,7 @@ + package org.scijava.event.bushe; public interface SubscriberForTesting { + long getTimesCalled(); } diff --git a/src/test/java/org/scijava/event/bushe/TestPerformance.java b/src/test/java/org/scijava/event/bushe/TestPerformance.java index a936200ee..d4d8c2ec7 100644 --- a/src/test/java/org/scijava/event/bushe/TestPerformance.java +++ b/src/test/java/org/scijava/event/bushe/TestPerformance.java @@ -1,3 +1,4 @@ + package org.scijava.event.bushe; import junit.framework.TestCase; @@ -12,64 +13,76 @@ * For proving performance. */ public class TestPerformance extends TestCase { - private EventSubscriber doNothingSubscriber = new EventSubscriber() { - public void onEvent(Object event) { - } - }; - private EventTopicSubscriber doNothingTopicSubscriber = new EventTopicSubscriber() { - public void onEvent(String topic, Object payload) { - } - }; + private EventSubscriber doNothingSubscriber = new EventSubscriber() { + + public void onEvent(Object event) {} + }; + + private EventTopicSubscriber doNothingTopicSubscriber = + new EventTopicSubscriber() + { + + public void onEvent(String topic, Object payload) {} + }; - public void testClassPerformance() { - ThreadSafeEventService eventService = new ThreadSafeEventService(); - Class[] classes = {Color.class, String.class, JTextField.class, List.class, JButton.class, - Boolean.class, Integer.class, Boolean.class, Set.class, Date.class}; - Object[] payloads = {Color.BLUE, "foo", new JTextField(), new ArrayList(), new JButton(), - Boolean.TRUE, 35, 36L, new HashSet(), new Date()}; - for (Class aClass : classes) { - eventService.subscribe(aClass, doNothingSubscriber); - } + public void testClassPerformance() { + ThreadSafeEventService eventService = new ThreadSafeEventService(); + Class[] classes = { Color.class, String.class, JTextField.class, List.class, + JButton.class, Boolean.class, Integer.class, Boolean.class, Set.class, + Date.class }; + Object[] payloads = { Color.BLUE, "foo", new JTextField(), new ArrayList(), + new JButton(), Boolean.TRUE, 35, 36L, new HashSet(), new Date() }; + for (Class aClass : classes) { + eventService.subscribe(aClass, doNothingSubscriber); + } - long start = System.currentTimeMillis(); - int count = 100000; - for (int i=0; i < count; i++) { - for (Object payload : payloads) { - eventService.publish(payload); - } - } - long end = System.currentTimeMillis(); - long duration = (end - start)/1000; - int numPubs = count * payloads.length; - System.out.println("Time for "+ numPubs +" publications with subscribers to "+classes.length - +" different classes subscribed to was "+ duration +" s. Average:"+((double)duration/(double)numPubs)); - Assert.assertTrue("Things are slowing down, "+numPubs+" class publications used to take 3.3 seconds, it now takes " +duration, duration < 7); - } + long start = System.currentTimeMillis(); + int count = 100000; + for (int i = 0; i < count; i++) { + for (Object payload : payloads) { + eventService.publish(payload); + } + } + long end = System.currentTimeMillis(); + long duration = (end - start) / 1000; + int numPubs = count * payloads.length; + System.out.println("Time for " + numPubs + + " publications with subscribers to " + classes.length + + " different classes subscribed to was " + duration + " s. Average:" + + ((double) duration / (double) numPubs)); + Assert.assertTrue("Things are slowing down, " + numPubs + + " class publications used to take 3.3 seconds, it now takes " + duration, + duration < 7); + } - public void testStringPerformance() { - ThreadSafeEventService eventService = new ThreadSafeEventService(); - String[] strings = {"Color", "String", "JTextField", "List", "JButton", - "Boolean", "Integer", "Boolean", "Set", "Date"}; - Object[] payloads = {Color.BLUE, "foo", new JTextField(), new ArrayList(), new JButton(), - Boolean.TRUE, 35, 36L, new HashSet(), new Date()}; - for (String aString : strings) { - eventService.subscribe(aString, doNothingTopicSubscriber); - } + public void testStringPerformance() { + ThreadSafeEventService eventService = new ThreadSafeEventService(); + String[] strings = { "Color", "String", "JTextField", "List", "JButton", + "Boolean", "Integer", "Boolean", "Set", "Date" }; + Object[] payloads = { Color.BLUE, "foo", new JTextField(), new ArrayList(), + new JButton(), Boolean.TRUE, 35, 36L, new HashSet(), new Date() }; + for (String aString : strings) { + eventService.subscribe(aString, doNothingTopicSubscriber); + } - long start = System.currentTimeMillis(); - int count = 100000; - for (int i=0; i < count; i++) { - for (int j=0; j < strings.length; j++) { - eventService.publish(strings[j], payloads[j]); - } - } - long end = System.currentTimeMillis(); - long duration = (end - start)/1000; - int numPubs = count * payloads.length; - System.out.println("Time for "+ numPubs +" topic publications with topic subscribers to "+ strings.length - +" different strings subscribed to was "+ duration +" s. Average:"+((double)duration/(double)numPubs)); - Assert.assertTrue("Things are slowing down, "+numPubs+" string publications used to take 1.3 seconds, it now takes "+duration, duration < 4); - } + long start = System.currentTimeMillis(); + int count = 100000; + for (int i = 0; i < count; i++) { + for (int j = 0; j < strings.length; j++) { + eventService.publish(strings[j], payloads[j]); + } + } + long end = System.currentTimeMillis(); + long duration = (end - start) / 1000; + int numPubs = count * payloads.length; + System.out.println("Time for " + numPubs + + " topic publications with topic subscribers to " + strings.length + + " different strings subscribed to was " + duration + " s. Average:" + + ((double) duration / (double) numPubs)); + Assert.assertTrue("Things are slowing down, " + numPubs + + " string publications used to take 1.3 seconds, it now takes " + duration, + duration < 4); + } } diff --git a/src/test/java/org/scijava/event/bushe/TopicSubscriberForTest.java b/src/test/java/org/scijava/event/bushe/TopicSubscriberForTest.java index 3b7836df8..1b92bdce5 100644 --- a/src/test/java/org/scijava/event/bushe/TopicSubscriberForTest.java +++ b/src/test/java/org/scijava/event/bushe/TopicSubscriberForTest.java @@ -1,3 +1,4 @@ + package org.scijava.event.bushe; /** @@ -5,31 +6,36 @@ * @since Nov 19, 2005 11:00:53 PM */ public class TopicSubscriberForTest implements EventTopicSubscriber { - private boolean throwException; - private Long waitTime; - private EBTestCounter testDefaultEventService; - public TopicSubscriberForTest(EBTestCounter testDefaultEventService, Long waitTime) { - this.testDefaultEventService = testDefaultEventService; - this.waitTime = waitTime; - } + private boolean throwException; + private Long waitTime; + private EBTestCounter testDefaultEventService; + + public TopicSubscriberForTest(EBTestCounter testDefaultEventService, + Long waitTime) + { + this.testDefaultEventService = testDefaultEventService; + this.waitTime = waitTime; + } - public TopicSubscriberForTest(EBTestCounter testDefaultEventService, boolean throwException) { - this.testDefaultEventService = testDefaultEventService; - this.throwException = throwException; - } + public TopicSubscriberForTest(EBTestCounter testDefaultEventService, + boolean throwException) + { + this.testDefaultEventService = testDefaultEventService; + this.throwException = throwException; + } - public void onEvent(String topic, Object evt) { - if (waitTime != null) { - try { - Thread.sleep(waitTime.longValue()); - } catch (InterruptedException e) { - } - } - testDefaultEventService.eventsHandledCount++; - if (throwException) { - testDefaultEventService.subscribeExceptionCount++; - throw new IllegalArgumentException(); - } - } + public void onEvent(String topic, Object evt) { + if (waitTime != null) { + try { + Thread.sleep(waitTime.longValue()); + } + catch (InterruptedException e) {} + } + testDefaultEventService.eventsHandledCount++; + if (throwException) { + testDefaultEventService.subscribeExceptionCount++; + throw new IllegalArgumentException(); + } + } } diff --git a/src/test/java/org/scijava/event/bushe/VetoEventListenerForTest.java b/src/test/java/org/scijava/event/bushe/VetoEventListenerForTest.java index 81a481185..788375dc3 100644 --- a/src/test/java/org/scijava/event/bushe/VetoEventListenerForTest.java +++ b/src/test/java/org/scijava/event/bushe/VetoEventListenerForTest.java @@ -1,3 +1,4 @@ + package org.scijava.event.bushe; /** @@ -5,20 +6,21 @@ * @since Nov 19, 2005 11:00:42 PM */ public class VetoEventListenerForTest implements VetoEventListener { - private boolean throwException; - public VetoEventListenerForTest() { - this(false); - } + private boolean throwException; + + public VetoEventListenerForTest() { + this(false); + } - public VetoEventListenerForTest(boolean throwException) { - this.throwException = throwException; - } + public VetoEventListenerForTest(boolean throwException) { + this.throwException = throwException; + } - public boolean shouldVeto(Object evt) { - if (throwException) { - throw new IllegalArgumentException("veto ex"); - } - return true; - } + public boolean shouldVeto(Object evt) { + if (throwException) { + throw new IllegalArgumentException("veto ex"); + } + return true; + } } diff --git a/src/test/java/org/scijava/event/bushe/VetoTopicEventListenerForTest.java b/src/test/java/org/scijava/event/bushe/VetoTopicEventListenerForTest.java index af8bf79e5..5e86eaf36 100644 --- a/src/test/java/org/scijava/event/bushe/VetoTopicEventListenerForTest.java +++ b/src/test/java/org/scijava/event/bushe/VetoTopicEventListenerForTest.java @@ -1,3 +1,4 @@ + package org.scijava.event.bushe; /** @@ -5,20 +6,21 @@ * @since Nov 19, 2005 11:00:42 PM */ public class VetoTopicEventListenerForTest implements VetoTopicEventListener { - private boolean throwException; - public VetoTopicEventListenerForTest() { - this(false); - } + private boolean throwException; + + public VetoTopicEventListenerForTest() { + this(false); + } - VetoTopicEventListenerForTest(boolean throwException) { - this.throwException = throwException; - } + VetoTopicEventListenerForTest(boolean throwException) { + this.throwException = throwException; + } - public boolean shouldVeto(String topic, Object data) { - if (throwException) { - throw new IllegalArgumentException("veto ex"); - } - return true; - } + public boolean shouldVeto(String topic, Object data) { + if (throwException) { + throw new IllegalArgumentException("veto ex"); + } + return true; + } } diff --git a/src/test/java/org/scijava/io/ByteArrayByteBankTest.java b/src/test/java/org/scijava/io/ByteArrayByteBankTest.java index e57db1f3e..79c6678e7 100644 --- a/src/test/java/org/scijava/io/ByteArrayByteBankTest.java +++ b/src/test/java/org/scijava/io/ByteArrayByteBankTest.java @@ -6,13 +6,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/test/java/org/scijava/io/ByteBankTest.java b/src/test/java/org/scijava/io/ByteBankTest.java index fd1ff0b6a..ea6341925 100644 --- a/src/test/java/org/scijava/io/ByteBankTest.java +++ b/src/test/java/org/scijava/io/ByteBankTest.java @@ -6,13 +6,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/test/java/org/scijava/io/IOServiceTest.java b/src/test/java/org/scijava/io/IOServiceTest.java index bae4be289..cd6bf6df7 100644 --- a/src/test/java/org/scijava/io/IOServiceTest.java +++ b/src/test/java/org/scijava/io/IOServiceTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.io; import org.junit.Test; @@ -49,7 +50,8 @@ public class IOServiceTest { public void testTextFile() throws IOException { // create context, add dummy text format final Context ctx = new Context(); - ctx.getPluginIndex().add(new PluginInfo<>(DummyTextFormat.class, TextFormat.class)); + ctx.getPluginIndex().add(new PluginInfo<>(DummyTextFormat.class, + TextFormat.class)); final IOService io = ctx.getService(IOService.class); // open text file from resources as String @@ -65,8 +67,7 @@ public void testTextFile() throws IOException { assertEquals(content, obj.toString()); } - - public static class DummyTextFormat extends AbstractTextFormat { + public static class DummyTextFormat extends AbstractTextFormat { @Override public List getExtensions() { diff --git a/src/test/java/org/scijava/io/TypedIOServiceTest.java b/src/test/java/org/scijava/io/TypedIOServiceTest.java index d59cb9014..125b420f3 100644 --- a/src/test/java/org/scijava/io/TypedIOServiceTest.java +++ b/src/test/java/org/scijava/io/TypedIOServiceTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.io; import org.junit.Test; @@ -48,7 +49,8 @@ public class TypedIOServiceTest { public void testTextFile() throws IOException { // create context, add dummy text format final Context ctx = new Context(); - ctx.getPluginIndex().add(new PluginInfo<>(DummyTextFormat.class, TextFormat.class)); + ctx.getPluginIndex().add(new PluginInfo<>(DummyTextFormat.class, + TextFormat.class)); // try to get the TextIOService final TextIOService io = ctx.service(TextIOService.class); @@ -61,7 +63,7 @@ public void testTextFile() throws IOException { assertTrue(obj.contains("content")); } - public static class DummyTextFormat extends AbstractTextFormat { + public static class DummyTextFormat extends AbstractTextFormat { @Override public List getExtensions() { diff --git a/src/test/java/org/scijava/io/event/DataEventTest.java b/src/test/java/org/scijava/io/event/DataEventTest.java index 0c4e8e7ea..e1ed3f0a9 100644 --- a/src/test/java/org/scijava/io/event/DataEventTest.java +++ b/src/test/java/org/scijava/io/event/DataEventTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.io.event; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/org/scijava/io/handle/BytesHandleTest.java b/src/test/java/org/scijava/io/handle/BytesHandleTest.java index a996b4fa2..922cc2b82 100644 --- a/src/test/java/org/scijava/io/handle/BytesHandleTest.java +++ b/src/test/java/org/scijava/io/handle/BytesHandleTest.java @@ -6,13 +6,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/test/java/org/scijava/io/handle/DataHandleEdgeCaseTests.java b/src/test/java/org/scijava/io/handle/DataHandleEdgeCaseTests.java index bac3ee2f2..0a2ee7080 100644 --- a/src/test/java/org/scijava/io/handle/DataHandleEdgeCaseTests.java +++ b/src/test/java/org/scijava/io/handle/DataHandleEdgeCaseTests.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ /** * Additional Tests for edge case behavior of {@link DataHandle}. - * + * * @author Gabriel Einsdorf */ public class DataHandleEdgeCaseTests { @@ -57,7 +57,7 @@ public class DataHandleEdgeCaseTests { * Test to ensure {@link DataHandle#findString(String...)} and * {@link DataHandle#readCString()} work with {@link DataHandle} * implementations that have unknown length. - * + * * @throws IOException */ @Test @@ -69,7 +69,7 @@ public void testFindStringsOnUnknonwLengthHandle() throws IOException { assertEquals("Hello,", dummy.findString(",")); assertEquals(" world\n", dummy.findString("\n")); - + dummy.seek(41); assertEquals("he", dummy.findString("\n")); diff --git a/src/test/java/org/scijava/io/handle/DataHandleTest.java b/src/test/java/org/scijava/io/handle/DataHandleTest.java index 8e84c4087..2b794bfee 100644 --- a/src/test/java/org/scijava/io/handle/DataHandleTest.java +++ b/src/test/java/org/scijava/io/handle/DataHandleTest.java @@ -6,13 +6,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 @@ -435,9 +435,8 @@ public void checkAdvancedStringWriting( /** * Checks writing methods affected by endianness. * - * @param handleCreator a supplier that creates properly initialized - * handles. All created handles must point to the same - * location! + * @param handleCreator a supplier that creates properly initialized handles. + * All created handles must point to the same location! * @param order Byte order to use when writing to the handles. */ public void checkWriteEndianes( diff --git a/src/test/java/org/scijava/io/handle/DataHandlesTest.java b/src/test/java/org/scijava/io/handle/DataHandlesTest.java index 5e0a95359..577c8b5ec 100644 --- a/src/test/java/org/scijava/io/handle/DataHandlesTest.java +++ b/src/test/java/org/scijava/io/handle/DataHandlesTest.java @@ -6,13 +6,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/test/java/org/scijava/io/handle/FileHandleTest.java b/src/test/java/org/scijava/io/handle/FileHandleTest.java index 6caa0c7e3..6e514fcf4 100644 --- a/src/test/java/org/scijava/io/handle/FileHandleTest.java +++ b/src/test/java/org/scijava/io/handle/FileHandleTest.java @@ -6,13 +6,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 @@ -83,7 +83,7 @@ public void testExists() throws IOException { handle.writeBoolean(true); assertTrue(handle.exists()); - assertEquals(1, handle.length()); + assertEquals(1, handle.length()); } // Clean up. diff --git a/src/test/java/org/scijava/io/handle/ReadBufferDataHandleMockTest.java b/src/test/java/org/scijava/io/handle/ReadBufferDataHandleMockTest.java index 3337d4a82..c2242b87a 100644 --- a/src/test/java/org/scijava/io/handle/ReadBufferDataHandleMockTest.java +++ b/src/test/java/org/scijava/io/handle/ReadBufferDataHandleMockTest.java @@ -6,13 +6,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/test/java/org/scijava/io/handle/ReadBufferDataHandleTest.java b/src/test/java/org/scijava/io/handle/ReadBufferDataHandleTest.java index 5e0fce0df..ccfe911af 100644 --- a/src/test/java/org/scijava/io/handle/ReadBufferDataHandleTest.java +++ b/src/test/java/org/scijava/io/handle/ReadBufferDataHandleTest.java @@ -6,13 +6,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/test/java/org/scijava/io/handle/WriteBufferDataHandleTest.java b/src/test/java/org/scijava/io/handle/WriteBufferDataHandleTest.java index dd0c158f4..2c558d26f 100644 --- a/src/test/java/org/scijava/io/handle/WriteBufferDataHandleTest.java +++ b/src/test/java/org/scijava/io/handle/WriteBufferDataHandleTest.java @@ -6,13 +6,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/test/java/org/scijava/io/location/BytesLocationTest.java b/src/test/java/org/scijava/io/location/BytesLocationTest.java index 4dbcd46a4..4f33ca68e 100644 --- a/src/test/java/org/scijava/io/location/BytesLocationTest.java +++ b/src/test/java/org/scijava/io/location/BytesLocationTest.java @@ -6,13 +6,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/test/java/org/scijava/io/location/FileLocationResolverTest.java b/src/test/java/org/scijava/io/location/FileLocationResolverTest.java index 0b71e739f..b178c9508 100644 --- a/src/test/java/org/scijava/io/location/FileLocationResolverTest.java +++ b/src/test/java/org/scijava/io/location/FileLocationResolverTest.java @@ -6,13 +6,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/test/java/org/scijava/io/location/FileLocationTest.java b/src/test/java/org/scijava/io/location/FileLocationTest.java index b9d189f0f..3438640a5 100644 --- a/src/test/java/org/scijava/io/location/FileLocationTest.java +++ b/src/test/java/org/scijava/io/location/FileLocationTest.java @@ -6,13 +6,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,7 +38,7 @@ /** * Tests {@link FileLocation}. - * + * * @author Curtis Rueden */ public class FileLocationTest { diff --git a/src/test/java/org/scijava/io/location/LocationServiceTest.java b/src/test/java/org/scijava/io/location/LocationServiceTest.java index 5889dae32..b5e5d86a1 100644 --- a/src/test/java/org/scijava/io/location/LocationServiceTest.java +++ b/src/test/java/org/scijava/io/location/LocationServiceTest.java @@ -6,13 +6,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 @@ -42,7 +42,7 @@ /** * Tests {@link LocationService}. - * + * * @author Gabriel Einsdorf * @author Curtis Rueden */ diff --git a/src/test/java/org/scijava/io/location/URILocationTest.java b/src/test/java/org/scijava/io/location/URILocationTest.java index 49ff094ab..672e0bdc8 100644 --- a/src/test/java/org/scijava/io/location/URILocationTest.java +++ b/src/test/java/org/scijava/io/location/URILocationTest.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ /** * Tests {@link URILocation}. - * + * * @author Curtis Rueden */ public class URILocationTest { diff --git a/src/test/java/org/scijava/io/location/URLLocationTest.java b/src/test/java/org/scijava/io/location/URLLocationTest.java index f053a1fab..f9cc21122 100644 --- a/src/test/java/org/scijava/io/location/URLLocationTest.java +++ b/src/test/java/org/scijava/io/location/URLLocationTest.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * Tests {@link URLLocation}. - * + * * @author Curtis Rueden */ public class URLLocationTest { diff --git a/src/test/java/org/scijava/io/nio/ByteBufferByteBankTest.java b/src/test/java/org/scijava/io/nio/ByteBufferByteBankTest.java index 76fdf7e21..71a2628e0 100644 --- a/src/test/java/org/scijava/io/nio/ByteBufferByteBankTest.java +++ b/src/test/java/org/scijava/io/nio/ByteBufferByteBankTest.java @@ -6,13 +6,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/test/java/org/scijava/log/CallingClassUtilsTest.java b/src/test/java/org/scijava/log/CallingClassUtilsTest.java index 8817580ee..968a0ca77 100644 --- a/src/test/java/org/scijava/log/CallingClassUtilsTest.java +++ b/src/test/java/org/scijava/log/CallingClassUtilsTest.java @@ -6,13 +6,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 @@ -37,10 +37,11 @@ /** * Tests {@link CallingClassUtils}. - * + * * @author Matthias Arzt */ public class CallingClassUtilsTest { + @Test public void testGetCallingClass() { String callingClass = CallingClassUtils.getCallingClassName(); @@ -54,6 +55,7 @@ public void testIgnoreAsCallingClass() { } public static class ClassA { + static String returnGetCallingClass() { return CallingClassUtils.getCallingClassName(); } @@ -61,6 +63,7 @@ static String returnGetCallingClass() { @IgnoreAsCallingClass private static class ClassB { + static String returnGetCallingClass() { return CallingClassUtils.getCallingClassName(); } diff --git a/src/test/java/org/scijava/log/DefaultLoggerTest.java b/src/test/java/org/scijava/log/DefaultLoggerTest.java index 5c2f29805..87b260982 100644 --- a/src/test/java/org/scijava/log/DefaultLoggerTest.java +++ b/src/test/java/org/scijava/log/DefaultLoggerTest.java @@ -6,13 +6,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 @@ -50,7 +50,8 @@ public class DefaultLoggerTest { @Before public void setup() { - logger = new DefaultLogger(message -> {}, LogSource.newRoot(), LogLevel.INFO); + logger = new DefaultLogger(message -> {}, LogSource.newRoot(), + LogLevel.INFO); listener = new TestLogListener(); logger.addLogListener(listener); } diff --git a/src/test/java/org/scijava/log/LogMessageTest.java b/src/test/java/org/scijava/log/LogMessageTest.java index 0699ddc37..4f665371e 100644 --- a/src/test/java/org/scijava/log/LogMessageTest.java +++ b/src/test/java/org/scijava/log/LogMessageTest.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ /** * Tests {@link LogMessage}. - * + * * @author Matthias Arzt */ public class LogMessageTest { @@ -50,35 +50,43 @@ public class LogMessageTest { public void testToString() { String nameOfThisMethod = "testToString"; // setup - LogMessage message = new LogMessage(LogSource.newRoot(), LogLevel.DEBUG, 42, new NullPointerException()); + LogMessage message = new LogMessage(LogSource.newRoot(), LogLevel.DEBUG, 42, + new NullPointerException()); // process String s = message.toString(); - //test - Assert.assertTrue("Log message contains level", s.contains(LogLevel.prefix(message.level()))); + // test + Assert.assertTrue("Log message contains level", s.contains(LogLevel.prefix( + message.level()))); Assert.assertTrue("Log message contains msg", s.contains(message.text())); - Assert.assertTrue("Log message contains throwable", s.contains(message.throwable().toString())); - Assert.assertTrue("Log message contains stack trace", s.contains(nameOfThisMethod)); + Assert.assertTrue("Log message contains throwable", s.contains(message + .throwable().toString())); + Assert.assertTrue("Log message contains stack trace", s.contains( + nameOfThisMethod)); } @Test public void testToStringOptionalParameters() { // setup - LogMessage message = new LogMessage(LogSource.newRoot(), LogLevel.WARN, null, null); + LogMessage message = new LogMessage(LogSource.newRoot(), LogLevel.WARN, + null, null); // process // Can it still format the message if optional parameters are null? String s = message.toString(); // test - Assert.assertTrue("Log message contains level", s.contains(LogLevel.prefix(message.level()))); + Assert.assertTrue("Log message contains level", s.contains(LogLevel.prefix( + message.level()))); } @Test public void testAttachments() { - LogMessage message = new LogMessage(LogSource.newRoot(), LogLevel.ERROR, "Message") ; + LogMessage message = new LogMessage(LogSource.newRoot(), LogLevel.ERROR, + "Message"); assertTrue(message.attachments().isEmpty()); Object object = new Object(); message.attach(object); - assertEquals(Collections.singletonList(object), new ArrayList<>(message.attachments())); + assertEquals(Collections.singletonList(object), new ArrayList<>(message + .attachments())); } } diff --git a/src/test/java/org/scijava/log/LogServiceTest.java b/src/test/java/org/scijava/log/LogServiceTest.java index 78a128073..5cbfbf6e6 100644 --- a/src/test/java/org/scijava/log/LogServiceTest.java +++ b/src/test/java/org/scijava/log/LogServiceTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.log; import org.junit.Test; @@ -54,11 +55,16 @@ public void testGetPrefix() { @Test public void testCompleteLogMethod() { - testCompleteLogMethod("ERROR", (logService, msg, t) -> logService.error(msg, t)); - testCompleteLogMethod("WARN", (logService, msg, t) -> logService.warn(msg, t)); - testCompleteLogMethod("INFO", (logService, msg, t) -> logService.info(msg, t)); - testCompleteLogMethod("DEBUG", (logService, msg, t) -> logService.debug(msg, t)); - testCompleteLogMethod("TRACE", (logService, msg, t) -> logService.trace(msg, t)); + testCompleteLogMethod("ERROR", (logService, msg, t) -> logService.error(msg, + t)); + testCompleteLogMethod("WARN", (logService, msg, t) -> logService.warn(msg, + t)); + testCompleteLogMethod("INFO", (logService, msg, t) -> logService.info(msg, + t)); + testCompleteLogMethod("DEBUG", (logService, msg, t) -> logService.debug(msg, + t)); + testCompleteLogMethod("TRACE", (logService, msg, t) -> logService.trace(msg, + t)); } @Test @@ -79,20 +85,30 @@ public void testExceptionLogMethod() { testExceptionLogMethod("TRACE", (logService, t) -> logService.trace(t)); } - private void testCompleteLogMethod(String prefix, LogMethodCall logMethodCall) { + private void testCompleteLogMethod(String prefix, + LogMethodCall logMethodCall) + { testLogMethod(prefix, logMethodCall, true, true); } - private void testMessageLogMethod(String prefix, BiConsumer call) { - testLogMethod(prefix, (log, text, exception) -> call.accept(log, text), true, false); + private void testMessageLogMethod(String prefix, + BiConsumer call) + { + testLogMethod(prefix, (log, text, exception) -> call.accept(log, text), + true, false); } - private void testExceptionLogMethod(String prefix, BiConsumer call) { - testLogMethod(prefix, (log, text, exception) -> call.accept(log, exception), false, true); + private void testExceptionLogMethod(String prefix, + BiConsumer call) + { + testLogMethod(prefix, (log, text, exception) -> call.accept(log, exception), + false, true); } - private void testLogMethod(String prefix, LogMethodCall logMethodCall, boolean testMessage, boolean testException) { + private void testLogMethod(String prefix, LogMethodCall logMethodCall, + boolean testMessage, boolean testException) + { // setup TestableLogService logService = new TestableLogService(); logService.setLevel(LogLevel.TRACE); @@ -101,12 +117,11 @@ private void testLogMethod(String prefix, LogMethodCall logMethodCall, boolean t // process logMethodCall.run(logService, text, exception); // test - if(testMessage) { + if (testMessage) { assertTrue(logService.message().contains(prefix)); assertTrue(logService.message().contains(text)); } - if(testException) - assertEquals(exception, logService.exception()); + if (testException) assertEquals(exception, logService.exception()); } @Test @@ -161,6 +176,7 @@ public void testMainSystemProperty() { } static class Dummy { + public static int getLevel(LogService log) { return log.getLevel(); } @@ -178,8 +194,10 @@ public void testClassLogLevel() { @Test public void testClassLogLevelViaProperties() { Properties properties = new Properties(); - properties.setProperty(LogService.LOG_LEVEL_PROPERTY + ":" + Dummy.class.getName(), LogLevel.prefix(LogLevel.ERROR)); - properties.setProperty(LogService.LOG_LEVEL_PROPERTY + ":" + this.getClass().getName(), LogLevel.prefix(LogLevel.TRACE)); + properties.setProperty(LogService.LOG_LEVEL_PROPERTY + ":" + Dummy.class + .getName(), LogLevel.prefix(LogLevel.ERROR)); + properties.setProperty(LogService.LOG_LEVEL_PROPERTY + ":" + this.getClass() + .getName(), LogLevel.prefix(LogLevel.TRACE)); final LogService log = new TestableLogService(properties); log.setLevel(LogLevel.DEBUG); int level = Dummy.getLevel(log); @@ -198,8 +216,10 @@ public void testSubLoggerLogLevel() { @Test public void testSubLoggerLogLevelViaProperties() { Properties properties = new Properties(); - properties.setProperty(LogService.LOG_LEVEL_BY_SOURCE_PROPERTY + ":Hello:World", LogLevel.prefix(LogLevel.ERROR)); - properties.setProperty(LogService.LOG_LEVEL_BY_SOURCE_PROPERTY + ":foo:bar", LogLevel.prefix(LogLevel.TRACE)); + properties.setProperty(LogService.LOG_LEVEL_BY_SOURCE_PROPERTY + + ":Hello:World", LogLevel.prefix(LogLevel.ERROR)); + properties.setProperty(LogService.LOG_LEVEL_BY_SOURCE_PROPERTY + ":foo:bar", + LogLevel.prefix(LogLevel.TRACE)); final LogService log = new TestableLogService(properties); Logger sub = log.subLogger("foo").subLogger("bar"); assertEquals(LogLevel.TRACE, sub.getLevel()); @@ -255,6 +275,7 @@ int getLevel() { } private interface LogMethodCall { + void run(LogService logService, Object text, Throwable exception); } diff --git a/src/test/java/org/scijava/log/LogSourceTest.java b/src/test/java/org/scijava/log/LogSourceTest.java index e6d7883a7..45df70ba7 100644 --- a/src/test/java/org/scijava/log/LogSourceTest.java +++ b/src/test/java/org/scijava/log/LogSourceTest.java @@ -6,13 +6,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 @@ -75,7 +75,8 @@ public void testLogSourceParse() { @Test public void testToString() { - LogSource source = LogSource.newRoot().subSource("Hello").subSource("World"); + LogSource source = LogSource.newRoot().subSource("Hello").subSource( + "World"); String result = source.toString(); assertEquals("Hello:World", result); } @@ -89,7 +90,8 @@ public void testRootToString() { @Test public void testName() { - LogSource source = LogSource.newRoot().subSource("Hello").subSource("World"); + LogSource source = LogSource.newRoot().subSource("Hello").subSource( + "World"); assertEquals("World", source.name()); } diff --git a/src/test/java/org/scijava/log/StderrLogServiceTest.java b/src/test/java/org/scijava/log/StderrLogServiceTest.java index 42db64727..4e6f6995c 100644 --- a/src/test/java/org/scijava/log/StderrLogServiceTest.java +++ b/src/test/java/org/scijava/log/StderrLogServiceTest.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * Tests {@link StderrLogService}. - * + * * @author Johannes Schindelin * @author Matthias Arzt */ diff --git a/src/test/java/org/scijava/log/TestLogListener.java b/src/test/java/org/scijava/log/TestLogListener.java index 94ed38813..30af5348d 100644 --- a/src/test/java/org/scijava/log/TestLogListener.java +++ b/src/test/java/org/scijava/log/TestLogListener.java @@ -6,13 +6,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/test/java/org/scijava/main/MainServiceTest.java b/src/test/java/org/scijava/main/MainServiceTest.java index e87501a7b..b33fbcb3f 100644 --- a/src/test/java/org/scijava/main/MainServiceTest.java +++ b/src/test/java/org/scijava/main/MainServiceTest.java @@ -6,13 +6,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 @@ -91,9 +91,9 @@ public void testConsoleArgs() { 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()); + 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()); + assertArrayEquals(new String[] { "7", "-", "4" }, m[1].args()); final int mainCount = mainService.execMains(); assertEquals(2, mainCount); @@ -113,7 +113,9 @@ private static String key(final int 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) { diff --git a/src/test/java/org/scijava/main/run/MainCodeRunnerTest.java b/src/test/java/org/scijava/main/run/MainCodeRunnerTest.java index 20c0997fe..db8f669a1 100644 --- a/src/test/java/org/scijava/main/run/MainCodeRunnerTest.java +++ b/src/test/java/org/scijava/main/run/MainCodeRunnerTest.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ /** * Tests {@link MainCodeRunner}. - * + * * @author Curtis Rueden */ public class MainCodeRunnerTest { diff --git a/src/test/java/org/scijava/menu/MenuServiceTest.java b/src/test/java/org/scijava/menu/MenuServiceTest.java index a3b2f203f..759da5aba 100644 --- a/src/test/java/org/scijava/menu/MenuServiceTest.java +++ b/src/test/java/org/scijava/menu/MenuServiceTest.java @@ -6,13 +6,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/test/java/org/scijava/menu/ShadowMenuTest.java b/src/test/java/org/scijava/menu/ShadowMenuTest.java index 5eb75a2cb..903bf7564 100644 --- a/src/test/java/org/scijava/menu/ShadowMenuTest.java +++ b/src/test/java/org/scijava/menu/ShadowMenuTest.java @@ -6,13 +6,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 @@ -46,7 +46,7 @@ /** * Tests {@link ShadowMenu}. - * + * * @author Curtis Rueden */ public class ShadowMenuTest { @@ -120,8 +120,8 @@ public void testGetMenu() { assertEquals(eFileNew, aFileNew2); final ShadowMenu eFileNewImage = eFileNew.getChildren().get(0); - final ShadowMenu aFileNewImage1 = - root.getMenu(new MenuPath("File>New>Image")); + final ShadowMenu aFileNewImage1 = root.getMenu(new MenuPath( + "File>New>Image")); assertEquals(eFileNewImage, aFileNewImage1); final ShadowMenu aFileNewImage2 = aFile.getMenu(new MenuPath("New>Image")); assertEquals(eFileNewImage, aFileNewImage2); @@ -177,8 +177,7 @@ private void checkStructure(final ShadowMenu root) { checkNode(fileExit, "Exit", 1, 1, 0); final ShadowMenu fileNew = fileChildren.get(1); - final List fileNewChildren = - checkNode(fileNew, "New", 2, 1, 2); + final List fileNewChildren = checkNode(fileNew, "New", 2, 1, 2); final ShadowMenu fileNewImage = fileNewChildren.get(0); checkNode(fileNewImage, "Image", 1, 2, 0); diff --git a/src/test/java/org/scijava/module/ModuleServiceTest.java b/src/test/java/org/scijava/module/ModuleServiceTest.java index cdaf44a84..cf01f52b4 100644 --- a/src/test/java/org/scijava/module/ModuleServiceTest.java +++ b/src/test/java/org/scijava/module/ModuleServiceTest.java @@ -6,13 +6,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 @@ -50,7 +50,7 @@ /** * Tests {@link ModuleService}. - * + * * @author Curtis Rueden */ public class ModuleServiceTest { @@ -59,7 +59,8 @@ public class ModuleServiceTest { @Before public void setUp() { - final Context context = new Context(ModuleService.class, ParseService.class); + final Context context = new Context(ModuleService.class, + ParseService.class); moduleService = context.service(ModuleService.class); } @@ -142,24 +143,24 @@ public void testGetSingleInput() throws ModuleException { final Module module = info.createModule(); // verify single string input is detected - final ModuleItem singleString = - moduleService.getSingleInput(module, String.class); + final ModuleItem singleString = moduleService.getSingleInput(module, + String.class); assertSame(info.getInput("string"), singleString); // check that non-autofilled inputs are not detected - final ModuleItem singleFloat = - moduleService.getSingleInput(module, Float.class); + final ModuleItem singleFloat = moduleService.getSingleInput(module, + Float.class); assertNull(singleFloat); // verify that multiple inputs of the same type are not detected - final ModuleItem singleInteger = - moduleService.getSingleInput(module, Integer.class); + final ModuleItem singleInteger = moduleService.getSingleInput( + module, Integer.class); assertNull(singleInteger); // verify that single input is detected if there are // non-autofilled inputs of the same kind too - final ModuleItem singleDouble = - moduleService.getSingleInput(module, Double.class); + final ModuleItem singleDouble = moduleService.getSingleInput(module, + Double.class); assertSame(info.getInput("double2"), singleDouble); } diff --git a/src/test/java/org/scijava/module/event/ModuleErroredEventTest.java b/src/test/java/org/scijava/module/event/ModuleErroredEventTest.java index def867107..4fe8e2f09 100644 --- a/src/test/java/org/scijava/module/event/ModuleErroredEventTest.java +++ b/src/test/java/org/scijava/module/event/ModuleErroredEventTest.java @@ -6,13 +6,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/test/java/org/scijava/module/process/LoggerPreprocessorTest.java b/src/test/java/org/scijava/module/process/LoggerPreprocessorTest.java index 7698f30b9..23a709cdc 100644 --- a/src/test/java/org/scijava/module/process/LoggerPreprocessorTest.java +++ b/src/test/java/org/scijava/module/process/LoggerPreprocessorTest.java @@ -6,13 +6,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 @@ -61,7 +61,8 @@ public void testInjection() throws InterruptedException, ExecutionException { context.service(LogService.class).addLogListener(listener); commandService.run(CommandWithLogger.class, true).get(); - assertTrue(listener.hasLogged(m -> m.source().path().contains(CommandWithLogger.class.getSimpleName()))); + assertTrue(listener.hasLogged(m -> m.source().path().contains( + CommandWithLogger.class.getSimpleName()))); } /** Tests redirection of a command's log output. */ @@ -95,7 +96,9 @@ public void run() { } @Test - public void testLoggerNameByAnnotation() throws ExecutionException, InterruptedException { + public void testLoggerNameByAnnotation() throws ExecutionException, + InterruptedException + { final Context context = new Context(CommandService.class); final CommandService commandService = context.service(CommandService.class); commandService.run(CommandWithNamedLogger.class, true).get(); diff --git a/src/test/java/org/scijava/module/run/ModuleCodeRunnerTest.java b/src/test/java/org/scijava/module/run/ModuleCodeRunnerTest.java index 719ed815f..ae77bc9f6 100644 --- a/src/test/java/org/scijava/module/run/ModuleCodeRunnerTest.java +++ b/src/test/java/org/scijava/module/run/ModuleCodeRunnerTest.java @@ -6,13 +6,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 @@ -49,7 +49,7 @@ /** * Tests {@link ModuleCodeRunner}. - * + * * @author Curtis Rueden */ public class ModuleCodeRunnerTest { @@ -101,7 +101,9 @@ public void testSupports() { public static class AlphabetModule extends DefaultMutableModule { @Override - public AlphabetModuleInfo getInfo() { return new AlphabetModuleInfo(); } + public AlphabetModuleInfo getInfo() { + return new AlphabetModuleInfo(); + } @Override public void run() { @@ -122,12 +124,10 @@ 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); + new DefaultMutableModuleItem<>(this, "buffer", StringBuilder.class); bufferItem.setIOType(ItemIO.BOTH); addInput(bufferItem); - addInput(new DefaultMutableModuleItem<>(this, "length", - int.class)); + addInput(new DefaultMutableModuleItem<>(this, "length", int.class)); } } diff --git a/src/test/java/org/scijava/object/NamedObjectIndexTest.java b/src/test/java/org/scijava/object/NamedObjectIndexTest.java index 7ceef8e27..b456d9415 100644 --- a/src/test/java/org/scijava/object/NamedObjectIndexTest.java +++ b/src/test/java/org/scijava/object/NamedObjectIndexTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.object; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/org/scijava/object/ObjectIndexTest.java b/src/test/java/org/scijava/object/ObjectIndexTest.java index 95f0c9dc8..ca8e50334 100644 --- a/src/test/java/org/scijava/object/ObjectIndexTest.java +++ b/src/test/java/org/scijava/object/ObjectIndexTest.java @@ -6,13 +6,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 @@ -44,15 +44,14 @@ /** * Tests {@link ObjectIndex}. - * + * * @author Curtis Rueden */ public class ObjectIndexTest { @Test public void testGetAll() { - final ObjectIndex objectIndex = - new ObjectIndex<>(Object.class); + final ObjectIndex objectIndex = new ObjectIndex<>(Object.class); final Object o1 = new Integer(5); final Object o2 = new Float(2.5f); final Object o3 = new Integer(3); @@ -68,8 +67,7 @@ public void testGetAll() { @Test public void testGet() { - final ObjectIndex objectIndex = - new ObjectIndex<>(Object.class); + final ObjectIndex objectIndex = new ObjectIndex<>(Object.class); final Object o1 = new Integer(5); final Object o2 = new Float(2.5f); final Object o3 = new Integer(3); @@ -89,8 +87,7 @@ public void testGet() { @Test public void testIsEmpty() { - final ObjectIndex objectIndex = - new ObjectIndex<>(Object.class); + final ObjectIndex objectIndex = new ObjectIndex<>(Object.class); assertTrue(objectIndex.isEmpty()); final Object o1 = new Integer(5); objectIndex.add(o1); @@ -101,8 +98,7 @@ public void testIsEmpty() { @Test public void testContains() { - final ObjectIndex objectIndex = - new ObjectIndex<>(Object.class); + final ObjectIndex objectIndex = new ObjectIndex<>(Object.class); final Object o1 = new Integer(5); assertFalse(objectIndex.contains(o1)); objectIndex.add(o1); @@ -113,10 +109,9 @@ public void testContains() { @Test public void testIterator() { - final ObjectIndex objectIndex = - new ObjectIndex<>(Object.class); - final Object[] objects = - { new Integer(5), new Float(2.5f), new Integer(3) }; + final ObjectIndex objectIndex = new ObjectIndex<>(Object.class); + final Object[] objects = { new Integer(5), new Float(2.5f), new Integer( + 3) }; for (final Object o : objects) objectIndex.add(o); final Iterator iter = objectIndex.iterator(); @@ -130,10 +125,9 @@ public void testIterator() { @Test public void testToArray() { - final ObjectIndex objectIndex = - new ObjectIndex<>(Object.class); - final Object[] objects = - { new Integer(5), new Float(2.5f), new Integer(3) }; + final ObjectIndex objectIndex = new ObjectIndex<>(Object.class); + final Object[] objects = { new Integer(5), new Float(2.5f), new Integer( + 3) }; for (final Object o : objects) objectIndex.add(o); final Object[] result = objectIndex.toArray(); @@ -142,8 +136,7 @@ public void testToArray() { @Test public void testContainsAll() { - final ObjectIndex objectIndex = - new ObjectIndex<>(Object.class); + final ObjectIndex objectIndex = new ObjectIndex<>(Object.class); assertTrue(objectIndex.containsAll(new ArrayList<>())); final Object o1 = new Integer(5); final Object o2 = new Float(2.5f); @@ -161,8 +154,7 @@ public void testContainsAll() { @Test public void testAddAll() { - final ObjectIndex objectIndex = - new ObjectIndex<>(Object.class); + final ObjectIndex objectIndex = new ObjectIndex<>(Object.class); final ArrayList objects = new ArrayList<>(); objects.add(new Integer(5)); objects.add(new Float(2.5f)); @@ -174,8 +166,7 @@ public void testAddAll() { @Test public void testRemoveAll() { - final ObjectIndex objectIndex = - new ObjectIndex<>(Object.class); + final ObjectIndex objectIndex = new ObjectIndex<>(Object.class); final Object o1 = new Integer(5); final Object o2 = new Float(2.5f); final Object o3 = new Integer(3); @@ -193,8 +184,7 @@ public void testRemoveAll() { @Test public void testClear() { - final ObjectIndex objectIndex = - new ObjectIndex<>(Object.class); + final ObjectIndex objectIndex = new ObjectIndex<>(Object.class); objectIndex.clear(); assertTrue(objectIndex.isEmpty()); objectIndex.add(new Integer(5)); @@ -205,22 +195,18 @@ public void testClear() { @Test public void testToString() { - final ObjectIndex objectIndex = - new ObjectIndex<>(Object.class); + final ObjectIndex objectIndex = new ObjectIndex<>(Object.class); objectIndex.add(new Integer(5)); objectIndex.add(new Float(2.5f)); objectIndex.add(new Integer(3)); final List expected = new ArrayList<>(); - expected.addAll(Arrays.asList( - "java.io.Serializable: {5, 2.5, 3}", - "java.lang.Comparable: {5, 2.5, 3}", - "java.lang.Float: {2.5}", - "java.lang.Integer: {5, 3}", - "java.lang.Number: {5, 2.5, 3}", - "java.lang.Object: {5, 2.5, 3}" - )); - final String[] javaVersion = System.getProperty("java.version").split("\\."); + expected.addAll(Arrays.asList("java.io.Serializable: {5, 2.5, 3}", + "java.lang.Comparable: {5, 2.5, 3}", "java.lang.Float: {2.5}", + "java.lang.Integer: {5, 3}", "java.lang.Number: {5, 2.5, 3}", + "java.lang.Object: {5, 2.5, 3}")); + final String[] javaVersion = System.getProperty("java.version").split( + "\\."); final int majorVersion = Integer.parseInt(javaVersion[0]); if (majorVersion >= 12) { expected.add("java.lang.constant.Constable: {5, 2.5, 3}"); @@ -228,8 +214,8 @@ public void testToString() { } expected.add("org.scijava.object.ObjectIndex$All: {5, 2.5, 3}"); - final String[] actual = - objectIndex.toString().split(System.getProperty("line.separator")); + final String[] actual = objectIndex.toString().split(System.getProperty( + "line.separator")); assertArrayEquals(expected.toArray(), actual); } diff --git a/src/test/java/org/scijava/object/ObjectServiceTest.java b/src/test/java/org/scijava/object/ObjectServiceTest.java index c8f27051e..dcc03d039 100644 --- a/src/test/java/org/scijava/object/ObjectServiceTest.java +++ b/src/test/java/org/scijava/object/ObjectServiceTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.object; import static org.junit.Assert.assertEquals; @@ -62,33 +63,45 @@ public void testAddRemoveObjects() { String name1 = "Object 1"; Object obj2 = ""; Object obj3 = new Double(0.3); - PluginInfo obj4 = PluginInfo.create(TestPlugin.class, SciJavaPlugin.class); + PluginInfo obj4 = PluginInfo.create(TestPlugin.class, + SciJavaPlugin.class); obj4.setName("TestPlugin name"); objectService.addObject(obj1, name1); assertEquals("Name of object 1", name1, objectService.getName(obj1)); objectService.addObject(obj2); - assertEquals("Name of object 2", obj2.toString(), objectService.getName(obj2)); + assertEquals("Name of object 2", obj2.toString(), objectService.getName( + obj2)); objectService.addObject(obj3, null); - assertEquals("Name of object 3", obj3.toString(), objectService.getName(obj3)); + assertEquals("Name of object 3", obj3.toString(), objectService.getName( + obj3)); objectService.addObject(obj4); assertNotNull(objectService.getName(obj4)); - assertEquals("Name of object 4", obj4.getName(), objectService.getName(obj4)); + assertEquals("Name of object 4", obj4.getName(), objectService.getName( + obj4)); - assertTrue("Object 1 registered", objectService.getObjects(Object.class).contains(obj1)); - assertTrue("Object 2 registered", objectService.getObjects(Object.class).contains(obj2)); - assertTrue("Object 3 registered", objectService.getObjects(Object.class).contains(obj3)); - assertTrue("Object 4 registered", objectService.getObjects(Object.class).contains(obj4)); + assertTrue("Object 1 registered", objectService.getObjects(Object.class) + .contains(obj1)); + assertTrue("Object 2 registered", objectService.getObjects(Object.class) + .contains(obj2)); + assertTrue("Object 3 registered", objectService.getObjects(Object.class) + .contains(obj3)); + assertTrue("Object 4 registered", objectService.getObjects(Object.class) + .contains(obj4)); objectService.removeObject(obj1); objectService.removeObject(obj2); objectService.removeObject(obj3); objectService.removeObject(obj4); - assertFalse("Object 1 removed", objectService.getObjects(Object.class).contains(obj1)); - assertFalse("Object 2 removed", objectService.getObjects(Object.class).contains(obj2)); - assertFalse("Object 3 removed", objectService.getObjects(Object.class).contains(obj3)); - assertFalse("Object 4 removed", objectService.getObjects(Object.class).contains(obj4)); + assertFalse("Object 1 removed", objectService.getObjects(Object.class) + .contains(obj1)); + assertFalse("Object 2 removed", objectService.getObjects(Object.class) + .contains(obj2)); + assertFalse("Object 3 removed", objectService.getObjects(Object.class) + .contains(obj3)); + assertFalse("Object 4 removed", objectService.getObjects(Object.class) + .contains(obj4)); } @Test diff --git a/src/test/java/org/scijava/object/SortedObjectIndexTest.java b/src/test/java/org/scijava/object/SortedObjectIndexTest.java index 3a3c31e97..98c00af19 100644 --- a/src/test/java/org/scijava/object/SortedObjectIndexTest.java +++ b/src/test/java/org/scijava/object/SortedObjectIndexTest.java @@ -6,13 +6,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,15 +38,15 @@ /** * Tests {@link SortedObjectIndex}. - * + * * @author Curtis Rueden */ public class SortedObjectIndexTest { @Test public void testGetAllSorted() { - final SortedObjectIndex objectIndex = - new SortedObjectIndex<>(String.class); + final SortedObjectIndex objectIndex = new SortedObjectIndex<>( + String.class); final String o1 = "quick"; final String o2 = "brown"; final String o3 = "fox"; @@ -62,8 +62,8 @@ public void testGetAllSorted() { @Test public void testDuplicates() { - final SortedObjectIndex objectIndex = - new SortedObjectIndex<>(String.class); + final SortedObjectIndex objectIndex = 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 da1b4a51a..92ebe3ec7 100644 --- a/src/test/java/org/scijava/options/OptionsTest.java +++ b/src/test/java/org/scijava/options/OptionsTest.java @@ -6,13 +6,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 @@ -43,19 +43,19 @@ /** * Tests {@link OptionsService} and {@link OptionsPlugin}s. - * + * * @author Curtis Rueden */ public class OptionsTest { private OptionsService createOptionsService() { - final Context context = - new Context(PluginService.class, OptionsService.class); + final Context context = new Context(PluginService.class, + OptionsService.class); // add FooOptions to the list of available plugins final PluginService pluginService = context.getService(PluginService.class); - final PluginInfo info = - new PluginInfo<>(FooOptions.class, OptionsPlugin.class); + final PluginInfo info = new PluginInfo<>(FooOptions.class, + OptionsPlugin.class); pluginService.addPlugin(info); return context.getService(OptionsService.class); diff --git a/src/test/java/org/scijava/parse/ParseServiceTest.java b/src/test/java/org/scijava/parse/ParseServiceTest.java index ffe1ee60d..d8acb926b 100644 --- a/src/test/java/org/scijava/parse/ParseServiceTest.java +++ b/src/test/java/org/scijava/parse/ParseServiceTest.java @@ -6,13 +6,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/test/java/org/scijava/plugin/PluginFinderTest.java b/src/test/java/org/scijava/plugin/PluginFinderTest.java index 7c83b3b57..7d838c578 100644 --- a/src/test/java/org/scijava/plugin/PluginFinderTest.java +++ b/src/test/java/org/scijava/plugin/PluginFinderTest.java @@ -6,13 +6,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 @@ -37,7 +37,7 @@ /** * Tests {@link PluginFinder}. - * + * * @author Curtis Rueden */ public class PluginFinderTest { diff --git a/src/test/java/org/scijava/plugin/PluginIndexTest.java b/src/test/java/org/scijava/plugin/PluginIndexTest.java index 76a076493..f070d6797 100644 --- a/src/test/java/org/scijava/plugin/PluginIndexTest.java +++ b/src/test/java/org/scijava/plugin/PluginIndexTest.java @@ -6,13 +6,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 @@ -39,7 +39,7 @@ /** * Tests {@link PluginIndex}. - * + * * @author Curtis Rueden */ public class PluginIndexTest { @@ -56,20 +56,20 @@ public void testGetPluginsOfClass() { final PluginIndex pluginIndex = context.getPluginIndex(); // add a plugin to the index - final PluginInfo testPlugin = - new PluginInfo<>(FooBar.class.getName(), SciJavaPlugin.class); + final PluginInfo testPlugin = new PluginInfo<>(FooBar.class + .getName(), SciJavaPlugin.class); pluginIndex.add(testPlugin); // retrieve the plugin from the index, by class final PluginService pluginService = context.getService(PluginService.class); - final List> plugins = - pluginService.getPluginsOfClass(FooBar.class); + final List> plugins = pluginService + .getPluginsOfClass(FooBar.class); assertEquals(1, plugins.size()); assertSame(testPlugin, plugins.get(0)); - final PluginInfo plugin = - pluginService.getPlugin(FooBar.class); + final PluginInfo plugin = pluginService.getPlugin( + FooBar.class); assertSame(testPlugin, plugin); context.dispose(); @@ -88,14 +88,14 @@ public void testGetPluginsOfClassString() { // add a fake plugin to the index final String fakeClass = "foo.bar.FooBar"; - final PluginInfo testPlugin = - new PluginInfo<>(fakeClass, SciJavaPlugin.class); + final PluginInfo testPlugin = new PluginInfo<>(fakeClass, + SciJavaPlugin.class); pluginIndex.add(testPlugin); // retrieve the fake plugin from the index, by class name final PluginService pluginService = context.getService(PluginService.class); - final List> plugins = - pluginService.getPluginsOfClass(fakeClass); + final List> plugins = pluginService + .getPluginsOfClass(fakeClass); assertEquals(1, plugins.size()); assertSame(testPlugin, plugins.get(0)); diff --git a/src/test/java/org/scijava/plugin/PluginInfoTest.java b/src/test/java/org/scijava/plugin/PluginInfoTest.java index ae9098a0d..4fed9f99f 100644 --- a/src/test/java/org/scijava/plugin/PluginInfoTest.java +++ b/src/test/java/org/scijava/plugin/PluginInfoTest.java @@ -6,13 +6,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 @@ -47,7 +47,7 @@ /** * Tests {@link PluginInfo}. - * + * * @author Curtis Rueden */ public class PluginInfoTest { diff --git a/src/test/java/org/scijava/plugin/SingletonServiceTest.java b/src/test/java/org/scijava/plugin/SingletonServiceTest.java index 1ef3e82de..22b707bb3 100644 --- a/src/test/java/org/scijava/plugin/SingletonServiceTest.java +++ b/src/test/java/org/scijava/plugin/SingletonServiceTest.java @@ -6,13 +6,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/test/java/org/scijava/prefs/PrefServiceTest.java b/src/test/java/org/scijava/prefs/PrefServiceTest.java index 7a8535ed0..f2ba5fdf5 100644 --- a/src/test/java/org/scijava/prefs/PrefServiceTest.java +++ b/src/test/java/org/scijava/prefs/PrefServiceTest.java @@ -6,13 +6,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 @@ -46,7 +46,7 @@ /** * Tests {@link PrefService}. - * + * * @author Curtis Rueden */ public class PrefServiceTest { @@ -168,7 +168,8 @@ public void testList() { recentFiles.add("some/path2"); recentFiles.add("some/path3"); prefService.put(getClass(), recentFilesName, recentFiles); - final List result = prefService.getList(getClass(), recentFilesName); + final List result = prefService.getList(getClass(), + recentFilesName); assertEquals(recentFiles, result); } diff --git a/src/test/java/org/scijava/run/RunServiceTest.java b/src/test/java/org/scijava/run/RunServiceTest.java index 71e2213d9..c3177c621 100644 --- a/src/test/java/org/scijava/run/RunServiceTest.java +++ b/src/test/java/org/scijava/run/RunServiceTest.java @@ -6,13 +6,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/test/java/org/scijava/script/AbstractScriptLanguageTest.java b/src/test/java/org/scijava/script/AbstractScriptLanguageTest.java index 8ad3ef941..6a7f1dc78 100644 --- a/src/test/java/org/scijava/script/AbstractScriptLanguageTest.java +++ b/src/test/java/org/scijava/script/AbstractScriptLanguageTest.java @@ -6,13 +6,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/test/java/org/scijava/script/ScriptEngineTest.java b/src/test/java/org/scijava/script/ScriptEngineTest.java index f8fac4dc9..cd36d43e7 100644 --- a/src/test/java/org/scijava/script/ScriptEngineTest.java +++ b/src/test/java/org/scijava/script/ScriptEngineTest.java @@ -6,13 +6,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 @@ -52,7 +52,7 @@ /** * Basic tests for the {@link ScriptService}. - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -85,9 +85,8 @@ public void testRot13() throws Exception { @Test public void testScriptModuleValue() throws Exception { - final ScriptModule module = - scriptService.run("test.rot13", ScriptModule.class.getName(), false, - (Map) null).get(); + final ScriptModule module = scriptService.run("test.rot13", + ScriptModule.class.getName(), false, (Map) null).get(); final ScriptModule scriptModule = Rot13Engine.latestModule; assertEquals(module, scriptModule); assertNotNull(scriptModule); @@ -168,19 +167,24 @@ public Object eval(Reader reader) throws ScriptException { } if (c >= 'A' && c <= 'Z') { c = 'Z' - c + 'A'; - } else if (c >= 'a' && c <= 'z') { + } + else if (c >= 'a' && c <= 'z') { c = 'z' - c + 'a'; } builder.append((char) c); } - } catch (final IOException e) { + } + catch (final IOException e) { throw new ScriptException(e); } return builder.toString(); } } - private static class Rot13Bindings extends HashMap implements Bindings { + private static class Rot13Bindings extends HashMap implements + Bindings + { + private static final long serialVersionUID = 1L; } } diff --git a/src/test/java/org/scijava/script/ScriptFinderTest.java b/src/test/java/org/scijava/script/ScriptFinderTest.java index 74fdc4583..686ba9f37 100644 --- a/src/test/java/org/scijava/script/ScriptFinderTest.java +++ b/src/test/java/org/scijava/script/ScriptFinderTest.java @@ -6,13 +6,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 @@ -53,7 +53,7 @@ /** * Tests the {@link ScriptFinder}. - * + * * @author Curtis Rueden */ public class ScriptFinderTest { @@ -192,8 +192,8 @@ public void testOverlappingDirectories() { private ScriptService createScriptService() { final Context context = new Context(ScriptService.class); final ScriptService scriptService = context.service(ScriptService.class); - final File defaultScriptsDir = - new File(AppUtils.getBaseDirectory(ScriptFinder.class), "scripts"); + final File defaultScriptsDir = new File(AppUtils.getBaseDirectory( + ScriptFinder.class), "scripts"); scriptService.removeScriptDirectory(defaultScriptsDir); return scriptService; } @@ -210,7 +210,7 @@ private void assertMenuPaths(final String[] expected, final ArrayList scripts) { assertEquals(expected.length, scripts.size()); - for (int i=0; i outputs = scriptModule.getOutputs(); assertEquals(1, outputs.size()); @@ -187,8 +185,8 @@ 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 ScriptModule scriptModule = scriptService.run( + "exclude-return-value.bsizes", script, true).get(); final Map outputs = scriptModule.getOutputs(); assertEquals(1, outputs.size()); @@ -206,8 +204,8 @@ public void testNoisyParameters() throws Exception { "% @LogService log\n" + // "% @OUTPUT Integer output" + // "% kraken@blah.net\n"; - final ScriptModule scriptModule = - scriptService.run("hello.bsizes", script, true).get(); + final ScriptModule scriptModule = scriptService.run("hello.bsizes", script, + true).get(); final Object output = scriptModule.getReturnValue(); @@ -259,8 +257,8 @@ public void testParameters() { "#@ String (visibility=MESSAGE) msg\n" + // "#@BOTH java.lang.StringBuilder buffer"; - final ScriptInfo info = - new ScriptInfo(context, "params.bsizes", new StringReader(script)); + final ScriptInfo info = new ScriptInfo(context, "params.bsizes", + new StringReader(script)); final List noChoices = Collections.emptyList(); @@ -270,14 +268,16 @@ 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.0, noChoices, sliderValue); - assertTrue("Case-insensitive trimmed style", WidgetStyle.isStyle(sliderValue, "slider")); + true, null, " slidEr,", 11, null, null, 5, 15, 3.0, noChoices, + sliderValue); + assertTrue("Case-insensitive trimmed style", WidgetStyle.isStyle( + sliderValue, "slider")); 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); + 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 notAutoFilled = info.getInput("notAutoFilled"); @@ -291,7 +291,8 @@ public void testParameters() { null, null, null, null, null, null, null, null, noChoices, buffer); int inputCount = 0; - final ModuleItem[] inputs = { log, sliderValue, animal, notAutoFilled, msg, buffer }; + final ModuleItem[] inputs = { log, sliderValue, animal, notAutoFilled, + msg, buffer }; for (final ModuleItem inItem : info.inputs()) { assertSame(inputs[inputCount++], inItem); } @@ -316,12 +317,11 @@ public void testScriptDirective() { ", priority = \"extremely-high\"" + // ", headless = true" + // ", foo = \"bar\"" + // - ")\n" + - "WOOT\n"; + ")\n" + "WOOT\n"; ScriptInfo info = null; - info = - new ScriptInfo(context, "scriptHeader.bsizes", new StringReader(script)); + info = new ScriptInfo(context, "scriptHeader.bsizes", new StringReader( + script)); info.inputs(); // HACK: Force lazy initialization. assertEquals("my_script", info.getName()); @@ -347,12 +347,13 @@ public void testReaderSanity() throws Exception { "% @LogService log\n" + // "% @OUTPUT Integer output"; - final ScriptInfo info = - new ScriptInfo(context, "hello.bsizes", new StringReader(script)); + 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()); } // -- Helper methods -- diff --git a/src/test/java/org/scijava/script/ScriptServiceTest.java b/src/test/java/org/scijava/script/ScriptServiceTest.java index 404550f5d..7b8476dcd 100644 --- a/src/test/java/org/scijava/script/ScriptServiceTest.java +++ b/src/test/java/org/scijava/script/ScriptServiceTest.java @@ -6,13 +6,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 @@ -48,7 +48,7 @@ /** * Tests the {@link DefaultScriptService}. - * + * * @author Curtis Rueden */ public class ScriptServiceTest { diff --git a/src/test/java/org/scijava/script/process/ParameterScriptProcessorTest.java b/src/test/java/org/scijava/script/process/ParameterScriptProcessorTest.java index 8e9c5b653..0e44ea431 100644 --- a/src/test/java/org/scijava/script/process/ParameterScriptProcessorTest.java +++ b/src/test/java/org/scijava/script/process/ParameterScriptProcessorTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.script.process; import static org.junit.Assert.*; @@ -55,24 +56,28 @@ public void tearDown() { @Test public void testScriptParameterParsing() { String script = "" + // - "% @String legacyStyleParameter\n" + - "% #@ String commentedHeaderParameter\n" + - "% ############## Some Comment ###########\n" + - "#@ String implicitInputParameter\n" + - "#@input String explicitInputParameter\n" + - "\n" + - "% @String legacyStyleBodyParameter\n" + - "% #@ String commentedBodyParameter\n" + - "\n" + - "#@output implicitlyTypedOutputParameter\n" + - "#@output String explicitlyTypedOutputParameter\n"; - final ScriptInfo info = new ScriptInfo(context, ".bsizes", new StringReader(script)); - assertEquals("legacyStyleParameter", info.getInput("legacyStyleParameter").getName()); - assertEquals("implicitInputParameter", info.getInput("implicitInputParameter").getName()); - assertEquals("explicitInputParameter", info.getInput("explicitInputParameter").getName()); + "% @String legacyStyleParameter\n" + + "% #@ String commentedHeaderParameter\n" + + "% ############## Some Comment ###########\n" + + "#@ String implicitInputParameter\n" + + "#@input String explicitInputParameter\n" + "\n" + + "% @String legacyStyleBodyParameter\n" + + "% #@ String commentedBodyParameter\n" + "\n" + + "#@output implicitlyTypedOutputParameter\n" + + "#@output String explicitlyTypedOutputParameter\n"; + final ScriptInfo info = new ScriptInfo(context, ".bsizes", new StringReader( + script)); + assertEquals("legacyStyleParameter", info.getInput("legacyStyleParameter") + .getName()); + assertEquals("implicitInputParameter", info.getInput( + "implicitInputParameter").getName()); + assertEquals("explicitInputParameter", info.getInput( + "explicitInputParameter").getName()); - assertEquals("implicitlyTypedOutputParameter", info.getOutput("implicitlyTypedOutputParameter").getName()); - assertEquals("explicitlyTypedOutputParameter", info.getOutput("explicitlyTypedOutputParameter").getName()); + assertEquals("implicitlyTypedOutputParameter", info.getOutput( + "implicitlyTypedOutputParameter").getName()); + assertEquals("explicitlyTypedOutputParameter", info.getOutput( + "explicitlyTypedOutputParameter").getName()); assertNull(info.getInput("commentedHeaderParameter")); assertNull(info.getInput("legacyStyleBodyParameter")); diff --git a/src/test/java/org/scijava/service/ServiceIndexTest.java b/src/test/java/org/scijava/service/ServiceIndexTest.java index ea3f6cc8c..f2f4819a5 100644 --- a/src/test/java/org/scijava/service/ServiceIndexTest.java +++ b/src/test/java/org/scijava/service/ServiceIndexTest.java @@ -6,13 +6,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 @@ -48,7 +48,7 @@ /** * Tests {@link ServiceIndex}. - * + * * @author Curtis Rueden */ public class ServiceIndexTest { @@ -86,7 +86,8 @@ public void testGetPrevService() { // HigherOptionsService > DefaultOptionsService > LowerOptionsService final ServiceIndex serviceIndex = setUpPrivateServices(context); - // DefaultOptionsService should be the previous service to LowerOptionsService + // DefaultOptionsService should be the previous service to + // LowerOptionsService assertEquals(DefaultOptionsService.class, serviceIndex.getPrevService( OptionsService.class, LowerOptionsService.class).getClass()); diff --git a/src/test/java/org/scijava/task/TaskEventTest.java b/src/test/java/org/scijava/task/TaskEventTest.java index 82d98f85f..d52f38ee8 100644 --- a/src/test/java/org/scijava/task/TaskEventTest.java +++ b/src/test/java/org/scijava/task/TaskEventTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.task; import org.junit.After; @@ -41,99 +42,100 @@ import static org.junit.Assert.assertEquals; /** - * Tests whether many tasks run in parallel consistently trigger an Event - * when each task is started and when each task is ended. - * - * The test fails inconsistently, sometimes with a few tasks remaining, sometimes with almost all tasks remaining. + * Tests whether many tasks run in parallel consistently trigger an Event when + * each task is started and when each task is ended. The test fails + * inconsistently, sometimes with a few tasks remaining, sometimes with almost + * all tasks remaining. */ public class TaskEventTest { - private TaskService taskService; - private TaskEventListener eventListener; - - static int nTasks = 500; // Putting higher value can lead to issues because too many threads cannot be launched in parallel - - @Before - public void setUp() { - final Context ctx = new Context(TaskService.class); - taskService = ctx.service(TaskService.class); - eventListener = new TaskEventListener(); - ctx.inject(eventListener); - } - - @After - public void tearDown() { - taskService.context().dispose(); - } - - @Test - public void testManyTasks() throws InterruptedException { - for (int i=0;i { - try { - Thread.sleep(msBeforeStart); - - // Task started - task.setProgressMaximum(100); - - task.run(() -> { - int totalMs = 0; - while(totalMs tasks = new HashSet<>(); - - @EventHandler - private synchronized void onEvent(final TaskEvent evt) { - Task task = evt.getTask(); - if (task.isDone()) { - tasks.remove(task); - } else { - tasks.add(task); - } - } - - public synchronized Set getLeftOvers() { - return new HashSet<>(tasks); - } - } + private TaskService taskService; + private TaskEventListener eventListener; + + static int nTasks = 500; // Putting higher value can lead to issues because + // too many threads cannot be launched in parallel + + @Before + public void setUp() { + final Context ctx = new Context(TaskService.class); + taskService = ctx.service(TaskService.class); + eventListener = new TaskEventListener(); + ctx.inject(eventListener); + } + + @After + public void tearDown() { + taskService.context().dispose(); + } + + @Test + public void testManyTasks() throws InterruptedException { + for (int i = 0; i < nTasks; i++) { + createTask(taskService, "Task_" + i, 100, 10, 100); + } + // Wait up to a few seconds for all tasks to complete. + long start = System.currentTimeMillis(); + long maxWaitTime = 5000; + while (System.currentTimeMillis() - start < maxWaitTime) { + if (eventListener.tasks.isEmpty()) break; // done! + Thread.sleep(10); + } + assertEquals(0, eventListener.getLeftOvers().size()); + } + + public static void createTask(TaskService taskService, String taskName, + int msBeforeStart, int msUpdate, int msTaskDuration) + { + Task task = taskService.createTask(taskName); + + new Thread(() -> { + try { + Thread.sleep(msBeforeStart); + + // Task started + task.setProgressMaximum(100); + + task.run(() -> { + int totalMs = 0; + while (totalMs < msTaskDuration) { + try { + Thread.sleep(msUpdate); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + totalMs += msUpdate; + task.setProgressValue((int) (((double) totalMs / msTaskDuration) * + 100.0)); + } + // Task ended + }); + + } + catch (InterruptedException e) { + e.printStackTrace(); + } + }).start(); + } + + public static class TaskEventListener { + + Set tasks = new HashSet<>(); + + @EventHandler + private synchronized void onEvent(final TaskEvent evt) { + Task task = evt.getTask(); + if (task.isDone()) { + tasks.remove(task); + } + else { + tasks.add(task); + } + } + + public synchronized Set getLeftOvers() { + return new HashSet<>(tasks); + } + } } diff --git a/src/test/java/org/scijava/task/TaskServiceTest.java b/src/test/java/org/scijava/task/TaskServiceTest.java index 00b320b0a..f380452a1 100644 --- a/src/test/java/org/scijava/task/TaskServiceTest.java +++ b/src/test/java/org/scijava/task/TaskServiceTest.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ /** * Tests {@link TaskService}. - * + * * @author Curtis Rueden */ public class TaskServiceTest { diff --git a/src/test/java/org/scijava/test/AbstractSciJavaTest.java b/src/test/java/org/scijava/test/AbstractSciJavaTest.java index 3b859e001..f5e9a2f85 100644 --- a/src/test/java/org/scijava/test/AbstractSciJavaTest.java +++ b/src/test/java/org/scijava/test/AbstractSciJavaTest.java @@ -6,13 +6,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 @@ -43,7 +43,7 @@ * DRY * principle, we should implement it only once. Here. *

      - * + * * @author Johannes Schindelin * @author Curtis Rueden */ diff --git a/src/test/java/org/scijava/test/TestUtilsTest.java b/src/test/java/org/scijava/test/TestUtilsTest.java index 69beb2bd2..effa986dd 100644 --- a/src/test/java/org/scijava/test/TestUtilsTest.java +++ b/src/test/java/org/scijava/test/TestUtilsTest.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ /** * Tests the {@link TestUtils}. - * + * * @author Johannes Schindelin */ public class TestUtilsTest { @@ -54,12 +54,12 @@ public void testCreateTemporaryDirectory() throws IOException { final File tmp2 = TestUtils.createTemporaryDirectory("test-utils-test-"); assertTrue(!tmp1.getAbsolutePath().equals(tmp2.getAbsolutePath())); - final File tmp3 = - TestUtils.createTemporaryDirectory("test-utils-test-", getClass()); + final File tmp3 = TestUtils.createTemporaryDirectory("test-utils-test-", + getClass()); assertTrue("Not in target/: " + tmp3.getAbsolutePath(), tmp3 .getAbsolutePath().replace('\\', '/').contains("/target/")); - final File tmp4 = - TestUtils.createTemporaryDirectory("test-utils-test-", getClass()); + final File tmp4 = TestUtils.createTemporaryDirectory("test-utils-test-", + getClass()); assertTrue(!tmp3.getAbsolutePath().equals(tmp4.getAbsolutePath())); } @@ -71,7 +71,8 @@ public void sameDirectoryTwice() throws IOException { final File tmp = TestUtils.createTemporaryDirectory("same-"); assertTrue(tmp != null); final String[] list = tmp.list(); - assertTrue("Not null: " + Arrays.toString(list), list == null || list.length == 0); + assertTrue("Not null: " + Arrays.toString(list), list == null || + list.length == 0); out[i] = new FileOutputStream(new File(tmp, "hello" + i + ".txt")); } for (final FileOutputStream stream : out) { diff --git a/src/test/java/org/scijava/text/TextServiceTest.java b/src/test/java/org/scijava/text/TextServiceTest.java index fd16a40f3..956b3a1f1 100644 --- a/src/test/java/org/scijava/text/TextServiceTest.java +++ b/src/test/java/org/scijava/text/TextServiceTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.text; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/org/scijava/thread/ThreadServiceTest.java b/src/test/java/org/scijava/thread/ThreadServiceTest.java index 29ce7b4dd..5510bf683 100644 --- a/src/test/java/org/scijava/thread/ThreadServiceTest.java +++ b/src/test/java/org/scijava/thread/ThreadServiceTest.java @@ -6,13 +6,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 @@ -45,7 +45,7 @@ /** * Tests the {@link ThreadService}. - * + * * @author Johannes Schindelin */ public class ThreadServiceTest { @@ -66,7 +66,8 @@ public void tearDown() { /** Tests {@link ThreadService#run(Callable)}. */ @Test - public void testRunCallable() throws InterruptedException, ExecutionException + public void testRunCallable() throws InterruptedException, + ExecutionException { final Thread result = threadService.run(new Callable() { @@ -80,7 +81,8 @@ public Thread call() { /** Tests {@link ThreadService#run(Runnable)}. */ @Test - public void testRunRunnable() throws InterruptedException, ExecutionException + public void testRunRunnable() throws InterruptedException, + ExecutionException { final Thread[] results = new Thread[1]; threadService.run(new Runnable() { diff --git a/src/test/java/org/scijava/ui/UIServiceTest.java b/src/test/java/org/scijava/ui/UIServiceTest.java index 9aba1641c..496d1f73d 100644 --- a/src/test/java/org/scijava/ui/UIServiceTest.java +++ b/src/test/java/org/scijava/ui/UIServiceTest.java @@ -6,13 +6,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 @@ -98,8 +98,8 @@ public void testHeadlessUI() { } else { // This environment is not headless! We can test more things. - assertSame("UIService default UI override failed", - mockUI, uiService.getDefaultUI()); + assertSame("UIService default UI override failed", mockUI, uiService + .getDefaultUI()); // This environment isn't headless now; // let's test overriding it to be so. @@ -111,8 +111,8 @@ public void testHeadlessUI() { // Now we put it back! uiService.setHeadless(false); assertFalse(uiService.isHeadless()); - assertSame("UIService default UI override was not restored", - mockUI, uiService.getDefaultUI()); + assertSame("UIService default UI override was not restored", mockUI, + uiService.getDefaultUI()); } } diff --git a/src/test/java/org/scijava/util/AppUtilsTest.java b/src/test/java/org/scijava/util/AppUtilsTest.java index a67e4b758..e65fa9394 100644 --- a/src/test/java/org/scijava/util/AppUtilsTest.java +++ b/src/test/java/org/scijava/util/AppUtilsTest.java @@ -6,13 +6,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,7 +38,7 @@ /** * Tests {@link AppUtils}. - * + * * @author Johannes Schindelin */ public class AppUtilsTest { @@ -48,12 +48,12 @@ public void testBaseDirectory() { assertNull(AppUtils.getBaseDirectory(new File( "/home/blub/.m2/repository/org/dscho/secret/1.0/secret-1.0.jar"), null)); final String tmp = PlatformUtils.isWindows() ? "c:/tmp" : "/tmp"; - assertEquals(new File(tmp), AppUtils.getBaseDirectory(new File( - tmp + "/app/target/classes"), "app")); - assertEquals(new File(tmp), AppUtils.getBaseDirectory(new File( - tmp + "/app/target/test-classes"), "app")); - assertEquals(new File(tmp), AppUtils.getBaseDirectory(new File( - tmp + "/app/target/ij-app-1.57.jar"), "app")); + assertEquals(new File(tmp), AppUtils.getBaseDirectory(new File(tmp + + "/app/target/classes"), "app")); + assertEquals(new File(tmp), AppUtils.getBaseDirectory(new File(tmp + + "/app/target/test-classes"), "app")); + assertEquals(new File(tmp), AppUtils.getBaseDirectory(new File(tmp + + "/app/target/ij-app-1.57.jar"), "app")); } } diff --git a/src/test/java/org/scijava/util/ArrayUtilsTest.java b/src/test/java/org/scijava/util/ArrayUtilsTest.java index 2ce778bb9..6d5696b57 100644 --- a/src/test/java/org/scijava/util/ArrayUtilsTest.java +++ b/src/test/java/org/scijava/util/ArrayUtilsTest.java @@ -6,13 +6,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 @@ -99,8 +99,8 @@ public void testSafeMultiply64() { // test edge cases near Long.MAX_VALUE assertSafeMultiply64Pass(9223372036854775806L, Long.MAX_VALUE / 6, 2, 3); assertSafeMultiply64Fail( - "Array size too large: 1537228672809129302 x 2 x 3", - Long.MAX_VALUE / 6 + 1, 2, 3); + "Array size too large: 1537228672809129302 x 2 x 3", Long.MAX_VALUE / 6 + + 1, 2, 3); assertSafeMultiply64Pass(9223372033963249500L, 3037000499L, 3037000500L); assertSafeMultiply64Fail("Array size too large: 3037000500 x 3037000500", 3037000500L, 3037000500L); @@ -110,8 +110,8 @@ public void testSafeMultiply64() { // -- Helper methods -- - private void - assertSafeMultiply32Pass(final int expected, final long... sizes) + private void assertSafeMultiply32Pass(final int expected, + final long... sizes) { assertEquals(expected, ArrayUtils.safeMultiply32(sizes)); } diff --git a/src/test/java/org/scijava/util/BoolArrayTest.java b/src/test/java/org/scijava/util/BoolArrayTest.java index 9b8239e68..f78ee3f23 100644 --- a/src/test/java/org/scijava/util/BoolArrayTest.java +++ b/src/test/java/org/scijava/util/BoolArrayTest.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ /** * Tests {@link BoolArray}. - * + * * @author Mark Hiner * @author Curtis Rueden * @author Johannes Schindelin diff --git a/src/test/java/org/scijava/util/ByteArrayTest.java b/src/test/java/org/scijava/util/ByteArrayTest.java index 0e8108951..27eda29aa 100644 --- a/src/test/java/org/scijava/util/ByteArrayTest.java +++ b/src/test/java/org/scijava/util/ByteArrayTest.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ /** * Tests {@link ByteArray}. - * + * * @author Curtis Rueden * @author Johannes Schindelin */ @@ -215,8 +215,7 @@ public void testContains() { } /** - * Tests {@link ByteArray#getArray()} and - * {@link ByteArray#setArray(byte[])}. + * Tests {@link ByteArray#getArray()} and {@link ByteArray#setArray(byte[])}. */ @Test public void testSetArray() { diff --git a/src/test/java/org/scijava/util/CharArrayTest.java b/src/test/java/org/scijava/util/CharArrayTest.java index 9d4403e75..fe91e8ce5 100644 --- a/src/test/java/org/scijava/util/CharArrayTest.java +++ b/src/test/java/org/scijava/util/CharArrayTest.java @@ -6,13 +6,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 @@ -42,7 +42,7 @@ /** * Tests {@link CharArray}. - * + * * @author Mark Hiner * @author Curtis Rueden * @author Johannes Schindelin @@ -217,8 +217,7 @@ public void testContains() { } /** - * Tests {@link CharArray#getArray()} and - * {@link CharArray#setArray(char[])}. + * Tests {@link CharArray#getArray()} and {@link CharArray#setArray(char[])}. */ @Test public void testSetArray() { diff --git a/src/test/java/org/scijava/util/ClassUtilsTest.java b/src/test/java/org/scijava/util/ClassUtilsTest.java index 1e3f809d4..118527fac 100644 --- a/src/test/java/org/scijava/util/ClassUtilsTest.java +++ b/src/test/java/org/scijava/util/ClassUtilsTest.java @@ -6,13 +6,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 @@ -47,7 +47,7 @@ /** * Tests {@link ClassUtils}. - * + * * @author Johannes Schindelin * @author Curtis Rueden */ @@ -58,13 +58,13 @@ public void testUnpackedClass() throws IOException { final File tmpDir = createTemporaryDirectory("class-utils-test-"); final String path = getClass().getName().replace('.', '/') + ".class"; final File classFile = new File(tmpDir, path); - assertTrue(classFile.getParentFile().exists() || - classFile.getParentFile().mkdirs()); - copy(getClass().getResource("/" + path).openStream(), - new FileOutputStream(classFile), true); + assertTrue(classFile.getParentFile().exists() || classFile.getParentFile() + .mkdirs()); + copy(getClass().getResource("/" + path).openStream(), new FileOutputStream( + classFile), true); - final ClassLoader classLoader = - new URLClassLoader(new URL[] { tmpDir.toURI().toURL() }, null); + final ClassLoader classLoader = new URLClassLoader(new URL[] { tmpDir + .toURI().toURL() }, null); final URL location = ClassUtils.getLocation(getClass().getName(), classLoader); assertEquals(tmpDir, FileUtils.urlToFile(location)); @@ -80,9 +80,10 @@ public void testClassInJar() throws IOException { out.putNextEntry(new ZipEntry(path)); copy(getClass().getResource("/" + path).openStream(), out, true); - final ClassLoader classLoader = - new URLClassLoader(new URL[] { jar.toURI().toURL() }, null); - final URL location = ClassUtils.getLocation(getClass().getName(), classLoader); + final ClassLoader classLoader = new URLClassLoader(new URL[] { jar.toURI() + .toURL() }, null); + final URL location = ClassUtils.getLocation(getClass().getName(), + classLoader); assertEquals(jar, FileUtils.urlToFile(location)); jar.deleteOnExit(); } @@ -91,7 +92,7 @@ public void testClassInJar() throws IOException { /** * Copies bytes from an {@link InputStream} to an {@link OutputStream}. - * + * * @param in the source * @param out the sink * @param closeOut whether to close the sink after we're done diff --git a/src/test/java/org/scijava/util/ColorRGBTest.java b/src/test/java/org/scijava/util/ColorRGBTest.java index 8f5225b58..37a0316c7 100644 --- a/src/test/java/org/scijava/util/ColorRGBTest.java +++ b/src/test/java/org/scijava/util/ColorRGBTest.java @@ -6,13 +6,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,7 +38,7 @@ /** * Tests {@link ColorRGB}. - * + * * @author Lee Kamentsky */ public class ColorRGBTest { @@ -84,8 +84,8 @@ public void testGetAlpha() { @Test public void testGetARGB() { - assertEquals(255 * 256 * 256 * 256 + 256 * 256 + 2 * 256 + 3, - new ColorRGB(1, 2, 3).getARGB()); + assertEquals(255 * 256 * 256 * 256 + 256 * 256 + 2 * 256 + 3, new ColorRGB( + 1, 2, 3).getARGB()); } @Test diff --git a/src/test/java/org/scijava/util/ConversionUtilsTest.java b/src/test/java/org/scijava/util/ConversionUtilsTest.java index f19b7f8e4..40e63db55 100644 --- a/src/test/java/org/scijava/util/ConversionUtilsTest.java +++ b/src/test/java/org/scijava/util/ConversionUtilsTest.java @@ -6,13 +6,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 @@ -46,7 +46,7 @@ /** * Tests {@link ConversionUtils}. - * + * * @author Mark Hiner * @author Curtis Rueden */ @@ -364,9 +364,11 @@ private void setFieldValue(final Object o, final String fieldName, * another. */ public static class HisList extends ArrayList { + public HisList() { super(); } + public HisList(final Collection c) { super(c); } @@ -377,6 +379,7 @@ public HisList(final Collection c) { * another. */ public static class HerList extends ArrayList { + public HerList(final Collection c) { super(c); } @@ -387,6 +390,7 @@ public HerList(final Collection c) { * another. */ public static class ObjectList extends ArrayList { + public ObjectList(final Collection c) { super(c); } @@ -399,17 +403,19 @@ public ObjectList(final Collection c) { public static class NumberList extends ArrayList implements INumberList { + public NumberList() { super(); } + public NumberList(final Collection c) { super(c); } } /** - * Helper interface for testing conversion of an {@link ArrayList} subclass - * to one of its implementing interfaces. + * Helper interface for testing conversion of an {@link ArrayList} subclass to + * one of its implementing interfaces. */ private static interface INumberList extends List { // NB: No implementation needed. diff --git a/src/test/java/org/scijava/util/DigestUtilsTest.java b/src/test/java/org/scijava/util/DigestUtilsTest.java index c9b37378b..b688ed17a 100644 --- a/src/test/java/org/scijava/util/DigestUtilsTest.java +++ b/src/test/java/org/scijava/util/DigestUtilsTest.java @@ -6,13 +6,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 @@ -44,11 +44,11 @@ public class DigestUtilsTest { private static final byte[] COFFEE_SHA1 = { -71, 2, 27, -126, -23, -70, -89, 35, -65, -15, -108, 66, 72, 113, 29, -32, -12, -42, -49, 6 }; - private static final byte[] COFFEE_MD5 = { -39, -98, 9, -40, -39, 44, 31, - -62, 23, 9, 38, 101, 85, -57, 121, -110 }; + private static final byte[] COFFEE_MD5 = { -39, -98, 9, -40, -39, 44, 31, -62, + 23, 9, 38, 101, 85, -57, 121, -110 }; - private static final byte[] HELLO_WORLD_SHA1 = { 123, 80, 44, 58, 31, 72, - -56, 96, -102, -30, 18, -51, -5, 99, -99, -18, 57, 103, 63, 94 }; + private static final byte[] HELLO_WORLD_SHA1 = { 123, 80, 44, 58, 31, 72, -56, + 96, -102, -30, 18, -51, -5, 99, -99, -18, 57, 103, 63, 94 }; private static final String HELLO_WORLD_SHA1_HEX = "7b502c3a1f48c8609ae212cdfb639dee39673f5e"; @@ -67,8 +67,8 @@ public class DigestUtilsTest { public void testBytesString() { final String s = "Hello world"; final byte[] bytes = DigestUtils.bytes(s); - final byte[] expected = - { 72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100 }; + final byte[] expected = { 72, 101, 108, 108, 111, 32, 119, 111, 114, 108, + 100 }; assertArrayEquals(expected, bytes); } @@ -176,7 +176,8 @@ public void testBestHexBytes() { /** Tests {@link DigestUtils#bestBase64(String)}. */ @Test public void testBestBase64String() { - assertEquals(HELLO_WORLD_SHA1_BASE64, DigestUtils.bestBase64("Hello world")); + assertEquals(HELLO_WORLD_SHA1_BASE64, DigestUtils.bestBase64( + "Hello world")); } /** Tests {@link DigestUtils#bestBase64(byte[])}. */ diff --git a/src/test/java/org/scijava/util/DoubleArrayTest.java b/src/test/java/org/scijava/util/DoubleArrayTest.java index 385b8ee31..9dcda0be8 100644 --- a/src/test/java/org/scijava/util/DoubleArrayTest.java +++ b/src/test/java/org/scijava/util/DoubleArrayTest.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ /** * Tests {@link DoubleArray}. - * + * * @author Curtis Rueden * @author Johannes Schindelin */ diff --git a/src/test/java/org/scijava/util/FileUtilsTest.java b/src/test/java/org/scijava/util/FileUtilsTest.java index 0bbc6645e..5c4574d43 100644 --- a/src/test/java/org/scijava/util/FileUtilsTest.java +++ b/src/test/java/org/scijava/util/FileUtilsTest.java @@ -6,13 +6,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 @@ -53,7 +53,7 @@ /** * Tests {@link FileUtils}. - * + * * @author Curtis Rueden * @author Johannes Schindelin * @author Grant Harris @@ -89,7 +89,8 @@ public void testURLToFile() throws MalformedURLException { final String jqpublic; if (PlatformUtils.isWindows()) { jqpublic = "C:/Users/jqpublic/"; - } else { + } + else { jqpublic = "/Users/jqpublic/"; } @@ -102,8 +103,8 @@ public void testURLToFile() throws MalformedURLException { assertEqualsPath(filePath, fileFile.getPath()); // verify that file path with spaces works - final File spaceFileOriginal = - new File(jqpublic.replace("jqpublic", "Spaceman Spiff") + "stun/Blaster.class"); + final File spaceFileOriginal = new File(jqpublic.replace("jqpublic", + "Spaceman Spiff") + "stun/Blaster.class"); final URL spaceURL = spaceFileOriginal.toURI().toURL(); final File spaceFileResult = FileUtils.urlToFile(spaceURL); assertEqualsPath(spaceFileOriginal.getPath(), spaceFileResult.getPath()); @@ -113,11 +114,12 @@ public void testURLToFile() throws MalformedURLException { final String alphaHi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; final String numbers = "1234567890"; final String special = "_~!@#$%^&*()+`-="; - final File specialFileOriginal = new File(jqpublic.replace("jqpublic", alphaLo) + - alphaHi + "/" + numbers + "/" + special + "/foo/Bar.class"); + final File specialFileOriginal = new File(jqpublic.replace("jqpublic", + alphaLo) + alphaHi + "/" + numbers + "/" + special + "/foo/Bar.class"); final URL specialURL = specialFileOriginal.toURI().toURL(); final File specialFileResult = FileUtils.urlToFile(specialURL); - assertEqualsPath(specialFileOriginal.getPath(), specialFileResult.getPath()); + assertEqualsPath(specialFileOriginal.getPath(), specialFileResult + .getPath()); // verify that 'jar:' URL works final String jarPath = "/Users/jqpublic/foo/fubar.jar"; @@ -139,42 +141,40 @@ public void testURLToFile() throws MalformedURLException { @Test public void testShortenPath() { - assertEquals("C:\\Documents and Settings\\" - + "All Users\\Application Data\\Apple Computer\\...\\SC Info.txt", - FileUtils.shortenPath("C:\\Documents and Settings\\All Users" - + "\\Application Data\\Apple Computer\\iTunes\\SC Info\\SC Info.txt")); - assertEquals("C:\\Documents and Settings\\All Users\\Application Data\\" - + "Apple Computer\\iTunes\\...\\SC Info.txt", FileUtils.shortenPath( - "C:\\Documents and Settings\\All Users\\" - + "Application Data\\Apple Computer\\iTunes\\SC Info\\SC Info.txt", 5)); + assertEquals("C:\\Documents and Settings\\" + + "All Users\\Application Data\\Apple Computer\\...\\SC Info.txt", FileUtils + .shortenPath("C:\\Documents and Settings\\All Users" + + "\\Application Data\\Apple Computer\\iTunes\\SC Info\\SC Info.txt")); + assertEquals("C:\\Documents and Settings\\All Users\\Application Data\\" + + "Apple Computer\\iTunes\\...\\SC Info.txt", FileUtils.shortenPath( + "C:\\Documents and Settings\\All Users\\" + + "Application Data\\Apple Computer\\iTunes\\SC Info\\SC Info.txt", 5)); assertEquals("C:\\temp", FileUtils.shortenPath("C:\\temp")); - assertEquals("C:\\1\\2\\3\\4\\...\\test.txt", FileUtils - .shortenPath("C:\\1\\2\\3\\4\\5\\test.txt")); + assertEquals("C:\\1\\2\\3\\4\\...\\test.txt", FileUtils.shortenPath( + "C:\\1\\2\\3\\4\\5\\test.txt")); assertEquals("C:/1/2/test.txt", FileUtils.shortenPath("C:/1/2/test.txt")); - assertEquals("C:/1/2/3/4/.../test.txt", FileUtils - .shortenPath("C:/1/2/3/4/5/test.txt")); - assertEquals("\\\\server\\p1\\p2\\p3\\p4\\...\\p6", FileUtils - .shortenPath("\\\\server\\p1\\p2\\p3\\p4\\p5\\p6")); - assertEquals("\\\\server\\p1\\p2\\p3", FileUtils - .shortenPath("\\\\server\\p1\\p2\\p3")); + assertEquals("C:/1/2/3/4/.../test.txt", FileUtils.shortenPath( + "C:/1/2/3/4/5/test.txt")); + assertEquals("\\\\server\\p1\\p2\\p3\\p4\\...\\p6", FileUtils.shortenPath( + "\\\\server\\p1\\p2\\p3\\p4\\p5\\p6")); + assertEquals("\\\\server\\p1\\p2\\p3", FileUtils.shortenPath( + "\\\\server\\p1\\p2\\p3")); assertEquals("https://www.rgagnon.com/p1/p2/p3/.../pb.html", FileUtils .shortenPath("https://www.rgagnon.com/p1/p2/p3/p4/p5/pb.html")); } @Test public void testLimitPath() { - assertEquals("C:\\Doc...SC Info.txt", - FileUtils - .limitPath("C:\\Documents and Settings\\All Users\\" - + "Application Data\\Apple Computer\\iTunes\\SC Info\\SC Info.txt", - 20)); + assertEquals("C:\\Doc...SC Info.txt", FileUtils.limitPath( + "C:\\Documents and Settings\\All Users\\" + + "Application Data\\Apple Computer\\iTunes\\SC Info\\SC Info.txt", 20)); assertEquals("C:\\temp", FileUtils.limitPath("C:\\temp", 20)); assertEquals("C:\\1\\2\\3\\...test.txt", FileUtils.limitPath( "C:\\1\\2\\3\\4\\5\\test.txt", 20)); assertEquals("...testfile.txt", FileUtils.limitPath("C:/1/2/testfile.txt", 15)); - assertEquals("C:/1...test.txt", FileUtils.limitPath( - "C:/1/2/3/4/5/test.txt", 15)); + assertEquals("C:/1...test.txt", FileUtils.limitPath("C:/1/2/3/4/5/test.txt", + 15)); assertEquals("\\\\server\\p1\\p2\\...p6", FileUtils.limitPath( "\\\\server\\p1\\p2\\p3\\p4\\p5\\p6", 20)); assertEquals("https://www...pb.html", FileUtils.limitPath( @@ -192,10 +192,12 @@ public void testListContents() throws IOException, URISyntaxException { i++; } try { - Collection urls = FileUtils.listContents(nonExisting.toURI().toURL()); + Collection urls = FileUtils.listContents(nonExisting.toURI() + .toURL()); assertNotNull(urls); assertEquals(0, urls.size()); - } catch (MalformedURLException e) { + } + catch (MalformedURLException e) { e.printStackTrace(); } @@ -231,7 +233,8 @@ public void testListContents() throws IOException, URISyntaxException { jarOut.write("jumps over the lazy dog".getBytes()); jarOut.closeEntry(); jarOut.close(); - } finally { + } + finally { out.close(); } @@ -252,8 +255,8 @@ public void testListContents() throws IOException, URISyntaxException { // check listContents: recursive including directories final Collection setTF = FileUtils.listContents(url, true, false); final URL[] listTF = setTF.toArray(new URL[setTF.size()]); - assertArrayEquals( - new URL[] { subSubURL, helloURL, rockURL, foxURL, dogURL }, listTF); + assertArrayEquals(new URL[] { subSubURL, helloURL, rockURL, foxURL, + dogURL }, listTF); // check listContents: non-recursive without directories final Collection setFT = FileUtils.listContents(url, false, true); @@ -272,49 +275,80 @@ public void testListContents() throws IOException, URISyntaxException { private static void assertEqualsPath(final String a, final String b) { if (PlatformUtils.isWindows()) { assertEquals(a.replace('\\', '/'), b.replace('\\', '/')); - } else { + } + else { assertEquals(a, b); } } @Test public void testStripVersionFromFilename() { - assertEquals("jars/bio-formats.jar", FileUtils.stripFilenameVersion("jars/bio-formats-4.4-imagej-2.0.0-beta1.jar")); - assertEquals(FileUtils.stripFilenameVersion("jars/ij-data-2.0.0.1-beta1.jar"), FileUtils.stripFilenameVersion("jars/ij-data-2.0.0.1-SNAPSHOT.jar")); - assertEquals(FileUtils.stripFilenameVersion("jars/ij-1.44.jar"), FileUtils.stripFilenameVersion("jars/ij-1.46b.jar")); - assertEquals(FileUtils.stripFilenameVersion("jars/javassist.jar"), FileUtils.stripFilenameVersion("jars/javassist-3.9.0.GA.jar")); - assertEquals(FileUtils.stripFilenameVersion("jars/javassist.jar"), FileUtils.stripFilenameVersion("jars/javassist-3.16.1-GA.jar")); - assertEquals(FileUtils.stripFilenameVersion("jars/bsh.jar"), FileUtils.stripFilenameVersion("jars/bsh-2.0b4.jar")); - assertEquals(FileUtils.stripFilenameVersion("jars/mpicbg.jar"), FileUtils.stripFilenameVersion("jars/mpicbg-20111128.jar")); - assertEquals(FileUtils.stripFilenameVersion("jars/miglayout-swing.jar"), FileUtils.stripFilenameVersion("jars/miglayout-3.7.3.1-swing.jar")); + assertEquals("jars/bio-formats.jar", FileUtils.stripFilenameVersion( + "jars/bio-formats-4.4-imagej-2.0.0-beta1.jar")); + assertEquals(FileUtils.stripFilenameVersion( + "jars/ij-data-2.0.0.1-beta1.jar"), FileUtils.stripFilenameVersion( + "jars/ij-data-2.0.0.1-SNAPSHOT.jar")); + assertEquals(FileUtils.stripFilenameVersion("jars/ij-1.44.jar"), FileUtils + .stripFilenameVersion("jars/ij-1.46b.jar")); + assertEquals(FileUtils.stripFilenameVersion("jars/javassist.jar"), FileUtils + .stripFilenameVersion("jars/javassist-3.9.0.GA.jar")); + assertEquals(FileUtils.stripFilenameVersion("jars/javassist.jar"), FileUtils + .stripFilenameVersion("jars/javassist-3.16.1-GA.jar")); + assertEquals(FileUtils.stripFilenameVersion("jars/bsh.jar"), FileUtils + .stripFilenameVersion("jars/bsh-2.0b4.jar")); + assertEquals(FileUtils.stripFilenameVersion("jars/mpicbg.jar"), FileUtils + .stripFilenameVersion("jars/mpicbg-20111128.jar")); + assertEquals(FileUtils.stripFilenameVersion("jars/miglayout-swing.jar"), + FileUtils.stripFilenameVersion("jars/miglayout-3.7.3.1-swing.jar")); // Test that native binary .jars don't clash with their partner hook .jar - assertEquals("jars/ffmpeg-windows-x86.jar", FileUtils.stripFilenameVersion("jars/ffmpeg-2.6.1-0.11-windows-x86.jar")); - assertEquals("jars/ffmpeg-windows-x86_64.jar", FileUtils.stripFilenameVersion("jars/ffmpeg-2.6.1-0.11-windows-x86_64.jar")); - assertEquals("jars/ffmpeg-macosx-x86_64.jar", FileUtils.stripFilenameVersion("jars/ffmpeg-2.6.1-0.11-macosx-x86_64.jar")); - assertEquals("jars/ffmpeg-linux-x86_64.jar", FileUtils.stripFilenameVersion("jars/ffmpeg-2.6.1-0.11-linux-x86_64.jar")); - assertEquals("jars/ffmpeg-linux-x86.jar", FileUtils.stripFilenameVersion("jars/ffmpeg-2.6.1-0.11-linux-x86.jar")); - 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")); + assertEquals("jars/ffmpeg-windows-x86.jar", FileUtils.stripFilenameVersion( + "jars/ffmpeg-2.6.1-0.11-windows-x86.jar")); + assertEquals("jars/ffmpeg-windows-x86_64.jar", FileUtils + .stripFilenameVersion("jars/ffmpeg-2.6.1-0.11-windows-x86_64.jar")); + assertEquals("jars/ffmpeg-macosx-x86_64.jar", FileUtils + .stripFilenameVersion("jars/ffmpeg-2.6.1-0.11-macosx-x86_64.jar")); + assertEquals("jars/ffmpeg-linux-x86_64.jar", FileUtils.stripFilenameVersion( + "jars/ffmpeg-2.6.1-0.11-linux-x86_64.jar")); + assertEquals("jars/ffmpeg-linux-x86.jar", FileUtils.stripFilenameVersion( + "jars/ffmpeg-2.6.1-0.11-linux-x86.jar")); + 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")); + 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 jinput style of native binary .jars - assertEquals("jars/jinput-natives-all.jar", FileUtils.stripFilenameVersion("jars/jinput-2.0.9-natives-all.jar")); + assertEquals("jars/jinput-natives-all.jar", FileUtils.stripFilenameVersion( + "jars/jinput-2.0.9-natives-all.jar")); // Test that native-lib-loader is not misrecognized as a native classifier - assertEquals("jars/native-lib-loader.jar", FileUtils.stripFilenameVersion("jars/native-lib-loader-2.3.2.jar")); + assertEquals("jars/native-lib-loader.jar", FileUtils.stripFilenameVersion( + "jars/native-lib-loader-2.3.2.jar")); } @Test @@ -327,8 +361,8 @@ public void testGetAllVersions() throws IOException { writeEmptyFile(new File(tmp, withClassifier)); writeEmptyFile(new File(tmp, withoutClassifier)); - assertArrayEquals(new File[] { new File(tmp, withClassifier) }, - FileUtils.getAllVersions(tmp, withClassifier)); + assertArrayEquals(new File[] { new File(tmp, withClassifier) }, FileUtils + .getAllVersions(tmp, withClassifier)); assertArrayEquals(new File[] { new File(tmp, withoutClassifier) }, FileUtils.getAllVersions(tmp, withoutClassifier)); } @@ -337,7 +371,9 @@ public void testGetAllVersions() throws IOException { } } - private static void writeEmptyFile(final File file) throws FileNotFoundException, IOException { + private static void writeEmptyFile(final File file) + throws FileNotFoundException, IOException + { final OutputStream out = new FileOutputStream(file); out.flush(); out.close(); diff --git a/src/test/java/org/scijava/util/FloatArrayTest.java b/src/test/java/org/scijava/util/FloatArrayTest.java index 9a8516ac9..65d140bff 100644 --- a/src/test/java/org/scijava/util/FloatArrayTest.java +++ b/src/test/java/org/scijava/util/FloatArrayTest.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ /** * Tests {@link FloatArray}. - * + * * @author Curtis Rueden * @author Johannes Schindelin */ diff --git a/src/test/java/org/scijava/util/GenericArrayTypesTest.java b/src/test/java/org/scijava/util/GenericArrayTypesTest.java index 5c6e06e9d..c7dd0278c 100644 --- a/src/test/java/org/scijava/util/GenericArrayTypesTest.java +++ b/src/test/java/org/scijava/util/GenericArrayTypesTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.util; import static org.junit.Assert.assertEquals; @@ -45,12 +46,16 @@ public class GenericArrayTypesTest { @Test public void testArrayFields() throws NoSuchFieldException, SecurityException { Field rawField = Types.field(ClassWithFields.class, "rawListArray"); - Field genericWildcardField = Types.field(ClassWithFields.class, "wildcardListArray"); - Field genericTypedField = Types.field(ClassWithFields.class, "integerListArray"); + Field genericWildcardField = Types.field(ClassWithFields.class, + "wildcardListArray"); + Field genericTypedField = Types.field(ClassWithFields.class, + "integerListArray"); Type rawFieldType = Types.fieldType(rawField, ClassWithFields.class); - Type genericWildcardFieldType = Types.fieldType(genericWildcardField, ClassWithFields.class); - Type genericTypedFieldType = Types.fieldType(genericTypedField, ClassWithFields.class); + Type genericWildcardFieldType = Types.fieldType(genericWildcardField, + ClassWithFields.class); + Type genericTypedFieldType = Types.fieldType(genericTypedField, + ClassWithFields.class); // raw type assertFalse(rawFieldType instanceof GenericArrayType); @@ -61,7 +66,8 @@ public void testArrayFields() throws NoSuchFieldException, SecurityException { assertTrue(genericTypedFieldType instanceof GenericArrayType); assertEquals(rawField.getGenericType(), rawFieldType); - assertEquals(genericWildcardField.getGenericType(), genericWildcardFieldType); + assertEquals(genericWildcardField.getGenericType(), + genericWildcardFieldType); assertEquals(genericTypedField.getGenericType(), genericTypedFieldType); assertSame(List[].class, Types.raw(rawFieldType)); @@ -71,6 +77,7 @@ public void testArrayFields() throws NoSuchFieldException, SecurityException { @SuppressWarnings({ "rawtypes", "unused" }) private static class ClassWithFields { + public List[] rawListArray; public List[] wildcardListArray; public List[] integerListArray; diff --git a/src/test/java/org/scijava/util/IntArrayTest.java b/src/test/java/org/scijava/util/IntArrayTest.java index b28b46390..2213ccc0e 100644 --- a/src/test/java/org/scijava/util/IntArrayTest.java +++ b/src/test/java/org/scijava/util/IntArrayTest.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ /** * Tests {@link IntArray}. - * + * * @author Curtis Rueden * @author Johannes Schindelin */ @@ -215,8 +215,7 @@ public void testContains() { } /** - * Tests {@link IntArray#getArray()} and - * {@link IntArray#setArray(int[])}. + * Tests {@link IntArray#getArray()} and {@link IntArray#setArray(int[])}. */ @Test public void testSetArray() { diff --git a/src/test/java/org/scijava/util/LastRecentlyUsedTest.java b/src/test/java/org/scijava/util/LastRecentlyUsedTest.java index 10d11e427..b4c02effd 100644 --- a/src/test/java/org/scijava/util/LastRecentlyUsedTest.java +++ b/src/test/java/org/scijava/util/LastRecentlyUsedTest.java @@ -6,13 +6,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,7 +38,7 @@ /** * Tests the {@link LastRecentlyUsed} data structure. - * + * * @author Johannes Schindelin */ public class LastRecentlyUsedTest { diff --git a/src/test/java/org/scijava/util/LongArrayTest.java b/src/test/java/org/scijava/util/LongArrayTest.java index c0a384b7a..5873eddbc 100644 --- a/src/test/java/org/scijava/util/LongArrayTest.java +++ b/src/test/java/org/scijava/util/LongArrayTest.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ /** * Tests {@link LongArray}. - * + * * @author Curtis Rueden * @author Johannes Schindelin */ @@ -215,8 +215,7 @@ public void testContains() { } /** - * Tests {@link LongArray#getArray()} and - * {@link LongArray#setArray(long[])}. + * Tests {@link LongArray#getArray()} and {@link LongArray#setArray(long[])}. */ @Test public void testSetArray() { diff --git a/src/test/java/org/scijava/util/NumberUtilsTest.java b/src/test/java/org/scijava/util/NumberUtilsTest.java index 28cef6cea..8956a3075 100644 --- a/src/test/java/org/scijava/util/NumberUtilsTest.java +++ b/src/test/java/org/scijava/util/NumberUtilsTest.java @@ -6,13 +6,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/test/java/org/scijava/util/ObjectArrayTest.java b/src/test/java/org/scijava/util/ObjectArrayTest.java index 8bcdf73ee..120ed3aea 100644 --- a/src/test/java/org/scijava/util/ObjectArrayTest.java +++ b/src/test/java/org/scijava/util/ObjectArrayTest.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ /** * Tests {@link ObjectArray}. - * + * * @author Mark Hiner * @author Curtis Rueden * @author Johannes Schindelin @@ -60,8 +60,7 @@ public void testConstructorNoArgs() { @Test public void testConstructorSize() { final int size = 24; - final ObjectArray array = - new ObjectArray<>(Integer.class, size); + final ObjectArray array = new ObjectArray<>(Integer.class, size); assertEquals(size, array.size()); assertEquals(size, array.copyArray().length); } @@ -365,12 +364,12 @@ public void testContainsAll() { list.add(1); assertFalse(array.containsAll(list)); - final ObjectArray yes = - new ObjectArray<>(new Integer[] { 3, 8, 21 }); + final ObjectArray yes = new ObjectArray<>(new Integer[] { 3, 8, + 21 }); assertTrue(array.containsAll(yes)); - final ObjectArray no = - new ObjectArray<>(new Integer[] { 5, 13, 1 }); + final ObjectArray no = new ObjectArray<>(new Integer[] { 5, 13, + 1 }); assertFalse(array.containsAll(no)); } @@ -399,8 +398,8 @@ public void testAddAll() { public void testRemoveAll() { final Integer[] raw = { 3, 5, 8, 13, 21 }; final ObjectArray array = new ObjectArray<>(raw.clone()); - final ObjectArray toRemove = - new ObjectArray<>(new Integer[] { 3, 8, 21 }); + final ObjectArray toRemove = 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/POMTest.java b/src/test/java/org/scijava/util/POMTest.java index 2ca1ea072..275eeb398 100644 --- a/src/test/java/org/scijava/util/POMTest.java +++ b/src/test/java/org/scijava/util/POMTest.java @@ -6,13 +6,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 @@ -45,7 +45,7 @@ /** * Tests methods of {@link POM}. - * + * * @author Curtis Rueden */ public class POMTest { @@ -82,8 +82,8 @@ public void testCompareVersions() { } @Test - public void testAccessors() throws ParserConfigurationException, - SAXException, IOException + public void testAccessors() throws ParserConfigurationException, SAXException, + IOException { final POM pom = new POM(new File("pom.xml")); assertEquals("org.scijava", pom.getParentGroupId()); @@ -120,8 +120,8 @@ public void testAccessors() throws ParserConfigurationException, } @Test - public void testCdata() throws ParserConfigurationException, - SAXException, IOException + public void testCdata() throws ParserConfigurationException, SAXException, + IOException { final POM pom = new POM(new File("pom.xml")); assertEquals("repo", pom.cdata("//project/licenses/license/distribution")); @@ -130,12 +130,12 @@ public void testCdata() throws ParserConfigurationException, } @Test - public void testElements() throws ParserConfigurationException, - SAXException, IOException + public void testElements() throws ParserConfigurationException, SAXException, + IOException { final POM pom = new POM(new File("pom.xml")); - final ArrayList developers = - pom.elements("//project/developers/developer"); + final ArrayList developers = pom.elements( + "//project/developers/developer"); assertEquals(1, developers.size()); assertEquals("ctrueden", XML.cdata(developers.get(0), "id")); } diff --git a/src/test/java/org/scijava/util/PrimitiveArrayTest.java b/src/test/java/org/scijava/util/PrimitiveArrayTest.java index 64a74492b..861ccccfe 100644 --- a/src/test/java/org/scijava/util/PrimitiveArrayTest.java +++ b/src/test/java/org/scijava/util/PrimitiveArrayTest.java @@ -6,13 +6,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,7 +33,7 @@ /** * Abstract superclass for {@link PrimitiveArray}-based tests. - * + * * @author Curtis Rueden * @author Johannes Schindelin */ @@ -46,12 +46,12 @@ protected void testInsert(final PrimitiveArray array) { final Object e2 = array.get(2); final Object e3 = array.get(3); final Object eN = array.get(size - 1); - + array.insert(size, 3); assertEquals(size + 3, array.size()); assertEquals(e0, array.get(0)); assertEquals(eN, array.get(size - 1)); - + array.insert(3, 7); assertEquals(size + 10, array.size()); assertEquals(e0, array.get(0)); @@ -75,7 +75,7 @@ protected void testDelete(final PrimitiveArray array) { for (int i = 0; i < a.length - 2; i++) { assertEquals("@" + i, a[i], array.get(i)); } - + array.delete(0, 2); assertEquals(a.length - 4, array.size()); for (int i = 0; i < a.length - 4; i++) { diff --git a/src/test/java/org/scijava/util/ProcessUtilsTest.java b/src/test/java/org/scijava/util/ProcessUtilsTest.java index ce3346a2c..bd0d5cf9d 100644 --- a/src/test/java/org/scijava/util/ProcessUtilsTest.java +++ b/src/test/java/org/scijava/util/ProcessUtilsTest.java @@ -6,13 +6,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 @@ -40,7 +40,7 @@ /** * Tests {@link ProcessUtils}. - * + * * @author Johannes Schindelin */ public class ProcessUtilsTest { @@ -71,6 +71,7 @@ private void assumePOSIX() { /** A class executing a 'sleep' call, to be interrupted. */ private static class SleepThread extends Thread { + private int seconds; private Throwable result; @@ -82,7 +83,8 @@ public SleepThread(int seconds) { public void run() { try { ProcessUtils.exec(null, null, null, "sleep", "" + seconds); - } catch (Throwable t) { + } + catch (Throwable t) { result = t; } } diff --git a/src/test/java/org/scijava/util/PropertiesHelperTest.java b/src/test/java/org/scijava/util/PropertiesHelperTest.java index 3e3cc57fb..ffb451769 100644 --- a/src/test/java/org/scijava/util/PropertiesHelperTest.java +++ b/src/test/java/org/scijava/util/PropertiesHelperTest.java @@ -6,13 +6,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/test/java/org/scijava/util/ShortArrayTest.java b/src/test/java/org/scijava/util/ShortArrayTest.java index 005718285..500d7ffa3 100644 --- a/src/test/java/org/scijava/util/ShortArrayTest.java +++ b/src/test/java/org/scijava/util/ShortArrayTest.java @@ -6,13 +6,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 @@ -41,7 +41,7 @@ /** * Tests {@link ShortArray}. - * + * * @author Curtis Rueden * @author Johannes Schindelin */ diff --git a/src/test/java/org/scijava/util/StringUtilsTest.java b/src/test/java/org/scijava/util/StringUtilsTest.java index 95b0cd431..0428cbb63 100644 --- a/src/test/java/org/scijava/util/StringUtilsTest.java +++ b/src/test/java/org/scijava/util/StringUtilsTest.java @@ -6,13 +6,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 @@ -50,12 +50,8 @@ public class StringUtilsTest { public void testSplitUnquoted() { // See https://stackoverflow.com/a/1757107/1919049 final String line = "foo,bar,c;qual=\"baz,blurb\",d;junk=\"quux,syzygy\""; - final String[] expected = { - "foo", - "bar", - "c;qual=\"baz,blurb\"", - "d;junk=\"quux,syzygy\"" - }; + final String[] expected = { "foo", "bar", "c;qual=\"baz,blurb\"", + "d;junk=\"quux,syzygy\"" }; final String[] actual = StringUtils.splitUnquoted(line, ","); assertArrayEquals(expected, actual); } @@ -124,7 +120,8 @@ public void padEnd() throws Exception { assertEquals(newLength, padded.length()); final String padding = padded.substring(padded.length() - 5); - assertTrue(padding.chars().allMatch(c -> c == StringUtils.DEFAULT_PAD_CHAR)); + assertTrue(padding.chars().allMatch( + c -> c == StringUtils.DEFAULT_PAD_CHAR)); assertEquals(s, padded.substring(0, padded.length() - 5)); } @@ -181,7 +178,8 @@ public void padStart() throws Exception { assertEquals(newLength, padded.length()); final String padding = padded.substring(0, 5); - assertTrue(padding.chars().allMatch(c -> c == StringUtils.DEFAULT_PAD_CHAR)); + assertTrue(padding.chars().allMatch( + c -> c == StringUtils.DEFAULT_PAD_CHAR)); assertEquals(s, padded.substring(5, padded.length())); } } diff --git a/src/test/java/org/scijava/util/TypesTest.java b/src/test/java/org/scijava/util/TypesTest.java index d3529cb0c..d7ac6f9e3 100644 --- a/src/test/java/org/scijava/util/TypesTest.java +++ b/src/test/java/org/scijava/util/TypesTest.java @@ -6,13 +6,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 @@ -64,9 +64,10 @@ import org.junit.Test; import org.scijava.util.FileUtils; + /** * Tests {@link Types}. - * + * * @author Curtis Rueden * @author Mark Hiner * @author Johannes Schindelin @@ -152,13 +153,13 @@ public void testLocationUnpackedClass() throws IOException { final File tmpDir = createTemporaryDirectory("class-utils-test-"); final String path = getClass().getName().replace('.', '/') + ".class"; final File classFile = new File(tmpDir, path); - assertTrue(classFile.getParentFile().exists() || - classFile.getParentFile().mkdirs()); - copy(getClass().getResource("/" + path).openStream(), - new FileOutputStream(classFile), true); + assertTrue(classFile.getParentFile().exists() || classFile.getParentFile() + .mkdirs()); + copy(getClass().getResource("/" + path).openStream(), new FileOutputStream( + classFile), true); - final ClassLoader classLoader = - new URLClassLoader(new URL[] { tmpDir.toURI().toURL() }, null); + final ClassLoader classLoader = new URLClassLoader(new URL[] { tmpDir + .toURI().toURL() }, null); final Class c = Types.load(getClass().getName(), classLoader); final URL location = Types.location(c); assertEquals(tmpDir, FileUtils.urlToFile(location)); @@ -175,8 +176,8 @@ public void testLocationClassInJar() throws IOException { out.putNextEntry(new ZipEntry(path)); copy(getClass().getResource("/" + path).openStream(), out, true); - final ClassLoader classLoader = - new URLClassLoader(new URL[] { jar.toURI().toURL() }, null); + final ClassLoader classLoader = new URLClassLoader(new URL[] { jar.toURI() + .toURL() }, null); final Class c = Types.load(getClass().getName(), classLoader); final URL location = Types.location(c); assertEquals(jar, FileUtils.urlToFile(location)); @@ -240,7 +241,8 @@ public void testRaws() { final Field field = Types.field(Thing.class, "thing"); // Object - assertAllTheSame(Types.raws(Types.fieldType(field, Thing.class)), Object.class); + assertAllTheSame(Types.raws(Types.fieldType(field, Thing.class)), + Object.class); // N extends Number assertAllTheSame(Types.raws(Types.fieldType(field, NumberThing.class)), @@ -287,22 +289,22 @@ public void testBox() { final Class[] types = { // Boolean.class, Byte.class, Character.class, Double.class, // - Float.class, Integer.class, Long.class, Short.class, // - Void.class, // - String.class, // - Number.class, BigInteger.class, BigDecimal.class, // - 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, // - Void[].class, // - Object.class, Object[].class, String[].class, // - Object[][].class, String[][].class, // - Collection.class, // - List.class, ArrayList.class, LinkedList.class, // - Set.class, HashSet.class, // - Map.class, HashMap.class, // - Collection[].class, List[].class, Set[].class, Map[].class }; + Float.class, Integer.class, Long.class, Short.class, // + Void.class, // + String.class, // + Number.class, BigInteger.class, BigDecimal.class, // + 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, // + Void[].class, // + Object.class, Object[].class, String[].class, // + Object[][].class, String[][].class, // + Collection.class, // + List.class, ArrayList.class, LinkedList.class, // + Set.class, HashSet.class, // + Map.class, HashMap.class, // + Collection[].class, List[].class, Set[].class, Map[].class }; for (final Class c : types) { final Class type = Types.box(c); assertSame(c, type); @@ -415,7 +417,7 @@ public void testArray() { Types.array(void.class); fail("Unexpected success creating void[]"); } - catch (final IllegalArgumentException exc) { } + catch (final IllegalArgumentException exc) {} // multidimensional cases assertSame(Number[][].class, Types.array(Number.class, 2)); @@ -425,7 +427,7 @@ public void testArray() { Types.array(char.class, -1); fail("Unexpected success creating negative dimensional array"); } - catch (final IllegalArgumentException exc) { } + catch (final IllegalArgumentException exc) {} } /** Tests {@link Types#component(Type)}. */ @@ -676,7 +678,8 @@ private static class ComplexThing extends /** Enumeration for testing conversion to enum types. */ public static enum Words { - FOO("Foo"), BAR("Bar"), FUBAR("OMG"); + + FOO("Foo"), BAR("Bar"), FUBAR("OMG"); private final String label; @@ -691,10 +694,15 @@ public String toString() { } private interface TestTypes { + T t(); + List listT(); + List listNumber(); + List listInteger(); + List listExtendsNumber(); } @@ -702,7 +710,7 @@ private interface TestTypes { /** * Copies bytes from an {@link InputStream} to an {@link OutputStream}. - * + * * @param in the source * @param out the sink * @param closeOut whether to close the sink after we're done @@ -724,7 +732,7 @@ private void copy(final InputStream in, final OutputStream out, private Class loadCustomClass() { // NB: The bytecode below was compiled from the following source: // - // public class Hello {} + // public class Hello {} // final byte[] bytecode = { -54, -2, -70, -66, 0, 0, 0, 52, 0, 13, 10, 0, 3, 0, 10, 7, 0, 11, 7, 0, 12, 1, 0, 6, 60, 105, 110, 105, 116, 62, 1, 0, 3, @@ -738,6 +746,7 @@ private Class loadCustomClass() { 0, 1, 0, 0, 0, 1, 0, 1, 0, 8, 0, 0, 0, 2, 0, 9 }; class BytesClassLoader extends ClassLoader { + public Class load(final String name, final byte[] b) { return defineClass(name, b, 0, b.length); } diff --git a/src/test/java/org/scijava/util/UnitUtilsTest.java b/src/test/java/org/scijava/util/UnitUtilsTest.java index e253a0319..e496e6421 100644 --- a/src/test/java/org/scijava/util/UnitUtilsTest.java +++ b/src/test/java/org/scijava/util/UnitUtilsTest.java @@ -6,13 +6,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 @@ -35,7 +35,7 @@ /** * Tests {@link UnitUtils}. - * + * * @author Curtis Rueden */ public class UnitUtilsTest { @@ -74,8 +74,10 @@ public void testGetAbbreviatedByteLabel() { assertEquals(local(82.7, "YiB"), UnitUtils.getAbbreviatedByteLabel(1e26)); assertEquals(local(827.2, "YiB"), UnitUtils.getAbbreviatedByteLabel(1e27)); assertEquals(local(8271.8, "YiB"), UnitUtils.getAbbreviatedByteLabel(1e28)); - assertEquals(local(82718.1, "YiB"), UnitUtils.getAbbreviatedByteLabel(1e29)); - assertEquals(local(827180.6, "YiB"), UnitUtils.getAbbreviatedByteLabel(1e30)); + assertEquals(local(82718.1, "YiB"), UnitUtils.getAbbreviatedByteLabel( + 1e29)); + assertEquals(local(827180.6, "YiB"), UnitUtils.getAbbreviatedByteLabel( + 1e30)); } /** diff --git a/src/test/java/org/scijava/util/VersionUtilsTest.java b/src/test/java/org/scijava/util/VersionUtilsTest.java index f56be8426..8d55b3d25 100644 --- a/src/test/java/org/scijava/util/VersionUtilsTest.java +++ b/src/test/java/org/scijava/util/VersionUtilsTest.java @@ -6,13 +6,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 @@ -36,7 +36,7 @@ /** * Tests {@link VersionUtils}. - * + * * @author Curtis Rueden */ public class VersionUtilsTest { @@ -76,7 +76,7 @@ public void testCompare() { // Check non-numeric tokens. assertTrue(VersionUtils.compare("a.b.c", "a.b.d") < 0); - + // Check for numerical (not lexicographic) comparison. assertTrue(VersionUtils.compare("2.0", "23.0") < 0); assertTrue(VersionUtils.compare("23.0", "2.0") > 0); diff --git a/src/test/java/org/scijava/widget/WidgetStyleTest.java b/src/test/java/org/scijava/widget/WidgetStyleTest.java index 0043dba69..c4dde2461 100644 --- a/src/test/java/org/scijava/widget/WidgetStyleTest.java +++ b/src/test/java/org/scijava/widget/WidgetStyleTest.java @@ -6,13 +6,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 @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ + package org.scijava.widget; import static org.junit.Assert.assertArrayEquals; @@ -53,20 +54,22 @@ public class WidgetStyleTest { @RunWith(Parameterized.class) public static class TestIsStyle { - static String[] styleStrings = { "foo, bar, someThing", " FOO, BAR, SOMEthing ", "foo ", " bar", - "trash, sOmEtHiNg", null }; + static String[] styleStrings = { "foo, bar, someThing", + " FOO, BAR, SOMEthing ", "foo ", " bar", "trash, sOmEtHiNg", null }; static String[] stylesToTest = { "foo", "bar", "someThing", null }; static boolean[][] stylesToHave = { // foo, bar, someThing - new boolean[] { true, true, true, false }, new boolean[] { true, true, true, false }, - new boolean[] { true, false, false, false }, new boolean[] { false, true, false, false }, - new boolean[] { false, false, true, false }, new boolean[] { false, false, false, true } }; + new boolean[] { true, true, true, false }, new boolean[] { true, true, + true, false }, new boolean[] { true, false, false, false }, + new boolean[] { false, true, false, false }, new boolean[] { false, false, + true, false }, new boolean[] { false, false, false, true } }; @Parameters(name = "{0}") public static List params() { - return IntStream.range(0, styleStrings.length) - .mapToObj(i -> new Object[] { styleStrings[i], stylesToHave[i] }).collect(Collectors.toList()); + return IntStream.range(0, styleStrings.length).mapToObj( + i -> new Object[] { styleStrings[i], stylesToHave[i] }).collect( + Collectors.toList()); } @Parameter @@ -78,18 +81,21 @@ public static List params() { @Test public void testSimpleStyles() { for (int i = 0; i < stylesToTest.length; i++) { - assertEquals("style: " + stylesToTest[i], targetStyles[i], - WidgetStyle.isStyle(styleString, stylesToTest[i])); + assertEquals("style: " + stylesToTest[i], targetStyles[i], WidgetStyle + .isStyle(styleString, stylesToTest[i])); } } } public static class TestStyleModifiers { + @Test public void testStyleModifiers() { String style = "open, extensions:tiff/tif/jpeg/jpg"; - Set extensions = new HashSet<>(Arrays.asList(WidgetStyle.getStyleModifiers(style, "extensions"))); - Set expected = new HashSet<>(Arrays.asList("tiff", "jpg", "jpeg", "tif")); + Set extensions = new HashSet<>(Arrays.asList(WidgetStyle + .getStyleModifiers(style, "extensions"))); + Set expected = new HashSet<>(Arrays.asList("tiff", "jpg", "jpeg", + "tif")); assertEquals(expected, extensions); } }