Skip to content

Commit 412cf74

Browse files
committed
BytesLocation: Add method to set the name for the Location
In some instances libarary users want to create a BytesLocation that has a specific name, e.g. so that it is correctly detected by a Service that performs a name based lookup.
1 parent 821f89f commit 412cf74

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/main/java/org/scijava/io/location/BytesLocation.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
import org.scijava.io.ByteArrayByteBank;
3636
import org.scijava.io.ByteBank;
37-
import org.scijava.io.handle.DataHandle;
3837
import org.scijava.util.ByteArray;
3938

4039
/**
@@ -47,6 +46,8 @@ public class BytesLocation extends AbstractLocation {
4746

4847
private final ByteBank bytes;
4948

49+
private String name = defaultName();
50+
5051
/**
5152
* Creates a {@link BytesLocation} backed by the specified
5253
* {@link ByteBank}.
@@ -106,6 +107,22 @@ public ByteBank getByteBank() {
106107
return bytes;
107108
}
108109

110+
/**
111+
* Set's the name that is returned by {@link #getName()}. Required if this
112+
* {@link BytesLocation} is consumed by services that change behavior
113+
* depending on the name of a Location.
114+
*
115+
* @param name the name to be
116+
*/
117+
public void setName(final String name) {
118+
this.name = name;
119+
}
120+
121+
@Override
122+
public String getName() {
123+
return name;
124+
}
125+
109126
// -- Object methods --
110127

111128
@Override

0 commit comments

Comments
 (0)