@@ -0,0 +1,1331 @@
+// SPDX-License-Identifier: MIT%0A// Copyright (C) 2018-present iced project and contributors%0A%0Apackage com.github.icedland.iced.x86.fmt;%0A%0A/**%0A * Formatter output that stores the formatted text in a %7B@link StringBuilder%7D%0A */%0Apublic final class StringOutput extends FormatterOutput %7B%0A%09private final StringBuilder sb;%0A%0A%09/**%0A%09 * Constructor%0A%09 */%0A%09public StringOutput() %7B%0A%09%09sb = new StringBuilder();%0A%09%7D%0A%0A%09/**%0A%09 * Constructor%0A%09 *%0A%09 * @param sb String builder%0A%09 */%0A%09public StringOutput(StringBuilder sb) %7B%0A%09%09if (sb == null)%0A%09%09%09throw new NullPointerException(%22sb%22);%0A%09%09this.sb = sb;%0A%09%7D%0A%0A%09/**%0A%09 * Writes text and text kind%0A%09 *%0A%09 * @param text Text, can be an empty string%0A%09 * @param kind Text kind (a %7B@link FormatterTextKind%7D enum variant)%0A%09 */%0A%09@Override%0A%09public void write(String text, int kind) %7B%0A%09%09sb.append(text);%0A%09%7D%0A%0A%09/**%0A%09 * Clears the %7B@link StringBuilder%7D instance so this class can be reused to format the next instruction%0A%09 */%0A%09public void reset() %7B%0A%09%09sb.setLength(0);%0A%09%7D%0A%0A%09/**%0A%09 * Returns the current formatted text and clears the %7B@link StringBuilder%7D instance so this class can be reused to format the next instruction%0A%09 */%0A%09public String toStringAndReset() %7B%0A%09%09String result = toString();%0A%09%09reset();%0A%09%09return result;%0A%09%7D%0A%0A%09/**%0A%09 * Gets the current output%0A%09 */%0A%09@Override%0A%09public String toString() %7B%0A%09%09return sb.toString();%0A%09%7D%0A%7D%0A

Add Java `StringOutput`