Skip to content

Commit 4a4b185

Browse files
committed
Gateway: add a getShortName for use with scripting
When the gateway is a variable somewhere, it is convenient for its name to be as short as possible. E.g.: * "SciJava" can be "sj" * "ImageJ" can be "ij" It is handy for each gateway to self-suggest such a name.
1 parent 2d3ff66 commit 4a4b185

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/main/java/org/scijava/AbstractGateway.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ public AbstractGateway(final String appName, final Context context) {
8787

8888
// -- Gateway methods --
8989

90+
@Override
91+
public String getShortName() {
92+
return getClass().getName().toLowerCase();
93+
}
94+
9095
@Override
9196
public <S extends Service> S get(final Class<S> serviceClass) {
9297
return context().service(serviceClass);

src/main/java/org/scijava/Gateway.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@
118118
*/
119119
public interface Gateway extends RichPlugin, Versioned {
120120

121+
/**
122+
* Gets a very succinct name for use referring to this gateway, e.g. as a
123+
* variable name for scripting.
124+
*/
125+
String getShortName();
126+
121127
/**
122128
* Returns an implementation of the requested {@link Service}, if it exists in
123129
* the underlying {@link Context}.

src/main/java/org/scijava/SciJava.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,11 @@ public SciJava(final Context context) {
112112
super(SciJavaApp.NAME, context);
113113
}
114114

115+
// -- Gateway methods --
116+
117+
@Override
118+
public String getShortName() {
119+
return "sj";
120+
}
121+
115122
}

0 commit comments

Comments
 (0)