@Override default String printable(S handle, long offset) { return handle.printable(offset); }
@Override default String printable(S handle, long offset) { return handle.printable(offset); }
private static void toString(@org.jetbrains.annotations.NotNull @NotNull RandomDataInput bytes, @org.jetbrains.annotations.NotNull @NotNull Appendable sb, long start, long last) throws IOException { for (long i = start; i < last; i++) { sb.append(bytes.printable(i)); } }
/** * {@code Data} implementations should override {@link Object#toString()} with delegation to * this method. Delegates to {@code Data}'s <i>object</i> {@code toString()}, i. e. equivalent * to calling {@code get().toString()} on this {@code Data} instance with some fallback, if * {@code get()} method throws an exception. */ default String dataToString() { try { return get().toString(); } catch (Exception e) { StringBuilder sb = new StringBuilder(); sb.append("failed to deserialize object from data with bytes: ["); RandomDataInput bs = bytes(); for (long off = offset(), lim = offset() + size(); off < lim; off++) { sb.append(bs.printable(off)); } sb.append("], exception: "); StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); String exceptionAsString = sw.toString(); sb.append(exceptionAsString); return sb.toString(); } } }