From fda76aad7a76847a76d36d9cb566d4c57bfe632d Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Thu, 13 Aug 2020 18:06:54 -0700 Subject: [PATCH] Exposed ByteBuf for ByteInput and ByteOutput as a read-only view with doc --- core/src/com/riiablo/io/ByteInput.java | 8 +++++++- core/src/com/riiablo/io/ByteOutput.java | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/src/com/riiablo/io/ByteInput.java b/core/src/com/riiablo/io/ByteInput.java index 44a73338..8cb8df21 100644 --- a/core/src/com/riiablo/io/ByteInput.java +++ b/core/src/com/riiablo/io/ByteInput.java @@ -73,7 +73,13 @@ public class ByteInput { return this.bitInput = bitInput; } - ByteBuf buffer() { + /** + * Returns a read-only view of the underlying byte buffer. This method is + * provided for debugging and testing purposes. Do not use this in + * production code! + */ + public ByteBuf buffer() { + assert buffer.isReadOnly(); return buffer; } diff --git a/core/src/com/riiablo/io/ByteOutput.java b/core/src/com/riiablo/io/ByteOutput.java index ecdd69dd..50561a51 100644 --- a/core/src/com/riiablo/io/ByteOutput.java +++ b/core/src/com/riiablo/io/ByteOutput.java @@ -25,8 +25,13 @@ public class ByteOutput { return bitOutput != null ? bitOutput : (bitOutput = new BitOutput(this)); } + /** + * Returns a read-only view of the underlying byte buffer. This method is + * provided for debugging and testing purposes. Do not use this in + * production code! + */ public ByteBuf buffer() { - return buffer; + return buffer.asReadOnly(); } public int bytesRemaining() {