@Override default void writeByte(R handle, long offset, int i) { handle.writeByte(offset, i); }
@Override default void writeByte(R handle, long offset, int i) { handle.writeByte(offset, i); }
@Override default void writeByte(R handle, long offset, byte i8) { handle.writeByte(offset, i8); }
@Override default void writeByte(R handle, long offset, byte i8) { handle.writeByte(offset, i8); }
public static long appendUtf8Char(@org.jetbrains.annotations.NotNull @NotNull RandomDataOutput out, long offset, int c) throws BufferOverflowException { if (c <= 0x007F) { out.writeByte(offset++, (byte) c); } else if (c <= 0x07FF) { out.writeByte(offset++, (byte) (0xC0 | ((c >> 6) & 0x1F))); out.writeByte(offset++, (byte) (0x80 | c & 0x3F)); } else if (c <= 0xFFFF) { out.writeByte(offset++, (byte) (0xE0 | ((c >> 12) & 0x0F))); out.writeByte(offset++, (byte) (0x80 | ((c >> 6) & 0x3F))); out.writeByte(offset++, (byte) (0x80 | (c & 0x3F))); } else { out.writeByte(offset++, (byte) (0xF0 | ((c >> 18) & 0x07))); out.writeByte(offset++, (byte) (0x80 | ((c >> 12) & 0x3F))); out.writeByte(offset++, (byte) (0x80 | ((c >> 6) & 0x3F))); out.writeByte(offset++, (byte) (0x80 | (c & 0x3F))); } return offset; }
/** * Write a boolean at an offset. * * @param offset to write to * @param flag the value * @return this * @throws BufferOverflowException if the capacity was exceeded */ @NotNull default R writeBoolean(long offset, boolean flag) throws BufferOverflowException { try { return writeByte(offset, flag ? 'Y' : 'N'); } catch (IllegalArgumentException e) { throw new AssertionError(e); } }
static long writeStopBit0(@org.jetbrains.annotations.NotNull @NotNull RandomDataOutput out, long offset, long n) throws BufferOverflowException { boolean neg = false; if (n < 0) { neg = true; n = ~n; } long n2; while ((n2 = n >>> 7) != 0) { out.writeByte(offset++, (byte) (0x80L | n)); n = n2; } // final byte if (!neg) { out.writeByte(offset++, (byte) n); } else { out.writeByte(offset++, (byte) (0x80L | n)); out.writeByte(offset++, (byte) 0); } return offset; }
public static long writeStopBit(@org.jetbrains.annotations.NotNull @NotNull RandomDataOutput out, long offset, long n) throws BufferOverflowException { if ((n & ~0x7F) == 0) { out.writeByte(offset++, (byte) (n & 0x7f)); return offset; } if ((n & ~0x3FFF) == 0) { out.writeByte(offset++, (byte) ((n & 0x7f) | 0x80)); out.writeByte(offset++, (byte) (n >> 7)); return offset; } return writeStopBit0(out, offset, n); }
@NotNull default R writeInt24(long offset, int i) throws BufferOverflowException { writeShort(offset, (short) i); return writeByte(offset + 2, (byte) (i >> 16)); }
/** * Write an unsigned byte at an offset. * * @param offset to write to * @param i the value * @return this * @throws BufferOverflowException if the capacity was exceeded * @throws IllegalArgumentException if the value cannot be cast to the type without loss. */ @NotNull default R writeUnsignedByte(long offset, int i) throws BufferOverflowException, IllegalArgumentException { return writeByte(offset, (byte) Maths.toUInt8(i)); }
/** * Write a byte at an offset. * * @param offset to write to * @param i the value * @return this * @throws BufferOverflowException if the capacity was exceeded * @throws IllegalArgumentException if the value cannot be cast to the type without loss. */ @NotNull default R writeByte(long offset, int i) throws BufferOverflowException, IllegalArgumentException { return writeByte(offset, Maths.toInt8(i)); }
/** * The length of the number must be fixed otherwise short numbers will not overwrite longer * numbers */ public static void append(@org.jetbrains.annotations.NotNull @NotNull RandomDataOutput out, long offset, long num, int digits) throws BufferOverflowException, IllegalArgumentException { boolean negative = num < 0; num = Math.abs(num); for (int i = digits - 1; i > 0; i--) { out.writeByte(offset + i, (byte) (num % 10 + '0')); num /= 10; } if (negative) { if (num != 0) numberTooLarge(digits); out.writeByte(offset, '-'); } else { if (num > 9) numberTooLarge(digits); out.writeByte(offset, (byte) (num % 10 + '0')); } }
public static long appendUtf8(@org.jetbrains.annotations.NotNull @NotNull RandomDataOutput out, long outOffset, @org.jetbrains.annotations.NotNull @NotNull CharSequence str, int strOffset, int length) throws IndexOutOfBoundsException, BufferOverflowException { int i; for (i = 0; i < length; i++) { char c = str.charAt(strOffset + i); if (c > 0x007F) break; out.writeByte(outOffset++, (byte) c); } return appendUtf82(out, outOffset, str, strOffset, length, i); }
endIndex = MIN_VALUE_TEXT.length; } else { out.writeByte(offset++, (byte) '-'); num = -num; endIndex = appendLong1(numberBuffer, num);