From dcd49e564582bd2f31efc7b444f2814e780ae46d Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Fri, 24 Mar 2023 00:24:03 +0100 Subject: [PATCH] ByteUtils: remove unused helpers --- .../org/bitcoinj/base/internal/ByteUtils.java | 88 +------------------ 1 file changed, 2 insertions(+), 86 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/base/internal/ByteUtils.java b/core/src/main/java/org/bitcoinj/base/internal/ByteUtils.java index 4f7cb43493b..42e92b7615f 100644 --- a/core/src/main/java/org/bitcoinj/base/internal/ByteUtils.java +++ b/core/src/main/java/org/bitcoinj/base/internal/ByteUtils.java @@ -121,23 +121,6 @@ public static ByteBuffer writeInt16LE(int val, ByteBuffer buf) throws BufferOver return buf.order(ByteOrder.LITTLE_ENDIAN).putShort((short) val); } - /** - * Write a 16-bit integer to a given byte array in little-endian format, starting at a given offset. - *

- * The value is expected as an unsigned {@code int} as per the Java Unsigned Integer API. - * - * @param val value to be written - * @param out buffer to be written into - * @param offset offset into the buffer - * @throws ArrayIndexOutOfBoundsException if offset points outside of the buffer, or - * if the value doesn't fit the remaining buffer - */ - public static void writeInt16LE(int val, byte[] out, int offset) throws ArrayIndexOutOfBoundsException { - check(offset >= 0 && offset <= out.length - 2, () -> - new ArrayIndexOutOfBoundsException(offset)); - writeInt16LE(val, ByteBuffer.wrap(out, offset, out.length - offset)); - } - /** * Write a 16-bit integer to a given buffer in big-endian format. *

@@ -154,23 +137,6 @@ public static ByteBuffer writeInt16BE(int val, ByteBuffer buf) throws BufferOver return buf.order(ByteOrder.BIG_ENDIAN).putShort((short) val); } - /** - * Write a 16-bit integer to a given byte array in big-endian format, starting at a given offset. - *

- * The value is expected as an unsigned {@code int} as per the Java Unsigned Integer API. - * - * @param val value to be written - * @param out buffer to be written into - * @param offset offset into the buffer - * @throws ArrayIndexOutOfBoundsException if offset points outside of the buffer, or - * if the value doesn't fit the remaining buffer - */ - public static void writeInt16BE(int val, byte[] out, int offset) throws ArrayIndexOutOfBoundsException { - check(offset >= 0 && offset <= out.length - 2, () -> - new ArrayIndexOutOfBoundsException(offset)); - writeInt16BE(val, ByteBuffer.wrap(out, offset, out.length - offset)); - } - /** * Write a 32-bit integer to a given buffer in little-endian format. *

@@ -222,24 +188,7 @@ public static void writeInt32LE(long val, byte[] out, int offset) throws ArrayIn /** * Write a 32-bit integer to a given buffer in big-endian format. *

- * The value is expected as an unsigned {@code long} as per the Java Unsigned Integer API. - * - * @param val value to be written - * @param buf buffer to be written into - * @return the buffer - * @throws BufferOverflowException if the value doesn't fit the remaining buffer - */ - public static ByteBuffer writeInt32BE(long val, ByteBuffer buf) throws BufferOverflowException { - checkArgument(val >= 0 && val <= MAX_UNSIGNED_INTEGER, () -> - "value out of range: " + val); - return buf.order(ByteOrder.BIG_ENDIAN).putInt((int) val); - } - - /** - * Write a 32-bit integer to a given buffer in big-endian format. - *

- * The value is expected as a signed or unsigned {@code int}. If you've got an unsigned {@code long} as per the - * Java Unsigned Integer API, use {@link #writeInt32BE(long, ByteBuffer)}. + * The value is expected as a signed or unsigned {@code int}. * * @param val value to be written * @param buf buffer to be written into @@ -253,25 +202,7 @@ public static ByteBuffer writeInt32BE(int val, ByteBuffer buf) throws BufferOver /** * Write a 32-bit integer to a given byte array in big-endian format, starting at a given offset. *

- * The value is expected as an unsigned {@code long} as per the Java Unsigned Integer API. - * - * @param val value to be written - * @param out buffer to be written into - * @param offset offset into the buffer - * @throws ArrayIndexOutOfBoundsException if offset points outside of the buffer, or - * if the value doesn't fit the remaining buffer - */ - public static void writeInt32BE(long val, byte[] out, int offset) throws ArrayIndexOutOfBoundsException { - check(offset >= 0 && offset <= out.length - 4, () -> - new ArrayIndexOutOfBoundsException(offset)); - writeInt32BE(val, ByteBuffer.wrap(out, offset, out.length - offset)); - } - - /** - * Write a 32-bit integer to a given byte array in big-endian format, starting at a given offset. - *

- * The value is expected as a signed or unsigned {@code int}. If you've got an unsigned {@code long} as per the - * Java Unsigned Integer API, use {@link #writeInt32BE(long, byte[], int)}. + * The value is expected as a signed or unsigned {@code int}. * * @param val value to be written * @param out buffer to be written into @@ -375,21 +306,6 @@ public static void writeInt32LE(long val, OutputStream stream) throws IOExceptio stream.write(buf); } - /** - * Write a 32-bit integer to a given output stream in big-endian format. - *

- * The value is expected as an unsigned {@code long} as per the Java Unsigned Integer API. - * - * @param val value to be written - * @param stream stream to be written into - * @throws IOException if an I/O error occurs - */ - public static void writeInt32BE(long val, OutputStream stream) throws IOException { - byte[] buf = new byte[4]; - writeInt32BE(val, ByteBuffer.wrap(buf)); - stream.write(buf); - } - /** * Write a 32-bit integer to a given output stream in big-endian format. *