Skip to content

Commit 26fcec1

Browse files
ctruedengab1one
authored andcommitted
BytesLocation: make the backing ByteBuffer mutable
We will need this in the BytesHandle, because it might try to write too much data to the buffer... and then what do you do? Well, you allocate a new, larger buffer, and copy the contents from the old buffer into that. Unfortunately, this has the confusing side effect of making the BytesHandle's backing BytesLocation no longer wrap the originally given ByteBuffer/byte[], but that's tough -- when you keep writing to a buffer past its capacity, something has to give.
1 parent bb9fbd3 commit 26fcec1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
*/
4141
public class BytesLocation extends AbstractLocation {
4242

43-
private final ByteBuffer bytes;
43+
private ByteBuffer bytes;
4444

4545
public BytesLocation(final ByteBuffer bytes) {
4646
this.bytes = bytes;
@@ -61,4 +61,9 @@ public ByteBuffer getByteBuffer() {
6161
return bytes;
6262
}
6363

64+
/** Sets the associated {@link ByteBuffer}. */
65+
public void setByteBuffer(final ByteBuffer bytes) {
66+
this.bytes = bytes;
67+
}
68+
6469
}

0 commit comments

Comments
 (0)