Added setBuffer(DirectBuffer) method

This commit is contained in:
nathan 2020-09-18 01:10:57 +02:00
parent bb2a7d8c41
commit a8a6a517f7
2 changed files with 17 additions and 1 deletions

View File

@ -147,7 +147,14 @@ class AeronInput extends Input {
}
/**
* Throws {@link UnsupportedOperationException} because this input uses a ByteBuffer, not a byte[].
* Sets the internal buffer (and properties based on that buffer)
*/
public void setBuffer(DirectBuffer buffer) {
setBuffer(buffer, 0, buffer.capacity());
}
/**
* Sets the internal buffer (and properties based on that buffer)
*/
public void setBuffer (DirectBuffer buffer, int offset, int length) {
this.internalBuffer = buffer;

View File

@ -123,6 +123,15 @@ public class AeronOutput extends Output {
throw new UnsupportedOperationException("This buffer does not used a byte[], see #getInternaleBuffer().");
}
/**
* Sets a new buffer to write to. The max size is the buffer's length.
*/
public void setBuffer (MutableDirectBuffer buffer) {
internalBuffer = buffer;
position = 0;
capacity = buffer.capacity();
}
/**
* Sets a new buffer to write to. The max size is the buffer's length.
*/