Skip to content

Commit 672d764

Browse files
committed
Replace SCIFIO Handles with SciJava's
1 parent 6a16353 commit 672d764

2 files changed

Lines changed: 17 additions & 20 deletions

File tree

pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,6 @@ Institute of Molecular Cell Biology and Genetics.</license.copyrightOwners>
106106
<version>1.3</version>
107107
</dependency>
108108

109-
<!-- SCIFIO dependencies -->
110-
<dependency>
111-
<groupId>io.scif</groupId>
112-
<artifactId>scifio</artifactId>
113-
</dependency>
114-
115109
<!-- Test scope dependencies -->
116110
<dependency>
117111
<groupId>junit</groupId>

src/main/java/net/imagej/table/DefaultTableIOPlugin.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121

2222
package net.imagej.table;
2323

24-
import io.scif.io.IRandomAccess;
25-
import io.scif.io.VirtualHandle;
26-
import io.scif.services.LocationService;
27-
2824
import java.io.IOException;
2925
import java.util.ArrayList;
3026
import java.util.Arrays;
@@ -37,7 +33,11 @@
3733

3834
import org.scijava.Priority;
3935
import org.scijava.io.AbstractIOPlugin;
36+
import org.scijava.io.DataHandle;
37+
import org.scijava.io.DataHandleService;
38+
import org.scijava.io.FileLocation;
4039
import org.scijava.io.IOPlugin;
40+
import org.scijava.io.Location;
4141
import org.scijava.plugin.Parameter;
4242
import org.scijava.plugin.Plugin;
4343
import org.scijava.util.FileUtils;
@@ -51,7 +51,7 @@
5151
public class DefaultTableIOPlugin extends AbstractIOPlugin<GenericTable> {
5252

5353
@Parameter
54-
private LocationService locationService;
54+
private DataHandleService dataHandleService;
5555

5656
/** Reads the first row of the input file as column headers. */
5757
@Parameter(required = false)
@@ -180,12 +180,16 @@ else if (line.charAt(idx) == separator) {
180180

181181
@Override
182182
public GenericTable open(final String source) throws IOException {
183-
final IRandomAccess handle = locationService.getHandle(source);
184-
if (handle instanceof VirtualHandle) {
183+
// FIXME Assumes FileLocation
184+
final Location sourceLocation = new FileLocation(source);
185+
final DataHandle<? extends Location> handle = //
186+
dataHandleService.create(sourceLocation);
187+
long length = handle.length();
188+
if (length == 0) {
185189
throw new IOException("Cannot open source");
186190
}
187-
handle.seek(0);
188-
final byte[] buffer = new byte[(int) handle.length()];
191+
192+
final byte[] buffer = new byte[(int) length];
189193
handle.read(buffer);
190194
final String text = new String(buffer);
191195

@@ -248,11 +252,10 @@ public GenericTable open(final String source) throws IOException {
248252
public void save(final GenericTable table, final String source)
249253
throws IOException
250254
{
251-
final IRandomAccess handle = locationService.getHandle(source, true);
252-
if (handle instanceof VirtualHandle) {
253-
throw new IOException("Cannot open source");
254-
}
255-
handle.seek(0);
255+
// FIXME Assumes FileLocation
256+
final Location sourceLocation = new FileLocation(source);
257+
final DataHandle<Location> handle = //
258+
dataHandleService.create(sourceLocation);
256259

257260
final boolean writeRH = this.writeRowHeaders && table.getRowCount() > 0 &&
258261
IntStream.range(0, table.getRowCount()).allMatch(row -> table

0 commit comments

Comments
 (0)