static final class NotifyingStringBuffer implements CharSequence, Appendable { new StringBuilder builder; long changes; L onChange; public synchronized Appendable append(char c) { builder.append(c); ret change(); } public synchronized Appendable append(CharSequence csq, int start, int end) { builder.append(csq, start, end); ret change(); } public synchronized Appendable append(CharSequence csq) { builder.append(csq); ret change(); } public synchronized void setLength(int i) { builder.setLength(i); change(); } public synchronized void trimToSize() { builder.trimToSize(); } // internal NotifyingStringBuffer change() { ++changes; pcallFAll(onChange); this; } synchronized toString { ret builder.toString(); } public synchronized char charAt(int index) { ret builder.charAt(index); } public synchronized int length() { ret builder.length(); } public synchronized CharSequence subSequence(int start, int end) { ret builder.subSequence(start, end); } synchronized S substring(int start) { ret builder.substring(start); } int capacity() { ret builder.capacity(); } public synchronized void onChange(Runnable r) { onChange = listCreateAndAdd(onChange, r); } }