Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public Object decodeMessage(@Nullable ByteBuffer message) {
* Writes an int representing a size to the specified stream. Uses an expanding code of 1 to 5
* bytes to optimize for small values.
*/
protected static final void writeSize(@NonNull ByteArrayOutputStream stream, int value) {
protected static void writeSize(@NonNull ByteArrayOutputStream stream, int value) {
if (BuildConfig.DEBUG && 0 > value) {
Log.e(TAG, "Attempted to write a negative size.");
}
Expand All @@ -131,7 +131,7 @@ protected static final void writeSize(@NonNull ByteArrayOutputStream stream, int
}

/** Writes the least significant two bytes of the specified int to the specified stream. */
protected static final void writeChar(@NonNull ByteArrayOutputStream stream, int value) {
protected static void writeChar(@NonNull ByteArrayOutputStream stream, int value) {
if (LITTLE_ENDIAN) {
stream.write(value);
stream.write(value >>> 8);
Expand All @@ -142,7 +142,7 @@ protected static final void writeChar(@NonNull ByteArrayOutputStream stream, int
}

/** Writes the specified int as 4 bytes to the specified stream. */
protected static final void writeInt(@NonNull ByteArrayOutputStream stream, int value) {
protected static void writeInt(@NonNull ByteArrayOutputStream stream, int value) {
if (LITTLE_ENDIAN) {
stream.write(value);
stream.write(value >>> 8);
Expand All @@ -157,7 +157,7 @@ protected static final void writeInt(@NonNull ByteArrayOutputStream stream, int
}

/** Writes the specified long as 8 bytes to the specified stream. */
protected static final void writeLong(@NonNull ByteArrayOutputStream stream, long value) {
protected static void writeLong(@NonNull ByteArrayOutputStream stream, long value) {
if (LITTLE_ENDIAN) {
stream.write((byte) value);
stream.write((byte) (value >>> 8));
Expand All @@ -180,18 +180,17 @@ protected static final void writeLong(@NonNull ByteArrayOutputStream stream, lon
}

/** Writes the specified double as 4 bytes to the specified stream */
protected static final void writeFloat(@NonNull ByteArrayOutputStream stream, float value) {
protected static void writeFloat(@NonNull ByteArrayOutputStream stream, float value) {
writeInt(stream, Float.floatToIntBits(value));
}

/** Writes the specified double as 8 bytes to the specified stream. */
protected static final void writeDouble(@NonNull ByteArrayOutputStream stream, double value) {
protected static void writeDouble(@NonNull ByteArrayOutputStream stream, double value) {
writeLong(stream, Double.doubleToLongBits(value));
}

/** Writes the length and then the actual bytes of the specified array to the specified stream. */
protected static final void writeBytes(
@NonNull ByteArrayOutputStream stream, @NonNull byte[] bytes) {
protected static void writeBytes(@NonNull ByteArrayOutputStream stream, @NonNull byte[] bytes) {
writeSize(stream, bytes.length);
stream.write(bytes, 0, bytes.length);
}
Expand All @@ -201,7 +200,7 @@ protected static final void writeBytes(
* aligned to a whole multiple of the specified alignment. An example usage with alignment = 8 is
* to ensure doubles are word-aligned in the stream.
*/
protected static final void writeAlignment(@NonNull ByteArrayOutputStream stream, int alignment) {
protected static void writeAlignment(@NonNull ByteArrayOutputStream stream, int alignment) {
final int mod = stream.size() % alignment;
if (mod != 0) {
for (int i = 0; i < alignment - mod; i++) {
Expand All @@ -221,7 +220,7 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, @Nullable Objec
if (value == null || value.equals(null)) {
stream.write(NULL);
} else if (value instanceof Boolean) {
stream.write(((Boolean) value).booleanValue() ? TRUE : FALSE);
stream.write((Boolean) value ? TRUE : FALSE);
} else if (value instanceof Number) {
if (value instanceof Integer || value instanceof Short || value instanceof Byte) {
stream.write(INT);
Expand Down Expand Up @@ -299,7 +298,7 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, @Nullable Objec
}

/** Reads an int representing a size as written by writeSize. */
protected static final int readSize(@NonNull ByteBuffer buffer) {
protected static int readSize(@NonNull ByteBuffer buffer) {
if (!buffer.hasRemaining()) {
throw new IllegalArgumentException("Message corrupted");
}
Expand All @@ -315,15 +314,15 @@ protected static final int readSize(@NonNull ByteBuffer buffer) {

/** Reads a byte array as written by writeBytes. */
@NonNull
protected static final byte[] readBytes(@NonNull ByteBuffer buffer) {
protected static byte[] readBytes(@NonNull ByteBuffer buffer) {
final int length = readSize(buffer);
final byte[] bytes = new byte[length];
buffer.get(bytes);
return bytes;
}

/** Reads alignment padding bytes as written by writeAlignment. */
protected static final void readAlignment(@NonNull ByteBuffer buffer, int alignment) {
protected static void readAlignment(@NonNull ByteBuffer buffer, int alignment) {
final int mod = buffer.position() % alignment;
if (mod != 0) {
buffer.position(buffer.position() + alignment - mod);
Expand Down