|
30 | 30 |
|
31 | 31 | package org.scijava.table; |
32 | 32 |
|
| 33 | +import java.net.URISyntaxException; |
33 | 34 | import java.io.IOException; |
34 | 35 | import java.util.ArrayList; |
35 | 36 | import java.util.Arrays; |
|
42 | 43 |
|
43 | 44 | import org.scijava.Priority; |
44 | 45 | import org.scijava.io.AbstractIOPlugin; |
| 46 | +import org.scijava.io.IOPlugin; |
45 | 47 | import org.scijava.io.handle.DataHandle; |
46 | 48 | import org.scijava.io.handle.DataHandleService; |
47 | | -import org.scijava.io.location.FileLocation; |
48 | | -import org.scijava.io.IOPlugin; |
49 | 49 | import org.scijava.io.location.Location; |
| 50 | +import org.scijava.io.location.LocationService; |
50 | 51 | import org.scijava.plugin.Parameter; |
51 | 52 | import org.scijava.plugin.Plugin; |
52 | 53 | import org.scijava.util.FileUtils; |
|
60 | 61 | @Plugin(type = IOPlugin.class, priority = Priority.LOW) |
61 | 62 | public class DefaultTableIOPlugin extends AbstractIOPlugin<Table> { |
62 | 63 |
|
| 64 | + @Parameter |
| 65 | + private LocationService locationService; |
| 66 | + |
63 | 67 | @Parameter |
64 | 68 | private DataHandleService dataHandleService; |
65 | 69 |
|
@@ -190,8 +194,13 @@ else if (line.charAt(idx) == separator) { |
190 | 194 |
|
191 | 195 | @Override |
192 | 196 | public GenericTable open(final String source) throws IOException { |
193 | | - // FIXME Assumes FileLocation |
194 | | - final Location sourceLocation = new FileLocation(source); |
| 197 | + final Location sourceLocation; |
| 198 | + try { |
| 199 | + sourceLocation = locationService.resolve(source); |
| 200 | + } |
| 201 | + catch (final URISyntaxException exc) { |
| 202 | + throw new IOException("Unresolvable source: " + source, exc); |
| 203 | + } |
195 | 204 | final GenericTable table = new DefaultGenericTable(); |
196 | 205 |
|
197 | 206 | try (final DataHandle<? extends Location> handle = // |
@@ -266,8 +275,13 @@ public GenericTable open(final String source) throws IOException { |
266 | 275 | public void save(final Table table, final String destination) |
267 | 276 | throws IOException |
268 | 277 | { |
269 | | - // FIXME Assumes FileLocation |
270 | | - final Location dstLocation = new FileLocation(destination); |
| 278 | + final Location dstLocation; |
| 279 | + try { |
| 280 | + dstLocation = locationService.resolve(destination); |
| 281 | + } |
| 282 | + catch (final URISyntaxException exc) { |
| 283 | + throw new IOException("Unresolvable destination: " + destination, exc); |
| 284 | + } |
271 | 285 |
|
272 | 286 | try (final DataHandle<Location> handle = // |
273 | 287 | dataHandleService.create(dstLocation)) |
|
0 commit comments