Skip to content

Commit 632faa7

Browse files
committed
Update package structure of handles and locations
Each location / handle pair now lives in it's own package under org.scijava.io.location, which also contains all the abstract Location implementations.
1 parent ab26f94 commit 632faa7

29 files changed

+163
-22
lines changed

src/main/java/org/scijava/io/AbstractDataHandle.java renamed to src/main/java/org/scijava/io/location/AbstractDataHandle.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@
2929
* #L%
3030
*/
3131

32-
package org.scijava.io;
32+
package org.scijava.io.location;
3333

3434
import java.nio.ByteOrder;
3535

36+
import org.scijava.io.DataHandle;
37+
import org.scijava.io.Location;
3638
import org.scijava.plugin.AbstractWrapperPlugin;
3739

3840
/**
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* #%L
3+
* SciJava Common shared library for SciJava software.
4+
* %%
5+
* Copyright (C) 2009 - 2017 Board of Regents of the University of
6+
* Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
7+
* Institute of Molecular Cell Biology and Genetics.
8+
* %%
9+
* Redistribution and use in source and binary forms, with or without
10+
* modification, are permitted provided that the following conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice,
13+
* this list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
* POSSIBILITY OF SUCH DAMAGE.
29+
* #L%
30+
*/
31+
32+
package org.scijava.io.location;
33+
34+
import java.util.Objects;
35+
36+
import org.scijava.io.Location;
37+
38+
/**
39+
* Abstract superclass for {@link Location}s that wrap other {@link Location}s.
40+
*
41+
* @author Gabriel Einsdorf
42+
*/
43+
public abstract class AbstractHigherOrderLocation extends AbstractLocation {
44+
45+
/**
46+
* The location wrapped by this class
47+
*/
48+
protected final Location location;
49+
50+
public AbstractHigherOrderLocation(Location location) {
51+
Objects.requireNonNull(location);
52+
this.location = location;
53+
}
54+
55+
/**
56+
* @return the {@link Location} wrapped by this higher order location
57+
*/
58+
public Location getBaseLocation() {
59+
return location;
60+
}
61+
62+
@Override
63+
public String getName() {
64+
return location.getName();
65+
}
66+
67+
@Override
68+
public int hashCode() {
69+
final int prime = 31;
70+
int result = super.hashCode();
71+
result = prime * result + ((location == null) ? 0 : location.hashCode());
72+
return result;
73+
}
74+
75+
@Override
76+
public boolean equals(Object obj) {
77+
if (this == obj) return true;
78+
if (obj == null) return false;
79+
if (getClass() != obj.getClass()) return false;
80+
AbstractHigherOrderLocation other = (AbstractHigherOrderLocation) obj;
81+
return (location.equals(other.location));
82+
}
83+
84+
}

src/main/java/org/scijava/io/AbstractLocation.java renamed to src/main/java/org/scijava/io/location/AbstractLocation.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@
2929
* #L%
3030
*/
3131

32-
package org.scijava.io;
32+
package org.scijava.io.location;
3333

3434
import java.util.Objects;
3535

36+
import org.scijava.io.Location;
37+
3638
/**
3739
* Abstract base class for {@link Location} implementations.
3840
*

src/main/java/org/scijava/io/AbstractRemoteLocation.java renamed to src/main/java/org/scijava/io/location/AbstractRemoteLocation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* #L%
3030
*/
3131

32-
package org.scijava.io;
32+
package org.scijava.io.location;
3333

3434
/**
3535
* Abstract base class for {@link RemoteLocation} implementations.

src/main/java/org/scijava/io/AbstractSeekableStreamHandle.java renamed to src/main/java/org/scijava/io/location/AbstractSeekableStreamHandle.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@
2929
* #L%
3030
*/
3131

32-
package org.scijava.io;
32+
package org.scijava.io.location;
3333

3434
import java.io.IOException;
3535

36+
import org.scijava.io.Location;
37+
3638
public abstract class AbstractSeekableStreamHandle<L extends Location> extends
3739
AbstractStreamHandle<L> implements SeekableStreamHandle<L>
3840
{

src/main/java/org/scijava/io/AbstractStreamHandle.java renamed to src/main/java/org/scijava/io/location/AbstractStreamHandle.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
* #L%
3030
*/
3131

32-
package org.scijava.io;
32+
package org.scijava.io.location;
33+
34+
import org.scijava.io.Location;
3335

3436
/**
3537
* Abstract base class for {@link StreamHandle} implementations.

src/main/java/org/scijava/io/BufferedStreamHandle.java renamed to src/main/java/org/scijava/io/location/BufferedStreamHandle.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
* #L%
3030
*/
3131

32-
package org.scijava.io;
32+
package org.scijava.io.location;
33+
34+
import org.scijava.io.Location;
3335

3436
/**
3537
* A buffered {@link StreamHandle}.

src/main/java/org/scijava/io/DefaultBufferedStreamHandle.java renamed to src/main/java/org/scijava/io/location/DefaultBufferedStreamHandle.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,18 @@
2929
* #L%
3030
*/
3131

32-
package org.scijava.io;
32+
package org.scijava.io.location;
3333

3434
import java.io.IOException;
3535
import java.io.InputStream;
3636
import java.io.OutputStream;
3737

38+
import org.scijava.io.DataHandleInputStream;
39+
import org.scijava.io.DataHandleOutputStream;
40+
import org.scijava.io.Location;
41+
import org.scijava.io.bytes.ByteArrayIOBuffer;
42+
import org.scijava.io.bytes.IOBuffer;
43+
3844
/**
3945
* A {@link BufferedStreamHandle} backed by an {@link IOBuffer}.
4046
*

src/main/java/org/scijava/io/RemoteLocation.java renamed to src/main/java/org/scijava/io/location/RemoteLocation.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
* #L%
3030
*/
3131

32-
package org.scijava.io;
32+
package org.scijava.io.location;
33+
34+
import org.scijava.io.Location;
3335

3436
/**
3537
* A {@link Location} which resides on a remote machine.

src/main/java/org/scijava/io/ResettableStreamHandle.java renamed to src/main/java/org/scijava/io/location/ResettableStreamHandle.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@
2929
* #L%
3030
*/
3131

32-
package org.scijava.io;
32+
package org.scijava.io.location;
3333

3434
import java.io.IOException;
3535
import java.io.InputStream;
3636
import java.io.OutputStream;
3737

38+
import org.scijava.io.DataHandle;
39+
import org.scijava.io.Location;
40+
3841
/**
3942
* A {@link DataHandle} backed by an {@link InputStream} and/or
4043
* {@link OutputStream}. Supports resetting the handle to the start of the

0 commit comments

Comments
 (0)