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-SNAPSHOTSciJava CommonSciJava 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:
*
* 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); }
* 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.
*
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 extends MenuEntry> 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 extends Annotation> annotation =
(Class extends Annotation>) loader.loadClass(annotationName);
- for (IndexItem extends Annotation> item : Index
- .load(annotation, loader))
+ for (IndexItem extends Annotation> 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 extends TypeElement> 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 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
*/
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 extends Command> commandClass) {
@@ -143,7 +140,7 @@ public CommandInfo(final Class extends Command> 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 extends Command> 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 extends Display>> displayType =
(Class extends Display>>) 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 extends SciJavaEvent> 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 extends SciJavaEvent> getEventClass(final Method m) {
@SuppressWarnings("unchecked")
final Class extends SciJavaEvent> typedClass =
- (Class extends SciJavaEvent>) eventClass;
+ (Class extends SciJavaEvent>) eventClass;
return typedClass;
}
@@ -233,7 +234,7 @@ private Class extends SciJavaEvent> 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 extends SciJavaEvent> 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.
*
- * 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.
*
*
- *
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
+ *
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).
- *
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.
+ *
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).
- *