public static void appendUtf8Char(@org.jetbrains.annotations.NotNull @NotNull StreamingDataOutput bytes, int c) throws BufferOverflowException { if (c <= 0x007F) { bytes.writeByte((byte) c); } else if (c <= 0x07FF) { bytes.writeByte((byte) (0xC0 | ((c >> 6) & 0x1F))); bytes.writeByte((byte) (0x80 | c & 0x3F)); } else if (c <= 0xFFFF) { bytes.writeByte((byte) (0xE0 | ((c >> 12) & 0x0F))); bytes.writeByte((byte) (0x80 | ((c >> 6) & 0x3F))); bytes.writeByte((byte) (0x80 | (c & 0x3F))); } else { bytes.writeByte((byte) (0xF0 | ((c >> 18) & 0x07))); bytes.writeByte((byte) (0x80 | ((c >> 12) & 0x3F))); bytes.writeByte((byte) (0x80 | ((c >> 6) & 0x3F))); bytes.writeByte((byte) (0x80 | (c & 0x3F))); } }
static void writeStopBit0(@org.jetbrains.annotations.NotNull @NotNull StreamingDataOutput out, long n) throws BufferOverflowException { boolean neg = false; if (n < 0) { neg = true; n = ~n; } long n2; while ((n2 = n >>> 7) != 0) { out.writeByte((byte) (0x80L | n)); n = n2; } // final byte if (!neg) { out.writeByte((byte) n); } else { out.writeByte((byte) (0x80L | n)); out.writeByte((byte) 0); } }
public static void writeStopBit(@org.jetbrains.annotations.NotNull @NotNull StreamingDataOutput out, char n) throws BufferOverflowException { if ((n & ~0x7F) == 0) { out.writeByte((byte) (n & 0x7f)); return; } if ((n & ~0x3FFF) == 0) { out.writeByte((byte) ((n & 0x7f) | 0x80)); out.writeByte((byte) (n >> 7)); return; } writeStopBit0(out, n); }
int b3 = bytes[offset + i + 2] & 0xFF; // unsigned byte int b4 = bytes[offset + i + 3] & 0xFF; // unsigned byte this.writeByte((byte) b4); this.writeByte((byte) b3); this.writeByte((byte) b2); this.writeByte((byte) b); int b2 = bytes[offset + i + 1] & 0xFF; // unsigned byte int b3 = bytes[offset + i + 2] & 0xFF; // unsigned byte this.writeByte((byte) b3); this.writeByte((byte) b2); this.writeByte((byte) b); this.writeByte((byte) b2); this.writeByte((byte) b); this.writeByte((byte) b);
@SuppressWarnings("ShiftOutOfRange") public static void writeStopBit(@org.jetbrains.annotations.NotNull @NotNull StreamingDataOutput out, double d) throws BufferOverflowException { long n = Double.doubleToRawLongBits(d); while ((n & (~0L >>> 7)) != 0) { out.writeByte((byte) (((n >>> -7) & 0x7F) | 0x80)); n <<= 7; } out.writeByte((byte) ((n >>> -7) & 0x7F)); }
public static void writeStopBit(@org.jetbrains.annotations.NotNull @NotNull StreamingDataOutput out, long n) throws BufferOverflowException { if ((n & ~0x7F) == 0) { out.writeByte((byte) (n & 0x7f)); return; } if ((n & ~0x3FFF) == 0) { out.writeByte((byte) ((n & 0x7f) | 0x80)); out.writeByte((byte) (n >> 7)); return; } writeStopBit0(out, n); }
@org.jetbrains.annotations.NotNull @NotNull default S writeBoolean(boolean flag) throws BufferOverflowException { return writeByte(flag ? (byte) 'Y' : (byte) 'N'); }
@org.jetbrains.annotations.NotNull default S appendUtf8(char[] chars, int offset, int length) throws BufferOverflowException, IllegalArgumentException { int i; ascii: { for (i = 0; i < length; i++) { char c = chars[offset + i]; if (c > 0x007F) break ascii; writeByte((byte) c); } return (S) this; } for (; i < length; i++) { char c = chars[offset + i]; BytesInternal.appendUtf8Char(this, c); } return (S) this; }
@org.jetbrains.annotations.NotNull @NotNull default S writeUnsignedByte(int i) throws BufferOverflowException, IllegalArgumentException { return writeByte((byte) Maths.toUInt8(i)); }
public static void appendUtf8(@org.jetbrains.annotations.NotNull @NotNull StreamingDataOutput bytes, @org.jetbrains.annotations.NotNull @NotNull CharSequence str, int offset, int length) throws IndexOutOfBoundsException, BufferOverflowException { int i; for (i = 0; i < length; i++) { char c = str.charAt(offset + i); if (c > 0x007F) break; bytes.writeByte((byte) c); } appendUtf82(bytes, str, offset, length, i); }
long mantissa = val & ((1L << 52) - 1); if (sign != 0) { out.writeByte((byte) '-'); out.writeByte((byte) '0'); out.writeByte((byte) '.'); out.writeByte((byte) '0'); return; mantissa -= intValue << shift; if (mantissa > 0) { out.writeByte((byte) '.'); mantissa <<= 1; mantissa++; long num = (mantissa >> precision); value = value * 10 + num; out.writeByte((byte) ('0' + num)); mantissa -= num << precision; out.writeByte((byte) '.'); out.writeByte((byte) '0'); out.writeByte((byte) '0'); out.writeByte((byte) '.'); mantissa <<= 6; mantissa += (1 << 5); if (precision >= 64) {
private static void appendInt0(@org.jetbrains.annotations.NotNull @NotNull StreamingDataOutput out, int num) throws IllegalArgumentException, BufferOverflowException { if (num < 10) { out.writeByte((byte) ('0' + num)); } else if (num < 100) { out.writeShort((short) (num / 10 + (num % 10 << 8) + '0' * 0x101)); } else { byte[] numberBuffer = NUMBER_BUFFER.get(); // Extract digits into the end of the numberBuffer int endIndex = appendInt1(numberBuffer, num); // Bulk copy the digits into the front of the buffer out.write(numberBuffer, endIndex, numberBuffer.length - endIndex); } }
private static void appendLong0(@org.jetbrains.annotations.NotNull @NotNull StreamingDataOutput out, long num) throws IllegalArgumentException, BufferOverflowException { if (num < 10) { out.writeByte((byte) ('0' + num)); } else if (num < 100) { out.writeShort((short) (num / 10 + (num % 10 << 8) + '0' * 0x101)); } else { byte[] numberBuffer = NUMBER_BUFFER.get(); // Extract digits into the end of the numberBuffer int endIndex = appendLong1(numberBuffer, num); // Bulk copy the digits into the front of the buffer out.write(numberBuffer, endIndex, numberBuffer.length - endIndex); } }
public static void writeFully(@org.jetbrains.annotations.NotNull @NotNull RandomDataInput bytes, long offset, long length, @org.jetbrains.annotations.NotNull StreamingDataOutput sdo) throws BufferUnderflowException, BufferOverflowException { long i = 0; for (; i < length - 7; i += 8) sdo.writeLong(bytes.readLong(offset + i)); if (i < length - 3) { sdo.writeInt(bytes.readInt(offset + i)); i += 4; } for (; i < length; i++) sdo.writeByte(bytes.readByte(offset + i)); }