Skip to content

IOService recognizes a new 3rd state of loading data #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/main/java/org/scijava/io/IOService.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ default <D> IOPlugin<D> getSaver(D data, Location destination) {
return null;
}

/** A special type of "openned data" that can be returned by the
* {@link #open(String)} and {@link #open(Location)} methods, and
* that signals that data is opened outside the ImageJ2 data model.
* Example is the opening of BigDataViewer's .xml files, in which case
* no image is actually loaded into ImageJ2 per se, but an instance of
* the BigDataViewer over the .xml file is opened/started instead.
*/
Object GOVERNING_APP_STARTED = new Object();

/**
* Loads data from the given source. For extensibility, the nature of the
* source is left intentionally general, but two common examples include file
Expand All @@ -95,11 +104,16 @@ default <D> IOPlugin<D> getSaver(D data, Location destination) {
* The opener to use is automatically determined based on available
* {@link IOPlugin}s; see {@link #getOpener(String)}.
* </p>
* The opener may open the source in "external" application (e.g., in BigDataViewer)
* in which case it must return {@link #GOVERNING_APP_STARTED} object (and not the
* source data itself).
* </p>
*
* @param source The source (e.g., file path) from which to data should be
* loaded.
* @return An object representing the loaded data, or null if the source is
* not supported.
* @return An object representing the loaded data, or {@link #GOVERNING_APP_STARTED}
* object signalling that the source was loaded into an external application,
* or null if the source is not supported.
* @throws IOException if something goes wrong loading the data.
*/
Object open(String source) throws IOException;
Expand All @@ -110,10 +124,15 @@ default <D> IOPlugin<D> getSaver(D data, Location destination) {
* The opener to use is automatically determined based on available
* {@link IOPlugin}s; see {@link #getOpener(Location)}.
* </p>
* The opener may open the source in "external" application (e.g., in BigDataViewer)
* in which case it must return {@link #GOVERNING_APP_STARTED} object (and not the
* source data itself).
* </p>
*
* @param source The location from which to data should be loaded.
* @return An object representing the loaded data, or null if the source is
* not supported.
* @return An object representing the loaded data, or {@link #GOVERNING_APP_STARTED}
* object signalling that the source was loaded into an external application,
* or null if the source is not supported.
* @throws IOException if something goes wrong loading the data.
*/
default Object open(Location source) throws IOException {
Expand Down