@Override default int readUnsignedByte(S handle, long offset) { return handle.readUnsignedByte(offset); }
@Override default int readUnsignedByte(S handle, long offset) { return handle.readUnsignedByte(offset); }
/** * Read the byte at an offset and converts it into a printable * * @param offset to read * @return the byte in a printable form. * @throws BufferUnderflowException if the offset is outside the limits of the Bytes */ default String printable(long offset) throws BufferUnderflowException { return charToString[readUnsignedByte(offset)]; }
public static boolean bytesEqual(@Nullable CharSequence cs, @org.jetbrains.annotations.NotNull RandomDataInput bs, long offset, int length) { if (cs == null || cs.length() != length) return false; for (int i = 0; i < length; i++) { if (cs.charAt(i) != bs.readUnsignedByte(offset + i)) return false; } return true; }
/** * Read an unsigned int at an offset * * @param offset to read * @return the int * @throws BufferUnderflowException if the offset is outside the limits of the Bytes */ default int readUnsignedInt24(long offset) throws BufferUnderflowException { return readUnsignedShort(offset) | (readUnsignedByte(offset) << 16); }
public static void parse8bit1(long offset, @org.jetbrains.annotations.NotNull @NotNull RandomDataInput bytes, @org.jetbrains.annotations.NotNull @NotNull Appendable appendable, int utflen) throws BufferUnderflowException, IOException { assert bytes.realCapacity() >= utflen + offset; for (int count = 0; count < utflen; count++) { int c = bytes.readUnsignedByte(offset + count); appendable.append((char) c); } }
long limit = offset + utfLen; while (offset < limit && charI < other.length()) { int c = input.readUnsignedByte(offset++); switch (c >> 4) { case 0: throw new UTFDataFormatRuntimeException( "malformed input: partial character at end"); int char2 = input.readUnsignedByte(offset++); if ((char2 & 0xC0) != 0x80) throw new UTFDataFormatRuntimeException( throw new UTFDataFormatRuntimeException( "malformed input: partial character at end"); int char2 = input.readUnsignedByte(offset++); int char3 = input.readUnsignedByte(offset++);
/** * Read a long which is zero padded (high bytes) if the available bytes is less than 8. * If the offset is at or beyond the readLimit, this will return 0L. * * @param offset to read from * @return the long which might be padded. */ default long readIncompleteLong(long offset) { long left = readLimit() - offset; long l; try { if (left >= 8) return readLong(offset); if (left == 4) return readInt(offset); l = 0; for (int i = 0, remaining = (int) left; i < remaining; i++) { l |= (long) readUnsignedByte(offset + i) << (i * 8); } } catch (BufferUnderflowException e) { throw new AssertionError(e); } return l; }
throws IOException, UTFDataFormatRuntimeException, BufferUnderflowException { while (offset < limit) { int c = input.readUnsignedByte(offset++); switch (c >> 4) { case 0: throw new UTFDataFormatRuntimeException( "malformed input: partial character at end"); int char2 = input.readUnsignedByte(offset++); if ((char2 & 0xC0) != 0x80) throw new UTFDataFormatRuntimeException( throw new UTFDataFormatRuntimeException( "malformed input: partial character at end"); int char2 = input.readUnsignedByte(offset++); int char3 = input.readUnsignedByte(offset++);
public static void parseUtf81(@org.jetbrains.annotations.NotNull @NotNull RandomDataInput input, long offset, @org.jetbrains.annotations.NotNull @NotNull Appendable appendable, int utflen) throws UTFDataFormatRuntimeException, BufferUnderflowException { try { assert input.realCapacity() >= offset + utflen; long limit = offset + utflen; while (offset < limit) { int c = input.readUnsignedByte(offset++); if (c >= 128) { offset--; break; } else if (c < 0) { break; } appendable.append((char) c); } if (limit > offset) parseUtf82(input, offset, limit, appendable, utflen); } catch (IOException e) { throw Jvm.rethrow(e); } }
private static void toString(@org.jetbrains.annotations.NotNull @NotNull RandomDataInput bytes, @org.jetbrains.annotations.NotNull @NotNull StringBuilder sb) throws IllegalStateException { bytes.reserve(); assert bytes.start() <= bytes.readPosition(); assert bytes.readPosition() <= bytes.readLimit(); assert bytes.readLimit() <= bytes.realCapacity(); try { for (long i = bytes.readPosition(); i < bytes.readLimit(); i++) { sb.append((char) bytes.readUnsignedByte(i)); } } catch (BufferUnderflowException e) { sb.append(' ').append(e); } bytes.release(); }