Skip to content

Commit bba50af

Browse files
frauzufallctrueden
authored andcommitted
Adding TextIOService with default implementation
* .. which was originally implemented in the TypedIOServiceTest for testing the TypedIOService architecture
1 parent 5a83bcd commit bba50af

File tree

4 files changed

+85
-13
lines changed

4 files changed

+85
-13
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* #%L
3+
* SciJava Common shared library for SciJava software.
4+
* %%
5+
* Copyright (C) 2009 - 2020 SciJava developers.
6+
* %%
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
* #L%
28+
*/
29+
30+
package org.scijava.text.io;
31+
32+
import org.scijava.io.AbstractTypedIOService;
33+
import org.scijava.plugin.Plugin;
34+
import org.scijava.service.Service;
35+
36+
/**
37+
* Default {@link TextIOService} implementation for opening and saving text data
38+
*
39+
* @author Deborah Schmidt
40+
*/
41+
@Plugin(type = Service.class)
42+
public class DefaultTextIOService extends AbstractTypedIOService<String> implements TextIOService {
43+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* #%L
3+
* SciJava Common shared library for SciJava software.
4+
* %%
5+
* Copyright (C) 2009 - 2020 SciJava developers.
6+
* %%
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
* #L%
28+
*/
29+
30+
package org.scijava.text.io;
31+
32+
import org.scijava.io.TypedIOService;
33+
34+
/**
35+
* {@link TypedIOService} for opening and saving text data
36+
*
37+
* @author Deborah Schmidt
38+
*/
39+
public interface TextIOService extends TypedIOService<String> {
40+
}

src/test/java/org/scijava/ContextCreationTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public void testFull() {
114114
org.scijava.startup.DefaultStartupService.class,
115115
org.scijava.task.DefaultTaskService.class,
116116
org.scijava.text.DefaultTextService.class,
117+
org.scijava.text.io.DefaultTextIOService.class,
117118
org.scijava.thread.DefaultThreadService.class,
118119
org.scijava.tool.DefaultToolService.class,
119120
org.scijava.ui.DefaultUIService.class,

src/test/java/org/scijava/io/TypedIOServiceTest.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
import org.junit.Test;
44
import org.scijava.Context;
55
import org.scijava.plugin.PluginInfo;
6-
import org.scijava.plugin.PluginService;
7-
import org.scijava.plugin.SciJavaPlugin;
8-
import org.scijava.service.SciJavaService;
96
import org.scijava.text.AbstractTextFormat;
107
import org.scijava.text.TextFormat;
11-
import org.scijava.text.TextService;
8+
import org.scijava.text.io.TextIOService;
129

1310
import java.io.IOException;
1411
import java.util.Collections;
@@ -24,9 +21,6 @@ public void testTextFile() throws IOException {
2421
// create context, add dummy text format
2522
final Context ctx = new Context();
2623
ctx.getPluginIndex().add(new PluginInfo<>(DummyTextFormat.class, TextFormat.class));
27-
ctx.getPluginIndex().add(new PluginInfo<>(DefaultTextIOService.class, TextIOService.class));
28-
TextIOService instance = (TextIOService) ctx.getService(PluginService.class).createInstance(ctx.getPluginIndex().get(TextIOService.class).get(0));
29-
ctx.getServiceIndex().add(instance);
3024

3125
// try to get the TextIOService
3226
final TextIOService io = ctx.service(TextIOService.class);
@@ -39,12 +33,6 @@ public void testTextFile() throws IOException {
3933
assertTrue(obj.contains("content"));
4034
}
4135

42-
interface TextIOService extends TypedIOService<String> {
43-
}
44-
45-
public static class DefaultTextIOService extends AbstractTypedIOService<String> implements TextIOService {
46-
}
47-
4836
public static class DummyTextFormat extends AbstractTextFormat {
4937

5038
@Override

0 commit comments

Comments
 (0)